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);
150 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
152 nsAString_InitDepend(&nsstr, v);
153 nsres = nsIDOMHTMLAnchorElement_SetTarget(This->nsanchor, &nsstr);
154 nsAString_Finish(&nsstr);
161 static HRESULT WINAPI HTMLAnchorElement_get_target(IHTMLAnchorElement *iface, BSTR *p)
163 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
164 nsAString target_str;
167 TRACE("(%p)->(%p)\n", This, p);
169 nsAString_Init(&target_str, NULL);
170 nsres = nsIDOMHTMLAnchorElement_GetTarget(This->nsanchor, &target_str);
172 return return_nsstr(nsres, &target_str, p);
175 static HRESULT WINAPI HTMLAnchorElement_put_rel(IHTMLAnchorElement *iface, BSTR v)
177 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
178 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
182 static HRESULT WINAPI HTMLAnchorElement_get_rel(IHTMLAnchorElement *iface, BSTR *p)
184 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
185 FIXME("(%p)->(%p)\n", This, p);
189 static HRESULT WINAPI HTMLAnchorElement_put_rev(IHTMLAnchorElement *iface, BSTR v)
191 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
192 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
196 static HRESULT WINAPI HTMLAnchorElement_get_rev(IHTMLAnchorElement *iface, BSTR *p)
198 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
199 FIXME("(%p)->(%p)\n", This, p);
203 static HRESULT WINAPI HTMLAnchorElement_put_urn(IHTMLAnchorElement *iface, BSTR v)
205 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
206 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
210 static HRESULT WINAPI HTMLAnchorElement_get_urn(IHTMLAnchorElement *iface, BSTR *p)
212 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
213 FIXME("(%p)->(%p)\n", This, p);
217 static HRESULT WINAPI HTMLAnchorElement_put_Methods(IHTMLAnchorElement *iface, BSTR v)
219 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
220 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
224 static HRESULT WINAPI HTMLAnchorElement_get_Methods(IHTMLAnchorElement *iface, BSTR *p)
226 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
227 FIXME("(%p)->(%p)\n", This, p);
231 static HRESULT WINAPI HTMLAnchorElement_put_name(IHTMLAnchorElement *iface, BSTR v)
233 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
234 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
238 static HRESULT WINAPI HTMLAnchorElement_get_name(IHTMLAnchorElement *iface, BSTR *p)
240 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
241 FIXME("(%p)->(%p)\n", This, p);
245 static HRESULT WINAPI HTMLAnchorElement_put_host(IHTMLAnchorElement *iface, BSTR v)
247 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
248 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
252 static HRESULT WINAPI HTMLAnchorElement_get_host(IHTMLAnchorElement *iface, BSTR *p)
254 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
255 FIXME("(%p)->(%p)\n", This, p);
259 static HRESULT WINAPI HTMLAnchorElement_put_hostname(IHTMLAnchorElement *iface, BSTR v)
261 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
262 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
266 static HRESULT WINAPI HTMLAnchorElement_get_hostname(IHTMLAnchorElement *iface, BSTR *p)
268 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
269 FIXME("(%p)->(%p)\n", This, p);
273 static HRESULT WINAPI HTMLAnchorElement_put_pathname(IHTMLAnchorElement *iface, BSTR v)
275 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
276 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
280 static HRESULT WINAPI HTMLAnchorElement_get_pathname(IHTMLAnchorElement *iface, BSTR *p)
282 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
283 FIXME("(%p)->(%p)\n", This, p);
287 static HRESULT WINAPI HTMLAnchorElement_put_port(IHTMLAnchorElement *iface, BSTR v)
289 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
290 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
294 static HRESULT WINAPI HTMLAnchorElement_get_port(IHTMLAnchorElement *iface, BSTR *p)
296 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
297 FIXME("(%p)->(%p)\n", This, p);
301 static HRESULT WINAPI HTMLAnchorElement_put_protocol(IHTMLAnchorElement *iface, BSTR v)
303 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
304 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
308 static HRESULT WINAPI HTMLAnchorElement_get_protocol(IHTMLAnchorElement *iface, BSTR *p)
310 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
311 FIXME("(%p)->(%p)\n", This, p);
315 static HRESULT WINAPI HTMLAnchorElement_put_search(IHTMLAnchorElement *iface, BSTR v)
317 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
318 FIXME("(%p)->(%p)\n", This, debugstr_w(v));
322 static HRESULT WINAPI HTMLAnchorElement_get_search(IHTMLAnchorElement *iface, BSTR *p)
324 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
325 FIXME("(%p)->(%p)\n", This, p);
329 static HRESULT WINAPI HTMLAnchorElement_put_hash(IHTMLAnchorElement *iface, BSTR v)
331 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
332 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
336 static HRESULT WINAPI HTMLAnchorElement_get_hash(IHTMLAnchorElement *iface, BSTR *p)
338 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
339 FIXME("(%p)->(%p)\n", This, p);
343 static HRESULT WINAPI HTMLAnchorElement_put_onblur(IHTMLAnchorElement *iface, VARIANT v)
345 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
347 TRACE("(%p)->()\n", This);
349 return IHTMLElement2_put_onblur(&This->element.IHTMLElement2_iface, v);
352 static HRESULT WINAPI HTMLAnchorElement_get_onblur(IHTMLAnchorElement *iface, VARIANT *p)
354 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
356 TRACE("(%p)->(%p)\n", This, p);
358 return IHTMLElement2_get_onblur(&This->element.IHTMLElement2_iface, p);
361 static HRESULT WINAPI HTMLAnchorElement_put_onfocus(IHTMLAnchorElement *iface, VARIANT v)
363 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
365 TRACE("(%p)->()\n", This);
367 return IHTMLElement2_put_onfocus(&This->element.IHTMLElement2_iface, v);
370 static HRESULT WINAPI HTMLAnchorElement_get_onfocus(IHTMLAnchorElement *iface, VARIANT *p)
372 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
374 TRACE("(%p)->(%p)\n", This, p);
376 return IHTMLElement2_get_onfocus(&This->element.IHTMLElement2_iface, p);
379 static HRESULT WINAPI HTMLAnchorElement_put_accessKey(IHTMLAnchorElement *iface, BSTR v)
381 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
383 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
385 return IHTMLElement2_put_accessKey(&This->element.IHTMLElement2_iface, v);
388 static HRESULT WINAPI HTMLAnchorElement_get_accessKey(IHTMLAnchorElement *iface, BSTR *p)
390 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
392 TRACE("(%p)->(%p)\n", This, p);
394 return IHTMLElement2_get_accessKey(&This->element.IHTMLElement2_iface, p);
397 static HRESULT WINAPI HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement *iface, BSTR *p)
399 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
400 FIXME("(%p)->(%p)\n", This, p);
404 static HRESULT WINAPI HTMLAnchorElement_get_mimeType(IHTMLAnchorElement *iface, BSTR *p)
406 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
407 FIXME("(%p)->(%p)\n", This, p);
411 static HRESULT WINAPI HTMLAnchorElement_get_nameProp(IHTMLAnchorElement *iface, BSTR *p)
413 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
414 FIXME("(%p)->(%p)\n", This, p);
418 static HRESULT WINAPI HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement *iface, short v)
420 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
422 TRACE("(%p)->()\n", This);
424 return IHTMLElement2_put_tabIndex(&This->element.IHTMLElement2_iface, v);
427 static HRESULT WINAPI HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement *iface, short *p)
429 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
431 TRACE("(%p)->(%p)\n", This, p);
433 return IHTMLElement2_get_tabIndex(&This->element.IHTMLElement2_iface, p);
436 static HRESULT WINAPI HTMLAnchorElement_focus(IHTMLAnchorElement *iface)
438 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
440 TRACE("(%p)\n", This);
442 return IHTMLElement2_focus(&This->element.IHTMLElement2_iface);
445 static HRESULT WINAPI HTMLAnchorElement_blur(IHTMLAnchorElement *iface)
447 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
449 TRACE("(%p)\n", This);
451 return IHTMLElement2_blur(&This->element.IHTMLElement2_iface);
454 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl = {
455 HTMLAnchorElement_QueryInterface,
456 HTMLAnchorElement_AddRef,
457 HTMLAnchorElement_Release,
458 HTMLAnchorElement_GetTypeInfoCount,
459 HTMLAnchorElement_GetTypeInfo,
460 HTMLAnchorElement_GetIDsOfNames,
461 HTMLAnchorElement_Invoke,
462 HTMLAnchorElement_put_href,
463 HTMLAnchorElement_get_href,
464 HTMLAnchorElement_put_target,
465 HTMLAnchorElement_get_target,
466 HTMLAnchorElement_put_rel,
467 HTMLAnchorElement_get_rel,
468 HTMLAnchorElement_put_rev,
469 HTMLAnchorElement_get_rev,
470 HTMLAnchorElement_put_urn,
471 HTMLAnchorElement_get_urn,
472 HTMLAnchorElement_put_Methods,
473 HTMLAnchorElement_get_Methods,
474 HTMLAnchorElement_put_name,
475 HTMLAnchorElement_get_name,
476 HTMLAnchorElement_put_host,
477 HTMLAnchorElement_get_host,
478 HTMLAnchorElement_put_hostname,
479 HTMLAnchorElement_get_hostname,
480 HTMLAnchorElement_put_pathname,
481 HTMLAnchorElement_get_pathname,
482 HTMLAnchorElement_put_port,
483 HTMLAnchorElement_get_port,
484 HTMLAnchorElement_put_protocol,
485 HTMLAnchorElement_get_protocol,
486 HTMLAnchorElement_put_search,
487 HTMLAnchorElement_get_search,
488 HTMLAnchorElement_put_hash,
489 HTMLAnchorElement_get_hash,
490 HTMLAnchorElement_put_onblur,
491 HTMLAnchorElement_get_onblur,
492 HTMLAnchorElement_put_onfocus,
493 HTMLAnchorElement_get_onfocus,
494 HTMLAnchorElement_put_accessKey,
495 HTMLAnchorElement_get_accessKey,
496 HTMLAnchorElement_get_protocolLong,
497 HTMLAnchorElement_get_mimeType,
498 HTMLAnchorElement_get_nameProp,
499 HTMLAnchorElement_put_tabIndex,
500 HTMLAnchorElement_get_tabIndex,
501 HTMLAnchorElement_focus,
502 HTMLAnchorElement_blur
505 static inline HTMLAnchorElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
507 return CONTAINING_RECORD(iface, HTMLAnchorElement, element.node);
510 static HRESULT HTMLAnchorElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
512 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
516 if(IsEqualGUID(&IID_IUnknown, riid)) {
517 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
518 *ppv = &This->IHTMLAnchorElement_iface;
519 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
520 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
521 *ppv = &This->IHTMLAnchorElement_iface;
522 }else if(IsEqualGUID(&IID_IHTMLAnchorElement, riid)) {
523 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This, ppv);
524 *ppv = &This->IHTMLAnchorElement_iface;
528 IUnknown_AddRef((IUnknown*)*ppv);
532 return HTMLElement_QI(&This->element.node, riid, ppv);
535 static void HTMLAnchorElement_destructor(HTMLDOMNode *iface)
537 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
540 nsIDOMHTMLAnchorElement_Release(This->nsanchor);
542 HTMLElement_destructor(&This->element.node);
545 static const NodeImplVtbl HTMLAnchorElementImplVtbl = {
546 HTMLAnchorElement_QI,
547 HTMLAnchorElement_destructor,
551 static const tid_t HTMLAnchorElement_iface_tids[] = {
552 IHTMLAnchorElement_tid,
554 IHTMLTextContainer_tid,
559 static dispex_static_data_t HTMLAnchorElement_dispex = {
561 DispHTMLAnchorElement_tid,
563 HTMLAnchorElement_iface_tids
566 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
568 HTMLAnchorElement *ret;
571 ret = heap_alloc_zero(sizeof(HTMLAnchorElement));
573 return E_OUTOFMEMORY;
575 ret->IHTMLAnchorElement_iface.lpVtbl = &HTMLAnchorElementVtbl;
576 ret->element.node.vtbl = &HTMLAnchorElementImplVtbl;
578 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLAnchorElement, (void**)&ret->nsanchor);
579 if(NS_FAILED(nsres)) {
580 ERR("Could not get nsIDOMHTMLAnchorElement iface: %08x\n", nsres);
585 HTMLElement_Init(&ret->element, doc, nselem, &HTMLAnchorElement_dispex);
587 *elem = &ret->element;