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
30 #include "mshtml_private.h"
31 #include "htmlevent.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
41 IHTMLAnchorElement IHTMLAnchorElement_iface
;
43 nsIDOMHTMLAnchorElement
*nsanchor
;
46 static HRESULT
navigate_anchor_window(HTMLAnchorElement
*This
, const WCHAR
*target
)
53 nsAString_Init(&href_str
, NULL
);
54 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
55 if(NS_SUCCEEDED(nsres
)) {
56 const PRUnichar
*href
;
58 nsAString_GetData(&href_str
, &href
);
59 hres
= create_relative_uri(This
->element
.node
.doc
->basedoc
.window
, href
, &uri
);
61 ERR("Could not get anchor href: %08x\n", nsres
);
64 nsAString_Finish(&href_str
);
68 hres
= navigate_new_window(This
->element
.node
.doc
->basedoc
.window
, uri
, target
, NULL
, NULL
);
73 HTMLOuterWindow
*get_target_window(HTMLOuterWindow
*window
, nsAString
*target_str
, BOOL
*use_new_window
)
75 HTMLOuterWindow
*top_window
, *ret_window
;
76 const PRUnichar
*target
;
79 static const WCHAR _parentW
[] = {'_','p','a','r','e','n','t',0};
80 static const WCHAR _selfW
[] = {'_','s','e','l','f',0};
81 static const WCHAR _topW
[] = {'_','t','o','p',0};
83 *use_new_window
= FALSE
;
85 nsAString_GetData(target_str
, &target
);
86 TRACE("%s\n", debugstr_w(target
));
88 if(!*target
|| !strcmpiW(target
, _selfW
)) {
89 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
93 if(!strcmpiW(target
, _topW
)) {
94 get_top_window(window
, &top_window
);
95 IHTMLWindow2_AddRef(&top_window
->base
.IHTMLWindow2_iface
);
99 if(!strcmpiW(target
, _parentW
)) {
100 if(!window
->parent
) {
101 WARN("Window has no parent, treat as self\n");
102 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
106 IHTMLWindow2_AddRef(&window
->parent
->base
.IHTMLWindow2_iface
);
107 return window
->parent
;
110 get_top_window(window
, &top_window
);
112 hres
= get_frame_by_name(top_window
, target
, TRUE
, &ret_window
);
113 if(FAILED(hres
) || !ret_window
) {
114 *use_new_window
= TRUE
;
118 IHTMLWindow2_AddRef(&ret_window
->base
.IHTMLWindow2_iface
);
122 static HRESULT
navigate_anchor(HTMLAnchorElement
*This
)
124 nsAString href_str
, target_str
;
125 HTMLOuterWindow
*window
;
128 HRESULT hres
= E_FAIL
;
131 nsAString_Init(&target_str
, NULL
);
132 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
136 window
= get_target_window(This
->element
.node
.doc
->basedoc
.window
, &target_str
, &use_new_window
);
137 if(!window
&& use_new_window
) {
138 const PRUnichar
*target
;
140 nsAString_GetData(&target_str
, &target
);
141 hres
= navigate_anchor_window(This
, target
);
142 nsAString_Finish(&target_str
);
146 nsAString_Finish(&target_str
);
150 nsAString_Init(&href_str
, NULL
);
151 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
152 if(NS_SUCCEEDED(nsres
)) {
153 const PRUnichar
*href
;
155 nsAString_GetData(&href_str
, &href
);
157 hres
= navigate_url(window
, href
, window
->uri_nofrag
, BINDING_NAVIGATED
);
159 TRACE("empty href\n");
163 nsAString_Finish(&href_str
);
164 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
168 static inline HTMLAnchorElement
*impl_from_IHTMLAnchorElement(IHTMLAnchorElement
*iface
)
170 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, IHTMLAnchorElement_iface
);
173 static HRESULT WINAPI
HTMLAnchorElement_QueryInterface(IHTMLAnchorElement
*iface
,
174 REFIID riid
, void **ppv
)
176 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
178 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
181 static ULONG WINAPI
HTMLAnchorElement_AddRef(IHTMLAnchorElement
*iface
)
183 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
185 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
188 static ULONG WINAPI
HTMLAnchorElement_Release(IHTMLAnchorElement
*iface
)
190 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
192 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
195 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement
*iface
, UINT
*pctinfo
)
197 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
198 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
201 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement
*iface
, UINT iTInfo
,
202 LCID lcid
, ITypeInfo
**ppTInfo
)
204 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
205 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
209 static HRESULT WINAPI
HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement
*iface
, REFIID riid
,
210 LPOLESTR
*rgszNames
, UINT cNames
,
211 LCID lcid
, DISPID
*rgDispId
)
213 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
214 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
215 cNames
, lcid
, rgDispId
);
218 static HRESULT WINAPI
HTMLAnchorElement_Invoke(IHTMLAnchorElement
*iface
, DISPID dispIdMember
,
219 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
220 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
222 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
223 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
224 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
227 static HRESULT WINAPI
HTMLAnchorElement_put_href(IHTMLAnchorElement
*iface
, BSTR v
)
229 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
233 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
235 nsAString_InitDepend(&nsstr
, v
);
236 nsres
= nsIDOMHTMLAnchorElement_SetHref(This
->nsanchor
, &nsstr
);
237 nsAString_Finish(&nsstr
);
244 static HRESULT WINAPI
HTMLAnchorElement_get_href(IHTMLAnchorElement
*iface
, BSTR
*p
)
246 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
251 TRACE("(%p)->(%p)\n", This
, p
);
253 nsAString_Init(&href_str
, NULL
);
254 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
255 if(NS_SUCCEEDED(nsres
)) {
256 const PRUnichar
*href
;
258 nsAString_GetData(&href_str
, &href
);
259 hres
= nsuri_to_url(href
, TRUE
, p
);
261 ERR("GetHref failed: %08x\n", nsres
);
265 nsAString_Finish(&href_str
);
269 static HRESULT WINAPI
HTMLAnchorElement_put_target(IHTMLAnchorElement
*iface
, BSTR v
)
271 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
275 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
277 nsAString_InitDepend(&nsstr
, v
);
278 nsres
= nsIDOMHTMLAnchorElement_SetTarget(This
->nsanchor
, &nsstr
);
279 nsAString_Finish(&nsstr
);
286 static HRESULT WINAPI
HTMLAnchorElement_get_target(IHTMLAnchorElement
*iface
, BSTR
*p
)
288 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
289 nsAString target_str
;
292 TRACE("(%p)->(%p)\n", This
, p
);
294 nsAString_Init(&target_str
, NULL
);
295 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
297 return return_nsstr(nsres
, &target_str
, p
);
300 static HRESULT WINAPI
HTMLAnchorElement_put_rel(IHTMLAnchorElement
*iface
, BSTR v
)
302 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
306 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
308 nsAString_InitDepend(&nsstr
, v
);
309 nsres
= nsIDOMHTMLAnchorElement_SetRel(This
->nsanchor
, &nsstr
);
310 nsAString_Finish(&nsstr
);
317 static HRESULT WINAPI
HTMLAnchorElement_get_rel(IHTMLAnchorElement
*iface
, BSTR
*p
)
319 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
323 TRACE("(%p)->(%p)\n", This
, p
);
325 nsAString_Init(&nsstr
, NULL
);
326 nsres
= nsIDOMHTMLAnchorElement_GetRel(This
->nsanchor
, &nsstr
);
327 return return_nsstr(nsres
, &nsstr
, p
);
330 static HRESULT WINAPI
HTMLAnchorElement_put_rev(IHTMLAnchorElement
*iface
, BSTR v
)
332 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
333 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
337 static HRESULT WINAPI
HTMLAnchorElement_get_rev(IHTMLAnchorElement
*iface
, BSTR
*p
)
339 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
340 FIXME("(%p)->(%p)\n", This
, p
);
344 static HRESULT WINAPI
HTMLAnchorElement_put_urn(IHTMLAnchorElement
*iface
, BSTR v
)
346 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
347 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
351 static HRESULT WINAPI
HTMLAnchorElement_get_urn(IHTMLAnchorElement
*iface
, BSTR
*p
)
353 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
354 FIXME("(%p)->(%p)\n", This
, p
);
358 static HRESULT WINAPI
HTMLAnchorElement_put_Methods(IHTMLAnchorElement
*iface
, BSTR v
)
360 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
361 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
365 static HRESULT WINAPI
HTMLAnchorElement_get_Methods(IHTMLAnchorElement
*iface
, BSTR
*p
)
367 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
368 FIXME("(%p)->(%p)\n", This
, p
);
372 static HRESULT WINAPI
HTMLAnchorElement_put_name(IHTMLAnchorElement
*iface
, BSTR v
)
374 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
378 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
380 nsAString_InitDepend(&nsstr
, v
);
381 nsres
= nsIDOMHTMLAnchorElement_SetName(This
->nsanchor
, &nsstr
);
382 nsAString_Finish(&nsstr
);
389 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
391 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
395 TRACE("(%p)->(%p)\n", This
, p
);
397 nsAString_Init(&name_str
, NULL
);
398 nsres
= nsIDOMHTMLAnchorElement_GetName(This
->nsanchor
, &name_str
);
400 return return_nsstr(nsres
, &name_str
, p
);
403 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
405 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
406 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
410 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
412 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
413 FIXME("(%p)->(%p)\n", This
, p
);
417 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
419 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
420 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
424 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
426 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
427 nsAString hostname_str
;
430 TRACE("(%p)->(%p)\n", This
, p
);
432 nsAString_Init(&hostname_str
, NULL
);
433 nsres
= nsIDOMHTMLAnchorElement_GetHostname(This
->nsanchor
, &hostname_str
);
434 return return_nsstr(nsres
, &hostname_str
, p
);
437 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
439 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
440 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
444 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
446 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
447 FIXME("(%p)->(%p)\n", This
, p
);
451 static HRESULT WINAPI
HTMLAnchorElement_put_port(IHTMLAnchorElement
*iface
, BSTR v
)
453 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
454 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
458 static HRESULT WINAPI
HTMLAnchorElement_get_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
460 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
461 FIXME("(%p)->(%p)\n", This
, p
);
465 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(IHTMLAnchorElement
*iface
, BSTR v
)
467 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
468 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
472 static HRESULT WINAPI
HTMLAnchorElement_get_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
474 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
475 FIXME("(%p)->(%p)\n", This
, p
);
479 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
481 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
485 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
487 nsAString_InitDepend(&nsstr
, v
);
488 nsres
= nsIDOMHTMLAnchorElement_SetSearch(This
->nsanchor
, &nsstr
);
489 nsAString_Finish(&nsstr
);
496 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
498 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
499 nsAString search_str
;
502 TRACE("(%p)->(%p)\n", This
, p
);
504 nsAString_Init(&search_str
, NULL
);
505 nsres
= nsIDOMHTMLAnchorElement_GetSearch(This
->nsanchor
, &search_str
);
506 return return_nsstr(nsres
, &search_str
, p
);
509 static HRESULT WINAPI
HTMLAnchorElement_put_hash(IHTMLAnchorElement
*iface
, BSTR v
)
511 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
512 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
516 static HRESULT WINAPI
HTMLAnchorElement_get_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
518 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
522 TRACE("(%p)->(%p)\n", This
, p
);
524 nsAString_Init(&hash_str
, NULL
);
525 nsres
= nsIDOMHTMLAnchorElement_GetHash(This
->nsanchor
, &hash_str
);
526 return return_nsstr(nsres
, &hash_str
, p
);
529 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
531 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
533 TRACE("(%p)->()\n", This
);
535 return IHTMLElement2_put_onblur(&This
->element
.IHTMLElement2_iface
, v
);
538 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
540 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
542 TRACE("(%p)->(%p)\n", This
, p
);
544 return IHTMLElement2_get_onblur(&This
->element
.IHTMLElement2_iface
, p
);
547 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
549 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
551 TRACE("(%p)->()\n", This
);
553 return IHTMLElement2_put_onfocus(&This
->element
.IHTMLElement2_iface
, v
);
556 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
558 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
560 TRACE("(%p)->(%p)\n", This
, p
);
562 return IHTMLElement2_get_onfocus(&This
->element
.IHTMLElement2_iface
, p
);
565 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
567 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
569 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
571 return IHTMLElement2_put_accessKey(&This
->element
.IHTMLElement2_iface
, v
);
574 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
576 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
578 TRACE("(%p)->(%p)\n", This
, p
);
580 return IHTMLElement2_get_accessKey(&This
->element
.IHTMLElement2_iface
, p
);
583 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
585 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
586 FIXME("(%p)->(%p)\n", This
, p
);
590 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
592 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
593 FIXME("(%p)->(%p)\n", This
, p
);
597 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
599 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
600 FIXME("(%p)->(%p)\n", This
, p
);
604 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
606 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
608 TRACE("(%p)->()\n", This
);
610 return IHTMLElement2_put_tabIndex(&This
->element
.IHTMLElement2_iface
, v
);
613 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
615 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
617 TRACE("(%p)->(%p)\n", This
, p
);
619 return IHTMLElement2_get_tabIndex(&This
->element
.IHTMLElement2_iface
, p
);
622 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
624 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
626 TRACE("(%p)\n", This
);
628 return IHTMLElement2_focus(&This
->element
.IHTMLElement2_iface
);
631 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
633 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
635 TRACE("(%p)\n", This
);
637 return IHTMLElement2_blur(&This
->element
.IHTMLElement2_iface
);
640 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
641 HTMLAnchorElement_QueryInterface
,
642 HTMLAnchorElement_AddRef
,
643 HTMLAnchorElement_Release
,
644 HTMLAnchorElement_GetTypeInfoCount
,
645 HTMLAnchorElement_GetTypeInfo
,
646 HTMLAnchorElement_GetIDsOfNames
,
647 HTMLAnchorElement_Invoke
,
648 HTMLAnchorElement_put_href
,
649 HTMLAnchorElement_get_href
,
650 HTMLAnchorElement_put_target
,
651 HTMLAnchorElement_get_target
,
652 HTMLAnchorElement_put_rel
,
653 HTMLAnchorElement_get_rel
,
654 HTMLAnchorElement_put_rev
,
655 HTMLAnchorElement_get_rev
,
656 HTMLAnchorElement_put_urn
,
657 HTMLAnchorElement_get_urn
,
658 HTMLAnchorElement_put_Methods
,
659 HTMLAnchorElement_get_Methods
,
660 HTMLAnchorElement_put_name
,
661 HTMLAnchorElement_get_name
,
662 HTMLAnchorElement_put_host
,
663 HTMLAnchorElement_get_host
,
664 HTMLAnchorElement_put_hostname
,
665 HTMLAnchorElement_get_hostname
,
666 HTMLAnchorElement_put_pathname
,
667 HTMLAnchorElement_get_pathname
,
668 HTMLAnchorElement_put_port
,
669 HTMLAnchorElement_get_port
,
670 HTMLAnchorElement_put_protocol
,
671 HTMLAnchorElement_get_protocol
,
672 HTMLAnchorElement_put_search
,
673 HTMLAnchorElement_get_search
,
674 HTMLAnchorElement_put_hash
,
675 HTMLAnchorElement_get_hash
,
676 HTMLAnchorElement_put_onblur
,
677 HTMLAnchorElement_get_onblur
,
678 HTMLAnchorElement_put_onfocus
,
679 HTMLAnchorElement_get_onfocus
,
680 HTMLAnchorElement_put_accessKey
,
681 HTMLAnchorElement_get_accessKey
,
682 HTMLAnchorElement_get_protocolLong
,
683 HTMLAnchorElement_get_mimeType
,
684 HTMLAnchorElement_get_nameProp
,
685 HTMLAnchorElement_put_tabIndex
,
686 HTMLAnchorElement_get_tabIndex
,
687 HTMLAnchorElement_focus
,
688 HTMLAnchorElement_blur
691 static inline HTMLAnchorElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
693 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, element
.node
);
696 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
698 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
702 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
703 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
704 *ppv
= &This
->IHTMLAnchorElement_iface
;
705 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
706 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
707 *ppv
= &This
->IHTMLAnchorElement_iface
;
708 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
709 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
710 *ppv
= &This
->IHTMLAnchorElement_iface
;
714 IUnknown_AddRef((IUnknown
*)*ppv
);
718 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
721 static HRESULT
HTMLAnchorElement_handle_event(HTMLDOMNode
*iface
, eventid_t eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
723 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
725 if(eid
== EVENTID_CLICK
) {
726 nsIDOMMouseEvent
*mouse_event
;
732 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
733 assert(nsres
== NS_OK
);
735 nsres
= nsIDOMMouseEvent_GetButton(mouse_event
, &button
);
736 assert(nsres
== NS_OK
);
738 nsIDOMMouseEvent_Release(mouse_event
);
742 *prevent_default
= TRUE
;
743 return navigate_anchor(This
);
745 *prevent_default
= TRUE
;
746 return navigate_anchor_window(This
, NULL
);
748 *prevent_default
= FALSE
;
753 return HTMLElement_handle_event(&This
->element
.node
, eid
, event
, prevent_default
);
756 static void HTMLAnchorElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
758 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
761 note_cc_edge((nsISupports
*)This
->nsanchor
, "This->nsanchor", cb
);
764 static void HTMLAnchorElement_unlink(HTMLDOMNode
*iface
)
766 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
769 nsIDOMHTMLAnchorElement
*nsanchor
= This
->nsanchor
;
771 This
->nsanchor
= NULL
;
772 nsIDOMHTMLAnchorElement_Release(nsanchor
);
776 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
777 HTMLAnchorElement_QI
,
778 HTMLElement_destructor
,
781 HTMLAnchorElement_handle_event
,
782 HTMLElement_get_attr_col
,
792 HTMLAnchorElement_traverse
,
793 HTMLAnchorElement_unlink
796 static const tid_t HTMLAnchorElement_iface_tids
[] = {
797 IHTMLAnchorElement_tid
,
803 static dispex_static_data_t HTMLAnchorElement_dispex
= {
805 DispHTMLAnchorElement_tid
,
807 HTMLAnchorElement_iface_tids
810 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
812 HTMLAnchorElement
*ret
;
815 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
817 return E_OUTOFMEMORY
;
819 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
820 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
822 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
824 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
825 assert(nsres
== NS_OK
);
827 *elem
= &ret
->element
;