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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
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
,
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
));
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
);
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
));
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
);
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
));
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
);
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
));
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
);
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
));
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
);
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
);
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
);
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
));
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
);
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
));
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
);
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
));
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
);
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
));
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
);
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
));
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
);
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
));
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
);
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
));
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
);
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
);
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
);
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
);
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
);
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
);
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
);
326 static HRESULT WINAPI
HTMLAreaElement_focus(IHTMLAreaElement
*iface
)
328 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
329 FIXME("(%p)\n", This
);
333 static HRESULT WINAPI
HTMLAreaElement_blur(IHTMLAreaElement
*iface
)
335 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
336 FIXME("(%p)\n", This
);
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
,
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
);
395 if(IsEqualGUID(&IID_IHTMLAreaElement
, riid
)) {
396 TRACE("(%p)->(IID_IHTMLAreaElement %p)\n", This
, ppv
);
397 *ppv
= &This
->IHTMLAreaElement_iface
;
399 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
402 IUnknown_AddRef((IUnknown
*)*ppv
);
406 static HRESULT
HTMLAreaElement_handle_event(HTMLDOMNode
*iface
, eventid_t eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
408 HTMLAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
409 nsAString href_str
, target_str
;
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
);
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
);
427 return handle_link_click_event(&This
->element
, &href_str
, &target_str
, event
, prevent_default
);
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
= {
439 HTMLElement_destructor
,
442 HTMLAreaElement_handle_event
,
443 HTMLElement_get_attr_col
446 static const tid_t HTMLAreaElement_iface_tids
[] = {
448 IHTMLAreaElement_tid
,
451 static dispex_static_data_t HTMLAreaElement_dispex
= {
453 DispHTMLAreaElement_tid
,
454 HTMLAreaElement_iface_tids
,
455 HTMLElement_init_dispex_info
458 HRESULT
HTMLAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
460 HTMLAreaElement
*ret
;
463 ret
= heap_alloc_zero(sizeof(HTMLAreaElement
));
465 return E_OUTOFMEMORY
;
467 ret
->IHTMLAreaElement_iface
.lpVtbl
= &HTMLAreaElementVtbl
;
468 ret
->element
.node
.vtbl
= &HTMLAreaElementImplVtbl
;
470 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAreaElement_dispex
);
472 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAreaElement
, (void**)&ret
->nsarea
);
473 assert(nsres
== NS_OK
);
475 *elem
= &ret
->element
;