widl: Strip last separator in append_namespaces if suffix is NULL.
[wine.git] / dlls / mshtml / htmlarea.c
bloba5ebfe757aed842f64a6ae606d1b3d25f689b31b
1 /*
2 * Copyright 2015 Alex Henrie
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 struct HTMLAreaElement {
37 HTMLElement element;
39 IHTMLAreaElement IHTMLAreaElement_iface;
41 nsIDOMHTMLAreaElement *nsarea;
44 static inline HTMLAreaElement *impl_from_IHTMLAreaElement(IHTMLAreaElement *iface)
46 return CONTAINING_RECORD(iface, HTMLAreaElement, IHTMLAreaElement_iface);
49 static HRESULT WINAPI HTMLAreaElement_QueryInterface(IHTMLAreaElement *iface, REFIID riid, void **ppv)
51 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
53 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
56 static ULONG WINAPI HTMLAreaElement_AddRef(IHTMLAreaElement *iface)
58 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
60 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLAreaElement_Release(IHTMLAreaElement *iface)
65 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
67 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
70 static HRESULT WINAPI HTMLAreaElement_GetTypeInfoCount(IHTMLAreaElement *iface, UINT *pctinfo)
72 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
73 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
76 static HRESULT WINAPI HTMLAreaElement_GetTypeInfo(IHTMLAreaElement *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
80 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
81 ppTInfo);
84 static HRESULT WINAPI HTMLAreaElement_GetIDsOfNames(IHTMLAreaElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames,
86 LCID lcid, DISPID *rgDispId)
88 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
89 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
90 cNames, lcid, rgDispId);
93 static HRESULT WINAPI HTMLAreaElement_Invoke(IHTMLAreaElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
98 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
99 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
102 static HRESULT WINAPI HTMLAreaElement_put_shape(IHTMLAreaElement *iface, BSTR v)
104 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
105 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
106 return E_NOTIMPL;
109 static HRESULT WINAPI HTMLAreaElement_get_shape(IHTMLAreaElement *iface, BSTR *p)
111 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
112 FIXME("(%p)->(%p)\n", This, p);
113 return E_NOTIMPL;
116 static HRESULT WINAPI HTMLAreaElement_put_coords(IHTMLAreaElement *iface, BSTR v)
118 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
119 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
120 return E_NOTIMPL;
123 static HRESULT WINAPI HTMLAreaElement_get_coords(IHTMLAreaElement *iface, BSTR *p)
125 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
126 FIXME("(%p)->(%p)\n", This, p);
127 return E_NOTIMPL;
130 static HRESULT WINAPI HTMLAreaElement_put_href(IHTMLAreaElement *iface, BSTR v)
132 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
133 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
134 return E_NOTIMPL;
137 static HRESULT WINAPI HTMLAreaElement_get_href(IHTMLAreaElement *iface, BSTR *p)
139 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
140 FIXME("(%p)->(%p)\n", This, p);
141 return E_NOTIMPL;
144 static HRESULT WINAPI HTMLAreaElement_put_target(IHTMLAreaElement *iface, BSTR v)
146 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
147 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
148 return E_NOTIMPL;
151 static HRESULT WINAPI HTMLAreaElement_get_target(IHTMLAreaElement *iface, BSTR *p)
153 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
154 FIXME("(%p)->(%p)\n", This, p);
155 return E_NOTIMPL;
158 static HRESULT WINAPI HTMLAreaElement_put_alt(IHTMLAreaElement *iface, BSTR v)
160 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
161 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
162 return E_NOTIMPL;
165 static HRESULT WINAPI HTMLAreaElement_get_alt(IHTMLAreaElement *iface, BSTR *p)
167 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
168 FIXME("(%p)->(%p)\n", This, p);
169 return E_NOTIMPL;
172 static HRESULT WINAPI HTMLAreaElement_put_noHref(IHTMLAreaElement *iface, VARIANT_BOOL v)
174 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
175 FIXME("(%p)->(%i)\n", This, v);
176 return E_NOTIMPL;
179 static HRESULT WINAPI HTMLAreaElement_get_noHref(IHTMLAreaElement *iface, VARIANT_BOOL *p)
181 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
182 FIXME("(%p)->(%p)\n", This, p);
183 return E_NOTIMPL;
186 static HRESULT WINAPI HTMLAreaElement_put_host(IHTMLAreaElement *iface, BSTR v)
188 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
189 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
190 return E_NOTIMPL;
193 static HRESULT WINAPI HTMLAreaElement_get_host(IHTMLAreaElement *iface, BSTR *p)
195 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
196 FIXME("(%p)->(%p)\n", This, p);
197 return E_NOTIMPL;
200 static HRESULT WINAPI HTMLAreaElement_put_hostname(IHTMLAreaElement *iface, BSTR v)
202 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
203 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
204 return E_NOTIMPL;
207 static HRESULT WINAPI HTMLAreaElement_get_hostname(IHTMLAreaElement *iface, BSTR *p)
209 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
210 FIXME("(%p)->(%p)\n", This, p);
211 return E_NOTIMPL;
214 static HRESULT WINAPI HTMLAreaElement_put_pathname(IHTMLAreaElement *iface, BSTR v)
216 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
217 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
218 return E_NOTIMPL;
221 static HRESULT WINAPI HTMLAreaElement_get_pathname(IHTMLAreaElement *iface, BSTR *p)
223 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
224 FIXME("(%p)->(%p)\n", This, p);
225 return E_NOTIMPL;
228 static HRESULT WINAPI HTMLAreaElement_put_port(IHTMLAreaElement *iface, BSTR v)
230 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
231 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
232 return E_NOTIMPL;
235 static HRESULT WINAPI HTMLAreaElement_get_port(IHTMLAreaElement *iface, BSTR *p)
237 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
238 FIXME("(%p)->(%p)\n", This, p);
239 return E_NOTIMPL;
242 static HRESULT WINAPI HTMLAreaElement_put_protocol(IHTMLAreaElement *iface, BSTR v)
244 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
245 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
246 return E_NOTIMPL;
249 static HRESULT WINAPI HTMLAreaElement_get_protocol(IHTMLAreaElement *iface, BSTR *p)
251 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
252 FIXME("(%p)->(%p)\n", This, p);
253 return E_NOTIMPL;
256 static HRESULT WINAPI HTMLAreaElement_put_search(IHTMLAreaElement *iface, BSTR v)
258 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
259 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
260 return E_NOTIMPL;
263 static HRESULT WINAPI HTMLAreaElement_get_search(IHTMLAreaElement *iface, BSTR *p)
265 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
266 FIXME("(%p)->(%p)\n", This, p);
267 return E_NOTIMPL;
270 static HRESULT WINAPI HTMLAreaElement_put_hash(IHTMLAreaElement *iface, BSTR v)
272 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
273 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
274 return E_NOTIMPL;
277 static HRESULT WINAPI HTMLAreaElement_get_hash(IHTMLAreaElement *iface, BSTR *p)
279 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
280 FIXME("(%p)->(%p)\n", This, p);
281 return E_NOTIMPL;
284 static HRESULT WINAPI HTMLAreaElement_put_onblur(IHTMLAreaElement *iface, VARIANT v)
286 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
287 FIXME("(%p)->(%p)\n", This, &v);
288 return E_NOTIMPL;
291 static HRESULT WINAPI HTMLAreaElement_get_onblur(IHTMLAreaElement *iface, VARIANT *p)
293 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
294 FIXME("(%p)->(%p)\n", This, p);
295 return E_NOTIMPL;
298 static HRESULT WINAPI HTMLAreaElement_put_onfocus(IHTMLAreaElement *iface, VARIANT v)
300 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
301 FIXME("(%p)->(%p)\n", This, &v);
302 return E_NOTIMPL;
305 static HRESULT WINAPI HTMLAreaElement_get_onfocus(IHTMLAreaElement *iface, VARIANT *p)
307 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
308 FIXME("(%p)->(%p)\n", This, p);
309 return E_NOTIMPL;
312 static HRESULT WINAPI HTMLAreaElement_put_tabIndex(IHTMLAreaElement *iface, short v)
314 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
315 FIXME("(%p)->(%i)\n", This, v);
316 return E_NOTIMPL;
319 static HRESULT WINAPI HTMLAreaElement_get_tabIndex(IHTMLAreaElement *iface, short *p)
321 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
322 FIXME("(%p)->(%p)\n", This, p);
323 return E_NOTIMPL;
326 static HRESULT WINAPI HTMLAreaElement_focus(IHTMLAreaElement *iface)
328 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
329 FIXME("(%p)\n", This);
330 return E_NOTIMPL;
333 static HRESULT WINAPI HTMLAreaElement_blur(IHTMLAreaElement *iface)
335 HTMLAreaElement *This = impl_from_IHTMLAreaElement(iface);
336 FIXME("(%p)\n", This);
337 return E_NOTIMPL;
340 static const IHTMLAreaElementVtbl HTMLAreaElementVtbl = {
341 HTMLAreaElement_QueryInterface,
342 HTMLAreaElement_AddRef,
343 HTMLAreaElement_Release,
344 HTMLAreaElement_GetTypeInfoCount,
345 HTMLAreaElement_GetTypeInfo,
346 HTMLAreaElement_GetIDsOfNames,
347 HTMLAreaElement_Invoke,
348 HTMLAreaElement_put_shape,
349 HTMLAreaElement_get_shape,
350 HTMLAreaElement_put_coords,
351 HTMLAreaElement_get_coords,
352 HTMLAreaElement_put_href,
353 HTMLAreaElement_get_href,
354 HTMLAreaElement_put_target,
355 HTMLAreaElement_get_target,
356 HTMLAreaElement_put_alt,
357 HTMLAreaElement_get_alt,
358 HTMLAreaElement_put_noHref,
359 HTMLAreaElement_get_noHref,
360 HTMLAreaElement_put_host,
361 HTMLAreaElement_get_host,
362 HTMLAreaElement_put_hostname,
363 HTMLAreaElement_get_hostname,
364 HTMLAreaElement_put_pathname,
365 HTMLAreaElement_get_pathname,
366 HTMLAreaElement_put_port,
367 HTMLAreaElement_get_port,
368 HTMLAreaElement_put_protocol,
369 HTMLAreaElement_get_protocol,
370 HTMLAreaElement_put_search,
371 HTMLAreaElement_get_search,
372 HTMLAreaElement_put_hash,
373 HTMLAreaElement_get_hash,
374 HTMLAreaElement_put_onblur,
375 HTMLAreaElement_get_onblur,
376 HTMLAreaElement_put_onfocus,
377 HTMLAreaElement_get_onfocus,
378 HTMLAreaElement_put_tabIndex,
379 HTMLAreaElement_get_tabIndex,
380 HTMLAreaElement_focus,
381 HTMLAreaElement_blur
384 static inline HTMLAreaElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
386 return CONTAINING_RECORD(iface, HTMLAreaElement, element.node);
389 static HRESULT HTMLAreaElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
391 HTMLAreaElement *This = impl_from_HTMLDOMNode(iface);
393 *ppv = NULL;
395 if(IsEqualGUID(&IID_IHTMLAreaElement, riid)) {
396 TRACE("(%p)->(IID_IHTMLAreaElement %p)\n", This, ppv);
397 *ppv = &This->IHTMLAreaElement_iface;
398 }else {
399 return HTMLElement_QI(&This->element.node, riid, ppv);
402 IUnknown_AddRef((IUnknown*)*ppv);
403 return S_OK;
406 static HRESULT HTMLAreaElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
408 HTMLAreaElement *This = impl_from_HTMLDOMNode(iface);
409 nsAString href_str, target_str;
410 nsresult nsres;
412 if(eid == EVENTID_CLICK) {
413 nsAString_Init(&href_str, NULL);
414 nsres = nsIDOMHTMLAreaElement_GetHref(This->nsarea, &href_str);
415 if (NS_FAILED(nsres)) {
416 ERR("Could not get area href: %08x\n", nsres);
417 goto fallback;
420 nsAString_Init(&target_str, NULL);
421 nsres = nsIDOMHTMLAreaElement_GetTarget(This->nsarea, &target_str);
422 if (NS_FAILED(nsres)) {
423 ERR("Could not get area target: %08x\n", nsres);
424 goto fallback;
427 return handle_link_click_event(&This->element, &href_str, &target_str, event, prevent_default);
429 fallback:
430 nsAString_Finish(&href_str);
431 nsAString_Finish(&target_str);
434 return HTMLElement_handle_event(&This->element.node, eid, event, prevent_default);
437 static const NodeImplVtbl HTMLAreaElementImplVtbl = {
438 &CLSID_HTMLAreaElement,
439 HTMLAreaElement_QI,
440 HTMLElement_destructor,
441 HTMLElement_cpc,
442 HTMLElement_clone,
443 HTMLAreaElement_handle_event,
444 HTMLElement_get_attr_col
447 static const tid_t HTMLAreaElement_iface_tids[] = {
448 HTMLELEMENT_TIDS,
449 IHTMLAreaElement_tid,
452 static dispex_static_data_t HTMLAreaElement_dispex = {
453 NULL,
454 DispHTMLAreaElement_tid,
455 HTMLAreaElement_iface_tids,
456 HTMLElement_init_dispex_info
459 HRESULT HTMLAreaElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
461 HTMLAreaElement *ret;
462 nsresult nsres;
464 ret = heap_alloc_zero(sizeof(HTMLAreaElement));
465 if(!ret)
466 return E_OUTOFMEMORY;
468 ret->IHTMLAreaElement_iface.lpVtbl = &HTMLAreaElementVtbl;
469 ret->element.node.vtbl = &HTMLAreaElementImplVtbl;
471 HTMLElement_Init(&ret->element, doc, nselem, &HTMLAreaElement_dispex);
473 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLAreaElement, (void**)&ret->nsarea);
474 assert(nsres == NS_OK);
476 *elem = &ret->element;
477 return S_OK;