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 HTMLWindow
*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
);
317 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
321 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
323 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
324 FIXME("(%p)->(%p)\n", This
, p
);
328 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
330 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
331 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
335 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
337 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
338 FIXME("(%p)->(%p)\n", This
, p
);
342 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
344 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
345 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
349 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
351 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
352 FIXME("(%p)->(%p)\n", This
, p
);
356 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
358 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
359 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
363 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
365 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
366 FIXME("(%p)->(%p)\n", This
, p
);
370 static HRESULT WINAPI
HTMLAnchorElement_put_port(IHTMLAnchorElement
*iface
, BSTR v
)
372 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
373 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
377 static HRESULT WINAPI
HTMLAnchorElement_get_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
379 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
380 FIXME("(%p)->(%p)\n", This
, p
);
384 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(IHTMLAnchorElement
*iface
, BSTR v
)
386 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
387 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
391 static HRESULT WINAPI
HTMLAnchorElement_get_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
393 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
394 FIXME("(%p)->(%p)\n", This
, p
);
398 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
400 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
401 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
405 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
407 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
408 FIXME("(%p)->(%p)\n", This
, p
);
412 static HRESULT WINAPI
HTMLAnchorElement_put_hash(IHTMLAnchorElement
*iface
, BSTR v
)
414 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
415 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
419 static HRESULT WINAPI
HTMLAnchorElement_get_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
421 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
422 FIXME("(%p)->(%p)\n", This
, p
);
426 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
428 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
430 TRACE("(%p)->()\n", This
);
432 return IHTMLElement2_put_onblur(&This
->element
.IHTMLElement2_iface
, v
);
435 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
437 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
439 TRACE("(%p)->(%p)\n", This
, p
);
441 return IHTMLElement2_get_onblur(&This
->element
.IHTMLElement2_iface
, p
);
444 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
446 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
448 TRACE("(%p)->()\n", This
);
450 return IHTMLElement2_put_onfocus(&This
->element
.IHTMLElement2_iface
, v
);
453 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
455 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
457 TRACE("(%p)->(%p)\n", This
, p
);
459 return IHTMLElement2_get_onfocus(&This
->element
.IHTMLElement2_iface
, p
);
462 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
464 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
466 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
468 return IHTMLElement2_put_accessKey(&This
->element
.IHTMLElement2_iface
, v
);
471 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
473 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
475 TRACE("(%p)->(%p)\n", This
, p
);
477 return IHTMLElement2_get_accessKey(&This
->element
.IHTMLElement2_iface
, p
);
480 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
482 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
483 FIXME("(%p)->(%p)\n", This
, p
);
487 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
489 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
490 FIXME("(%p)->(%p)\n", This
, p
);
494 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
496 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
497 FIXME("(%p)->(%p)\n", This
, p
);
501 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
503 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
505 TRACE("(%p)->()\n", This
);
507 return IHTMLElement2_put_tabIndex(&This
->element
.IHTMLElement2_iface
, v
);
510 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
512 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
514 TRACE("(%p)->(%p)\n", This
, p
);
516 return IHTMLElement2_get_tabIndex(&This
->element
.IHTMLElement2_iface
, p
);
519 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
521 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
523 TRACE("(%p)\n", This
);
525 return IHTMLElement2_focus(&This
->element
.IHTMLElement2_iface
);
528 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
530 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
532 TRACE("(%p)\n", This
);
534 return IHTMLElement2_blur(&This
->element
.IHTMLElement2_iface
);
537 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
538 HTMLAnchorElement_QueryInterface
,
539 HTMLAnchorElement_AddRef
,
540 HTMLAnchorElement_Release
,
541 HTMLAnchorElement_GetTypeInfoCount
,
542 HTMLAnchorElement_GetTypeInfo
,
543 HTMLAnchorElement_GetIDsOfNames
,
544 HTMLAnchorElement_Invoke
,
545 HTMLAnchorElement_put_href
,
546 HTMLAnchorElement_get_href
,
547 HTMLAnchorElement_put_target
,
548 HTMLAnchorElement_get_target
,
549 HTMLAnchorElement_put_rel
,
550 HTMLAnchorElement_get_rel
,
551 HTMLAnchorElement_put_rev
,
552 HTMLAnchorElement_get_rev
,
553 HTMLAnchorElement_put_urn
,
554 HTMLAnchorElement_get_urn
,
555 HTMLAnchorElement_put_Methods
,
556 HTMLAnchorElement_get_Methods
,
557 HTMLAnchorElement_put_name
,
558 HTMLAnchorElement_get_name
,
559 HTMLAnchorElement_put_host
,
560 HTMLAnchorElement_get_host
,
561 HTMLAnchorElement_put_hostname
,
562 HTMLAnchorElement_get_hostname
,
563 HTMLAnchorElement_put_pathname
,
564 HTMLAnchorElement_get_pathname
,
565 HTMLAnchorElement_put_port
,
566 HTMLAnchorElement_get_port
,
567 HTMLAnchorElement_put_protocol
,
568 HTMLAnchorElement_get_protocol
,
569 HTMLAnchorElement_put_search
,
570 HTMLAnchorElement_get_search
,
571 HTMLAnchorElement_put_hash
,
572 HTMLAnchorElement_get_hash
,
573 HTMLAnchorElement_put_onblur
,
574 HTMLAnchorElement_get_onblur
,
575 HTMLAnchorElement_put_onfocus
,
576 HTMLAnchorElement_get_onfocus
,
577 HTMLAnchorElement_put_accessKey
,
578 HTMLAnchorElement_get_accessKey
,
579 HTMLAnchorElement_get_protocolLong
,
580 HTMLAnchorElement_get_mimeType
,
581 HTMLAnchorElement_get_nameProp
,
582 HTMLAnchorElement_put_tabIndex
,
583 HTMLAnchorElement_get_tabIndex
,
584 HTMLAnchorElement_focus
,
585 HTMLAnchorElement_blur
588 static inline HTMLAnchorElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
590 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, element
.node
);
593 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
595 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
599 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
600 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
601 *ppv
= &This
->IHTMLAnchorElement_iface
;
602 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
603 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
604 *ppv
= &This
->IHTMLAnchorElement_iface
;
605 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
606 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
607 *ppv
= &This
->IHTMLAnchorElement_iface
;
611 IUnknown_AddRef((IUnknown
*)*ppv
);
615 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
618 static void HTMLAnchorElement_destructor(HTMLDOMNode
*iface
)
620 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
623 nsIDOMHTMLAnchorElement_Release(This
->nsanchor
);
625 HTMLElement_destructor(&This
->element
.node
);
628 static HRESULT
HTMLAnchorElement_handle_event(HTMLDOMNode
*iface
, eventid_t eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
630 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
632 if(eid
== EVENTID_CLICK
) {
633 nsIDOMMouseEvent
*mouse_event
;
639 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
640 assert(nsres
== NS_OK
);
642 nsres
= nsIDOMMouseEvent_GetButton(mouse_event
, &button
);
643 assert(nsres
== NS_OK
);
645 nsIDOMMouseEvent_Release(mouse_event
);
649 *prevent_default
= TRUE
;
650 return navigate_anchor(This
);
652 *prevent_default
= TRUE
;
653 return navigate_anchor_window(This
, NULL
);
655 *prevent_default
= FALSE
;
663 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
664 HTMLAnchorElement_QI
,
665 HTMLAnchorElement_destructor
,
667 HTMLElement_get_attr_col
,
670 HTMLAnchorElement_handle_event
673 static const tid_t HTMLAnchorElement_iface_tids
[] = {
674 IHTMLAnchorElement_tid
,
676 IHTMLTextContainer_tid
,
681 static dispex_static_data_t HTMLAnchorElement_dispex
= {
683 DispHTMLAnchorElement_tid
,
685 HTMLAnchorElement_iface_tids
688 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
690 HTMLAnchorElement
*ret
;
693 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
695 return E_OUTOFMEMORY
;
697 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
698 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
700 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
701 if(NS_FAILED(nsres
)) {
702 ERR("Could not get nsIDOMHTMLAnchorElement iface: %08x\n", nsres
);
707 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
709 *elem
= &ret
->element
;