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 DISPEX_IDISPATCH_IMPL(HTMLAreaElement
, IHTMLAreaElement
,
49 impl_from_IHTMLAreaElement(iface
)->element
.node
.event_target
.dispex
)
51 static HRESULT WINAPI
HTMLAreaElement_put_shape(IHTMLAreaElement
*iface
, BSTR v
)
53 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
54 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
58 static HRESULT WINAPI
HTMLAreaElement_get_shape(IHTMLAreaElement
*iface
, BSTR
*p
)
60 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
61 FIXME("(%p)->(%p)\n", This
, p
);
65 static HRESULT WINAPI
HTMLAreaElement_put_coords(IHTMLAreaElement
*iface
, BSTR v
)
67 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
68 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
72 static HRESULT WINAPI
HTMLAreaElement_get_coords(IHTMLAreaElement
*iface
, BSTR
*p
)
74 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
75 FIXME("(%p)->(%p)\n", This
, p
);
79 static HRESULT WINAPI
HTMLAreaElement_put_href(IHTMLAreaElement
*iface
, BSTR v
)
81 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
85 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
87 nsAString_InitDepend(&nsstr
, v
);
88 nsres
= nsIDOMHTMLAreaElement_SetHref(This
->nsarea
, &nsstr
);
89 nsAString_Finish(&nsstr
);
96 static HRESULT WINAPI
HTMLAreaElement_get_href(IHTMLAreaElement
*iface
, BSTR
*p
)
98 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
103 TRACE("(%p)->(%p)\n", This
, p
);
105 nsAString_Init(&href_str
, NULL
);
106 nsres
= nsIDOMHTMLAreaElement_GetHref(This
->nsarea
, &href_str
);
107 if(NS_SUCCEEDED(nsres
)) {
108 const PRUnichar
*href
;
110 nsAString_GetData(&href_str
, &href
);
111 hres
= nsuri_to_url(href
, TRUE
, p
);
113 ERR("GetHref failed: %08lx\n", nsres
);
117 nsAString_Finish(&href_str
);
121 static HRESULT WINAPI
HTMLAreaElement_put_target(IHTMLAreaElement
*iface
, BSTR v
)
123 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
124 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
128 static HRESULT WINAPI
HTMLAreaElement_get_target(IHTMLAreaElement
*iface
, BSTR
*p
)
130 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
131 FIXME("(%p)->(%p)\n", This
, p
);
135 static HRESULT WINAPI
HTMLAreaElement_put_alt(IHTMLAreaElement
*iface
, BSTR v
)
137 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
138 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
142 static HRESULT WINAPI
HTMLAreaElement_get_alt(IHTMLAreaElement
*iface
, BSTR
*p
)
144 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
145 FIXME("(%p)->(%p)\n", This
, p
);
149 static HRESULT WINAPI
HTMLAreaElement_put_noHref(IHTMLAreaElement
*iface
, VARIANT_BOOL v
)
151 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
152 FIXME("(%p)->(%i)\n", This
, v
);
156 static HRESULT WINAPI
HTMLAreaElement_get_noHref(IHTMLAreaElement
*iface
, VARIANT_BOOL
*p
)
158 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
159 FIXME("(%p)->(%p)\n", This
, p
);
163 static HRESULT WINAPI
HTMLAreaElement_put_host(IHTMLAreaElement
*iface
, BSTR v
)
165 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
166 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
170 static HRESULT WINAPI
HTMLAreaElement_get_host(IHTMLAreaElement
*iface
, BSTR
*p
)
172 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
173 FIXME("(%p)->(%p)\n", This
, p
);
177 static HRESULT WINAPI
HTMLAreaElement_put_hostname(IHTMLAreaElement
*iface
, BSTR v
)
179 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
180 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
184 static HRESULT WINAPI
HTMLAreaElement_get_hostname(IHTMLAreaElement
*iface
, BSTR
*p
)
186 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
187 FIXME("(%p)->(%p)\n", This
, p
);
191 static HRESULT WINAPI
HTMLAreaElement_put_pathname(IHTMLAreaElement
*iface
, BSTR v
)
193 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
194 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
198 static HRESULT WINAPI
HTMLAreaElement_get_pathname(IHTMLAreaElement
*iface
, BSTR
*p
)
200 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
201 FIXME("(%p)->(%p)\n", This
, p
);
205 static HRESULT WINAPI
HTMLAreaElement_put_port(IHTMLAreaElement
*iface
, BSTR v
)
207 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
208 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
212 static HRESULT WINAPI
HTMLAreaElement_get_port(IHTMLAreaElement
*iface
, BSTR
*p
)
214 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
215 FIXME("(%p)->(%p)\n", This
, p
);
219 static HRESULT WINAPI
HTMLAreaElement_put_protocol(IHTMLAreaElement
*iface
, BSTR v
)
221 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
222 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
226 static HRESULT WINAPI
HTMLAreaElement_get_protocol(IHTMLAreaElement
*iface
, BSTR
*p
)
228 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
229 FIXME("(%p)->(%p)\n", This
, p
);
233 static HRESULT WINAPI
HTMLAreaElement_put_search(IHTMLAreaElement
*iface
, BSTR v
)
235 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
236 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
240 static HRESULT WINAPI
HTMLAreaElement_get_search(IHTMLAreaElement
*iface
, BSTR
*p
)
242 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
243 FIXME("(%p)->(%p)\n", This
, p
);
247 static HRESULT WINAPI
HTMLAreaElement_put_hash(IHTMLAreaElement
*iface
, BSTR v
)
249 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
250 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
254 static HRESULT WINAPI
HTMLAreaElement_get_hash(IHTMLAreaElement
*iface
, BSTR
*p
)
256 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
257 FIXME("(%p)->(%p)\n", This
, p
);
261 static HRESULT WINAPI
HTMLAreaElement_put_onblur(IHTMLAreaElement
*iface
, VARIANT v
)
263 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
264 FIXME("(%p)->(%p)\n", This
, &v
);
268 static HRESULT WINAPI
HTMLAreaElement_get_onblur(IHTMLAreaElement
*iface
, VARIANT
*p
)
270 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
271 FIXME("(%p)->(%p)\n", This
, p
);
275 static HRESULT WINAPI
HTMLAreaElement_put_onfocus(IHTMLAreaElement
*iface
, VARIANT v
)
277 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
278 FIXME("(%p)->(%p)\n", This
, &v
);
282 static HRESULT WINAPI
HTMLAreaElement_get_onfocus(IHTMLAreaElement
*iface
, VARIANT
*p
)
284 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
285 FIXME("(%p)->(%p)\n", This
, p
);
289 static HRESULT WINAPI
HTMLAreaElement_put_tabIndex(IHTMLAreaElement
*iface
, short v
)
291 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
292 FIXME("(%p)->(%i)\n", This
, v
);
296 static HRESULT WINAPI
HTMLAreaElement_get_tabIndex(IHTMLAreaElement
*iface
, short *p
)
298 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
299 FIXME("(%p)->(%p)\n", This
, p
);
303 static HRESULT WINAPI
HTMLAreaElement_focus(IHTMLAreaElement
*iface
)
305 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
306 FIXME("(%p)\n", This
);
310 static HRESULT WINAPI
HTMLAreaElement_blur(IHTMLAreaElement
*iface
)
312 HTMLAreaElement
*This
= impl_from_IHTMLAreaElement(iface
);
313 FIXME("(%p)\n", This
);
317 static const IHTMLAreaElementVtbl HTMLAreaElementVtbl
= {
318 HTMLAreaElement_QueryInterface
,
319 HTMLAreaElement_AddRef
,
320 HTMLAreaElement_Release
,
321 HTMLAreaElement_GetTypeInfoCount
,
322 HTMLAreaElement_GetTypeInfo
,
323 HTMLAreaElement_GetIDsOfNames
,
324 HTMLAreaElement_Invoke
,
325 HTMLAreaElement_put_shape
,
326 HTMLAreaElement_get_shape
,
327 HTMLAreaElement_put_coords
,
328 HTMLAreaElement_get_coords
,
329 HTMLAreaElement_put_href
,
330 HTMLAreaElement_get_href
,
331 HTMLAreaElement_put_target
,
332 HTMLAreaElement_get_target
,
333 HTMLAreaElement_put_alt
,
334 HTMLAreaElement_get_alt
,
335 HTMLAreaElement_put_noHref
,
336 HTMLAreaElement_get_noHref
,
337 HTMLAreaElement_put_host
,
338 HTMLAreaElement_get_host
,
339 HTMLAreaElement_put_hostname
,
340 HTMLAreaElement_get_hostname
,
341 HTMLAreaElement_put_pathname
,
342 HTMLAreaElement_get_pathname
,
343 HTMLAreaElement_put_port
,
344 HTMLAreaElement_get_port
,
345 HTMLAreaElement_put_protocol
,
346 HTMLAreaElement_get_protocol
,
347 HTMLAreaElement_put_search
,
348 HTMLAreaElement_get_search
,
349 HTMLAreaElement_put_hash
,
350 HTMLAreaElement_get_hash
,
351 HTMLAreaElement_put_onblur
,
352 HTMLAreaElement_get_onblur
,
353 HTMLAreaElement_put_onfocus
,
354 HTMLAreaElement_get_onfocus
,
355 HTMLAreaElement_put_tabIndex
,
356 HTMLAreaElement_get_tabIndex
,
357 HTMLAreaElement_focus
,
361 static inline HTMLAreaElement
*impl_from_DispatchEx(DispatchEx
*iface
)
363 return CONTAINING_RECORD(iface
, HTMLAreaElement
, element
.node
.event_target
.dispex
);
366 static void *HTMLAreaElement_query_interface(DispatchEx
*dispex
, REFIID riid
)
368 HTMLAreaElement
*This
= impl_from_DispatchEx(dispex
);
370 if(IsEqualGUID(&IID_IHTMLAreaElement
, riid
))
371 return &This
->IHTMLAreaElement_iface
;
373 return HTMLElement_query_interface(&This
->element
.node
.event_target
.dispex
, riid
);
376 static void HTMLAreaElement_traverse(DispatchEx
*dispex
, nsCycleCollectionTraversalCallback
*cb
)
378 HTMLAreaElement
*This
= impl_from_DispatchEx(dispex
);
379 HTMLElement_traverse(dispex
, cb
);
382 note_cc_edge((nsISupports
*)This
->nsarea
, "nsarea", cb
);
385 static void HTMLAreaElement_unlink(DispatchEx
*dispex
)
387 HTMLAreaElement
*This
= impl_from_DispatchEx(dispex
);
388 HTMLElement_unlink(dispex
);
389 unlink_ref(&This
->nsarea
);
392 static HRESULT
HTMLAreaElement_handle_event(DispatchEx
*dispex
, DOMEvent
*event
, BOOL
*prevent_default
)
394 HTMLAreaElement
*This
= impl_from_DispatchEx(dispex
);
395 nsAString href_str
, target_str
;
398 if(event
->event_id
== EVENTID_CLICK
) {
399 nsAString_Init(&href_str
, NULL
);
400 nsres
= nsIDOMHTMLAreaElement_GetHref(This
->nsarea
, &href_str
);
401 if (NS_FAILED(nsres
)) {
402 ERR("Could not get area href: %08lx\n", nsres
);
406 nsAString_Init(&target_str
, NULL
);
407 nsres
= nsIDOMHTMLAreaElement_GetTarget(This
->nsarea
, &target_str
);
408 if (NS_FAILED(nsres
)) {
409 ERR("Could not get area target: %08lx\n", nsres
);
413 return handle_link_click_event(&This
->element
, &href_str
, &target_str
, event
->nsevent
, prevent_default
);
416 nsAString_Finish(&href_str
);
417 nsAString_Finish(&target_str
);
420 return HTMLElement_handle_event(&This
->element
.node
.event_target
.dispex
, event
, prevent_default
);
423 static const NodeImplVtbl HTMLAreaElementImplVtbl
= {
424 .clsid
= &CLSID_HTMLAreaElement
,
425 .cpc_entries
= HTMLElement_cpc
,
426 .clone
= HTMLElement_clone
,
427 .get_attr_col
= HTMLElement_get_attr_col
,
430 static const event_target_vtbl_t HTMLAreaElement_event_target_vtbl
= {
432 HTMLELEMENT_DISPEX_VTBL_ENTRIES
,
433 .query_interface
= HTMLAreaElement_query_interface
,
434 .destructor
= HTMLElement_destructor
,
435 .traverse
= HTMLAreaElement_traverse
,
436 .unlink
= HTMLAreaElement_unlink
438 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES
,
439 .handle_event
= HTMLAreaElement_handle_event
442 static const tid_t HTMLAreaElement_iface_tids
[] = {
444 IHTMLAreaElement_tid
,
447 static dispex_static_data_t HTMLAreaElement_dispex
= {
449 &HTMLAreaElement_event_target_vtbl
.dispex_vtbl
,
450 DispHTMLAreaElement_tid
,
451 HTMLAreaElement_iface_tids
,
452 HTMLElement_init_dispex_info
455 HRESULT
HTMLAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
457 HTMLAreaElement
*ret
;
460 ret
= calloc(1, sizeof(HTMLAreaElement
));
462 return E_OUTOFMEMORY
;
464 ret
->IHTMLAreaElement_iface
.lpVtbl
= &HTMLAreaElementVtbl
;
465 ret
->element
.node
.vtbl
= &HTMLAreaElementImplVtbl
;
467 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAreaElement_dispex
);
469 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAreaElement
, (void**)&ret
->nsarea
);
470 assert(nsres
== NS_OK
);
472 *elem
= &ret
->element
;