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
);
73 static HRESULT
navigate_anchor(HTMLAnchorElement
*This
)
75 nsAString href_str
, target_str
;
76 HTMLOuterWindow
*window
= NULL
;
78 HRESULT hres
= E_FAIL
;
80 static const WCHAR _parentW
[] = {'p','a','r','e','n','t',0};
81 static const WCHAR _selfW
[] = {'_','s','e','l','f',0};
82 static const WCHAR _topW
[] = {'_','t','o','p',0};
84 nsAString_Init(&target_str
, NULL
);
85 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
86 if(NS_SUCCEEDED(nsres
)) {
87 const PRUnichar
*target
;
89 nsAString_GetData(&target_str
, &target
);
90 if(*target
&& strcmpiW(target
, _selfW
)) {
91 if(!strcmpiW(target
, _topW
)) {
92 TRACE("target _top\n");
93 get_top_window(This
->element
.node
.doc
->basedoc
.window
, &window
);
94 }else if(!strcmpiW(target
, _parentW
)) {
95 FIXME("Navigating to target _parent is not implemented\n");
96 nsAString_Finish(&target_str
);
99 hres
= navigate_anchor_window(This
, target
);
100 nsAString_Finish(&target_str
);
105 nsAString_Finish(&target_str
);
107 nsAString_Init(&href_str
, NULL
);
108 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
109 if(NS_SUCCEEDED(nsres
)) {
110 const PRUnichar
*href
;
112 nsAString_GetData(&href_str
, &href
);
115 window
= This
->element
.node
.doc
->basedoc
.window
;
116 hres
= navigate_url(window
, href
, window
->url
);
118 TRACE("empty href\n");
122 nsAString_Finish(&href_str
);
126 static inline HTMLAnchorElement
*impl_from_IHTMLAnchorElement(IHTMLAnchorElement
*iface
)
128 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, IHTMLAnchorElement_iface
);
131 static HRESULT WINAPI
HTMLAnchorElement_QueryInterface(IHTMLAnchorElement
*iface
,
132 REFIID riid
, void **ppv
)
134 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
136 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
139 static ULONG WINAPI
HTMLAnchorElement_AddRef(IHTMLAnchorElement
*iface
)
141 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
143 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
146 static ULONG WINAPI
HTMLAnchorElement_Release(IHTMLAnchorElement
*iface
)
148 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
150 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
153 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement
*iface
, UINT
*pctinfo
)
155 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
156 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
159 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement
*iface
, UINT iTInfo
,
160 LCID lcid
, ITypeInfo
**ppTInfo
)
162 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
163 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
167 static HRESULT WINAPI
HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement
*iface
, REFIID riid
,
168 LPOLESTR
*rgszNames
, UINT cNames
,
169 LCID lcid
, DISPID
*rgDispId
)
171 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
172 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
173 cNames
, lcid
, rgDispId
);
176 static HRESULT WINAPI
HTMLAnchorElement_Invoke(IHTMLAnchorElement
*iface
, DISPID dispIdMember
,
177 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
178 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
180 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
181 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
182 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
185 static HRESULT WINAPI
HTMLAnchorElement_put_href(IHTMLAnchorElement
*iface
, BSTR v
)
187 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
191 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
193 nsAString_InitDepend(&nsstr
, v
);
194 nsres
= nsIDOMHTMLAnchorElement_SetHref(This
->nsanchor
, &nsstr
);
195 nsAString_Finish(&nsstr
);
202 static HRESULT WINAPI
HTMLAnchorElement_get_href(IHTMLAnchorElement
*iface
, BSTR
*p
)
204 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
209 TRACE("(%p)->(%p)\n", This
, p
);
211 nsAString_Init(&href_str
, NULL
);
212 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
213 if(NS_SUCCEEDED(nsres
)) {
214 const PRUnichar
*href
;
216 nsAString_GetData(&href_str
, &href
);
217 hres
= nsuri_to_url(href
, TRUE
, p
);
219 ERR("GetHref failed: %08x\n", nsres
);
223 nsAString_Finish(&href_str
);
227 static HRESULT WINAPI
HTMLAnchorElement_put_target(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_SetTarget(This
->nsanchor
, &nsstr
);
237 nsAString_Finish(&nsstr
);
244 static HRESULT WINAPI
HTMLAnchorElement_get_target(IHTMLAnchorElement
*iface
, BSTR
*p
)
246 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
247 nsAString target_str
;
250 TRACE("(%p)->(%p)\n", This
, p
);
252 nsAString_Init(&target_str
, NULL
);
253 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
255 return return_nsstr(nsres
, &target_str
, p
);
258 static HRESULT WINAPI
HTMLAnchorElement_put_rel(IHTMLAnchorElement
*iface
, BSTR v
)
260 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
261 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
265 static HRESULT WINAPI
HTMLAnchorElement_get_rel(IHTMLAnchorElement
*iface
, BSTR
*p
)
267 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
268 FIXME("(%p)->(%p)\n", This
, p
);
272 static HRESULT WINAPI
HTMLAnchorElement_put_rev(IHTMLAnchorElement
*iface
, BSTR v
)
274 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
275 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
279 static HRESULT WINAPI
HTMLAnchorElement_get_rev(IHTMLAnchorElement
*iface
, BSTR
*p
)
281 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
282 FIXME("(%p)->(%p)\n", This
, p
);
286 static HRESULT WINAPI
HTMLAnchorElement_put_urn(IHTMLAnchorElement
*iface
, BSTR v
)
288 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
289 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
293 static HRESULT WINAPI
HTMLAnchorElement_get_urn(IHTMLAnchorElement
*iface
, BSTR
*p
)
295 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
296 FIXME("(%p)->(%p)\n", This
, p
);
300 static HRESULT WINAPI
HTMLAnchorElement_put_Methods(IHTMLAnchorElement
*iface
, BSTR v
)
302 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
303 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
307 static HRESULT WINAPI
HTMLAnchorElement_get_Methods(IHTMLAnchorElement
*iface
, BSTR
*p
)
309 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
310 FIXME("(%p)->(%p)\n", This
, p
);
314 static HRESULT WINAPI
HTMLAnchorElement_put_name(IHTMLAnchorElement
*iface
, BSTR v
)
316 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
320 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
322 nsAString_InitDepend(&nsstr
, v
);
323 nsres
= nsIDOMHTMLAnchorElement_SetName(This
->nsanchor
, &nsstr
);
324 nsAString_Finish(&nsstr
);
331 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
333 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
337 TRACE("(%p)->(%p)\n", This
, p
);
339 nsAString_Init(&name_str
, NULL
);
340 nsres
= nsIDOMHTMLAnchorElement_GetName(This
->nsanchor
, &name_str
);
342 return return_nsstr(nsres
, &name_str
, p
);
345 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
347 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
348 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
352 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
354 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
355 FIXME("(%p)->(%p)\n", This
, p
);
359 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
361 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
362 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
366 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
368 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
369 FIXME("(%p)->(%p)\n", This
, p
);
373 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
375 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
376 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
380 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
382 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
383 FIXME("(%p)->(%p)\n", This
, p
);
387 static HRESULT WINAPI
HTMLAnchorElement_put_port(IHTMLAnchorElement
*iface
, BSTR v
)
389 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
390 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
394 static HRESULT WINAPI
HTMLAnchorElement_get_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
396 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
397 FIXME("(%p)->(%p)\n", This
, p
);
401 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(IHTMLAnchorElement
*iface
, BSTR v
)
403 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
404 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
408 static HRESULT WINAPI
HTMLAnchorElement_get_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
410 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
411 FIXME("(%p)->(%p)\n", This
, p
);
415 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
417 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
418 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
422 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
424 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
425 FIXME("(%p)->(%p)\n", This
, p
);
429 static HRESULT WINAPI
HTMLAnchorElement_put_hash(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_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
438 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
439 FIXME("(%p)->(%p)\n", This
, p
);
443 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
445 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
447 TRACE("(%p)->()\n", This
);
449 return IHTMLElement2_put_onblur(&This
->element
.IHTMLElement2_iface
, v
);
452 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
454 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
456 TRACE("(%p)->(%p)\n", This
, p
);
458 return IHTMLElement2_get_onblur(&This
->element
.IHTMLElement2_iface
, p
);
461 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
463 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
465 TRACE("(%p)->()\n", This
);
467 return IHTMLElement2_put_onfocus(&This
->element
.IHTMLElement2_iface
, v
);
470 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
472 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
474 TRACE("(%p)->(%p)\n", This
, p
);
476 return IHTMLElement2_get_onfocus(&This
->element
.IHTMLElement2_iface
, p
);
479 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
481 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
483 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
485 return IHTMLElement2_put_accessKey(&This
->element
.IHTMLElement2_iface
, v
);
488 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
490 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
492 TRACE("(%p)->(%p)\n", This
, p
);
494 return IHTMLElement2_get_accessKey(&This
->element
.IHTMLElement2_iface
, p
);
497 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
499 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
500 FIXME("(%p)->(%p)\n", This
, p
);
504 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
506 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
507 FIXME("(%p)->(%p)\n", This
, p
);
511 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
513 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
514 FIXME("(%p)->(%p)\n", This
, p
);
518 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
520 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
522 TRACE("(%p)->()\n", This
);
524 return IHTMLElement2_put_tabIndex(&This
->element
.IHTMLElement2_iface
, v
);
527 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
529 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
531 TRACE("(%p)->(%p)\n", This
, p
);
533 return IHTMLElement2_get_tabIndex(&This
->element
.IHTMLElement2_iface
, p
);
536 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
538 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
540 TRACE("(%p)\n", This
);
542 return IHTMLElement2_focus(&This
->element
.IHTMLElement2_iface
);
545 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
547 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
549 TRACE("(%p)\n", This
);
551 return IHTMLElement2_blur(&This
->element
.IHTMLElement2_iface
);
554 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
555 HTMLAnchorElement_QueryInterface
,
556 HTMLAnchorElement_AddRef
,
557 HTMLAnchorElement_Release
,
558 HTMLAnchorElement_GetTypeInfoCount
,
559 HTMLAnchorElement_GetTypeInfo
,
560 HTMLAnchorElement_GetIDsOfNames
,
561 HTMLAnchorElement_Invoke
,
562 HTMLAnchorElement_put_href
,
563 HTMLAnchorElement_get_href
,
564 HTMLAnchorElement_put_target
,
565 HTMLAnchorElement_get_target
,
566 HTMLAnchorElement_put_rel
,
567 HTMLAnchorElement_get_rel
,
568 HTMLAnchorElement_put_rev
,
569 HTMLAnchorElement_get_rev
,
570 HTMLAnchorElement_put_urn
,
571 HTMLAnchorElement_get_urn
,
572 HTMLAnchorElement_put_Methods
,
573 HTMLAnchorElement_get_Methods
,
574 HTMLAnchorElement_put_name
,
575 HTMLAnchorElement_get_name
,
576 HTMLAnchorElement_put_host
,
577 HTMLAnchorElement_get_host
,
578 HTMLAnchorElement_put_hostname
,
579 HTMLAnchorElement_get_hostname
,
580 HTMLAnchorElement_put_pathname
,
581 HTMLAnchorElement_get_pathname
,
582 HTMLAnchorElement_put_port
,
583 HTMLAnchorElement_get_port
,
584 HTMLAnchorElement_put_protocol
,
585 HTMLAnchorElement_get_protocol
,
586 HTMLAnchorElement_put_search
,
587 HTMLAnchorElement_get_search
,
588 HTMLAnchorElement_put_hash
,
589 HTMLAnchorElement_get_hash
,
590 HTMLAnchorElement_put_onblur
,
591 HTMLAnchorElement_get_onblur
,
592 HTMLAnchorElement_put_onfocus
,
593 HTMLAnchorElement_get_onfocus
,
594 HTMLAnchorElement_put_accessKey
,
595 HTMLAnchorElement_get_accessKey
,
596 HTMLAnchorElement_get_protocolLong
,
597 HTMLAnchorElement_get_mimeType
,
598 HTMLAnchorElement_get_nameProp
,
599 HTMLAnchorElement_put_tabIndex
,
600 HTMLAnchorElement_get_tabIndex
,
601 HTMLAnchorElement_focus
,
602 HTMLAnchorElement_blur
605 static inline HTMLAnchorElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
607 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, element
.node
);
610 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
612 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
616 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
617 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
618 *ppv
= &This
->IHTMLAnchorElement_iface
;
619 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
620 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
621 *ppv
= &This
->IHTMLAnchorElement_iface
;
622 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
623 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
624 *ppv
= &This
->IHTMLAnchorElement_iface
;
628 IUnknown_AddRef((IUnknown
*)*ppv
);
632 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
635 static HRESULT
HTMLAnchorElement_handle_event(HTMLDOMNode
*iface
, eventid_t eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
637 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
639 if(eid
== EVENTID_CLICK
) {
640 nsIDOMMouseEvent
*mouse_event
;
646 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
647 assert(nsres
== NS_OK
);
649 nsres
= nsIDOMMouseEvent_GetButton(mouse_event
, &button
);
650 assert(nsres
== NS_OK
);
652 nsIDOMMouseEvent_Release(mouse_event
);
656 *prevent_default
= TRUE
;
657 return navigate_anchor(This
);
659 *prevent_default
= TRUE
;
660 return navigate_anchor_window(This
, NULL
);
662 *prevent_default
= FALSE
;
670 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
671 HTMLAnchorElement_QI
,
672 HTMLElement_destructor
,
674 HTMLElement_get_attr_col
,
677 HTMLAnchorElement_handle_event
680 static const tid_t HTMLAnchorElement_iface_tids
[] = {
681 IHTMLAnchorElement_tid
,
683 IHTMLTextContainer_tid
,
688 static dispex_static_data_t HTMLAnchorElement_dispex
= {
690 DispHTMLAnchorElement_tid
,
692 HTMLAnchorElement_iface_tids
695 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
697 HTMLAnchorElement
*ret
;
700 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
702 return E_OUTOFMEMORY
;
704 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
705 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
707 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
709 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
711 /* Shere the reference with nsnode */
712 assert(nsres
== NS_OK
&& (nsIDOMNode
*)ret
->nsanchor
== ret
->element
.node
.nsnode
);
713 nsIDOMNode_Release(ret
->element
.node
.nsnode
);
715 *elem
= &ret
->element
;