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 "mshtml_private.h"
24 IHTMLAreaElement IHTMLAreaElement_iface
;
26 nsIDOMHTMLAreaElement
*nsarea
;
29 static inline HTMLAreaElement
*impl_from_IHTMLAreaElement(IHTMLAreaElement
*iface
)
31 return CONTAINING_RECORD(iface
, HTMLAreaElement
, IHTMLAreaElement_iface
);
34 static HRESULT WINAPI
HTMLAreaElement_QueryInterface(IHTMLAreaElement
*iface
, REFIID riid
, void **ppv
)
36 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
38 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
41 static ULONG WINAPI
HTMLAreaElement_AddRef(IHTMLAreaElement
*iface
)
43 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
45 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
48 static ULONG WINAPI
HTMLAreaElement_Release(IHTMLAreaElement
*iface
)
50 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
52 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
55 static HRESULT WINAPI
HTMLAreaElement_GetTypeInfoCount(IHTMLAreaElement
*iface
, UINT
*pctinfo
)
57 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
58 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
61 static HRESULT WINAPI
HTMLAreaElement_GetTypeInfo(IHTMLAreaElement
*iface
, UINT iTInfo
,
62 LCID lcid
, ITypeInfo
**ppTInfo
)
64 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
65 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
69 static HRESULT WINAPI
HTMLAreaElement_GetIDsOfNames(IHTMLAreaElement
*iface
, REFIID riid
,
70 LPOLESTR
*rgszNames
, UINT cNames
,
71 LCID lcid
, DISPID
*rgDispId
)
73 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
74 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
75 cNames
, lcid
, rgDispId
);
78 static HRESULT WINAPI
HTMLAreaElement_Invoke(IHTMLAreaElement
*iface
, DISPID dispIdMember
,
79 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
80 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
82 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
83 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
84 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
87 static HRESULT WINAPI
HTMLAreaElement_put_shape(IHTMLAreaElement
*iface
, BSTR v
)
89 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
90 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
94 static HRESULT WINAPI
HTMLAreaElement_get_shape(IHTMLAreaElement
*iface
, BSTR
*p
)
96 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
97 FIXME("(%p)->(%p)\n", This
, p
);
101 static HRESULT WINAPI
HTMLAreaElement_put_coords(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_coords(IHTMLAreaElement
*iface
, BSTR
*p
)
110 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
111 FIXME("(%p)->(%p)\n", This
, p
);
115 static HRESULT WINAPI
HTMLAreaElement_put_href(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_href(IHTMLAreaElement
*iface
, BSTR
*p
)
124 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
125 FIXME("(%p)->(%p)\n", This
, p
);
129 static HRESULT WINAPI
HTMLAreaElement_put_target(IHTMLAreaElement
*iface
, BSTR v
)
131 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
132 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
136 static HRESULT WINAPI
HTMLAreaElement_get_target(IHTMLAreaElement
*iface
, BSTR
*p
)
138 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
139 FIXME("(%p)->(%p)\n", This
, p
);
143 static HRESULT WINAPI
HTMLAreaElement_put_alt(IHTMLAreaElement
*iface
, BSTR v
)
145 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
146 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
150 static HRESULT WINAPI
HTMLAreaElement_get_alt(IHTMLAreaElement
*iface
, BSTR
*p
)
152 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
153 FIXME("(%p)->(%p)\n", This
, p
);
157 static HRESULT WINAPI
HTMLAreaElement_put_noHref(IHTMLAreaElement
*iface
, VARIANT_BOOL v
)
159 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
160 FIXME("(%p)->(%i)\n", This
, v
);
164 static HRESULT WINAPI
HTMLAreaElement_get_noHref(IHTMLAreaElement
*iface
, VARIANT_BOOL
*p
)
166 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
167 FIXME("(%p)->(%p)\n", This
, p
);
171 static HRESULT WINAPI
HTMLAreaElement_put_host(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_host(IHTMLAreaElement
*iface
, BSTR
*p
)
180 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
181 FIXME("(%p)->(%p)\n", This
, p
);
185 static HRESULT WINAPI
HTMLAreaElement_put_hostname(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_hostname(IHTMLAreaElement
*iface
, BSTR
*p
)
194 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
195 FIXME("(%p)->(%p)\n", This
, p
);
199 static HRESULT WINAPI
HTMLAreaElement_put_pathname(IHTMLAreaElement
*iface
, BSTR v
)
201 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
202 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
206 static HRESULT WINAPI
HTMLAreaElement_get_pathname(IHTMLAreaElement
*iface
, BSTR
*p
)
208 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
209 FIXME("(%p)->(%p)\n", This
, p
);
213 static HRESULT WINAPI
HTMLAreaElement_put_port(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_port(IHTMLAreaElement
*iface
, BSTR
*p
)
222 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
223 FIXME("(%p)->(%p)\n", This
, p
);
227 static HRESULT WINAPI
HTMLAreaElement_put_protocol(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_protocol(IHTMLAreaElement
*iface
, BSTR
*p
)
236 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
237 FIXME("(%p)->(%p)\n", This
, p
);
241 static HRESULT WINAPI
HTMLAreaElement_put_search(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_search(IHTMLAreaElement
*iface
, BSTR
*p
)
250 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
251 FIXME("(%p)->(%p)\n", This
, p
);
255 static HRESULT WINAPI
HTMLAreaElement_put_hash(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_hash(IHTMLAreaElement
*iface
, BSTR
*p
)
264 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
265 FIXME("(%p)->(%p)\n", This
, p
);
269 static HRESULT WINAPI
HTMLAreaElement_put_onblur(IHTMLAreaElement
*iface
, VARIANT v
)
271 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
272 FIXME("(%p)->(%p)\n", This
, &v
);
276 static HRESULT WINAPI
HTMLAreaElement_get_onblur(IHTMLAreaElement
*iface
, VARIANT
*p
)
278 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
279 FIXME("(%p)->(%p)\n", This
, p
);
283 static HRESULT WINAPI
HTMLAreaElement_put_onfocus(IHTMLAreaElement
*iface
, VARIANT v
)
285 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
286 FIXME("(%p)->(%p)\n", This
, &v
);
290 static HRESULT WINAPI
HTMLAreaElement_get_onfocus(IHTMLAreaElement
*iface
, VARIANT
*p
)
292 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
293 FIXME("(%p)->(%p)\n", This
, p
);
297 static HRESULT WINAPI
HTMLAreaElement_put_tabIndex(IHTMLAreaElement
*iface
, short v
)
299 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
300 FIXME("(%p)->(%i)\n", This
, v
);
304 static HRESULT WINAPI
HTMLAreaElement_get_tabIndex(IHTMLAreaElement
*iface
, short *p
)
306 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
307 FIXME("(%p)->(%p)\n", This
, p
);
311 static HRESULT WINAPI
HTMLAreaElement_focus(IHTMLAreaElement
*iface
)
313 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
314 FIXME("(%p)\n", This
);
318 static HRESULT WINAPI
HTMLAreaElement_blur(IHTMLAreaElement
*iface
)
320 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
321 FIXME("(%p)\n", This
);
325 static const IHTMLAreaElementVtbl HTMLAreaElementVtbl
= {
326 HTMLAreaElement_QueryInterface
,
327 HTMLAreaElement_AddRef
,
328 HTMLAreaElement_Release
,
329 HTMLAreaElement_GetTypeInfoCount
,
330 HTMLAreaElement_GetTypeInfo
,
331 HTMLAreaElement_GetIDsOfNames
,
332 HTMLAreaElement_Invoke
,
333 HTMLAreaElement_put_shape
,
334 HTMLAreaElement_get_shape
,
335 HTMLAreaElement_put_coords
,
336 HTMLAreaElement_get_coords
,
337 HTMLAreaElement_put_href
,
338 HTMLAreaElement_get_href
,
339 HTMLAreaElement_put_target
,
340 HTMLAreaElement_get_target
,
341 HTMLAreaElement_put_alt
,
342 HTMLAreaElement_get_alt
,
343 HTMLAreaElement_put_noHref
,
344 HTMLAreaElement_get_noHref
,
345 HTMLAreaElement_put_host
,
346 HTMLAreaElement_get_host
,
347 HTMLAreaElement_put_hostname
,
348 HTMLAreaElement_get_hostname
,
349 HTMLAreaElement_put_pathname
,
350 HTMLAreaElement_get_pathname
,
351 HTMLAreaElement_put_port
,
352 HTMLAreaElement_get_port
,
353 HTMLAreaElement_put_protocol
,
354 HTMLAreaElement_get_protocol
,
355 HTMLAreaElement_put_search
,
356 HTMLAreaElement_get_search
,
357 HTMLAreaElement_put_hash
,
358 HTMLAreaElement_get_hash
,
359 HTMLAreaElement_put_onblur
,
360 HTMLAreaElement_get_onblur
,
361 HTMLAreaElement_put_onfocus
,
362 HTMLAreaElement_get_onfocus
,
363 HTMLAreaElement_put_tabIndex
,
364 HTMLAreaElement_get_tabIndex
,
365 HTMLAreaElement_focus
,
369 static inline HTMLAreaElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
371 return CONTAINING_RECORD(iface
, HTMLAreaElement
, element
.node
);
374 static HRESULT
HTMLAreaElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
376 HTMLAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
380 if(IsEqualGUID(&IID_IHTMLAreaElement
, riid
)) {
381 TRACE("(%p)->(IID_IHTMLAreaElement %p)\n", This
, ppv
);
382 *ppv
= &This
->IHTMLAreaElement_iface
;
384 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
387 IUnknown_AddRef((IUnknown
*)*ppv
);
391 static HRESULT
HTMLAreaElement_handle_event(HTMLDOMNode
*iface
, DWORD eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
393 HTMLAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
394 nsAString href_str
, target_str
;
397 if(eid
== EVENTID_CLICK
) {
398 nsAString_Init(&href_str
, NULL
);
399 nsres
= nsIDOMHTMLAreaElement_GetHref(This
->nsarea
, &href_str
);
400 if (NS_FAILED(nsres
)) {
401 ERR("Could not get area href: %08x\n", nsres
);
405 nsAString_Init(&target_str
, NULL
);
406 nsres
= nsIDOMHTMLAreaElement_GetTarget(This
->nsarea
, &target_str
);
407 if (NS_FAILED(nsres
)) {
408 ERR("Could not get area target: %08x\n", nsres
);
412 return handle_link_click_event(&This
->element
, &href_str
, &target_str
, event
, prevent_default
);
415 nsAString_Finish(&href_str
);
416 nsAString_Finish(&target_str
);
419 return HTMLElement_handle_event(&This
->element
.node
, eid
, event
, prevent_default
);
422 static const NodeImplVtbl HTMLAreaElementImplVtbl
= {
424 HTMLElement_destructor
,
427 HTMLAreaElement_handle_event
,
428 HTMLElement_get_attr_col
431 static const tid_t HTMLAreaElement_iface_tids
[] = {
433 IHTMLAreaElement_tid
,
436 static dispex_static_data_t HTMLAreaElement_dispex
= {
438 DispHTMLAreaElement_tid
,
440 HTMLAreaElement_iface_tids
443 HRESULT
HTMLAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
445 HTMLAreaElement
*ret
;
448 ret
= heap_alloc_zero(sizeof(HTMLAreaElement
));
450 return E_OUTOFMEMORY
;
452 ret
->IHTMLAreaElement_iface
.lpVtbl
= &HTMLAreaElementVtbl
;
453 ret
->element
.node
.vtbl
= &HTMLAreaElementImplVtbl
;
455 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAreaElement_dispex
);
457 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAreaElement
, (void**)&ret
->nsarea
);
458 assert(nsres
== NS_OK
);
460 *elem
= &ret
->element
;