msvcp140: Add _ContextCallback implementation.
[wine.git] / dlls / mshtml / htmlelem.c
blob42674a3600dfef4ec2dfce7d624d367772500716
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);
3869 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3871 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
3874 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3876 HTMLElement *This = impl_from_IHTMLElement4(iface);
3878 TRACE("(%p)->(%p)\n", This, p);
3880 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
3883 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3885 HTMLElement *This = impl_from_IHTMLElement4(iface);
3887 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3889 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3892 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3894 HTMLElement *This = impl_from_IHTMLElement4(iface);
3896 TRACE("(%p)->(%p)\n", This, p);
3898 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3901 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3903 HTMLElement *This = impl_from_IHTMLElement4(iface);
3905 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3907 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
3910 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3912 HTMLElement *This = impl_from_IHTMLElement4(iface);
3914 TRACE("(%p)->(%p)\n", This, p);
3916 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
3919 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3920 HTMLElement4_QueryInterface,
3921 HTMLElement4_AddRef,
3922 HTMLElement4_Release,
3923 HTMLElement4_GetTypeInfoCount,
3924 HTMLElement4_GetTypeInfo,
3925 HTMLElement4_GetIDsOfNames,
3926 HTMLElement4_Invoke,
3927 HTMLElement4_put_onmousewheel,
3928 HTMLElement4_get_onmousewheel,
3929 HTMLElement4_normalize,
3930 HTMLElement4_getAttributeNode,
3931 HTMLElement4_setAttributeNode,
3932 HTMLElement4_removeAttributeNode,
3933 HTMLElement4_put_onbeforeactivate,
3934 HTMLElement4_get_onbeforeactivate,
3935 HTMLElement4_put_onfocusin,
3936 HTMLElement4_get_onfocusin,
3937 HTMLElement4_put_onfocusout,
3938 HTMLElement4_get_onfocusout
3941 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
3943 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
3946 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
3947 REFIID riid, void **ppv)
3949 HTMLElement *This = impl_from_IHTMLElement6(iface);
3950 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3953 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
3955 HTMLElement *This = impl_from_IHTMLElement6(iface);
3956 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3959 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
3961 HTMLElement *This = impl_from_IHTMLElement6(iface);
3962 return IHTMLElement_Release(&This->IHTMLElement_iface);
3965 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
3967 HTMLElement *This = impl_from_IHTMLElement6(iface);
3968 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3971 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
3972 LCID lcid, ITypeInfo **ppTInfo)
3974 HTMLElement *This = impl_from_IHTMLElement6(iface);
3975 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3978 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
3979 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3981 HTMLElement *This = impl_from_IHTMLElement6(iface);
3982 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3983 lcid, rgDispId);
3986 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
3987 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3989 HTMLElement *This = impl_from_IHTMLElement6(iface);
3990 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3991 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3994 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
3996 HTMLElement *This = impl_from_IHTMLElement6(iface);
3997 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
3998 return E_NOTIMPL;
4001 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4003 HTMLElement *This = impl_from_IHTMLElement6(iface);
4004 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4005 return E_NOTIMPL;
4008 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4010 HTMLElement *This = impl_from_IHTMLElement6(iface);
4011 FIXME("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4012 return E_NOTIMPL;
4015 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4017 HTMLElement *This = impl_from_IHTMLElement6(iface);
4018 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4019 return E_NOTIMPL;
4022 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4024 HTMLElement *This = impl_from_IHTMLElement6(iface);
4025 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4026 return E_NOTIMPL;
4029 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4031 HTMLElement *This = impl_from_IHTMLElement6(iface);
4032 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4033 return E_NOTIMPL;
4036 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4038 HTMLElement *This = impl_from_IHTMLElement6(iface);
4039 FIXME("(%p)->(%s %p)\n", This, debugstr_w(strAttributeName), AttributeValue);
4040 return E_NOTIMPL;
4043 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4045 HTMLElement *This = impl_from_IHTMLElement6(iface);
4046 FIXME("(%p)->(%s %p)\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4047 return E_NOTIMPL;
4050 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4052 HTMLElement *This = impl_from_IHTMLElement6(iface);
4053 FIXME("(%p)->(%s)\n", This, debugstr_w(strAttributeName));
4054 return E_NOTIMPL;
4057 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4059 HTMLElement *This = impl_from_IHTMLElement6(iface);
4060 FIXME("(%p)->(%s %p)\n", This, debugstr_w(strAttributeName), ppretAttribute);
4061 return E_NOTIMPL;
4064 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4066 HTMLElement *This = impl_from_IHTMLElement6(iface);
4067 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4068 return E_NOTIMPL;
4071 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4073 HTMLElement *This = impl_from_IHTMLElement6(iface);
4074 FIXME("(%p)->()\n", This);
4075 return E_NOTIMPL;
4078 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *pfHasAttribute)
4080 HTMLElement *This = impl_from_IHTMLElement6(iface);
4081 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), pfHasAttribute);
4082 return E_NOTIMPL;
4085 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
4087 HTMLElement *This = impl_from_IHTMLElement6(iface);
4088 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
4089 return E_NOTIMPL;
4092 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
4094 HTMLElement *This = impl_from_IHTMLElement6(iface);
4095 FIXME("(%p)->(%p)\n", This, p);
4096 return E_NOTIMPL;
4099 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
4101 HTMLElement *This = impl_from_IHTMLElement6(iface);
4102 FIXME("(%p)->(%p)\n", This, p);
4103 return E_NOTIMPL;
4106 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
4108 HTMLElement *This = impl_from_IHTMLElement6(iface);
4109 nsIDOMHTMLCollection *nscol = NULL;
4110 nsAString nsstr;
4111 nsresult nsres;
4113 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4115 if(This->nselem) {
4116 nsAString_InitDepend(&nsstr, v);
4117 nsres = nsIDOMHTMLElement_GetElementsByClassName(This->nselem, &nsstr, &nscol);
4118 nsAString_Finish(&nsstr);
4119 if(NS_FAILED(nsres)) {
4120 ERR("GetElementsByClassName failed: %08x\n", nsres);
4121 return E_FAIL;
4125 *pel = create_collection_from_htmlcol(This->node.doc, nscol);
4126 nsIDOMHTMLCollection_Release(nscol);
4127 return S_OK;
4130 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
4132 HTMLElement *This = impl_from_IHTMLElement6(iface);
4133 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
4134 return E_NOTIMPL;
4137 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
4139 HTMLElement *This = impl_from_IHTMLElement6(iface);
4141 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4143 return set_node_event(&This->node, EVENTID_ABORT, &v);
4146 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
4148 HTMLElement *This = impl_from_IHTMLElement6(iface);
4150 TRACE("(%p)->(%p)\n", This, p);
4152 return get_node_event(&This->node, EVENTID_ABORT, p);
4155 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
4157 HTMLElement *This = impl_from_IHTMLElement6(iface);
4158 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4159 return E_NOTIMPL;
4162 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
4164 HTMLElement *This = impl_from_IHTMLElement6(iface);
4165 FIXME("(%p)->(%p)\n", This, p);
4166 return E_NOTIMPL;
4169 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
4171 HTMLElement *This = impl_from_IHTMLElement6(iface);
4172 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4173 return E_NOTIMPL;
4176 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
4178 HTMLElement *This = impl_from_IHTMLElement6(iface);
4179 FIXME("(%p)->(%p)\n", This, p);
4180 return E_NOTIMPL;
4183 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
4185 HTMLElement *This = impl_from_IHTMLElement6(iface);
4187 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4189 return set_node_event(&This->node, EVENTID_CHANGE, &v);
4192 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
4194 HTMLElement *This = impl_from_IHTMLElement6(iface);
4196 TRACE("(%p)->(%p)\n", This, p);
4198 return get_node_event(&This->node, EVENTID_CHANGE, p);
4201 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
4203 HTMLElement *This = impl_from_IHTMLElement6(iface);
4204 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4205 return E_NOTIMPL;
4208 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
4210 HTMLElement *This = impl_from_IHTMLElement6(iface);
4211 FIXME("(%p)->(%p)\n", This, p);
4212 return E_NOTIMPL;
4215 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
4217 HTMLElement *This = impl_from_IHTMLElement6(iface);
4218 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4219 return E_NOTIMPL;
4222 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
4224 HTMLElement *This = impl_from_IHTMLElement6(iface);
4225 FIXME("(%p)->(%p)\n", This, p);
4226 return E_NOTIMPL;
4229 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
4231 HTMLElement *This = impl_from_IHTMLElement6(iface);
4232 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4233 return E_NOTIMPL;
4236 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
4238 HTMLElement *This = impl_from_IHTMLElement6(iface);
4239 FIXME("(%p)->(%p)\n", This, p);
4240 return E_NOTIMPL;
4243 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
4245 HTMLElement *This = impl_from_IHTMLElement6(iface);
4247 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4249 return set_node_event(&This->node, EVENTID_ERROR, &v);
4252 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
4254 HTMLElement *This = impl_from_IHTMLElement6(iface);
4256 TRACE("(%p)->(%p)\n", This, p);
4258 return get_node_event(&This->node, EVENTID_ERROR, p);
4261 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
4263 HTMLElement *This = impl_from_IHTMLElement6(iface);
4264 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4265 return E_NOTIMPL;
4268 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
4270 HTMLElement *This = impl_from_IHTMLElement6(iface);
4271 FIXME("(%p)->(%p)\n", This, p);
4272 return E_NOTIMPL;
4275 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
4277 HTMLElement *This = impl_from_IHTMLElement6(iface);
4279 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4281 return set_node_event(&This->node, EVENTID_LOAD, &v);
4284 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
4286 HTMLElement *This = impl_from_IHTMLElement6(iface);
4288 TRACE("(%p)->(%p)\n", This, p);
4290 return get_node_event(&This->node, EVENTID_LOAD, p);
4293 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
4295 HTMLElement *This = impl_from_IHTMLElement6(iface);
4296 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4297 return E_NOTIMPL;
4300 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
4302 HTMLElement *This = impl_from_IHTMLElement6(iface);
4303 FIXME("(%p)->(%p)\n", This, p);
4304 return E_NOTIMPL;
4307 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
4309 HTMLElement *This = impl_from_IHTMLElement6(iface);
4310 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4311 return E_NOTIMPL;
4314 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
4316 HTMLElement *This = impl_from_IHTMLElement6(iface);
4317 FIXME("(%p)->(%p)\n", This, p);
4318 return E_NOTIMPL;
4321 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
4323 HTMLElement *This = impl_from_IHTMLElement6(iface);
4324 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4325 return E_NOTIMPL;
4328 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
4330 HTMLElement *This = impl_from_IHTMLElement6(iface);
4331 FIXME("(%p)->(%p)\n", This, p);
4332 return E_NOTIMPL;
4335 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
4337 HTMLElement *This = impl_from_IHTMLElement6(iface);
4338 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4339 return E_NOTIMPL;
4342 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
4344 HTMLElement *This = impl_from_IHTMLElement6(iface);
4345 FIXME("(%p)->(%p)\n", This, p);
4346 return E_NOTIMPL;
4349 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
4351 HTMLElement *This = impl_from_IHTMLElement6(iface);
4352 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4353 return E_NOTIMPL;
4356 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
4358 HTMLElement *This = impl_from_IHTMLElement6(iface);
4359 FIXME("(%p)->(%p)\n", This, p);
4360 return E_NOTIMPL;
4363 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
4365 HTMLElement *This = impl_from_IHTMLElement6(iface);
4366 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4367 return E_NOTIMPL;
4370 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
4372 HTMLElement *This = impl_from_IHTMLElement6(iface);
4373 FIXME("(%p)->(%p)\n", This, p);
4374 return E_NOTIMPL;
4377 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
4379 HTMLElement *This = impl_from_IHTMLElement6(iface);
4380 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4381 return E_NOTIMPL;
4384 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
4386 HTMLElement *This = impl_from_IHTMLElement6(iface);
4387 FIXME("(%p)->(%p)\n", This, p);
4388 return E_NOTIMPL;
4391 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
4393 HTMLElement *This = impl_from_IHTMLElement6(iface);
4394 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4395 return E_NOTIMPL;
4398 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
4400 HTMLElement *This = impl_from_IHTMLElement6(iface);
4401 FIXME("(%p)->(%p)\n", This, p);
4402 return E_NOTIMPL;
4405 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
4407 HTMLElement *This = impl_from_IHTMLElement6(iface);
4408 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4409 return E_NOTIMPL;
4412 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
4414 HTMLElement *This = impl_from_IHTMLElement6(iface);
4415 FIXME("(%p)->(%p)\n", This, p);
4416 return E_NOTIMPL;
4419 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
4421 HTMLElement *This = impl_from_IHTMLElement6(iface);
4422 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4423 return E_NOTIMPL;
4426 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
4428 HTMLElement *This = impl_from_IHTMLElement6(iface);
4429 FIXME("(%p)->(%p)\n", This, p);
4430 return E_NOTIMPL;
4433 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
4435 HTMLElement *This = impl_from_IHTMLElement6(iface);
4436 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4437 return E_NOTIMPL;
4440 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
4442 HTMLElement *This = impl_from_IHTMLElement6(iface);
4443 FIXME("(%p)->(%p)\n", This, p);
4444 return E_NOTIMPL;
4447 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
4449 HTMLElement *This = impl_from_IHTMLElement6(iface);
4450 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4451 return E_NOTIMPL;
4454 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
4456 HTMLElement *This = impl_from_IHTMLElement6(iface);
4457 FIXME("(%p)->(%p)\n", This, p);
4458 return E_NOTIMPL;
4461 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
4463 HTMLElement *This = impl_from_IHTMLElement6(iface);
4464 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4465 return E_NOTIMPL;
4468 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
4470 HTMLElement *This = impl_from_IHTMLElement6(iface);
4471 FIXME("(%p)->(%p)\n", This, p);
4472 return E_NOTIMPL;
4475 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
4477 HTMLElement *This = impl_from_IHTMLElement6(iface);
4479 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4481 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
4484 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
4486 HTMLElement *This = impl_from_IHTMLElement6(iface);
4488 TRACE("(%p)->(%p)\n", This, p);
4490 return get_node_event(&This->node, EVENTID_SUBMIT, p);
4493 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
4495 HTMLElement *This = impl_from_IHTMLElement6(iface);
4496 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4497 return E_NOTIMPL;
4500 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
4502 HTMLElement *This = impl_from_IHTMLElement6(iface);
4503 FIXME("(%p)->(%p)\n", This, p);
4504 return E_NOTIMPL;
4507 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
4509 HTMLElement *This = impl_from_IHTMLElement6(iface);
4510 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4511 return E_NOTIMPL;
4514 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
4516 HTMLElement *This = impl_from_IHTMLElement6(iface);
4517 FIXME("(%p)->(%p)\n", This, p);
4518 return E_NOTIMPL;
4521 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
4523 HTMLElement *This = impl_from_IHTMLElement6(iface);
4524 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4525 return E_NOTIMPL;
4528 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
4530 HTMLElement *This = impl_from_IHTMLElement6(iface);
4531 FIXME("(%p)->(%p)\n", This, p);
4532 return E_NOTIMPL;
4535 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
4537 HTMLElement *This = impl_from_IHTMLElement6(iface);
4538 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4539 return E_NOTIMPL;
4542 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
4544 HTMLElement *This = impl_from_IHTMLElement6(iface);
4545 FIXME("(%p)->(%p)\n", This, p);
4546 return E_NOTIMPL;
4549 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
4551 HTMLElement *This = impl_from_IHTMLElement6(iface);
4552 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
4553 return E_NOTIMPL;
4556 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
4557 HTMLElement6_QueryInterface,
4558 HTMLElement6_AddRef,
4559 HTMLElement6_Release,
4560 HTMLElement6_GetTypeInfoCount,
4561 HTMLElement6_GetTypeInfo,
4562 HTMLElement6_GetIDsOfNames,
4563 HTMLElement6_Invoke,
4564 HTMLElement6_getAttributeNS,
4565 HTMLElement6_setAttributeNS,
4566 HTMLElement6_removeAttributeNS,
4567 HTMLElement6_getAttributeNodeNS,
4568 HTMLElement6_setAttributeNodeNS,
4569 HTMLElement6_hasAttributeNS,
4570 HTMLElement6_getAttribute,
4571 HTMLElement6_setAttribute,
4572 HTMLElement6_removeAttribute,
4573 HTMLElement6_getAttributeNode,
4574 HTMLElement6_setAttributeNode,
4575 HTMLElement6_removeAttributeNode,
4576 HTMLElement6_hasAttribute,
4577 HTMLElement6_getElementsByTagNameNS,
4578 HTMLElement6_get_tagName,
4579 HTMLElement6_get_nodeName,
4580 HTMLElement6_getElementsByClassName,
4581 HTMLElement6_msMatchesSelector,
4582 HTMLElement6_put_onabort,
4583 HTMLElement6_get_onabort,
4584 HTMLElement6_put_oncanplay,
4585 HTMLElement6_get_oncanplay,
4586 HTMLElement6_put_oncanplaythrough,
4587 HTMLElement6_get_oncanplaythrough,
4588 HTMLElement6_put_onchange,
4589 HTMLElement6_get_onchange,
4590 HTMLElement6_put_ondurationchange,
4591 HTMLElement6_get_ondurationchange,
4592 HTMLElement6_put_onemptied,
4593 HTMLElement6_get_onemptied,
4594 HTMLElement6_put_onended,
4595 HTMLElement6_get_onended,
4596 HTMLElement6_put_onerror,
4597 HTMLElement6_get_onerror,
4598 HTMLElement6_put_oninput,
4599 HTMLElement6_get_oninput,
4600 HTMLElement6_put_onload,
4601 HTMLElement6_get_onload,
4602 HTMLElement6_put_onloadeddata,
4603 HTMLElement6_get_onloadeddata,
4604 HTMLElement6_put_onloadedmetadata,
4605 HTMLElement6_get_onloadedmetadata,
4606 HTMLElement6_put_onloadstart,
4607 HTMLElement6_get_onloadstart,
4608 HTMLElement6_put_onpause,
4609 HTMLElement6_get_onpause,
4610 HTMLElement6_put_onplay,
4611 HTMLElement6_get_onplay,
4612 HTMLElement6_put_onplaying,
4613 HTMLElement6_get_onplaying,
4614 HTMLElement6_put_onprogress,
4615 HTMLElement6_get_onprogress,
4616 HTMLElement6_put_onratechange,
4617 HTMLElement6_get_onratechange,
4618 HTMLElement6_put_onreset,
4619 HTMLElement6_get_onreset,
4620 HTMLElement6_put_onseeked,
4621 HTMLElement6_get_onseeked,
4622 HTMLElement6_put_onseeking,
4623 HTMLElement6_get_onseeking,
4624 HTMLElement6_put_onselect,
4625 HTMLElement6_get_onselect,
4626 HTMLElement6_put_onstalled,
4627 HTMLElement6_get_onstalled,
4628 HTMLElement6_put_onsubmit,
4629 HTMLElement6_get_onsubmit,
4630 HTMLElement6_put_onsuspend,
4631 HTMLElement6_get_onsuspend,
4632 HTMLElement6_put_ontimeupdate,
4633 HTMLElement6_get_ontimeupdate,
4634 HTMLElement6_put_onvolumechange,
4635 HTMLElement6_get_onvolumechange,
4636 HTMLElement6_put_onwaiting,
4637 HTMLElement6_get_onwaiting,
4638 HTMLElement6_hasAttributes
4641 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
4643 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
4646 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
4648 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4649 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4652 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
4654 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4655 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4658 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
4660 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4661 return IHTMLElement_Release(&This->IHTMLElement_iface);
4664 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
4666 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4667 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4670 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
4671 LCID lcid, ITypeInfo **ppTInfo)
4673 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4674 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4677 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
4678 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4680 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4681 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4682 lcid, rgDispId);
4685 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
4686 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4688 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4689 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4690 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4693 HRESULT elem_unique_id(unsigned id, BSTR *p)
4695 WCHAR buf[32];
4697 static const WCHAR formatW[] = {'m','s','_','_','i','d','%','u',0};
4699 sprintfW(buf, formatW, id);
4700 *p = SysAllocString(buf);
4701 return *p ? S_OK : E_OUTOFMEMORY;
4704 static void ensure_unique_id(HTMLElement *elem)
4706 if(!elem->unique_id)
4707 elem->unique_id = ++elem->node.doc->unique_id;
4710 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
4712 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4714 TRACE("(%p)->(%p)\n", This, p);
4716 ensure_unique_id(This);
4717 *p = This->unique_id;
4718 return S_OK;
4721 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
4723 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4725 TRACE("(%p)->(%p)\n", This, p);
4727 ensure_unique_id(This);
4728 return elem_unique_id(This->unique_id, p);
4731 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
4732 HTMLUniqueName_QueryInterface,
4733 HTMLUniqueName_AddRef,
4734 HTMLUniqueName_Release,
4735 HTMLUniqueName_GetTypeInfoCount,
4736 HTMLUniqueName_GetTypeInfo,
4737 HTMLUniqueName_GetIDsOfNames,
4738 HTMLUniqueName_Invoke,
4739 HTMLUniqueName_get_uniqueNumber,
4740 HTMLUniqueName_get_uniqueID
4743 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
4745 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
4748 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
4750 HTMLElement *This = impl_from_IElementSelector(iface);
4751 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4754 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
4756 HTMLElement *This = impl_from_IElementSelector(iface);
4757 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4760 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
4762 HTMLElement *This = impl_from_IElementSelector(iface);
4763 return IHTMLElement_Release(&This->IHTMLElement_iface);
4766 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
4768 HTMLElement *This = impl_from_IElementSelector(iface);
4769 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4772 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
4773 LCID lcid, ITypeInfo **ppTInfo)
4775 HTMLElement *This = impl_from_IElementSelector(iface);
4776 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4779 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
4780 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4782 HTMLElement *This = impl_from_IElementSelector(iface);
4783 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
4786 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
4787 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4789 HTMLElement *This = impl_from_IElementSelector(iface);
4790 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4791 pDispParams, pVarResult, pExcepInfo, puArgErr);
4794 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
4796 HTMLElement *This = impl_from_IElementSelector(iface);
4797 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4798 return E_NOTIMPL;
4801 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4803 HTMLElement *This = impl_from_IElementSelector(iface);
4804 nsIDOMNodeList *node_list;
4805 nsAString nsstr;
4806 nsresult nsres;
4808 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4810 nsAString_InitDepend(&nsstr, v);
4811 nsres = nsIDOMHTMLElement_QuerySelectorAll(This->nselem, &nsstr, &node_list);
4812 nsAString_Finish(&nsstr);
4813 if(NS_FAILED(nsres)) {
4814 ERR("QuerySelectorAll failed: %08x\n", nsres);
4815 return E_FAIL;
4818 *pel = create_child_collection(This->node.doc, node_list);
4819 nsIDOMNodeList_Release(node_list);
4820 return *pel ? S_OK : E_OUTOFMEMORY;
4823 static const IElementSelectorVtbl ElementSelectorVtbl = {
4824 ElementSelector_QueryInterface,
4825 ElementSelector_AddRef,
4826 ElementSelector_Release,
4827 ElementSelector_GetTypeInfoCount,
4828 ElementSelector_GetTypeInfo,
4829 ElementSelector_GetIDsOfNames,
4830 ElementSelector_Invoke,
4831 ElementSelector_querySelector,
4832 ElementSelector_querySelectorAll
4835 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
4837 return CONTAINING_RECORD(iface, HTMLElement, node);
4840 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
4842 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4844 if(IsEqualGUID(&IID_IUnknown, riid)) {
4845 *ppv = &This->IHTMLElement_iface;
4846 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
4847 *ppv = &This->IHTMLElement_iface;
4848 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
4849 *ppv = &This->IHTMLElement_iface;
4850 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
4851 *ppv = &This->IHTMLElement2_iface;
4852 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
4853 *ppv = &This->IHTMLElement3_iface;
4854 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
4855 *ppv = &This->IHTMLElement4_iface;
4856 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
4857 *ppv = &This->IHTMLElement6_iface;
4858 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
4859 *ppv = &This->IHTMLUniqueName_iface;
4860 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
4861 *ppv = &This->IElementSelector_iface;
4862 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
4863 *ppv = &This->cp_container.IConnectionPointContainer_iface;
4864 }else {
4865 return HTMLDOMNode_QI(&This->node, riid, ppv);
4868 IUnknown_AddRef((IUnknown*)*ppv);
4869 return S_OK;
4872 void HTMLElement_destructor(HTMLDOMNode *iface)
4874 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4876 ConnectionPointContainer_Destroy(&This->cp_container);
4878 if(This->style) {
4879 This->style->elem = NULL;
4880 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
4882 if(This->runtime_style) {
4883 This->runtime_style->elem = NULL;
4884 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
4886 if(This->attrs) {
4887 HTMLDOMAttribute *attr;
4889 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
4890 attr->elem = NULL;
4892 This->attrs->elem = NULL;
4893 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
4896 heap_free(This->filter);
4898 HTMLDOMNode_destructor(&This->node);
4901 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
4903 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4904 HTMLElement *new_elem;
4905 HRESULT hres;
4907 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
4908 if(FAILED(hres))
4909 return hres;
4911 if(This->filter) {
4912 new_elem->filter = heap_strdupW(This->filter);
4913 if(!new_elem->filter) {
4914 IHTMLElement_Release(&This->IHTMLElement_iface);
4915 return E_OUTOFMEMORY;
4919 *ret = &new_elem->node;
4920 return S_OK;
4923 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
4925 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4927 switch(eid) {
4928 case EVENTID_KEYDOWN: {
4929 nsIDOMKeyEvent *key_event;
4930 nsresult nsres;
4932 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
4933 if(NS_SUCCEEDED(nsres)) {
4934 UINT32 code = 0;
4936 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
4938 switch(code) {
4939 case VK_F1: /* DOM_VK_F1 */
4940 TRACE("F1 pressed\n");
4941 fire_event(This->node.doc, EVENTID_HELP, TRUE, &This->node, NULL, NULL);
4942 *prevent_default = TRUE;
4945 nsIDOMKeyEvent_Release(key_event);
4950 return S_OK;
4953 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
4955 const cpc_entry_t HTMLElement_cpc[] = {
4956 HTMLELEMENT_CPC,
4957 {NULL}
4960 static const NodeImplVtbl HTMLElementImplVtbl = {
4961 HTMLElement_QI,
4962 HTMLElement_destructor,
4963 HTMLElement_cpc,
4964 HTMLElement_clone,
4965 HTMLElement_handle_event,
4966 HTMLElement_get_attr_col
4969 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
4971 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
4974 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
4975 DWORD grfdex, DISPID *pid)
4977 HTMLElement *This = impl_from_DispatchEx(dispex);
4979 if(This->node.vtbl->get_dispid)
4980 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
4982 return DISP_E_UNKNOWNNAME;
4985 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4986 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
4987 IServiceProvider *caller)
4989 HTMLElement *This = impl_from_DispatchEx(dispex);
4991 if(This->node.vtbl->invoke)
4992 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
4993 params, res, ei, caller);
4995 ERR("(%p): element has no invoke method\n", This);
4996 return E_NOTIMPL;
4999 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
5001 HTMLElement *This = impl_from_DispatchEx(dispex);
5002 nsIDOMMozNamedAttrMap *attrs;
5003 nsIDOMAttr *attr;
5004 nsAString nsstr;
5005 const PRUnichar *str;
5006 BSTR name;
5007 VARIANT value;
5008 unsigned i;
5009 UINT32 len;
5010 DISPID id;
5011 nsresult nsres;
5012 HRESULT hres;
5014 if(!This->nselem)
5015 return S_FALSE;
5017 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
5018 if(NS_FAILED(nsres))
5019 return E_FAIL;
5021 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
5022 if(NS_FAILED(nsres)) {
5023 nsIDOMMozNamedAttrMap_Release(attrs);
5024 return E_FAIL;
5027 nsAString_Init(&nsstr, NULL);
5028 for(i=0; i<len; i++) {
5029 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
5030 if(NS_FAILED(nsres))
5031 continue;
5033 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
5034 if(NS_FAILED(nsres)) {
5035 nsIDOMAttr_Release(attr);
5036 continue;
5039 nsAString_GetData(&nsstr, &str);
5040 name = SysAllocString(str);
5041 if(!name) {
5042 nsIDOMAttr_Release(attr);
5043 continue;
5046 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
5047 if(hres != DISP_E_UNKNOWNNAME) {
5048 nsIDOMAttr_Release(attr);
5049 SysFreeString(name);
5050 continue;
5053 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
5054 nsIDOMAttr_Release(attr);
5055 if(NS_FAILED(nsres)) {
5056 SysFreeString(name);
5057 continue;
5060 nsAString_GetData(&nsstr, &str);
5061 V_VT(&value) = VT_BSTR;
5062 if(*str) {
5063 V_BSTR(&value) = SysAllocString(str);
5064 if(!V_BSTR(&value)) {
5065 SysFreeString(name);
5066 continue;
5068 } else
5069 V_BSTR(&value) = NULL;
5071 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
5072 SysFreeString(name);
5073 VariantClear(&value);
5075 nsAString_Finish(&nsstr);
5077 nsIDOMMozNamedAttrMap_Release(attrs);
5078 return S_OK;
5081 static EventTarget *HTMLElement_get_event_target(DispatchEx *dispex)
5083 HTMLElement *This = impl_from_DispatchEx(dispex);
5084 return This->node.vtbl->get_event_target
5085 ? This->node.vtbl->get_event_target(&This->node)
5086 : &This->node.event_target;
5089 static void HTMLElement_bind_event(DispatchEx *dispex, int eid)
5091 HTMLElement *This = impl_from_DispatchEx(dispex);
5093 static const WCHAR loadW[] = {'l','o','a','d',0};
5095 switch(eid) {
5096 case EVENTID_LOAD:
5097 add_nsevent_listener(This->node.doc, This->node.nsnode, loadW);
5098 return;
5099 default:
5100 dispex_get_vtbl(&This->node.doc->node.event_target.dispex)->bind_event(&This->node.doc->node.event_target.dispex, eid);
5104 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5106 if(mode >= COMPAT_MODE_IE8)
5107 dispex_info_add_interface(info, IElementSelector_tid);
5110 static const tid_t HTMLElement_iface_tids[] = {
5111 HTMLELEMENT_TIDS,
5115 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
5116 NULL,
5117 HTMLElement_get_dispid,
5118 HTMLElement_invoke,
5119 HTMLElement_populate_props,
5120 HTMLElement_get_event_target,
5121 HTMLElement_bind_event
5124 static dispex_static_data_t HTMLElement_dispex = {
5125 &HTMLElement_dispex_vtbl,
5126 DispHTMLUnknownElement_tid,
5127 HTMLElement_iface_tids,
5128 HTMLElement_init_dispex_info
5131 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
5133 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
5134 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
5135 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
5136 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
5137 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
5138 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
5139 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
5141 if(dispex_data && !dispex_data->vtbl)
5142 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
5143 init_dispex_with_compat_mode(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
5144 dispex_data ? dispex_data : &HTMLElement_dispex, doc->document_mode);
5146 if(nselem) {
5147 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
5149 /* No AddRef, share reference with HTMLDOMNode */
5150 assert((nsIDOMNode*)nselem == This->node.nsnode);
5151 This->nselem = nselem;
5154 This->node.cp_container = &This->cp_container;
5155 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
5158 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
5160 nsIDOMHTMLElement *nselem;
5161 nsAString class_name_str;
5162 const PRUnichar *class_name;
5163 const tag_desc_t *tag;
5164 HTMLElement *elem;
5165 nsresult nsres;
5166 HRESULT hres;
5168 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
5169 if(NS_FAILED(nsres))
5170 return E_FAIL;
5172 nsAString_Init(&class_name_str, NULL);
5173 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
5175 nsAString_GetData(&class_name_str, &class_name);
5177 tag = get_tag_desc(class_name);
5178 if(tag) {
5179 hres = tag->constructor(doc, nselem, &elem);
5180 }else if(use_generic) {
5181 hres = HTMLGenericElement_Create(doc, nselem, &elem);
5182 }else {
5183 elem = heap_alloc_zero(sizeof(HTMLElement));
5184 if(elem) {
5185 elem->node.vtbl = &HTMLElementImplVtbl;
5186 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
5187 hres = S_OK;
5188 }else {
5189 hres = E_OUTOFMEMORY;
5193 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
5195 nsIDOMHTMLElement_Release(nselem);
5196 nsAString_Finish(&class_name_str);
5197 if(FAILED(hres))
5198 return hres;
5200 *ret = elem;
5201 return S_OK;
5204 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
5206 HTMLDOMNode *node;
5207 HRESULT hres;
5209 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
5210 if(FAILED(hres))
5211 return hres;
5213 *ret = impl_from_HTMLDOMNode(node);
5214 return S_OK;
5217 /* interface IHTMLFiltersCollection */
5218 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
5220 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5222 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
5224 if(IsEqualGUID(&IID_IUnknown, riid)) {
5225 *ppv = &This->IHTMLFiltersCollection_iface;
5226 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
5227 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
5228 *ppv = &This->IHTMLFiltersCollection_iface;
5229 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5230 return *ppv ? S_OK : E_NOINTERFACE;
5231 }else {
5232 *ppv = NULL;
5233 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5234 return E_NOINTERFACE;
5237 IUnknown_AddRef((IUnknown*)*ppv);
5238 return S_OK;
5241 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
5243 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5244 LONG ref = InterlockedIncrement(&This->ref);
5246 TRACE("(%p) ref=%d\n", This, ref);
5248 return ref;
5251 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
5253 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5254 LONG ref = InterlockedDecrement(&This->ref);
5256 TRACE("(%p) ref=%d\n", This, ref);
5258 if(!ref)
5260 heap_free(This);
5263 return ref;
5266 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
5268 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5269 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5272 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
5273 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5275 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5276 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5279 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
5280 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5281 LCID lcid, DISPID *rgDispId)
5283 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5284 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5285 lcid, rgDispId);
5288 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
5289 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
5290 EXCEPINFO *pExcepInfo, UINT *puArgErr)
5292 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5293 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5294 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5297 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
5299 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5301 if(!p)
5302 return E_POINTER;
5304 FIXME("(%p)->(%p) Always returning 0\n", This, p);
5305 *p = 0;
5307 return S_OK;
5310 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
5312 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5313 FIXME("(%p)->(%p)\n", This, p);
5314 return E_NOTIMPL;
5317 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
5319 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5320 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
5321 return E_NOTIMPL;
5324 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
5325 HTMLFiltersCollection_QueryInterface,
5326 HTMLFiltersCollection_AddRef,
5327 HTMLFiltersCollection_Release,
5328 HTMLFiltersCollection_GetTypeInfoCount,
5329 HTMLFiltersCollection_GetTypeInfo,
5330 HTMLFiltersCollection_GetIDsOfNames,
5331 HTMLFiltersCollection_Invoke,
5332 HTMLFiltersCollection_get_length,
5333 HTMLFiltersCollection_get__newEnum,
5334 HTMLFiltersCollection_item
5337 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
5339 WCHAR *ptr;
5340 int idx = 0;
5342 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
5343 idx = idx*10 + (*ptr-'0');
5344 if(*ptr)
5345 return DISP_E_UNKNOWNNAME;
5347 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
5348 TRACE("ret %x\n", *dispid);
5349 return S_OK;
5352 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5353 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5355 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
5357 V_VT(res) = VT_DISPATCH;
5358 V_DISPATCH(res) = NULL;
5360 FIXME("always returning NULL\n");
5362 return S_OK;
5365 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
5366 NULL,
5367 HTMLFiltersCollection_get_dispid,
5368 HTMLFiltersCollection_invoke,
5369 NULL
5372 static const tid_t HTMLFiltersCollection_iface_tids[] = {
5373 IHTMLFiltersCollection_tid,
5376 static dispex_static_data_t HTMLFiltersCollection_dispex = {
5377 &HTMLFiltersCollection_dispex_vtbl,
5378 IHTMLFiltersCollection_tid,
5379 HTMLFiltersCollection_iface_tids
5382 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
5384 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
5386 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
5387 ret->ref = 1;
5389 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
5390 &HTMLFiltersCollection_dispex);
5392 return &ret->IHTMLFiltersCollection_iface;
5395 /* interface IHTMLAttributeCollection */
5396 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
5398 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
5401 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
5403 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5405 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5407 if(IsEqualGUID(&IID_IUnknown, riid)) {
5408 *ppv = &This->IHTMLAttributeCollection_iface;
5409 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
5410 *ppv = &This->IHTMLAttributeCollection_iface;
5411 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
5412 *ppv = &This->IHTMLAttributeCollection2_iface;
5413 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
5414 *ppv = &This->IHTMLAttributeCollection3_iface;
5415 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5416 return *ppv ? S_OK : E_NOINTERFACE;
5417 }else {
5418 *ppv = NULL;
5419 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5420 return E_NOINTERFACE;
5423 IUnknown_AddRef((IUnknown*)*ppv);
5424 return S_OK;
5427 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
5429 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5430 LONG ref = InterlockedIncrement(&This->ref);
5432 TRACE("(%p) ref=%d\n", This, ref);
5434 return ref;
5437 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
5439 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5440 LONG ref = InterlockedDecrement(&This->ref);
5442 TRACE("(%p) ref=%d\n", This, ref);
5444 if(!ref) {
5445 while(!list_empty(&This->attrs)) {
5446 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
5448 list_remove(&attr->entry);
5449 attr->elem = NULL;
5450 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
5453 heap_free(This);
5456 return ref;
5459 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
5461 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5462 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5465 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
5466 LCID lcid, ITypeInfo **ppTInfo)
5468 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5469 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5472 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
5473 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5475 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5476 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5477 lcid, rgDispId);
5480 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
5481 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5482 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5484 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5485 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5486 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5489 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
5491 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
5492 DISPID id = DISPID_STARTENUM;
5493 LONG len = -1;
5494 HRESULT hres;
5496 FIXME("filter non-enumerable attributes out\n");
5498 while(1) {
5499 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
5500 if(FAILED(hres))
5501 return hres;
5502 else if(hres == S_FALSE)
5503 break;
5505 len++;
5506 if(len == *idx)
5507 break;
5510 if(dispid) {
5511 *dispid = id;
5512 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
5515 *idx = len+1;
5516 return S_OK;
5519 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
5521 HRESULT hres;
5523 if(name[0]>='0' && name[0]<='9') {
5524 WCHAR *end_ptr;
5525 LONG idx;
5527 idx = strtoulW(name, &end_ptr, 10);
5528 if(!*end_ptr) {
5529 hres = get_attr_dispid_by_idx(This, &idx, id);
5530 if(SUCCEEDED(hres))
5531 return hres;
5535 if(!This->elem) {
5536 WARN("NULL elem\n");
5537 return E_UNEXPECTED;
5540 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
5541 name, fdexNameCaseInsensitive, id);
5542 return hres;
5545 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
5547 HTMLDOMAttribute *iter;
5548 LONG pos = 0;
5549 HRESULT hres;
5551 *attr = NULL;
5552 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
5553 if(iter->dispid == id) {
5554 *attr = iter;
5555 break;
5557 pos++;
5560 if(!*attr) {
5561 if(!This->elem) {
5562 WARN("NULL elem\n");
5563 return E_UNEXPECTED;
5566 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
5567 if(FAILED(hres))
5568 return hres;
5571 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
5572 if(list_pos)
5573 *list_pos = pos;
5574 return S_OK;
5577 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
5579 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5580 HRESULT hres;
5582 TRACE("(%p)->(%p)\n", This, p);
5584 *p = -1;
5585 hres = get_attr_dispid_by_idx(This, p, NULL);
5586 return hres;
5589 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
5591 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5592 FIXME("(%p)->(%p)\n", This, p);
5593 return E_NOTIMPL;
5596 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
5598 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5599 HTMLDOMAttribute *attr;
5600 DISPID id;
5601 HRESULT hres;
5603 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
5605 switch(V_VT(name)) {
5606 case VT_I4:
5607 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
5608 break;
5609 case VT_BSTR:
5610 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
5611 break;
5612 default:
5613 FIXME("unsupported name %s\n", debugstr_variant(name));
5614 hres = E_NOTIMPL;
5616 if(hres == DISP_E_UNKNOWNNAME)
5617 return E_INVALIDARG;
5618 if(FAILED(hres))
5619 return hres;
5621 hres = get_domattr(This, id, NULL, &attr);
5622 if(FAILED(hres))
5623 return hres;
5625 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
5626 return S_OK;
5629 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
5630 HTMLAttributeCollection_QueryInterface,
5631 HTMLAttributeCollection_AddRef,
5632 HTMLAttributeCollection_Release,
5633 HTMLAttributeCollection_GetTypeInfoCount,
5634 HTMLAttributeCollection_GetTypeInfo,
5635 HTMLAttributeCollection_GetIDsOfNames,
5636 HTMLAttributeCollection_Invoke,
5637 HTMLAttributeCollection_get_length,
5638 HTMLAttributeCollection__newEnum,
5639 HTMLAttributeCollection_item
5642 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
5644 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
5647 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
5649 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5650 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
5653 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
5655 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5656 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
5659 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
5661 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5662 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
5665 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
5667 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5668 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5671 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
5672 LCID lcid, ITypeInfo **ppTInfo)
5674 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5675 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5678 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
5679 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5681 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5682 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5683 lcid, rgDispId);
5686 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
5687 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5688 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5690 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5691 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5692 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5695 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
5696 IHTMLDOMAttribute **newretNode)
5698 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5699 HTMLDOMAttribute *attr;
5700 DISPID id;
5701 HRESULT hres;
5703 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
5705 hres = get_attr_dispid_by_name(This, bstrName, &id);
5706 if(hres == DISP_E_UNKNOWNNAME) {
5707 *newretNode = NULL;
5708 return S_OK;
5709 } else if(FAILED(hres)) {
5710 return hres;
5713 hres = get_domattr(This, id, NULL, &attr);
5714 if(FAILED(hres))
5715 return hres;
5717 *newretNode = &attr->IHTMLDOMAttribute_iface;
5718 return S_OK;
5721 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
5722 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
5724 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5725 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
5726 return E_NOTIMPL;
5729 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
5730 BSTR bstrName, IHTMLDOMAttribute **newretNode)
5732 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
5733 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
5734 return E_NOTIMPL;
5737 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
5738 HTMLAttributeCollection2_QueryInterface,
5739 HTMLAttributeCollection2_AddRef,
5740 HTMLAttributeCollection2_Release,
5741 HTMLAttributeCollection2_GetTypeInfoCount,
5742 HTMLAttributeCollection2_GetTypeInfo,
5743 HTMLAttributeCollection2_GetIDsOfNames,
5744 HTMLAttributeCollection2_Invoke,
5745 HTMLAttributeCollection2_getNamedItem,
5746 HTMLAttributeCollection2_setNamedItem,
5747 HTMLAttributeCollection2_removeNamedItem
5750 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
5752 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
5755 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
5757 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5758 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
5761 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
5763 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5764 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
5767 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
5769 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5770 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
5773 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
5775 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5776 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5779 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
5780 LCID lcid, ITypeInfo **ppTInfo)
5782 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5783 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5786 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
5787 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5789 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5790 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5791 lcid, rgDispId);
5794 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
5795 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5796 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5798 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5799 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5800 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5803 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
5804 IHTMLDOMAttribute **ppNodeOut)
5806 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5807 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
5810 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
5811 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
5813 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5814 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
5815 return E_NOTIMPL;
5818 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
5819 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
5821 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5822 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
5823 return E_NOTIMPL;
5826 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
5828 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5829 HTMLDOMAttribute *attr;
5830 DISPID id;
5831 HRESULT hres;
5833 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
5835 hres = get_attr_dispid_by_idx(This, &index, &id);
5836 if(hres == DISP_E_UNKNOWNNAME)
5837 return E_INVALIDARG;
5838 if(FAILED(hres))
5839 return hres;
5841 hres = get_domattr(This, id, NULL, &attr);
5842 if(FAILED(hres))
5843 return hres;
5845 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
5846 return S_OK;
5849 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
5851 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
5852 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
5855 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
5856 HTMLAttributeCollection3_QueryInterface,
5857 HTMLAttributeCollection3_AddRef,
5858 HTMLAttributeCollection3_Release,
5859 HTMLAttributeCollection3_GetTypeInfoCount,
5860 HTMLAttributeCollection3_GetTypeInfo,
5861 HTMLAttributeCollection3_GetIDsOfNames,
5862 HTMLAttributeCollection3_Invoke,
5863 HTMLAttributeCollection3_getNamedItem,
5864 HTMLAttributeCollection3_setNamedItem,
5865 HTMLAttributeCollection3_removeNamedItem,
5866 HTMLAttributeCollection3_item,
5867 HTMLAttributeCollection3_get_length
5870 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
5872 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
5875 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
5877 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
5878 HTMLDOMAttribute *attr;
5879 LONG pos;
5880 HRESULT hres;
5882 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
5884 hres = get_attr_dispid_by_name(This, name, dispid);
5885 if(FAILED(hres))
5886 return hres;
5888 hres = get_domattr(This, *dispid, &pos, &attr);
5889 if(FAILED(hres))
5890 return hres;
5891 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
5893 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
5894 return S_OK;
5897 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
5898 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5900 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
5902 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
5904 switch(flags) {
5905 case DISPATCH_PROPERTYGET: {
5906 HTMLDOMAttribute *iter;
5907 DWORD pos;
5909 pos = id-MSHTML_DISPID_CUSTOM_MIN;
5911 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
5912 if(!pos) {
5913 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
5914 V_VT(res) = VT_DISPATCH;
5915 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
5916 return S_OK;
5918 pos--;
5921 WARN("invalid arg\n");
5922 return E_INVALIDARG;
5925 default:
5926 FIXME("unimplemented flags %x\n", flags);
5927 return E_NOTIMPL;
5931 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
5932 NULL,
5933 HTMLAttributeCollection_get_dispid,
5934 HTMLAttributeCollection_invoke,
5935 NULL
5938 static const tid_t HTMLAttributeCollection_iface_tids[] = {
5939 IHTMLAttributeCollection_tid,
5940 IHTMLAttributeCollection2_tid,
5941 IHTMLAttributeCollection3_tid,
5945 static dispex_static_data_t HTMLAttributeCollection_dispex = {
5946 &HTMLAttributeCollection_dispex_vtbl,
5947 DispHTMLAttributeCollection_tid,
5948 HTMLAttributeCollection_iface_tids
5951 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
5953 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5955 if(This->attrs) {
5956 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
5957 *ac = This->attrs;
5958 return S_OK;
5961 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
5962 if(!This->attrs)
5963 return E_OUTOFMEMORY;
5965 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
5966 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
5967 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
5968 This->attrs->ref = 2;
5970 This->attrs->elem = This;
5971 list_init(&This->attrs->attrs);
5972 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
5973 &HTMLAttributeCollection_dispex);
5975 *ac = This->attrs;
5976 return S_OK;