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
19 #include "mshtml_private.h"
24 IHTMLAnchorElement IHTMLAnchorElement_iface
;
26 nsIDOMHTMLAnchorElement
*nsanchor
;
29 static HRESULT
navigate_anchor_window(HTMLAnchorElement
*This
, const WCHAR
*target
)
36 nsAString_Init(&href_str
, NULL
);
37 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
38 if(NS_SUCCEEDED(nsres
)) {
39 const PRUnichar
*href
;
41 nsAString_GetData(&href_str
, &href
);
42 hres
= create_relative_uri(This
->element
.node
.doc
->basedoc
.window
, href
, &uri
);
44 ERR("Could not get anchor href: %08x\n", nsres
);
47 nsAString_Finish(&href_str
);
51 hres
= navigate_new_window(This
->element
.node
.doc
->basedoc
.window
, uri
, target
, NULL
);
56 HTMLOuterWindow
*get_target_window(HTMLOuterWindow
*window
, nsAString
*target_str
, BOOL
*use_new_window
)
58 HTMLOuterWindow
*top_window
, *ret_window
;
59 const PRUnichar
*target
;
62 static const WCHAR _parentW
[] = {'_','p','a','r','e','n','t',0};
63 static const WCHAR _selfW
[] = {'_','s','e','l','f',0};
64 static const WCHAR _topW
[] = {'_','t','o','p',0};
66 *use_new_window
= FALSE
;
68 nsAString_GetData(target_str
, &target
);
69 TRACE("%s\n", debugstr_w(target
));
71 if(!*target
|| !strcmpiW(target
, _selfW
)) {
72 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
76 if(!strcmpiW(target
, _topW
)) {
77 get_top_window(window
, &top_window
);
78 IHTMLWindow2_AddRef(&top_window
->base
.IHTMLWindow2_iface
);
82 if(!strcmpiW(target
, _parentW
)) {
84 WARN("Window has no parent, treat as self\n");
85 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
89 IHTMLWindow2_AddRef(&window
->parent
->base
.IHTMLWindow2_iface
);
90 return window
->parent
;
93 get_top_window(window
, &top_window
);
95 hres
= get_frame_by_name(top_window
, target
, TRUE
, &ret_window
);
96 if(FAILED(hres
) || !ret_window
) {
97 *use_new_window
= TRUE
;
101 IHTMLWindow2_AddRef(&ret_window
->base
.IHTMLWindow2_iface
);
105 static HRESULT
navigate_anchor(HTMLAnchorElement
*This
)
107 nsAString href_str
, target_str
;
108 HTMLOuterWindow
*window
;
111 HRESULT hres
= E_FAIL
;
114 nsAString_Init(&target_str
, NULL
);
115 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
119 window
= get_target_window(This
->element
.node
.doc
->basedoc
.window
, &target_str
, &use_new_window
);
120 if(!window
&& use_new_window
) {
121 const PRUnichar
*target
;
123 nsAString_GetData(&target_str
, &target
);
124 hres
= navigate_anchor_window(This
, target
);
125 nsAString_Finish(&target_str
);
129 nsAString_Finish(&target_str
);
133 nsAString_Init(&href_str
, NULL
);
134 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
135 if(NS_SUCCEEDED(nsres
)) {
136 const PRUnichar
*href
;
138 nsAString_GetData(&href_str
, &href
);
140 hres
= navigate_url(window
, href
, window
->uri_nofrag
, BINDING_NAVIGATED
);
142 TRACE("empty href\n");
146 nsAString_Finish(&href_str
);
147 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
151 static inline HTMLAnchorElement
*impl_from_IHTMLAnchorElement(IHTMLAnchorElement
*iface
)
153 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, IHTMLAnchorElement_iface
);
156 static HRESULT WINAPI
HTMLAnchorElement_QueryInterface(IHTMLAnchorElement
*iface
,
157 REFIID riid
, void **ppv
)
159 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
161 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
164 static ULONG WINAPI
HTMLAnchorElement_AddRef(IHTMLAnchorElement
*iface
)
166 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
168 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
171 static ULONG WINAPI
HTMLAnchorElement_Release(IHTMLAnchorElement
*iface
)
173 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
175 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
178 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement
*iface
, UINT
*pctinfo
)
180 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
181 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
184 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement
*iface
, UINT iTInfo
,
185 LCID lcid
, ITypeInfo
**ppTInfo
)
187 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
188 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
192 static HRESULT WINAPI
HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement
*iface
, REFIID riid
,
193 LPOLESTR
*rgszNames
, UINT cNames
,
194 LCID lcid
, DISPID
*rgDispId
)
196 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
197 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
198 cNames
, lcid
, rgDispId
);
201 static HRESULT WINAPI
HTMLAnchorElement_Invoke(IHTMLAnchorElement
*iface
, DISPID dispIdMember
,
202 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
203 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
205 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
206 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
207 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
210 static HRESULT WINAPI
HTMLAnchorElement_put_href(IHTMLAnchorElement
*iface
, BSTR v
)
212 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
216 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
218 nsAString_InitDepend(&nsstr
, v
);
219 nsres
= nsIDOMHTMLAnchorElement_SetHref(This
->nsanchor
, &nsstr
);
220 nsAString_Finish(&nsstr
);
227 static HRESULT WINAPI
HTMLAnchorElement_get_href(IHTMLAnchorElement
*iface
, BSTR
*p
)
229 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
234 TRACE("(%p)->(%p)\n", This
, p
);
236 nsAString_Init(&href_str
, NULL
);
237 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
238 if(NS_SUCCEEDED(nsres
)) {
239 const PRUnichar
*href
;
241 nsAString_GetData(&href_str
, &href
);
242 hres
= nsuri_to_url(href
, TRUE
, p
);
244 ERR("GetHref failed: %08x\n", nsres
);
248 nsAString_Finish(&href_str
);
252 static HRESULT WINAPI
HTMLAnchorElement_put_target(IHTMLAnchorElement
*iface
, BSTR v
)
254 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
258 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
260 nsAString_InitDepend(&nsstr
, v
);
261 nsres
= nsIDOMHTMLAnchorElement_SetTarget(This
->nsanchor
, &nsstr
);
262 nsAString_Finish(&nsstr
);
269 static HRESULT WINAPI
HTMLAnchorElement_get_target(IHTMLAnchorElement
*iface
, BSTR
*p
)
271 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
272 nsAString target_str
;
275 TRACE("(%p)->(%p)\n", This
, p
);
277 nsAString_Init(&target_str
, NULL
);
278 nsres
= nsIDOMHTMLAnchorElement_GetTarget(This
->nsanchor
, &target_str
);
280 return return_nsstr(nsres
, &target_str
, p
);
283 static HRESULT WINAPI
HTMLAnchorElement_put_rel(IHTMLAnchorElement
*iface
, BSTR v
)
285 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
289 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
291 nsAString_InitDepend(&nsstr
, v
);
292 nsres
= nsIDOMHTMLAnchorElement_SetRel(This
->nsanchor
, &nsstr
);
293 nsAString_Finish(&nsstr
);
300 static HRESULT WINAPI
HTMLAnchorElement_get_rel(IHTMLAnchorElement
*iface
, BSTR
*p
)
302 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
306 TRACE("(%p)->(%p)\n", This
, p
);
308 nsAString_Init(&nsstr
, NULL
);
309 nsres
= nsIDOMHTMLAnchorElement_GetRel(This
->nsanchor
, &nsstr
);
310 return return_nsstr(nsres
, &nsstr
, p
);
313 static HRESULT WINAPI
HTMLAnchorElement_put_rev(IHTMLAnchorElement
*iface
, BSTR v
)
315 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
316 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
320 static HRESULT WINAPI
HTMLAnchorElement_get_rev(IHTMLAnchorElement
*iface
, BSTR
*p
)
322 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
323 FIXME("(%p)->(%p)\n", This
, p
);
327 static HRESULT WINAPI
HTMLAnchorElement_put_urn(IHTMLAnchorElement
*iface
, BSTR v
)
329 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
330 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
334 static HRESULT WINAPI
HTMLAnchorElement_get_urn(IHTMLAnchorElement
*iface
, BSTR
*p
)
336 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
337 FIXME("(%p)->(%p)\n", This
, p
);
341 static HRESULT WINAPI
HTMLAnchorElement_put_Methods(IHTMLAnchorElement
*iface
, BSTR v
)
343 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
344 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
348 static HRESULT WINAPI
HTMLAnchorElement_get_Methods(IHTMLAnchorElement
*iface
, BSTR
*p
)
350 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
351 FIXME("(%p)->(%p)\n", This
, p
);
355 static HRESULT WINAPI
HTMLAnchorElement_put_name(IHTMLAnchorElement
*iface
, BSTR v
)
357 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
361 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
363 nsAString_InitDepend(&nsstr
, v
);
364 nsres
= nsIDOMHTMLAnchorElement_SetName(This
->nsanchor
, &nsstr
);
365 nsAString_Finish(&nsstr
);
372 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
374 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
378 TRACE("(%p)->(%p)\n", This
, p
);
380 nsAString_Init(&name_str
, NULL
);
381 nsres
= nsIDOMHTMLAnchorElement_GetName(This
->nsanchor
, &name_str
);
383 return return_nsstr(nsres
, &name_str
, p
);
386 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
388 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
389 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
393 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
395 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
396 FIXME("(%p)->(%p)\n", This
, p
);
400 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
402 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
403 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
407 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
409 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
410 nsAString hostname_str
;
413 TRACE("(%p)->(%p)\n", This
, p
);
415 nsAString_Init(&hostname_str
, NULL
);
416 nsres
= nsIDOMHTMLAnchorElement_GetHostname(This
->nsanchor
, &hostname_str
);
417 return return_nsstr(nsres
, &hostname_str
, p
);
420 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
422 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
423 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
427 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
429 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
430 FIXME("(%p)->(%p)\n", This
, p
);
434 static HRESULT WINAPI
HTMLAnchorElement_put_port(IHTMLAnchorElement
*iface
, BSTR v
)
436 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
437 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
441 static HRESULT WINAPI
HTMLAnchorElement_get_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
443 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
444 FIXME("(%p)->(%p)\n", This
, p
);
448 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(IHTMLAnchorElement
*iface
, BSTR v
)
450 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
451 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
455 static HRESULT WINAPI
HTMLAnchorElement_get_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
457 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
458 FIXME("(%p)->(%p)\n", This
, p
);
462 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
464 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
465 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
469 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
471 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
472 FIXME("(%p)->(%p)\n", This
, p
);
476 static HRESULT WINAPI
HTMLAnchorElement_put_hash(IHTMLAnchorElement
*iface
, BSTR v
)
478 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
479 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
483 static HRESULT WINAPI
HTMLAnchorElement_get_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
485 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
489 TRACE("(%p)->(%p)\n", This
, p
);
491 nsAString_Init(&hash_str
, NULL
);
492 nsres
= nsIDOMHTMLAnchorElement_GetHash(This
->nsanchor
, &hash_str
);
493 return return_nsstr(nsres
, &hash_str
, p
);
496 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
498 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
500 TRACE("(%p)->()\n", This
);
502 return IHTMLElement2_put_onblur(&This
->element
.IHTMLElement2_iface
, v
);
505 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
507 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
509 TRACE("(%p)->(%p)\n", This
, p
);
511 return IHTMLElement2_get_onblur(&This
->element
.IHTMLElement2_iface
, p
);
514 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
516 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
518 TRACE("(%p)->()\n", This
);
520 return IHTMLElement2_put_onfocus(&This
->element
.IHTMLElement2_iface
, v
);
523 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
525 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
527 TRACE("(%p)->(%p)\n", This
, p
);
529 return IHTMLElement2_get_onfocus(&This
->element
.IHTMLElement2_iface
, p
);
532 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
534 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
536 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
538 return IHTMLElement2_put_accessKey(&This
->element
.IHTMLElement2_iface
, v
);
541 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
543 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
545 TRACE("(%p)->(%p)\n", This
, p
);
547 return IHTMLElement2_get_accessKey(&This
->element
.IHTMLElement2_iface
, p
);
550 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
552 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
553 FIXME("(%p)->(%p)\n", This
, p
);
557 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
559 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
560 FIXME("(%p)->(%p)\n", This
, p
);
564 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
566 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
567 FIXME("(%p)->(%p)\n", This
, p
);
571 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
573 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
575 TRACE("(%p)->()\n", This
);
577 return IHTMLElement2_put_tabIndex(&This
->element
.IHTMLElement2_iface
, v
);
580 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
582 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
584 TRACE("(%p)->(%p)\n", This
, p
);
586 return IHTMLElement2_get_tabIndex(&This
->element
.IHTMLElement2_iface
, p
);
589 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
591 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
593 TRACE("(%p)\n", This
);
595 return IHTMLElement2_focus(&This
->element
.IHTMLElement2_iface
);
598 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
600 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
602 TRACE("(%p)\n", This
);
604 return IHTMLElement2_blur(&This
->element
.IHTMLElement2_iface
);
607 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
608 HTMLAnchorElement_QueryInterface
,
609 HTMLAnchorElement_AddRef
,
610 HTMLAnchorElement_Release
,
611 HTMLAnchorElement_GetTypeInfoCount
,
612 HTMLAnchorElement_GetTypeInfo
,
613 HTMLAnchorElement_GetIDsOfNames
,
614 HTMLAnchorElement_Invoke
,
615 HTMLAnchorElement_put_href
,
616 HTMLAnchorElement_get_href
,
617 HTMLAnchorElement_put_target
,
618 HTMLAnchorElement_get_target
,
619 HTMLAnchorElement_put_rel
,
620 HTMLAnchorElement_get_rel
,
621 HTMLAnchorElement_put_rev
,
622 HTMLAnchorElement_get_rev
,
623 HTMLAnchorElement_put_urn
,
624 HTMLAnchorElement_get_urn
,
625 HTMLAnchorElement_put_Methods
,
626 HTMLAnchorElement_get_Methods
,
627 HTMLAnchorElement_put_name
,
628 HTMLAnchorElement_get_name
,
629 HTMLAnchorElement_put_host
,
630 HTMLAnchorElement_get_host
,
631 HTMLAnchorElement_put_hostname
,
632 HTMLAnchorElement_get_hostname
,
633 HTMLAnchorElement_put_pathname
,
634 HTMLAnchorElement_get_pathname
,
635 HTMLAnchorElement_put_port
,
636 HTMLAnchorElement_get_port
,
637 HTMLAnchorElement_put_protocol
,
638 HTMLAnchorElement_get_protocol
,
639 HTMLAnchorElement_put_search
,
640 HTMLAnchorElement_get_search
,
641 HTMLAnchorElement_put_hash
,
642 HTMLAnchorElement_get_hash
,
643 HTMLAnchorElement_put_onblur
,
644 HTMLAnchorElement_get_onblur
,
645 HTMLAnchorElement_put_onfocus
,
646 HTMLAnchorElement_get_onfocus
,
647 HTMLAnchorElement_put_accessKey
,
648 HTMLAnchorElement_get_accessKey
,
649 HTMLAnchorElement_get_protocolLong
,
650 HTMLAnchorElement_get_mimeType
,
651 HTMLAnchorElement_get_nameProp
,
652 HTMLAnchorElement_put_tabIndex
,
653 HTMLAnchorElement_get_tabIndex
,
654 HTMLAnchorElement_focus
,
655 HTMLAnchorElement_blur
658 static inline HTMLAnchorElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
660 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, element
.node
);
663 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
665 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
669 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
670 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
671 *ppv
= &This
->IHTMLAnchorElement_iface
;
672 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
673 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
674 *ppv
= &This
->IHTMLAnchorElement_iface
;
675 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
676 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
677 *ppv
= &This
->IHTMLAnchorElement_iface
;
681 IUnknown_AddRef((IUnknown
*)*ppv
);
685 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
688 static HRESULT
HTMLAnchorElement_handle_event(HTMLDOMNode
*iface
, eventid_t eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
690 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
692 if(eid
== EVENTID_CLICK
) {
693 nsIDOMMouseEvent
*mouse_event
;
699 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
700 assert(nsres
== NS_OK
);
702 nsres
= nsIDOMMouseEvent_GetButton(mouse_event
, &button
);
703 assert(nsres
== NS_OK
);
705 nsIDOMMouseEvent_Release(mouse_event
);
709 *prevent_default
= TRUE
;
710 return navigate_anchor(This
);
712 *prevent_default
= TRUE
;
713 return navigate_anchor_window(This
, NULL
);
715 *prevent_default
= FALSE
;
720 return HTMLElement_handle_event(&This
->element
.node
, eid
, event
, prevent_default
);
723 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
724 HTMLAnchorElement_QI
,
725 HTMLElement_destructor
,
728 HTMLAnchorElement_handle_event
,
729 HTMLElement_get_attr_col
732 static const tid_t HTMLAnchorElement_iface_tids
[] = {
733 IHTMLAnchorElement_tid
,
739 static dispex_static_data_t HTMLAnchorElement_dispex
= {
741 DispHTMLAnchorElement_tid
,
743 HTMLAnchorElement_iface_tids
746 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
748 HTMLAnchorElement
*ret
;
751 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
753 return E_OUTOFMEMORY
;
755 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
756 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
758 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
760 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
762 /* Shere the reference with nsnode */
763 assert(nsres
== NS_OK
&& (nsIDOMNode
*)ret
->nsanchor
== ret
->element
.node
.nsnode
);
764 nsIDOMNode_Release(ret
->element
.node
.nsnode
);
766 *elem
= &ret
->element
;