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 nsAString hostname_str;
380 TRACE("(%p)->(%p)\n", This, p);
382 nsAString_Init(&hostname_str, NULL);
383 nsres = nsIDOMHTMLAnchorElement_GetHostname(This->nsanchor, &hostname_str);
384 return return_nsstr(nsres, &hostname_str, p);
387 static HRESULT WINAPI HTMLAnchorElement_put_pathname(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_pathname(IHTMLAnchorElement *iface, BSTR *p)
396 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
397 FIXME("(%p)->(%p)\n", This, p);
401 static HRESULT WINAPI HTMLAnchorElement_put_port(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_port(IHTMLAnchorElement *iface, BSTR *p)
410 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
411 FIXME("(%p)->(%p)\n", This, p);
415 static HRESULT WINAPI HTMLAnchorElement_put_protocol(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_protocol(IHTMLAnchorElement *iface, BSTR *p)
424 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
425 FIXME("(%p)->(%p)\n", This, p);
429 static HRESULT WINAPI HTMLAnchorElement_put_search(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_search(IHTMLAnchorElement *iface, BSTR *p)
438 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
439 FIXME("(%p)->(%p)\n", This, p);
443 static HRESULT WINAPI HTMLAnchorElement_put_hash(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_hash(IHTMLAnchorElement *iface, BSTR *p)
452 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
453 FIXME("(%p)->(%p)\n", This, p);
457 static HRESULT WINAPI HTMLAnchorElement_put_onblur(IHTMLAnchorElement *iface, VARIANT v)
459 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
461 TRACE("(%p)->()\n", This);
463 return IHTMLElement2_put_onblur(&This->element.IHTMLElement2_iface, v);
466 static HRESULT WINAPI HTMLAnchorElement_get_onblur(IHTMLAnchorElement *iface, VARIANT *p)
468 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
470 TRACE("(%p)->(%p)\n", This, p);
472 return IHTMLElement2_get_onblur(&This->element.IHTMLElement2_iface, p);
475 static HRESULT WINAPI HTMLAnchorElement_put_onfocus(IHTMLAnchorElement *iface, VARIANT v)
477 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
479 TRACE("(%p)->()\n", This);
481 return IHTMLElement2_put_onfocus(&This->element.IHTMLElement2_iface, v);
484 static HRESULT WINAPI HTMLAnchorElement_get_onfocus(IHTMLAnchorElement *iface, VARIANT *p)
486 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
488 TRACE("(%p)->(%p)\n", This, p);
490 return IHTMLElement2_get_onfocus(&This->element.IHTMLElement2_iface, p);
493 static HRESULT WINAPI HTMLAnchorElement_put_accessKey(IHTMLAnchorElement *iface, BSTR v)
495 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
497 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
499 return IHTMLElement2_put_accessKey(&This->element.IHTMLElement2_iface, v);
502 static HRESULT WINAPI HTMLAnchorElement_get_accessKey(IHTMLAnchorElement *iface, BSTR *p)
504 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
506 TRACE("(%p)->(%p)\n", This, p);
508 return IHTMLElement2_get_accessKey(&This->element.IHTMLElement2_iface, p);
511 static HRESULT WINAPI HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement *iface, BSTR *p)
513 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
514 FIXME("(%p)->(%p)\n", This, p);
518 static HRESULT WINAPI HTMLAnchorElement_get_mimeType(IHTMLAnchorElement *iface, BSTR *p)
520 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
521 FIXME("(%p)->(%p)\n", This, p);
525 static HRESULT WINAPI HTMLAnchorElement_get_nameProp(IHTMLAnchorElement *iface, BSTR *p)
527 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
528 FIXME("(%p)->(%p)\n", This, p);
532 static HRESULT WINAPI HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement *iface, short v)
534 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
536 TRACE("(%p)->()\n", This);
538 return IHTMLElement2_put_tabIndex(&This->element.IHTMLElement2_iface, v);
541 static HRESULT WINAPI HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement *iface, short *p)
543 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
545 TRACE("(%p)->(%p)\n", This, p);
547 return IHTMLElement2_get_tabIndex(&This->element.IHTMLElement2_iface, p);
550 static HRESULT WINAPI HTMLAnchorElement_focus(IHTMLAnchorElement *iface)
552 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
554 TRACE("(%p)\n", This);
556 return IHTMLElement2_focus(&This->element.IHTMLElement2_iface);
559 static HRESULT WINAPI HTMLAnchorElement_blur(IHTMLAnchorElement *iface)
561 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
563 TRACE("(%p)\n", This);
565 return IHTMLElement2_blur(&This->element.IHTMLElement2_iface);
568 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl = {
569 HTMLAnchorElement_QueryInterface,
570 HTMLAnchorElement_AddRef,
571 HTMLAnchorElement_Release,
572 HTMLAnchorElement_GetTypeInfoCount,
573 HTMLAnchorElement_GetTypeInfo,
574 HTMLAnchorElement_GetIDsOfNames,
575 HTMLAnchorElement_Invoke,
576 HTMLAnchorElement_put_href,
577 HTMLAnchorElement_get_href,
578 HTMLAnchorElement_put_target,
579 HTMLAnchorElement_get_target,
580 HTMLAnchorElement_put_rel,
581 HTMLAnchorElement_get_rel,
582 HTMLAnchorElement_put_rev,
583 HTMLAnchorElement_get_rev,
584 HTMLAnchorElement_put_urn,
585 HTMLAnchorElement_get_urn,
586 HTMLAnchorElement_put_Methods,
587 HTMLAnchorElement_get_Methods,
588 HTMLAnchorElement_put_name,
589 HTMLAnchorElement_get_name,
590 HTMLAnchorElement_put_host,
591 HTMLAnchorElement_get_host,
592 HTMLAnchorElement_put_hostname,
593 HTMLAnchorElement_get_hostname,
594 HTMLAnchorElement_put_pathname,
595 HTMLAnchorElement_get_pathname,
596 HTMLAnchorElement_put_port,
597 HTMLAnchorElement_get_port,
598 HTMLAnchorElement_put_protocol,
599 HTMLAnchorElement_get_protocol,
600 HTMLAnchorElement_put_search,
601 HTMLAnchorElement_get_search,
602 HTMLAnchorElement_put_hash,
603 HTMLAnchorElement_get_hash,
604 HTMLAnchorElement_put_onblur,
605 HTMLAnchorElement_get_onblur,
606 HTMLAnchorElement_put_onfocus,
607 HTMLAnchorElement_get_onfocus,
608 HTMLAnchorElement_put_accessKey,
609 HTMLAnchorElement_get_accessKey,
610 HTMLAnchorElement_get_protocolLong,
611 HTMLAnchorElement_get_mimeType,
612 HTMLAnchorElement_get_nameProp,
613 HTMLAnchorElement_put_tabIndex,
614 HTMLAnchorElement_get_tabIndex,
615 HTMLAnchorElement_focus,
616 HTMLAnchorElement_blur
619 static inline HTMLAnchorElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
621 return CONTAINING_RECORD(iface, HTMLAnchorElement, element.node);
624 static HRESULT HTMLAnchorElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
626 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
630 if(IsEqualGUID(&IID_IUnknown, riid)) {
631 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
632 *ppv = &This->IHTMLAnchorElement_iface;
633 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
634 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
635 *ppv = &This->IHTMLAnchorElement_iface;
636 }else if(IsEqualGUID(&IID_IHTMLAnchorElement, riid)) {
637 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This, ppv);
638 *ppv = &This->IHTMLAnchorElement_iface;
642 IUnknown_AddRef((IUnknown*)*ppv);
646 return HTMLElement_QI(&This->element.node, riid, ppv);
649 static HRESULT HTMLAnchorElement_handle_event(HTMLDOMNode *iface, eventid_t eid, nsIDOMEvent *event, BOOL *prevent_default)
651 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
653 if(eid == EVENTID_CLICK) {
654 nsIDOMMouseEvent *mouse_event;
660 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
661 assert(nsres == NS_OK);
663 nsres = nsIDOMMouseEvent_GetButton(mouse_event, &button);
664 assert(nsres == NS_OK);
666 nsIDOMMouseEvent_Release(mouse_event);
670 *prevent_default = TRUE;
671 return navigate_anchor(This);
673 *prevent_default = TRUE;
674 return navigate_anchor_window(This, NULL);
676 *prevent_default = FALSE;
681 return HTMLElement_handle_event(&This->element.node, eid, event, prevent_default);
684 static const NodeImplVtbl HTMLAnchorElementImplVtbl = {
685 HTMLAnchorElement_QI,
686 HTMLElement_destructor,
689 HTMLAnchorElement_handle_event,
690 HTMLElement_get_attr_col
693 static const tid_t HTMLAnchorElement_iface_tids[] = {
694 IHTMLAnchorElement_tid,
700 static dispex_static_data_t HTMLAnchorElement_dispex = {
702 DispHTMLAnchorElement_tid,
704 HTMLAnchorElement_iface_tids
707 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
709 HTMLAnchorElement *ret;
712 ret = heap_alloc_zero(sizeof(HTMLAnchorElement));
714 return E_OUTOFMEMORY;
716 ret->IHTMLAnchorElement_iface.lpVtbl = &HTMLAnchorElementVtbl;
717 ret->element.node.vtbl = &HTMLAnchorElementImplVtbl;
719 HTMLElement_Init(&ret->element, doc, nselem, &HTMLAnchorElement_dispex);
721 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLAnchorElement, (void**)&ret->nsanchor);
723 /* Shere the reference with nsnode */
724 assert(nsres == NS_OK && (nsIDOMNode*)ret->nsanchor == ret->element.node.nsnode);
725 nsIDOMNode_Release(ret->element.node.nsnode);
727 *elem = &ret->element;