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 TRACE("target %s\n", debugstr_w(target
));
91 if(*target
&& strcmpiW(target
, _selfW
)) {
92 if(!strcmpiW(target
, _topW
)) {
93 TRACE("target _top\n");
94 get_top_window(This
->element
.node
.doc
->basedoc
.window
, &window
);
95 }else if(!strcmpiW(target
, _parentW
)) {
96 FIXME("Navigating to target _parent is not implemented\n");
97 nsAString_Finish(&target_str
);
100 HTMLOuterWindow
*top_window
;
102 get_top_window(This
->element
.node
.doc
->basedoc
.window
, &top_window
);
104 hres
= get_frame_by_name(top_window
, target
, TRUE
, &window
);
105 if(FAILED(hres
) || !window
) {
106 hres
= navigate_anchor_window(This
, target
);
107 nsAString_Finish(&target_str
);
113 nsAString_Finish(&target_str
);
115 nsAString_Init(&href_str
, NULL
);
116 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
117 if(NS_SUCCEEDED(nsres
)) {
118 const PRUnichar
*href
;
120 nsAString_GetData(&href_str
, &href
);
123 window
= This
->element
.node
.doc
->basedoc
.window
;
124 hres
= navigate_url(window
, href
, window
->uri
, BINDING_NAVIGATED
);
126 TRACE("empty href\n");
130 nsAString_Finish(&href_str
);
134 static inline HTMLAnchorElement
*impl_from_IHTMLAnchorElement(IHTMLAnchorElement
*iface
)
136 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, IHTMLAnchorElement_iface
);
139 static HRESULT WINAPI
HTMLAnchorElement_QueryInterface(IHTMLAnchorElement
*iface
,
140 REFIID riid
, void **ppv
)
142 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
144 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
147 static ULONG WINAPI
HTMLAnchorElement_AddRef(IHTMLAnchorElement
*iface
)
149 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
151 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
154 static ULONG WINAPI
HTMLAnchorElement_Release(IHTMLAnchorElement
*iface
)
156 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
158 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
161 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement
*iface
, UINT
*pctinfo
)
163 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
164 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
167 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement
*iface
, UINT iTInfo
,
168 LCID lcid
, ITypeInfo
**ppTInfo
)
170 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
171 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
175 static HRESULT WINAPI
HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement
*iface
, REFIID riid
,
176 LPOLESTR
*rgszNames
, UINT cNames
,
177 LCID lcid
, DISPID
*rgDispId
)
179 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
180 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
181 cNames
, lcid
, rgDispId
);
184 static HRESULT WINAPI
HTMLAnchorElement_Invoke(IHTMLAnchorElement
*iface
, DISPID dispIdMember
,
185 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
186 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
188 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
189 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
190 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
193 static HRESULT WINAPI
HTMLAnchorElement_put_href(IHTMLAnchorElement
*iface
, BSTR v
)
195 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
199 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
201 nsAString_InitDepend(&nsstr
, v
);
202 nsres
= nsIDOMHTMLAnchorElement_SetHref(This
->nsanchor
, &nsstr
);
203 nsAString_Finish(&nsstr
);
210 static HRESULT WINAPI
HTMLAnchorElement_get_href(IHTMLAnchorElement
*iface
, BSTR
*p
)
212 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
217 TRACE("(%p)->(%p)\n", This
, p
);
219 nsAString_Init(&href_str
, NULL
);
220 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
221 if(NS_SUCCEEDED(nsres
)) {
222 const PRUnichar
*href
;
224 nsAString_GetData(&href_str
, &href
);
225 hres
= nsuri_to_url(href
, TRUE
, p
);
227 ERR("GetHref failed: %08x\n", nsres
);
231 nsAString_Finish(&href_str
);
235 static HRESULT WINAPI
HTMLAnchorElement_put_target(IHTMLAnchorElement
*iface
, BSTR v
)
237 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
241 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
243 nsAString_InitDepend(&nsstr
, v
);
244 nsres
= nsIDOMHTMLAnchorElement_SetTarget(This
->nsanchor
, &nsstr
);
245 nsAString_Finish(&nsstr
);
252 static HRESULT WINAPI
HTMLAnchorElement_get_target(IHTMLAnchorElement
*iface
, BSTR
*p
)
254 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
255 nsAString target_str
;
258 TRACE("(%p)->(%p)\n", This
, p
);
260 nsAString_Init(&target_str
, NULL
);
261 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
263 return return_nsstr(nsres
, &target_str
, p
);
266 static HRESULT WINAPI
HTMLAnchorElement_put_rel(IHTMLAnchorElement
*iface
, BSTR v
)
268 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
269 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
273 static HRESULT WINAPI
HTMLAnchorElement_get_rel(IHTMLAnchorElement
*iface
, BSTR
*p
)
275 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
276 FIXME("(%p)->(%p)\n", This
, p
);
280 static HRESULT WINAPI
HTMLAnchorElement_put_rev(IHTMLAnchorElement
*iface
, BSTR v
)
282 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
283 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
287 static HRESULT WINAPI
HTMLAnchorElement_get_rev(IHTMLAnchorElement
*iface
, BSTR
*p
)
289 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
290 FIXME("(%p)->(%p)\n", This
, p
);
294 static HRESULT WINAPI
HTMLAnchorElement_put_urn(IHTMLAnchorElement
*iface
, BSTR v
)
296 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
297 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
301 static HRESULT WINAPI
HTMLAnchorElement_get_urn(IHTMLAnchorElement
*iface
, BSTR
*p
)
303 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
304 FIXME("(%p)->(%p)\n", This
, p
);
308 static HRESULT WINAPI
HTMLAnchorElement_put_Methods(IHTMLAnchorElement
*iface
, BSTR v
)
310 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
311 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
315 static HRESULT WINAPI
HTMLAnchorElement_get_Methods(IHTMLAnchorElement
*iface
, BSTR
*p
)
317 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
318 FIXME("(%p)->(%p)\n", This
, p
);
322 static HRESULT WINAPI
HTMLAnchorElement_put_name(IHTMLAnchorElement
*iface
, BSTR v
)
324 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
328 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
330 nsAString_InitDepend(&nsstr
, v
);
331 nsres
= nsIDOMHTMLAnchorElement_SetName(This
->nsanchor
, &nsstr
);
332 nsAString_Finish(&nsstr
);
339 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
341 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
345 TRACE("(%p)->(%p)\n", This
, p
);
347 nsAString_Init(&name_str
, NULL
);
348 nsres
= nsIDOMHTMLAnchorElement_GetName(This
->nsanchor
, &name_str
);
350 return return_nsstr(nsres
, &name_str
, p
);
353 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
355 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
356 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
360 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
362 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
363 FIXME("(%p)->(%p)\n", This
, p
);
367 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
369 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
370 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
374 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
376 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
377 FIXME("(%p)->(%p)\n", This
, p
);
381 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
383 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
384 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
388 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
390 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
391 FIXME("(%p)->(%p)\n", This
, p
);
395 static HRESULT WINAPI
HTMLAnchorElement_put_port(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_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
404 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
405 FIXME("(%p)->(%p)\n", This
, p
);
409 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(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_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
418 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
419 FIXME("(%p)->(%p)\n", This
, p
);
423 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
425 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
426 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
430 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
432 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
433 FIXME("(%p)->(%p)\n", This
, p
);
437 static HRESULT WINAPI
HTMLAnchorElement_put_hash(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_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
446 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
447 FIXME("(%p)->(%p)\n", This
, p
);
451 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
453 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
455 TRACE("(%p)->()\n", This
);
457 return IHTMLElement2_put_onblur(&This
->element
.IHTMLElement2_iface
, v
);
460 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
462 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
464 TRACE("(%p)->(%p)\n", This
, p
);
466 return IHTMLElement2_get_onblur(&This
->element
.IHTMLElement2_iface
, p
);
469 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
471 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
473 TRACE("(%p)->()\n", This
);
475 return IHTMLElement2_put_onfocus(&This
->element
.IHTMLElement2_iface
, v
);
478 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
480 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
482 TRACE("(%p)->(%p)\n", This
, p
);
484 return IHTMLElement2_get_onfocus(&This
->element
.IHTMLElement2_iface
, p
);
487 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
489 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
491 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
493 return IHTMLElement2_put_accessKey(&This
->element
.IHTMLElement2_iface
, v
);
496 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
498 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
500 TRACE("(%p)->(%p)\n", This
, p
);
502 return IHTMLElement2_get_accessKey(&This
->element
.IHTMLElement2_iface
, p
);
505 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
507 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
508 FIXME("(%p)->(%p)\n", This
, p
);
512 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
514 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
515 FIXME("(%p)->(%p)\n", This
, p
);
519 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
521 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
522 FIXME("(%p)->(%p)\n", This
, p
);
526 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
528 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
530 TRACE("(%p)->()\n", This
);
532 return IHTMLElement2_put_tabIndex(&This
->element
.IHTMLElement2_iface
, v
);
535 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
537 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
539 TRACE("(%p)->(%p)\n", This
, p
);
541 return IHTMLElement2_get_tabIndex(&This
->element
.IHTMLElement2_iface
, p
);
544 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
546 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
548 TRACE("(%p)\n", This
);
550 return IHTMLElement2_focus(&This
->element
.IHTMLElement2_iface
);
553 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
555 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
557 TRACE("(%p)\n", This
);
559 return IHTMLElement2_blur(&This
->element
.IHTMLElement2_iface
);
562 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
563 HTMLAnchorElement_QueryInterface
,
564 HTMLAnchorElement_AddRef
,
565 HTMLAnchorElement_Release
,
566 HTMLAnchorElement_GetTypeInfoCount
,
567 HTMLAnchorElement_GetTypeInfo
,
568 HTMLAnchorElement_GetIDsOfNames
,
569 HTMLAnchorElement_Invoke
,
570 HTMLAnchorElement_put_href
,
571 HTMLAnchorElement_get_href
,
572 HTMLAnchorElement_put_target
,
573 HTMLAnchorElement_get_target
,
574 HTMLAnchorElement_put_rel
,
575 HTMLAnchorElement_get_rel
,
576 HTMLAnchorElement_put_rev
,
577 HTMLAnchorElement_get_rev
,
578 HTMLAnchorElement_put_urn
,
579 HTMLAnchorElement_get_urn
,
580 HTMLAnchorElement_put_Methods
,
581 HTMLAnchorElement_get_Methods
,
582 HTMLAnchorElement_put_name
,
583 HTMLAnchorElement_get_name
,
584 HTMLAnchorElement_put_host
,
585 HTMLAnchorElement_get_host
,
586 HTMLAnchorElement_put_hostname
,
587 HTMLAnchorElement_get_hostname
,
588 HTMLAnchorElement_put_pathname
,
589 HTMLAnchorElement_get_pathname
,
590 HTMLAnchorElement_put_port
,
591 HTMLAnchorElement_get_port
,
592 HTMLAnchorElement_put_protocol
,
593 HTMLAnchorElement_get_protocol
,
594 HTMLAnchorElement_put_search
,
595 HTMLAnchorElement_get_search
,
596 HTMLAnchorElement_put_hash
,
597 HTMLAnchorElement_get_hash
,
598 HTMLAnchorElement_put_onblur
,
599 HTMLAnchorElement_get_onblur
,
600 HTMLAnchorElement_put_onfocus
,
601 HTMLAnchorElement_get_onfocus
,
602 HTMLAnchorElement_put_accessKey
,
603 HTMLAnchorElement_get_accessKey
,
604 HTMLAnchorElement_get_protocolLong
,
605 HTMLAnchorElement_get_mimeType
,
606 HTMLAnchorElement_get_nameProp
,
607 HTMLAnchorElement_put_tabIndex
,
608 HTMLAnchorElement_get_tabIndex
,
609 HTMLAnchorElement_focus
,
610 HTMLAnchorElement_blur
613 static inline HTMLAnchorElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
615 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, element
.node
);
618 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
620 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
624 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
625 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
626 *ppv
= &This
->IHTMLAnchorElement_iface
;
627 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
628 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
629 *ppv
= &This
->IHTMLAnchorElement_iface
;
630 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
631 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
632 *ppv
= &This
->IHTMLAnchorElement_iface
;
636 IUnknown_AddRef((IUnknown
*)*ppv
);
640 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
643 static HRESULT
HTMLAnchorElement_handle_event(HTMLDOMNode
*iface
, eventid_t eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
645 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
647 if(eid
== EVENTID_CLICK
) {
648 nsIDOMMouseEvent
*mouse_event
;
654 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
655 assert(nsres
== NS_OK
);
657 nsres
= nsIDOMMouseEvent_GetButton(mouse_event
, &button
);
658 assert(nsres
== NS_OK
);
660 nsIDOMMouseEvent_Release(mouse_event
);
664 *prevent_default
= TRUE
;
665 return navigate_anchor(This
);
667 *prevent_default
= TRUE
;
668 return navigate_anchor_window(This
, NULL
);
670 *prevent_default
= FALSE
;
675 return HTMLElement_handle_event(&This
->element
.node
, eid
, event
, prevent_default
);
678 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
679 HTMLAnchorElement_QI
,
680 HTMLElement_destructor
,
682 HTMLAnchorElement_handle_event
,
683 HTMLElement_get_attr_col
686 static const tid_t HTMLAnchorElement_iface_tids
[] = {
687 IHTMLAnchorElement_tid
,
689 IHTMLTextContainer_tid
,
694 static dispex_static_data_t HTMLAnchorElement_dispex
= {
696 DispHTMLAnchorElement_tid
,
698 HTMLAnchorElement_iface_tids
701 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
703 HTMLAnchorElement
*ret
;
706 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
708 return E_OUTOFMEMORY
;
710 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
711 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
713 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
715 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
717 /* Shere the reference with nsnode */
718 assert(nsres
== NS_OK
&& (nsIDOMNode
*)ret
->nsanchor
== ret
->element
.node
.nsnode
);
719 nsIDOMNode_Release(ret
->element
.node
.nsnode
);
721 *elem
= &ret
->element
;