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(HTMLDOMNODE(&This
->element
.node
), riid
, ppv
);
56 static ULONG WINAPI
HTMLAnchorElement_AddRef(IHTMLAnchorElement
*iface
)
58 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
60 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->element
.node
));
63 static ULONG WINAPI
HTMLAnchorElement_Release(IHTMLAnchorElement
*iface
)
65 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
67 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->element
.node
));
70 static HRESULT WINAPI
HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement
*iface
, UINT
*pctinfo
)
72 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
73 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->element
.node
.dispex
), 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(DISPATCHEX(&This
->element
.node
.dispex
), iTInfo
, lcid
, ppTInfo
);
83 static HRESULT WINAPI
HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement
*iface
, REFIID riid
,
84 LPOLESTR
*rgszNames
, UINT cNames
,
85 LCID lcid
, DISPID
*rgDispId
)
87 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
88 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->element
.node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
91 static HRESULT WINAPI
HTMLAnchorElement_Invoke(IHTMLAnchorElement
*iface
, DISPID dispIdMember
,
92 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
93 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
95 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
96 return IDispatchEx_Invoke(DISPATCHEX(&This
->element
.node
.dispex
), dispIdMember
, riid
, lcid
,
97 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
100 static HRESULT WINAPI
HTMLAnchorElement_put_href(IHTMLAnchorElement
*iface
, BSTR v
)
102 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
103 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
107 static HRESULT WINAPI
HTMLAnchorElement_get_href(IHTMLAnchorElement
*iface
, BSTR
*p
)
109 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
114 TRACE("(%p)->(%p)\n", This
, p
);
116 nsAString_Init(&href_str
, NULL
);
117 nsres
= nsIDOMHTMLAnchorElement_GetHref(This
->nsanchor
, &href_str
);
118 if(NS_SUCCEEDED(nsres
)) {
119 const PRUnichar
*href
;
121 nsAString_GetData(&href_str
, &href
);
122 hres
= nsuri_to_url(href
, TRUE
, p
);
124 ERR("GetHref failed: %08x\n", nsres
);
128 nsAString_Finish(&href_str
);
132 static HRESULT WINAPI
HTMLAnchorElement_put_target(IHTMLAnchorElement
*iface
, BSTR v
)
134 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
135 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
139 static HRESULT WINAPI
HTMLAnchorElement_get_target(IHTMLAnchorElement
*iface
, BSTR
*p
)
141 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
142 FIXME("(%p)->(%p)\n", This
, p
);
146 static HRESULT WINAPI
HTMLAnchorElement_put_rel(IHTMLAnchorElement
*iface
, BSTR v
)
148 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
149 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
153 static HRESULT WINAPI
HTMLAnchorElement_get_rel(IHTMLAnchorElement
*iface
, BSTR
*p
)
155 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
156 FIXME("(%p)->(%p)\n", This
, p
);
160 static HRESULT WINAPI
HTMLAnchorElement_put_rev(IHTMLAnchorElement
*iface
, BSTR v
)
162 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
163 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
167 static HRESULT WINAPI
HTMLAnchorElement_get_rev(IHTMLAnchorElement
*iface
, BSTR
*p
)
169 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
170 FIXME("(%p)->(%p)\n", This
, p
);
174 static HRESULT WINAPI
HTMLAnchorElement_put_urn(IHTMLAnchorElement
*iface
, BSTR v
)
176 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
177 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
181 static HRESULT WINAPI
HTMLAnchorElement_get_urn(IHTMLAnchorElement
*iface
, BSTR
*p
)
183 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
184 FIXME("(%p)->(%p)\n", This
, p
);
188 static HRESULT WINAPI
HTMLAnchorElement_put_Methods(IHTMLAnchorElement
*iface
, BSTR v
)
190 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
191 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
195 static HRESULT WINAPI
HTMLAnchorElement_get_Methods(IHTMLAnchorElement
*iface
, BSTR
*p
)
197 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
198 FIXME("(%p)->(%p)\n", This
, p
);
202 static HRESULT WINAPI
HTMLAnchorElement_put_name(IHTMLAnchorElement
*iface
, BSTR v
)
204 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
205 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
209 static HRESULT WINAPI
HTMLAnchorElement_get_name(IHTMLAnchorElement
*iface
, BSTR
*p
)
211 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
212 FIXME("(%p)->(%p)\n", This
, p
);
216 static HRESULT WINAPI
HTMLAnchorElement_put_host(IHTMLAnchorElement
*iface
, BSTR v
)
218 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
219 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
223 static HRESULT WINAPI
HTMLAnchorElement_get_host(IHTMLAnchorElement
*iface
, BSTR
*p
)
225 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
226 FIXME("(%p)->(%p)\n", This
, p
);
230 static HRESULT WINAPI
HTMLAnchorElement_put_hostname(IHTMLAnchorElement
*iface
, BSTR v
)
232 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
233 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
237 static HRESULT WINAPI
HTMLAnchorElement_get_hostname(IHTMLAnchorElement
*iface
, BSTR
*p
)
239 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
240 FIXME("(%p)->(%p)\n", This
, p
);
244 static HRESULT WINAPI
HTMLAnchorElement_put_pathname(IHTMLAnchorElement
*iface
, BSTR v
)
246 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
247 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
251 static HRESULT WINAPI
HTMLAnchorElement_get_pathname(IHTMLAnchorElement
*iface
, BSTR
*p
)
253 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
254 FIXME("(%p)->(%p)\n", This
, p
);
258 static HRESULT WINAPI
HTMLAnchorElement_put_port(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_port(IHTMLAnchorElement
*iface
, BSTR
*p
)
267 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
268 FIXME("(%p)->(%p)\n", This
, p
);
272 static HRESULT WINAPI
HTMLAnchorElement_put_protocol(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_protocol(IHTMLAnchorElement
*iface
, BSTR
*p
)
281 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
282 FIXME("(%p)->(%p)\n", This
, p
);
286 static HRESULT WINAPI
HTMLAnchorElement_put_search(IHTMLAnchorElement
*iface
, BSTR v
)
288 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
289 FIXME("(%p)->(%p)\n", This
, debugstr_w(v
));
293 static HRESULT WINAPI
HTMLAnchorElement_get_search(IHTMLAnchorElement
*iface
, BSTR
*p
)
295 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
296 FIXME("(%p)->(%p)\n", This
, p
);
300 static HRESULT WINAPI
HTMLAnchorElement_put_hash(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_hash(IHTMLAnchorElement
*iface
, BSTR
*p
)
309 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
310 FIXME("(%p)->(%p)\n", This
, p
);
314 static HRESULT WINAPI
HTMLAnchorElement_put_onblur(IHTMLAnchorElement
*iface
, VARIANT v
)
316 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
318 TRACE("(%p)->()\n", This
);
320 return IHTMLElement2_put_onblur(HTMLELEM2(&This
->element
), v
);
323 static HRESULT WINAPI
HTMLAnchorElement_get_onblur(IHTMLAnchorElement
*iface
, VARIANT
*p
)
325 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
327 TRACE("(%p)->(%p)\n", This
, p
);
329 return IHTMLElement2_get_onblur(HTMLELEM2(&This
->element
), p
);
332 static HRESULT WINAPI
HTMLAnchorElement_put_onfocus(IHTMLAnchorElement
*iface
, VARIANT v
)
334 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
336 TRACE("(%p)->()\n", This
);
338 return IHTMLElement2_put_onfocus(HTMLELEM2(&This
->element
), v
);
341 static HRESULT WINAPI
HTMLAnchorElement_get_onfocus(IHTMLAnchorElement
*iface
, VARIANT
*p
)
343 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
345 TRACE("(%p)->(%p)\n", This
, p
);
347 return IHTMLElement2_get_onfocus(HTMLELEM2(&This
->element
), p
);
350 static HRESULT WINAPI
HTMLAnchorElement_put_accessKey(IHTMLAnchorElement
*iface
, BSTR v
)
352 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
354 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
356 return IHTMLElement2_put_accessKey(HTMLELEM2(&This
->element
), v
);
359 static HRESULT WINAPI
HTMLAnchorElement_get_accessKey(IHTMLAnchorElement
*iface
, BSTR
*p
)
361 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
363 TRACE("(%p)->(%p)\n", This
, p
);
365 return IHTMLElement2_get_accessKey(HTMLELEM2(&This
->element
), p
);
368 static HRESULT WINAPI
HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement
*iface
, BSTR
*p
)
370 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
371 FIXME("(%p)->(%p)\n", This
, p
);
375 static HRESULT WINAPI
HTMLAnchorElement_get_mimeType(IHTMLAnchorElement
*iface
, BSTR
*p
)
377 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
378 FIXME("(%p)->(%p)\n", This
, p
);
382 static HRESULT WINAPI
HTMLAnchorElement_get_nameProp(IHTMLAnchorElement
*iface
, BSTR
*p
)
384 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
385 FIXME("(%p)->(%p)\n", This
, p
);
389 static HRESULT WINAPI
HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement
*iface
, short v
)
391 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
393 TRACE("(%p)->()\n", This
);
395 return IHTMLElement2_put_tabIndex(HTMLELEM2(&This
->element
), v
);
398 static HRESULT WINAPI
HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement
*iface
, short *p
)
400 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
402 TRACE("(%p)->(%p)\n", This
, p
);
404 return IHTMLElement2_get_tabIndex(HTMLELEM2(&This
->element
), p
);
407 static HRESULT WINAPI
HTMLAnchorElement_focus(IHTMLAnchorElement
*iface
)
409 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
411 TRACE("(%p)\n", This
);
413 return IHTMLElement2_focus(HTMLELEM2(&This
->element
));
416 static HRESULT WINAPI
HTMLAnchorElement_blur(IHTMLAnchorElement
*iface
)
418 HTMLAnchorElement
*This
= impl_from_IHTMLAnchorElement(iface
);
420 TRACE("(%p)\n", This
);
422 return IHTMLElement2_blur(HTMLELEM2(&This
->element
));
425 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl
= {
426 HTMLAnchorElement_QueryInterface
,
427 HTMLAnchorElement_AddRef
,
428 HTMLAnchorElement_Release
,
429 HTMLAnchorElement_GetTypeInfoCount
,
430 HTMLAnchorElement_GetTypeInfo
,
431 HTMLAnchorElement_GetIDsOfNames
,
432 HTMLAnchorElement_Invoke
,
433 HTMLAnchorElement_put_href
,
434 HTMLAnchorElement_get_href
,
435 HTMLAnchorElement_put_target
,
436 HTMLAnchorElement_get_target
,
437 HTMLAnchorElement_put_rel
,
438 HTMLAnchorElement_get_rel
,
439 HTMLAnchorElement_put_rev
,
440 HTMLAnchorElement_get_rev
,
441 HTMLAnchorElement_put_urn
,
442 HTMLAnchorElement_get_urn
,
443 HTMLAnchorElement_put_Methods
,
444 HTMLAnchorElement_get_Methods
,
445 HTMLAnchorElement_put_name
,
446 HTMLAnchorElement_get_name
,
447 HTMLAnchorElement_put_host
,
448 HTMLAnchorElement_get_host
,
449 HTMLAnchorElement_put_hostname
,
450 HTMLAnchorElement_get_hostname
,
451 HTMLAnchorElement_put_pathname
,
452 HTMLAnchorElement_get_pathname
,
453 HTMLAnchorElement_put_port
,
454 HTMLAnchorElement_get_port
,
455 HTMLAnchorElement_put_protocol
,
456 HTMLAnchorElement_get_protocol
,
457 HTMLAnchorElement_put_search
,
458 HTMLAnchorElement_get_search
,
459 HTMLAnchorElement_put_hash
,
460 HTMLAnchorElement_get_hash
,
461 HTMLAnchorElement_put_onblur
,
462 HTMLAnchorElement_get_onblur
,
463 HTMLAnchorElement_put_onfocus
,
464 HTMLAnchorElement_get_onfocus
,
465 HTMLAnchorElement_put_accessKey
,
466 HTMLAnchorElement_get_accessKey
,
467 HTMLAnchorElement_get_protocolLong
,
468 HTMLAnchorElement_get_mimeType
,
469 HTMLAnchorElement_get_nameProp
,
470 HTMLAnchorElement_put_tabIndex
,
471 HTMLAnchorElement_get_tabIndex
,
472 HTMLAnchorElement_focus
,
473 HTMLAnchorElement_blur
476 #define HTMLANCHOR_NODE_THIS(iface) DEFINE_THIS2(HTMLAnchorElement, element.node, iface)
478 static HRESULT
HTMLAnchorElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
480 HTMLAnchorElement
*This
= HTMLANCHOR_NODE_THIS(iface
);
484 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
485 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
486 *ppv
= &This
->IHTMLAnchorElement_iface
;
487 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
488 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
489 *ppv
= &This
->IHTMLAnchorElement_iface
;
490 }else if(IsEqualGUID(&IID_IHTMLAnchorElement
, riid
)) {
491 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This
, ppv
);
492 *ppv
= &This
->IHTMLAnchorElement_iface
;
496 IUnknown_AddRef((IUnknown
*)*ppv
);
500 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
503 static void HTMLAnchorElement_destructor(HTMLDOMNode
*iface
)
505 HTMLAnchorElement
*This
= HTMLANCHOR_NODE_THIS(iface
);
508 nsIDOMHTMLAnchorElement_Release(This
->nsanchor
);
510 HTMLElement_destructor(&This
->element
.node
);
513 #undef HTMLANCHOR_NODE_THIS
515 static const NodeImplVtbl HTMLAnchorElementImplVtbl
= {
516 HTMLAnchorElement_QI
,
517 HTMLAnchorElement_destructor
,
521 static const tid_t HTMLAnchorElement_iface_tids
[] = {
522 IHTMLAnchorElement_tid
,
524 IHTMLTextContainer_tid
,
529 static dispex_static_data_t HTMLAnchorElement_dispex
= {
531 DispHTMLAnchorElement_tid
,
533 HTMLAnchorElement_iface_tids
536 HRESULT
HTMLAnchorElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
538 HTMLAnchorElement
*ret
;
541 ret
= heap_alloc_zero(sizeof(HTMLAnchorElement
));
543 return E_OUTOFMEMORY
;
545 ret
->IHTMLAnchorElement_iface
.lpVtbl
= &HTMLAnchorElementVtbl
;
546 ret
->element
.node
.vtbl
= &HTMLAnchorElementImplVtbl
;
548 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLAnchorElement
, (void**)&ret
->nsanchor
);
549 if(NS_FAILED(nsres
)) {
550 ERR("Could not get nsIDOMHTMLAnchorElement iface: %08x\n", nsres
);
555 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLAnchorElement_dispex
);
557 *elem
= &ret
->element
;