gdiplus/tests: Check more return values (Coverity).
[wine.git] / dlls / mshtml / htmlelem.c
blob1bd4ec4899d826bf4a498e898dfa9c08de18342d
1 /*
2 * Copyright 2006-2010 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
19 #include <stdarg.h>
20 #include <assert.h>
21 #include <math.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winreg.h"
29 #include "ole2.h"
30 #include "shlwapi.h"
31 #include "mshtmdid.h"
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
37 #include "htmlstyle.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 static const WCHAR aW[] = {'A',0};
42 static const WCHAR areaW[] = {'A','R','E','A',0};
43 static const WCHAR bodyW[] = {'B','O','D','Y',0};
44 static const WCHAR buttonW[] = {'B','U','T','T','O','N',0};
45 static const WCHAR embedW[] = {'E','M','B','E','D',0};
46 static const WCHAR formW[] = {'F','O','R','M',0};
47 static const WCHAR frameW[] = {'F','R','A','M','E',0};
48 static const WCHAR headW[] = {'H','E','A','D',0};
49 static const WCHAR htmlW[] = {'H','T','M','L',0};
50 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
51 static const WCHAR imgW[] = {'I','M','G',0};
52 static const WCHAR inputW[] = {'I','N','P','U','T',0};
53 static const WCHAR labelW[] = {'L','A','B','E','L',0};
54 static const WCHAR linkW[] = {'L','I','N','K',0};
55 static const WCHAR metaW[] = {'M','E','T','A',0};
56 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
57 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
58 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
59 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
60 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
61 static const WCHAR tableW[] = {'T','A','B','L','E',0};
62 static const WCHAR tdW[] = {'T','D',0};
63 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
64 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
65 static const WCHAR trW[] = {'T','R',0};
67 #define ATTRFLAG_CASESENSITIVE 0x0001
68 #define ATTRFLAG_ASSTRING 0x0002
69 #define ATTRFLAG_EXPANDURL 0x0004
71 typedef struct {
72 const WCHAR *name;
73 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
74 } tag_desc_t;
76 static const tag_desc_t tag_descs[] = {
77 {aW, HTMLAnchorElement_Create},
78 {areaW, HTMLAreaElement_Create},
79 {bodyW, HTMLBodyElement_Create},
80 {buttonW, HTMLButtonElement_Create},
81 {embedW, HTMLEmbedElement_Create},
82 {formW, HTMLFormElement_Create},
83 {frameW, HTMLFrameElement_Create},
84 {headW, HTMLHeadElement_Create},
85 {htmlW, HTMLHtmlElement_Create},
86 {iframeW, HTMLIFrame_Create},
87 {imgW, HTMLImgElement_Create},
88 {inputW, HTMLInputElement_Create},
89 {labelW, HTMLLabelElement_Create},
90 {linkW, HTMLLinkElement_Create},
91 {metaW, HTMLMetaElement_Create},
92 {objectW, HTMLObjectElement_Create},
93 {optionW, HTMLOptionElement_Create},
94 {scriptW, HTMLScriptElement_Create},
95 {selectW, HTMLSelectElement_Create},
96 {styleW, HTMLStyleElement_Create},
97 {tableW, HTMLTable_Create},
98 {tdW, HTMLTableCell_Create},
99 {textareaW, HTMLTextAreaElement_Create},
100 {title_tagW, HTMLTitleElement_Create},
101 {trW, HTMLTableRow_Create}
104 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
106 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
107 int r;
109 while(min <= max) {
110 i = (min+max)/2;
111 r = strcmpW(tag_name, tag_descs[i].name);
112 if(!r)
113 return tag_descs+i;
115 if(r < 0)
116 max = i-1;
117 else
118 min = i+1;
121 return NULL;
124 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
126 nsIDOMDocumentFragment *nsfragment;
127 nsIDOMNode *nsparent;
128 nsIDOMRange *range;
129 nsAString html_str;
130 nsresult nsres;
131 HRESULT hres = S_OK;
133 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
134 if(NS_FAILED(nsres)) {
135 ERR("CreateRange failed: %08x\n", nsres);
136 return E_FAIL;
139 nsAString_InitDepend(&html_str, html);
140 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
141 nsIDOMRange_Release(range);
142 nsAString_Finish(&html_str);
143 if(NS_FAILED(nsres)) {
144 ERR("CreateContextualFragment failed: %08x\n", nsres);
145 return E_FAIL;
148 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
149 if(NS_SUCCEEDED(nsres) && nsparent) {
150 nsIDOMNode *nstmp;
152 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
153 nsIDOMNode_Release(nsparent);
154 if(NS_FAILED(nsres)) {
155 ERR("ReplaceChild failed: %08x\n", nsres);
156 hres = E_FAIL;
157 }else if(nstmp) {
158 nsIDOMNode_Release(nstmp);
160 }else {
161 ERR("GetParentNode failed: %08x\n", nsres);
162 hres = E_FAIL;
165 nsIDOMDocumentFragment_Release(nsfragment);
166 return hres;
169 nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
171 nsAString name_str;
172 nsresult nsres;
174 nsAString_InitDepend(&name_str, name);
175 nsAString_Init(val_str, NULL);
176 nsres = nsIDOMHTMLElement_GetAttribute(nselem, &name_str, val_str);
177 nsAString_Finish(&name_str);
178 if(NS_FAILED(nsres)) {
179 ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name), nsres);
180 nsAString_Finish(val_str);
181 return nsres;
184 nsAString_GetData(val_str, val);
185 return NS_OK;
188 HRESULT elem_string_attr_getter(HTMLElement *elem, const WCHAR *name, BOOL use_null, BSTR *p)
190 const PRUnichar *val;
191 nsAString val_str;
192 nsresult nsres;
193 HRESULT hres = S_OK;
195 nsres = get_elem_attr_value(elem->nselem, name, &val_str, &val);
196 if(NS_FAILED(nsres))
197 return E_FAIL;
199 TRACE("%s: returning %s\n", debugstr_w(name), debugstr_w(val));
201 if(*val || !use_null) {
202 *p = SysAllocString(val);
203 if(!*p)
204 hres = E_OUTOFMEMORY;
205 }else {
206 *p = NULL;
208 nsAString_Finish(&val_str);
209 return hres;
212 HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHAR *value)
214 nsAString name_str, val_str;
215 nsresult nsres;
217 nsAString_InitDepend(&name_str, name);
218 nsAString_InitDepend(&val_str, value);
219 nsres = nsIDOMHTMLElement_SetAttribute(elem->nselem, &name_str, &val_str);
220 nsAString_Finish(&name_str);
221 nsAString_Finish(&val_str);
223 if(NS_FAILED(nsres)) {
224 WARN("SetAttribute failed: %08x\n", nsres);
225 return E_FAIL;
228 return S_OK;
231 HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
233 static const WCHAR uninitializedW[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
234 static const WCHAR loadingW[] = {'l','o','a','d','i','n','g',0};
235 static const WCHAR loadedW[] = {'l','o','a','d','e','d',0};
236 static const WCHAR interactiveW[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
237 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
239 static const LPCWSTR readystate_strs[] = {
240 uninitializedW,
241 loadingW,
242 loadedW,
243 interactiveW,
244 completeW
247 assert(readystate <= READYSTATE_COMPLETE);
248 *p = SysAllocString(readystate_strs[readystate]);
249 return *p ? S_OK : E_OUTOFMEMORY;
252 typedef struct
254 DispatchEx dispex;
255 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
257 LONG ref;
258 } HTMLFiltersCollection;
260 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
262 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
265 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
267 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
269 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
272 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
274 nsIDOMElement *nselem;
275 nsAString tag_str;
276 nsresult nsres;
278 if(!doc->nsdoc) {
279 WARN("NULL nsdoc\n");
280 return E_UNEXPECTED;
283 nsAString_InitDepend(&tag_str, tag);
284 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
285 nsAString_Finish(&tag_str);
286 if(NS_FAILED(nsres)) {
287 ERR("CreateElement failed: %08x\n", nsres);
288 return E_FAIL;
291 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
292 nsIDOMElement_Release(nselem);
293 if(NS_FAILED(nsres)) {
294 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
295 return E_FAIL;
298 return S_OK;
301 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
303 nsIDOMHTMLElement *nselem;
304 HRESULT hres;
306 /* Use owner doc if called on document fragment */
307 if(!doc->nsdoc)
308 doc = doc->node.doc;
310 hres = create_nselem(doc, tag, &nselem);
311 if(FAILED(hres))
312 return hres;
314 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
315 nsIDOMHTMLElement_Release(nselem);
316 return hres;
319 typedef struct {
320 DispatchEx dispex;
321 IHTMLRect IHTMLRect_iface;
323 LONG ref;
325 nsIDOMClientRect *nsrect;
326 } HTMLRect;
328 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
330 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
333 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
335 HTMLRect *This = impl_from_IHTMLRect(iface);
337 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
339 if(IsEqualGUID(&IID_IUnknown, riid)) {
340 *ppv = &This->IHTMLRect_iface;
341 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
342 *ppv = &This->IHTMLRect_iface;
343 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
344 return *ppv ? S_OK : E_NOINTERFACE;
345 }else {
346 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
347 *ppv = NULL;
348 return E_NOINTERFACE;
351 IUnknown_AddRef((IUnknown*)*ppv);
352 return S_OK;
355 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
357 HTMLRect *This = impl_from_IHTMLRect(iface);
358 LONG ref = InterlockedIncrement(&This->ref);
360 TRACE("(%p) ref=%d\n", This, ref);
362 return ref;
365 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
367 HTMLRect *This = impl_from_IHTMLRect(iface);
368 LONG ref = InterlockedDecrement(&This->ref);
370 TRACE("(%p) ref=%d\n", This, ref);
372 if(!ref) {
373 if(This->nsrect)
374 nsIDOMClientRect_Release(This->nsrect);
375 release_dispex(&This->dispex);
376 heap_free(This);
379 return ref;
382 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
384 HTMLRect *This = impl_from_IHTMLRect(iface);
385 FIXME("(%p)->(%p)\n", This, pctinfo);
386 return E_NOTIMPL;
389 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
390 LCID lcid, ITypeInfo **ppTInfo)
392 HTMLRect *This = impl_from_IHTMLRect(iface);
394 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
397 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
398 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
400 HTMLRect *This = impl_from_IHTMLRect(iface);
402 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
403 lcid, rgDispId);
406 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
407 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
408 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
410 HTMLRect *This = impl_from_IHTMLRect(iface);
412 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
413 pDispParams, pVarResult, pExcepInfo, puArgErr);
416 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
418 HTMLRect *This = impl_from_IHTMLRect(iface);
419 FIXME("(%p)->(%d)\n", This, v);
420 return E_NOTIMPL;
423 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
425 HTMLRect *This = impl_from_IHTMLRect(iface);
426 float left;
427 nsresult nsres;
429 TRACE("(%p)->(%p)\n", This, p);
431 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
432 if(NS_FAILED(nsres)) {
433 ERR("GetLeft failed: %08x\n", nsres);
434 return E_FAIL;
437 *p = floor(left+0.5);
438 return S_OK;
441 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
443 HTMLRect *This = impl_from_IHTMLRect(iface);
444 FIXME("(%p)->(%d)\n", This, v);
445 return E_NOTIMPL;
448 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
450 HTMLRect *This = impl_from_IHTMLRect(iface);
451 float top;
452 nsresult nsres;
454 TRACE("(%p)->(%p)\n", This, p);
456 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
457 if(NS_FAILED(nsres)) {
458 ERR("GetTop failed: %08x\n", nsres);
459 return E_FAIL;
462 *p = floor(top+0.5);
463 return S_OK;
466 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
468 HTMLRect *This = impl_from_IHTMLRect(iface);
469 FIXME("(%p)->(%d)\n", This, v);
470 return E_NOTIMPL;
473 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
475 HTMLRect *This = impl_from_IHTMLRect(iface);
476 float right;
477 nsresult nsres;
479 TRACE("(%p)->(%p)\n", This, p);
481 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
482 if(NS_FAILED(nsres)) {
483 ERR("GetRight failed: %08x\n", nsres);
484 return E_FAIL;
487 *p = floor(right+0.5);
488 return S_OK;
491 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
493 HTMLRect *This = impl_from_IHTMLRect(iface);
494 FIXME("(%p)->(%d)\n", This, v);
495 return E_NOTIMPL;
498 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
500 HTMLRect *This = impl_from_IHTMLRect(iface);
501 float bottom;
502 nsresult nsres;
504 TRACE("(%p)->(%p)\n", This, p);
506 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
507 if(NS_FAILED(nsres)) {
508 ERR("GetBottom failed: %08x\n", nsres);
509 return E_FAIL;
512 *p = floor(bottom+0.5);
513 return S_OK;
516 static const IHTMLRectVtbl HTMLRectVtbl = {
517 HTMLRect_QueryInterface,
518 HTMLRect_AddRef,
519 HTMLRect_Release,
520 HTMLRect_GetTypeInfoCount,
521 HTMLRect_GetTypeInfo,
522 HTMLRect_GetIDsOfNames,
523 HTMLRect_Invoke,
524 HTMLRect_put_left,
525 HTMLRect_get_left,
526 HTMLRect_put_top,
527 HTMLRect_get_top,
528 HTMLRect_put_right,
529 HTMLRect_get_right,
530 HTMLRect_put_bottom,
531 HTMLRect_get_bottom
534 static const tid_t HTMLRect_iface_tids[] = {
535 IHTMLRect_tid,
538 static dispex_static_data_t HTMLRect_dispex = {
539 NULL,
540 IHTMLRect_tid,
541 HTMLRect_iface_tids
544 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
546 HTMLRect *rect;
548 rect = heap_alloc_zero(sizeof(HTMLRect));
549 if(!rect)
550 return E_OUTOFMEMORY;
552 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
553 rect->ref = 1;
555 init_dispex(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex);
557 nsIDOMClientRect_AddRef(nsrect);
558 rect->nsrect = nsrect;
560 *ret = &rect->IHTMLRect_iface;
561 return S_OK;
564 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
565 REFIID riid, void **ppv)
567 HTMLElement *This = impl_from_IHTMLElement(iface);
569 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
572 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
574 HTMLElement *This = impl_from_IHTMLElement(iface);
576 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
579 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
581 HTMLElement *This = impl_from_IHTMLElement(iface);
583 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
586 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
588 HTMLElement *This = impl_from_IHTMLElement(iface);
589 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
592 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
593 LCID lcid, ITypeInfo **ppTInfo)
595 HTMLElement *This = impl_from_IHTMLElement(iface);
596 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
599 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
600 LPOLESTR *rgszNames, UINT cNames,
601 LCID lcid, DISPID *rgDispId)
603 HTMLElement *This = impl_from_IHTMLElement(iface);
604 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
605 lcid, rgDispId);
608 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
609 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
610 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
612 HTMLElement *This = impl_from_IHTMLElement(iface);
613 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
614 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
617 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
619 DISPID propput_dispid = DISPID_PROPERTYPUT;
620 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
621 EXCEPINFO ei;
623 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
624 TRACE("Ignoring call on style attribute\n");
625 return S_OK;
628 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid,
629 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
632 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
633 VARIANT AttributeValue, LONG lFlags)
635 HTMLElement *This = impl_from_IHTMLElement(iface);
636 DISPID dispid;
637 HRESULT hres;
639 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
641 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
642 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
643 if(FAILED(hres))
644 return hres;
646 return set_elem_attr_value_by_dispid(This, dispid, &AttributeValue);
649 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
651 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
652 EXCEPINFO excep;
654 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
655 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
658 HRESULT attr_value_to_string(VARIANT *v)
660 HRESULT hres;
662 static const WCHAR nullW[] = {'n','u','l','l',0};
664 switch(V_VT(v)) {
665 case VT_BSTR:
666 break;
667 case VT_NULL:
668 V_BSTR(v) = SysAllocString(nullW);
669 if(!V_BSTR(v))
670 return E_OUTOFMEMORY;
671 V_VT(v) = VT_BSTR;
672 break;
673 case VT_DISPATCH:
674 IDispatch_Release(V_DISPATCH(v));
675 V_VT(v) = VT_BSTR;
676 V_BSTR(v) = SysAllocString(NULL);
677 break;
678 default:
679 hres = VariantChangeType(v, v, 0, VT_BSTR);
680 if(FAILED(hres))
681 return hres;
684 return S_OK;
687 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
688 LONG lFlags, VARIANT *AttributeValue)
690 HTMLElement *This = impl_from_IHTMLElement(iface);
691 DISPID dispid;
692 HRESULT hres;
694 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
696 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
697 FIXME("Unsupported flags %x\n", lFlags);
699 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
700 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
701 if(hres == DISP_E_UNKNOWNNAME) {
702 V_VT(AttributeValue) = VT_NULL;
703 return S_OK;
706 if(FAILED(hres)) {
707 V_VT(AttributeValue) = VT_NULL;
708 return hres;
711 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
712 if(SUCCEEDED(hres) && (lFlags & ATTRFLAG_ASSTRING))
713 hres = attr_value_to_string(AttributeValue);
714 return hres;
717 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
718 LONG lFlags, VARIANT_BOOL *pfSuccess)
720 HTMLElement *This = impl_from_IHTMLElement(iface);
721 DISPID id;
722 HRESULT hres;
724 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
726 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
727 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
728 if(hres == DISP_E_UNKNOWNNAME) {
729 *pfSuccess = VARIANT_FALSE;
730 return S_OK;
732 if(FAILED(hres))
733 return hres;
735 if(id == DISPID_IHTMLELEMENT_STYLE) {
736 IHTMLStyle *style;
738 TRACE("Special case: style\n");
740 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
741 if(FAILED(hres))
742 return hres;
744 hres = IHTMLStyle_put_cssText(style, NULL);
745 IHTMLStyle_Release(style);
746 if(FAILED(hres))
747 return hres;
749 *pfSuccess = VARIANT_TRUE;
750 return S_OK;
753 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
756 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
758 HTMLElement *This = impl_from_IHTMLElement(iface);
759 nsAString classname_str;
760 nsresult nsres;
762 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
764 if(!This->nselem) {
765 FIXME("NULL nselem\n");
766 return E_NOTIMPL;
769 nsAString_InitDepend(&classname_str, v);
770 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
771 nsAString_Finish(&classname_str);
772 if(NS_FAILED(nsres))
773 ERR("SetClassName failed: %08x\n", nsres);
775 return S_OK;
778 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
780 HTMLElement *This = impl_from_IHTMLElement(iface);
781 nsAString class_str;
782 nsresult nsres;
784 TRACE("(%p)->(%p)\n", This, p);
786 if(!This->nselem) {
787 FIXME("NULL nselem\n");
788 return E_NOTIMPL;
791 nsAString_Init(&class_str, NULL);
792 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
793 return return_nsstr(nsres, &class_str, p);
796 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
798 HTMLElement *This = impl_from_IHTMLElement(iface);
799 nsAString id_str;
800 nsresult nsres;
802 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
804 if(!This->nselem) {
805 FIXME("nselem == NULL\n");
806 return S_OK;
809 nsAString_InitDepend(&id_str, v);
810 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
811 nsAString_Finish(&id_str);
812 if(NS_FAILED(nsres))
813 ERR("SetId failed: %08x\n", nsres);
815 return S_OK;
818 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
820 HTMLElement *This = impl_from_IHTMLElement(iface);
821 nsAString id_str;
822 nsresult nsres;
824 TRACE("(%p)->(%p)\n", This, p);
826 if(!This->nselem) {
827 *p = NULL;
828 return S_OK;
831 nsAString_Init(&id_str, NULL);
832 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
833 return return_nsstr(nsres, &id_str, p);
836 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
838 HTMLElement *This = impl_from_IHTMLElement(iface);
839 nsAString tag_str;
840 nsresult nsres;
842 TRACE("(%p)->(%p)\n", This, p);
844 if(!This->nselem) {
845 static const WCHAR comment_tagW[] = {'!',0};
847 WARN("NULL nselem, assuming comment\n");
849 *p = SysAllocString(comment_tagW);
850 return *p ? S_OK : E_OUTOFMEMORY;
853 nsAString_Init(&tag_str, NULL);
854 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
855 return return_nsstr(nsres, &tag_str, p);
858 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
860 HTMLElement *This = impl_from_IHTMLElement(iface);
861 IHTMLDOMNode *node;
862 HRESULT hres;
864 TRACE("(%p)->(%p)\n", This, p);
866 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
867 if(FAILED(hres))
868 return hres;
870 if(!node) {
871 *p = NULL;
872 return S_OK;
875 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
876 IHTMLDOMNode_Release(node);
877 if(FAILED(hres))
878 *p = NULL;
880 return S_OK;
883 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
885 HTMLElement *This = impl_from_IHTMLElement(iface);
887 TRACE("(%p)->(%p)\n", This, p);
889 if(!This->style) {
890 HRESULT hres;
892 hres = HTMLStyle_Create(This, &This->style);
893 if(FAILED(hres))
894 return hres;
897 *p = &This->style->IHTMLStyle_iface;
898 IHTMLStyle_AddRef(*p);
899 return S_OK;
902 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
904 HTMLElement *This = impl_from_IHTMLElement(iface);
906 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
908 return set_node_event(&This->node, EVENTID_HELP, &v);
911 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
913 HTMLElement *This = impl_from_IHTMLElement(iface);
915 TRACE("(%p)->(%p)\n", This, p);
917 return get_node_event(&This->node, EVENTID_HELP, p);
920 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
922 HTMLElement *This = impl_from_IHTMLElement(iface);
924 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
926 return set_node_event(&This->node, EVENTID_CLICK, &v);
929 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
931 HTMLElement *This = impl_from_IHTMLElement(iface);
933 TRACE("(%p)->(%p)\n", This, p);
935 return get_node_event(&This->node, EVENTID_CLICK, p);
938 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
940 HTMLElement *This = impl_from_IHTMLElement(iface);
942 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
944 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
947 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
949 HTMLElement *This = impl_from_IHTMLElement(iface);
951 TRACE("(%p)->(%p)\n", This, p);
953 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
956 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
958 HTMLElement *This = impl_from_IHTMLElement(iface);
960 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
962 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
965 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
967 HTMLElement *This = impl_from_IHTMLElement(iface);
969 TRACE("(%p)->(%p)\n", This, p);
971 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
974 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
976 HTMLElement *This = impl_from_IHTMLElement(iface);
978 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
980 return set_node_event(&This->node, EVENTID_KEYUP, &v);
983 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
985 HTMLElement *This = impl_from_IHTMLElement(iface);
987 TRACE("(%p)->(%p)\n", This, p);
989 return get_node_event(&This->node, EVENTID_KEYUP, p);
992 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
994 HTMLElement *This = impl_from_IHTMLElement(iface);
996 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
998 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
1001 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
1003 HTMLElement *This = impl_from_IHTMLElement(iface);
1005 TRACE("(%p)->(%p)\n", This, p);
1007 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1010 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1012 HTMLElement *This = impl_from_IHTMLElement(iface);
1014 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1016 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1019 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1021 HTMLElement *This = impl_from_IHTMLElement(iface);
1023 TRACE("(%p)->(%p)\n", This, p);
1025 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1028 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1030 HTMLElement *This = impl_from_IHTMLElement(iface);
1032 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1034 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1037 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1039 HTMLElement *This = impl_from_IHTMLElement(iface);
1041 TRACE("(%p)->(%p)\n", This, p);
1043 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1046 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1048 HTMLElement *This = impl_from_IHTMLElement(iface);
1050 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1052 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1055 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1057 HTMLElement *This = impl_from_IHTMLElement(iface);
1059 TRACE("(%p)->(%p)\n", This, p);
1061 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1064 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1066 HTMLElement *This = impl_from_IHTMLElement(iface);
1068 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1070 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1073 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1075 HTMLElement *This = impl_from_IHTMLElement(iface);
1077 TRACE("(%p)->(%p)\n", This, p);
1079 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1082 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1084 HTMLElement *This = impl_from_IHTMLElement(iface);
1086 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1088 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1091 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1093 HTMLElement *This = impl_from_IHTMLElement(iface);
1095 TRACE("(%p)->(%p)\n", This, p);
1097 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1100 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1102 HTMLElement *This = impl_from_IHTMLElement(iface);
1104 TRACE("(%p)->(%p)\n", This, p);
1106 if(!p)
1107 return E_POINTER;
1109 if(This->node.vtbl->get_document)
1110 return This->node.vtbl->get_document(&This->node, p);
1112 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1113 IDispatch_AddRef(*p);
1114 return S_OK;
1117 static const WCHAR titleW[] = {'t','i','t','l','e',0};
1119 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1121 HTMLElement *This = impl_from_IHTMLElement(iface);
1122 nsAString title_str;
1123 nsresult nsres;
1125 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1127 if(!This->nselem) {
1128 VARIANT *var;
1129 HRESULT hres;
1131 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, TRUE, &var);
1132 if(FAILED(hres))
1133 return hres;
1135 VariantClear(var);
1136 V_VT(var) = VT_BSTR;
1137 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1138 return S_OK;
1141 nsAString_InitDepend(&title_str, v);
1142 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
1143 nsAString_Finish(&title_str);
1144 if(NS_FAILED(nsres))
1145 ERR("SetTitle failed: %08x\n", nsres);
1147 return S_OK;
1150 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1152 HTMLElement *This = impl_from_IHTMLElement(iface);
1153 nsAString title_str;
1154 nsresult nsres;
1156 TRACE("(%p)->(%p)\n", This, p);
1158 if(!This->nselem) {
1159 VARIANT *var;
1160 HRESULT hres;
1162 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, FALSE, &var);
1163 if(hres == DISP_E_UNKNOWNNAME) {
1164 *p = NULL;
1165 }else if(V_VT(var) != VT_BSTR) {
1166 FIXME("title = %s\n", debugstr_variant(var));
1167 return E_FAIL;
1168 }else {
1169 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1172 return S_OK;
1175 nsAString_Init(&title_str, NULL);
1176 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
1177 return return_nsstr(nsres, &title_str, p);
1180 static const WCHAR languageW[] = {'l','a','n','g','u','a','g','e',0};
1182 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1184 HTMLElement *This = impl_from_IHTMLElement(iface);
1186 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1188 return elem_string_attr_setter(This, languageW, v);
1191 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1193 HTMLElement *This = impl_from_IHTMLElement(iface);
1195 TRACE("(%p)->(%p)\n", This, p);
1197 return elem_string_attr_getter(This, languageW, TRUE, p);
1200 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1202 HTMLElement *This = impl_from_IHTMLElement(iface);
1204 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1206 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1209 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1211 HTMLElement *This = impl_from_IHTMLElement(iface);
1213 TRACE("(%p)->(%p)\n", This, p);
1215 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1218 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1220 HTMLElement *This = impl_from_IHTMLElement(iface);
1221 cpp_bool start = TRUE;
1222 nsresult nsres;
1224 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1226 switch(V_VT(&varargStart)) {
1227 case VT_EMPTY:
1228 case VT_ERROR:
1229 break;
1230 case VT_BOOL:
1231 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1232 break;
1233 default:
1234 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1237 if(!This->nselem) {
1238 FIXME("Unsupported for comments\n");
1239 return E_NOTIMPL;
1242 nsres = nsIDOMHTMLElement_ScrollIntoView(This->nselem, start, 1);
1243 assert(nsres == NS_OK);
1245 return S_OK;
1248 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1249 VARIANT_BOOL *pfResult)
1251 HTMLElement *This = impl_from_IHTMLElement(iface);
1252 cpp_bool result = FALSE;
1254 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1256 if(pChild) {
1257 HTMLElement *child;
1258 nsresult nsres;
1260 child = unsafe_impl_from_IHTMLElement(pChild);
1261 if(!child) {
1262 ERR("not our element\n");
1263 return E_FAIL;
1266 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1267 assert(nsres == NS_OK);
1270 *pfResult = variant_bool(result);
1271 return S_OK;
1274 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1276 HTMLElement *This = impl_from_IHTMLElement(iface);
1278 TRACE("(%p)->(%p)\n", This, p);
1280 return get_elem_source_index(This, p);
1283 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1285 HTMLElement *This = impl_from_IHTMLElement(iface);
1286 FIXME("(%p)->(%p)\n", This, p);
1287 return E_NOTIMPL;
1290 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1292 HTMLElement *This = impl_from_IHTMLElement(iface);
1293 nsAString nsstr;
1294 nsresult nsres;
1296 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1298 if(!This->nselem) {
1299 FIXME("NULL nselem\n");
1300 return E_NOTIMPL;
1303 nsAString_InitDepend(&nsstr, v);
1304 nsres = nsIDOMHTMLElement_SetLang(This->nselem, &nsstr);
1305 nsAString_Finish(&nsstr);
1306 if(NS_FAILED(nsres)) {
1307 ERR("SetLang failed: %08x\n", nsres);
1308 return E_FAIL;
1311 return S_OK;
1314 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1316 HTMLElement *This = impl_from_IHTMLElement(iface);
1317 nsAString nsstr;
1318 nsresult nsres;
1320 TRACE("(%p)->(%p)\n", This, p);
1322 if(!This->nselem) {
1323 FIXME("NULL nselem\n");
1324 return E_NOTIMPL;
1327 nsAString_Init(&nsstr, NULL);
1328 nsres = nsIDOMHTMLElement_GetLang(This->nselem, &nsstr);
1329 return return_nsstr(nsres, &nsstr, p);
1332 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1334 HTMLElement *This = impl_from_IHTMLElement(iface);
1335 nsresult nsres;
1337 TRACE("(%p)->(%p)\n", This, p);
1339 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, p);
1340 if(NS_FAILED(nsres)) {
1341 ERR("GetOffsetLeft failed: %08x\n", nsres);
1342 return E_FAIL;
1345 return S_OK;
1348 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1350 HTMLElement *This = impl_from_IHTMLElement(iface);
1351 nsresult nsres;
1353 TRACE("(%p)->(%p)\n", This, p);
1355 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, p);
1356 if(NS_FAILED(nsres)) {
1357 ERR("GetOffsetTop failed: %08x\n", nsres);
1358 return E_FAIL;
1361 return S_OK;
1364 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1366 HTMLElement *This = impl_from_IHTMLElement(iface);
1367 nsresult nsres;
1369 TRACE("(%p)->(%p)\n", This, p);
1371 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, p);
1372 if(NS_FAILED(nsres)) {
1373 ERR("GetOffsetWidth failed: %08x\n", nsres);
1374 return E_FAIL;
1377 return S_OK;
1380 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1382 HTMLElement *This = impl_from_IHTMLElement(iface);
1383 nsresult nsres;
1385 TRACE("(%p)->(%p)\n", This, p);
1387 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, p);
1388 if(NS_FAILED(nsres)) {
1389 ERR("GetOffsetHeight failed: %08x\n", nsres);
1390 return E_FAIL;
1393 return S_OK;
1396 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1398 HTMLElement *This = impl_from_IHTMLElement(iface);
1399 nsIDOMElement *nsparent;
1400 nsresult nsres;
1401 HRESULT hres;
1403 TRACE("(%p)->(%p)\n", This, p);
1405 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
1406 if(NS_FAILED(nsres)) {
1407 ERR("GetOffsetParent failed: %08x\n", nsres);
1408 return E_FAIL;
1411 if(nsparent) {
1412 HTMLDOMNode *node;
1414 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1415 nsIDOMElement_Release(nsparent);
1416 if(FAILED(hres))
1417 return hres;
1419 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1420 node_release(node);
1421 }else {
1422 *p = NULL;
1423 hres = S_OK;
1426 return hres;
1429 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1431 HTMLElement *This = impl_from_IHTMLElement(iface);
1432 nsAString html_str;
1433 nsresult nsres;
1435 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1437 if(!This->nselem) {
1438 FIXME("NULL nselem\n");
1439 return E_NOTIMPL;
1442 nsAString_InitDepend(&html_str, v);
1443 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
1444 nsAString_Finish(&html_str);
1445 if(NS_FAILED(nsres)) {
1446 FIXME("SetInnerHtml failed %08x\n", nsres);
1447 return E_FAIL;
1450 return S_OK;
1453 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1455 HTMLElement *This = impl_from_IHTMLElement(iface);
1456 nsAString html_str;
1457 nsresult nsres;
1459 TRACE("(%p)->(%p)\n", This, p);
1461 if(!This->nselem) {
1462 FIXME("NULL nselem\n");
1463 return E_NOTIMPL;
1466 nsAString_Init(&html_str, NULL);
1467 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
1468 return return_nsstr(nsres, &html_str, p);
1471 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1473 HTMLElement *This = impl_from_IHTMLElement(iface);
1474 nsIDOMNode *nschild, *tmp;
1475 nsIDOMText *text_node;
1476 nsAString text_str;
1477 nsresult nsres;
1479 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1481 while(1) {
1482 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1483 if(NS_FAILED(nsres)) {
1484 ERR("GetLastChild failed: %08x\n", nsres);
1485 return E_FAIL;
1487 if(!nschild)
1488 break;
1490 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1491 nsIDOMNode_Release(nschild);
1492 if(NS_FAILED(nsres)) {
1493 ERR("RemoveChild failed: %08x\n", nsres);
1494 return E_FAIL;
1496 nsIDOMNode_Release(tmp);
1499 nsAString_InitDepend(&text_str, v);
1500 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1501 nsAString_Finish(&text_str);
1502 if(NS_FAILED(nsres)) {
1503 ERR("CreateTextNode failed: %08x\n", nsres);
1504 return E_FAIL;
1507 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1508 if(NS_FAILED(nsres)) {
1509 ERR("AppendChild failed: %08x\n", nsres);
1510 return E_FAIL;
1513 nsIDOMNode_Release(tmp);
1514 return S_OK;
1517 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1519 HTMLElement *This = impl_from_IHTMLElement(iface);
1521 TRACE("(%p)->(%p)\n", This, p);
1523 return get_node_text(&This->node, p);
1526 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1528 HTMLElement *This = impl_from_IHTMLElement(iface);
1530 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1532 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1535 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1537 HTMLElement *This = impl_from_IHTMLElement(iface);
1538 nsAString html_str;
1539 HRESULT hres;
1541 WARN("(%p)->(%p) semi-stub\n", This, p);
1543 nsAString_Init(&html_str, NULL);
1544 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1545 if(SUCCEEDED(hres)) {
1546 const PRUnichar *html;
1548 nsAString_GetData(&html_str, &html);
1549 *p = SysAllocString(html);
1550 if(!*p)
1551 hres = E_OUTOFMEMORY;
1554 nsAString_Finish(&html_str);
1556 TRACE("ret %s\n", debugstr_w(*p));
1557 return hres;
1560 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1562 HTMLElement *This = impl_from_IHTMLElement(iface);
1563 nsIDOMText *text_node;
1564 nsIDOMRange *range;
1565 nsAString nsstr;
1566 nsresult nsres;
1568 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1570 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
1571 WARN("Called on element that does not support setting the property.\n");
1572 return 0x800a0258; /* undocumented error code */
1575 if(!This->node.doc->nsdoc) {
1576 FIXME("NULL nsdoc\n");
1577 return E_FAIL;
1580 nsAString_InitDepend(&nsstr, v);
1581 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &nsstr, &text_node);
1582 nsAString_Finish(&nsstr);
1583 if(NS_FAILED(nsres)) {
1584 ERR("CreateTextNode failed\n");
1585 return E_FAIL;
1588 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1589 if(NS_SUCCEEDED(nsres)) {
1590 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
1591 if(NS_SUCCEEDED(nsres))
1592 nsres = nsIDOMRange_DeleteContents(range);
1593 if(NS_SUCCEEDED(nsres))
1594 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
1595 if(NS_SUCCEEDED(nsres))
1596 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
1597 if(NS_SUCCEEDED(nsres))
1598 nsres = nsIDOMRange_DeleteContents(range);
1599 nsIDOMRange_Release(range);
1601 nsIDOMText_Release(text_node);
1602 if(NS_FAILED(nsres)) {
1603 ERR("failed to set text: %08x\n", nsres);
1604 return E_FAIL;
1607 return S_OK;
1610 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1612 HTMLElement *This = impl_from_IHTMLElement(iface);
1614 TRACE("(%p)->(%p)\n", This, p);
1616 /* getter is the same as innerText */
1617 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
1620 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1622 nsIDOMNode *ret_nsnode;
1623 nsresult nsres;
1624 HRESULT hres = S_OK;
1626 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1627 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1628 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1629 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1631 if (!strcmpiW(where, beforebeginW)) {
1632 nsIDOMNode *parent;
1634 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1635 if(NS_FAILED(nsres))
1636 return E_FAIL;
1638 if(!parent)
1639 return E_INVALIDARG;
1641 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1642 nsIDOMNode_Release(parent);
1643 }else if(!strcmpiW(where, afterbeginW)) {
1644 nsIDOMNode *first_child;
1646 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1647 if(NS_FAILED(nsres))
1648 return E_FAIL;
1650 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1651 if(NS_FAILED(nsres))
1652 return E_FAIL;
1654 if (first_child)
1655 nsIDOMNode_Release(first_child);
1656 }else if (!strcmpiW(where, beforeendW)) {
1657 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1658 }else if (!strcmpiW(where, afterendW)) {
1659 nsIDOMNode *next_sibling, *parent;
1661 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1662 if(NS_FAILED(nsres))
1663 return E_FAIL;
1664 if(!parent)
1665 return E_INVALIDARG;
1667 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1668 if(NS_SUCCEEDED(nsres)) {
1669 if(next_sibling) {
1670 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1671 nsIDOMNode_Release(next_sibling);
1672 }else {
1673 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1677 nsIDOMNode_Release(parent);
1678 }else {
1679 ERR("invalid where: %s\n", debugstr_w(where));
1680 return E_INVALIDARG;
1683 if (NS_FAILED(nsres))
1684 return E_FAIL;
1686 if(ret_node)
1687 hres = get_node(This->node.doc, ret_nsnode, TRUE, ret_node);
1688 nsIDOMNode_Release(ret_nsnode);
1689 return hres;
1692 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1693 BSTR html)
1695 HTMLElement *This = impl_from_IHTMLElement(iface);
1696 nsIDOMRange *range;
1697 nsIDOMNode *nsnode;
1698 nsAString ns_html;
1699 nsresult nsres;
1700 HRESULT hr;
1702 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1704 if(!This->node.doc->nsdoc) {
1705 WARN("NULL nsdoc\n");
1706 return E_UNEXPECTED;
1709 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1710 if(NS_FAILED(nsres))
1712 ERR("CreateRange failed: %08x\n", nsres);
1713 return E_FAIL;
1716 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1718 nsAString_InitDepend(&ns_html, html);
1719 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1720 nsAString_Finish(&ns_html);
1721 nsIDOMRange_Release(range);
1723 if(NS_FAILED(nsres) || !nsnode)
1725 ERR("CreateTextNode failed: %08x\n", nsres);
1726 return E_FAIL;
1729 hr = insert_adjacent_node(This, where, nsnode, NULL);
1730 nsIDOMNode_Release(nsnode);
1731 return hr;
1734 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1735 BSTR text)
1737 HTMLElement *This = impl_from_IHTMLElement(iface);
1738 nsIDOMNode *nsnode;
1739 nsAString ns_text;
1740 nsresult nsres;
1741 HRESULT hr;
1743 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1745 if(!This->node.doc->nsdoc) {
1746 WARN("NULL nsdoc\n");
1747 return E_UNEXPECTED;
1751 nsAString_InitDepend(&ns_text, text);
1752 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1753 nsAString_Finish(&ns_text);
1755 if(NS_FAILED(nsres) || !nsnode)
1757 ERR("CreateTextNode failed: %08x\n", nsres);
1758 return E_FAIL;
1761 hr = insert_adjacent_node(This, where, nsnode, NULL);
1762 nsIDOMNode_Release(nsnode);
1764 return hr;
1767 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1769 HTMLElement *This = impl_from_IHTMLElement(iface);
1770 FIXME("(%p)->(%p)\n", This, p);
1771 return E_NOTIMPL;
1774 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1776 HTMLElement *This = impl_from_IHTMLElement(iface);
1778 TRACE("(%p)->(%p)\n", This, p);
1780 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
1781 return S_OK;
1784 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1786 HTMLElement *This = impl_from_IHTMLElement(iface);
1787 nsresult nsres;
1789 TRACE("(%p)\n", This);
1791 if(!This->nselem) {
1792 FIXME("not implemented for comments\n");
1793 return E_NOTIMPL;
1796 nsres = nsIDOMHTMLElement_Click(This->nselem);
1797 if(NS_FAILED(nsres)) {
1798 ERR("Click failed: %08x\n", nsres);
1799 return E_FAIL;
1802 return S_OK;
1805 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1806 IHTMLFiltersCollection **p)
1808 HTMLElement *This = impl_from_IHTMLElement(iface);
1809 TRACE("(%p)->(%p)\n", This, p);
1811 if(!p)
1812 return E_POINTER;
1814 *p = HTMLFiltersCollection_Create();
1816 return S_OK;
1819 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1821 HTMLElement *This = impl_from_IHTMLElement(iface);
1823 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1825 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
1828 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1830 HTMLElement *This = impl_from_IHTMLElement(iface);
1832 TRACE("(%p)->(%p)\n", This, p);
1834 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
1837 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1839 HTMLElement *This = impl_from_IHTMLElement(iface);
1840 FIXME("(%p)->(%p)\n", This, String);
1841 return E_NOTIMPL;
1844 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1846 HTMLElement *This = impl_from_IHTMLElement(iface);
1847 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1848 return E_NOTIMPL;
1851 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1853 HTMLElement *This = impl_from_IHTMLElement(iface);
1854 FIXME("(%p)->(%p)\n", This, p);
1855 return E_NOTIMPL;
1858 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1860 HTMLElement *This = impl_from_IHTMLElement(iface);
1861 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1862 return E_NOTIMPL;
1865 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1867 HTMLElement *This = impl_from_IHTMLElement(iface);
1868 FIXME("(%p)->(%p)\n", This, p);
1869 return E_NOTIMPL;
1872 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1874 HTMLElement *This = impl_from_IHTMLElement(iface);
1875 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1876 return E_NOTIMPL;
1879 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1881 HTMLElement *This = impl_from_IHTMLElement(iface);
1882 FIXME("(%p)->(%p)\n", This, p);
1883 return E_NOTIMPL;
1886 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1888 HTMLElement *This = impl_from_IHTMLElement(iface);
1889 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1890 return E_NOTIMPL;
1893 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1895 HTMLElement *This = impl_from_IHTMLElement(iface);
1896 FIXME("(%p)->(%p)\n", This, p);
1897 return E_NOTIMPL;
1900 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1902 HTMLElement *This = impl_from_IHTMLElement(iface);
1903 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1904 return E_NOTIMPL;
1907 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1909 HTMLElement *This = impl_from_IHTMLElement(iface);
1910 FIXME("(%p)->(%p)\n", This, p);
1911 return E_NOTIMPL;
1914 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1916 HTMLElement *This = impl_from_IHTMLElement(iface);
1917 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1918 return E_NOTIMPL;
1921 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1923 HTMLElement *This = impl_from_IHTMLElement(iface);
1924 FIXME("(%p)->(%p)\n", This, p);
1925 return E_NOTIMPL;
1928 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1930 HTMLElement *This = impl_from_IHTMLElement(iface);
1932 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1934 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1937 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1939 HTMLElement *This = impl_from_IHTMLElement(iface);
1941 TRACE("(%p)->(%p)\n", This, p);
1943 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1946 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1948 HTMLElement *This = impl_from_IHTMLElement(iface);
1949 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1950 return E_NOTIMPL;
1953 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1955 HTMLElement *This = impl_from_IHTMLElement(iface);
1956 FIXME("(%p)->(%p)\n", This, p);
1957 return E_NOTIMPL;
1960 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1962 HTMLElement *This = impl_from_IHTMLElement(iface);
1963 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1964 return E_NOTIMPL;
1967 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1969 HTMLElement *This = impl_from_IHTMLElement(iface);
1970 FIXME("(%p)->(%p)\n", This, p);
1971 return E_NOTIMPL;
1974 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1976 HTMLElement *This = impl_from_IHTMLElement(iface);
1977 nsIDOMNodeList *nsnode_list;
1978 nsresult nsres;
1980 TRACE("(%p)->(%p)\n", This, p);
1982 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1983 if(NS_FAILED(nsres)) {
1984 ERR("GetChildNodes failed: %08x\n", nsres);
1985 return E_FAIL;
1988 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1990 nsIDOMNodeList_Release(nsnode_list);
1991 return S_OK;
1994 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1996 HTMLElement *This = impl_from_IHTMLElement(iface);
1998 TRACE("(%p)->(%p)\n", This, p);
2000 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2001 return S_OK;
2004 static const IHTMLElementVtbl HTMLElementVtbl = {
2005 HTMLElement_QueryInterface,
2006 HTMLElement_AddRef,
2007 HTMLElement_Release,
2008 HTMLElement_GetTypeInfoCount,
2009 HTMLElement_GetTypeInfo,
2010 HTMLElement_GetIDsOfNames,
2011 HTMLElement_Invoke,
2012 HTMLElement_setAttribute,
2013 HTMLElement_getAttribute,
2014 HTMLElement_removeAttribute,
2015 HTMLElement_put_className,
2016 HTMLElement_get_className,
2017 HTMLElement_put_id,
2018 HTMLElement_get_id,
2019 HTMLElement_get_tagName,
2020 HTMLElement_get_parentElement,
2021 HTMLElement_get_style,
2022 HTMLElement_put_onhelp,
2023 HTMLElement_get_onhelp,
2024 HTMLElement_put_onclick,
2025 HTMLElement_get_onclick,
2026 HTMLElement_put_ondblclick,
2027 HTMLElement_get_ondblclick,
2028 HTMLElement_put_onkeydown,
2029 HTMLElement_get_onkeydown,
2030 HTMLElement_put_onkeyup,
2031 HTMLElement_get_onkeyup,
2032 HTMLElement_put_onkeypress,
2033 HTMLElement_get_onkeypress,
2034 HTMLElement_put_onmouseout,
2035 HTMLElement_get_onmouseout,
2036 HTMLElement_put_onmouseover,
2037 HTMLElement_get_onmouseover,
2038 HTMLElement_put_onmousemove,
2039 HTMLElement_get_onmousemove,
2040 HTMLElement_put_onmousedown,
2041 HTMLElement_get_onmousedown,
2042 HTMLElement_put_onmouseup,
2043 HTMLElement_get_onmouseup,
2044 HTMLElement_get_document,
2045 HTMLElement_put_title,
2046 HTMLElement_get_title,
2047 HTMLElement_put_language,
2048 HTMLElement_get_language,
2049 HTMLElement_put_onselectstart,
2050 HTMLElement_get_onselectstart,
2051 HTMLElement_scrollIntoView,
2052 HTMLElement_contains,
2053 HTMLElement_get_sourceIndex,
2054 HTMLElement_get_recordNumber,
2055 HTMLElement_put_lang,
2056 HTMLElement_get_lang,
2057 HTMLElement_get_offsetLeft,
2058 HTMLElement_get_offsetTop,
2059 HTMLElement_get_offsetWidth,
2060 HTMLElement_get_offsetHeight,
2061 HTMLElement_get_offsetParent,
2062 HTMLElement_put_innerHTML,
2063 HTMLElement_get_innerHTML,
2064 HTMLElement_put_innerText,
2065 HTMLElement_get_innerText,
2066 HTMLElement_put_outerHTML,
2067 HTMLElement_get_outerHTML,
2068 HTMLElement_put_outerText,
2069 HTMLElement_get_outerText,
2070 HTMLElement_insertAdjacentHTML,
2071 HTMLElement_insertAdjacentText,
2072 HTMLElement_get_parentTextEdit,
2073 HTMLElement_get_isTextEdit,
2074 HTMLElement_click,
2075 HTMLElement_get_filters,
2076 HTMLElement_put_ondragstart,
2077 HTMLElement_get_ondragstart,
2078 HTMLElement_toString,
2079 HTMLElement_put_onbeforeupdate,
2080 HTMLElement_get_onbeforeupdate,
2081 HTMLElement_put_onafterupdate,
2082 HTMLElement_get_onafterupdate,
2083 HTMLElement_put_onerrorupdate,
2084 HTMLElement_get_onerrorupdate,
2085 HTMLElement_put_onrowexit,
2086 HTMLElement_get_onrowexit,
2087 HTMLElement_put_onrowenter,
2088 HTMLElement_get_onrowenter,
2089 HTMLElement_put_ondatasetchanged,
2090 HTMLElement_get_ondatasetchanged,
2091 HTMLElement_put_ondataavailable,
2092 HTMLElement_get_ondataavailable,
2093 HTMLElement_put_ondatasetcomplete,
2094 HTMLElement_get_ondatasetcomplete,
2095 HTMLElement_put_onfilterchange,
2096 HTMLElement_get_onfilterchange,
2097 HTMLElement_get_children,
2098 HTMLElement_get_all
2101 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2103 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2106 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2108 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2111 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2112 REFIID riid, void **ppv)
2114 HTMLElement *This = impl_from_IHTMLElement2(iface);
2115 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2118 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2120 HTMLElement *This = impl_from_IHTMLElement2(iface);
2121 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2124 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2126 HTMLElement *This = impl_from_IHTMLElement2(iface);
2127 return IHTMLElement_Release(&This->IHTMLElement_iface);
2130 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2132 HTMLElement *This = impl_from_IHTMLElement2(iface);
2133 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2136 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2137 LCID lcid, ITypeInfo **ppTInfo)
2139 HTMLElement *This = impl_from_IHTMLElement2(iface);
2140 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2143 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2144 LPOLESTR *rgszNames, UINT cNames,
2145 LCID lcid, DISPID *rgDispId)
2147 HTMLElement *This = impl_from_IHTMLElement2(iface);
2148 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2149 lcid, rgDispId);
2152 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2153 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2154 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2156 HTMLElement *This = impl_from_IHTMLElement2(iface);
2157 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2158 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2161 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2163 HTMLElement *This = impl_from_IHTMLElement2(iface);
2164 FIXME("(%p)->(%p)\n", This, p);
2165 return E_NOTIMPL;
2168 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2170 HTMLElement *This = impl_from_IHTMLElement2(iface);
2171 FIXME("(%p)->(%x)\n", This, containerCapture);
2172 return E_NOTIMPL;
2175 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2177 HTMLElement *This = impl_from_IHTMLElement2(iface);
2178 FIXME("(%p)\n", This);
2179 return E_NOTIMPL;
2182 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2184 HTMLElement *This = impl_from_IHTMLElement2(iface);
2185 FIXME("(%p)->()\n", This);
2186 return E_NOTIMPL;
2189 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2191 HTMLElement *This = impl_from_IHTMLElement2(iface);
2192 FIXME("(%p)->(%p)\n", This, p);
2193 return E_NOTIMPL;
2196 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2197 LONG x, LONG y, BSTR *component)
2199 HTMLElement *This = impl_from_IHTMLElement2(iface);
2200 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2201 return E_NOTIMPL;
2204 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2206 HTMLElement *This = impl_from_IHTMLElement2(iface);
2208 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2210 if(!This->node.doc->content_ready
2211 || !This->node.doc->basedoc.doc_obj->in_place_active)
2212 return E_PENDING;
2214 WARN("stub\n");
2215 return S_OK;
2218 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2220 HTMLElement *This = impl_from_IHTMLElement2(iface);
2222 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2224 return set_node_event(&This->node, EVENTID_SCROLL, &v);
2227 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2229 HTMLElement *This = impl_from_IHTMLElement2(iface);
2231 TRACE("(%p)->(%p)\n", This, p);
2233 return get_node_event(&This->node, EVENTID_SCROLL, p);
2236 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2238 HTMLElement *This = impl_from_IHTMLElement2(iface);
2240 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2242 return set_node_event(&This->node, EVENTID_DRAG, &v);
2245 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2247 HTMLElement *This = impl_from_IHTMLElement2(iface);
2249 TRACE("(%p)->(%p)\n", This, p);
2251 return get_node_event(&This->node, EVENTID_DRAG, p);
2254 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2256 HTMLElement *This = impl_from_IHTMLElement2(iface);
2257 FIXME("(%p)->()\n", This);
2258 return E_NOTIMPL;
2261 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2263 HTMLElement *This = impl_from_IHTMLElement2(iface);
2264 FIXME("(%p)->(%p)\n", This, p);
2265 return E_NOTIMPL;
2268 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2270 HTMLElement *This = impl_from_IHTMLElement2(iface);
2271 FIXME("(%p)->()\n", This);
2272 return E_NOTIMPL;
2275 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2277 HTMLElement *This = impl_from_IHTMLElement2(iface);
2278 FIXME("(%p)->(%p)\n", This, p);
2279 return E_NOTIMPL;
2282 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2284 HTMLElement *This = impl_from_IHTMLElement2(iface);
2285 FIXME("(%p)->()\n", This);
2286 return E_NOTIMPL;
2289 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2291 HTMLElement *This = impl_from_IHTMLElement2(iface);
2292 FIXME("(%p)->(%p)\n", This, p);
2293 return E_NOTIMPL;
2296 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2298 HTMLElement *This = impl_from_IHTMLElement2(iface);
2299 FIXME("(%p)->()\n", This);
2300 return E_NOTIMPL;
2303 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2305 HTMLElement *This = impl_from_IHTMLElement2(iface);
2306 FIXME("(%p)->(%p)\n", This, p);
2307 return E_NOTIMPL;
2310 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2312 HTMLElement *This = impl_from_IHTMLElement2(iface);
2313 FIXME("(%p)->()\n", This);
2314 return E_NOTIMPL;
2317 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2319 HTMLElement *This = impl_from_IHTMLElement2(iface);
2320 FIXME("(%p)->(%p)\n", This, p);
2321 return E_NOTIMPL;
2324 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2326 HTMLElement *This = impl_from_IHTMLElement2(iface);
2327 FIXME("(%p)->()\n", This);
2328 return E_NOTIMPL;
2331 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2333 HTMLElement *This = impl_from_IHTMLElement2(iface);
2334 FIXME("(%p)->(%p)\n", This, p);
2335 return E_NOTIMPL;
2338 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2340 HTMLElement *This = impl_from_IHTMLElement2(iface);
2341 FIXME("(%p)->()\n", This);
2342 return E_NOTIMPL;
2345 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2347 HTMLElement *This = impl_from_IHTMLElement2(iface);
2348 FIXME("(%p)->(%p)\n", This, p);
2349 return E_NOTIMPL;
2352 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2354 HTMLElement *This = impl_from_IHTMLElement2(iface);
2355 FIXME("(%p)->()\n", This);
2356 return E_NOTIMPL;
2359 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2361 HTMLElement *This = impl_from_IHTMLElement2(iface);
2362 FIXME("(%p)->(%p)\n", This, p);
2363 return E_NOTIMPL;
2366 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2368 HTMLElement *This = impl_from_IHTMLElement2(iface);
2369 FIXME("(%p)->()\n", This);
2370 return E_NOTIMPL;
2373 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2375 HTMLElement *This = impl_from_IHTMLElement2(iface);
2376 FIXME("(%p)->(%p)\n", This, p);
2377 return E_NOTIMPL;
2380 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2382 HTMLElement *This = impl_from_IHTMLElement2(iface);
2383 FIXME("(%p)->()\n", This);
2384 return E_NOTIMPL;
2387 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2389 HTMLElement *This = impl_from_IHTMLElement2(iface);
2390 FIXME("(%p)->(%p)\n", This, p);
2391 return E_NOTIMPL;
2394 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2396 HTMLElement *This = impl_from_IHTMLElement2(iface);
2398 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2400 return set_node_event(&This->node, EVENTID_PASTE, &v);
2403 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2405 HTMLElement *This = impl_from_IHTMLElement2(iface);
2407 TRACE("(%p)->(%p)\n", This, p);
2409 return get_node_event(&This->node, EVENTID_PASTE, p);
2412 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2414 HTMLElement *This = impl_from_IHTMLElement2(iface);
2416 TRACE("(%p)->(%p)\n", This, p);
2418 return HTMLCurrentStyle_Create(This, p);
2421 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2423 HTMLElement *This = impl_from_IHTMLElement2(iface);
2424 FIXME("(%p)->()\n", This);
2425 return E_NOTIMPL;
2428 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2430 HTMLElement *This = impl_from_IHTMLElement2(iface);
2431 FIXME("(%p)->(%p)\n", This, p);
2432 return E_NOTIMPL;
2435 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2437 HTMLElement *This = impl_from_IHTMLElement2(iface);
2438 FIXME("(%p)->(%p)\n", This, pRectCol);
2439 return E_NOTIMPL;
2442 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2444 HTMLElement *This = impl_from_IHTMLElement2(iface);
2445 nsIDOMClientRect *nsrect;
2446 nsresult nsres;
2447 HRESULT hres;
2449 TRACE("(%p)->(%p)\n", This, pRect);
2451 nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
2452 if(NS_FAILED(nsres) || !nsrect) {
2453 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2454 return E_FAIL;
2457 hres = create_html_rect(nsrect, pRect);
2459 nsIDOMClientRect_Release(nsrect);
2460 return hres;
2463 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2464 BSTR expression, BSTR language)
2466 HTMLElement *This = impl_from_IHTMLElement2(iface);
2467 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2468 debugstr_w(language));
2469 return E_NOTIMPL;
2472 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2473 VARIANT *expression)
2475 HTMLElement *This = impl_from_IHTMLElement2(iface);
2476 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2477 return E_NOTIMPL;
2480 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2481 VARIANT_BOOL *pfSuccess)
2483 HTMLElement *This = impl_from_IHTMLElement2(iface);
2484 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2485 return E_NOTIMPL;
2488 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2490 HTMLElement *This = impl_from_IHTMLElement2(iface);
2491 nsresult nsres;
2493 TRACE("(%p)->(%d)\n", This, v);
2495 nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
2496 if(NS_FAILED(nsres))
2497 ERR("GetTabIndex failed: %08x\n", nsres);
2499 return S_OK;
2502 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2504 HTMLElement *This = impl_from_IHTMLElement2(iface);
2505 LONG index;
2506 nsresult nsres;
2508 TRACE("(%p)->(%p)\n", This, p);
2510 nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
2511 if(NS_FAILED(nsres)) {
2512 ERR("GetTabIndex failed: %08x\n", nsres);
2513 return E_FAIL;
2516 *p = index;
2517 return S_OK;
2520 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2522 HTMLElement *This = impl_from_IHTMLElement2(iface);
2523 nsresult nsres;
2525 TRACE("(%p)\n", This);
2527 nsres = nsIDOMHTMLElement_Focus(This->nselem);
2528 if(NS_FAILED(nsres))
2529 ERR("Focus failed: %08x\n", nsres);
2531 return S_OK;
2534 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2536 HTMLElement *This = impl_from_IHTMLElement2(iface);
2537 VARIANT var;
2539 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2541 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2543 V_VT(&var) = VT_BSTR;
2544 V_BSTR(&var) = v;
2545 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2548 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2550 HTMLElement *This = impl_from_IHTMLElement2(iface);
2551 FIXME("(%p)->(%p)\n", This, p);
2552 return E_NOTIMPL;
2555 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2557 HTMLElement *This = impl_from_IHTMLElement2(iface);
2559 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2561 return set_node_event(&This->node, EVENTID_BLUR, &v);
2564 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2566 HTMLElement *This = impl_from_IHTMLElement2(iface);
2568 TRACE("(%p)->(%p)\n", This, p);
2570 return get_node_event(&This->node, EVENTID_BLUR, p);
2573 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2575 HTMLElement *This = impl_from_IHTMLElement2(iface);
2577 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2579 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2582 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2584 HTMLElement *This = impl_from_IHTMLElement2(iface);
2586 TRACE("(%p)->(%p)\n", This, p);
2588 return get_node_event(&This->node, EVENTID_FOCUS, p);
2591 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2593 HTMLElement *This = impl_from_IHTMLElement2(iface);
2595 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2597 return set_node_event(&This->node, EVENTID_RESIZE, &v);
2600 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2602 HTMLElement *This = impl_from_IHTMLElement2(iface);
2604 TRACE("(%p)->(%p)\n", This, p);
2606 return get_node_event(&This->node, EVENTID_RESIZE, p);
2609 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2611 HTMLElement *This = impl_from_IHTMLElement2(iface);
2612 nsresult nsres;
2614 TRACE("(%p)\n", This);
2616 nsres = nsIDOMHTMLElement_Blur(This->nselem);
2617 if(NS_FAILED(nsres)) {
2618 ERR("Blur failed: %08x\n", nsres);
2619 return E_FAIL;
2622 return S_OK;
2625 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2627 HTMLElement *This = impl_from_IHTMLElement2(iface);
2628 FIXME("(%p)->(%p)\n", This, pUnk);
2629 return E_NOTIMPL;
2632 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2634 HTMLElement *This = impl_from_IHTMLElement2(iface);
2635 FIXME("(%p)->(%p)\n", This, pUnk);
2636 return E_NOTIMPL;
2639 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2641 HTMLElement *This = impl_from_IHTMLElement2(iface);
2642 nsresult nsres;
2644 TRACE("(%p)->(%p)\n", This, p);
2646 nsres = nsIDOMHTMLElement_GetClientHeight(This->nselem, p);
2647 assert(nsres == NS_OK);
2648 return S_OK;
2651 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2653 HTMLElement *This = impl_from_IHTMLElement2(iface);
2654 nsresult nsres;
2656 TRACE("(%p)->(%p)\n", This, p);
2658 nsres = nsIDOMHTMLElement_GetClientWidth(This->nselem, p);
2659 assert(nsres == NS_OK);
2660 return S_OK;
2663 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2665 HTMLElement *This = impl_from_IHTMLElement2(iface);
2666 nsresult nsres;
2668 TRACE("(%p)->(%p)\n", This, p);
2670 nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, p);
2671 assert(nsres == NS_OK);
2673 TRACE("*p = %d\n", *p);
2674 return S_OK;
2677 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2679 HTMLElement *This = impl_from_IHTMLElement2(iface);
2680 nsresult nsres;
2682 TRACE("(%p)->(%p)\n", This, p);
2684 nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, p);
2685 assert(nsres == NS_OK);
2687 TRACE("*p = %d\n", *p);
2688 return S_OK;
2691 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2692 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2694 HTMLElement *This = impl_from_IHTMLElement2(iface);
2696 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2698 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2701 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2703 HTMLElement *This = impl_from_IHTMLElement2(iface);
2705 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2707 return detach_event(&This->node.event_target, event, pDisp);
2710 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2712 HTMLElement *This = impl_from_IHTMLElement2(iface);
2713 BSTR str;
2715 TRACE("(%p)->(%p)\n", This, p);
2717 if(This->node.vtbl->get_readystate) {
2718 HRESULT hres;
2720 hres = This->node.vtbl->get_readystate(&This->node, &str);
2721 if(FAILED(hres))
2722 return hres;
2723 }else {
2724 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2726 str = SysAllocString(completeW);
2727 if(!str)
2728 return E_OUTOFMEMORY;
2731 V_VT(p) = VT_BSTR;
2732 V_BSTR(p) = str;
2733 return S_OK;
2736 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2738 HTMLElement *This = impl_from_IHTMLElement2(iface);
2740 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2742 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2745 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2747 HTMLElement *This = impl_from_IHTMLElement2(iface);
2749 TRACE("(%p)->(%p)\n", This, p);
2751 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2754 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2756 HTMLElement *This = impl_from_IHTMLElement2(iface);
2757 FIXME("(%p)->()\n", This);
2758 return E_NOTIMPL;
2761 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2763 HTMLElement *This = impl_from_IHTMLElement2(iface);
2764 FIXME("(%p)->(%p)\n", This, p);
2765 return E_NOTIMPL;
2768 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2770 HTMLElement *This = impl_from_IHTMLElement2(iface);
2771 FIXME("(%p)->()\n", This);
2772 return E_NOTIMPL;
2775 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2777 HTMLElement *This = impl_from_IHTMLElement2(iface);
2778 FIXME("(%p)->(%p)\n", This, p);
2779 return E_NOTIMPL;
2782 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2784 HTMLElement *This = impl_from_IHTMLElement2(iface);
2785 FIXME("(%p)->()\n", This);
2786 return E_NOTIMPL;
2789 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2791 HTMLElement *This = impl_from_IHTMLElement2(iface);
2792 FIXME("(%p)->(%p)\n", This, p);
2793 return E_NOTIMPL;
2796 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2798 HTMLElement *This = impl_from_IHTMLElement2(iface);
2799 nsAString nsstr;
2800 nsresult nsres;
2802 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2804 if(!This->nselem) {
2805 FIXME("Unsupported for comment nodes.\n");
2806 return S_OK;
2809 nsAString_InitDepend(&nsstr, v);
2810 nsres = nsIDOMHTMLElement_SetDir(This->nselem, &nsstr);
2811 nsAString_Finish(&nsstr);
2812 if(NS_FAILED(nsres)) {
2813 ERR("SetDir failed: %08x\n", nsres);
2814 return E_FAIL;
2817 return S_OK;
2820 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2822 HTMLElement *This = impl_from_IHTMLElement2(iface);
2823 nsAString dir_str;
2824 nsresult nsres;
2826 TRACE("(%p)->(%p)\n", This, p);
2828 if(!This->nselem) {
2829 *p = NULL;
2830 return S_OK;
2833 nsAString_Init(&dir_str, NULL);
2834 nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
2835 return return_nsstr(nsres, &dir_str, p);
2838 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2840 HTMLElement *This = impl_from_IHTMLElement2(iface);
2841 FIXME("(%p)->(%p)\n", This, range);
2842 return E_NOTIMPL;
2845 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2847 HTMLElement *This = impl_from_IHTMLElement2(iface);
2848 nsresult nsres;
2850 TRACE("(%p)->(%p)\n", This, p);
2852 nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, p);
2853 assert(nsres == NS_OK);
2855 TRACE("*p = %d\n", *p);
2856 return S_OK;
2859 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2861 HTMLElement *This = impl_from_IHTMLElement2(iface);
2862 nsresult nsres;
2864 TRACE("(%p)->(%p)\n", This, p);
2866 nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, p);
2867 assert(nsres == NS_OK);
2869 TRACE("*p = %d\n", *p);
2870 return S_OK;
2873 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2875 HTMLElement *This = impl_from_IHTMLElement2(iface);
2877 TRACE("(%p)->(%d)\n", This, v);
2879 if(!This->nselem) {
2880 FIXME("NULL nselem\n");
2881 return E_NOTIMPL;
2884 nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
2885 return S_OK;
2888 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2890 HTMLElement *This = impl_from_IHTMLElement2(iface);
2891 nsresult nsres;
2893 TRACE("(%p)->(%p)\n", This, p);
2895 nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, p);
2896 assert(nsres == NS_OK);
2898 TRACE("*p = %d\n", *p);
2899 return S_OK;
2902 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2904 HTMLElement *This = impl_from_IHTMLElement2(iface);
2906 TRACE("(%p)->(%d)\n", This, v);
2908 if(!This->nselem) {
2909 FIXME("NULL nselem\n");
2910 return E_NOTIMPL;
2913 nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
2914 return S_OK;
2917 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2919 HTMLElement *This = impl_from_IHTMLElement2(iface);
2920 nsresult nsres;
2922 TRACE("(%p)->(%p)\n", This, p);
2924 if(!p)
2925 return E_INVALIDARG;
2927 if(!This->nselem)
2929 FIXME("NULL nselem\n");
2930 return E_NOTIMPL;
2933 nsres = nsIDOMHTMLElement_GetScrollLeft(This->nselem, p);
2934 assert(nsres == NS_OK);
2936 TRACE("*p = %d\n", *p);
2937 return S_OK;
2940 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
2942 HTMLElement *This = impl_from_IHTMLElement2(iface);
2943 FIXME("(%p)\n", This);
2944 return E_NOTIMPL;
2947 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
2949 HTMLElement *This = impl_from_IHTMLElement2(iface);
2950 FIXME("(%p)->(%p)\n", This, mergeThis);
2951 return E_NOTIMPL;
2954 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
2956 HTMLElement *This = impl_from_IHTMLElement2(iface);
2958 TRACE("(%p)->()\n", This);
2960 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
2963 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
2965 HTMLElement *This = impl_from_IHTMLElement2(iface);
2967 TRACE("(%p)->(%p)\n", This, p);
2969 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
2972 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
2973 IHTMLElement *insertedElement, IHTMLElement **inserted)
2975 HTMLElement *This = impl_from_IHTMLElement2(iface);
2976 HTMLDOMNode *ret_node;
2977 HTMLElement *elem;
2978 HRESULT hres;
2980 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
2982 elem = unsafe_impl_from_IHTMLElement(insertedElement);
2983 if(!elem)
2984 return E_INVALIDARG;
2986 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
2987 if(FAILED(hres))
2988 return hres;
2990 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
2991 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
2992 return hres;
2995 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
2996 BSTR where, IHTMLElement **applied)
2998 HTMLElement *This = impl_from_IHTMLElement2(iface);
2999 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3000 return E_NOTIMPL;
3003 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3005 HTMLElement *This = impl_from_IHTMLElement2(iface);
3006 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3007 return E_NOTIMPL;
3010 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3011 BSTR newText, BSTR *oldText)
3013 HTMLElement *This = impl_from_IHTMLElement2(iface);
3014 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3015 return E_NOTIMPL;
3018 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3020 HTMLElement *This = impl_from_IHTMLElement2(iface);
3021 FIXME("(%p)->(%p)\n", This, p);
3022 return E_NOTIMPL;
3025 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3026 VARIANT *pvarFactory, LONG *pCookie)
3028 HTMLElement *This = impl_from_IHTMLElement2(iface);
3029 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3030 return E_NOTIMPL;
3033 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3034 VARIANT_BOOL *pfResult)
3036 HTMLElement *This = impl_from_IHTMLElement2(iface);
3037 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
3038 return E_NOTIMPL;
3041 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3043 HTMLElement *This = impl_from_IHTMLElement2(iface);
3045 FIXME("(%p)->(%p): hack\n", This, p);
3047 /* We can't implement correct behavior on top of Gecko (although we could
3048 try a bit harder). Making runtimeStyle behave like regular style is
3049 enough for most use cases. */
3050 if(!This->runtime_style) {
3051 HRESULT hres;
3053 hres = HTMLStyle_Create(This, &This->runtime_style);
3054 if(FAILED(hres))
3055 return hres;
3058 *p = &This->runtime_style->IHTMLStyle_iface;
3059 IHTMLStyle_AddRef(*p);
3060 return S_OK;
3063 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
3065 HTMLElement *This = impl_from_IHTMLElement2(iface);
3066 FIXME("(%p)->(%p)\n", This, p);
3067 return E_NOTIMPL;
3070 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
3072 HTMLElement *This = impl_from_IHTMLElement2(iface);
3073 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3074 return E_NOTIMPL;
3077 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
3079 HTMLElement *This = impl_from_IHTMLElement2(iface);
3080 FIXME("(%p)->(%p)\n", This, p);
3081 return E_NOTIMPL;
3084 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
3086 HTMLElement *This = impl_from_IHTMLElement2(iface);
3087 FIXME("(%p)->()\n", This);
3088 return E_NOTIMPL;
3091 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3093 HTMLElement *This = impl_from_IHTMLElement2(iface);
3094 FIXME("(%p)->(%p)\n", This, p);
3095 return E_NOTIMPL;
3098 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3100 HTMLElement *This = impl_from_IHTMLElement2(iface);
3101 FIXME("(%p)->(%p)\n", This, p);
3102 return E_NOTIMPL;
3105 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3106 IHTMLElementCollection **pelColl)
3108 HTMLElement *This = impl_from_IHTMLElement2(iface);
3109 nsIDOMHTMLCollection *nscol;
3110 nsAString tag_str;
3111 nsresult nsres;
3113 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3115 if(!This->nselem) {
3116 *pelColl = create_collection_from_htmlcol(This->node.doc, NULL);
3117 return S_OK;
3120 nsAString_InitDepend(&tag_str, v);
3121 nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nscol);
3122 nsAString_Finish(&tag_str);
3123 if(NS_FAILED(nsres)) {
3124 ERR("GetElementByTagName failed: %08x\n", nsres);
3125 return E_FAIL;
3128 *pelColl = create_collection_from_htmlcol(This->node.doc, nscol);
3129 nsIDOMHTMLCollection_Release(nscol);
3130 return S_OK;
3133 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3134 HTMLElement2_QueryInterface,
3135 HTMLElement2_AddRef,
3136 HTMLElement2_Release,
3137 HTMLElement2_GetTypeInfoCount,
3138 HTMLElement2_GetTypeInfo,
3139 HTMLElement2_GetIDsOfNames,
3140 HTMLElement2_Invoke,
3141 HTMLElement2_get_scopeName,
3142 HTMLElement2_setCapture,
3143 HTMLElement2_releaseCapture,
3144 HTMLElement2_put_onlosecapture,
3145 HTMLElement2_get_onlosecapture,
3146 HTMLElement2_componentFromPoint,
3147 HTMLElement2_doScroll,
3148 HTMLElement2_put_onscroll,
3149 HTMLElement2_get_onscroll,
3150 HTMLElement2_put_ondrag,
3151 HTMLElement2_get_ondrag,
3152 HTMLElement2_put_ondragend,
3153 HTMLElement2_get_ondragend,
3154 HTMLElement2_put_ondragenter,
3155 HTMLElement2_get_ondragenter,
3156 HTMLElement2_put_ondragover,
3157 HTMLElement2_get_ondragover,
3158 HTMLElement2_put_ondragleave,
3159 HTMLElement2_get_ondragleave,
3160 HTMLElement2_put_ondrop,
3161 HTMLElement2_get_ondrop,
3162 HTMLElement2_put_onbeforecut,
3163 HTMLElement2_get_onbeforecut,
3164 HTMLElement2_put_oncut,
3165 HTMLElement2_get_oncut,
3166 HTMLElement2_put_onbeforecopy,
3167 HTMLElement2_get_onbeforecopy,
3168 HTMLElement2_put_oncopy,
3169 HTMLElement2_get_oncopy,
3170 HTMLElement2_put_onbeforepaste,
3171 HTMLElement2_get_onbeforepaste,
3172 HTMLElement2_put_onpaste,
3173 HTMLElement2_get_onpaste,
3174 HTMLElement2_get_currentStyle,
3175 HTMLElement2_put_onpropertychange,
3176 HTMLElement2_get_onpropertychange,
3177 HTMLElement2_getClientRects,
3178 HTMLElement2_getBoundingClientRect,
3179 HTMLElement2_setExpression,
3180 HTMLElement2_getExpression,
3181 HTMLElement2_removeExpression,
3182 HTMLElement2_put_tabIndex,
3183 HTMLElement2_get_tabIndex,
3184 HTMLElement2_focus,
3185 HTMLElement2_put_accessKey,
3186 HTMLElement2_get_accessKey,
3187 HTMLElement2_put_onblur,
3188 HTMLElement2_get_onblur,
3189 HTMLElement2_put_onfocus,
3190 HTMLElement2_get_onfocus,
3191 HTMLElement2_put_onresize,
3192 HTMLElement2_get_onresize,
3193 HTMLElement2_blur,
3194 HTMLElement2_addFilter,
3195 HTMLElement2_removeFilter,
3196 HTMLElement2_get_clientHeight,
3197 HTMLElement2_get_clientWidth,
3198 HTMLElement2_get_clientTop,
3199 HTMLElement2_get_clientLeft,
3200 HTMLElement2_attachEvent,
3201 HTMLElement2_detachEvent,
3202 HTMLElement2_get_readyState,
3203 HTMLElement2_put_onreadystatechange,
3204 HTMLElement2_get_onreadystatechange,
3205 HTMLElement2_put_onrowsdelete,
3206 HTMLElement2_get_onrowsdelete,
3207 HTMLElement2_put_onrowsinserted,
3208 HTMLElement2_get_onrowsinserted,
3209 HTMLElement2_put_oncellchange,
3210 HTMLElement2_get_oncellchange,
3211 HTMLElement2_put_dir,
3212 HTMLElement2_get_dir,
3213 HTMLElement2_createControlRange,
3214 HTMLElement2_get_scrollHeight,
3215 HTMLElement2_get_scrollWidth,
3216 HTMLElement2_put_scrollTop,
3217 HTMLElement2_get_scrollTop,
3218 HTMLElement2_put_scrollLeft,
3219 HTMLElement2_get_scrollLeft,
3220 HTMLElement2_clearAttributes,
3221 HTMLElement2_mergeAttributes,
3222 HTMLElement2_put_oncontextmenu,
3223 HTMLElement2_get_oncontextmenu,
3224 HTMLElement2_insertAdjacentElement,
3225 HTMLElement2_applyElement,
3226 HTMLElement2_getAdjacentText,
3227 HTMLElement2_replaceAdjacentText,
3228 HTMLElement2_get_canHandleChildren,
3229 HTMLElement2_addBehavior,
3230 HTMLElement2_removeBehavior,
3231 HTMLElement2_get_runtimeStyle,
3232 HTMLElement2_get_behaviorUrns,
3233 HTMLElement2_put_tagUrn,
3234 HTMLElement2_get_tagUrn,
3235 HTMLElement2_put_onbeforeeditfocus,
3236 HTMLElement2_get_onbeforeeditfocus,
3237 HTMLElement2_get_readyStateValue,
3238 HTMLElement2_getElementsByTagName,
3241 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3243 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3246 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3247 REFIID riid, void **ppv)
3249 HTMLElement *This = impl_from_IHTMLElement3(iface);
3250 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3253 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3255 HTMLElement *This = impl_from_IHTMLElement3(iface);
3256 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3259 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3261 HTMLElement *This = impl_from_IHTMLElement3(iface);
3262 return IHTMLElement_Release(&This->IHTMLElement_iface);
3265 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3267 HTMLElement *This = impl_from_IHTMLElement3(iface);
3268 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3271 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3272 LCID lcid, ITypeInfo **ppTInfo)
3274 HTMLElement *This = impl_from_IHTMLElement3(iface);
3275 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3278 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3279 LPOLESTR *rgszNames, UINT cNames,
3280 LCID lcid, DISPID *rgDispId)
3282 HTMLElement *This = impl_from_IHTMLElement3(iface);
3283 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3284 lcid, rgDispId);
3287 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3288 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3289 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3291 HTMLElement *This = impl_from_IHTMLElement3(iface);
3292 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3293 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3296 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3298 HTMLElement *This = impl_from_IHTMLElement3(iface);
3299 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3300 return E_NOTIMPL;
3303 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3305 HTMLElement *This = impl_from_IHTMLElement3(iface);
3306 FIXME("(%p)->(%p)\n", This, p);
3307 return E_NOTIMPL;
3310 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3312 HTMLElement *This = impl_from_IHTMLElement3(iface);
3313 FIXME("(%p)->(%p)\n", This, p);
3314 return E_NOTIMPL;
3317 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3319 HTMLElement *This = impl_from_IHTMLElement3(iface);
3320 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3321 return E_NOTIMPL;
3324 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3326 HTMLElement *This = impl_from_IHTMLElement3(iface);
3327 FIXME("(%p)->(%p)\n", This, p);
3328 return E_NOTIMPL;
3331 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3333 HTMLElement *This = impl_from_IHTMLElement3(iface);
3334 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3335 return E_NOTIMPL;
3338 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3340 HTMLElement *This = impl_from_IHTMLElement3(iface);
3341 FIXME("(%p)->(%p)\n", This, p);
3342 return E_NOTIMPL;
3345 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3347 HTMLElement *This = impl_from_IHTMLElement3(iface);
3348 FIXME("(%p)->(%x)\n", This, v);
3349 return E_NOTIMPL;
3352 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3354 HTMLElement *This = impl_from_IHTMLElement3(iface);
3355 FIXME("(%p)->(%p)\n", This, p);
3356 return E_NOTIMPL;
3359 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3361 HTMLElement *This = impl_from_IHTMLElement3(iface);
3362 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3363 return E_NOTIMPL;
3366 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3368 HTMLElement *This = impl_from_IHTMLElement3(iface);
3369 FIXME("(%p)->(%p)\n", This, p);
3370 return E_NOTIMPL;
3373 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3375 HTMLElement *This = impl_from_IHTMLElement3(iface);
3376 FIXME("(%p)\n", This);
3377 return E_NOTIMPL;
3380 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3382 HTMLElement *This = impl_from_IHTMLElement3(iface);
3383 nsresult nsres;
3384 nsAString str;
3386 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3388 nsAString_InitDepend(&str, v);
3389 nsres = nsIDOMHTMLElement_SetContentEditable(This->nselem, &str);
3390 nsAString_Finish(&str);
3392 if (NS_FAILED(nsres)){
3393 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3394 return E_FAIL;
3397 return S_OK;
3400 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3402 HTMLElement *This = impl_from_IHTMLElement3(iface);
3403 nsresult nsres;
3404 nsAString str;
3406 TRACE("(%p)->(%p)\n", This, p);
3408 nsAString_Init(&str, NULL);
3409 nsres = nsIDOMHTMLElement_GetContentEditable(This->nselem, &str);
3410 return return_nsstr(nsres, &str, p);
3413 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3415 HTMLElement *This = impl_from_IHTMLElement3(iface);
3416 FIXME("(%p)->(%p)\n", This, p);
3417 return E_NOTIMPL;
3420 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3422 HTMLElement *This = impl_from_IHTMLElement3(iface);
3423 FIXME("(%p)->(%x)\n", This, v);
3424 return E_NOTIMPL;
3427 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3429 HTMLElement *This = impl_from_IHTMLElement3(iface);
3430 FIXME("(%p)->(%p)\n", This, p);
3431 return E_NOTIMPL;
3434 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3436 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3438 HTMLElement *This = impl_from_IHTMLElement3(iface);
3439 VARIANT *var;
3440 HRESULT hres;
3442 TRACE("(%p)->(%x)\n", This, v);
3444 if(This->node.vtbl->put_disabled)
3445 return This->node.vtbl->put_disabled(&This->node, v);
3447 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3448 if(FAILED(hres))
3449 return hres;
3451 VariantClear(var);
3452 V_VT(var) = VT_BOOL;
3453 V_BOOL(var) = v;
3454 return S_OK;
3457 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3459 HTMLElement *This = impl_from_IHTMLElement3(iface);
3460 VARIANT *var;
3461 HRESULT hres;
3463 TRACE("(%p)->(%p)\n", This, p);
3465 if(This->node.vtbl->get_disabled)
3466 return This->node.vtbl->get_disabled(&This->node, p);
3468 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3469 if(hres == DISP_E_UNKNOWNNAME) {
3470 *p = VARIANT_FALSE;
3471 return S_OK;
3473 if(FAILED(hres))
3474 return hres;
3476 if(V_VT(var) != VT_BOOL) {
3477 FIXME("value is %s\n", debugstr_variant(var));
3478 return E_NOTIMPL;
3481 *p = V_BOOL(var);
3482 return S_OK;
3485 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3487 HTMLElement *This = impl_from_IHTMLElement3(iface);
3488 FIXME("(%p)->(%p)\n", This, p);
3489 return E_NOTIMPL;
3492 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3494 HTMLElement *This = impl_from_IHTMLElement3(iface);
3495 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3496 return E_NOTIMPL;
3499 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3501 HTMLElement *This = impl_from_IHTMLElement3(iface);
3502 FIXME("(%p)->(%p)\n", This, p);
3503 return E_NOTIMPL;
3506 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3508 HTMLElement *This = impl_from_IHTMLElement3(iface);
3509 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3510 return E_NOTIMPL;
3513 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3515 HTMLElement *This = impl_from_IHTMLElement3(iface);
3516 FIXME("(%p)->(%p)\n", This, p);
3517 return E_NOTIMPL;
3520 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3521 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3523 HTMLElement *This = impl_from_IHTMLElement3(iface);
3525 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3526 pfCancelled);
3528 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3531 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
3533 HTMLElement *This = impl_from_IHTMLElement3(iface);
3534 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3535 return E_NOTIMPL;
3538 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
3540 HTMLElement *This = impl_from_IHTMLElement3(iface);
3541 FIXME("(%p)->(%p)\n", This, p);
3542 return E_NOTIMPL;
3545 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3547 HTMLElement *This = impl_from_IHTMLElement3(iface);
3548 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3549 return E_NOTIMPL;
3552 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3554 HTMLElement *This = impl_from_IHTMLElement3(iface);
3555 FIXME("(%p)->(%p)\n", This, p);
3556 return E_NOTIMPL;
3559 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3561 HTMLElement *This = impl_from_IHTMLElement3(iface);
3562 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3563 return E_NOTIMPL;
3566 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3568 HTMLElement *This = impl_from_IHTMLElement3(iface);
3569 FIXME("(%p)->(%p)\n", This, p);
3570 return E_NOTIMPL;
3573 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3575 HTMLElement *This = impl_from_IHTMLElement3(iface);
3576 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3577 return E_NOTIMPL;
3580 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3582 HTMLElement *This = impl_from_IHTMLElement3(iface);
3583 FIXME("(%p)->(%p)\n", This, p);
3584 return E_NOTIMPL;
3587 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3589 HTMLElement *This = impl_from_IHTMLElement3(iface);
3590 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3591 return E_NOTIMPL;
3594 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3596 HTMLElement *This = impl_from_IHTMLElement3(iface);
3597 FIXME("(%p)->(%p)\n", This, p);
3598 return E_NOTIMPL;
3601 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3603 HTMLElement *This = impl_from_IHTMLElement3(iface);
3604 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3605 return E_NOTIMPL;
3608 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3610 HTMLElement *This = impl_from_IHTMLElement3(iface);
3611 FIXME("(%p)->(%p)\n", This, p);
3612 return E_NOTIMPL;
3615 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3617 HTMLElement *This = impl_from_IHTMLElement3(iface);
3618 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3619 return E_NOTIMPL;
3622 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3624 HTMLElement *This = impl_from_IHTMLElement3(iface);
3625 FIXME("(%p)->(%p)\n", This, p);
3626 return E_NOTIMPL;
3629 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3631 HTMLElement *This = impl_from_IHTMLElement3(iface);
3632 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3633 return E_NOTIMPL;
3636 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3638 HTMLElement *This = impl_from_IHTMLElement3(iface);
3639 FIXME("(%p)->(%p)\n", This, p);
3640 return E_NOTIMPL;
3643 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3645 HTMLElement *This = impl_from_IHTMLElement3(iface);
3646 FIXME("(%p)->(%p)\n", This, pfRet);
3647 return E_NOTIMPL;
3650 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3652 HTMLElement *This = impl_from_IHTMLElement3(iface);
3653 FIXME("(%p)->(%p)\n", This, p);
3654 return E_NOTIMPL;
3657 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3658 HTMLElement3_QueryInterface,
3659 HTMLElement3_AddRef,
3660 HTMLElement3_Release,
3661 HTMLElement3_GetTypeInfoCount,
3662 HTMLElement3_GetTypeInfo,
3663 HTMLElement3_GetIDsOfNames,
3664 HTMLElement3_Invoke,
3665 HTMLElement3_mergeAttributes,
3666 HTMLElement3_get_isMultiLine,
3667 HTMLElement3_get_canHaveHTML,
3668 HTMLElement3_put_onlayoutcomplete,
3669 HTMLElement3_get_onlayoutcomplete,
3670 HTMLElement3_put_onpage,
3671 HTMLElement3_get_onpage,
3672 HTMLElement3_put_inflateBlock,
3673 HTMLElement3_get_inflateBlock,
3674 HTMLElement3_put_onbeforedeactivate,
3675 HTMLElement3_get_onbeforedeactivate,
3676 HTMLElement3_setActive,
3677 HTMLElement3_put_contentEditable,
3678 HTMLElement3_get_contentEditable,
3679 HTMLElement3_get_isContentEditable,
3680 HTMLElement3_put_hideFocus,
3681 HTMLElement3_get_hideFocus,
3682 HTMLElement3_put_disabled,
3683 HTMLElement3_get_disabled,
3684 HTMLElement3_get_isDisabled,
3685 HTMLElement3_put_onmove,
3686 HTMLElement3_get_onmove,
3687 HTMLElement3_put_oncontrolselect,
3688 HTMLElement3_get_oncontrolselect,
3689 HTMLElement3_fireEvent,
3690 HTMLElement3_put_onresizestart,
3691 HTMLElement3_get_onresizestart,
3692 HTMLElement3_put_onresizeend,
3693 HTMLElement3_get_onresizeend,
3694 HTMLElement3_put_onmovestart,
3695 HTMLElement3_get_onmovestart,
3696 HTMLElement3_put_onmoveend,
3697 HTMLElement3_get_onmoveend,
3698 HTMLElement3_put_onmousecenter,
3699 HTMLElement3_get_onmousecenter,
3700 HTMLElement3_put_onmouseleave,
3701 HTMLElement3_get_onmouseleave,
3702 HTMLElement3_put_onactivate,
3703 HTMLElement3_get_onactivate,
3704 HTMLElement3_put_ondeactivate,
3705 HTMLElement3_get_ondeactivate,
3706 HTMLElement3_dragDrop,
3707 HTMLElement3_get_glyphMode
3710 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3712 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3715 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3716 REFIID riid, void **ppv)
3718 HTMLElement *This = impl_from_IHTMLElement4(iface);
3719 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3722 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3724 HTMLElement *This = impl_from_IHTMLElement4(iface);
3725 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3728 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3730 HTMLElement *This = impl_from_IHTMLElement4(iface);
3731 return IHTMLElement_Release(&This->IHTMLElement_iface);
3734 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3736 HTMLElement *This = impl_from_IHTMLElement4(iface);
3737 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3740 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3741 LCID lcid, ITypeInfo **ppTInfo)
3743 HTMLElement *This = impl_from_IHTMLElement4(iface);
3744 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3747 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3748 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3750 HTMLElement *This = impl_from_IHTMLElement4(iface);
3751 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3752 lcid, rgDispId);
3755 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3756 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3758 HTMLElement *This = impl_from_IHTMLElement4(iface);
3759 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3760 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3763 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3765 HTMLElement *This = impl_from_IHTMLElement4(iface);
3767 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3769 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3772 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3774 HTMLElement *This = impl_from_IHTMLElement4(iface);
3776 TRACE("(%p)->(%p)\n", This, p);
3778 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3781 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3783 HTMLElement *This = impl_from_IHTMLElement4(iface);
3784 FIXME("(%p)\n", This);
3785 return E_NOTIMPL;
3788 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3790 HTMLElement *This = impl_from_IHTMLElement4(iface);
3791 HTMLAttributeCollection *attrs;
3792 HRESULT hres;
3794 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3796 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3797 if(FAILED(hres))
3798 return hres;
3800 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3801 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3802 return hres;
3805 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3806 IHTMLDOMAttribute **ppretAttribute)
3808 HTMLElement *This = impl_from_IHTMLElement4(iface);
3809 HTMLDOMAttribute *attr, *iter, *replace = NULL;
3810 HTMLAttributeCollection *attrs;
3811 DISPID dispid;
3812 HRESULT hres;
3814 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3816 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
3817 if(!attr)
3818 return E_INVALIDARG;
3820 if(attr->elem) {
3821 WARN("Tried to set already attached attribute.\n");
3822 return E_INVALIDARG;
3825 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
3826 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
3827 if(FAILED(hres))
3828 return hres;
3830 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3831 if(FAILED(hres))
3832 return hres;
3834 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
3835 if(iter->dispid == dispid) {
3836 replace = iter;
3837 break;
3841 if(replace) {
3842 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
3843 if(FAILED(hres)) {
3844 WARN("could not get attr value: %08x\n", hres);
3845 V_VT(&replace->value) = VT_EMPTY;
3847 if(!replace->name) {
3848 replace->name = attr->name;
3849 attr->name = NULL;
3851 list_add_head(&replace->entry, &attr->entry);
3852 list_remove(&replace->entry);
3853 replace->elem = NULL;
3854 }else {
3855 list_add_tail(&attrs->attrs, &attr->entry);
3858 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
3859 attr->elem = This;
3860 attr->dispid = dispid;
3862 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3864 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
3865 if(FAILED(hres))
3866 WARN("Could not set attribute value: %08x\n", hres);
3867 VariantClear(&attr->value);
3869 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
3870 return S_OK;
3873 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3874 IHTMLDOMAttribute **ppretAttribute)
3876 HTMLElement *This = impl_from_IHTMLElement4(iface);
3877 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3878 return E_NOTIMPL;
3881 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3883 HTMLElement *This = impl_from_IHTMLElement4(iface);
3885 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3887 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
3890 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3892 HTMLElement *This = impl_from_IHTMLElement4(iface);
3894 TRACE("(%p)->(%p)\n", This, p);
3896 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
3899 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3901 HTMLElement *This = impl_from_IHTMLElement4(iface);
3903 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3905 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3908 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3910 HTMLElement *This = impl_from_IHTMLElement4(iface);
3912 TRACE("(%p)->(%p)\n", This, p);
3914 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3917 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3919 HTMLElement *This = impl_from_IHTMLElement4(iface);
3921 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3923 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
3926 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3928 HTMLElement *This = impl_from_IHTMLElement4(iface);
3930 TRACE("(%p)->(%p)\n", This, p);
3932 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
3935 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3936 HTMLElement4_QueryInterface,
3937 HTMLElement4_AddRef,
3938 HTMLElement4_Release,
3939 HTMLElement4_GetTypeInfoCount,
3940 HTMLElement4_GetTypeInfo,
3941 HTMLElement4_GetIDsOfNames,
3942 HTMLElement4_Invoke,
3943 HTMLElement4_put_onmousewheel,
3944 HTMLElement4_get_onmousewheel,
3945 HTMLElement4_normalize,
3946 HTMLElement4_getAttributeNode,
3947 HTMLElement4_setAttributeNode,
3948 HTMLElement4_removeAttributeNode,
3949 HTMLElement4_put_onbeforeactivate,
3950 HTMLElement4_get_onbeforeactivate,
3951 HTMLElement4_put_onfocusin,
3952 HTMLElement4_get_onfocusin,
3953 HTMLElement4_put_onfocusout,
3954 HTMLElement4_get_onfocusout
3957 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
3959 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
3962 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
3963 REFIID riid, void **ppv)
3965 HTMLElement *This = impl_from_IHTMLElement6(iface);
3966 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3969 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
3971 HTMLElement *This = impl_from_IHTMLElement6(iface);
3972 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3975 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
3977 HTMLElement *This = impl_from_IHTMLElement6(iface);
3978 return IHTMLElement_Release(&This->IHTMLElement_iface);
3981 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
3983 HTMLElement *This = impl_from_IHTMLElement6(iface);
3984 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3987 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
3988 LCID lcid, ITypeInfo **ppTInfo)
3990 HTMLElement *This = impl_from_IHTMLElement6(iface);
3991 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3994 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
3995 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3997 HTMLElement *This = impl_from_IHTMLElement6(iface);
3998 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3999 lcid, rgDispId);
4002 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
4003 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4005 HTMLElement *This = impl_from_IHTMLElement6(iface);
4006 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4007 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4010 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4012 HTMLElement *This = impl_from_IHTMLElement6(iface);
4013 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4014 return E_NOTIMPL;
4017 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4019 HTMLElement *This = impl_from_IHTMLElement6(iface);
4020 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4021 return E_NOTIMPL;
4024 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4026 HTMLElement *This = impl_from_IHTMLElement6(iface);
4027 FIXME("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4028 return E_NOTIMPL;
4031 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4033 HTMLElement *This = impl_from_IHTMLElement6(iface);
4034 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4035 return E_NOTIMPL;
4038 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4040 HTMLElement *This = impl_from_IHTMLElement6(iface);
4041 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4042 return E_NOTIMPL;
4045 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4047 HTMLElement *This = impl_from_IHTMLElement6(iface);
4048 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4049 return E_NOTIMPL;
4052 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4054 HTMLElement *This = impl_from_IHTMLElement6(iface);
4056 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
4058 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
4061 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4063 HTMLElement *This = impl_from_IHTMLElement6(iface);
4065 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4067 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
4070 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4072 HTMLElement *This = impl_from_IHTMLElement6(iface);
4073 VARIANT_BOOL success;
4075 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
4077 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
4080 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4082 HTMLElement *This = impl_from_IHTMLElement6(iface);
4083 IHTMLDOMAttribute *attr;
4084 HRESULT hres;
4086 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
4088 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
4089 if(FAILED(hres))
4090 return hres;
4092 if(attr) {
4093 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4094 IHTMLDOMAttribute_Release(attr);
4095 }else {
4096 *ppretAttribute = NULL;
4098 return hres;
4101 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4103 HTMLElement *This = impl_from_IHTMLElement6(iface);
4104 IHTMLDOMAttribute *attr, *ret_attr;
4105 HRESULT hres;
4107 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
4109 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
4110 if(FAILED(hres))
4111 return hres;
4113 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
4114 if(FAILED(hres))
4115 return hres;
4117 if(ret_attr) {
4118 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4119 IHTMLDOMAttribute_Release(ret_attr);
4120 }else {
4121 *ppretAttribute = NULL;
4123 return hres;
4126 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4128 HTMLElement *This = impl_from_IHTMLElement6(iface);
4129 FIXME("(%p)->()\n", This);
4130 return E_NOTIMPL;
4133 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *pfHasAttribute)
4135 HTMLElement *This = impl_from_IHTMLElement6(iface);
4136 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), pfHasAttribute);
4137 return E_NOTIMPL;
4140 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
4142 HTMLElement *This = impl_from_IHTMLElement6(iface);
4143 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
4144 return E_NOTIMPL;
4147 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
4149 HTMLElement *This = impl_from_IHTMLElement6(iface);
4151 TRACE("(%p)->(%p)\n", This, p);
4153 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
4156 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
4158 HTMLElement *This = impl_from_IHTMLElement6(iface);
4160 TRACE("(%p)->(%p)\n", This, p);
4162 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
4165 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
4167 HTMLElement *This = impl_from_IHTMLElement6(iface);
4168 nsIDOMHTMLCollection *nscol = NULL;
4169 nsAString nsstr;
4170 nsresult nsres;
4172 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4174 if(This->nselem) {
4175 nsAString_InitDepend(&nsstr, v);
4176 nsres = nsIDOMHTMLElement_GetElementsByClassName(This->nselem, &nsstr, &nscol);
4177 nsAString_Finish(&nsstr);
4178 if(NS_FAILED(nsres)) {
4179 ERR("GetElementsByClassName failed: %08x\n", nsres);
4180 return E_FAIL;
4184 *pel = create_collection_from_htmlcol(This->node.doc, nscol);
4185 nsIDOMHTMLCollection_Release(nscol);
4186 return S_OK;
4189 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
4191 HTMLElement *This = impl_from_IHTMLElement6(iface);
4192 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
4193 return E_NOTIMPL;
4196 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
4198 HTMLElement *This = impl_from_IHTMLElement6(iface);
4200 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4202 return set_node_event(&This->node, EVENTID_ABORT, &v);
4205 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
4207 HTMLElement *This = impl_from_IHTMLElement6(iface);
4209 TRACE("(%p)->(%p)\n", This, p);
4211 return get_node_event(&This->node, EVENTID_ABORT, p);
4214 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
4216 HTMLElement *This = impl_from_IHTMLElement6(iface);
4217 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4218 return E_NOTIMPL;
4221 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
4223 HTMLElement *This = impl_from_IHTMLElement6(iface);
4224 FIXME("(%p)->(%p)\n", This, p);
4225 return E_NOTIMPL;
4228 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
4230 HTMLElement *This = impl_from_IHTMLElement6(iface);
4231 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4232 return E_NOTIMPL;
4235 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
4237 HTMLElement *This = impl_from_IHTMLElement6(iface);
4238 FIXME("(%p)->(%p)\n", This, p);
4239 return E_NOTIMPL;
4242 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
4244 HTMLElement *This = impl_from_IHTMLElement6(iface);
4246 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4248 return set_node_event(&This->node, EVENTID_CHANGE, &v);
4251 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
4253 HTMLElement *This = impl_from_IHTMLElement6(iface);
4255 TRACE("(%p)->(%p)\n", This, p);
4257 return get_node_event(&This->node, EVENTID_CHANGE, p);
4260 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
4262 HTMLElement *This = impl_from_IHTMLElement6(iface);
4263 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4264 return E_NOTIMPL;
4267 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
4269 HTMLElement *This = impl_from_IHTMLElement6(iface);
4270 FIXME("(%p)->(%p)\n", This, p);
4271 return E_NOTIMPL;
4274 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
4276 HTMLElement *This = impl_from_IHTMLElement6(iface);
4277 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4278 return E_NOTIMPL;
4281 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
4283 HTMLElement *This = impl_from_IHTMLElement6(iface);
4284 FIXME("(%p)->(%p)\n", This, p);
4285 return E_NOTIMPL;
4288 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
4290 HTMLElement *This = impl_from_IHTMLElement6(iface);
4291 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4292 return E_NOTIMPL;
4295 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
4297 HTMLElement *This = impl_from_IHTMLElement6(iface);
4298 FIXME("(%p)->(%p)\n", This, p);
4299 return E_NOTIMPL;
4302 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
4304 HTMLElement *This = impl_from_IHTMLElement6(iface);
4306 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4308 return set_node_event(&This->node, EVENTID_ERROR, &v);
4311 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
4313 HTMLElement *This = impl_from_IHTMLElement6(iface);
4315 TRACE("(%p)->(%p)\n", This, p);
4317 return get_node_event(&This->node, EVENTID_ERROR, p);
4320 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
4322 HTMLElement *This = impl_from_IHTMLElement6(iface);
4323 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4324 return E_NOTIMPL;
4327 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
4329 HTMLElement *This = impl_from_IHTMLElement6(iface);
4330 FIXME("(%p)->(%p)\n", This, p);
4331 return E_NOTIMPL;
4334 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
4336 HTMLElement *This = impl_from_IHTMLElement6(iface);
4338 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4340 return set_node_event(&This->node, EVENTID_LOAD, &v);
4343 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
4345 HTMLElement *This = impl_from_IHTMLElement6(iface);
4347 TRACE("(%p)->(%p)\n", This, p);
4349 return get_node_event(&This->node, EVENTID_LOAD, p);
4352 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
4354 HTMLElement *This = impl_from_IHTMLElement6(iface);
4355 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4356 return E_NOTIMPL;
4359 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
4361 HTMLElement *This = impl_from_IHTMLElement6(iface);
4362 FIXME("(%p)->(%p)\n", This, p);
4363 return E_NOTIMPL;
4366 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
4368 HTMLElement *This = impl_from_IHTMLElement6(iface);
4369 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4370 return E_NOTIMPL;
4373 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
4375 HTMLElement *This = impl_from_IHTMLElement6(iface);
4376 FIXME("(%p)->(%p)\n", This, p);
4377 return E_NOTIMPL;
4380 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
4382 HTMLElement *This = impl_from_IHTMLElement6(iface);
4383 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4384 return E_NOTIMPL;
4387 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
4389 HTMLElement *This = impl_from_IHTMLElement6(iface);
4390 FIXME("(%p)->(%p)\n", This, p);
4391 return E_NOTIMPL;
4394 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
4396 HTMLElement *This = impl_from_IHTMLElement6(iface);
4397 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4398 return E_NOTIMPL;
4401 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
4403 HTMLElement *This = impl_from_IHTMLElement6(iface);
4404 FIXME("(%p)->(%p)\n", This, p);
4405 return E_NOTIMPL;
4408 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
4410 HTMLElement *This = impl_from_IHTMLElement6(iface);
4411 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4412 return E_NOTIMPL;
4415 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
4417 HTMLElement *This = impl_from_IHTMLElement6(iface);
4418 FIXME("(%p)->(%p)\n", This, p);
4419 return E_NOTIMPL;
4422 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
4424 HTMLElement *This = impl_from_IHTMLElement6(iface);
4425 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4426 return E_NOTIMPL;
4429 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
4431 HTMLElement *This = impl_from_IHTMLElement6(iface);
4432 FIXME("(%p)->(%p)\n", This, p);
4433 return E_NOTIMPL;
4436 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
4438 HTMLElement *This = impl_from_IHTMLElement6(iface);
4439 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4440 return E_NOTIMPL;
4443 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
4445 HTMLElement *This = impl_from_IHTMLElement6(iface);
4446 FIXME("(%p)->(%p)\n", This, p);
4447 return E_NOTIMPL;
4450 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
4452 HTMLElement *This = impl_from_IHTMLElement6(iface);
4453 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4454 return E_NOTIMPL;
4457 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
4459 HTMLElement *This = impl_from_IHTMLElement6(iface);
4460 FIXME("(%p)->(%p)\n", This, p);
4461 return E_NOTIMPL;
4464 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
4466 HTMLElement *This = impl_from_IHTMLElement6(iface);
4467 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4468 return E_NOTIMPL;
4471 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
4473 HTMLElement *This = impl_from_IHTMLElement6(iface);
4474 FIXME("(%p)->(%p)\n", This, p);
4475 return E_NOTIMPL;
4478 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
4480 HTMLElement *This = impl_from_IHTMLElement6(iface);
4481 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4482 return E_NOTIMPL;
4485 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
4487 HTMLElement *This = impl_from_IHTMLElement6(iface);
4488 FIXME("(%p)->(%p)\n", This, p);
4489 return E_NOTIMPL;
4492 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
4494 HTMLElement *This = impl_from_IHTMLElement6(iface);
4495 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4496 return E_NOTIMPL;
4499 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
4501 HTMLElement *This = impl_from_IHTMLElement6(iface);
4502 FIXME("(%p)->(%p)\n", This, p);
4503 return E_NOTIMPL;
4506 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
4508 HTMLElement *This = impl_from_IHTMLElement6(iface);
4509 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4510 return E_NOTIMPL;
4513 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
4515 HTMLElement *This = impl_from_IHTMLElement6(iface);
4516 FIXME("(%p)->(%p)\n", This, p);
4517 return E_NOTIMPL;
4520 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
4522 HTMLElement *This = impl_from_IHTMLElement6(iface);
4523 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4524 return E_NOTIMPL;
4527 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
4529 HTMLElement *This = impl_from_IHTMLElement6(iface);
4530 FIXME("(%p)->(%p)\n", This, p);
4531 return E_NOTIMPL;
4534 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
4536 HTMLElement *This = impl_from_IHTMLElement6(iface);
4538 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4540 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
4543 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
4545 HTMLElement *This = impl_from_IHTMLElement6(iface);
4547 TRACE("(%p)->(%p)\n", This, p);
4549 return get_node_event(&This->node, EVENTID_SUBMIT, p);
4552 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
4554 HTMLElement *This = impl_from_IHTMLElement6(iface);
4555 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4556 return E_NOTIMPL;
4559 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
4561 HTMLElement *This = impl_from_IHTMLElement6(iface);
4562 FIXME("(%p)->(%p)\n", This, p);
4563 return E_NOTIMPL;
4566 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
4568 HTMLElement *This = impl_from_IHTMLElement6(iface);
4569 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4570 return E_NOTIMPL;
4573 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
4575 HTMLElement *This = impl_from_IHTMLElement6(iface);
4576 FIXME("(%p)->(%p)\n", This, p);
4577 return E_NOTIMPL;
4580 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
4582 HTMLElement *This = impl_from_IHTMLElement6(iface);
4583 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4584 return E_NOTIMPL;
4587 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
4589 HTMLElement *This = impl_from_IHTMLElement6(iface);
4590 FIXME("(%p)->(%p)\n", This, p);
4591 return E_NOTIMPL;
4594 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
4596 HTMLElement *This = impl_from_IHTMLElement6(iface);
4597 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4598 return E_NOTIMPL;
4601 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
4603 HTMLElement *This = impl_from_IHTMLElement6(iface);
4604 FIXME("(%p)->(%p)\n", This, p);
4605 return E_NOTIMPL;
4608 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
4610 HTMLElement *This = impl_from_IHTMLElement6(iface);
4611 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
4612 return E_NOTIMPL;
4615 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
4616 HTMLElement6_QueryInterface,
4617 HTMLElement6_AddRef,
4618 HTMLElement6_Release,
4619 HTMLElement6_GetTypeInfoCount,
4620 HTMLElement6_GetTypeInfo,
4621 HTMLElement6_GetIDsOfNames,
4622 HTMLElement6_Invoke,
4623 HTMLElement6_getAttributeNS,
4624 HTMLElement6_setAttributeNS,
4625 HTMLElement6_removeAttributeNS,
4626 HTMLElement6_getAttributeNodeNS,
4627 HTMLElement6_setAttributeNodeNS,
4628 HTMLElement6_hasAttributeNS,
4629 HTMLElement6_getAttribute,
4630 HTMLElement6_setAttribute,
4631 HTMLElement6_removeAttribute,
4632 HTMLElement6_getAttributeNode,
4633 HTMLElement6_setAttributeNode,
4634 HTMLElement6_removeAttributeNode,
4635 HTMLElement6_hasAttribute,
4636 HTMLElement6_getElementsByTagNameNS,
4637 HTMLElement6_get_tagName,
4638 HTMLElement6_get_nodeName,
4639 HTMLElement6_getElementsByClassName,
4640 HTMLElement6_msMatchesSelector,
4641 HTMLElement6_put_onabort,
4642 HTMLElement6_get_onabort,
4643 HTMLElement6_put_oncanplay,
4644 HTMLElement6_get_oncanplay,
4645 HTMLElement6_put_oncanplaythrough,
4646 HTMLElement6_get_oncanplaythrough,
4647 HTMLElement6_put_onchange,
4648 HTMLElement6_get_onchange,
4649 HTMLElement6_put_ondurationchange,
4650 HTMLElement6_get_ondurationchange,
4651 HTMLElement6_put_onemptied,
4652 HTMLElement6_get_onemptied,
4653 HTMLElement6_put_onended,
4654 HTMLElement6_get_onended,
4655 HTMLElement6_put_onerror,
4656 HTMLElement6_get_onerror,
4657 HTMLElement6_put_oninput,
4658 HTMLElement6_get_oninput,
4659 HTMLElement6_put_onload,
4660 HTMLElement6_get_onload,
4661 HTMLElement6_put_onloadeddata,
4662 HTMLElement6_get_onloadeddata,
4663 HTMLElement6_put_onloadedmetadata,
4664 HTMLElement6_get_onloadedmetadata,
4665 HTMLElement6_put_onloadstart,
4666 HTMLElement6_get_onloadstart,
4667 HTMLElement6_put_onpause,
4668 HTMLElement6_get_onpause,
4669 HTMLElement6_put_onplay,
4670 HTMLElement6_get_onplay,
4671 HTMLElement6_put_onplaying,
4672 HTMLElement6_get_onplaying,
4673 HTMLElement6_put_onprogress,
4674 HTMLElement6_get_onprogress,
4675 HTMLElement6_put_onratechange,
4676 HTMLElement6_get_onratechange,
4677 HTMLElement6_put_onreset,
4678 HTMLElement6_get_onreset,
4679 HTMLElement6_put_onseeked,
4680 HTMLElement6_get_onseeked,
4681 HTMLElement6_put_onseeking,
4682 HTMLElement6_get_onseeking,
4683 HTMLElement6_put_onselect,
4684 HTMLElement6_get_onselect,
4685 HTMLElement6_put_onstalled,
4686 HTMLElement6_get_onstalled,
4687 HTMLElement6_put_onsubmit,
4688 HTMLElement6_get_onsubmit,
4689 HTMLElement6_put_onsuspend,
4690 HTMLElement6_get_onsuspend,
4691 HTMLElement6_put_ontimeupdate,
4692 HTMLElement6_get_ontimeupdate,
4693 HTMLElement6_put_onvolumechange,
4694 HTMLElement6_get_onvolumechange,
4695 HTMLElement6_put_onwaiting,
4696 HTMLElement6_get_onwaiting,
4697 HTMLElement6_hasAttributes
4700 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
4702 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
4705 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
4707 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4708 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4711 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
4713 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4714 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4717 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
4719 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4720 return IHTMLElement_Release(&This->IHTMLElement_iface);
4723 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
4725 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4726 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4729 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
4730 LCID lcid, ITypeInfo **ppTInfo)
4732 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4733 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4736 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
4737 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4739 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4740 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4741 lcid, rgDispId);
4744 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
4745 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4747 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4748 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4749 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4752 HRESULT elem_unique_id(unsigned id, BSTR *p)
4754 WCHAR buf[32];
4756 static const WCHAR formatW[] = {'m','s','_','_','i','d','%','u',0};
4758 sprintfW(buf, formatW, id);
4759 *p = SysAllocString(buf);
4760 return *p ? S_OK : E_OUTOFMEMORY;
4763 static void ensure_unique_id(HTMLElement *elem)
4765 if(!elem->unique_id)
4766 elem->unique_id = ++elem->node.doc->unique_id;
4769 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
4771 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4773 TRACE("(%p)->(%p)\n", This, p);
4775 ensure_unique_id(This);
4776 *p = This->unique_id;
4777 return S_OK;
4780 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
4782 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4784 TRACE("(%p)->(%p)\n", This, p);
4786 ensure_unique_id(This);
4787 return elem_unique_id(This->unique_id, p);
4790 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
4791 HTMLUniqueName_QueryInterface,
4792 HTMLUniqueName_AddRef,
4793 HTMLUniqueName_Release,
4794 HTMLUniqueName_GetTypeInfoCount,
4795 HTMLUniqueName_GetTypeInfo,
4796 HTMLUniqueName_GetIDsOfNames,
4797 HTMLUniqueName_Invoke,
4798 HTMLUniqueName_get_uniqueNumber,
4799 HTMLUniqueName_get_uniqueID
4802 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
4804 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
4807 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
4809 HTMLElement *This = impl_from_IElementSelector(iface);
4810 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4813 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
4815 HTMLElement *This = impl_from_IElementSelector(iface);
4816 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4819 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
4821 HTMLElement *This = impl_from_IElementSelector(iface);
4822 return IHTMLElement_Release(&This->IHTMLElement_iface);
4825 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
4827 HTMLElement *This = impl_from_IElementSelector(iface);
4828 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4831 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
4832 LCID lcid, ITypeInfo **ppTInfo)
4834 HTMLElement *This = impl_from_IElementSelector(iface);
4835 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4838 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
4839 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4841 HTMLElement *This = impl_from_IElementSelector(iface);
4842 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
4845 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
4846 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4848 HTMLElement *This = impl_from_IElementSelector(iface);
4849 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4850 pDispParams, pVarResult, pExcepInfo, puArgErr);
4853 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
4855 HTMLElement *This = impl_from_IElementSelector(iface);
4856 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4857 return E_NOTIMPL;
4860 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4862 HTMLElement *This = impl_from_IElementSelector(iface);
4863 nsIDOMNodeList *node_list;
4864 nsAString nsstr;
4865 nsresult nsres;
4867 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4869 nsAString_InitDepend(&nsstr, v);
4870 nsres = nsIDOMHTMLElement_QuerySelectorAll(This->nselem, &nsstr, &node_list);
4871 nsAString_Finish(&nsstr);
4872 if(NS_FAILED(nsres)) {
4873 ERR("QuerySelectorAll failed: %08x\n", nsres);
4874 return E_FAIL;
4877 *pel = create_child_collection(This->node.doc, node_list);
4878 nsIDOMNodeList_Release(node_list);
4879 return *pel ? S_OK : E_OUTOFMEMORY;
4882 static const IElementSelectorVtbl ElementSelectorVtbl = {
4883 ElementSelector_QueryInterface,
4884 ElementSelector_AddRef,
4885 ElementSelector_Release,
4886 ElementSelector_GetTypeInfoCount,
4887 ElementSelector_GetTypeInfo,
4888 ElementSelector_GetIDsOfNames,
4889 ElementSelector_Invoke,
4890 ElementSelector_querySelector,
4891 ElementSelector_querySelectorAll
4894 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
4896 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
4899 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
4900 REFIID riid, void **ppv)
4902 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4903 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4906 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
4908 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4909 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4912 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
4914 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4915 return IHTMLElement_Release(&This->IHTMLElement_iface);
4918 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
4920 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4921 TRACE("(%p)->(%p)\n", This, ppTI);
4922 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
4925 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
4927 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4928 FIXME("(%p)->(%u %p)\n", This, dwGuidKind, pGUID);
4929 return E_NOTIMPL;
4932 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
4934 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4935 FIXME("(%p)->(%p)\n", This, pcti);
4936 *pcti = 1;
4937 return S_OK;
4940 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
4941 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
4943 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4944 FIXME("(%p)->(%u %x %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
4945 return E_NOTIMPL;
4948 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
4949 ProvideClassInfo_QueryInterface,
4950 ProvideClassInfo_AddRef,
4951 ProvideClassInfo_Release,
4952 ProvideClassInfo_GetClassInfo,
4953 ProvideClassInfo2_GetGUID,
4954 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
4955 ProvideMultipleClassInfo_GetInfoOfIndex
4958 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
4960 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
4963 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
4965 HTMLElement *This = impl_from_IElementTraversal(iface);
4966 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4969 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
4971 HTMLElement *This = impl_from_IElementTraversal(iface);
4973 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4976 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
4978 HTMLElement *This = impl_from_IElementTraversal(iface);
4980 return IHTMLElement_Release(&This->IHTMLElement_iface);
4983 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
4985 HTMLElement *This = impl_from_IElementTraversal(iface);
4986 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4989 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
4990 LCID lcid, ITypeInfo **ppTInfo)
4992 HTMLElement *This = impl_from_IElementTraversal(iface);
4993 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4996 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
4997 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4999 HTMLElement *This = impl_from_IElementTraversal(iface);
5000 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5001 lcid, rgDispId);
5004 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
5005 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5007 HTMLElement *This = impl_from_IElementTraversal(iface);
5008 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5009 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5012 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
5014 HTMLElement *This = impl_from_IElementTraversal(iface);
5015 nsIDOMElement *nselem = NULL;
5016 HTMLElement *elem;
5017 HRESULT hres;
5019 TRACE("(%p)->(%p)\n", This, p);
5021 nsIDOMHTMLElement_GetFirstElementChild(This->nselem, &nselem);
5022 if(!nselem) {
5023 *p = NULL;
5024 return S_OK;
5027 hres = get_elem(This->node.doc, nselem, &elem);
5028 nsIDOMElement_Release(nselem);
5029 if(FAILED(hres))
5030 return hres;
5032 *p = &elem->IHTMLElement_iface;
5033 return S_OK;
5036 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
5038 HTMLElement *This = impl_from_IElementTraversal(iface);
5039 FIXME("(%p)->(%p)\n", This, p);
5040 return E_NOTIMPL;
5043 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
5045 HTMLElement *This = impl_from_IElementTraversal(iface);
5046 FIXME("(%p)->(%p)\n", This, p);
5047 return E_NOTIMPL;
5050 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
5052 HTMLElement *This = impl_from_IElementTraversal(iface);
5053 FIXME("(%p)->(%p)\n", This, p);
5054 return E_NOTIMPL;
5057 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
5059 HTMLElement *This = impl_from_IElementTraversal(iface);
5060 FIXME("(%p)->(%p)\n", This, p);
5061 return E_NOTIMPL;
5064 static const IElementTraversalVtbl ElementTraversalVtbl = {
5065 ElementTraversal_QueryInterface,
5066 ElementTraversal_AddRef,
5067 ElementTraversal_Release,
5068 ElementTraversal_GetTypeInfoCount,
5069 ElementTraversal_GetTypeInfo,
5070 ElementTraversal_GetIDsOfNames,
5071 ElementTraversal_Invoke,
5072 ElementTraversal_get_firstElementChild,
5073 ElementTraversal_get_lastElementChild,
5074 ElementTraversal_get_previousElementSibling,
5075 ElementTraversal_get_nextElementSibling,
5076 ElementTraversal_get_childElementCount
5079 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5081 return CONTAINING_RECORD(iface, HTMLElement, node);
5084 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5086 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5088 if(IsEqualGUID(&IID_IUnknown, riid)) {
5089 *ppv = &This->IHTMLElement_iface;
5090 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
5091 *ppv = &This->IHTMLElement_iface;
5092 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
5093 *ppv = &This->IHTMLElement_iface;
5094 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
5095 *ppv = &This->IHTMLElement2_iface;
5096 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
5097 *ppv = &This->IHTMLElement3_iface;
5098 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
5099 *ppv = &This->IHTMLElement4_iface;
5100 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
5101 *ppv = &This->IHTMLElement6_iface;
5102 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
5103 *ppv = &This->IHTMLUniqueName_iface;
5104 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
5105 *ppv = &This->IElementSelector_iface;
5106 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
5107 *ppv = &This->IElementTraversal_iface;
5108 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
5109 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5110 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
5111 *ppv = &This->IProvideMultipleClassInfo_iface;
5112 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
5113 *ppv = &This->IProvideMultipleClassInfo_iface;
5114 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
5115 *ppv = &This->IProvideMultipleClassInfo_iface;
5116 }else {
5117 return HTMLDOMNode_QI(&This->node, riid, ppv);
5120 IUnknown_AddRef((IUnknown*)*ppv);
5121 return S_OK;
5124 void HTMLElement_destructor(HTMLDOMNode *iface)
5126 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5128 ConnectionPointContainer_Destroy(&This->cp_container);
5130 if(This->style) {
5131 This->style->elem = NULL;
5132 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
5134 if(This->runtime_style) {
5135 This->runtime_style->elem = NULL;
5136 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
5138 if(This->attrs) {
5139 HTMLDOMAttribute *attr;
5141 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
5142 attr->elem = NULL;
5144 This->attrs->elem = NULL;
5145 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
5148 heap_free(This->filter);
5150 HTMLDOMNode_destructor(&This->node);
5153 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5155 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5156 HTMLElement *new_elem;
5157 HRESULT hres;
5159 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
5160 if(FAILED(hres))
5161 return hres;
5163 if(This->filter) {
5164 new_elem->filter = heap_strdupW(This->filter);
5165 if(!new_elem->filter) {
5166 IHTMLElement_Release(&This->IHTMLElement_iface);
5167 return E_OUTOFMEMORY;
5171 *ret = &new_elem->node;
5172 return S_OK;
5175 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
5177 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5179 switch(eid) {
5180 case EVENTID_KEYDOWN: {
5181 nsIDOMKeyEvent *key_event;
5182 nsresult nsres;
5184 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
5185 if(NS_SUCCEEDED(nsres)) {
5186 UINT32 code = 0;
5188 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
5190 if(code == VK_F1 /* DOM_VK_F1 */) {
5191 DOMEvent *help_event;
5192 HRESULT hres;
5194 TRACE("F1 pressed\n");
5196 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
5197 if(SUCCEEDED(hres)) {
5198 dispatch_event(&This->node.event_target, help_event);
5199 IDOMEvent_Release(&help_event->IDOMEvent_iface);
5201 *prevent_default = TRUE;
5204 nsIDOMKeyEvent_Release(key_event);
5209 return S_OK;
5212 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
5214 const cpc_entry_t HTMLElement_cpc[] = {
5215 HTMLELEMENT_CPC,
5216 {NULL}
5219 static const NodeImplVtbl HTMLElementImplVtbl = {
5220 &CLSID_HTMLUnknownElement,
5221 HTMLElement_QI,
5222 HTMLElement_destructor,
5223 HTMLElement_cpc,
5224 HTMLElement_clone,
5225 HTMLElement_handle_event,
5226 HTMLElement_get_attr_col
5229 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
5231 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
5234 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
5235 DWORD grfdex, DISPID *pid)
5237 HTMLElement *This = impl_from_DispatchEx(dispex);
5239 if(This->node.vtbl->get_dispid)
5240 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
5242 return DISP_E_UNKNOWNNAME;
5245 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
5246 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
5247 IServiceProvider *caller)
5249 HTMLElement *This = impl_from_DispatchEx(dispex);
5251 if(This->node.vtbl->invoke)
5252 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
5253 params, res, ei, caller);
5255 ERR("(%p): element has no invoke method\n", This);
5256 return E_NOTIMPL;
5259 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
5261 HTMLElement *This = impl_from_DispatchEx(dispex);
5262 nsIDOMMozNamedAttrMap *attrs;
5263 nsIDOMAttr *attr;
5264 nsAString nsstr;
5265 const PRUnichar *str;
5266 BSTR name;
5267 VARIANT value;
5268 unsigned i;
5269 UINT32 len;
5270 DISPID id;
5271 nsresult nsres;
5272 HRESULT hres;
5274 if(!This->nselem)
5275 return S_FALSE;
5277 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
5278 if(NS_FAILED(nsres))
5279 return E_FAIL;
5281 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
5282 if(NS_FAILED(nsres)) {
5283 nsIDOMMozNamedAttrMap_Release(attrs);
5284 return E_FAIL;
5287 nsAString_Init(&nsstr, NULL);
5288 for(i=0; i<len; i++) {
5289 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
5290 if(NS_FAILED(nsres))
5291 continue;
5293 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
5294 if(NS_FAILED(nsres)) {
5295 nsIDOMAttr_Release(attr);
5296 continue;
5299 nsAString_GetData(&nsstr, &str);
5300 name = SysAllocString(str);
5301 if(!name) {
5302 nsIDOMAttr_Release(attr);
5303 continue;
5306 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
5307 if(hres != DISP_E_UNKNOWNNAME) {
5308 nsIDOMAttr_Release(attr);
5309 SysFreeString(name);
5310 continue;
5313 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
5314 nsIDOMAttr_Release(attr);
5315 if(NS_FAILED(nsres)) {
5316 SysFreeString(name);
5317 continue;
5320 nsAString_GetData(&nsstr, &str);
5321 V_VT(&value) = VT_BSTR;
5322 if(*str) {
5323 V_BSTR(&value) = SysAllocString(str);
5324 if(!V_BSTR(&value)) {
5325 SysFreeString(name);
5326 continue;
5328 } else
5329 V_BSTR(&value) = NULL;
5331 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
5332 SysFreeString(name);
5333 VariantClear(&value);
5335 nsAString_Finish(&nsstr);
5337 nsIDOMMozNamedAttrMap_Release(attrs);
5338 return S_OK;
5341 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
5343 HTMLElement *This = impl_from_DispatchEx(dispex);
5345 static const WCHAR loadW[] = {'l','o','a','d',0};
5347 switch(eid) {
5348 case EVENTID_LOAD:
5349 add_nsevent_listener(This->node.doc, This->node.nsnode, loadW);
5350 return;
5351 default:
5352 ensure_doc_nsevent_handler(This->node.doc, eid);
5356 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
5358 HTMLElement *This = impl_from_DispatchEx(dispex);
5360 if(!This->node.vtbl->handle_event)
5361 return S_OK;
5362 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
5365 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
5367 HTMLElement *This = impl_from_DispatchEx(dispex);
5368 HTMLDOMNode *node;
5369 nsIDOMNode *nsnode;
5370 nsresult nsres;
5371 HRESULT hres;
5373 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
5374 assert(nsres == NS_OK);
5375 if(!nsnode)
5376 return NULL;
5378 hres = get_node(This->node.doc, nsnode, TRUE, &node);
5379 nsIDOMNode_Release(nsnode);
5380 if(FAILED(hres))
5381 return NULL;
5383 return &node->event_target;
5386 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
5388 HTMLElement *This = impl_from_DispatchEx(dispex);
5389 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
5390 return &This->cp_container;
5393 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
5395 HTMLElement *This = impl_from_DispatchEx(dispex);
5396 return default_set_current_event(This->node.doc->window, event);
5399 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5401 static const dispex_hook_t elem2_ie11_hooks[] = {
5402 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
5403 {DISPID_UNKNOWN}
5406 HTMLDOMNode_init_dispex_info(info, mode);
5408 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
5410 if(mode >= COMPAT_MODE_IE8)
5411 dispex_info_add_interface(info, IElementSelector_tid, NULL);
5413 if(mode >= COMPAT_MODE_IE9) {
5414 dispex_info_add_interface(info, IHTMLElement6_tid, NULL);
5415 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
5419 static const tid_t HTMLElement_iface_tids[] = {
5420 HTMLELEMENT_TIDS,
5424 static event_target_vtbl_t HTMLElement_event_target_vtbl = {
5426 NULL,
5427 HTMLElement_get_dispid,
5428 HTMLElement_invoke,
5429 NULL,
5430 HTMLElement_populate_props
5432 HTMLElement_bind_event,
5433 HTMLElement_get_parent_event_target,
5434 HTMLElement_handle_event_default,
5435 HTMLElement_get_cp_container,
5436 HTMLElement_set_current_event
5439 static dispex_static_data_t HTMLElement_dispex = {
5440 &HTMLElement_event_target_vtbl.dispex_vtbl,
5441 DispHTMLUnknownElement_tid,
5442 HTMLElement_iface_tids,
5443 HTMLElement_init_dispex_info
5446 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
5448 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
5449 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
5450 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
5451 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
5452 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
5453 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
5454 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
5455 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
5456 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
5458 if(dispex_data && !dispex_data->vtbl)
5459 dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl;
5461 if(nselem) {
5462 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLElement_dispex);
5464 /* No AddRef, share reference with HTMLDOMNode */
5465 assert((nsIDOMNode*)nselem == This->node.nsnode);
5466 This->nselem = nselem;
5469 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
5472 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
5474 nsIDOMHTMLElement *nselem;
5475 nsAString class_name_str;
5476 const PRUnichar *class_name;
5477 const tag_desc_t *tag;
5478 HTMLElement *elem;
5479 nsresult nsres;
5480 HRESULT hres;
5482 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
5483 if(NS_FAILED(nsres))
5484 return E_FAIL;
5486 nsAString_Init(&class_name_str, NULL);
5487 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
5489 nsAString_GetData(&class_name_str, &class_name);
5491 tag = get_tag_desc(class_name);
5492 if(tag) {
5493 hres = tag->constructor(doc, nselem, &elem);
5494 }else if(use_generic) {
5495 hres = HTMLGenericElement_Create(doc, nselem, &elem);
5496 }else {
5497 elem = heap_alloc_zero(sizeof(HTMLElement));
5498 if(elem) {
5499 elem->node.vtbl = &HTMLElementImplVtbl;
5500 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
5501 hres = S_OK;
5502 }else {
5503 hres = E_OUTOFMEMORY;
5507 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
5509 nsIDOMHTMLElement_Release(nselem);
5510 nsAString_Finish(&class_name_str);
5511 if(FAILED(hres))
5512 return hres;
5514 *ret = elem;
5515 return S_OK;
5518 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
5520 HTMLDOMNode *node;
5521 HRESULT hres;
5523 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
5524 if(FAILED(hres))
5525 return hres;
5527 *ret = impl_from_HTMLDOMNode(node);
5528 return S_OK;
5531 /* interface IHTMLFiltersCollection */
5532 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
5534 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5536 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
5538 if(IsEqualGUID(&IID_IUnknown, riid)) {
5539 *ppv = &This->IHTMLFiltersCollection_iface;
5540 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
5541 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
5542 *ppv = &This->IHTMLFiltersCollection_iface;
5543 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5544 return *ppv ? S_OK : E_NOINTERFACE;
5545 }else {
5546 *ppv = NULL;
5547 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5548 return E_NOINTERFACE;
5551 IUnknown_AddRef((IUnknown*)*ppv);
5552 return S_OK;
5555 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
5557 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5558 LONG ref = InterlockedIncrement(&This->ref);
5560 TRACE("(%p) ref=%d\n", This, ref);
5562 return ref;
5565 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
5567 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5568 LONG ref = InterlockedDecrement(&This->ref);
5570 TRACE("(%p) ref=%d\n", This, ref);
5572 if(!ref)
5574 heap_free(This);
5577 return ref;
5580 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
5582 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5583 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5586 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
5587 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5589 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5590 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5593 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
5594 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5595 LCID lcid, DISPID *rgDispId)
5597 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5598 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5599 lcid, rgDispId);
5602 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
5603 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
5604 EXCEPINFO *pExcepInfo, UINT *puArgErr)
5606 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5607 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5608 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5611 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
5613 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5615 if(!p)
5616 return E_POINTER;
5618 FIXME("(%p)->(%p) Always returning 0\n", This, p);
5619 *p = 0;
5621 return S_OK;
5624 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
5626 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5627 FIXME("(%p)->(%p)\n", This, p);
5628 return E_NOTIMPL;
5631 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
5633 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5634 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
5635 return E_NOTIMPL;
5638 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
5639 HTMLFiltersCollection_QueryInterface,
5640 HTMLFiltersCollection_AddRef,
5641 HTMLFiltersCollection_Release,
5642 HTMLFiltersCollection_GetTypeInfoCount,
5643 HTMLFiltersCollection_GetTypeInfo,
5644 HTMLFiltersCollection_GetIDsOfNames,
5645 HTMLFiltersCollection_Invoke,
5646 HTMLFiltersCollection_get_length,
5647 HTMLFiltersCollection_get__newEnum,
5648 HTMLFiltersCollection_item
5651 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
5653 WCHAR *ptr;
5654 int idx = 0;
5656 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
5657 idx = idx*10 + (*ptr-'0');
5658 if(*ptr)
5659 return DISP_E_UNKNOWNNAME;
5661 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
5662 TRACE("ret %x\n", *dispid);
5663 return S_OK;
5666 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5667 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5669 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
5671 V_VT(res) = VT_DISPATCH;
5672 V_DISPATCH(res) = NULL;
5674 FIXME("always returning NULL\n");
5676 return S_OK;
5679 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
5680 NULL,
5681 HTMLFiltersCollection_get_dispid,
5682 HTMLFiltersCollection_invoke,
5683 NULL
5686 static const tid_t HTMLFiltersCollection_iface_tids[] = {
5687 IHTMLFiltersCollection_tid,
5690 static dispex_static_data_t HTMLFiltersCollection_dispex = {
5691 &HTMLFiltersCollection_dispex_vtbl,
5692 IHTMLFiltersCollection_tid,
5693 HTMLFiltersCollection_iface_tids
5696 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
5698 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
5700 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
5701 ret->ref = 1;
5703 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
5704 &HTMLFiltersCollection_dispex);
5706 return &ret->IHTMLFiltersCollection_iface;
5709 /* interface IHTMLAttributeCollection */
5710 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
5712 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
5715 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
5717 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5719 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5721 if(IsEqualGUID(&IID_IUnknown, riid)) {
5722 *ppv = &This->IHTMLAttributeCollection_iface;
5723 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
5724 *ppv = &This->IHTMLAttributeCollection_iface;
5725 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
5726 *ppv = &This->IHTMLAttributeCollection2_iface;
5727 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
5728 *ppv = &This->IHTMLAttributeCollection3_iface;
5729 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5730 return *ppv ? S_OK : E_NOINTERFACE;
5731 }else {
5732 *ppv = NULL;
5733 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5734 return E_NOINTERFACE;
5737 IUnknown_AddRef((IUnknown*)*ppv);
5738 return S_OK;
5741 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
5743 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5744 LONG ref = InterlockedIncrement(&This->ref);
5746 TRACE("(%p) ref=%d\n", This, ref);
5748 return ref;
5751 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
5753 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5754 LONG ref = InterlockedDecrement(&This->ref);
5756 TRACE("(%p) ref=%d\n", This, ref);
5758 if(!ref) {
5759 while(!list_empty(&This->attrs)) {
5760 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
5762 list_remove(&attr->entry);
5763 attr->elem = NULL;
5764 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
5767 heap_free(This);
5770 return ref;
5773 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
5775 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5776 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5779 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
5780 LCID lcid, ITypeInfo **ppTInfo)
5782 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5783 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5786 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
5787 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5789 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5790 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5791 lcid, rgDispId);
5794 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
5795 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5796 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5798 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5799 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5800 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5803 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
5805 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
5806 DISPID id = DISPID_STARTENUM;
5807 LONG len = -1;
5808 HRESULT hres;
5810 FIXME("filter non-enumerable attributes out\n");
5812 while(1) {
5813 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
5814 if(FAILED(hres))
5815 return hres;
5816 else if(hres == S_FALSE)
5817 break;
5819 len++;
5820 if(len == *idx)
5821 break;
5824 if(dispid) {
5825 *dispid = id;
5826 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
5829 *idx = len+1;
5830 return S_OK;
5833 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
5835 HRESULT hres;
5837 if(name[0]>='0' && name[0]<='9') {
5838 WCHAR *end_ptr;
5839 LONG idx;
5841 idx = strtoulW(name, &end_ptr, 10);
5842 if(!*end_ptr) {
5843 hres = get_attr_dispid_by_idx(This, &idx, id);
5844 if(SUCCEEDED(hres))
5845 return hres;
5849 if(!This->elem) {
5850 WARN("NULL elem\n");
5851 return E_UNEXPECTED;
5854 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
5855 name, fdexNameCaseInsensitive, id);
5856 return hres;
5859 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
5861 HTMLDOMAttribute *iter;
5862 LONG pos = 0;
5863 HRESULT hres;
5865 *attr = NULL;
5866 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
5867 if(iter->dispid == id) {
5868 *attr = iter;
5869 break;
5871 pos++;
5874 if(!*attr) {
5875 if(!This->elem) {
5876 WARN("NULL elem\n");
5877 return E_UNEXPECTED;
5880 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
5881 if(FAILED(hres))
5882 return hres;
5885 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
5886 if(list_pos)
5887 *list_pos = pos;
5888 return S_OK;
5891 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
5893 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5894 HRESULT hres;
5896 TRACE("(%p)->(%p)\n", This, p);
5898 *p = -1;
5899 hres = get_attr_dispid_by_idx(This, p, NULL);
5900 return hres;
5903 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
5905 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5906 FIXME("(%p)->(%p)\n", This, p);
5907 return E_NOTIMPL;
5910 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
5912 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5913 HTMLDOMAttribute *attr;
5914 DISPID id;
5915 HRESULT hres;
5917 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
5919 switch(V_VT(name)) {
5920 case VT_I4:
5921 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
5922 break;
5923 case VT_BSTR:
5924 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
5925 break;
5926 default:
5927 FIXME("unsupported name %s\n", debugstr_variant(name));
5928 hres = E_NOTIMPL;
5930 if(hres == DISP_E_UNKNOWNNAME)
5931 return E_INVALIDARG;
5932 if(FAILED(hres))
5933 return hres;
5935 hres = get_domattr(This, id, NULL, &attr);
5936 if(FAILED(hres))
5937 return hres;
5939 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
5940 return S_OK;
5943 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
5944 HTMLAttributeCollection_QueryInterface,
5945 HTMLAttributeCollection_AddRef,
5946 HTMLAttributeCollection_Release,
5947 HTMLAttributeCollection_GetTypeInfoCount,
5948 HTMLAttributeCollection_GetTypeInfo,
5949 HTMLAttributeCollection_GetIDsOfNames,
5950 HTMLAttributeCollection_Invoke,
5951 HTMLAttributeCollection_get_length,
5952 HTMLAttributeCollection__newEnum,
5953 HTMLAttributeCollection_item
5956 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
5958 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
5961 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
5963 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5964 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
5967 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
5969 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5970 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
5973 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
5975 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5976 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
5979 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
5981 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5982 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5985 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
5986 LCID lcid, ITypeInfo **ppTInfo)
5988 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5989 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5992 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
5993 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5995 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5996 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5997 lcid, rgDispId);
6000 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
6001 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6002 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6004 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6005 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6006 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6009 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
6010 IHTMLDOMAttribute **newretNode)
6012 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6013 HTMLDOMAttribute *attr;
6014 DISPID id;
6015 HRESULT hres;
6017 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
6019 hres = get_attr_dispid_by_name(This, bstrName, &id);
6020 if(hres == DISP_E_UNKNOWNNAME) {
6021 *newretNode = NULL;
6022 return S_OK;
6023 } else if(FAILED(hres)) {
6024 return hres;
6027 hres = get_domattr(This, id, NULL, &attr);
6028 if(FAILED(hres))
6029 return hres;
6031 *newretNode = &attr->IHTMLDOMAttribute_iface;
6032 return S_OK;
6035 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
6036 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
6038 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6039 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
6040 return E_NOTIMPL;
6043 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
6044 BSTR bstrName, IHTMLDOMAttribute **newretNode)
6046 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6047 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
6048 return E_NOTIMPL;
6051 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
6052 HTMLAttributeCollection2_QueryInterface,
6053 HTMLAttributeCollection2_AddRef,
6054 HTMLAttributeCollection2_Release,
6055 HTMLAttributeCollection2_GetTypeInfoCount,
6056 HTMLAttributeCollection2_GetTypeInfo,
6057 HTMLAttributeCollection2_GetIDsOfNames,
6058 HTMLAttributeCollection2_Invoke,
6059 HTMLAttributeCollection2_getNamedItem,
6060 HTMLAttributeCollection2_setNamedItem,
6061 HTMLAttributeCollection2_removeNamedItem
6064 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
6066 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
6069 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
6071 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6072 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
6075 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
6077 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6078 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
6081 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
6083 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6084 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
6087 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
6089 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6090 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
6093 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
6094 LCID lcid, ITypeInfo **ppTInfo)
6096 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6097 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6100 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
6101 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6103 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6104 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6105 lcid, rgDispId);
6108 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
6109 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6110 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6112 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6113 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6114 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6117 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
6118 IHTMLDOMAttribute **ppNodeOut)
6120 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6121 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
6124 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
6125 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
6127 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6128 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
6129 return E_NOTIMPL;
6132 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
6133 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
6135 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6136 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
6137 return E_NOTIMPL;
6140 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
6142 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6143 HTMLDOMAttribute *attr;
6144 DISPID id;
6145 HRESULT hres;
6147 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
6149 hres = get_attr_dispid_by_idx(This, &index, &id);
6150 if(hres == DISP_E_UNKNOWNNAME)
6151 return E_INVALIDARG;
6152 if(FAILED(hres))
6153 return hres;
6155 hres = get_domattr(This, id, NULL, &attr);
6156 if(FAILED(hres))
6157 return hres;
6159 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
6160 return S_OK;
6163 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
6165 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6166 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
6169 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
6170 HTMLAttributeCollection3_QueryInterface,
6171 HTMLAttributeCollection3_AddRef,
6172 HTMLAttributeCollection3_Release,
6173 HTMLAttributeCollection3_GetTypeInfoCount,
6174 HTMLAttributeCollection3_GetTypeInfo,
6175 HTMLAttributeCollection3_GetIDsOfNames,
6176 HTMLAttributeCollection3_Invoke,
6177 HTMLAttributeCollection3_getNamedItem,
6178 HTMLAttributeCollection3_setNamedItem,
6179 HTMLAttributeCollection3_removeNamedItem,
6180 HTMLAttributeCollection3_item,
6181 HTMLAttributeCollection3_get_length
6184 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
6186 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
6189 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
6191 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
6192 HTMLDOMAttribute *attr;
6193 LONG pos;
6194 HRESULT hres;
6196 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
6198 hres = get_attr_dispid_by_name(This, name, dispid);
6199 if(FAILED(hres))
6200 return hres;
6202 hres = get_domattr(This, *dispid, &pos, &attr);
6203 if(FAILED(hres))
6204 return hres;
6205 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
6207 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
6208 return S_OK;
6211 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6212 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6214 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
6216 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
6218 switch(flags) {
6219 case DISPATCH_PROPERTYGET: {
6220 HTMLDOMAttribute *iter;
6221 DWORD pos;
6223 pos = id-MSHTML_DISPID_CUSTOM_MIN;
6225 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
6226 if(!pos) {
6227 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
6228 V_VT(res) = VT_DISPATCH;
6229 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
6230 return S_OK;
6232 pos--;
6235 WARN("invalid arg\n");
6236 return E_INVALIDARG;
6239 default:
6240 FIXME("unimplemented flags %x\n", flags);
6241 return E_NOTIMPL;
6245 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
6246 NULL,
6247 HTMLAttributeCollection_get_dispid,
6248 HTMLAttributeCollection_invoke,
6249 NULL
6252 static const tid_t HTMLAttributeCollection_iface_tids[] = {
6253 IHTMLAttributeCollection_tid,
6254 IHTMLAttributeCollection2_tid,
6255 IHTMLAttributeCollection3_tid,
6259 static dispex_static_data_t HTMLAttributeCollection_dispex = {
6260 &HTMLAttributeCollection_dispex_vtbl,
6261 DispHTMLAttributeCollection_tid,
6262 HTMLAttributeCollection_iface_tids
6265 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
6267 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6269 if(This->attrs) {
6270 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
6271 *ac = This->attrs;
6272 return S_OK;
6275 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
6276 if(!This->attrs)
6277 return E_OUTOFMEMORY;
6279 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
6280 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
6281 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
6282 This->attrs->ref = 2;
6284 This->attrs->elem = This;
6285 list_init(&This->attrs->attrs);
6286 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
6287 &HTMLAttributeCollection_dispex);
6289 *ac = This->attrs;
6290 return S_OK;