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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
31 #include "htmlevent.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
35 struct HTMLAreaElement
{
38 IHTMLAreaElement IHTMLAreaElement_iface
;
40 nsIDOMHTMLAreaElement
*nsarea
;
43 static inline HTMLAreaElement
*impl_from_IHTMLAreaElement(IHTMLAreaElement
*iface
)
45 return CONTAINING_RECORD(iface
, HTMLAreaElement
, IHTMLAreaElement_iface
);
48 static HRESULT WINAPI
HTMLAreaElement_QueryInterface(IHTMLAreaElement
*iface
, REFIID riid
, void **ppv
)
50 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
52 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
55 static ULONG WINAPI
HTMLAreaElement_AddRef(IHTMLAreaElement
*iface
)
57 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
59 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
62 static ULONG WINAPI
HTMLAreaElement_Release(IHTMLAreaElement
*iface
)
64 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
66 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
69 static HRESULT WINAPI
HTMLAreaElement_GetTypeInfoCount(IHTMLAreaElement
*iface
, UINT
*pctinfo
)
71 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
72 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
75 static HRESULT WINAPI
HTMLAreaElement_GetTypeInfo(IHTMLAreaElement
*iface
, UINT iTInfo
,
76 LCID lcid
, ITypeInfo
**ppTInfo
)
78 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
79 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
83 static HRESULT WINAPI
HTMLAreaElement_GetIDsOfNames(IHTMLAreaElement
*iface
, REFIID riid
,
84 LPOLESTR
*rgszNames
, UINT cNames
,
85 LCID lcid
, DISPID
*rgDispId
)
87 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
88 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
89 cNames
, lcid
, rgDispId
);
92 static HRESULT WINAPI
HTMLAreaElement_Invoke(IHTMLAreaElement
*iface
, DISPID dispIdMember
,
93 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
94 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
96 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
97 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
98 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
101 static HRESULT WINAPI
HTMLAreaElement_put_shape(IHTMLAreaElement
*iface
, BSTR v
)
103 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
104 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
108 static HRESULT WINAPI
HTMLAreaElement_get_shape(IHTMLAreaElement
*iface
, BSTR
*p
)
110 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
111 FIXME("(%p)->(%p)\n", This
, p
);
115 static HRESULT WINAPI
HTMLAreaElement_put_coords(IHTMLAreaElement
*iface
, BSTR v
)
117 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
118 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
122 static HRESULT WINAPI
HTMLAreaElement_get_coords(IHTMLAreaElement
*iface
, BSTR
*p
)
124 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
125 FIXME("(%p)->(%p)\n", This
, p
);
129 static HRESULT WINAPI
HTMLAreaElement_put_href(IHTMLAreaElement
*iface
, BSTR v
)
131 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
135 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
137 nsAString_InitDepend(&nsstr
, v
);
138 nsres
= nsIDOMHTMLAreaElement_SetHref(This
->nsarea
, &nsstr
);
139 nsAString_Finish(&nsstr
);
146 static HRESULT WINAPI
HTMLAreaElement_get_href(IHTMLAreaElement
*iface
, BSTR
*p
)
148 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
153 TRACE("(%p)->(%p)\n", This
, p
);
155 nsAString_Init(&href_str
, NULL
);
156 nsres
= nsIDOMHTMLAreaElement_GetHref(This
->nsarea
, &href_str
);
157 if(NS_SUCCEEDED(nsres
)) {
158 const PRUnichar
*href
;
160 nsAString_GetData(&href_str
, &href
);
161 hres
= nsuri_to_url(href
, TRUE
, p
);
163 ERR("GetHref failed: %08lx\n", nsres
);
167 nsAString_Finish(&href_str
);
171 static HRESULT WINAPI
HTMLAreaElement_put_target(IHTMLAreaElement
*iface
, BSTR v
)
173 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
174 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
178 static HRESULT WINAPI
HTMLAreaElement_get_target(IHTMLAreaElement
*iface
, BSTR
*p
)
180 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
181 FIXME("(%p)->(%p)\n", This
, p
);
185 static HRESULT WINAPI
HTMLAreaElement_put_alt(IHTMLAreaElement
*iface
, BSTR v
)
187 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
188 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
192 static HRESULT WINAPI
HTMLAreaElement_get_alt(IHTMLAreaElement
*iface
, BSTR
*p
)
194 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
195 FIXME("(%p)->(%p)\n", This
, p
);
199 static HRESULT WINAPI
HTMLAreaElement_put_noHref(IHTMLAreaElement
*iface
, VARIANT_BOOL v
)
201 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
202 FIXME("(%p)->(%i)\n", This
, v
);
206 static HRESULT WINAPI
HTMLAreaElement_get_noHref(IHTMLAreaElement
*iface
, VARIANT_BOOL
*p
)
208 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
209 FIXME("(%p)->(%p)\n", This
, p
);
213 static HRESULT WINAPI
HTMLAreaElement_put_host(IHTMLAreaElement
*iface
, BSTR v
)
215 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
216 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
220 static HRESULT WINAPI
HTMLAreaElement_get_host(IHTMLAreaElement
*iface
, BSTR
*p
)
222 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
223 FIXME("(%p)->(%p)\n", This
, p
);
227 static HRESULT WINAPI
HTMLAreaElement_put_hostname(IHTMLAreaElement
*iface
, BSTR v
)
229 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
230 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
234 static HRESULT WINAPI
HTMLAreaElement_get_hostname(IHTMLAreaElement
*iface
, BSTR
*p
)
236 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
237 FIXME("(%p)->(%p)\n", This
, p
);
241 static HRESULT WINAPI
HTMLAreaElement_put_pathname(IHTMLAreaElement
*iface
, BSTR v
)
243 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
244 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
248 static HRESULT WINAPI
HTMLAreaElement_get_pathname(IHTMLAreaElement
*iface
, BSTR
*p
)
250 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
251 FIXME("(%p)->(%p)\n", This
, p
);
255 static HRESULT WINAPI
HTMLAreaElement_put_port(IHTMLAreaElement
*iface
, BSTR v
)
257 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
258 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
262 static HRESULT WINAPI
HTMLAreaElement_get_port(IHTMLAreaElement
*iface
, BSTR
*p
)
264 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
265 FIXME("(%p)->(%p)\n", This
, p
);
269 static HRESULT WINAPI
HTMLAreaElement_put_protocol(IHTMLAreaElement
*iface
, BSTR v
)
271 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
272 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
276 static HRESULT WINAPI
HTMLAreaElement_get_protocol(IHTMLAreaElement
*iface
, BSTR
*p
)
278 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
279 FIXME("(%p)->(%p)\n", This
, p
);
283 static HRESULT WINAPI
HTMLAreaElement_put_search(IHTMLAreaElement
*iface
, BSTR v
)
285 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
286 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
290 static HRESULT WINAPI
HTMLAreaElement_get_search(IHTMLAreaElement
*iface
, BSTR
*p
)
292 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
293 FIXME("(%p)->(%p)\n", This
, p
);
297 static HRESULT WINAPI
HTMLAreaElement_put_hash(IHTMLAreaElement
*iface
, BSTR v
)
299 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
300 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
304 static HRESULT WINAPI
HTMLAreaElement_get_hash(IHTMLAreaElement
*iface
, BSTR
*p
)
306 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
307 FIXME("(%p)->(%p)\n", This
, p
);
311 static HRESULT WINAPI
HTMLAreaElement_put_onblur(IHTMLAreaElement
*iface
, VARIANT v
)
313 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
314 FIXME("(%p)->(%p)\n", This
, &v
);
318 static HRESULT WINAPI
HTMLAreaElement_get_onblur(IHTMLAreaElement
*iface
, VARIANT
*p
)
320 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
321 FIXME("(%p)->(%p)\n", This
, p
);
325 static HRESULT WINAPI
HTMLAreaElement_put_onfocus(IHTMLAreaElement
*iface
, VARIANT v
)
327 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
328 FIXME("(%p)->(%p)\n", This
, &v
);
332 static HRESULT WINAPI
HTMLAreaElement_get_onfocus(IHTMLAreaElement
*iface
, VARIANT
*p
)
334 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
335 FIXME("(%p)->(%p)\n", This
, p
);
339 static HRESULT WINAPI
HTMLAreaElement_put_tabIndex(IHTMLAreaElement
*iface
, short v
)
341 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
342 FIXME("(%p)->(%i)\n", This
, v
);
346 static HRESULT WINAPI
HTMLAreaElement_get_tabIndex(IHTMLAreaElement
*iface
, short *p
)
348 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
349 FIXME("(%p)->(%p)\n", This
, p
);
353 static HRESULT WINAPI
HTMLAreaElement_focus(IHTMLAreaElement
*iface
)
355 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
356 FIXME("(%p)\n", This
);
360 static HRESULT WINAPI
HTMLAreaElement_blur(IHTMLAreaElement
*iface
)
362 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
363 FIXME("(%p)\n", This
);
367 static const IHTMLAreaElementVtbl HTMLAreaElementVtbl
= {
368 HTMLAreaElement_QueryInterface
,
369 HTMLAreaElement_AddRef
,
370 HTMLAreaElement_Release
,
371 HTMLAreaElement_GetTypeInfoCount
,
372 HTMLAreaElement_GetTypeInfo
,
373 HTMLAreaElement_GetIDsOfNames
,
374 HTMLAreaElement_Invoke
,
375 HTMLAreaElement_put_shape
,
376 HTMLAreaElement_get_shape
,
377 HTMLAreaElement_put_coords
,
378 HTMLAreaElement_get_coords
,
379 HTMLAreaElement_put_href
,
380 HTMLAreaElement_get_href
,
381 HTMLAreaElement_put_target
,
382 HTMLAreaElement_get_target
,
383 HTMLAreaElement_put_alt
,
384 HTMLAreaElement_get_alt
,
385 HTMLAreaElement_put_noHref
,
386 HTMLAreaElement_get_noHref
,
387 HTMLAreaElement_put_host
,
388 HTMLAreaElement_get_host
,
389 HTMLAreaElement_put_hostname
,
390 HTMLAreaElement_get_hostname
,
391 HTMLAreaElement_put_pathname
,
392 HTMLAreaElement_get_pathname
,
393 HTMLAreaElement_put_port
,
394 HTMLAreaElement_get_port
,
395 HTMLAreaElement_put_protocol
,
396 HTMLAreaElement_get_protocol
,
397 HTMLAreaElement_put_search
,
398 HTMLAreaElement_get_search
,
399 HTMLAreaElement_put_hash
,
400 HTMLAreaElement_get_hash
,
401 HTMLAreaElement_put_onblur
,
402 HTMLAreaElement_get_onblur
,
403 HTMLAreaElement_put_onfocus
,
404 HTMLAreaElement_get_onfocus
,
405 HTMLAreaElement_put_tabIndex
,
406 HTMLAreaElement_get_tabIndex
,
407 HTMLAreaElement_focus
,
411 static inline HTMLAreaElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
413 return CONTAINING_RECORD(iface
, HTMLAreaElement
, element
.node
);
416 static HRESULT
HTMLAreaElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
418 HTMLAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
422 if(IsEqualGUID(&IID_IHTMLAreaElement
, riid
)) {
423 TRACE("(%p)->(IID_IHTMLAreaElement %p)\n", This
, ppv
);
424 *ppv
= &This
->IHTMLAreaElement_iface
;
426 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
429 IUnknown_AddRef((IUnknown
*)*ppv
);
433 static HRESULT
HTMLAreaElement_handle_event(HTMLDOMNode
*iface
, DWORD eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
435 HTMLAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
436 nsAString href_str
, target_str
;
439 if(eid
== EVENTID_CLICK
) {
440 nsAString_Init(&href_str
, NULL
);
441 nsres
= nsIDOMHTMLAreaElement_GetHref(This
->nsarea
, &href_str
);
442 if (NS_FAILED(nsres
)) {
443 ERR("Could not get area href: %08lx\n", nsres
);
447 nsAString_Init(&target_str
, NULL
);
448 nsres
= nsIDOMHTMLAreaElement_GetTarget(This
->nsarea
, &target_str
);
449 if (NS_FAILED(nsres
)) {
450 ERR("Could not get area target: %08lx\n", nsres
);
454 return handle_link_click_event(&This
->element
, &href_str
, &target_str
, event
, prevent_default
);
457 nsAString_Finish(&href_str
);
458 nsAString_Finish(&target_str
);
461 return HTMLElement_handle_event(&This
->element
.node
, eid
, event
, prevent_default
);
464 static const NodeImplVtbl HTMLAreaElementImplVtbl
= {
465 &CLSID_HTMLAreaElement
,
467 HTMLElement_destructor
,
470 HTMLElement_dispatch_nsevent_hook
,
471 HTMLAreaElement_handle_event
,
472 HTMLElement_get_attr_col
475 static const tid_t HTMLAreaElement_iface_tids
[] = {
477 IHTMLAreaElement_tid
,
480 static dispex_static_data_t HTMLAreaElement_dispex
= {
483 DispHTMLAreaElement_tid
,
484 HTMLAreaElement_iface_tids
,
485 HTMLElement_init_dispex_info
488 HRESULT
HTMLAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
490 HTMLAreaElement
*ret
;
493 ret
= calloc(1, sizeof(HTMLAreaElement
));
495 return E_OUTOFMEMORY
;
497 ret
->IHTMLAreaElement_iface
.lpVtbl
= &HTMLAreaElementVtbl
;
498 ret
->element
.node
.vtbl
= &HTMLAreaElementImplVtbl
;
500 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAreaElement_dispex
);
502 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAreaElement
, (void**)&ret
->nsarea
);
503 assert(nsres
== NS_OK
);
505 *elem
= &ret
->element
;