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);
108 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
110 nsAString_InitDepend(&nsstr, v);
111 nsres = nsIDOMHTMLAnchorElement_SetHref(This->nsanchor, &nsstr);
112 nsAString_Finish(&nsstr);
119 static HRESULT WINAPI HTMLAnchorElement_get_href(IHTMLAnchorElement *iface, BSTR *p)
121 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
126 TRACE("(%p)->(%p)\n", This, p);
128 nsAString_Init(&href_str, NULL);
129 nsres = nsIDOMHTMLAnchorElement_GetHref(This->nsanchor, &href_str);
130 if(NS_SUCCEEDED(nsres)) {
131 const PRUnichar *href;
133 nsAString_GetData(&href_str, &href);
134 hres = nsuri_to_url(href, TRUE, p);
136 ERR("GetHref failed: %08x\n", nsres);
140 nsAString_Finish(&href_str);
144 static HRESULT WINAPI HTMLAnchorElement_put_target(IHTMLAnchorElement *iface, BSTR v)
146 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
147 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
151 static HRESULT WINAPI HTMLAnchorElement_get_target(IHTMLAnchorElement *iface, BSTR *p)
153 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
154 FIXME("(%p)->(%p)\n", This, p);
158 static HRESULT WINAPI HTMLAnchorElement_put_rel(IHTMLAnchorElement *iface, BSTR v)
160 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
161 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
165 static HRESULT WINAPI HTMLAnchorElement_get_rel(IHTMLAnchorElement *iface, BSTR *p)
167 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
168 FIXME("(%p)->(%p)\n", This, p);
172 static HRESULT WINAPI HTMLAnchorElement_put_rev(IHTMLAnchorElement *iface, BSTR v)
174 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
175 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
179 static HRESULT WINAPI HTMLAnchorElement_get_rev(IHTMLAnchorElement *iface, BSTR *p)
181 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
182 FIXME("(%p)->(%p)\n", This, p);
186 static HRESULT WINAPI HTMLAnchorElement_put_urn(IHTMLAnchorElement *iface, BSTR v)
188 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
189 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
193 static HRESULT WINAPI HTMLAnchorElement_get_urn(IHTMLAnchorElement *iface, BSTR *p)
195 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
196 FIXME("(%p)->(%p)\n", This, p);
200 static HRESULT WINAPI HTMLAnchorElement_put_Methods(IHTMLAnchorElement *iface, BSTR v)
202 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
203 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
207 static HRESULT WINAPI HTMLAnchorElement_get_Methods(IHTMLAnchorElement *iface, BSTR *p)
209 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
210 FIXME("(%p)->(%p)\n", This, p);
214 static HRESULT WINAPI HTMLAnchorElement_put_name(IHTMLAnchorElement *iface, BSTR v)
216 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
217 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
221 static HRESULT WINAPI HTMLAnchorElement_get_name(IHTMLAnchorElement *iface, BSTR *p)
223 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
224 FIXME("(%p)->(%p)\n", This, p);
228 static HRESULT WINAPI HTMLAnchorElement_put_host(IHTMLAnchorElement *iface, BSTR v)
230 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
231 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
235 static HRESULT WINAPI HTMLAnchorElement_get_host(IHTMLAnchorElement *iface, BSTR *p)
237 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
238 FIXME("(%p)->(%p)\n", This, p);
242 static HRESULT WINAPI HTMLAnchorElement_put_hostname(IHTMLAnchorElement *iface, BSTR v)
244 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
245 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
249 static HRESULT WINAPI HTMLAnchorElement_get_hostname(IHTMLAnchorElement *iface, BSTR *p)
251 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
252 FIXME("(%p)->(%p)\n", This, p);
256 static HRESULT WINAPI HTMLAnchorElement_put_pathname(IHTMLAnchorElement *iface, BSTR v)
258 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
259 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
263 static HRESULT WINAPI HTMLAnchorElement_get_pathname(IHTMLAnchorElement *iface, BSTR *p)
265 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
266 FIXME("(%p)->(%p)\n", This, p);
270 static HRESULT WINAPI HTMLAnchorElement_put_port(IHTMLAnchorElement *iface, BSTR v)
272 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
273 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
277 static HRESULT WINAPI HTMLAnchorElement_get_port(IHTMLAnchorElement *iface, BSTR *p)
279 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
280 FIXME("(%p)->(%p)\n", This, p);
284 static HRESULT WINAPI HTMLAnchorElement_put_protocol(IHTMLAnchorElement *iface, BSTR v)
286 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
287 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
291 static HRESULT WINAPI HTMLAnchorElement_get_protocol(IHTMLAnchorElement *iface, BSTR *p)
293 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
294 FIXME("(%p)->(%p)\n", This, p);
298 static HRESULT WINAPI HTMLAnchorElement_put_search(IHTMLAnchorElement *iface, BSTR v)
300 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
301 FIXME("(%p)->(%p)\n", This, debugstr_w(v));
305 static HRESULT WINAPI HTMLAnchorElement_get_search(IHTMLAnchorElement *iface, BSTR *p)
307 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
308 FIXME("(%p)->(%p)\n", This, p);
312 static HRESULT WINAPI HTMLAnchorElement_put_hash(IHTMLAnchorElement *iface, BSTR v)
314 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
315 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
319 static HRESULT WINAPI HTMLAnchorElement_get_hash(IHTMLAnchorElement *iface, BSTR *p)
321 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
322 FIXME("(%p)->(%p)\n", This, p);
326 static HRESULT WINAPI HTMLAnchorElement_put_onblur(IHTMLAnchorElement *iface, VARIANT v)
328 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
330 TRACE("(%p)->()\n", This);
332 return IHTMLElement2_put_onblur(&This->element.IHTMLElement2_iface, v);
335 static HRESULT WINAPI HTMLAnchorElement_get_onblur(IHTMLAnchorElement *iface, VARIANT *p)
337 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
339 TRACE("(%p)->(%p)\n", This, p);
341 return IHTMLElement2_get_onblur(&This->element.IHTMLElement2_iface, p);
344 static HRESULT WINAPI HTMLAnchorElement_put_onfocus(IHTMLAnchorElement *iface, VARIANT v)
346 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
348 TRACE("(%p)->()\n", This);
350 return IHTMLElement2_put_onfocus(&This->element.IHTMLElement2_iface, v);
353 static HRESULT WINAPI HTMLAnchorElement_get_onfocus(IHTMLAnchorElement *iface, VARIANT *p)
355 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
357 TRACE("(%p)->(%p)\n", This, p);
359 return IHTMLElement2_get_onfocus(&This->element.IHTMLElement2_iface, p);
362 static HRESULT WINAPI HTMLAnchorElement_put_accessKey(IHTMLAnchorElement *iface, BSTR v)
364 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
366 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
368 return IHTMLElement2_put_accessKey(&This->element.IHTMLElement2_iface, v);
371 static HRESULT WINAPI HTMLAnchorElement_get_accessKey(IHTMLAnchorElement *iface, BSTR *p)
373 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
375 TRACE("(%p)->(%p)\n", This, p);
377 return IHTMLElement2_get_accessKey(&This->element.IHTMLElement2_iface, p);
380 static HRESULT WINAPI HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement *iface, BSTR *p)
382 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
383 FIXME("(%p)->(%p)\n", This, p);
387 static HRESULT WINAPI HTMLAnchorElement_get_mimeType(IHTMLAnchorElement *iface, BSTR *p)
389 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
390 FIXME("(%p)->(%p)\n", This, p);
394 static HRESULT WINAPI HTMLAnchorElement_get_nameProp(IHTMLAnchorElement *iface, BSTR *p)
396 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
397 FIXME("(%p)->(%p)\n", This, p);
401 static HRESULT WINAPI HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement *iface, short v)
403 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
405 TRACE("(%p)->()\n", This);
407 return IHTMLElement2_put_tabIndex(&This->element.IHTMLElement2_iface, v);
410 static HRESULT WINAPI HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement *iface, short *p)
412 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
414 TRACE("(%p)->(%p)\n", This, p);
416 return IHTMLElement2_get_tabIndex(&This->element.IHTMLElement2_iface, p);
419 static HRESULT WINAPI HTMLAnchorElement_focus(IHTMLAnchorElement *iface)
421 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
423 TRACE("(%p)\n", This);
425 return IHTMLElement2_focus(&This->element.IHTMLElement2_iface);
428 static HRESULT WINAPI HTMLAnchorElement_blur(IHTMLAnchorElement *iface)
430 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
432 TRACE("(%p)\n", This);
434 return IHTMLElement2_blur(&This->element.IHTMLElement2_iface);
437 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl = {
438 HTMLAnchorElement_QueryInterface,
439 HTMLAnchorElement_AddRef,
440 HTMLAnchorElement_Release,
441 HTMLAnchorElement_GetTypeInfoCount,
442 HTMLAnchorElement_GetTypeInfo,
443 HTMLAnchorElement_GetIDsOfNames,
444 HTMLAnchorElement_Invoke,
445 HTMLAnchorElement_put_href,
446 HTMLAnchorElement_get_href,
447 HTMLAnchorElement_put_target,
448 HTMLAnchorElement_get_target,
449 HTMLAnchorElement_put_rel,
450 HTMLAnchorElement_get_rel,
451 HTMLAnchorElement_put_rev,
452 HTMLAnchorElement_get_rev,
453 HTMLAnchorElement_put_urn,
454 HTMLAnchorElement_get_urn,
455 HTMLAnchorElement_put_Methods,
456 HTMLAnchorElement_get_Methods,
457 HTMLAnchorElement_put_name,
458 HTMLAnchorElement_get_name,
459 HTMLAnchorElement_put_host,
460 HTMLAnchorElement_get_host,
461 HTMLAnchorElement_put_hostname,
462 HTMLAnchorElement_get_hostname,
463 HTMLAnchorElement_put_pathname,
464 HTMLAnchorElement_get_pathname,
465 HTMLAnchorElement_put_port,
466 HTMLAnchorElement_get_port,
467 HTMLAnchorElement_put_protocol,
468 HTMLAnchorElement_get_protocol,
469 HTMLAnchorElement_put_search,
470 HTMLAnchorElement_get_search,
471 HTMLAnchorElement_put_hash,
472 HTMLAnchorElement_get_hash,
473 HTMLAnchorElement_put_onblur,
474 HTMLAnchorElement_get_onblur,
475 HTMLAnchorElement_put_onfocus,
476 HTMLAnchorElement_get_onfocus,
477 HTMLAnchorElement_put_accessKey,
478 HTMLAnchorElement_get_accessKey,
479 HTMLAnchorElement_get_protocolLong,
480 HTMLAnchorElement_get_mimeType,
481 HTMLAnchorElement_get_nameProp,
482 HTMLAnchorElement_put_tabIndex,
483 HTMLAnchorElement_get_tabIndex,
484 HTMLAnchorElement_focus,
485 HTMLAnchorElement_blur
488 static inline HTMLAnchorElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
490 return CONTAINING_RECORD(iface, HTMLAnchorElement, element.node);
493 static HRESULT HTMLAnchorElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
495 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
499 if(IsEqualGUID(&IID_IUnknown, riid)) {
500 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
501 *ppv = &This->IHTMLAnchorElement_iface;
502 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
503 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
504 *ppv = &This->IHTMLAnchorElement_iface;
505 }else if(IsEqualGUID(&IID_IHTMLAnchorElement, riid)) {
506 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This, ppv);
507 *ppv = &This->IHTMLAnchorElement_iface;
511 IUnknown_AddRef((IUnknown*)*ppv);
515 return HTMLElement_QI(&This->element.node, riid, ppv);
518 static void HTMLAnchorElement_destructor(HTMLDOMNode *iface)
520 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
523 nsIDOMHTMLAnchorElement_Release(This->nsanchor);
525 HTMLElement_destructor(&This->element.node);
528 static const NodeImplVtbl HTMLAnchorElementImplVtbl = {
529 HTMLAnchorElement_QI,
530 HTMLAnchorElement_destructor,
534 static const tid_t HTMLAnchorElement_iface_tids[] = {
535 IHTMLAnchorElement_tid,
537 IHTMLTextContainer_tid,
542 static dispex_static_data_t HTMLAnchorElement_dispex = {
544 DispHTMLAnchorElement_tid,
546 HTMLAnchorElement_iface_tids
549 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
551 HTMLAnchorElement *ret;
554 ret = heap_alloc_zero(sizeof(HTMLAnchorElement));
556 return E_OUTOFMEMORY;
558 ret->IHTMLAnchorElement_iface.lpVtbl = &HTMLAnchorElementVtbl;
559 ret->element.node.vtbl = &HTMLAnchorElementImplVtbl;
561 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLAnchorElement, (void**)&ret->nsanchor);
562 if(NS_FAILED(nsres)) {
563 ERR("Could not get nsIDOMHTMLAnchorElement iface: %08x\n", nsres);
568 HTMLElement_Init(&ret->element, doc, nselem, &HTMLAnchorElement_dispex);
570 *elem = &ret->element;