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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 IHTMLAnchorElement IHTMLAnchorElement_iface
;
40 nsIDOMHTMLAnchorElement
*nsanchor
;
43 static inline HTMLAnchorElement
*impl_from_IHTMLAnchorElement(IHTMLAnchorElement
*iface
)
45 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, IHTMLAnchorElement_iface
);
48 static HRESULT WINAPI
HTMLAnchorElement_QueryInterface(IHTMLAnchorElement
*iface
,
49 REFIID riid
, void **ppv
)
51 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
53 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
56 static ULONG WINAPI
HTMLAnchorElement_AddRef(IHTMLAnchorElement
*iface
)
58 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
60 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
63 static ULONG WINAPI
HTMLAnchorElement_Release(IHTMLAnchorElement
*iface
)
65 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
67 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
70 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement
*iface
, UINT
*pctinfo
)
72 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
73 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
76 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement
*iface
, UINT iTInfo
,
77 LCID lcid
, ITypeInfo
**ppTInfo
)
79 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
80 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
84 static HRESULT WINAPI
HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement
*iface
, REFIID riid
,
85 LPOLESTR
*rgszNames
, UINT cNames
,
86 LCID lcid
, DISPID
*rgDispId
)
88 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
89 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
90 cNames
, lcid
, rgDispId
);
93 static HRESULT WINAPI
HTMLAnchorElement_Invoke(IHTMLAnchorElement
*iface
, DISPID dispIdMember
,
94 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
95 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
97 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
98 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
99 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
102 static HRESULT WINAPI
HTMLAnchorElement_put_href(IHTMLAnchorElement
*iface
, BSTR v
)
104 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
105 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
109 static HRESULT WINAPI
HTMLAnchorElement_get_href(IHTMLAnchorElement
*iface
, BSTR
*p
)
111 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
116 TRACE("(%p)->(%p)\n", This
, p
);
118 nsAString_Init(&href_str
, NULL
);
119 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
120 if(NS_SUCCEEDED(nsres
)) {
121 const PRUnichar
*href
;
123 nsAString_GetData(&href_str
, &href
);
124 hres
= nsuri_to_url(href
, TRUE
, p
);
126 ERR("GetHref failed: %08x\n", nsres
);
130 nsAString_Finish(&href_str
);
134 static HRESULT WINAPI
HTMLAnchorElement_put_target(IHTMLAnchorElement
*iface
, BSTR v
)
136 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
137 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
141 static HRESULT WINAPI
HTMLAnchorElement_get_target(IHTMLAnchorElement
*iface
, BSTR
*p
)
143 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
144 FIXME("(%p)->(%p)\n", This
, p
);
148 static HRESULT WINAPI
HTMLAnchorElement_put_rel(IHTMLAnchorElement
*iface
, BSTR v
)
150 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
151 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
155 static HRESULT WINAPI
HTMLAnchorElement_get_rel(IHTMLAnchorElement
*iface
, BSTR
*p
)
157 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
158 FIXME("(%p)->(%p)\n", This
, p
);
162 static HRESULT WINAPI
HTMLAnchorElement_put_rev(IHTMLAnchorElement
*iface
, BSTR v
)
164 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
165 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
169 static HRESULT WINAPI
HTMLAnchorElement_get_rev(IHTMLAnchorElement
*iface
, BSTR
*p
)
171 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
172 FIXME("(%p)->(%p)\n", This
, p
);
176 static HRESULT WINAPI
HTMLAnchorElement_put_urn(IHTMLAnchorElement
*iface
, BSTR v
)
178 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
179 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
183 static HRESULT WINAPI
HTMLAnchorElement_get_urn(IHTMLAnchorElement
*iface
, BSTR
*p
)
185 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
186 FIXME("(%p)->(%p)\n", This
, p
);
190 static HRESULT WINAPI
HTMLAnchorElement_put_Methods(IHTMLAnchorElement
*iface
, BSTR v
)
192 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
193 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
197 static HRESULT WINAPI
HTMLAnchorElement_get_Methods(IHTMLAnchorElement
*iface
, BSTR
*p
)
199 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
200 FIXME("(%p)->(%p)\n", This
, p
);
204 static HRESULT WINAPI
HTMLAnchorElement_put_name(IHTMLAnchorElement
*iface
, BSTR v
)
206 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
207 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
211 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
213 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
214 FIXME("(%p)->(%p)\n", This
, p
);
218 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
220 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
221 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
225 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
227 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
228 FIXME("(%p)->(%p)\n", This
, p
);
232 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
234 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
235 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
239 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
241 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
242 FIXME("(%p)->(%p)\n", This
, p
);
246 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
248 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
249 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
253 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
255 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
256 FIXME("(%p)->(%p)\n", This
, p
);
260 static HRESULT WINAPI
HTMLAnchorElement_put_port(IHTMLAnchorElement
*iface
, BSTR v
)
262 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
263 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
267 static HRESULT WINAPI
HTMLAnchorElement_get_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
269 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
270 FIXME("(%p)->(%p)\n", This
, p
);
274 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(IHTMLAnchorElement
*iface
, BSTR v
)
276 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
277 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
281 static HRESULT WINAPI
HTMLAnchorElement_get_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
283 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
284 FIXME("(%p)->(%p)\n", This
, p
);
288 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
290 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
291 FIXME("(%p)->(%p)\n", This
, debugstr_w(v
));
295 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
297 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
298 FIXME("(%p)->(%p)\n", This
, p
);
302 static HRESULT WINAPI
HTMLAnchorElement_put_hash(IHTMLAnchorElement
*iface
, BSTR v
)
304 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
305 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
309 static HRESULT WINAPI
HTMLAnchorElement_get_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
311 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
312 FIXME("(%p)->(%p)\n", This
, p
);
316 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
318 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
320 TRACE("(%p)->()\n", This
);
322 return IHTMLElement2_put_onblur(&This
->element
.IHTMLElement2_iface
, v
);
325 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
327 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
329 TRACE("(%p)->(%p)\n", This
, p
);
331 return IHTMLElement2_get_onblur(&This
->element
.IHTMLElement2_iface
, p
);
334 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
336 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
338 TRACE("(%p)->()\n", This
);
340 return IHTMLElement2_put_onfocus(&This
->element
.IHTMLElement2_iface
, v
);
343 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
345 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
347 TRACE("(%p)->(%p)\n", This
, p
);
349 return IHTMLElement2_get_onfocus(&This
->element
.IHTMLElement2_iface
, p
);
352 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
354 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
356 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
358 return IHTMLElement2_put_accessKey(&This
->element
.IHTMLElement2_iface
, v
);
361 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
363 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
365 TRACE("(%p)->(%p)\n", This
, p
);
367 return IHTMLElement2_get_accessKey(&This
->element
.IHTMLElement2_iface
, p
);
370 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
372 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
373 FIXME("(%p)->(%p)\n", This
, p
);
377 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
379 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
380 FIXME("(%p)->(%p)\n", This
, p
);
384 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
386 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
387 FIXME("(%p)->(%p)\n", This
, p
);
391 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
393 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
395 TRACE("(%p)->()\n", This
);
397 return IHTMLElement2_put_tabIndex(&This
->element
.IHTMLElement2_iface
, v
);
400 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
402 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
404 TRACE("(%p)->(%p)\n", This
, p
);
406 return IHTMLElement2_get_tabIndex(&This
->element
.IHTMLElement2_iface
, p
);
409 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
411 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
413 TRACE("(%p)\n", This
);
415 return IHTMLElement2_focus(&This
->element
.IHTMLElement2_iface
);
418 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
420 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
422 TRACE("(%p)\n", This
);
424 return IHTMLElement2_blur(&This
->element
.IHTMLElement2_iface
);
427 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
428 HTMLAnchorElement_QueryInterface
,
429 HTMLAnchorElement_AddRef
,
430 HTMLAnchorElement_Release
,
431 HTMLAnchorElement_GetTypeInfoCount
,
432 HTMLAnchorElement_GetTypeInfo
,
433 HTMLAnchorElement_GetIDsOfNames
,
434 HTMLAnchorElement_Invoke
,
435 HTMLAnchorElement_put_href
,
436 HTMLAnchorElement_get_href
,
437 HTMLAnchorElement_put_target
,
438 HTMLAnchorElement_get_target
,
439 HTMLAnchorElement_put_rel
,
440 HTMLAnchorElement_get_rel
,
441 HTMLAnchorElement_put_rev
,
442 HTMLAnchorElement_get_rev
,
443 HTMLAnchorElement_put_urn
,
444 HTMLAnchorElement_get_urn
,
445 HTMLAnchorElement_put_Methods
,
446 HTMLAnchorElement_get_Methods
,
447 HTMLAnchorElement_put_name
,
448 HTMLAnchorElement_get_name
,
449 HTMLAnchorElement_put_host
,
450 HTMLAnchorElement_get_host
,
451 HTMLAnchorElement_put_hostname
,
452 HTMLAnchorElement_get_hostname
,
453 HTMLAnchorElement_put_pathname
,
454 HTMLAnchorElement_get_pathname
,
455 HTMLAnchorElement_put_port
,
456 HTMLAnchorElement_get_port
,
457 HTMLAnchorElement_put_protocol
,
458 HTMLAnchorElement_get_protocol
,
459 HTMLAnchorElement_put_search
,
460 HTMLAnchorElement_get_search
,
461 HTMLAnchorElement_put_hash
,
462 HTMLAnchorElement_get_hash
,
463 HTMLAnchorElement_put_onblur
,
464 HTMLAnchorElement_get_onblur
,
465 HTMLAnchorElement_put_onfocus
,
466 HTMLAnchorElement_get_onfocus
,
467 HTMLAnchorElement_put_accessKey
,
468 HTMLAnchorElement_get_accessKey
,
469 HTMLAnchorElement_get_protocolLong
,
470 HTMLAnchorElement_get_mimeType
,
471 HTMLAnchorElement_get_nameProp
,
472 HTMLAnchorElement_put_tabIndex
,
473 HTMLAnchorElement_get_tabIndex
,
474 HTMLAnchorElement_focus
,
475 HTMLAnchorElement_blur
478 static inline HTMLAnchorElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
480 return CONTAINING_RECORD(iface
, HTMLAnchorElement
, element
.node
);
483 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
485 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
489 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
490 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
491 *ppv
= &This
->IHTMLAnchorElement_iface
;
492 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
493 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
494 *ppv
= &This
->IHTMLAnchorElement_iface
;
495 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
496 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
497 *ppv
= &This
->IHTMLAnchorElement_iface
;
501 IUnknown_AddRef((IUnknown
*)*ppv
);
505 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
508 static void HTMLAnchorElement_destructor(HTMLDOMNode
*iface
)
510 HTMLAnchorElement
*This
= impl_from_HTMLDOMNode(iface
);
513 nsIDOMHTMLAnchorElement_Release(This
->nsanchor
);
515 HTMLElement_destructor(&This
->element
.node
);
518 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
519 HTMLAnchorElement_QI
,
520 HTMLAnchorElement_destructor
,
524 static const tid_t HTMLAnchorElement_iface_tids
[] = {
525 IHTMLAnchorElement_tid
,
527 IHTMLTextContainer_tid
,
532 static dispex_static_data_t HTMLAnchorElement_dispex
= {
534 DispHTMLAnchorElement_tid
,
536 HTMLAnchorElement_iface_tids
539 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
541 HTMLAnchorElement
*ret
;
544 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
546 return E_OUTOFMEMORY
;
548 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
549 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
551 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
552 if(NS_FAILED(nsres
)) {
553 ERR("Could not get nsIDOMHTMLAnchorElement iface: %08x\n", nsres
);
558 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
560 *elem
= &ret
->element
;