2 * Copyright 2007 Jacek Caban for CodeWeavers
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 IHTMLAnchorElement IHTMLAnchorElement_iface
;
26 nsIDOMHTMLAnchorElement
*nsanchor
;
29 static HRESULT
navigate_href_new_window(HTMLElement
*element
, nsAString
*href_str
, const WCHAR
*target
)
31 const PRUnichar
*href
;
35 nsAString_GetData(href_str
, &href
);
36 hres
= create_relative_uri(element
->node
.doc
->basedoc
.window
, href
, &uri
);
40 hres
= navigate_new_window(element
->node
.doc
->basedoc
.window
, uri
, target
, NULL
, NULL
);
45 HTMLOuterWindow
*get_target_window(HTMLOuterWindow
*window
, nsAString
*target_str
, BOOL
*use_new_window
)
47 HTMLOuterWindow
*top_window
, *ret_window
;
48 const PRUnichar
*target
;
51 static const WCHAR _parentW
[] = {'_','p','a','r','e','n','t',0};
52 static const WCHAR _selfW
[] = {'_','s','e','l','f',0};
53 static const WCHAR _topW
[] = {'_','t','o','p',0};
55 *use_new_window
= FALSE
;
57 nsAString_GetData(target_str
, &target
);
58 TRACE("%s\n", debugstr_w(target
));
60 if(!*target
|| !strcmpiW(target
, _selfW
)) {
61 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
65 if(!strcmpiW(target
, _topW
)) {
66 get_top_window(window
, &top_window
);
67 IHTMLWindow2_AddRef(&top_window
->base
.IHTMLWindow2_iface
);
71 if(!strcmpiW(target
, _parentW
)) {
73 WARN("Window has no parent, treat as self\n");
74 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
78 IHTMLWindow2_AddRef(&window
->parent
->base
.IHTMLWindow2_iface
);
79 return window
->parent
;
82 get_top_window(window
, &top_window
);
84 hres
= get_frame_by_name(top_window
, target
, TRUE
, &ret_window
);
85 if(FAILED(hres
) || !ret_window
) {
86 *use_new_window
= TRUE
;
90 IHTMLWindow2_AddRef(&ret_window
->base
.IHTMLWindow2_iface
);
94 static HRESULT
navigate_href(HTMLElement
*element
, nsAString
*href_str
, nsAString
*target_str
)
96 HTMLOuterWindow
*window
;
98 const PRUnichar
*href
;
101 window
= get_target_window(element
->node
.doc
->basedoc
.window
, target_str
, &use_new_window
);
104 const PRUnichar
*target
;
105 nsAString_GetData(target_str
, &target
);
106 return navigate_href_new_window(element
, href_str
, target
);
112 nsAString_GetData(href_str
, &href
);
114 hres
= navigate_url(window
, href
, window
->uri_nofrag
, BINDING_NAVIGATED
);
116 TRACE("empty href\n");
119 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
123 HRESULT
handle_link_click_event(HTMLElement
*element
, nsAString
*href_str
, nsAString
*target_str
,
124 nsIDOMEvent
*event
, BOOL
*prevent_default
)
126 nsIDOMMouseEvent
*mouse_event
;
133 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
134 assert(nsres
== NS_OK
);
136 nsres
= nsIDOMMouseEvent_GetButton(mouse_event
, &button
);
137 assert(nsres
== NS_OK
);
139 nsIDOMMouseEvent_Release(mouse_event
);
143 *prevent_default
= TRUE
;
144 hres
= navigate_href(element
, href_str
, target_str
);
147 *prevent_default
= TRUE
;
148 hres
= navigate_href_new_window(element
, href_str
, NULL
);
151 *prevent_default
= FALSE
;
155 nsAString_Finish(href_str
);
156 nsAString_Finish(target_str
);
160 static inline HTMLAnchorElement
*impl_from_IHTMLAnchorElement(IHTMLAnchorElement
*iface
)
162 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, IHTMLAnchorElement_iface
);
165 static HRESULT WINAPI
HTMLAnchorElement_QueryInterface(IHTMLAnchorElement
*iface
,
166 REFIID riid
, void **ppv
)
168 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
170 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
173 static ULONG WINAPI
HTMLAnchorElement_AddRef(IHTMLAnchorElement
*iface
)
175 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
177 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
180 static ULONG WINAPI
HTMLAnchorElement_Release(IHTMLAnchorElement
*iface
)
182 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
184 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
187 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement
*iface
, UINT
*pctinfo
)
189 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
190 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
193 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement
*iface
, UINT iTInfo
,
194 LCID lcid
, ITypeInfo
**ppTInfo
)
196 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
197 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
201 static HRESULT WINAPI
HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement
*iface
, REFIID riid
,
202 LPOLESTR
*rgszNames
, UINT cNames
,
203 LCID lcid
, DISPID
*rgDispId
)
205 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
206 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
207 cNames
, lcid
, rgDispId
);
210 static HRESULT WINAPI
HTMLAnchorElement_Invoke(IHTMLAnchorElement
*iface
, DISPID dispIdMember
,
211 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
212 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
214 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
215 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
216 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
219 static HRESULT WINAPI
HTMLAnchorElement_put_href(IHTMLAnchorElement
*iface
, BSTR v
)
221 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
225 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
227 nsAString_InitDepend(&nsstr
, v
);
228 nsres
= nsIDOMHTMLAnchorElement_SetHref(This
->nsanchor
, &nsstr
);
229 nsAString_Finish(&nsstr
);
236 static HRESULT WINAPI
HTMLAnchorElement_get_href(IHTMLAnchorElement
*iface
, BSTR
*p
)
238 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
243 TRACE("(%p)->(%p)\n", This
, p
);
245 nsAString_Init(&href_str
, NULL
);
246 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
247 if(NS_SUCCEEDED(nsres
)) {
248 const PRUnichar
*href
;
250 nsAString_GetData(&href_str
, &href
);
251 hres
= nsuri_to_url(href
, TRUE
, p
);
253 ERR("GetHref failed: %08x\n", nsres
);
257 nsAString_Finish(&href_str
);
261 static HRESULT WINAPI
HTMLAnchorElement_put_target(IHTMLAnchorElement
*iface
, BSTR v
)
263 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
267 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
269 nsAString_InitDepend(&nsstr
, v
);
270 nsres
= nsIDOMHTMLAnchorElement_SetTarget(This
->nsanchor
, &nsstr
);
271 nsAString_Finish(&nsstr
);
278 static HRESULT WINAPI
HTMLAnchorElement_get_target(IHTMLAnchorElement
*iface
, BSTR
*p
)
280 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
281 nsAString target_str
;
284 TRACE("(%p)->(%p)\n", This
, p
);
286 nsAString_Init(&target_str
, NULL
);
287 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
289 return return_nsstr(nsres
, &target_str
, p
);
292 static HRESULT WINAPI
HTMLAnchorElement_put_rel(IHTMLAnchorElement
*iface
, BSTR v
)
294 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
298 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
300 nsAString_InitDepend(&nsstr
, v
);
301 nsres
= nsIDOMHTMLAnchorElement_SetRel(This
->nsanchor
, &nsstr
);
302 nsAString_Finish(&nsstr
);
309 static HRESULT WINAPI
HTMLAnchorElement_get_rel(IHTMLAnchorElement
*iface
, BSTR
*p
)
311 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
315 TRACE("(%p)->(%p)\n", This
, p
);
317 nsAString_Init(&nsstr
, NULL
);
318 nsres
= nsIDOMHTMLAnchorElement_GetRel(This
->nsanchor
, &nsstr
);
319 return return_nsstr(nsres
, &nsstr
, p
);
322 static HRESULT WINAPI
HTMLAnchorElement_put_rev(IHTMLAnchorElement
*iface
, BSTR v
)
324 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
325 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
329 static HRESULT WINAPI
HTMLAnchorElement_get_rev(IHTMLAnchorElement
*iface
, BSTR
*p
)
331 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
332 FIXME("(%p)->(%p)\n", This
, p
);
336 static HRESULT WINAPI
HTMLAnchorElement_put_urn(IHTMLAnchorElement
*iface
, BSTR v
)
338 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
339 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
343 static HRESULT WINAPI
HTMLAnchorElement_get_urn(IHTMLAnchorElement
*iface
, BSTR
*p
)
345 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
346 FIXME("(%p)->(%p)\n", This
, p
);
350 static HRESULT WINAPI
HTMLAnchorElement_put_Methods(IHTMLAnchorElement
*iface
, BSTR v
)
352 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
353 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
357 static HRESULT WINAPI
HTMLAnchorElement_get_Methods(IHTMLAnchorElement
*iface
, BSTR
*p
)
359 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
360 FIXME("(%p)->(%p)\n", This
, p
);
364 static HRESULT WINAPI
HTMLAnchorElement_put_name(IHTMLAnchorElement
*iface
, BSTR v
)
366 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
370 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
372 nsAString_InitDepend(&nsstr
, v
);
373 nsres
= nsIDOMHTMLAnchorElement_SetName(This
->nsanchor
, &nsstr
);
374 nsAString_Finish(&nsstr
);
381 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
383 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
387 TRACE("(%p)->(%p)\n", This
, p
);
389 nsAString_Init(&name_str
, NULL
);
390 nsres
= nsIDOMHTMLAnchorElement_GetName(This
->nsanchor
, &name_str
);
392 return return_nsstr(nsres
, &name_str
, p
);
395 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
397 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
398 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
402 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
404 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
405 FIXME("(%p)->(%p)\n", This
, p
);
409 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
411 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
412 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
416 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
418 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
419 nsAString hostname_str
;
422 TRACE("(%p)->(%p)\n", This
, p
);
424 nsAString_Init(&hostname_str
, NULL
);
425 nsres
= nsIDOMHTMLAnchorElement_GetHostname(This
->nsanchor
, &hostname_str
);
426 return return_nsstr(nsres
, &hostname_str
, p
);
429 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
431 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
432 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
436 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
438 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
439 FIXME("(%p)->(%p)\n", This
, p
);
443 static HRESULT WINAPI
HTMLAnchorElement_put_port(IHTMLAnchorElement
*iface
, BSTR v
)
445 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
446 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
450 static HRESULT WINAPI
HTMLAnchorElement_get_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
452 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
453 FIXME("(%p)->(%p)\n", This
, p
);
457 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(IHTMLAnchorElement
*iface
, BSTR v
)
459 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
460 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
464 static HRESULT WINAPI
HTMLAnchorElement_get_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
466 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
467 FIXME("(%p)->(%p)\n", This
, p
);
471 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
473 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
477 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
479 nsAString_InitDepend(&nsstr
, v
);
480 nsres
= nsIDOMHTMLAnchorElement_SetSearch(This
->nsanchor
, &nsstr
);
481 nsAString_Finish(&nsstr
);
488 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
490 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
491 nsAString search_str
;
494 TRACE("(%p)->(%p)\n", This
, p
);
496 nsAString_Init(&search_str
, NULL
);
497 nsres
= nsIDOMHTMLAnchorElement_GetSearch(This
->nsanchor
, &search_str
);
498 return return_nsstr(nsres
, &search_str
, p
);
501 static HRESULT WINAPI
HTMLAnchorElement_put_hash(IHTMLAnchorElement
*iface
, BSTR v
)
503 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
504 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
508 static HRESULT WINAPI
HTMLAnchorElement_get_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
510 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
514 TRACE("(%p)->(%p)\n", This
, p
);
516 nsAString_Init(&hash_str
, NULL
);
517 nsres
= nsIDOMHTMLAnchorElement_GetHash(This
->nsanchor
, &hash_str
);
518 return return_nsstr(nsres
, &hash_str
, p
);
521 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
523 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
525 TRACE("(%p)->()\n", This
);
527 return IHTMLElement2_put_onblur(&This
->element
.IHTMLElement2_iface
, v
);
530 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
532 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
534 TRACE("(%p)->(%p)\n", This
, p
);
536 return IHTMLElement2_get_onblur(&This
->element
.IHTMLElement2_iface
, p
);
539 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
541 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
543 TRACE("(%p)->()\n", This
);
545 return IHTMLElement2_put_onfocus(&This
->element
.IHTMLElement2_iface
, v
);
548 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
550 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
552 TRACE("(%p)->(%p)\n", This
, p
);
554 return IHTMLElement2_get_onfocus(&This
->element
.IHTMLElement2_iface
, p
);
557 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
559 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
561 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
563 return IHTMLElement2_put_accessKey(&This
->element
.IHTMLElement2_iface
, v
);
566 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
568 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
570 TRACE("(%p)->(%p)\n", This
, p
);
572 return IHTMLElement2_get_accessKey(&This
->element
.IHTMLElement2_iface
, p
);
575 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
577 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
578 FIXME("(%p)->(%p)\n", This
, p
);
582 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
584 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
585 FIXME("(%p)->(%p)\n", This
, p
);
589 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
591 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
592 FIXME("(%p)->(%p)\n", This
, p
);
596 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
598 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
600 TRACE("(%p)->()\n", This
);
602 return IHTMLElement2_put_tabIndex(&This
->element
.IHTMLElement2_iface
, v
);
605 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
607 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
609 TRACE("(%p)->(%p)\n", This
, p
);
611 return IHTMLElement2_get_tabIndex(&This
->element
.IHTMLElement2_iface
, p
);
614 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
616 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
618 TRACE("(%p)\n", This
);
620 return IHTMLElement2_focus(&This
->element
.IHTMLElement2_iface
);
623 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
625 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
627 TRACE("(%p)\n", This
);
629 return IHTMLElement2_blur(&This
->element
.IHTMLElement2_iface
);
632 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
633 HTMLAnchorElement_QueryInterface
,
634 HTMLAnchorElement_AddRef
,
635 HTMLAnchorElement_Release
,
636 HTMLAnchorElement_GetTypeInfoCount
,
637 HTMLAnchorElement_GetTypeInfo
,
638 HTMLAnchorElement_GetIDsOfNames
,
639 HTMLAnchorElement_Invoke
,
640 HTMLAnchorElement_put_href
,
641 HTMLAnchorElement_get_href
,
642 HTMLAnchorElement_put_target
,
643 HTMLAnchorElement_get_target
,
644 HTMLAnchorElement_put_rel
,
645 HTMLAnchorElement_get_rel
,
646 HTMLAnchorElement_put_rev
,
647 HTMLAnchorElement_get_rev
,
648 HTMLAnchorElement_put_urn
,
649 HTMLAnchorElement_get_urn
,
650 HTMLAnchorElement_put_Methods
,
651 HTMLAnchorElement_get_Methods
,
652 HTMLAnchorElement_put_name
,
653 HTMLAnchorElement_get_name
,
654 HTMLAnchorElement_put_host
,
655 HTMLAnchorElement_get_host
,
656 HTMLAnchorElement_put_hostname
,
657 HTMLAnchorElement_get_hostname
,
658 HTMLAnchorElement_put_pathname
,
659 HTMLAnchorElement_get_pathname
,
660 HTMLAnchorElement_put_port
,
661 HTMLAnchorElement_get_port
,
662 HTMLAnchorElement_put_protocol
,
663 HTMLAnchorElement_get_protocol
,
664 HTMLAnchorElement_put_search
,
665 HTMLAnchorElement_get_search
,
666 HTMLAnchorElement_put_hash
,
667 HTMLAnchorElement_get_hash
,
668 HTMLAnchorElement_put_onblur
,
669 HTMLAnchorElement_get_onblur
,
670 HTMLAnchorElement_put_onfocus
,
671 HTMLAnchorElement_get_onfocus
,
672 HTMLAnchorElement_put_accessKey
,
673 HTMLAnchorElement_get_accessKey
,
674 HTMLAnchorElement_get_protocolLong
,
675 HTMLAnchorElement_get_mimeType
,
676 HTMLAnchorElement_get_nameProp
,
677 HTMLAnchorElement_put_tabIndex
,
678 HTMLAnchorElement_get_tabIndex
,
679 HTMLAnchorElement_focus
,
680 HTMLAnchorElement_blur
683 static inline HTMLAnchorElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
685 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, element
.node
);
688 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
690 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
694 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
695 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
696 *ppv
= &This
->IHTMLAnchorElement_iface
;
697 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
698 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
699 *ppv
= &This
->IHTMLAnchorElement_iface
;
700 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
701 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
702 *ppv
= &This
->IHTMLAnchorElement_iface
;
706 IUnknown_AddRef((IUnknown
*)*ppv
);
710 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
713 static HRESULT
HTMLAnchorElement_handle_event(HTMLDOMNode
*iface
, DWORD eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
715 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
716 nsAString href_str
, target_str
;
719 if(eid
== EVENTID_CLICK
) {
720 nsAString_Init(&href_str
, NULL
);
721 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
722 if (NS_FAILED(nsres
)) {
723 ERR("Could not get anchor href: %08x\n", nsres
);
727 nsAString_Init(&target_str
, NULL
);
728 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
729 if (NS_FAILED(nsres
)) {
730 ERR("Could not get anchor target: %08x\n", nsres
);
734 return handle_link_click_event(&This
->element
, &href_str
, &target_str
, event
, prevent_default
);
737 nsAString_Finish(&href_str
);
738 nsAString_Finish(&target_str
);
741 return HTMLElement_handle_event(&This
->element
.node
, eid
, event
, prevent_default
);
744 static void HTMLAnchorElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
746 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
749 note_cc_edge((nsISupports
*)This
->nsanchor
, "This->nsanchor", cb
);
752 static void HTMLAnchorElement_unlink(HTMLDOMNode
*iface
)
754 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
757 nsIDOMHTMLAnchorElement
*nsanchor
= This
->nsanchor
;
759 This
->nsanchor
= NULL
;
760 nsIDOMHTMLAnchorElement_Release(nsanchor
);
764 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
765 HTMLAnchorElement_QI
,
766 HTMLElement_destructor
,
769 HTMLAnchorElement_handle_event
,
770 HTMLElement_get_attr_col
,
780 HTMLAnchorElement_traverse
,
781 HTMLAnchorElement_unlink
784 static const tid_t HTMLAnchorElement_iface_tids
[] = {
785 IHTMLAnchorElement_tid
,
791 static dispex_static_data_t HTMLAnchorElement_dispex
= {
793 DispHTMLAnchorElement_tid
,
795 HTMLAnchorElement_iface_tids
798 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
800 HTMLAnchorElement
*ret
;
803 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
805 return E_OUTOFMEMORY
;
807 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
808 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
810 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
812 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
813 assert(nsres
== NS_OK
);
815 *elem
= &ret
->element
;