gdiplus/tests: Make sure to use return values (LLVM/Clang).
[wine] / dlls / mshtml / htmlanchor.c
1 /*
2  * Copyright 2007 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20 #include <stdio.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28
29 #include "wine/debug.h"
30
31 #include "mshtml_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 typedef struct {
36     HTMLElement element;
37
38     IHTMLAnchorElement IHTMLAnchorElement_iface;
39
40     nsIDOMHTMLAnchorElement *nsanchor;
41 } HTMLAnchorElement;
42
43 static inline HTMLAnchorElement *impl_from_IHTMLAnchorElement(IHTMLAnchorElement *iface)
44 {
45     return CONTAINING_RECORD(iface, HTMLAnchorElement, IHTMLAnchorElement_iface);
46 }
47
48 static HRESULT WINAPI HTMLAnchorElement_QueryInterface(IHTMLAnchorElement *iface,
49         REFIID riid, void **ppv)
50 {
51     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
52
53     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
54 }
55
56 static ULONG WINAPI HTMLAnchorElement_AddRef(IHTMLAnchorElement *iface)
57 {
58     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
59
60     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
61 }
62
63 static ULONG WINAPI HTMLAnchorElement_Release(IHTMLAnchorElement *iface)
64 {
65     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
66
67     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
68 }
69
70 static HRESULT WINAPI HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement *iface, UINT *pctinfo)
71 {
72     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
73     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
74 }
75
76 static HRESULT WINAPI HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement *iface, UINT iTInfo,
77                                               LCID lcid, ITypeInfo **ppTInfo)
78 {
79     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
80     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
81             ppTInfo);
82 }
83
84 static HRESULT WINAPI HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement *iface, REFIID riid,
85                                                 LPOLESTR *rgszNames, UINT cNames,
86                                                 LCID lcid, DISPID *rgDispId)
87 {
88     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
89     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
90             cNames, lcid, rgDispId);
91 }
92
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)
96 {
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);
100 }
101
102 static HRESULT WINAPI HTMLAnchorElement_put_href(IHTMLAnchorElement *iface, BSTR v)
103 {
104     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
105     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
106     return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI HTMLAnchorElement_get_href(IHTMLAnchorElement *iface, BSTR *p)
110 {
111     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
112     nsAString href_str;
113     nsresult nsres;
114     HRESULT hres;
115
116     TRACE("(%p)->(%p)\n", This, p);
117
118     nsAString_Init(&href_str, NULL);
119     nsres = nsIDOMHTMLAnchorElement_GetHref(This->nsanchor, &href_str);
120     if(NS_SUCCEEDED(nsres)) {
121         const PRUnichar *href;
122
123         nsAString_GetData(&href_str, &href);
124         hres = nsuri_to_url(href, TRUE, p);
125     }else {
126         ERR("GetHref failed: %08x\n", nsres);
127         hres = E_FAIL;
128     }
129
130     nsAString_Finish(&href_str);
131     return hres;
132 }
133
134 static HRESULT WINAPI HTMLAnchorElement_put_target(IHTMLAnchorElement *iface, BSTR v)
135 {
136     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
137     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
138     return E_NOTIMPL;
139 }
140
141 static HRESULT WINAPI HTMLAnchorElement_get_target(IHTMLAnchorElement *iface, BSTR *p)
142 {
143     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
144     FIXME("(%p)->(%p)\n", This, p);
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI HTMLAnchorElement_put_rel(IHTMLAnchorElement *iface, BSTR v)
149 {
150     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
151     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI HTMLAnchorElement_get_rel(IHTMLAnchorElement *iface, BSTR *p)
156 {
157     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
158     FIXME("(%p)->(%p)\n", This, p);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI HTMLAnchorElement_put_rev(IHTMLAnchorElement *iface, BSTR v)
163 {
164     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
165     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI HTMLAnchorElement_get_rev(IHTMLAnchorElement *iface, BSTR *p)
170 {
171     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
172     FIXME("(%p)->(%p)\n", This, p);
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI HTMLAnchorElement_put_urn(IHTMLAnchorElement *iface, BSTR v)
177 {
178     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
179     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
180     return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI HTMLAnchorElement_get_urn(IHTMLAnchorElement *iface, BSTR *p)
184 {
185     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
186     FIXME("(%p)->(%p)\n", This, p);
187     return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI HTMLAnchorElement_put_Methods(IHTMLAnchorElement *iface, BSTR v)
191 {
192     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
193     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
194     return E_NOTIMPL;
195 }
196
197 static HRESULT WINAPI HTMLAnchorElement_get_Methods(IHTMLAnchorElement *iface, BSTR *p)
198 {
199     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
200     FIXME("(%p)->(%p)\n", This, p);
201     return E_NOTIMPL;
202 }
203
204 static HRESULT WINAPI HTMLAnchorElement_put_name(IHTMLAnchorElement *iface, BSTR v)
205 {
206     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
207     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
208     return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI HTMLAnchorElement_get_name(IHTMLAnchorElement *iface, BSTR *p)
212 {
213     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
214     FIXME("(%p)->(%p)\n", This, p);
215     return E_NOTIMPL;
216 }
217
218 static HRESULT WINAPI HTMLAnchorElement_put_host(IHTMLAnchorElement *iface, BSTR v)
219 {
220     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
221     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
222     return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI HTMLAnchorElement_get_host(IHTMLAnchorElement *iface, BSTR *p)
226 {
227     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
228     FIXME("(%p)->(%p)\n", This, p);
229     return E_NOTIMPL;
230 }
231
232 static HRESULT WINAPI HTMLAnchorElement_put_hostname(IHTMLAnchorElement *iface, BSTR v)
233 {
234     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
235     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
236     return E_NOTIMPL;
237 }
238
239 static HRESULT WINAPI HTMLAnchorElement_get_hostname(IHTMLAnchorElement *iface, BSTR *p)
240 {
241     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
242     FIXME("(%p)->(%p)\n", This, p);
243     return E_NOTIMPL;
244 }
245
246 static HRESULT WINAPI HTMLAnchorElement_put_pathname(IHTMLAnchorElement *iface, BSTR v)
247 {
248     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
249     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
250     return E_NOTIMPL;
251 }
252
253 static HRESULT WINAPI HTMLAnchorElement_get_pathname(IHTMLAnchorElement *iface, BSTR *p)
254 {
255     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
256     FIXME("(%p)->(%p)\n", This, p);
257     return E_NOTIMPL;
258 }
259
260 static HRESULT WINAPI HTMLAnchorElement_put_port(IHTMLAnchorElement *iface, BSTR v)
261 {
262     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
263     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
264     return E_NOTIMPL;
265 }
266
267 static HRESULT WINAPI HTMLAnchorElement_get_port(IHTMLAnchorElement *iface, BSTR *p)
268 {
269     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
270     FIXME("(%p)->(%p)\n", This, p);
271     return E_NOTIMPL;
272 }
273
274 static HRESULT WINAPI HTMLAnchorElement_put_protocol(IHTMLAnchorElement *iface, BSTR v)
275 {
276     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
277     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
278     return E_NOTIMPL;
279 }
280
281 static HRESULT WINAPI HTMLAnchorElement_get_protocol(IHTMLAnchorElement *iface, BSTR *p)
282 {
283     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
284     FIXME("(%p)->(%p)\n", This, p);
285     return E_NOTIMPL;
286 }
287
288 static HRESULT WINAPI HTMLAnchorElement_put_search(IHTMLAnchorElement *iface, BSTR v)
289 {
290     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
291     FIXME("(%p)->(%p)\n", This, debugstr_w(v));
292     return E_NOTIMPL;
293 }
294
295 static HRESULT WINAPI HTMLAnchorElement_get_search(IHTMLAnchorElement *iface, BSTR *p)
296 {
297     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
298     FIXME("(%p)->(%p)\n", This, p);
299     return E_NOTIMPL;
300 }
301
302 static HRESULT WINAPI HTMLAnchorElement_put_hash(IHTMLAnchorElement *iface, BSTR v)
303 {
304     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
305     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
306     return E_NOTIMPL;
307 }
308
309 static HRESULT WINAPI HTMLAnchorElement_get_hash(IHTMLAnchorElement *iface, BSTR *p)
310 {
311     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
312     FIXME("(%p)->(%p)\n", This, p);
313     return E_NOTIMPL;
314 }
315
316 static HRESULT WINAPI HTMLAnchorElement_put_onblur(IHTMLAnchorElement *iface, VARIANT v)
317 {
318     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
319
320     TRACE("(%p)->()\n", This);
321
322     return IHTMLElement2_put_onblur(&This->element.IHTMLElement2_iface, v);
323 }
324
325 static HRESULT WINAPI HTMLAnchorElement_get_onblur(IHTMLAnchorElement *iface, VARIANT *p)
326 {
327     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
328
329     TRACE("(%p)->(%p)\n", This, p);
330
331     return IHTMLElement2_get_onblur(&This->element.IHTMLElement2_iface, p);
332 }
333
334 static HRESULT WINAPI HTMLAnchorElement_put_onfocus(IHTMLAnchorElement *iface, VARIANT v)
335 {
336     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
337
338     TRACE("(%p)->()\n", This);
339
340     return IHTMLElement2_put_onfocus(&This->element.IHTMLElement2_iface, v);
341 }
342
343 static HRESULT WINAPI HTMLAnchorElement_get_onfocus(IHTMLAnchorElement *iface, VARIANT *p)
344 {
345     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
346
347     TRACE("(%p)->(%p)\n", This, p);
348
349     return IHTMLElement2_get_onfocus(&This->element.IHTMLElement2_iface, p);
350 }
351
352 static HRESULT WINAPI HTMLAnchorElement_put_accessKey(IHTMLAnchorElement *iface, BSTR v)
353 {
354     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
355
356     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
357
358     return IHTMLElement2_put_accessKey(&This->element.IHTMLElement2_iface, v);
359 }
360
361 static HRESULT WINAPI HTMLAnchorElement_get_accessKey(IHTMLAnchorElement *iface, BSTR *p)
362 {
363     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
364
365     TRACE("(%p)->(%p)\n", This, p);
366
367     return IHTMLElement2_get_accessKey(&This->element.IHTMLElement2_iface, p);
368 }
369
370 static HRESULT WINAPI HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement *iface, BSTR *p)
371 {
372     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
373     FIXME("(%p)->(%p)\n", This, p);
374     return E_NOTIMPL;
375 }
376
377 static HRESULT WINAPI HTMLAnchorElement_get_mimeType(IHTMLAnchorElement *iface, BSTR *p)
378 {
379     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
380     FIXME("(%p)->(%p)\n", This, p);
381     return E_NOTIMPL;
382 }
383
384 static HRESULT WINAPI HTMLAnchorElement_get_nameProp(IHTMLAnchorElement *iface, BSTR *p)
385 {
386     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
387     FIXME("(%p)->(%p)\n", This, p);
388     return E_NOTIMPL;
389 }
390
391 static HRESULT WINAPI HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement *iface, short v)
392 {
393     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
394
395     TRACE("(%p)->()\n", This);
396
397     return IHTMLElement2_put_tabIndex(&This->element.IHTMLElement2_iface, v);
398 }
399
400 static HRESULT WINAPI HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement *iface, short *p)
401 {
402     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
403
404     TRACE("(%p)->(%p)\n", This, p);
405
406     return IHTMLElement2_get_tabIndex(&This->element.IHTMLElement2_iface, p);
407 }
408
409 static HRESULT WINAPI HTMLAnchorElement_focus(IHTMLAnchorElement *iface)
410 {
411     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
412
413     TRACE("(%p)\n", This);
414
415     return IHTMLElement2_focus(&This->element.IHTMLElement2_iface);
416 }
417
418 static HRESULT WINAPI HTMLAnchorElement_blur(IHTMLAnchorElement *iface)
419 {
420     HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
421
422     TRACE("(%p)\n", This);
423
424     return IHTMLElement2_blur(&This->element.IHTMLElement2_iface);
425 }
426
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
476 };
477
478 static inline HTMLAnchorElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
479 {
480     return CONTAINING_RECORD(iface, HTMLAnchorElement, element.node);
481 }
482
483 static HRESULT HTMLAnchorElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
484 {
485     HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
486
487     *ppv = NULL;
488
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;
498     }
499
500     if(*ppv) {
501         IUnknown_AddRef((IUnknown*)*ppv);
502         return S_OK;
503     }
504
505     return HTMLElement_QI(&This->element.node, riid, ppv);
506 }
507
508 static void HTMLAnchorElement_destructor(HTMLDOMNode *iface)
509 {
510     HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
511
512     if(This->nsanchor)
513         nsIDOMHTMLAnchorElement_Release(This->nsanchor);
514
515     HTMLElement_destructor(&This->element.node);
516 }
517
518 static const NodeImplVtbl HTMLAnchorElementImplVtbl = {
519     HTMLAnchorElement_QI,
520     HTMLAnchorElement_destructor,
521     HTMLElement_clone
522 };
523
524 static const tid_t HTMLAnchorElement_iface_tids[] = {
525     IHTMLAnchorElement_tid,
526     HTMLELEMENT_TIDS,
527     IHTMLTextContainer_tid,
528     IHTMLUniqueName_tid,
529     0
530 };
531
532 static dispex_static_data_t HTMLAnchorElement_dispex = {
533     NULL,
534     DispHTMLAnchorElement_tid,
535     NULL,
536     HTMLAnchorElement_iface_tids
537 };
538
539 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
540 {
541     HTMLAnchorElement *ret;
542     nsresult nsres;
543
544     ret = heap_alloc_zero(sizeof(HTMLAnchorElement));
545     if(!ret)
546         return E_OUTOFMEMORY;
547
548     ret->IHTMLAnchorElement_iface.lpVtbl = &HTMLAnchorElementVtbl;
549     ret->element.node.vtbl = &HTMLAnchorElementImplVtbl;
550
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);
554         heap_free(ret);
555         return E_FAIL;
556     }
557
558     HTMLElement_Init(&ret->element, doc, nselem, &HTMLAnchorElement_dispex);
559
560     *elem = &ret->element;
561     return S_OK;
562 }