mpr: Enumerate connections capability before looking for functions entry points.
[wine.git] / dlls / mshtml / htmlelem.c
blobd191a3528dd260f508fdde631e8f4bd797610904
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 = result ? VARIANT_TRUE : VARIANT_FALSE;
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 = This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node)
1781 ? VARIANT_TRUE : VARIANT_FALSE;
1782 return S_OK;
1785 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1787 HTMLElement *This = impl_from_IHTMLElement(iface);
1789 TRACE("(%p)\n", This);
1791 return call_fire_event(&This->node, EVENTID_CLICK);
1794 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1795 IHTMLFiltersCollection **p)
1797 HTMLElement *This = impl_from_IHTMLElement(iface);
1798 TRACE("(%p)->(%p)\n", This, p);
1800 if(!p)
1801 return E_POINTER;
1803 *p = HTMLFiltersCollection_Create();
1805 return S_OK;
1808 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1810 HTMLElement *This = impl_from_IHTMLElement(iface);
1812 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1814 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
1817 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1819 HTMLElement *This = impl_from_IHTMLElement(iface);
1821 TRACE("(%p)->(%p)\n", This, p);
1823 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
1826 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1828 HTMLElement *This = impl_from_IHTMLElement(iface);
1829 FIXME("(%p)->(%p)\n", This, String);
1830 return E_NOTIMPL;
1833 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1835 HTMLElement *This = impl_from_IHTMLElement(iface);
1836 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1837 return E_NOTIMPL;
1840 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1842 HTMLElement *This = impl_from_IHTMLElement(iface);
1843 FIXME("(%p)->(%p)\n", This, p);
1844 return E_NOTIMPL;
1847 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1849 HTMLElement *This = impl_from_IHTMLElement(iface);
1850 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1851 return E_NOTIMPL;
1854 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1856 HTMLElement *This = impl_from_IHTMLElement(iface);
1857 FIXME("(%p)->(%p)\n", This, p);
1858 return E_NOTIMPL;
1861 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1863 HTMLElement *This = impl_from_IHTMLElement(iface);
1864 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1865 return E_NOTIMPL;
1868 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1870 HTMLElement *This = impl_from_IHTMLElement(iface);
1871 FIXME("(%p)->(%p)\n", This, p);
1872 return E_NOTIMPL;
1875 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1877 HTMLElement *This = impl_from_IHTMLElement(iface);
1878 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1879 return E_NOTIMPL;
1882 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1884 HTMLElement *This = impl_from_IHTMLElement(iface);
1885 FIXME("(%p)->(%p)\n", This, p);
1886 return E_NOTIMPL;
1889 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1891 HTMLElement *This = impl_from_IHTMLElement(iface);
1892 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1893 return E_NOTIMPL;
1896 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1898 HTMLElement *This = impl_from_IHTMLElement(iface);
1899 FIXME("(%p)->(%p)\n", This, p);
1900 return E_NOTIMPL;
1903 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1905 HTMLElement *This = impl_from_IHTMLElement(iface);
1906 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1907 return E_NOTIMPL;
1910 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1912 HTMLElement *This = impl_from_IHTMLElement(iface);
1913 FIXME("(%p)->(%p)\n", This, p);
1914 return E_NOTIMPL;
1917 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1919 HTMLElement *This = impl_from_IHTMLElement(iface);
1921 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1923 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1926 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1928 HTMLElement *This = impl_from_IHTMLElement(iface);
1930 TRACE("(%p)->(%p)\n", This, p);
1932 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1935 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1937 HTMLElement *This = impl_from_IHTMLElement(iface);
1938 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1939 return E_NOTIMPL;
1942 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1944 HTMLElement *This = impl_from_IHTMLElement(iface);
1945 FIXME("(%p)->(%p)\n", This, p);
1946 return E_NOTIMPL;
1949 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1951 HTMLElement *This = impl_from_IHTMLElement(iface);
1952 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1953 return E_NOTIMPL;
1956 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1958 HTMLElement *This = impl_from_IHTMLElement(iface);
1959 FIXME("(%p)->(%p)\n", This, p);
1960 return E_NOTIMPL;
1963 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1965 HTMLElement *This = impl_from_IHTMLElement(iface);
1966 nsIDOMNodeList *nsnode_list;
1967 nsresult nsres;
1969 TRACE("(%p)->(%p)\n", This, p);
1971 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1972 if(NS_FAILED(nsres)) {
1973 ERR("GetChildNodes failed: %08x\n", nsres);
1974 return E_FAIL;
1977 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1979 nsIDOMNodeList_Release(nsnode_list);
1980 return S_OK;
1983 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1985 HTMLElement *This = impl_from_IHTMLElement(iface);
1987 TRACE("(%p)->(%p)\n", This, p);
1989 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1990 return S_OK;
1993 static const IHTMLElementVtbl HTMLElementVtbl = {
1994 HTMLElement_QueryInterface,
1995 HTMLElement_AddRef,
1996 HTMLElement_Release,
1997 HTMLElement_GetTypeInfoCount,
1998 HTMLElement_GetTypeInfo,
1999 HTMLElement_GetIDsOfNames,
2000 HTMLElement_Invoke,
2001 HTMLElement_setAttribute,
2002 HTMLElement_getAttribute,
2003 HTMLElement_removeAttribute,
2004 HTMLElement_put_className,
2005 HTMLElement_get_className,
2006 HTMLElement_put_id,
2007 HTMLElement_get_id,
2008 HTMLElement_get_tagName,
2009 HTMLElement_get_parentElement,
2010 HTMLElement_get_style,
2011 HTMLElement_put_onhelp,
2012 HTMLElement_get_onhelp,
2013 HTMLElement_put_onclick,
2014 HTMLElement_get_onclick,
2015 HTMLElement_put_ondblclick,
2016 HTMLElement_get_ondblclick,
2017 HTMLElement_put_onkeydown,
2018 HTMLElement_get_onkeydown,
2019 HTMLElement_put_onkeyup,
2020 HTMLElement_get_onkeyup,
2021 HTMLElement_put_onkeypress,
2022 HTMLElement_get_onkeypress,
2023 HTMLElement_put_onmouseout,
2024 HTMLElement_get_onmouseout,
2025 HTMLElement_put_onmouseover,
2026 HTMLElement_get_onmouseover,
2027 HTMLElement_put_onmousemove,
2028 HTMLElement_get_onmousemove,
2029 HTMLElement_put_onmousedown,
2030 HTMLElement_get_onmousedown,
2031 HTMLElement_put_onmouseup,
2032 HTMLElement_get_onmouseup,
2033 HTMLElement_get_document,
2034 HTMLElement_put_title,
2035 HTMLElement_get_title,
2036 HTMLElement_put_language,
2037 HTMLElement_get_language,
2038 HTMLElement_put_onselectstart,
2039 HTMLElement_get_onselectstart,
2040 HTMLElement_scrollIntoView,
2041 HTMLElement_contains,
2042 HTMLElement_get_sourceIndex,
2043 HTMLElement_get_recordNumber,
2044 HTMLElement_put_lang,
2045 HTMLElement_get_lang,
2046 HTMLElement_get_offsetLeft,
2047 HTMLElement_get_offsetTop,
2048 HTMLElement_get_offsetWidth,
2049 HTMLElement_get_offsetHeight,
2050 HTMLElement_get_offsetParent,
2051 HTMLElement_put_innerHTML,
2052 HTMLElement_get_innerHTML,
2053 HTMLElement_put_innerText,
2054 HTMLElement_get_innerText,
2055 HTMLElement_put_outerHTML,
2056 HTMLElement_get_outerHTML,
2057 HTMLElement_put_outerText,
2058 HTMLElement_get_outerText,
2059 HTMLElement_insertAdjacentHTML,
2060 HTMLElement_insertAdjacentText,
2061 HTMLElement_get_parentTextEdit,
2062 HTMLElement_get_isTextEdit,
2063 HTMLElement_click,
2064 HTMLElement_get_filters,
2065 HTMLElement_put_ondragstart,
2066 HTMLElement_get_ondragstart,
2067 HTMLElement_toString,
2068 HTMLElement_put_onbeforeupdate,
2069 HTMLElement_get_onbeforeupdate,
2070 HTMLElement_put_onafterupdate,
2071 HTMLElement_get_onafterupdate,
2072 HTMLElement_put_onerrorupdate,
2073 HTMLElement_get_onerrorupdate,
2074 HTMLElement_put_onrowexit,
2075 HTMLElement_get_onrowexit,
2076 HTMLElement_put_onrowenter,
2077 HTMLElement_get_onrowenter,
2078 HTMLElement_put_ondatasetchanged,
2079 HTMLElement_get_ondatasetchanged,
2080 HTMLElement_put_ondataavailable,
2081 HTMLElement_get_ondataavailable,
2082 HTMLElement_put_ondatasetcomplete,
2083 HTMLElement_get_ondatasetcomplete,
2084 HTMLElement_put_onfilterchange,
2085 HTMLElement_get_onfilterchange,
2086 HTMLElement_get_children,
2087 HTMLElement_get_all
2090 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2092 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2095 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2097 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2100 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2101 REFIID riid, void **ppv)
2103 HTMLElement *This = impl_from_IHTMLElement2(iface);
2104 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2107 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2109 HTMLElement *This = impl_from_IHTMLElement2(iface);
2110 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2113 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2115 HTMLElement *This = impl_from_IHTMLElement2(iface);
2116 return IHTMLElement_Release(&This->IHTMLElement_iface);
2119 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2121 HTMLElement *This = impl_from_IHTMLElement2(iface);
2122 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2125 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2126 LCID lcid, ITypeInfo **ppTInfo)
2128 HTMLElement *This = impl_from_IHTMLElement2(iface);
2129 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2132 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2133 LPOLESTR *rgszNames, UINT cNames,
2134 LCID lcid, DISPID *rgDispId)
2136 HTMLElement *This = impl_from_IHTMLElement2(iface);
2137 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2138 lcid, rgDispId);
2141 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2142 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2143 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2145 HTMLElement *This = impl_from_IHTMLElement2(iface);
2146 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2147 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2150 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2152 HTMLElement *This = impl_from_IHTMLElement2(iface);
2153 FIXME("(%p)->(%p)\n", This, p);
2154 return E_NOTIMPL;
2157 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2159 HTMLElement *This = impl_from_IHTMLElement2(iface);
2160 FIXME("(%p)->(%x)\n", This, containerCapture);
2161 return E_NOTIMPL;
2164 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2166 HTMLElement *This = impl_from_IHTMLElement2(iface);
2167 FIXME("(%p)\n", This);
2168 return E_NOTIMPL;
2171 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2173 HTMLElement *This = impl_from_IHTMLElement2(iface);
2174 FIXME("(%p)->()\n", This);
2175 return E_NOTIMPL;
2178 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2180 HTMLElement *This = impl_from_IHTMLElement2(iface);
2181 FIXME("(%p)->(%p)\n", This, p);
2182 return E_NOTIMPL;
2185 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2186 LONG x, LONG y, BSTR *component)
2188 HTMLElement *This = impl_from_IHTMLElement2(iface);
2189 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2190 return E_NOTIMPL;
2193 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2195 HTMLElement *This = impl_from_IHTMLElement2(iface);
2197 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2199 if(!This->node.doc->content_ready
2200 || !This->node.doc->basedoc.doc_obj->in_place_active)
2201 return E_PENDING;
2203 WARN("stub\n");
2204 return S_OK;
2207 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2209 HTMLElement *This = impl_from_IHTMLElement2(iface);
2211 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2213 return set_node_event(&This->node, EVENTID_SCROLL, &v);
2216 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2218 HTMLElement *This = impl_from_IHTMLElement2(iface);
2220 TRACE("(%p)->(%p)\n", This, p);
2222 return get_node_event(&This->node, EVENTID_SCROLL, p);
2225 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2227 HTMLElement *This = impl_from_IHTMLElement2(iface);
2229 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2231 return set_node_event(&This->node, EVENTID_DRAG, &v);
2234 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2236 HTMLElement *This = impl_from_IHTMLElement2(iface);
2238 TRACE("(%p)->(%p)\n", This, p);
2240 return get_node_event(&This->node, EVENTID_DRAG, p);
2243 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2245 HTMLElement *This = impl_from_IHTMLElement2(iface);
2246 FIXME("(%p)->()\n", This);
2247 return E_NOTIMPL;
2250 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2252 HTMLElement *This = impl_from_IHTMLElement2(iface);
2253 FIXME("(%p)->(%p)\n", This, p);
2254 return E_NOTIMPL;
2257 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2259 HTMLElement *This = impl_from_IHTMLElement2(iface);
2260 FIXME("(%p)->()\n", This);
2261 return E_NOTIMPL;
2264 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2266 HTMLElement *This = impl_from_IHTMLElement2(iface);
2267 FIXME("(%p)->(%p)\n", This, p);
2268 return E_NOTIMPL;
2271 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2273 HTMLElement *This = impl_from_IHTMLElement2(iface);
2274 FIXME("(%p)->()\n", This);
2275 return E_NOTIMPL;
2278 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2280 HTMLElement *This = impl_from_IHTMLElement2(iface);
2281 FIXME("(%p)->(%p)\n", This, p);
2282 return E_NOTIMPL;
2285 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2287 HTMLElement *This = impl_from_IHTMLElement2(iface);
2288 FIXME("(%p)->()\n", This);
2289 return E_NOTIMPL;
2292 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2294 HTMLElement *This = impl_from_IHTMLElement2(iface);
2295 FIXME("(%p)->(%p)\n", This, p);
2296 return E_NOTIMPL;
2299 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2301 HTMLElement *This = impl_from_IHTMLElement2(iface);
2302 FIXME("(%p)->()\n", This);
2303 return E_NOTIMPL;
2306 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2308 HTMLElement *This = impl_from_IHTMLElement2(iface);
2309 FIXME("(%p)->(%p)\n", This, p);
2310 return E_NOTIMPL;
2313 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2315 HTMLElement *This = impl_from_IHTMLElement2(iface);
2316 FIXME("(%p)->()\n", This);
2317 return E_NOTIMPL;
2320 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2322 HTMLElement *This = impl_from_IHTMLElement2(iface);
2323 FIXME("(%p)->(%p)\n", This, p);
2324 return E_NOTIMPL;
2327 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2329 HTMLElement *This = impl_from_IHTMLElement2(iface);
2330 FIXME("(%p)->()\n", This);
2331 return E_NOTIMPL;
2334 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2336 HTMLElement *This = impl_from_IHTMLElement2(iface);
2337 FIXME("(%p)->(%p)\n", This, p);
2338 return E_NOTIMPL;
2341 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2343 HTMLElement *This = impl_from_IHTMLElement2(iface);
2344 FIXME("(%p)->()\n", This);
2345 return E_NOTIMPL;
2348 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2350 HTMLElement *This = impl_from_IHTMLElement2(iface);
2351 FIXME("(%p)->(%p)\n", This, p);
2352 return E_NOTIMPL;
2355 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2357 HTMLElement *This = impl_from_IHTMLElement2(iface);
2358 FIXME("(%p)->()\n", This);
2359 return E_NOTIMPL;
2362 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2364 HTMLElement *This = impl_from_IHTMLElement2(iface);
2365 FIXME("(%p)->(%p)\n", This, p);
2366 return E_NOTIMPL;
2369 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2371 HTMLElement *This = impl_from_IHTMLElement2(iface);
2372 FIXME("(%p)->()\n", This);
2373 return E_NOTIMPL;
2376 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2378 HTMLElement *This = impl_from_IHTMLElement2(iface);
2379 FIXME("(%p)->(%p)\n", This, p);
2380 return E_NOTIMPL;
2383 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2385 HTMLElement *This = impl_from_IHTMLElement2(iface);
2387 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2389 return set_node_event(&This->node, EVENTID_PASTE, &v);
2392 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2394 HTMLElement *This = impl_from_IHTMLElement2(iface);
2396 TRACE("(%p)->(%p)\n", This, p);
2398 return get_node_event(&This->node, EVENTID_PASTE, p);
2401 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2403 HTMLElement *This = impl_from_IHTMLElement2(iface);
2405 TRACE("(%p)->(%p)\n", This, p);
2407 return HTMLCurrentStyle_Create(This, p);
2410 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2412 HTMLElement *This = impl_from_IHTMLElement2(iface);
2413 FIXME("(%p)->()\n", This);
2414 return E_NOTIMPL;
2417 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2419 HTMLElement *This = impl_from_IHTMLElement2(iface);
2420 FIXME("(%p)->(%p)\n", This, p);
2421 return E_NOTIMPL;
2424 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2426 HTMLElement *This = impl_from_IHTMLElement2(iface);
2427 FIXME("(%p)->(%p)\n", This, pRectCol);
2428 return E_NOTIMPL;
2431 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2433 HTMLElement *This = impl_from_IHTMLElement2(iface);
2434 nsIDOMClientRect *nsrect;
2435 nsresult nsres;
2436 HRESULT hres;
2438 TRACE("(%p)->(%p)\n", This, pRect);
2440 nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
2441 if(NS_FAILED(nsres) || !nsrect) {
2442 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2443 return E_FAIL;
2446 hres = create_html_rect(nsrect, pRect);
2448 nsIDOMClientRect_Release(nsrect);
2449 return hres;
2452 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2453 BSTR expression, BSTR language)
2455 HTMLElement *This = impl_from_IHTMLElement2(iface);
2456 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2457 debugstr_w(language));
2458 return E_NOTIMPL;
2461 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2462 VARIANT *expression)
2464 HTMLElement *This = impl_from_IHTMLElement2(iface);
2465 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2466 return E_NOTIMPL;
2469 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2470 VARIANT_BOOL *pfSuccess)
2472 HTMLElement *This = impl_from_IHTMLElement2(iface);
2473 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2474 return E_NOTIMPL;
2477 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2479 HTMLElement *This = impl_from_IHTMLElement2(iface);
2480 nsresult nsres;
2482 TRACE("(%p)->(%d)\n", This, v);
2484 nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
2485 if(NS_FAILED(nsres))
2486 ERR("GetTabIndex failed: %08x\n", nsres);
2488 return S_OK;
2491 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2493 HTMLElement *This = impl_from_IHTMLElement2(iface);
2494 LONG index;
2495 nsresult nsres;
2497 TRACE("(%p)->(%p)\n", This, p);
2499 nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
2500 if(NS_FAILED(nsres)) {
2501 ERR("GetTabIndex failed: %08x\n", nsres);
2502 return E_FAIL;
2505 *p = index;
2506 return S_OK;
2509 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2511 HTMLElement *This = impl_from_IHTMLElement2(iface);
2512 nsresult nsres;
2514 TRACE("(%p)\n", This);
2516 nsres = nsIDOMHTMLElement_Focus(This->nselem);
2517 if(NS_FAILED(nsres))
2518 ERR("Focus failed: %08x\n", nsres);
2520 return S_OK;
2523 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2525 HTMLElement *This = impl_from_IHTMLElement2(iface);
2526 VARIANT var;
2528 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2530 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2532 V_VT(&var) = VT_BSTR;
2533 V_BSTR(&var) = v;
2534 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2537 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2539 HTMLElement *This = impl_from_IHTMLElement2(iface);
2540 FIXME("(%p)->(%p)\n", This, p);
2541 return E_NOTIMPL;
2544 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2546 HTMLElement *This = impl_from_IHTMLElement2(iface);
2548 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2550 return set_node_event(&This->node, EVENTID_BLUR, &v);
2553 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2555 HTMLElement *This = impl_from_IHTMLElement2(iface);
2557 TRACE("(%p)->(%p)\n", This, p);
2559 return get_node_event(&This->node, EVENTID_BLUR, p);
2562 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2564 HTMLElement *This = impl_from_IHTMLElement2(iface);
2566 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2568 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2571 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2573 HTMLElement *This = impl_from_IHTMLElement2(iface);
2575 TRACE("(%p)->(%p)\n", This, p);
2577 return get_node_event(&This->node, EVENTID_FOCUS, p);
2580 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2582 HTMLElement *This = impl_from_IHTMLElement2(iface);
2584 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2586 return set_node_event(&This->node, EVENTID_RESIZE, &v);
2589 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2591 HTMLElement *This = impl_from_IHTMLElement2(iface);
2593 TRACE("(%p)->(%p)\n", This, p);
2595 return get_node_event(&This->node, EVENTID_RESIZE, p);
2598 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2600 HTMLElement *This = impl_from_IHTMLElement2(iface);
2601 nsresult nsres;
2603 TRACE("(%p)\n", This);
2605 nsres = nsIDOMHTMLElement_Blur(This->nselem);
2606 if(NS_FAILED(nsres)) {
2607 ERR("Blur failed: %08x\n", nsres);
2608 return E_FAIL;
2611 return S_OK;
2614 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2616 HTMLElement *This = impl_from_IHTMLElement2(iface);
2617 FIXME("(%p)->(%p)\n", This, pUnk);
2618 return E_NOTIMPL;
2621 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2623 HTMLElement *This = impl_from_IHTMLElement2(iface);
2624 FIXME("(%p)->(%p)\n", This, pUnk);
2625 return E_NOTIMPL;
2628 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2630 HTMLElement *This = impl_from_IHTMLElement2(iface);
2631 nsresult nsres;
2633 TRACE("(%p)->(%p)\n", This, p);
2635 nsres = nsIDOMHTMLElement_GetClientHeight(This->nselem, p);
2636 assert(nsres == NS_OK);
2637 return S_OK;
2640 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2642 HTMLElement *This = impl_from_IHTMLElement2(iface);
2643 nsresult nsres;
2645 TRACE("(%p)->(%p)\n", This, p);
2647 nsres = nsIDOMHTMLElement_GetClientWidth(This->nselem, p);
2648 assert(nsres == NS_OK);
2649 return S_OK;
2652 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2654 HTMLElement *This = impl_from_IHTMLElement2(iface);
2655 nsresult nsres;
2657 TRACE("(%p)->(%p)\n", This, p);
2659 nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, p);
2660 assert(nsres == NS_OK);
2662 TRACE("*p = %d\n", *p);
2663 return S_OK;
2666 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2668 HTMLElement *This = impl_from_IHTMLElement2(iface);
2669 nsresult nsres;
2671 TRACE("(%p)->(%p)\n", This, p);
2673 nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, p);
2674 assert(nsres == NS_OK);
2676 TRACE("*p = %d\n", *p);
2677 return S_OK;
2680 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2681 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2683 HTMLElement *This = impl_from_IHTMLElement2(iface);
2685 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2687 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2690 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2692 HTMLElement *This = impl_from_IHTMLElement2(iface);
2694 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2696 return detach_event(&This->node.event_target, event, pDisp);
2699 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2701 HTMLElement *This = impl_from_IHTMLElement2(iface);
2702 BSTR str;
2704 TRACE("(%p)->(%p)\n", This, p);
2706 if(This->node.vtbl->get_readystate) {
2707 HRESULT hres;
2709 hres = This->node.vtbl->get_readystate(&This->node, &str);
2710 if(FAILED(hres))
2711 return hres;
2712 }else {
2713 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2715 str = SysAllocString(completeW);
2716 if(!str)
2717 return E_OUTOFMEMORY;
2720 V_VT(p) = VT_BSTR;
2721 V_BSTR(p) = str;
2722 return S_OK;
2725 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2727 HTMLElement *This = impl_from_IHTMLElement2(iface);
2729 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2731 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2734 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2736 HTMLElement *This = impl_from_IHTMLElement2(iface);
2738 TRACE("(%p)->(%p)\n", This, p);
2740 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2743 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2745 HTMLElement *This = impl_from_IHTMLElement2(iface);
2746 FIXME("(%p)->()\n", This);
2747 return E_NOTIMPL;
2750 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2752 HTMLElement *This = impl_from_IHTMLElement2(iface);
2753 FIXME("(%p)->(%p)\n", This, p);
2754 return E_NOTIMPL;
2757 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2759 HTMLElement *This = impl_from_IHTMLElement2(iface);
2760 FIXME("(%p)->()\n", This);
2761 return E_NOTIMPL;
2764 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2766 HTMLElement *This = impl_from_IHTMLElement2(iface);
2767 FIXME("(%p)->(%p)\n", This, p);
2768 return E_NOTIMPL;
2771 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2773 HTMLElement *This = impl_from_IHTMLElement2(iface);
2774 FIXME("(%p)->()\n", This);
2775 return E_NOTIMPL;
2778 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2780 HTMLElement *This = impl_from_IHTMLElement2(iface);
2781 FIXME("(%p)->(%p)\n", This, p);
2782 return E_NOTIMPL;
2785 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2787 HTMLElement *This = impl_from_IHTMLElement2(iface);
2788 nsAString nsstr;
2789 nsresult nsres;
2791 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2793 if(!This->nselem) {
2794 FIXME("Unsupported for comment nodes.\n");
2795 return S_OK;
2798 nsAString_InitDepend(&nsstr, v);
2799 nsres = nsIDOMHTMLElement_SetDir(This->nselem, &nsstr);
2800 nsAString_Finish(&nsstr);
2801 if(NS_FAILED(nsres)) {
2802 ERR("SetDir failed: %08x\n", nsres);
2803 return E_FAIL;
2806 return S_OK;
2809 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2811 HTMLElement *This = impl_from_IHTMLElement2(iface);
2812 nsAString dir_str;
2813 nsresult nsres;
2815 TRACE("(%p)->(%p)\n", This, p);
2817 if(!This->nselem) {
2818 *p = NULL;
2819 return S_OK;
2822 nsAString_Init(&dir_str, NULL);
2823 nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
2824 return return_nsstr(nsres, &dir_str, p);
2827 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2829 HTMLElement *This = impl_from_IHTMLElement2(iface);
2830 FIXME("(%p)->(%p)\n", This, range);
2831 return E_NOTIMPL;
2834 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2836 HTMLElement *This = impl_from_IHTMLElement2(iface);
2837 nsresult nsres;
2839 TRACE("(%p)->(%p)\n", This, p);
2841 nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, p);
2842 assert(nsres == NS_OK);
2844 TRACE("*p = %d\n", *p);
2845 return S_OK;
2848 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2850 HTMLElement *This = impl_from_IHTMLElement2(iface);
2851 nsresult nsres;
2853 TRACE("(%p)->(%p)\n", This, p);
2855 nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, p);
2856 assert(nsres == NS_OK);
2858 TRACE("*p = %d\n", *p);
2859 return S_OK;
2862 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2864 HTMLElement *This = impl_from_IHTMLElement2(iface);
2866 TRACE("(%p)->(%d)\n", This, v);
2868 if(!This->nselem) {
2869 FIXME("NULL nselem\n");
2870 return E_NOTIMPL;
2873 nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
2874 return S_OK;
2877 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2879 HTMLElement *This = impl_from_IHTMLElement2(iface);
2880 nsresult nsres;
2882 TRACE("(%p)->(%p)\n", This, p);
2884 nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, p);
2885 assert(nsres == NS_OK);
2887 TRACE("*p = %d\n", *p);
2888 return S_OK;
2891 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2893 HTMLElement *This = impl_from_IHTMLElement2(iface);
2895 TRACE("(%p)->(%d)\n", This, v);
2897 if(!This->nselem) {
2898 FIXME("NULL nselem\n");
2899 return E_NOTIMPL;
2902 nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
2903 return S_OK;
2906 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2908 HTMLElement *This = impl_from_IHTMLElement2(iface);
2909 nsresult nsres;
2911 TRACE("(%p)->(%p)\n", This, p);
2913 if(!p)
2914 return E_INVALIDARG;
2916 if(!This->nselem)
2918 FIXME("NULL nselem\n");
2919 return E_NOTIMPL;
2922 nsres = nsIDOMHTMLElement_GetScrollLeft(This->nselem, p);
2923 assert(nsres == NS_OK);
2925 TRACE("*p = %d\n", *p);
2926 return S_OK;
2929 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
2931 HTMLElement *This = impl_from_IHTMLElement2(iface);
2932 FIXME("(%p)\n", This);
2933 return E_NOTIMPL;
2936 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
2938 HTMLElement *This = impl_from_IHTMLElement2(iface);
2939 FIXME("(%p)->(%p)\n", This, mergeThis);
2940 return E_NOTIMPL;
2943 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
2945 HTMLElement *This = impl_from_IHTMLElement2(iface);
2947 TRACE("(%p)->()\n", This);
2949 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
2952 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
2954 HTMLElement *This = impl_from_IHTMLElement2(iface);
2956 TRACE("(%p)->(%p)\n", This, p);
2958 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
2961 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
2962 IHTMLElement *insertedElement, IHTMLElement **inserted)
2964 HTMLElement *This = impl_from_IHTMLElement2(iface);
2965 HTMLDOMNode *ret_node;
2966 HTMLElement *elem;
2967 HRESULT hres;
2969 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
2971 elem = unsafe_impl_from_IHTMLElement(insertedElement);
2972 if(!elem)
2973 return E_INVALIDARG;
2975 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
2976 if(FAILED(hres))
2977 return hres;
2979 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
2980 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
2981 return hres;
2984 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
2985 BSTR where, IHTMLElement **applied)
2987 HTMLElement *This = impl_from_IHTMLElement2(iface);
2988 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
2989 return E_NOTIMPL;
2992 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
2994 HTMLElement *This = impl_from_IHTMLElement2(iface);
2995 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
2996 return E_NOTIMPL;
2999 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3000 BSTR newText, BSTR *oldText)
3002 HTMLElement *This = impl_from_IHTMLElement2(iface);
3003 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3004 return E_NOTIMPL;
3007 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3009 HTMLElement *This = impl_from_IHTMLElement2(iface);
3010 FIXME("(%p)->(%p)\n", This, p);
3011 return E_NOTIMPL;
3014 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3015 VARIANT *pvarFactory, LONG *pCookie)
3017 HTMLElement *This = impl_from_IHTMLElement2(iface);
3018 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3019 return E_NOTIMPL;
3022 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3023 VARIANT_BOOL *pfResult)
3025 HTMLElement *This = impl_from_IHTMLElement2(iface);
3026 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
3027 return E_NOTIMPL;
3030 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3032 HTMLElement *This = impl_from_IHTMLElement2(iface);
3034 FIXME("(%p)->(%p): hack\n", This, p);
3036 /* We can't implement correct behavior on top of Gecko (although we could
3037 try a bit harder). Making runtimeStyle behave like regular style is
3038 enough for most use cases. */
3039 if(!This->runtime_style) {
3040 HRESULT hres;
3042 hres = HTMLStyle_Create(This, &This->runtime_style);
3043 if(FAILED(hres))
3044 return hres;
3047 *p = &This->runtime_style->IHTMLStyle_iface;
3048 IHTMLStyle_AddRef(*p);
3049 return S_OK;
3052 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
3054 HTMLElement *This = impl_from_IHTMLElement2(iface);
3055 FIXME("(%p)->(%p)\n", This, p);
3056 return E_NOTIMPL;
3059 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
3061 HTMLElement *This = impl_from_IHTMLElement2(iface);
3062 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3063 return E_NOTIMPL;
3066 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
3068 HTMLElement *This = impl_from_IHTMLElement2(iface);
3069 FIXME("(%p)->(%p)\n", This, p);
3070 return E_NOTIMPL;
3073 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
3075 HTMLElement *This = impl_from_IHTMLElement2(iface);
3076 FIXME("(%p)->()\n", This);
3077 return E_NOTIMPL;
3080 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3082 HTMLElement *This = impl_from_IHTMLElement2(iface);
3083 FIXME("(%p)->(%p)\n", This, p);
3084 return E_NOTIMPL;
3087 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3089 HTMLElement *This = impl_from_IHTMLElement2(iface);
3090 FIXME("(%p)->(%p)\n", This, p);
3091 return E_NOTIMPL;
3094 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3095 IHTMLElementCollection **pelColl)
3097 HTMLElement *This = impl_from_IHTMLElement2(iface);
3098 nsIDOMHTMLCollection *nscol;
3099 nsAString tag_str;
3100 nsresult nsres;
3102 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3104 nsAString_InitDepend(&tag_str, v);
3105 nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nscol);
3106 nsAString_Finish(&tag_str);
3107 if(NS_FAILED(nsres)) {
3108 ERR("GetElementByTagName failed: %08x\n", nsres);
3109 return E_FAIL;
3112 *pelColl = create_collection_from_htmlcol(This->node.doc, nscol);
3113 nsIDOMHTMLCollection_Release(nscol);
3114 return S_OK;
3117 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3118 HTMLElement2_QueryInterface,
3119 HTMLElement2_AddRef,
3120 HTMLElement2_Release,
3121 HTMLElement2_GetTypeInfoCount,
3122 HTMLElement2_GetTypeInfo,
3123 HTMLElement2_GetIDsOfNames,
3124 HTMLElement2_Invoke,
3125 HTMLElement2_get_scopeName,
3126 HTMLElement2_setCapture,
3127 HTMLElement2_releaseCapture,
3128 HTMLElement2_put_onlosecapture,
3129 HTMLElement2_get_onlosecapture,
3130 HTMLElement2_componentFromPoint,
3131 HTMLElement2_doScroll,
3132 HTMLElement2_put_onscroll,
3133 HTMLElement2_get_onscroll,
3134 HTMLElement2_put_ondrag,
3135 HTMLElement2_get_ondrag,
3136 HTMLElement2_put_ondragend,
3137 HTMLElement2_get_ondragend,
3138 HTMLElement2_put_ondragenter,
3139 HTMLElement2_get_ondragenter,
3140 HTMLElement2_put_ondragover,
3141 HTMLElement2_get_ondragover,
3142 HTMLElement2_put_ondragleave,
3143 HTMLElement2_get_ondragleave,
3144 HTMLElement2_put_ondrop,
3145 HTMLElement2_get_ondrop,
3146 HTMLElement2_put_onbeforecut,
3147 HTMLElement2_get_onbeforecut,
3148 HTMLElement2_put_oncut,
3149 HTMLElement2_get_oncut,
3150 HTMLElement2_put_onbeforecopy,
3151 HTMLElement2_get_onbeforecopy,
3152 HTMLElement2_put_oncopy,
3153 HTMLElement2_get_oncopy,
3154 HTMLElement2_put_onbeforepaste,
3155 HTMLElement2_get_onbeforepaste,
3156 HTMLElement2_put_onpaste,
3157 HTMLElement2_get_onpaste,
3158 HTMLElement2_get_currentStyle,
3159 HTMLElement2_put_onpropertychange,
3160 HTMLElement2_get_onpropertychange,
3161 HTMLElement2_getClientRects,
3162 HTMLElement2_getBoundingClientRect,
3163 HTMLElement2_setExpression,
3164 HTMLElement2_getExpression,
3165 HTMLElement2_removeExpression,
3166 HTMLElement2_put_tabIndex,
3167 HTMLElement2_get_tabIndex,
3168 HTMLElement2_focus,
3169 HTMLElement2_put_accessKey,
3170 HTMLElement2_get_accessKey,
3171 HTMLElement2_put_onblur,
3172 HTMLElement2_get_onblur,
3173 HTMLElement2_put_onfocus,
3174 HTMLElement2_get_onfocus,
3175 HTMLElement2_put_onresize,
3176 HTMLElement2_get_onresize,
3177 HTMLElement2_blur,
3178 HTMLElement2_addFilter,
3179 HTMLElement2_removeFilter,
3180 HTMLElement2_get_clientHeight,
3181 HTMLElement2_get_clientWidth,
3182 HTMLElement2_get_clientTop,
3183 HTMLElement2_get_clientLeft,
3184 HTMLElement2_attachEvent,
3185 HTMLElement2_detachEvent,
3186 HTMLElement2_get_readyState,
3187 HTMLElement2_put_onreadystatechange,
3188 HTMLElement2_get_onreadystatechange,
3189 HTMLElement2_put_onrowsdelete,
3190 HTMLElement2_get_onrowsdelete,
3191 HTMLElement2_put_onrowsinserted,
3192 HTMLElement2_get_onrowsinserted,
3193 HTMLElement2_put_oncellchange,
3194 HTMLElement2_get_oncellchange,
3195 HTMLElement2_put_dir,
3196 HTMLElement2_get_dir,
3197 HTMLElement2_createControlRange,
3198 HTMLElement2_get_scrollHeight,
3199 HTMLElement2_get_scrollWidth,
3200 HTMLElement2_put_scrollTop,
3201 HTMLElement2_get_scrollTop,
3202 HTMLElement2_put_scrollLeft,
3203 HTMLElement2_get_scrollLeft,
3204 HTMLElement2_clearAttributes,
3205 HTMLElement2_mergeAttributes,
3206 HTMLElement2_put_oncontextmenu,
3207 HTMLElement2_get_oncontextmenu,
3208 HTMLElement2_insertAdjacentElement,
3209 HTMLElement2_applyElement,
3210 HTMLElement2_getAdjacentText,
3211 HTMLElement2_replaceAdjacentText,
3212 HTMLElement2_get_canHandleChildren,
3213 HTMLElement2_addBehavior,
3214 HTMLElement2_removeBehavior,
3215 HTMLElement2_get_runtimeStyle,
3216 HTMLElement2_get_behaviorUrns,
3217 HTMLElement2_put_tagUrn,
3218 HTMLElement2_get_tagUrn,
3219 HTMLElement2_put_onbeforeeditfocus,
3220 HTMLElement2_get_onbeforeeditfocus,
3221 HTMLElement2_get_readyStateValue,
3222 HTMLElement2_getElementsByTagName,
3225 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3227 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3230 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3231 REFIID riid, void **ppv)
3233 HTMLElement *This = impl_from_IHTMLElement3(iface);
3234 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3237 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3239 HTMLElement *This = impl_from_IHTMLElement3(iface);
3240 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3243 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3245 HTMLElement *This = impl_from_IHTMLElement3(iface);
3246 return IHTMLElement_Release(&This->IHTMLElement_iface);
3249 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3251 HTMLElement *This = impl_from_IHTMLElement3(iface);
3252 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3255 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3256 LCID lcid, ITypeInfo **ppTInfo)
3258 HTMLElement *This = impl_from_IHTMLElement3(iface);
3259 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3262 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3263 LPOLESTR *rgszNames, UINT cNames,
3264 LCID lcid, DISPID *rgDispId)
3266 HTMLElement *This = impl_from_IHTMLElement3(iface);
3267 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3268 lcid, rgDispId);
3271 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3272 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3273 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3275 HTMLElement *This = impl_from_IHTMLElement3(iface);
3276 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3277 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3280 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3282 HTMLElement *This = impl_from_IHTMLElement3(iface);
3283 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3284 return E_NOTIMPL;
3287 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3289 HTMLElement *This = impl_from_IHTMLElement3(iface);
3290 FIXME("(%p)->(%p)\n", This, p);
3291 return E_NOTIMPL;
3294 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3296 HTMLElement *This = impl_from_IHTMLElement3(iface);
3297 FIXME("(%p)->(%p)\n", This, p);
3298 return E_NOTIMPL;
3301 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3303 HTMLElement *This = impl_from_IHTMLElement3(iface);
3304 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3305 return E_NOTIMPL;
3308 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3310 HTMLElement *This = impl_from_IHTMLElement3(iface);
3311 FIXME("(%p)->(%p)\n", This, p);
3312 return E_NOTIMPL;
3315 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3317 HTMLElement *This = impl_from_IHTMLElement3(iface);
3318 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3319 return E_NOTIMPL;
3322 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3324 HTMLElement *This = impl_from_IHTMLElement3(iface);
3325 FIXME("(%p)->(%p)\n", This, p);
3326 return E_NOTIMPL;
3329 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3331 HTMLElement *This = impl_from_IHTMLElement3(iface);
3332 FIXME("(%p)->(%x)\n", This, v);
3333 return E_NOTIMPL;
3336 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3338 HTMLElement *This = impl_from_IHTMLElement3(iface);
3339 FIXME("(%p)->(%p)\n", This, p);
3340 return E_NOTIMPL;
3343 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3345 HTMLElement *This = impl_from_IHTMLElement3(iface);
3346 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3347 return E_NOTIMPL;
3350 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3352 HTMLElement *This = impl_from_IHTMLElement3(iface);
3353 FIXME("(%p)->(%p)\n", This, p);
3354 return E_NOTIMPL;
3357 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3359 HTMLElement *This = impl_from_IHTMLElement3(iface);
3360 FIXME("(%p)\n", This);
3361 return E_NOTIMPL;
3364 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3366 HTMLElement *This = impl_from_IHTMLElement3(iface);
3367 nsresult nsres;
3368 nsAString str;
3370 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3372 nsAString_InitDepend(&str, v);
3373 nsres = nsIDOMHTMLElement_SetContentEditable(This->nselem, &str);
3374 nsAString_Finish(&str);
3376 if (NS_FAILED(nsres)){
3377 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3378 return E_FAIL;
3381 return S_OK;
3384 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3386 HTMLElement *This = impl_from_IHTMLElement3(iface);
3387 nsresult nsres;
3388 nsAString str;
3390 TRACE("(%p)->(%p)\n", This, p);
3392 nsAString_Init(&str, NULL);
3393 nsres = nsIDOMHTMLElement_GetContentEditable(This->nselem, &str);
3394 return return_nsstr(nsres, &str, p);
3397 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3399 HTMLElement *This = impl_from_IHTMLElement3(iface);
3400 FIXME("(%p)->(%p)\n", This, p);
3401 return E_NOTIMPL;
3404 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3406 HTMLElement *This = impl_from_IHTMLElement3(iface);
3407 FIXME("(%p)->(%x)\n", This, v);
3408 return E_NOTIMPL;
3411 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3413 HTMLElement *This = impl_from_IHTMLElement3(iface);
3414 FIXME("(%p)->(%p)\n", This, p);
3415 return E_NOTIMPL;
3418 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3420 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3422 HTMLElement *This = impl_from_IHTMLElement3(iface);
3423 VARIANT *var;
3424 HRESULT hres;
3426 TRACE("(%p)->(%x)\n", This, v);
3428 if(This->node.vtbl->put_disabled)
3429 return This->node.vtbl->put_disabled(&This->node, v);
3431 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3432 if(FAILED(hres))
3433 return hres;
3435 VariantClear(var);
3436 V_VT(var) = VT_BOOL;
3437 V_BOOL(var) = v;
3438 return S_OK;
3441 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3443 HTMLElement *This = impl_from_IHTMLElement3(iface);
3444 VARIANT *var;
3445 HRESULT hres;
3447 TRACE("(%p)->(%p)\n", This, p);
3449 if(This->node.vtbl->get_disabled)
3450 return This->node.vtbl->get_disabled(&This->node, p);
3452 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3453 if(hres == DISP_E_UNKNOWNNAME) {
3454 *p = VARIANT_FALSE;
3455 return S_OK;
3457 if(FAILED(hres))
3458 return hres;
3460 if(V_VT(var) != VT_BOOL) {
3461 FIXME("value is %s\n", debugstr_variant(var));
3462 return E_NOTIMPL;
3465 *p = V_BOOL(var);
3466 return S_OK;
3469 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3471 HTMLElement *This = impl_from_IHTMLElement3(iface);
3472 FIXME("(%p)->(%p)\n", This, p);
3473 return E_NOTIMPL;
3476 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3478 HTMLElement *This = impl_from_IHTMLElement3(iface);
3479 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3480 return E_NOTIMPL;
3483 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3485 HTMLElement *This = impl_from_IHTMLElement3(iface);
3486 FIXME("(%p)->(%p)\n", This, p);
3487 return E_NOTIMPL;
3490 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3492 HTMLElement *This = impl_from_IHTMLElement3(iface);
3493 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3494 return E_NOTIMPL;
3497 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3499 HTMLElement *This = impl_from_IHTMLElement3(iface);
3500 FIXME("(%p)->(%p)\n", This, p);
3501 return E_NOTIMPL;
3504 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3505 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3507 HTMLElement *This = impl_from_IHTMLElement3(iface);
3509 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3510 pfCancelled);
3512 return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3515 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
3517 HTMLElement *This = impl_from_IHTMLElement3(iface);
3518 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3519 return E_NOTIMPL;
3522 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
3524 HTMLElement *This = impl_from_IHTMLElement3(iface);
3525 FIXME("(%p)->(%p)\n", This, p);
3526 return E_NOTIMPL;
3529 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3531 HTMLElement *This = impl_from_IHTMLElement3(iface);
3532 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3533 return E_NOTIMPL;
3536 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3538 HTMLElement *This = impl_from_IHTMLElement3(iface);
3539 FIXME("(%p)->(%p)\n", This, p);
3540 return E_NOTIMPL;
3543 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3545 HTMLElement *This = impl_from_IHTMLElement3(iface);
3546 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3547 return E_NOTIMPL;
3550 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3552 HTMLElement *This = impl_from_IHTMLElement3(iface);
3553 FIXME("(%p)->(%p)\n", This, p);
3554 return E_NOTIMPL;
3557 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3559 HTMLElement *This = impl_from_IHTMLElement3(iface);
3560 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3561 return E_NOTIMPL;
3564 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3566 HTMLElement *This = impl_from_IHTMLElement3(iface);
3567 FIXME("(%p)->(%p)\n", This, p);
3568 return E_NOTIMPL;
3571 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3573 HTMLElement *This = impl_from_IHTMLElement3(iface);
3574 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3575 return E_NOTIMPL;
3578 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3580 HTMLElement *This = impl_from_IHTMLElement3(iface);
3581 FIXME("(%p)->(%p)\n", This, p);
3582 return E_NOTIMPL;
3585 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3587 HTMLElement *This = impl_from_IHTMLElement3(iface);
3588 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3589 return E_NOTIMPL;
3592 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3594 HTMLElement *This = impl_from_IHTMLElement3(iface);
3595 FIXME("(%p)->(%p)\n", This, p);
3596 return E_NOTIMPL;
3599 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3601 HTMLElement *This = impl_from_IHTMLElement3(iface);
3602 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3603 return E_NOTIMPL;
3606 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3608 HTMLElement *This = impl_from_IHTMLElement3(iface);
3609 FIXME("(%p)->(%p)\n", This, p);
3610 return E_NOTIMPL;
3613 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3615 HTMLElement *This = impl_from_IHTMLElement3(iface);
3616 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3617 return E_NOTIMPL;
3620 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3622 HTMLElement *This = impl_from_IHTMLElement3(iface);
3623 FIXME("(%p)->(%p)\n", This, p);
3624 return E_NOTIMPL;
3627 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3629 HTMLElement *This = impl_from_IHTMLElement3(iface);
3630 FIXME("(%p)->(%p)\n", This, pfRet);
3631 return E_NOTIMPL;
3634 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3636 HTMLElement *This = impl_from_IHTMLElement3(iface);
3637 FIXME("(%p)->(%p)\n", This, p);
3638 return E_NOTIMPL;
3641 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3642 HTMLElement3_QueryInterface,
3643 HTMLElement3_AddRef,
3644 HTMLElement3_Release,
3645 HTMLElement3_GetTypeInfoCount,
3646 HTMLElement3_GetTypeInfo,
3647 HTMLElement3_GetIDsOfNames,
3648 HTMLElement3_Invoke,
3649 HTMLElement3_mergeAttributes,
3650 HTMLElement3_get_isMultiLine,
3651 HTMLElement3_get_canHaveHTML,
3652 HTMLElement3_put_onlayoutcomplete,
3653 HTMLElement3_get_onlayoutcomplete,
3654 HTMLElement3_put_onpage,
3655 HTMLElement3_get_onpage,
3656 HTMLElement3_put_inflateBlock,
3657 HTMLElement3_get_inflateBlock,
3658 HTMLElement3_put_onbeforedeactivate,
3659 HTMLElement3_get_onbeforedeactivate,
3660 HTMLElement3_setActive,
3661 HTMLElement3_put_contentEditable,
3662 HTMLElement3_get_contentEditable,
3663 HTMLElement3_get_isContentEditable,
3664 HTMLElement3_put_hideFocus,
3665 HTMLElement3_get_hideFocus,
3666 HTMLElement3_put_disabled,
3667 HTMLElement3_get_disabled,
3668 HTMLElement3_get_isDisabled,
3669 HTMLElement3_put_onmove,
3670 HTMLElement3_get_onmove,
3671 HTMLElement3_put_oncontrolselect,
3672 HTMLElement3_get_oncontrolselect,
3673 HTMLElement3_fireEvent,
3674 HTMLElement3_put_onresizestart,
3675 HTMLElement3_get_onresizestart,
3676 HTMLElement3_put_onresizeend,
3677 HTMLElement3_get_onresizeend,
3678 HTMLElement3_put_onmovestart,
3679 HTMLElement3_get_onmovestart,
3680 HTMLElement3_put_onmoveend,
3681 HTMLElement3_get_onmoveend,
3682 HTMLElement3_put_onmousecenter,
3683 HTMLElement3_get_onmousecenter,
3684 HTMLElement3_put_onmouseleave,
3685 HTMLElement3_get_onmouseleave,
3686 HTMLElement3_put_onactivate,
3687 HTMLElement3_get_onactivate,
3688 HTMLElement3_put_ondeactivate,
3689 HTMLElement3_get_ondeactivate,
3690 HTMLElement3_dragDrop,
3691 HTMLElement3_get_glyphMode
3694 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3696 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3699 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3700 REFIID riid, void **ppv)
3702 HTMLElement *This = impl_from_IHTMLElement4(iface);
3703 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3706 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3708 HTMLElement *This = impl_from_IHTMLElement4(iface);
3709 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3712 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3714 HTMLElement *This = impl_from_IHTMLElement4(iface);
3715 return IHTMLElement_Release(&This->IHTMLElement_iface);
3718 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3720 HTMLElement *This = impl_from_IHTMLElement4(iface);
3721 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3724 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3725 LCID lcid, ITypeInfo **ppTInfo)
3727 HTMLElement *This = impl_from_IHTMLElement4(iface);
3728 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3731 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3732 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3734 HTMLElement *This = impl_from_IHTMLElement4(iface);
3735 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3736 lcid, rgDispId);
3739 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3740 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3742 HTMLElement *This = impl_from_IHTMLElement4(iface);
3743 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3744 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3747 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3749 HTMLElement *This = impl_from_IHTMLElement4(iface);
3751 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3753 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3756 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3758 HTMLElement *This = impl_from_IHTMLElement4(iface);
3760 TRACE("(%p)->(%p)\n", This, p);
3762 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3765 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3767 HTMLElement *This = impl_from_IHTMLElement4(iface);
3768 FIXME("(%p)\n", This);
3769 return E_NOTIMPL;
3772 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3774 HTMLElement *This = impl_from_IHTMLElement4(iface);
3775 HTMLAttributeCollection *attrs;
3776 HRESULT hres;
3778 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3780 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3781 if(FAILED(hres))
3782 return hres;
3784 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3785 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3786 return hres;
3789 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3790 IHTMLDOMAttribute **ppretAttribute)
3792 HTMLElement *This = impl_from_IHTMLElement4(iface);
3793 HTMLDOMAttribute *attr, *iter, *replace = NULL;
3794 HTMLAttributeCollection *attrs;
3795 DISPID dispid;
3796 HRESULT hres;
3798 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3800 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
3801 if(!attr)
3802 return E_INVALIDARG;
3804 if(attr->elem) {
3805 WARN("Tried to set already attached attribute.\n");
3806 return E_INVALIDARG;
3809 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
3810 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
3811 if(FAILED(hres))
3812 return hres;
3814 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3815 if(FAILED(hres))
3816 return hres;
3818 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
3819 if(iter->dispid == dispid) {
3820 replace = iter;
3821 break;
3825 if(replace) {
3826 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
3827 if(FAILED(hres)) {
3828 WARN("could not get attr value: %08x\n", hres);
3829 V_VT(&replace->value) = VT_EMPTY;
3831 if(!replace->name) {
3832 replace->name = attr->name;
3833 attr->name = NULL;
3835 list_add_head(&replace->entry, &attr->entry);
3836 list_remove(&replace->entry);
3837 replace->elem = NULL;
3838 }else {
3839 list_add_tail(&attrs->attrs, &attr->entry);
3842 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
3843 attr->elem = This;
3844 attr->dispid = dispid;
3846 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3848 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
3849 if(FAILED(hres))
3850 WARN("Could not set attribute value: %08x\n", hres);
3851 VariantClear(&attr->value);
3853 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
3854 return S_OK;
3857 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3858 IHTMLDOMAttribute **ppretAttribute)
3860 HTMLElement *This = impl_from_IHTMLElement4(iface);
3861 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3862 return E_NOTIMPL;
3865 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3867 HTMLElement *This = impl_from_IHTMLElement4(iface);
3868 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3869 return E_NOTIMPL;
3872 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3874 HTMLElement *This = impl_from_IHTMLElement4(iface);
3875 FIXME("(%p)->(%p)\n", This, p);
3876 return E_NOTIMPL;
3879 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3881 HTMLElement *This = impl_from_IHTMLElement4(iface);
3883 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3885 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3888 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3890 HTMLElement *This = impl_from_IHTMLElement4(iface);
3892 TRACE("(%p)->(%p)\n", This, p);
3894 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3897 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3899 HTMLElement *This = impl_from_IHTMLElement4(iface);
3901 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3903 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
3906 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3908 HTMLElement *This = impl_from_IHTMLElement4(iface);
3910 TRACE("(%p)->(%p)\n", This, p);
3912 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
3915 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3916 HTMLElement4_QueryInterface,
3917 HTMLElement4_AddRef,
3918 HTMLElement4_Release,
3919 HTMLElement4_GetTypeInfoCount,
3920 HTMLElement4_GetTypeInfo,
3921 HTMLElement4_GetIDsOfNames,
3922 HTMLElement4_Invoke,
3923 HTMLElement4_put_onmousewheel,
3924 HTMLElement4_get_onmousewheel,
3925 HTMLElement4_normalize,
3926 HTMLElement4_getAttributeNode,
3927 HTMLElement4_setAttributeNode,
3928 HTMLElement4_removeAttributeNode,
3929 HTMLElement4_put_onbeforeactivate,
3930 HTMLElement4_get_onbeforeactivate,
3931 HTMLElement4_put_onfocusin,
3932 HTMLElement4_get_onfocusin,
3933 HTMLElement4_put_onfocusout,
3934 HTMLElement4_get_onfocusout
3937 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
3939 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
3942 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
3943 REFIID riid, void **ppv)
3945 HTMLElement *This = impl_from_IHTMLElement6(iface);
3946 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3949 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
3951 HTMLElement *This = impl_from_IHTMLElement6(iface);
3952 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3955 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
3957 HTMLElement *This = impl_from_IHTMLElement6(iface);
3958 return IHTMLElement_Release(&This->IHTMLElement_iface);
3961 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
3963 HTMLElement *This = impl_from_IHTMLElement6(iface);
3964 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3967 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
3968 LCID lcid, ITypeInfo **ppTInfo)
3970 HTMLElement *This = impl_from_IHTMLElement6(iface);
3971 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3974 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
3975 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3977 HTMLElement *This = impl_from_IHTMLElement6(iface);
3978 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3979 lcid, rgDispId);
3982 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
3983 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3985 HTMLElement *This = impl_from_IHTMLElement6(iface);
3986 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3987 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3990 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
3992 HTMLElement *This = impl_from_IHTMLElement6(iface);
3993 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
3994 return E_NOTIMPL;
3997 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
3999 HTMLElement *This = impl_from_IHTMLElement6(iface);
4000 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4001 return E_NOTIMPL;
4004 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4006 HTMLElement *This = impl_from_IHTMLElement6(iface);
4007 FIXME("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4008 return E_NOTIMPL;
4011 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4013 HTMLElement *This = impl_from_IHTMLElement6(iface);
4014 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4015 return E_NOTIMPL;
4018 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4020 HTMLElement *This = impl_from_IHTMLElement6(iface);
4021 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4022 return E_NOTIMPL;
4025 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4027 HTMLElement *This = impl_from_IHTMLElement6(iface);
4028 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4029 return E_NOTIMPL;
4032 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4034 HTMLElement *This = impl_from_IHTMLElement6(iface);
4035 FIXME("(%p)->(%s %p)\n", This, debugstr_w(strAttributeName), AttributeValue);
4036 return E_NOTIMPL;
4039 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4041 HTMLElement *This = impl_from_IHTMLElement6(iface);
4042 FIXME("(%p)->(%s %p)\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4043 return E_NOTIMPL;
4046 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4048 HTMLElement *This = impl_from_IHTMLElement6(iface);
4049 FIXME("(%p)->(%s)\n", This, debugstr_w(strAttributeName));
4050 return E_NOTIMPL;
4053 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4055 HTMLElement *This = impl_from_IHTMLElement6(iface);
4056 FIXME("(%p)->(%s %p)\n", This, debugstr_w(strAttributeName), ppretAttribute);
4057 return E_NOTIMPL;
4060 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4062 HTMLElement *This = impl_from_IHTMLElement6(iface);
4063 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4064 return E_NOTIMPL;
4067 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4069 HTMLElement *This = impl_from_IHTMLElement6(iface);
4070 FIXME("(%p)->()\n", This);
4071 return E_NOTIMPL;
4074 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *pfHasAttribute)
4076 HTMLElement *This = impl_from_IHTMLElement6(iface);
4077 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), pfHasAttribute);
4078 return E_NOTIMPL;
4081 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
4083 HTMLElement *This = impl_from_IHTMLElement6(iface);
4084 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
4085 return E_NOTIMPL;
4088 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
4090 HTMLElement *This = impl_from_IHTMLElement6(iface);
4091 FIXME("(%p)->(%p)\n", This, p);
4092 return E_NOTIMPL;
4095 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
4097 HTMLElement *This = impl_from_IHTMLElement6(iface);
4098 FIXME("(%p)->(%p)\n", This, p);
4099 return E_NOTIMPL;
4102 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
4104 HTMLElement *This = impl_from_IHTMLElement6(iface);
4105 nsIDOMHTMLCollection *nscol = NULL;
4106 nsAString nsstr;
4107 nsresult nsres;
4109 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4111 if(This->nselem) {
4112 nsAString_InitDepend(&nsstr, v);
4113 nsres = nsIDOMHTMLElement_GetElementsByClassName(This->nselem, &nsstr, &nscol);
4114 nsAString_Finish(&nsstr);
4115 if(NS_FAILED(nsres)) {
4116 ERR("GetElementsByClassName failed: %08x\n", nsres);
4117 return E_FAIL;
4121 *pel = create_collection_from_htmlcol(This->node.doc, nscol);
4122 nsIDOMHTMLCollection_Release(nscol);
4123 return S_OK;
4126 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
4128 HTMLElement *This = impl_from_IHTMLElement6(iface);
4129 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
4130 return E_NOTIMPL;
4133 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
4135 HTMLElement *This = impl_from_IHTMLElement6(iface);
4137 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4139 return set_node_event(&This->node, EVENTID_ABORT, &v);
4142 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
4144 HTMLElement *This = impl_from_IHTMLElement6(iface);
4146 TRACE("(%p)->(%p)\n", This, p);
4148 return get_node_event(&This->node, EVENTID_ABORT, p);
4151 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
4153 HTMLElement *This = impl_from_IHTMLElement6(iface);
4154 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4155 return E_NOTIMPL;
4158 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
4160 HTMLElement *This = impl_from_IHTMLElement6(iface);
4161 FIXME("(%p)->(%p)\n", This, p);
4162 return E_NOTIMPL;
4165 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
4167 HTMLElement *This = impl_from_IHTMLElement6(iface);
4168 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4169 return E_NOTIMPL;
4172 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
4174 HTMLElement *This = impl_from_IHTMLElement6(iface);
4175 FIXME("(%p)->(%p)\n", This, p);
4176 return E_NOTIMPL;
4179 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
4181 HTMLElement *This = impl_from_IHTMLElement6(iface);
4183 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4185 return set_node_event(&This->node, EVENTID_CHANGE, &v);
4188 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
4190 HTMLElement *This = impl_from_IHTMLElement6(iface);
4192 TRACE("(%p)->(%p)\n", This, p);
4194 return get_node_event(&This->node, EVENTID_CHANGE, p);
4197 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
4199 HTMLElement *This = impl_from_IHTMLElement6(iface);
4200 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4201 return E_NOTIMPL;
4204 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
4206 HTMLElement *This = impl_from_IHTMLElement6(iface);
4207 FIXME("(%p)->(%p)\n", This, p);
4208 return E_NOTIMPL;
4211 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
4213 HTMLElement *This = impl_from_IHTMLElement6(iface);
4214 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4215 return E_NOTIMPL;
4218 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
4220 HTMLElement *This = impl_from_IHTMLElement6(iface);
4221 FIXME("(%p)->(%p)\n", This, p);
4222 return E_NOTIMPL;
4225 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
4227 HTMLElement *This = impl_from_IHTMLElement6(iface);
4228 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4229 return E_NOTIMPL;
4232 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
4234 HTMLElement *This = impl_from_IHTMLElement6(iface);
4235 FIXME("(%p)->(%p)\n", This, p);
4236 return E_NOTIMPL;
4239 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
4241 HTMLElement *This = impl_from_IHTMLElement6(iface);
4243 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4245 return set_node_event(&This->node, EVENTID_ERROR, &v);
4248 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
4250 HTMLElement *This = impl_from_IHTMLElement6(iface);
4252 TRACE("(%p)->(%p)\n", This, p);
4254 return get_node_event(&This->node, EVENTID_ERROR, p);
4257 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
4259 HTMLElement *This = impl_from_IHTMLElement6(iface);
4260 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4261 return E_NOTIMPL;
4264 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
4266 HTMLElement *This = impl_from_IHTMLElement6(iface);
4267 FIXME("(%p)->(%p)\n", This, p);
4268 return E_NOTIMPL;
4271 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
4273 HTMLElement *This = impl_from_IHTMLElement6(iface);
4275 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4277 return set_node_event(&This->node, EVENTID_LOAD, &v);
4280 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
4282 HTMLElement *This = impl_from_IHTMLElement6(iface);
4284 TRACE("(%p)->(%p)\n", This, p);
4286 return get_node_event(&This->node, EVENTID_LOAD, p);
4289 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
4291 HTMLElement *This = impl_from_IHTMLElement6(iface);
4292 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4293 return E_NOTIMPL;
4296 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
4298 HTMLElement *This = impl_from_IHTMLElement6(iface);
4299 FIXME("(%p)->(%p)\n", This, p);
4300 return E_NOTIMPL;
4303 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
4305 HTMLElement *This = impl_from_IHTMLElement6(iface);
4306 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4307 return E_NOTIMPL;
4310 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
4312 HTMLElement *This = impl_from_IHTMLElement6(iface);
4313 FIXME("(%p)->(%p)\n", This, p);
4314 return E_NOTIMPL;
4317 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
4319 HTMLElement *This = impl_from_IHTMLElement6(iface);
4320 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4321 return E_NOTIMPL;
4324 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
4326 HTMLElement *This = impl_from_IHTMLElement6(iface);
4327 FIXME("(%p)->(%p)\n", This, p);
4328 return E_NOTIMPL;
4331 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
4333 HTMLElement *This = impl_from_IHTMLElement6(iface);
4334 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4335 return E_NOTIMPL;
4338 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
4340 HTMLElement *This = impl_from_IHTMLElement6(iface);
4341 FIXME("(%p)->(%p)\n", This, p);
4342 return E_NOTIMPL;
4345 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
4347 HTMLElement *This = impl_from_IHTMLElement6(iface);
4348 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4349 return E_NOTIMPL;
4352 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
4354 HTMLElement *This = impl_from_IHTMLElement6(iface);
4355 FIXME("(%p)->(%p)\n", This, p);
4356 return E_NOTIMPL;
4359 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
4361 HTMLElement *This = impl_from_IHTMLElement6(iface);
4362 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4363 return E_NOTIMPL;
4366 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
4368 HTMLElement *This = impl_from_IHTMLElement6(iface);
4369 FIXME("(%p)->(%p)\n", This, p);
4370 return E_NOTIMPL;
4373 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
4375 HTMLElement *This = impl_from_IHTMLElement6(iface);
4376 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4377 return E_NOTIMPL;
4380 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
4382 HTMLElement *This = impl_from_IHTMLElement6(iface);
4383 FIXME("(%p)->(%p)\n", This, p);
4384 return E_NOTIMPL;
4387 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
4389 HTMLElement *This = impl_from_IHTMLElement6(iface);
4390 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4391 return E_NOTIMPL;
4394 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
4396 HTMLElement *This = impl_from_IHTMLElement6(iface);
4397 FIXME("(%p)->(%p)\n", This, p);
4398 return E_NOTIMPL;
4401 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
4403 HTMLElement *This = impl_from_IHTMLElement6(iface);
4404 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4405 return E_NOTIMPL;
4408 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
4410 HTMLElement *This = impl_from_IHTMLElement6(iface);
4411 FIXME("(%p)->(%p)\n", This, p);
4412 return E_NOTIMPL;
4415 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
4417 HTMLElement *This = impl_from_IHTMLElement6(iface);
4418 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4419 return E_NOTIMPL;
4422 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
4424 HTMLElement *This = impl_from_IHTMLElement6(iface);
4425 FIXME("(%p)->(%p)\n", This, p);
4426 return E_NOTIMPL;
4429 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
4431 HTMLElement *This = impl_from_IHTMLElement6(iface);
4432 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4433 return E_NOTIMPL;
4436 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
4438 HTMLElement *This = impl_from_IHTMLElement6(iface);
4439 FIXME("(%p)->(%p)\n", This, p);
4440 return E_NOTIMPL;
4443 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
4445 HTMLElement *This = impl_from_IHTMLElement6(iface);
4446 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4447 return E_NOTIMPL;
4450 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
4452 HTMLElement *This = impl_from_IHTMLElement6(iface);
4453 FIXME("(%p)->(%p)\n", This, p);
4454 return E_NOTIMPL;
4457 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
4459 HTMLElement *This = impl_from_IHTMLElement6(iface);
4460 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4461 return E_NOTIMPL;
4464 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
4466 HTMLElement *This = impl_from_IHTMLElement6(iface);
4467 FIXME("(%p)->(%p)\n", This, p);
4468 return E_NOTIMPL;
4471 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
4473 HTMLElement *This = impl_from_IHTMLElement6(iface);
4475 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4477 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
4480 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
4482 HTMLElement *This = impl_from_IHTMLElement6(iface);
4484 TRACE("(%p)->(%p)\n", This, p);
4486 return get_node_event(&This->node, EVENTID_SUBMIT, p);
4489 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
4491 HTMLElement *This = impl_from_IHTMLElement6(iface);
4492 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4493 return E_NOTIMPL;
4496 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
4498 HTMLElement *This = impl_from_IHTMLElement6(iface);
4499 FIXME("(%p)->(%p)\n", This, p);
4500 return E_NOTIMPL;
4503 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
4505 HTMLElement *This = impl_from_IHTMLElement6(iface);
4506 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4507 return E_NOTIMPL;
4510 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
4512 HTMLElement *This = impl_from_IHTMLElement6(iface);
4513 FIXME("(%p)->(%p)\n", This, p);
4514 return E_NOTIMPL;
4517 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
4519 HTMLElement *This = impl_from_IHTMLElement6(iface);
4520 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4521 return E_NOTIMPL;
4524 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
4526 HTMLElement *This = impl_from_IHTMLElement6(iface);
4527 FIXME("(%p)->(%p)\n", This, p);
4528 return E_NOTIMPL;
4531 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
4533 HTMLElement *This = impl_from_IHTMLElement6(iface);
4534 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4535 return E_NOTIMPL;
4538 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
4540 HTMLElement *This = impl_from_IHTMLElement6(iface);
4541 FIXME("(%p)->(%p)\n", This, p);
4542 return E_NOTIMPL;
4545 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
4547 HTMLElement *This = impl_from_IHTMLElement6(iface);
4548 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
4549 return E_NOTIMPL;
4552 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
4553 HTMLElement6_QueryInterface,
4554 HTMLElement6_AddRef,
4555 HTMLElement6_Release,
4556 HTMLElement6_GetTypeInfoCount,
4557 HTMLElement6_GetTypeInfo,
4558 HTMLElement6_GetIDsOfNames,
4559 HTMLElement6_Invoke,
4560 HTMLElement6_getAttributeNS,
4561 HTMLElement6_setAttributeNS,
4562 HTMLElement6_removeAttributeNS,
4563 HTMLElement6_getAttributeNodeNS,
4564 HTMLElement6_setAttributeNodeNS,
4565 HTMLElement6_hasAttributeNS,
4566 HTMLElement6_getAttribute,
4567 HTMLElement6_setAttribute,
4568 HTMLElement6_removeAttribute,
4569 HTMLElement6_getAttributeNode,
4570 HTMLElement6_setAttributeNode,
4571 HTMLElement6_removeAttributeNode,
4572 HTMLElement6_hasAttribute,
4573 HTMLElement6_getElementsByTagNameNS,
4574 HTMLElement6_get_tagName,
4575 HTMLElement6_get_nodeName,
4576 HTMLElement6_getElementsByClassName,
4577 HTMLElement6_msMatchesSelector,
4578 HTMLElement6_put_onabort,
4579 HTMLElement6_get_onabort,
4580 HTMLElement6_put_oncanplay,
4581 HTMLElement6_get_oncanplay,
4582 HTMLElement6_put_oncanplaythrough,
4583 HTMLElement6_get_oncanplaythrough,
4584 HTMLElement6_put_onchange,
4585 HTMLElement6_get_onchange,
4586 HTMLElement6_put_ondurationchange,
4587 HTMLElement6_get_ondurationchange,
4588 HTMLElement6_put_onemptied,
4589 HTMLElement6_get_onemptied,
4590 HTMLElement6_put_onended,
4591 HTMLElement6_get_onended,
4592 HTMLElement6_put_onerror,
4593 HTMLElement6_get_onerror,
4594 HTMLElement6_put_oninput,
4595 HTMLElement6_get_oninput,
4596 HTMLElement6_put_onload,
4597 HTMLElement6_get_onload,
4598 HTMLElement6_put_onloadeddata,
4599 HTMLElement6_get_onloadeddata,
4600 HTMLElement6_put_onloadedmetadata,
4601 HTMLElement6_get_onloadedmetadata,
4602 HTMLElement6_put_onloadstart,
4603 HTMLElement6_get_onloadstart,
4604 HTMLElement6_put_onpause,
4605 HTMLElement6_get_onpause,
4606 HTMLElement6_put_onplay,
4607 HTMLElement6_get_onplay,
4608 HTMLElement6_put_onplaying,
4609 HTMLElement6_get_onplaying,
4610 HTMLElement6_put_onprogress,
4611 HTMLElement6_get_onprogress,
4612 HTMLElement6_put_onratechange,
4613 HTMLElement6_get_onratechange,
4614 HTMLElement6_put_onreset,
4615 HTMLElement6_get_onreset,
4616 HTMLElement6_put_onseeked,
4617 HTMLElement6_get_onseeked,
4618 HTMLElement6_put_onseeking,
4619 HTMLElement6_get_onseeking,
4620 HTMLElement6_put_onselect,
4621 HTMLElement6_get_onselect,
4622 HTMLElement6_put_onstalled,
4623 HTMLElement6_get_onstalled,
4624 HTMLElement6_put_onsubmit,
4625 HTMLElement6_get_onsubmit,
4626 HTMLElement6_put_onsuspend,
4627 HTMLElement6_get_onsuspend,
4628 HTMLElement6_put_ontimeupdate,
4629 HTMLElement6_get_ontimeupdate,
4630 HTMLElement6_put_onvolumechange,
4631 HTMLElement6_get_onvolumechange,
4632 HTMLElement6_put_onwaiting,
4633 HTMLElement6_get_onwaiting,
4634 HTMLElement6_hasAttributes
4637 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
4639 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
4642 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
4644 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4645 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4648 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
4650 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4651 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4654 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
4656 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4657 return IHTMLElement_Release(&This->IHTMLElement_iface);
4660 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
4662 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4663 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4666 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
4667 LCID lcid, ITypeInfo **ppTInfo)
4669 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4670 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4673 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
4674 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4676 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4677 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4678 lcid, rgDispId);
4681 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
4682 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4684 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4685 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4686 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4689 HRESULT elem_unique_id(unsigned id, BSTR *p)
4691 WCHAR buf[32];
4693 static const WCHAR formatW[] = {'m','s','_','_','i','d','%','u',0};
4695 sprintfW(buf, formatW, id);
4696 *p = SysAllocString(buf);
4697 return *p ? S_OK : E_OUTOFMEMORY;
4700 static void ensure_unique_id(HTMLElement *elem)
4702 if(!elem->unique_id)
4703 elem->unique_id = ++elem->node.doc->unique_id;
4706 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
4708 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4710 TRACE("(%p)->(%p)\n", This, p);
4712 ensure_unique_id(This);
4713 *p = This->unique_id;
4714 return S_OK;
4717 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
4719 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4721 TRACE("(%p)->(%p)\n", This, p);
4723 ensure_unique_id(This);
4724 return elem_unique_id(This->unique_id, p);
4727 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
4728 HTMLUniqueName_QueryInterface,
4729 HTMLUniqueName_AddRef,
4730 HTMLUniqueName_Release,
4731 HTMLUniqueName_GetTypeInfoCount,
4732 HTMLUniqueName_GetTypeInfo,
4733 HTMLUniqueName_GetIDsOfNames,
4734 HTMLUniqueName_Invoke,
4735 HTMLUniqueName_get_uniqueNumber,
4736 HTMLUniqueName_get_uniqueID
4739 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
4741 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
4744 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
4746 HTMLElement *This = impl_from_IElementSelector(iface);
4747 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4750 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
4752 HTMLElement *This = impl_from_IElementSelector(iface);
4753 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4756 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
4758 HTMLElement *This = impl_from_IElementSelector(iface);
4759 return IHTMLElement_Release(&This->IHTMLElement_iface);
4762 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
4764 HTMLElement *This = impl_from_IElementSelector(iface);
4765 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4768 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
4769 LCID lcid, ITypeInfo **ppTInfo)
4771 HTMLElement *This = impl_from_IElementSelector(iface);
4772 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4775 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
4776 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4778 HTMLElement *This = impl_from_IElementSelector(iface);
4779 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
4782 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
4783 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4785 HTMLElement *This = impl_from_IElementSelector(iface);
4786 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4787 pDispParams, pVarResult, pExcepInfo, puArgErr);
4790 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
4792 HTMLElement *This = impl_from_IElementSelector(iface);
4793 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4794 return E_NOTIMPL;
4797 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4799 HTMLElement *This = impl_from_IElementSelector(iface);
4800 nsIDOMNodeList *node_list;
4801 nsAString nsstr;
4802 nsresult nsres;
4804 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4806 nsAString_InitDepend(&nsstr, v);
4807 nsres = nsIDOMHTMLElement_QuerySelectorAll(This->nselem, &nsstr, &node_list);
4808 nsAString_Finish(&nsstr);
4809 if(NS_FAILED(nsres)) {
4810 ERR("QuerySelectorAll failed: %08x\n", nsres);
4811 return E_FAIL;
4814 *pel = create_child_collection(This->node.doc, node_list);
4815 nsIDOMNodeList_Release(node_list);
4816 return *pel ? S_OK : E_OUTOFMEMORY;
4819 static const IElementSelectorVtbl ElementSelectorVtbl = {
4820 ElementSelector_QueryInterface,
4821 ElementSelector_AddRef,
4822 ElementSelector_Release,
4823 ElementSelector_GetTypeInfoCount,
4824 ElementSelector_GetTypeInfo,
4825 ElementSelector_GetIDsOfNames,
4826 ElementSelector_Invoke,
4827 ElementSelector_querySelector,
4828 ElementSelector_querySelectorAll
4831 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4833 return CONTAINING_RECORD(iface, HTMLElement, node);
4836 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4838 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4840 if(IsEqualGUID(&IID_IUnknown, riid)) {
4841 *ppv = &This->IHTMLElement_iface;
4842 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
4843 *ppv = &This->IHTMLElement_iface;
4844 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
4845 *ppv = &This->IHTMLElement_iface;
4846 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
4847 *ppv = &This->IHTMLElement2_iface;
4848 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
4849 *ppv = &This->IHTMLElement3_iface;
4850 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
4851 *ppv = &This->IHTMLElement4_iface;
4852 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
4853 *ppv = &This->IHTMLElement6_iface;
4854 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
4855 *ppv = &This->IHTMLUniqueName_iface;
4856 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
4857 *ppv = &This->IElementSelector_iface;
4858 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
4859 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4860 }else {
4861 return HTMLDOMNode_QI(&This->node, riid, ppv);
4864 IUnknown_AddRef((IUnknown*)*ppv);
4865 return S_OK;
4868 void HTMLElement_destructor(HTMLDOMNode *iface)
4870 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4872 ConnectionPointContainer_Destroy(&This->cp_container);
4874 if(This->style) {
4875 This->style->elem = NULL;
4876 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
4878 if(This->runtime_style) {
4879 This->runtime_style->elem = NULL;
4880 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
4882 if(This->attrs) {
4883 HTMLDOMAttribute *attr;
4885 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
4886 attr->elem = NULL;
4888 This->attrs->elem = NULL;
4889 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
4892 heap_free(This->filter);
4894 HTMLDOMNode_destructor(&This->node);
4897 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4899 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4900 HTMLElement *new_elem;
4901 HRESULT hres;
4903 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
4904 if(FAILED(hres))
4905 return hres;
4907 if(This->filter) {
4908 new_elem->filter = heap_strdupW(This->filter);
4909 if(!new_elem->filter) {
4910 IHTMLElement_Release(&This->IHTMLElement_iface);
4911 return E_OUTOFMEMORY;
4915 *ret = &new_elem->node;
4916 return S_OK;
4919 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
4921 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4923 switch(eid) {
4924 case EVENTID_KEYDOWN: {
4925 nsIDOMKeyEvent *key_event;
4926 nsresult nsres;
4928 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
4929 if(NS_SUCCEEDED(nsres)) {
4930 UINT32 code = 0;
4932 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
4934 switch(code) {
4935 case VK_F1: /* DOM_VK_F1 */
4936 TRACE("F1 pressed\n");
4937 fire_event(This->node.doc, EVENTID_HELP, TRUE, &This->node, NULL, NULL);
4938 *prevent_default = TRUE;
4941 nsIDOMKeyEvent_Release(key_event);
4946 return S_OK;
4949 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
4951 const cpc_entry_t HTMLElement_cpc[] = {
4952 HTMLELEMENT_CPC,
4953 {NULL}
4956 static const NodeImplVtbl HTMLElementImplVtbl = {
4957 HTMLElement_QI,
4958 HTMLElement_destructor,
4959 HTMLElement_cpc,
4960 HTMLElement_clone,
4961 HTMLElement_handle_event,
4962 HTMLElement_get_attr_col
4965 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
4967 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
4970 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
4971 DWORD grfdex, DISPID *pid)
4973 HTMLElement *This = impl_from_DispatchEx(dispex);
4975 if(This->node.vtbl->get_dispid)
4976 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
4978 return DISP_E_UNKNOWNNAME;
4981 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4982 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
4983 IServiceProvider *caller)
4985 HTMLElement *This = impl_from_DispatchEx(dispex);
4987 if(This->node.vtbl->invoke)
4988 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
4989 params, res, ei, caller);
4991 ERR("(%p): element has no invoke method\n", This);
4992 return E_NOTIMPL;
4995 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
4997 HTMLElement *This = impl_from_DispatchEx(dispex);
4998 nsIDOMMozNamedAttrMap *attrs;
4999 nsIDOMAttr *attr;
5000 nsAString nsstr;
5001 const PRUnichar *str;
5002 BSTR name;
5003 VARIANT value;
5004 unsigned i;
5005 UINT32 len;
5006 DISPID id;
5007 nsresult nsres;
5008 HRESULT hres;
5010 if(!This->nselem)
5011 return S_FALSE;
5013 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
5014 if(NS_FAILED(nsres))
5015 return E_FAIL;
5017 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
5018 if(NS_FAILED(nsres)) {
5019 nsIDOMMozNamedAttrMap_Release(attrs);
5020 return E_FAIL;
5023 nsAString_Init(&nsstr, NULL);
5024 for(i=0; i<len; i++) {
5025 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
5026 if(NS_FAILED(nsres))
5027 continue;
5029 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
5030 if(NS_FAILED(nsres)) {
5031 nsIDOMAttr_Release(attr);
5032 continue;
5035 nsAString_GetData(&nsstr, &str);
5036 name = SysAllocString(str);
5037 if(!name) {
5038 nsIDOMAttr_Release(attr);
5039 continue;
5042 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
5043 if(hres != DISP_E_UNKNOWNNAME) {
5044 nsIDOMAttr_Release(attr);
5045 SysFreeString(name);
5046 continue;
5049 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
5050 nsIDOMAttr_Release(attr);
5051 if(NS_FAILED(nsres)) {
5052 SysFreeString(name);
5053 continue;
5056 nsAString_GetData(&nsstr, &str);
5057 V_VT(&value) = VT_BSTR;
5058 if(*str) {
5059 V_BSTR(&value) = SysAllocString(str);
5060 if(!V_BSTR(&value)) {
5061 SysFreeString(name);
5062 continue;
5064 } else
5065 V_BSTR(&value) = NULL;
5067 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
5068 SysFreeString(name);
5069 VariantClear(&value);
5071 nsAString_Finish(&nsstr);
5073 nsIDOMMozNamedAttrMap_Release(attrs);
5074 return S_OK;
5077 static event_target_t **HTMLElement_get_event_target_ptr(DispatchEx *dispex)
5079 HTMLElement *This = impl_from_DispatchEx(dispex);
5080 return This->node.vtbl->get_event_target_ptr
5081 ? This->node.vtbl->get_event_target_ptr(&This->node)
5082 : &This->node.event_target.ptr;
5085 static void HTMLElement_bind_event(DispatchEx *dispex, int eid)
5087 HTMLElement *This = impl_from_DispatchEx(dispex);
5089 static const WCHAR loadW[] = {'l','o','a','d',0};
5091 switch(eid) {
5092 case EVENTID_LOAD:
5093 add_nsevent_listener(This->node.doc, This->node.nsnode, loadW);
5094 return;
5095 default:
5096 dispex_get_vtbl(&This->node.doc->node.event_target.dispex)->bind_event(&This->node.doc->node.event_target.dispex, eid);
5100 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5102 if(mode >= COMPAT_MODE_IE8)
5103 dispex_info_add_interface(info, IElementSelector_tid);
5106 static const tid_t HTMLElement_iface_tids[] = {
5107 HTMLELEMENT_TIDS,
5111 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
5112 NULL,
5113 HTMLElement_get_dispid,
5114 HTMLElement_invoke,
5115 HTMLElement_populate_props,
5116 HTMLElement_get_event_target_ptr,
5117 HTMLElement_bind_event
5120 static dispex_static_data_t HTMLElement_dispex = {
5121 &HTMLElement_dispex_vtbl,
5122 DispHTMLUnknownElement_tid,
5123 HTMLElement_iface_tids,
5124 HTMLElement_init_dispex_info
5127 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
5129 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
5130 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
5131 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
5132 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
5133 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
5134 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
5135 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
5137 if(dispex_data && !dispex_data->vtbl)
5138 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
5139 init_dispex_with_compat_mode(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
5140 dispex_data ? dispex_data : &HTMLElement_dispex, doc->document_mode);
5142 if(nselem) {
5143 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
5145 /* No AddRef, share reference with HTMLDOMNode */
5146 assert((nsIDOMNode*)nselem == This->node.nsnode);
5147 This->nselem = nselem;
5150 This->node.cp_container = &This->cp_container;
5151 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
5154 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
5156 nsIDOMHTMLElement *nselem;
5157 nsAString class_name_str;
5158 const PRUnichar *class_name;
5159 const tag_desc_t *tag;
5160 HTMLElement *elem;
5161 nsresult nsres;
5162 HRESULT hres;
5164 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
5165 if(NS_FAILED(nsres))
5166 return E_FAIL;
5168 nsAString_Init(&class_name_str, NULL);
5169 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
5171 nsAString_GetData(&class_name_str, &class_name);
5173 tag = get_tag_desc(class_name);
5174 if(tag) {
5175 hres = tag->constructor(doc, nselem, &elem);
5176 }else if(use_generic) {
5177 hres = HTMLGenericElement_Create(doc, nselem, &elem);
5178 }else {
5179 elem = heap_alloc_zero(sizeof(HTMLElement));
5180 if(elem) {
5181 elem->node.vtbl = &HTMLElementImplVtbl;
5182 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
5183 hres = S_OK;
5184 }else {
5185 hres = E_OUTOFMEMORY;
5189 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
5191 nsIDOMHTMLElement_Release(nselem);
5192 nsAString_Finish(&class_name_str);
5193 if(FAILED(hres))
5194 return hres;
5196 *ret = elem;
5197 return S_OK;
5200 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
5202 HTMLDOMNode *node;
5203 HRESULT hres;
5205 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
5206 if(FAILED(hres))
5207 return hres;
5209 *ret = impl_from_HTMLDOMNode(node);
5210 return S_OK;
5213 /* interface IHTMLFiltersCollection */
5214 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
5216 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5218 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
5220 if(IsEqualGUID(&IID_IUnknown, riid)) {
5221 *ppv = &This->IHTMLFiltersCollection_iface;
5222 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
5223 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
5224 *ppv = &This->IHTMLFiltersCollection_iface;
5225 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5226 return *ppv ? S_OK : E_NOINTERFACE;
5227 }else {
5228 *ppv = NULL;
5229 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5230 return E_NOINTERFACE;
5233 IUnknown_AddRef((IUnknown*)*ppv);
5234 return S_OK;
5237 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
5239 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5240 LONG ref = InterlockedIncrement(&This->ref);
5242 TRACE("(%p) ref=%d\n", This, ref);
5244 return ref;
5247 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
5249 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5250 LONG ref = InterlockedDecrement(&This->ref);
5252 TRACE("(%p) ref=%d\n", This, ref);
5254 if(!ref)
5256 heap_free(This);
5259 return ref;
5262 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
5264 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5265 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5268 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
5269 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5271 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5272 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5275 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
5276 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5277 LCID lcid, DISPID *rgDispId)
5279 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5280 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5281 lcid, rgDispId);
5284 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
5285 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
5286 EXCEPINFO *pExcepInfo, UINT *puArgErr)
5288 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5289 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5290 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5293 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
5295 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5297 if(!p)
5298 return E_POINTER;
5300 FIXME("(%p)->(%p) Always returning 0\n", This, p);
5301 *p = 0;
5303 return S_OK;
5306 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
5308 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5309 FIXME("(%p)->(%p)\n", This, p);
5310 return E_NOTIMPL;
5313 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
5315 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5316 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
5317 return E_NOTIMPL;
5320 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
5321 HTMLFiltersCollection_QueryInterface,
5322 HTMLFiltersCollection_AddRef,
5323 HTMLFiltersCollection_Release,
5324 HTMLFiltersCollection_GetTypeInfoCount,
5325 HTMLFiltersCollection_GetTypeInfo,
5326 HTMLFiltersCollection_GetIDsOfNames,
5327 HTMLFiltersCollection_Invoke,
5328 HTMLFiltersCollection_get_length,
5329 HTMLFiltersCollection_get__newEnum,
5330 HTMLFiltersCollection_item
5333 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
5335 WCHAR *ptr;
5336 int idx = 0;
5338 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
5339 idx = idx*10 + (*ptr-'0');
5340 if(*ptr)
5341 return DISP_E_UNKNOWNNAME;
5343 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
5344 TRACE("ret %x\n", *dispid);
5345 return S_OK;
5348 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5349 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5351 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
5353 V_VT(res) = VT_DISPATCH;
5354 V_DISPATCH(res) = NULL;
5356 FIXME("always returning NULL\n");
5358 return S_OK;
5361 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
5362 NULL,
5363 HTMLFiltersCollection_get_dispid,
5364 HTMLFiltersCollection_invoke,
5365 NULL
5368 static const tid_t HTMLFiltersCollection_iface_tids[] = {
5369 IHTMLFiltersCollection_tid,
5372 static dispex_static_data_t HTMLFiltersCollection_dispex = {
5373 &HTMLFiltersCollection_dispex_vtbl,
5374 IHTMLFiltersCollection_tid,
5375 HTMLFiltersCollection_iface_tids
5378 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
5380 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
5382 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
5383 ret->ref = 1;
5385 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
5386 &HTMLFiltersCollection_dispex);
5388 return &ret->IHTMLFiltersCollection_iface;
5391 /* interface IHTMLAttributeCollection */
5392 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
5394 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
5397 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
5399 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5401 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5403 if(IsEqualGUID(&IID_IUnknown, riid)) {
5404 *ppv = &This->IHTMLAttributeCollection_iface;
5405 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
5406 *ppv = &This->IHTMLAttributeCollection_iface;
5407 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
5408 *ppv = &This->IHTMLAttributeCollection2_iface;
5409 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
5410 *ppv = &This->IHTMLAttributeCollection3_iface;
5411 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5412 return *ppv ? S_OK : E_NOINTERFACE;
5413 }else {
5414 *ppv = NULL;
5415 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5416 return E_NOINTERFACE;
5419 IUnknown_AddRef((IUnknown*)*ppv);
5420 return S_OK;
5423 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
5425 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5426 LONG ref = InterlockedIncrement(&This->ref);
5428 TRACE("(%p) ref=%d\n", This, ref);
5430 return ref;
5433 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
5435 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5436 LONG ref = InterlockedDecrement(&This->ref);
5438 TRACE("(%p) ref=%d\n", This, ref);
5440 if(!ref) {
5441 while(!list_empty(&This->attrs)) {
5442 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
5444 list_remove(&attr->entry);
5445 attr->elem = NULL;
5446 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
5449 heap_free(This);
5452 return ref;
5455 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
5457 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5458 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5461 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
5462 LCID lcid, ITypeInfo **ppTInfo)
5464 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5465 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5468 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
5469 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5471 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5472 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5473 lcid, rgDispId);
5476 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
5477 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5478 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5480 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5481 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5482 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5485 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
5487 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
5488 DISPID id = DISPID_STARTENUM;
5489 LONG len = -1;
5490 HRESULT hres;
5492 FIXME("filter non-enumerable attributes out\n");
5494 while(1) {
5495 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
5496 if(FAILED(hres))
5497 return hres;
5498 else if(hres == S_FALSE)
5499 break;
5501 len++;
5502 if(len == *idx)
5503 break;
5506 if(dispid) {
5507 *dispid = id;
5508 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
5511 *idx = len+1;
5512 return S_OK;
5515 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
5517 HRESULT hres;
5519 if(name[0]>='0' && name[0]<='9') {
5520 WCHAR *end_ptr;
5521 LONG idx;
5523 idx = strtoulW(name, &end_ptr, 10);
5524 if(!*end_ptr) {
5525 hres = get_attr_dispid_by_idx(This, &idx, id);
5526 if(SUCCEEDED(hres))
5527 return hres;
5531 if(!This->elem) {
5532 WARN("NULL elem\n");
5533 return E_UNEXPECTED;
5536 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
5537 name, fdexNameCaseInsensitive, id);
5538 return hres;
5541 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
5543 HTMLDOMAttribute *iter;
5544 LONG pos = 0;
5545 HRESULT hres;
5547 *attr = NULL;
5548 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
5549 if(iter->dispid == id) {
5550 *attr = iter;
5551 break;
5553 pos++;
5556 if(!*attr) {
5557 if(!This->elem) {
5558 WARN("NULL elem\n");
5559 return E_UNEXPECTED;
5562 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
5563 if(FAILED(hres))
5564 return hres;
5567 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
5568 if(list_pos)
5569 *list_pos = pos;
5570 return S_OK;
5573 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
5575 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5576 HRESULT hres;
5578 TRACE("(%p)->(%p)\n", This, p);
5580 *p = -1;
5581 hres = get_attr_dispid_by_idx(This, p, NULL);
5582 return hres;
5585 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
5587 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5588 FIXME("(%p)->(%p)\n", This, p);
5589 return E_NOTIMPL;
5592 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
5594 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5595 HTMLDOMAttribute *attr;
5596 DISPID id;
5597 HRESULT hres;
5599 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
5601 switch(V_VT(name)) {
5602 case VT_I4:
5603 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
5604 break;
5605 case VT_BSTR:
5606 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
5607 break;
5608 default:
5609 FIXME("unsupported name %s\n", debugstr_variant(name));
5610 hres = E_NOTIMPL;
5612 if(hres == DISP_E_UNKNOWNNAME)
5613 return E_INVALIDARG;
5614 if(FAILED(hres))
5615 return hres;
5617 hres = get_domattr(This, id, NULL, &attr);
5618 if(FAILED(hres))
5619 return hres;
5621 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
5622 return S_OK;
5625 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
5626 HTMLAttributeCollection_QueryInterface,
5627 HTMLAttributeCollection_AddRef,
5628 HTMLAttributeCollection_Release,
5629 HTMLAttributeCollection_GetTypeInfoCount,
5630 HTMLAttributeCollection_GetTypeInfo,
5631 HTMLAttributeCollection_GetIDsOfNames,
5632 HTMLAttributeCollection_Invoke,
5633 HTMLAttributeCollection_get_length,
5634 HTMLAttributeCollection__newEnum,
5635 HTMLAttributeCollection_item
5638 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
5640 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
5643 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
5645 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5646 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
5649 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
5651 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5652 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
5655 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
5657 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5658 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
5661 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
5663 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5664 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5667 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
5668 LCID lcid, ITypeInfo **ppTInfo)
5670 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5671 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5674 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
5675 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5677 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5678 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5679 lcid, rgDispId);
5682 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
5683 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5684 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5686 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5687 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5688 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5691 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
5692 IHTMLDOMAttribute **newretNode)
5694 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5695 HTMLDOMAttribute *attr;
5696 DISPID id;
5697 HRESULT hres;
5699 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
5701 hres = get_attr_dispid_by_name(This, bstrName, &id);
5702 if(hres == DISP_E_UNKNOWNNAME) {
5703 *newretNode = NULL;
5704 return S_OK;
5705 } else if(FAILED(hres)) {
5706 return hres;
5709 hres = get_domattr(This, id, NULL, &attr);
5710 if(FAILED(hres))
5711 return hres;
5713 *newretNode = &attr->IHTMLDOMAttribute_iface;
5714 return S_OK;
5717 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
5718 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
5720 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5721 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
5722 return E_NOTIMPL;
5725 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
5726 BSTR bstrName, IHTMLDOMAttribute **newretNode)
5728 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5729 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
5730 return E_NOTIMPL;
5733 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
5734 HTMLAttributeCollection2_QueryInterface,
5735 HTMLAttributeCollection2_AddRef,
5736 HTMLAttributeCollection2_Release,
5737 HTMLAttributeCollection2_GetTypeInfoCount,
5738 HTMLAttributeCollection2_GetTypeInfo,
5739 HTMLAttributeCollection2_GetIDsOfNames,
5740 HTMLAttributeCollection2_Invoke,
5741 HTMLAttributeCollection2_getNamedItem,
5742 HTMLAttributeCollection2_setNamedItem,
5743 HTMLAttributeCollection2_removeNamedItem
5746 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
5748 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
5751 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
5753 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5754 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
5757 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
5759 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5760 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
5763 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
5765 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5766 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
5769 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
5771 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5772 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5775 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
5776 LCID lcid, ITypeInfo **ppTInfo)
5778 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5779 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5782 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
5783 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5785 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5786 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5787 lcid, rgDispId);
5790 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
5791 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5792 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5794 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5795 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5796 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5799 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
5800 IHTMLDOMAttribute **ppNodeOut)
5802 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5803 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
5806 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
5807 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
5809 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5810 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
5811 return E_NOTIMPL;
5814 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
5815 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
5817 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5818 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
5819 return E_NOTIMPL;
5822 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
5824 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5825 HTMLDOMAttribute *attr;
5826 DISPID id;
5827 HRESULT hres;
5829 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
5831 hres = get_attr_dispid_by_idx(This, &index, &id);
5832 if(hres == DISP_E_UNKNOWNNAME)
5833 return E_INVALIDARG;
5834 if(FAILED(hres))
5835 return hres;
5837 hres = get_domattr(This, id, NULL, &attr);
5838 if(FAILED(hres))
5839 return hres;
5841 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
5842 return S_OK;
5845 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
5847 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5848 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
5851 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
5852 HTMLAttributeCollection3_QueryInterface,
5853 HTMLAttributeCollection3_AddRef,
5854 HTMLAttributeCollection3_Release,
5855 HTMLAttributeCollection3_GetTypeInfoCount,
5856 HTMLAttributeCollection3_GetTypeInfo,
5857 HTMLAttributeCollection3_GetIDsOfNames,
5858 HTMLAttributeCollection3_Invoke,
5859 HTMLAttributeCollection3_getNamedItem,
5860 HTMLAttributeCollection3_setNamedItem,
5861 HTMLAttributeCollection3_removeNamedItem,
5862 HTMLAttributeCollection3_item,
5863 HTMLAttributeCollection3_get_length
5866 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
5868 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
5871 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
5873 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
5874 HTMLDOMAttribute *attr;
5875 LONG pos;
5876 HRESULT hres;
5878 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
5880 hres = get_attr_dispid_by_name(This, name, dispid);
5881 if(FAILED(hres))
5882 return hres;
5884 hres = get_domattr(This, *dispid, &pos, &attr);
5885 if(FAILED(hres))
5886 return hres;
5887 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
5889 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
5890 return S_OK;
5893 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
5894 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5896 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
5898 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
5900 switch(flags) {
5901 case DISPATCH_PROPERTYGET: {
5902 HTMLDOMAttribute *iter;
5903 DWORD pos;
5905 pos = id-MSHTML_DISPID_CUSTOM_MIN;
5907 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
5908 if(!pos) {
5909 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
5910 V_VT(res) = VT_DISPATCH;
5911 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
5912 return S_OK;
5914 pos--;
5917 WARN("invalid arg\n");
5918 return E_INVALIDARG;
5921 default:
5922 FIXME("unimplemented flags %x\n", flags);
5923 return E_NOTIMPL;
5927 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
5928 NULL,
5929 HTMLAttributeCollection_get_dispid,
5930 HTMLAttributeCollection_invoke,
5931 NULL
5934 static const tid_t HTMLAttributeCollection_iface_tids[] = {
5935 IHTMLAttributeCollection_tid,
5936 IHTMLAttributeCollection2_tid,
5937 IHTMLAttributeCollection3_tid,
5941 static dispex_static_data_t HTMLAttributeCollection_dispex = {
5942 &HTMLAttributeCollection_dispex_vtbl,
5943 DispHTMLAttributeCollection_tid,
5944 HTMLAttributeCollection_iface_tids
5947 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
5949 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5951 if(This->attrs) {
5952 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
5953 *ac = This->attrs;
5954 return S_OK;
5957 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
5958 if(!This->attrs)
5959 return E_OUTOFMEMORY;
5961 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
5962 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
5963 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
5964 This->attrs->ref = 2;
5966 This->attrs->elem = This;
5967 list_init(&This->attrs->attrs);
5968 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
5969 &HTMLAttributeCollection_dispex);
5971 *ac = This->attrs;
5972 return S_OK;