ntdll: Fix error code when querying too large memory address.
[wine.git] / dlls / mshtml / htmlelem.c
blob8a4e164540d90735817abb2fb75214ff873c5aeb
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*,nsIDOMElement*,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(nsIDOMElement *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 = nsIDOMElement_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->dom_element, 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 = nsIDOMElement_SetAttribute(elem->dom_element, &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, nsIDOMElement **ret)
274 nsAString tag_str;
275 nsresult nsres;
277 if(!doc->nsdoc) {
278 WARN("NULL nsdoc\n");
279 return E_UNEXPECTED;
282 nsAString_InitDepend(&tag_str, tag);
283 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, ret);
284 nsAString_Finish(&tag_str);
285 if(NS_FAILED(nsres)) {
286 ERR("CreateElement failed: %08x\n", nsres);
287 return E_FAIL;
290 return S_OK;
293 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
295 nsIDOMElement *nselem;
296 HRESULT hres;
298 /* Use owner doc if called on document fragment */
299 if(!doc->nsdoc)
300 doc = doc->node.doc;
302 hres = create_nselem(doc, tag, &nselem);
303 if(FAILED(hres))
304 return hres;
306 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
307 nsIDOMElement_Release(nselem);
308 return hres;
311 typedef struct {
312 DispatchEx dispex;
313 IHTMLRect IHTMLRect_iface;
315 LONG ref;
317 nsIDOMClientRect *nsrect;
318 } HTMLRect;
320 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
322 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
325 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
327 HTMLRect *This = impl_from_IHTMLRect(iface);
329 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
331 if(IsEqualGUID(&IID_IUnknown, riid)) {
332 *ppv = &This->IHTMLRect_iface;
333 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
334 *ppv = &This->IHTMLRect_iface;
335 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
336 return *ppv ? S_OK : E_NOINTERFACE;
337 }else {
338 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
339 *ppv = NULL;
340 return E_NOINTERFACE;
343 IUnknown_AddRef((IUnknown*)*ppv);
344 return S_OK;
347 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
349 HTMLRect *This = impl_from_IHTMLRect(iface);
350 LONG ref = InterlockedIncrement(&This->ref);
352 TRACE("(%p) ref=%d\n", This, ref);
354 return ref;
357 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
359 HTMLRect *This = impl_from_IHTMLRect(iface);
360 LONG ref = InterlockedDecrement(&This->ref);
362 TRACE("(%p) ref=%d\n", This, ref);
364 if(!ref) {
365 if(This->nsrect)
366 nsIDOMClientRect_Release(This->nsrect);
367 release_dispex(&This->dispex);
368 heap_free(This);
371 return ref;
374 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
376 HTMLRect *This = impl_from_IHTMLRect(iface);
377 FIXME("(%p)->(%p)\n", This, pctinfo);
378 return E_NOTIMPL;
381 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
382 LCID lcid, ITypeInfo **ppTInfo)
384 HTMLRect *This = impl_from_IHTMLRect(iface);
386 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
389 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
390 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
392 HTMLRect *This = impl_from_IHTMLRect(iface);
394 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
395 lcid, rgDispId);
398 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
399 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
400 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
402 HTMLRect *This = impl_from_IHTMLRect(iface);
404 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
405 pDispParams, pVarResult, pExcepInfo, puArgErr);
408 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
410 HTMLRect *This = impl_from_IHTMLRect(iface);
411 FIXME("(%p)->(%d)\n", This, v);
412 return E_NOTIMPL;
415 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
417 HTMLRect *This = impl_from_IHTMLRect(iface);
418 float left;
419 nsresult nsres;
421 TRACE("(%p)->(%p)\n", This, p);
423 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
424 if(NS_FAILED(nsres)) {
425 ERR("GetLeft failed: %08x\n", nsres);
426 return E_FAIL;
429 *p = floor(left+0.5);
430 return S_OK;
433 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
435 HTMLRect *This = impl_from_IHTMLRect(iface);
436 FIXME("(%p)->(%d)\n", This, v);
437 return E_NOTIMPL;
440 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
442 HTMLRect *This = impl_from_IHTMLRect(iface);
443 float top;
444 nsresult nsres;
446 TRACE("(%p)->(%p)\n", This, p);
448 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
449 if(NS_FAILED(nsres)) {
450 ERR("GetTop failed: %08x\n", nsres);
451 return E_FAIL;
454 *p = floor(top+0.5);
455 return S_OK;
458 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
460 HTMLRect *This = impl_from_IHTMLRect(iface);
461 FIXME("(%p)->(%d)\n", This, v);
462 return E_NOTIMPL;
465 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
467 HTMLRect *This = impl_from_IHTMLRect(iface);
468 float right;
469 nsresult nsres;
471 TRACE("(%p)->(%p)\n", This, p);
473 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
474 if(NS_FAILED(nsres)) {
475 ERR("GetRight failed: %08x\n", nsres);
476 return E_FAIL;
479 *p = floor(right+0.5);
480 return S_OK;
483 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
485 HTMLRect *This = impl_from_IHTMLRect(iface);
486 FIXME("(%p)->(%d)\n", This, v);
487 return E_NOTIMPL;
490 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
492 HTMLRect *This = impl_from_IHTMLRect(iface);
493 float bottom;
494 nsresult nsres;
496 TRACE("(%p)->(%p)\n", This, p);
498 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
499 if(NS_FAILED(nsres)) {
500 ERR("GetBottom failed: %08x\n", nsres);
501 return E_FAIL;
504 *p = floor(bottom+0.5);
505 return S_OK;
508 static const IHTMLRectVtbl HTMLRectVtbl = {
509 HTMLRect_QueryInterface,
510 HTMLRect_AddRef,
511 HTMLRect_Release,
512 HTMLRect_GetTypeInfoCount,
513 HTMLRect_GetTypeInfo,
514 HTMLRect_GetIDsOfNames,
515 HTMLRect_Invoke,
516 HTMLRect_put_left,
517 HTMLRect_get_left,
518 HTMLRect_put_top,
519 HTMLRect_get_top,
520 HTMLRect_put_right,
521 HTMLRect_get_right,
522 HTMLRect_put_bottom,
523 HTMLRect_get_bottom
526 static const tid_t HTMLRect_iface_tids[] = {
527 IHTMLRect_tid,
530 static dispex_static_data_t HTMLRect_dispex = {
531 NULL,
532 IHTMLRect_tid,
533 HTMLRect_iface_tids
536 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
538 HTMLRect *rect;
540 rect = heap_alloc_zero(sizeof(HTMLRect));
541 if(!rect)
542 return E_OUTOFMEMORY;
544 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
545 rect->ref = 1;
547 init_dispex(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex);
549 nsIDOMClientRect_AddRef(nsrect);
550 rect->nsrect = nsrect;
552 *ret = &rect->IHTMLRect_iface;
553 return S_OK;
556 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
557 REFIID riid, void **ppv)
559 HTMLElement *This = impl_from_IHTMLElement(iface);
561 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
564 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
566 HTMLElement *This = impl_from_IHTMLElement(iface);
568 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
571 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
573 HTMLElement *This = impl_from_IHTMLElement(iface);
575 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
578 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
580 HTMLElement *This = impl_from_IHTMLElement(iface);
581 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
584 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
585 LCID lcid, ITypeInfo **ppTInfo)
587 HTMLElement *This = impl_from_IHTMLElement(iface);
588 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
591 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
592 LPOLESTR *rgszNames, UINT cNames,
593 LCID lcid, DISPID *rgDispId)
595 HTMLElement *This = impl_from_IHTMLElement(iface);
596 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
597 lcid, rgDispId);
600 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
601 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
602 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
604 HTMLElement *This = impl_from_IHTMLElement(iface);
605 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
606 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
609 static HRESULT set_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *v)
611 DISPID propput_dispid = DISPID_PROPERTYPUT;
612 DISPPARAMS dp = {v, &propput_dispid, 1, 1};
613 EXCEPINFO ei;
615 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
616 TRACE("Ignoring call on style attribute\n");
617 return S_OK;
620 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid,
621 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL);
624 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
625 VARIANT AttributeValue, LONG lFlags)
627 HTMLElement *This = impl_from_IHTMLElement(iface);
628 DISPID dispid;
629 HRESULT hres;
631 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
633 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
634 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
635 if(FAILED(hres))
636 return hres;
638 return set_elem_attr_value_by_dispid(This, dispid, &AttributeValue);
641 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, VARIANT *ret)
643 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
644 EXCEPINFO excep;
646 return IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
647 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
650 HRESULT attr_value_to_string(VARIANT *v)
652 HRESULT hres;
654 static const WCHAR nullW[] = {'n','u','l','l',0};
656 switch(V_VT(v)) {
657 case VT_BSTR:
658 break;
659 case VT_NULL:
660 V_BSTR(v) = SysAllocString(nullW);
661 if(!V_BSTR(v))
662 return E_OUTOFMEMORY;
663 V_VT(v) = VT_BSTR;
664 break;
665 case VT_DISPATCH:
666 IDispatch_Release(V_DISPATCH(v));
667 V_VT(v) = VT_BSTR;
668 V_BSTR(v) = SysAllocString(NULL);
669 break;
670 default:
671 hres = VariantChangeType(v, v, 0, VT_BSTR);
672 if(FAILED(hres))
673 return hres;
676 return S_OK;
679 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
680 LONG lFlags, VARIANT *AttributeValue)
682 HTMLElement *This = impl_from_IHTMLElement(iface);
683 DISPID dispid;
684 HRESULT hres;
686 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
688 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
689 FIXME("Unsupported flags %x\n", lFlags);
691 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
692 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
693 if(hres == DISP_E_UNKNOWNNAME) {
694 V_VT(AttributeValue) = VT_NULL;
695 return S_OK;
698 if(FAILED(hres)) {
699 V_VT(AttributeValue) = VT_NULL;
700 return hres;
703 hres = get_elem_attr_value_by_dispid(This, dispid, AttributeValue);
704 if(SUCCEEDED(hres) && (lFlags & ATTRFLAG_ASSTRING))
705 hres = attr_value_to_string(AttributeValue);
706 return hres;
709 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
710 LONG lFlags, VARIANT_BOOL *pfSuccess)
712 HTMLElement *This = impl_from_IHTMLElement(iface);
713 DISPID id;
714 HRESULT hres;
716 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
718 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
719 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
720 if(hres == DISP_E_UNKNOWNNAME) {
721 *pfSuccess = VARIANT_FALSE;
722 return S_OK;
724 if(FAILED(hres))
725 return hres;
727 if(id == DISPID_IHTMLELEMENT_STYLE) {
728 IHTMLStyle *style;
730 TRACE("Special case: style\n");
732 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
733 if(FAILED(hres))
734 return hres;
736 hres = IHTMLStyle_put_cssText(style, NULL);
737 IHTMLStyle_Release(style);
738 if(FAILED(hres))
739 return hres;
741 *pfSuccess = VARIANT_TRUE;
742 return S_OK;
745 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
748 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
750 HTMLElement *This = impl_from_IHTMLElement(iface);
751 nsAString classname_str;
752 nsresult nsres;
754 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
756 if(!This->dom_element) {
757 FIXME("comment element\n");
758 return E_NOTIMPL;
761 nsAString_InitDepend(&classname_str, v);
762 nsres = nsIDOMElement_SetClassName(This->dom_element, &classname_str);
763 nsAString_Finish(&classname_str);
764 if(NS_FAILED(nsres))
765 ERR("SetClassName failed: %08x\n", nsres);
767 return S_OK;
770 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
772 HTMLElement *This = impl_from_IHTMLElement(iface);
773 nsAString class_str;
774 nsresult nsres;
776 TRACE("(%p)->(%p)\n", This, p);
778 if(!This->dom_element) {
779 FIXME("comment element\n");
780 return E_NOTIMPL;
783 nsAString_Init(&class_str, NULL);
784 nsres = nsIDOMElement_GetClassName(This->dom_element, &class_str);
785 return return_nsstr(nsres, &class_str, p);
788 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
790 HTMLElement *This = impl_from_IHTMLElement(iface);
791 nsAString id_str;
792 nsresult nsres;
794 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
796 if(!This->dom_element) {
797 FIXME("comment element\n");
798 return S_OK;
801 nsAString_InitDepend(&id_str, v);
802 nsres = nsIDOMElement_SetId(This->dom_element, &id_str);
803 nsAString_Finish(&id_str);
804 if(NS_FAILED(nsres))
805 ERR("SetId failed: %08x\n", nsres);
807 return S_OK;
810 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
812 HTMLElement *This = impl_from_IHTMLElement(iface);
813 nsAString id_str;
814 nsresult nsres;
816 TRACE("(%p)->(%p)\n", This, p);
818 if(!This->dom_element) {
819 *p = NULL;
820 return S_OK;
823 nsAString_Init(&id_str, NULL);
824 nsres = nsIDOMElement_GetId(This->dom_element, &id_str);
825 return return_nsstr(nsres, &id_str, p);
828 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
830 HTMLElement *This = impl_from_IHTMLElement(iface);
831 nsAString tag_str;
832 nsresult nsres;
834 TRACE("(%p)->(%p)\n", This, p);
836 if(!This->dom_element) {
837 static const WCHAR comment_tagW[] = {'!',0};
839 TRACE("comment element\n");
840 *p = SysAllocString(comment_tagW);
841 return *p ? S_OK : E_OUTOFMEMORY;
844 nsAString_Init(&tag_str, NULL);
845 nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
846 return return_nsstr(nsres, &tag_str, p);
849 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
851 HTMLElement *This = impl_from_IHTMLElement(iface);
852 IHTMLDOMNode *node;
853 HRESULT hres;
855 TRACE("(%p)->(%p)\n", This, p);
857 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
858 if(FAILED(hres))
859 return hres;
861 if(!node) {
862 *p = NULL;
863 return S_OK;
866 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
867 IHTMLDOMNode_Release(node);
868 if(FAILED(hres))
869 *p = NULL;
871 return S_OK;
874 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
876 HTMLElement *This = impl_from_IHTMLElement(iface);
878 TRACE("(%p)->(%p)\n", This, p);
880 if(!This->style) {
881 HRESULT hres;
883 hres = HTMLStyle_Create(This, &This->style);
884 if(FAILED(hres))
885 return hres;
888 *p = &This->style->IHTMLStyle_iface;
889 IHTMLStyle_AddRef(*p);
890 return S_OK;
893 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
895 HTMLElement *This = impl_from_IHTMLElement(iface);
897 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
899 return set_node_event(&This->node, EVENTID_HELP, &v);
902 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
904 HTMLElement *This = impl_from_IHTMLElement(iface);
906 TRACE("(%p)->(%p)\n", This, p);
908 return get_node_event(&This->node, EVENTID_HELP, p);
911 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
913 HTMLElement *This = impl_from_IHTMLElement(iface);
915 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
917 return set_node_event(&This->node, EVENTID_CLICK, &v);
920 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
922 HTMLElement *This = impl_from_IHTMLElement(iface);
924 TRACE("(%p)->(%p)\n", This, p);
926 return get_node_event(&This->node, EVENTID_CLICK, p);
929 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
931 HTMLElement *This = impl_from_IHTMLElement(iface);
933 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
935 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
938 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
940 HTMLElement *This = impl_from_IHTMLElement(iface);
942 TRACE("(%p)->(%p)\n", This, p);
944 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
947 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
949 HTMLElement *This = impl_from_IHTMLElement(iface);
951 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
953 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
956 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
958 HTMLElement *This = impl_from_IHTMLElement(iface);
960 TRACE("(%p)->(%p)\n", This, p);
962 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
965 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
967 HTMLElement *This = impl_from_IHTMLElement(iface);
969 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
971 return set_node_event(&This->node, EVENTID_KEYUP, &v);
974 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
976 HTMLElement *This = impl_from_IHTMLElement(iface);
978 TRACE("(%p)->(%p)\n", This, p);
980 return get_node_event(&This->node, EVENTID_KEYUP, p);
983 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
985 HTMLElement *This = impl_from_IHTMLElement(iface);
987 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
989 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
992 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
994 HTMLElement *This = impl_from_IHTMLElement(iface);
996 TRACE("(%p)->(%p)\n", This, p);
998 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
1001 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
1003 HTMLElement *This = impl_from_IHTMLElement(iface);
1005 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1007 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1010 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1012 HTMLElement *This = impl_from_IHTMLElement(iface);
1014 TRACE("(%p)->(%p)\n", This, p);
1016 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1019 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1021 HTMLElement *This = impl_from_IHTMLElement(iface);
1023 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1025 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1028 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1030 HTMLElement *This = impl_from_IHTMLElement(iface);
1032 TRACE("(%p)->(%p)\n", This, p);
1034 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1037 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1039 HTMLElement *This = impl_from_IHTMLElement(iface);
1041 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1043 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1046 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1048 HTMLElement *This = impl_from_IHTMLElement(iface);
1050 TRACE("(%p)->(%p)\n", This, p);
1052 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1055 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1057 HTMLElement *This = impl_from_IHTMLElement(iface);
1059 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1061 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1064 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1066 HTMLElement *This = impl_from_IHTMLElement(iface);
1068 TRACE("(%p)->(%p)\n", This, p);
1070 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1073 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1075 HTMLElement *This = impl_from_IHTMLElement(iface);
1077 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1079 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1082 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1084 HTMLElement *This = impl_from_IHTMLElement(iface);
1086 TRACE("(%p)->(%p)\n", This, p);
1088 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1091 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1093 HTMLElement *This = impl_from_IHTMLElement(iface);
1095 TRACE("(%p)->(%p)\n", This, p);
1097 if(!p)
1098 return E_POINTER;
1100 if(This->node.vtbl->get_document)
1101 return This->node.vtbl->get_document(&This->node, p);
1103 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1104 IDispatch_AddRef(*p);
1105 return S_OK;
1108 static const WCHAR titleW[] = {'t','i','t','l','e',0};
1110 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1112 HTMLElement *This = impl_from_IHTMLElement(iface);
1113 nsAString title_str;
1114 nsresult nsres;
1116 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1118 if(!This->html_element) {
1119 VARIANT *var;
1120 HRESULT hres;
1122 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, TRUE, &var);
1123 if(FAILED(hres))
1124 return hres;
1126 VariantClear(var);
1127 V_VT(var) = VT_BSTR;
1128 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1129 return S_OK;
1132 nsAString_InitDepend(&title_str, v);
1133 nsres = nsIDOMHTMLElement_SetTitle(This->html_element, &title_str);
1134 nsAString_Finish(&title_str);
1135 if(NS_FAILED(nsres))
1136 ERR("SetTitle failed: %08x\n", nsres);
1138 return S_OK;
1141 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1143 HTMLElement *This = impl_from_IHTMLElement(iface);
1144 nsAString title_str;
1145 nsresult nsres;
1147 TRACE("(%p)->(%p)\n", This, p);
1149 if(!This->html_element) {
1150 VARIANT *var;
1151 HRESULT hres;
1153 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, FALSE, &var);
1154 if(hres == DISP_E_UNKNOWNNAME) {
1155 *p = NULL;
1156 }else if(V_VT(var) != VT_BSTR) {
1157 FIXME("title = %s\n", debugstr_variant(var));
1158 return E_FAIL;
1159 }else {
1160 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1163 return S_OK;
1166 nsAString_Init(&title_str, NULL);
1167 nsres = nsIDOMHTMLElement_GetTitle(This->html_element, &title_str);
1168 return return_nsstr(nsres, &title_str, p);
1171 static const WCHAR languageW[] = {'l','a','n','g','u','a','g','e',0};
1173 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1175 HTMLElement *This = impl_from_IHTMLElement(iface);
1177 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1179 return elem_string_attr_setter(This, languageW, v);
1182 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1184 HTMLElement *This = impl_from_IHTMLElement(iface);
1186 TRACE("(%p)->(%p)\n", This, p);
1188 return elem_string_attr_getter(This, languageW, TRUE, p);
1191 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1193 HTMLElement *This = impl_from_IHTMLElement(iface);
1195 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1197 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1200 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1202 HTMLElement *This = impl_from_IHTMLElement(iface);
1204 TRACE("(%p)->(%p)\n", This, p);
1206 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1209 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1211 HTMLElement *This = impl_from_IHTMLElement(iface);
1212 cpp_bool start = TRUE;
1213 nsresult nsres;
1215 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1217 switch(V_VT(&varargStart)) {
1218 case VT_EMPTY:
1219 case VT_ERROR:
1220 break;
1221 case VT_BOOL:
1222 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1223 break;
1224 default:
1225 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1228 if(!This->html_element) {
1229 FIXME("non-HTML elements\n");
1230 return E_NOTIMPL;
1233 nsres = nsIDOMHTMLElement_ScrollIntoView(This->html_element, start, 1);
1234 assert(nsres == NS_OK);
1236 return S_OK;
1239 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1240 VARIANT_BOOL *pfResult)
1242 HTMLElement *This = impl_from_IHTMLElement(iface);
1243 cpp_bool result = FALSE;
1245 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1247 if(pChild) {
1248 HTMLElement *child;
1249 nsresult nsres;
1251 child = unsafe_impl_from_IHTMLElement(pChild);
1252 if(!child) {
1253 ERR("not our element\n");
1254 return E_FAIL;
1257 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1258 assert(nsres == NS_OK);
1261 *pfResult = variant_bool(result);
1262 return S_OK;
1265 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1267 HTMLElement *This = impl_from_IHTMLElement(iface);
1269 TRACE("(%p)->(%p)\n", This, p);
1271 return get_elem_source_index(This, p);
1274 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1276 HTMLElement *This = impl_from_IHTMLElement(iface);
1277 FIXME("(%p)->(%p)\n", This, p);
1278 return E_NOTIMPL;
1281 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1283 HTMLElement *This = impl_from_IHTMLElement(iface);
1284 nsAString nsstr;
1285 nsresult nsres;
1287 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1289 if(!This->html_element) {
1290 FIXME("non-HTML element\n");
1291 return E_NOTIMPL;
1294 nsAString_InitDepend(&nsstr, v);
1295 nsres = nsIDOMHTMLElement_SetLang(This->html_element, &nsstr);
1296 nsAString_Finish(&nsstr);
1297 if(NS_FAILED(nsres)) {
1298 ERR("SetLang failed: %08x\n", nsres);
1299 return E_FAIL;
1302 return S_OK;
1305 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1307 HTMLElement *This = impl_from_IHTMLElement(iface);
1308 nsAString nsstr;
1309 nsresult nsres;
1311 TRACE("(%p)->(%p)\n", This, p);
1313 if(!This->html_element) {
1314 FIXME("non-HTML element\n");
1315 return E_NOTIMPL;
1318 nsAString_Init(&nsstr, NULL);
1319 nsres = nsIDOMHTMLElement_GetLang(This->html_element, &nsstr);
1320 return return_nsstr(nsres, &nsstr, p);
1323 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1325 HTMLElement *This = impl_from_IHTMLElement(iface);
1326 nsresult nsres;
1328 TRACE("(%p)->(%p)\n", This, p);
1330 if(!This->html_element) {
1331 FIXME("non-HTML element\n");
1332 return E_NOTIMPL;
1335 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->html_element, p);
1336 if(NS_FAILED(nsres)) {
1337 ERR("GetOffsetLeft failed: %08x\n", nsres);
1338 return E_FAIL;
1341 return S_OK;
1344 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1346 HTMLElement *This = impl_from_IHTMLElement(iface);
1347 nsresult nsres;
1349 TRACE("(%p)->(%p)\n", This, p);
1351 if(!This->html_element) {
1352 FIXME("non-HTML element\n");
1353 return E_NOTIMPL;
1356 nsres = nsIDOMHTMLElement_GetOffsetTop(This->html_element, p);
1357 if(NS_FAILED(nsres)) {
1358 ERR("GetOffsetTop failed: %08x\n", nsres);
1359 return E_FAIL;
1362 return S_OK;
1365 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1367 HTMLElement *This = impl_from_IHTMLElement(iface);
1368 nsresult nsres;
1370 TRACE("(%p)->(%p)\n", This, p);
1372 if(!This->html_element) {
1373 FIXME("non-HTML element\n");
1374 return E_NOTIMPL;
1377 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->html_element, p);
1378 if(NS_FAILED(nsres)) {
1379 ERR("GetOffsetWidth failed: %08x\n", nsres);
1380 return E_FAIL;
1383 return S_OK;
1386 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1388 HTMLElement *This = impl_from_IHTMLElement(iface);
1389 nsresult nsres;
1391 TRACE("(%p)->(%p)\n", This, p);
1393 if(!This->html_element) {
1394 FIXME("non-HTML element\n");
1395 return E_NOTIMPL;
1398 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->html_element, p);
1399 if(NS_FAILED(nsres)) {
1400 ERR("GetOffsetHeight failed: %08x\n", nsres);
1401 return E_FAIL;
1404 return S_OK;
1407 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1409 HTMLElement *This = impl_from_IHTMLElement(iface);
1410 nsIDOMElement *nsparent;
1411 HTMLElement *parent;
1412 nsresult nsres;
1413 HRESULT hres;
1415 TRACE("(%p)->(%p)\n", This, p);
1417 if(!This->html_element) {
1418 FIXME("non-HTML element\n");
1419 return E_NOTIMPL;
1422 nsres = nsIDOMHTMLElement_GetOffsetParent(This->html_element, &nsparent);
1423 if(NS_FAILED(nsres)) {
1424 ERR("GetOffsetParent failed: %08x\n", nsres);
1425 return E_FAIL;
1428 if(!nsparent) {
1429 *p = NULL;
1430 hres = S_OK;
1433 hres = get_element(nsparent, &parent);
1434 nsIDOMElement_Release(nsparent);
1435 if(FAILED(hres))
1436 return hres;
1438 *p = &parent->IHTMLElement_iface;
1439 return S_OK;
1442 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1444 HTMLElement *This = impl_from_IHTMLElement(iface);
1445 nsAString html_str;
1446 nsresult nsres;
1448 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1450 if(!This->html_element) {
1451 FIXME("non-HTML element\n");
1452 return E_NOTIMPL;
1455 nsAString_InitDepend(&html_str, v);
1456 nsres = nsIDOMHTMLElement_SetInnerHTML(This->html_element, &html_str);
1457 nsAString_Finish(&html_str);
1458 if(NS_FAILED(nsres)) {
1459 FIXME("SetInnerHtml failed %08x\n", nsres);
1460 return E_FAIL;
1463 return S_OK;
1466 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1468 HTMLElement *This = impl_from_IHTMLElement(iface);
1469 nsAString html_str;
1470 nsresult nsres;
1472 TRACE("(%p)->(%p)\n", This, p);
1474 if(!This->html_element) {
1475 FIXME("non-HTML element\n");
1476 return E_NOTIMPL;
1479 nsAString_Init(&html_str, NULL);
1480 nsres = nsIDOMHTMLElement_GetInnerHTML(This->html_element, &html_str);
1481 return return_nsstr(nsres, &html_str, p);
1484 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1486 HTMLElement *This = impl_from_IHTMLElement(iface);
1487 nsIDOMNode *nschild, *tmp;
1488 nsIDOMText *text_node;
1489 nsAString text_str;
1490 nsresult nsres;
1492 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1494 while(1) {
1495 nsres = nsIDOMElement_GetLastChild(This->dom_element, &nschild);
1496 if(NS_FAILED(nsres)) {
1497 ERR("GetLastChild failed: %08x\n", nsres);
1498 return E_FAIL;
1500 if(!nschild)
1501 break;
1503 nsres = nsIDOMElement_RemoveChild(This->dom_element, nschild, &tmp);
1504 nsIDOMNode_Release(nschild);
1505 if(NS_FAILED(nsres)) {
1506 ERR("RemoveChild failed: %08x\n", nsres);
1507 return E_FAIL;
1509 nsIDOMNode_Release(tmp);
1512 nsAString_InitDepend(&text_str, v);
1513 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1514 nsAString_Finish(&text_str);
1515 if(NS_FAILED(nsres)) {
1516 ERR("CreateTextNode failed: %08x\n", nsres);
1517 return E_FAIL;
1520 nsres = nsIDOMElement_AppendChild(This->dom_element, (nsIDOMNode*)text_node, &tmp);
1521 if(NS_FAILED(nsres)) {
1522 ERR("AppendChild failed: %08x\n", nsres);
1523 return E_FAIL;
1526 nsIDOMNode_Release(tmp);
1527 return S_OK;
1530 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1532 HTMLElement *This = impl_from_IHTMLElement(iface);
1534 TRACE("(%p)->(%p)\n", This, p);
1536 return get_node_text(&This->node, p);
1539 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1541 HTMLElement *This = impl_from_IHTMLElement(iface);
1543 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1545 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1548 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1550 HTMLElement *This = impl_from_IHTMLElement(iface);
1551 nsAString html_str;
1552 HRESULT hres;
1554 WARN("(%p)->(%p) semi-stub\n", This, p);
1556 nsAString_Init(&html_str, NULL);
1557 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1558 if(SUCCEEDED(hres)) {
1559 const PRUnichar *html;
1561 nsAString_GetData(&html_str, &html);
1562 *p = SysAllocString(html);
1563 if(!*p)
1564 hres = E_OUTOFMEMORY;
1567 nsAString_Finish(&html_str);
1569 TRACE("ret %s\n", debugstr_w(*p));
1570 return hres;
1573 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1575 HTMLElement *This = impl_from_IHTMLElement(iface);
1576 nsIDOMText *text_node;
1577 nsIDOMRange *range;
1578 nsAString nsstr;
1579 nsresult nsres;
1581 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1583 if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
1584 WARN("Called on element that does not support setting the property.\n");
1585 return 0x800a0258; /* undocumented error code */
1588 if(!This->node.doc->nsdoc) {
1589 FIXME("NULL nsdoc\n");
1590 return E_FAIL;
1593 nsAString_InitDepend(&nsstr, v);
1594 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &nsstr, &text_node);
1595 nsAString_Finish(&nsstr);
1596 if(NS_FAILED(nsres)) {
1597 ERR("CreateTextNode failed\n");
1598 return E_FAIL;
1601 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1602 if(NS_SUCCEEDED(nsres)) {
1603 nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
1604 if(NS_SUCCEEDED(nsres))
1605 nsres = nsIDOMRange_DeleteContents(range);
1606 if(NS_SUCCEEDED(nsres))
1607 nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
1608 if(NS_SUCCEEDED(nsres))
1609 nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
1610 if(NS_SUCCEEDED(nsres))
1611 nsres = nsIDOMRange_DeleteContents(range);
1612 nsIDOMRange_Release(range);
1614 nsIDOMText_Release(text_node);
1615 if(NS_FAILED(nsres)) {
1616 ERR("failed to set text: %08x\n", nsres);
1617 return E_FAIL;
1620 return S_OK;
1623 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1625 HTMLElement *This = impl_from_IHTMLElement(iface);
1627 TRACE("(%p)->(%p)\n", This, p);
1629 /* getter is the same as innerText */
1630 return IHTMLElement_get_innerText(&This->IHTMLElement_iface, p);
1633 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1635 nsIDOMNode *ret_nsnode;
1636 nsresult nsres;
1637 HRESULT hres = S_OK;
1639 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1640 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1641 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1642 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1644 if (!strcmpiW(where, beforebeginW)) {
1645 nsIDOMNode *parent;
1647 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1648 if(NS_FAILED(nsres))
1649 return E_FAIL;
1651 if(!parent)
1652 return E_INVALIDARG;
1654 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1655 nsIDOMNode_Release(parent);
1656 }else if(!strcmpiW(where, afterbeginW)) {
1657 nsIDOMNode *first_child;
1659 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1660 if(NS_FAILED(nsres))
1661 return E_FAIL;
1663 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1664 if(NS_FAILED(nsres))
1665 return E_FAIL;
1667 if (first_child)
1668 nsIDOMNode_Release(first_child);
1669 }else if (!strcmpiW(where, beforeendW)) {
1670 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1671 }else if (!strcmpiW(where, afterendW)) {
1672 nsIDOMNode *next_sibling, *parent;
1674 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1675 if(NS_FAILED(nsres))
1676 return E_FAIL;
1677 if(!parent)
1678 return E_INVALIDARG;
1680 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1681 if(NS_SUCCEEDED(nsres)) {
1682 if(next_sibling) {
1683 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1684 nsIDOMNode_Release(next_sibling);
1685 }else {
1686 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1690 nsIDOMNode_Release(parent);
1691 }else {
1692 ERR("invalid where: %s\n", debugstr_w(where));
1693 return E_INVALIDARG;
1696 if (NS_FAILED(nsres))
1697 return E_FAIL;
1699 if(ret_node)
1700 hres = get_node(ret_nsnode, TRUE, ret_node);
1701 nsIDOMNode_Release(ret_nsnode);
1702 return hres;
1705 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1706 BSTR html)
1708 HTMLElement *This = impl_from_IHTMLElement(iface);
1709 nsIDOMRange *range;
1710 nsIDOMNode *nsnode;
1711 nsAString ns_html;
1712 nsresult nsres;
1713 HRESULT hr;
1715 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1717 if(!This->node.doc->nsdoc) {
1718 WARN("NULL nsdoc\n");
1719 return E_UNEXPECTED;
1722 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1723 if(NS_FAILED(nsres))
1725 ERR("CreateRange failed: %08x\n", nsres);
1726 return E_FAIL;
1729 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1731 nsAString_InitDepend(&ns_html, html);
1732 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1733 nsAString_Finish(&ns_html);
1734 nsIDOMRange_Release(range);
1736 if(NS_FAILED(nsres) || !nsnode)
1738 ERR("CreateTextNode failed: %08x\n", nsres);
1739 return E_FAIL;
1742 hr = insert_adjacent_node(This, where, nsnode, NULL);
1743 nsIDOMNode_Release(nsnode);
1744 return hr;
1747 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1748 BSTR text)
1750 HTMLElement *This = impl_from_IHTMLElement(iface);
1751 nsIDOMNode *nsnode;
1752 nsAString ns_text;
1753 nsresult nsres;
1754 HRESULT hr;
1756 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1758 if(!This->node.doc->nsdoc) {
1759 WARN("NULL nsdoc\n");
1760 return E_UNEXPECTED;
1764 nsAString_InitDepend(&ns_text, text);
1765 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1766 nsAString_Finish(&ns_text);
1768 if(NS_FAILED(nsres) || !nsnode)
1770 ERR("CreateTextNode failed: %08x\n", nsres);
1771 return E_FAIL;
1774 hr = insert_adjacent_node(This, where, nsnode, NULL);
1775 nsIDOMNode_Release(nsnode);
1777 return hr;
1780 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1782 HTMLElement *This = impl_from_IHTMLElement(iface);
1783 FIXME("(%p)->(%p)\n", This, p);
1784 return E_NOTIMPL;
1787 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1789 HTMLElement *This = impl_from_IHTMLElement(iface);
1791 TRACE("(%p)->(%p)\n", This, p);
1793 *p = variant_bool(This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node));
1794 return S_OK;
1797 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1799 HTMLElement *This = impl_from_IHTMLElement(iface);
1800 nsresult nsres;
1802 TRACE("(%p)\n", This);
1804 if(!This->html_element) {
1805 FIXME("non-HTML element\n");
1806 return E_NOTIMPL;
1809 nsres = nsIDOMHTMLElement_Click(This->html_element);
1810 if(NS_FAILED(nsres)) {
1811 ERR("Click failed: %08x\n", nsres);
1812 return E_FAIL;
1815 return S_OK;
1818 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1819 IHTMLFiltersCollection **p)
1821 HTMLElement *This = impl_from_IHTMLElement(iface);
1822 TRACE("(%p)->(%p)\n", This, p);
1824 if(!p)
1825 return E_POINTER;
1827 *p = HTMLFiltersCollection_Create();
1829 return S_OK;
1832 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1834 HTMLElement *This = impl_from_IHTMLElement(iface);
1836 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1838 return set_node_event(&This->node, EVENTID_DRAGSTART, &v);
1841 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1843 HTMLElement *This = impl_from_IHTMLElement(iface);
1845 TRACE("(%p)->(%p)\n", This, p);
1847 return get_node_event(&This->node, EVENTID_DRAGSTART, p);
1850 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1852 HTMLElement *This = impl_from_IHTMLElement(iface);
1853 FIXME("(%p)->(%p)\n", This, String);
1854 return E_NOTIMPL;
1857 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1859 HTMLElement *This = impl_from_IHTMLElement(iface);
1860 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1861 return E_NOTIMPL;
1864 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1866 HTMLElement *This = impl_from_IHTMLElement(iface);
1867 FIXME("(%p)->(%p)\n", This, p);
1868 return E_NOTIMPL;
1871 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1873 HTMLElement *This = impl_from_IHTMLElement(iface);
1874 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1875 return E_NOTIMPL;
1878 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1880 HTMLElement *This = impl_from_IHTMLElement(iface);
1881 FIXME("(%p)->(%p)\n", This, p);
1882 return E_NOTIMPL;
1885 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1887 HTMLElement *This = impl_from_IHTMLElement(iface);
1888 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1889 return E_NOTIMPL;
1892 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1894 HTMLElement *This = impl_from_IHTMLElement(iface);
1895 FIXME("(%p)->(%p)\n", This, p);
1896 return E_NOTIMPL;
1899 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1901 HTMLElement *This = impl_from_IHTMLElement(iface);
1902 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1903 return E_NOTIMPL;
1906 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1908 HTMLElement *This = impl_from_IHTMLElement(iface);
1909 FIXME("(%p)->(%p)\n", This, p);
1910 return E_NOTIMPL;
1913 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1915 HTMLElement *This = impl_from_IHTMLElement(iface);
1916 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1917 return E_NOTIMPL;
1920 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1922 HTMLElement *This = impl_from_IHTMLElement(iface);
1923 FIXME("(%p)->(%p)\n", This, p);
1924 return E_NOTIMPL;
1927 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1929 HTMLElement *This = impl_from_IHTMLElement(iface);
1930 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1931 return E_NOTIMPL;
1934 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1936 HTMLElement *This = impl_from_IHTMLElement(iface);
1937 FIXME("(%p)->(%p)\n", This, p);
1938 return E_NOTIMPL;
1941 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1943 HTMLElement *This = impl_from_IHTMLElement(iface);
1945 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1947 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1950 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1952 HTMLElement *This = impl_from_IHTMLElement(iface);
1954 TRACE("(%p)->(%p)\n", This, p);
1956 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1959 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1961 HTMLElement *This = impl_from_IHTMLElement(iface);
1962 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1963 return E_NOTIMPL;
1966 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1968 HTMLElement *This = impl_from_IHTMLElement(iface);
1969 FIXME("(%p)->(%p)\n", This, p);
1970 return E_NOTIMPL;
1973 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1975 HTMLElement *This = impl_from_IHTMLElement(iface);
1976 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1977 return E_NOTIMPL;
1980 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1982 HTMLElement *This = impl_from_IHTMLElement(iface);
1983 FIXME("(%p)->(%p)\n", This, p);
1984 return E_NOTIMPL;
1987 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1989 HTMLElement *This = impl_from_IHTMLElement(iface);
1990 nsIDOMNodeList *nsnode_list;
1991 nsresult nsres;
1993 TRACE("(%p)->(%p)\n", This, p);
1995 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1996 if(NS_FAILED(nsres)) {
1997 ERR("GetChildNodes failed: %08x\n", nsres);
1998 return E_FAIL;
2001 *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode);
2003 nsIDOMNodeList_Release(nsnode_list);
2004 return S_OK;
2007 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
2009 HTMLElement *This = impl_from_IHTMLElement(iface);
2011 TRACE("(%p)->(%p)\n", This, p);
2013 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
2014 return S_OK;
2017 static const IHTMLElementVtbl HTMLElementVtbl = {
2018 HTMLElement_QueryInterface,
2019 HTMLElement_AddRef,
2020 HTMLElement_Release,
2021 HTMLElement_GetTypeInfoCount,
2022 HTMLElement_GetTypeInfo,
2023 HTMLElement_GetIDsOfNames,
2024 HTMLElement_Invoke,
2025 HTMLElement_setAttribute,
2026 HTMLElement_getAttribute,
2027 HTMLElement_removeAttribute,
2028 HTMLElement_put_className,
2029 HTMLElement_get_className,
2030 HTMLElement_put_id,
2031 HTMLElement_get_id,
2032 HTMLElement_get_tagName,
2033 HTMLElement_get_parentElement,
2034 HTMLElement_get_style,
2035 HTMLElement_put_onhelp,
2036 HTMLElement_get_onhelp,
2037 HTMLElement_put_onclick,
2038 HTMLElement_get_onclick,
2039 HTMLElement_put_ondblclick,
2040 HTMLElement_get_ondblclick,
2041 HTMLElement_put_onkeydown,
2042 HTMLElement_get_onkeydown,
2043 HTMLElement_put_onkeyup,
2044 HTMLElement_get_onkeyup,
2045 HTMLElement_put_onkeypress,
2046 HTMLElement_get_onkeypress,
2047 HTMLElement_put_onmouseout,
2048 HTMLElement_get_onmouseout,
2049 HTMLElement_put_onmouseover,
2050 HTMLElement_get_onmouseover,
2051 HTMLElement_put_onmousemove,
2052 HTMLElement_get_onmousemove,
2053 HTMLElement_put_onmousedown,
2054 HTMLElement_get_onmousedown,
2055 HTMLElement_put_onmouseup,
2056 HTMLElement_get_onmouseup,
2057 HTMLElement_get_document,
2058 HTMLElement_put_title,
2059 HTMLElement_get_title,
2060 HTMLElement_put_language,
2061 HTMLElement_get_language,
2062 HTMLElement_put_onselectstart,
2063 HTMLElement_get_onselectstart,
2064 HTMLElement_scrollIntoView,
2065 HTMLElement_contains,
2066 HTMLElement_get_sourceIndex,
2067 HTMLElement_get_recordNumber,
2068 HTMLElement_put_lang,
2069 HTMLElement_get_lang,
2070 HTMLElement_get_offsetLeft,
2071 HTMLElement_get_offsetTop,
2072 HTMLElement_get_offsetWidth,
2073 HTMLElement_get_offsetHeight,
2074 HTMLElement_get_offsetParent,
2075 HTMLElement_put_innerHTML,
2076 HTMLElement_get_innerHTML,
2077 HTMLElement_put_innerText,
2078 HTMLElement_get_innerText,
2079 HTMLElement_put_outerHTML,
2080 HTMLElement_get_outerHTML,
2081 HTMLElement_put_outerText,
2082 HTMLElement_get_outerText,
2083 HTMLElement_insertAdjacentHTML,
2084 HTMLElement_insertAdjacentText,
2085 HTMLElement_get_parentTextEdit,
2086 HTMLElement_get_isTextEdit,
2087 HTMLElement_click,
2088 HTMLElement_get_filters,
2089 HTMLElement_put_ondragstart,
2090 HTMLElement_get_ondragstart,
2091 HTMLElement_toString,
2092 HTMLElement_put_onbeforeupdate,
2093 HTMLElement_get_onbeforeupdate,
2094 HTMLElement_put_onafterupdate,
2095 HTMLElement_get_onafterupdate,
2096 HTMLElement_put_onerrorupdate,
2097 HTMLElement_get_onerrorupdate,
2098 HTMLElement_put_onrowexit,
2099 HTMLElement_get_onrowexit,
2100 HTMLElement_put_onrowenter,
2101 HTMLElement_get_onrowenter,
2102 HTMLElement_put_ondatasetchanged,
2103 HTMLElement_get_ondatasetchanged,
2104 HTMLElement_put_ondataavailable,
2105 HTMLElement_get_ondataavailable,
2106 HTMLElement_put_ondatasetcomplete,
2107 HTMLElement_get_ondatasetcomplete,
2108 HTMLElement_put_onfilterchange,
2109 HTMLElement_get_onfilterchange,
2110 HTMLElement_get_children,
2111 HTMLElement_get_all
2114 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2116 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2119 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2121 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2124 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2125 REFIID riid, void **ppv)
2127 HTMLElement *This = impl_from_IHTMLElement2(iface);
2128 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2131 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2133 HTMLElement *This = impl_from_IHTMLElement2(iface);
2134 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2137 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2139 HTMLElement *This = impl_from_IHTMLElement2(iface);
2140 return IHTMLElement_Release(&This->IHTMLElement_iface);
2143 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2145 HTMLElement *This = impl_from_IHTMLElement2(iface);
2146 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2149 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2150 LCID lcid, ITypeInfo **ppTInfo)
2152 HTMLElement *This = impl_from_IHTMLElement2(iface);
2153 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2156 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2157 LPOLESTR *rgszNames, UINT cNames,
2158 LCID lcid, DISPID *rgDispId)
2160 HTMLElement *This = impl_from_IHTMLElement2(iface);
2161 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2162 lcid, rgDispId);
2165 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2166 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2167 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2169 HTMLElement *This = impl_from_IHTMLElement2(iface);
2170 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2171 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2174 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2176 HTMLElement *This = impl_from_IHTMLElement2(iface);
2177 FIXME("(%p)->(%p)\n", This, p);
2178 return E_NOTIMPL;
2181 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2183 HTMLElement *This = impl_from_IHTMLElement2(iface);
2184 FIXME("(%p)->(%x)\n", This, containerCapture);
2185 return E_NOTIMPL;
2188 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2190 HTMLElement *This = impl_from_IHTMLElement2(iface);
2191 FIXME("(%p)\n", This);
2192 return E_NOTIMPL;
2195 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2197 HTMLElement *This = impl_from_IHTMLElement2(iface);
2198 FIXME("(%p)->()\n", This);
2199 return E_NOTIMPL;
2202 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2204 HTMLElement *This = impl_from_IHTMLElement2(iface);
2205 FIXME("(%p)->(%p)\n", This, p);
2206 return E_NOTIMPL;
2209 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2210 LONG x, LONG y, BSTR *component)
2212 HTMLElement *This = impl_from_IHTMLElement2(iface);
2213 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2214 return E_NOTIMPL;
2217 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2219 HTMLElement *This = impl_from_IHTMLElement2(iface);
2221 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2223 if(!This->node.doc->content_ready
2224 || !This->node.doc->basedoc.doc_obj->in_place_active)
2225 return E_PENDING;
2227 WARN("stub\n");
2228 return S_OK;
2231 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2233 HTMLElement *This = impl_from_IHTMLElement2(iface);
2235 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2237 return set_node_event(&This->node, EVENTID_SCROLL, &v);
2240 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2242 HTMLElement *This = impl_from_IHTMLElement2(iface);
2244 TRACE("(%p)->(%p)\n", This, p);
2246 return get_node_event(&This->node, EVENTID_SCROLL, p);
2249 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2251 HTMLElement *This = impl_from_IHTMLElement2(iface);
2253 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2255 return set_node_event(&This->node, EVENTID_DRAG, &v);
2258 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2260 HTMLElement *This = impl_from_IHTMLElement2(iface);
2262 TRACE("(%p)->(%p)\n", This, p);
2264 return get_node_event(&This->node, EVENTID_DRAG, p);
2267 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2269 HTMLElement *This = impl_from_IHTMLElement2(iface);
2270 FIXME("(%p)->()\n", This);
2271 return E_NOTIMPL;
2274 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2276 HTMLElement *This = impl_from_IHTMLElement2(iface);
2277 FIXME("(%p)->(%p)\n", This, p);
2278 return E_NOTIMPL;
2281 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2283 HTMLElement *This = impl_from_IHTMLElement2(iface);
2284 FIXME("(%p)->()\n", This);
2285 return E_NOTIMPL;
2288 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2290 HTMLElement *This = impl_from_IHTMLElement2(iface);
2291 FIXME("(%p)->(%p)\n", This, p);
2292 return E_NOTIMPL;
2295 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2297 HTMLElement *This = impl_from_IHTMLElement2(iface);
2298 FIXME("(%p)->()\n", This);
2299 return E_NOTIMPL;
2302 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2304 HTMLElement *This = impl_from_IHTMLElement2(iface);
2305 FIXME("(%p)->(%p)\n", This, p);
2306 return E_NOTIMPL;
2309 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2311 HTMLElement *This = impl_from_IHTMLElement2(iface);
2312 FIXME("(%p)->()\n", This);
2313 return E_NOTIMPL;
2316 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2318 HTMLElement *This = impl_from_IHTMLElement2(iface);
2319 FIXME("(%p)->(%p)\n", This, p);
2320 return E_NOTIMPL;
2323 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2325 HTMLElement *This = impl_from_IHTMLElement2(iface);
2326 FIXME("(%p)->()\n", This);
2327 return E_NOTIMPL;
2330 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2332 HTMLElement *This = impl_from_IHTMLElement2(iface);
2333 FIXME("(%p)->(%p)\n", This, p);
2334 return E_NOTIMPL;
2337 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2339 HTMLElement *This = impl_from_IHTMLElement2(iface);
2340 FIXME("(%p)->()\n", This);
2341 return E_NOTIMPL;
2344 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2346 HTMLElement *This = impl_from_IHTMLElement2(iface);
2347 FIXME("(%p)->(%p)\n", This, p);
2348 return E_NOTIMPL;
2351 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2353 HTMLElement *This = impl_from_IHTMLElement2(iface);
2354 FIXME("(%p)->()\n", This);
2355 return E_NOTIMPL;
2358 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2360 HTMLElement *This = impl_from_IHTMLElement2(iface);
2361 FIXME("(%p)->(%p)\n", This, p);
2362 return E_NOTIMPL;
2365 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2367 HTMLElement *This = impl_from_IHTMLElement2(iface);
2368 FIXME("(%p)->()\n", This);
2369 return E_NOTIMPL;
2372 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2374 HTMLElement *This = impl_from_IHTMLElement2(iface);
2375 FIXME("(%p)->(%p)\n", This, p);
2376 return E_NOTIMPL;
2379 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2381 HTMLElement *This = impl_from_IHTMLElement2(iface);
2382 FIXME("(%p)->()\n", This);
2383 return E_NOTIMPL;
2386 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2388 HTMLElement *This = impl_from_IHTMLElement2(iface);
2389 FIXME("(%p)->(%p)\n", This, p);
2390 return E_NOTIMPL;
2393 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2395 HTMLElement *This = impl_from_IHTMLElement2(iface);
2396 FIXME("(%p)->()\n", This);
2397 return E_NOTIMPL;
2400 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2402 HTMLElement *This = impl_from_IHTMLElement2(iface);
2403 FIXME("(%p)->(%p)\n", This, p);
2404 return E_NOTIMPL;
2407 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2409 HTMLElement *This = impl_from_IHTMLElement2(iface);
2411 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2413 return set_node_event(&This->node, EVENTID_PASTE, &v);
2416 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2418 HTMLElement *This = impl_from_IHTMLElement2(iface);
2420 TRACE("(%p)->(%p)\n", This, p);
2422 return get_node_event(&This->node, EVENTID_PASTE, p);
2425 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2427 HTMLElement *This = impl_from_IHTMLElement2(iface);
2429 TRACE("(%p)->(%p)\n", This, p);
2431 return HTMLCurrentStyle_Create(This, p);
2434 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2436 HTMLElement *This = impl_from_IHTMLElement2(iface);
2437 FIXME("(%p)->()\n", This);
2438 return E_NOTIMPL;
2441 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2443 HTMLElement *This = impl_from_IHTMLElement2(iface);
2444 FIXME("(%p)->(%p)\n", This, p);
2445 return E_NOTIMPL;
2448 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2450 HTMLElement *This = impl_from_IHTMLElement2(iface);
2451 FIXME("(%p)->(%p)\n", This, pRectCol);
2452 return E_NOTIMPL;
2455 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2457 HTMLElement *This = impl_from_IHTMLElement2(iface);
2458 nsIDOMClientRect *nsrect;
2459 nsresult nsres;
2460 HRESULT hres;
2462 TRACE("(%p)->(%p)\n", This, pRect);
2464 if(!This->dom_element) {
2465 FIXME("comment element\n");
2466 return E_NOTIMPL;
2469 nsres = nsIDOMElement_GetBoundingClientRect(This->dom_element, &nsrect);
2470 if(NS_FAILED(nsres) || !nsrect) {
2471 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2472 return E_FAIL;
2475 hres = create_html_rect(nsrect, pRect);
2477 nsIDOMClientRect_Release(nsrect);
2478 return hres;
2481 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2482 BSTR expression, BSTR language)
2484 HTMLElement *This = impl_from_IHTMLElement2(iface);
2485 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2486 debugstr_w(language));
2487 return E_NOTIMPL;
2490 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2491 VARIANT *expression)
2493 HTMLElement *This = impl_from_IHTMLElement2(iface);
2494 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2495 return E_NOTIMPL;
2498 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2499 VARIANT_BOOL *pfSuccess)
2501 HTMLElement *This = impl_from_IHTMLElement2(iface);
2502 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2503 return E_NOTIMPL;
2506 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2508 HTMLElement *This = impl_from_IHTMLElement2(iface);
2509 nsresult nsres;
2511 TRACE("(%p)->(%d)\n", This, v);
2513 if(!This->html_element) {
2514 FIXME("non-HTML element\n");
2515 return E_NOTIMPL;
2518 nsres = nsIDOMHTMLElement_SetTabIndex(This->html_element, v);
2519 if(NS_FAILED(nsres))
2520 ERR("GetTabIndex failed: %08x\n", nsres);
2522 return S_OK;
2525 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2527 HTMLElement *This = impl_from_IHTMLElement2(iface);
2528 LONG index;
2529 nsresult nsres;
2531 TRACE("(%p)->(%p)\n", This, p);
2533 if(!This->html_element) {
2534 FIXME("non-HTML element\n");
2535 return E_NOTIMPL;
2538 nsres = nsIDOMHTMLElement_GetTabIndex(This->html_element, &index);
2539 if(NS_FAILED(nsres)) {
2540 ERR("GetTabIndex failed: %08x\n", nsres);
2541 return E_FAIL;
2544 *p = index;
2545 return S_OK;
2548 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2550 HTMLElement *This = impl_from_IHTMLElement2(iface);
2551 nsresult nsres;
2553 TRACE("(%p)\n", This);
2555 if(!This->html_element) {
2556 FIXME("non-HTML element\n");
2557 return E_NOTIMPL;
2560 nsres = nsIDOMHTMLElement_Focus(This->html_element);
2561 if(NS_FAILED(nsres))
2562 ERR("Focus failed: %08x\n", nsres);
2564 return S_OK;
2567 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2569 HTMLElement *This = impl_from_IHTMLElement2(iface);
2570 VARIANT var;
2572 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2574 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2576 V_VT(&var) = VT_BSTR;
2577 V_BSTR(&var) = v;
2578 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2581 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2583 HTMLElement *This = impl_from_IHTMLElement2(iface);
2584 FIXME("(%p)->(%p)\n", This, p);
2585 return E_NOTIMPL;
2588 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2590 HTMLElement *This = impl_from_IHTMLElement2(iface);
2592 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2594 return set_node_event(&This->node, EVENTID_BLUR, &v);
2597 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2599 HTMLElement *This = impl_from_IHTMLElement2(iface);
2601 TRACE("(%p)->(%p)\n", This, p);
2603 return get_node_event(&This->node, EVENTID_BLUR, p);
2606 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2608 HTMLElement *This = impl_from_IHTMLElement2(iface);
2610 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2612 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2615 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2617 HTMLElement *This = impl_from_IHTMLElement2(iface);
2619 TRACE("(%p)->(%p)\n", This, p);
2621 return get_node_event(&This->node, EVENTID_FOCUS, p);
2624 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2626 HTMLElement *This = impl_from_IHTMLElement2(iface);
2628 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2630 return set_node_event(&This->node, EVENTID_RESIZE, &v);
2633 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2635 HTMLElement *This = impl_from_IHTMLElement2(iface);
2637 TRACE("(%p)->(%p)\n", This, p);
2639 return get_node_event(&This->node, EVENTID_RESIZE, p);
2642 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2644 HTMLElement *This = impl_from_IHTMLElement2(iface);
2645 nsresult nsres;
2647 TRACE("(%p)\n", This);
2649 if(!This->html_element) {
2650 FIXME("non-HTML element\n");
2651 return E_NOTIMPL;
2654 nsres = nsIDOMHTMLElement_Blur(This->html_element);
2655 if(NS_FAILED(nsres)) {
2656 ERR("Blur failed: %08x\n", nsres);
2657 return E_FAIL;
2660 return S_OK;
2663 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2665 HTMLElement *This = impl_from_IHTMLElement2(iface);
2666 FIXME("(%p)->(%p)\n", This, pUnk);
2667 return E_NOTIMPL;
2670 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2672 HTMLElement *This = impl_from_IHTMLElement2(iface);
2673 FIXME("(%p)->(%p)\n", This, pUnk);
2674 return E_NOTIMPL;
2677 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2679 HTMLElement *This = impl_from_IHTMLElement2(iface);
2680 nsresult nsres;
2682 TRACE("(%p)->(%p)\n", This, p);
2684 if(!This->dom_element) {
2685 FIXME("Unimplemented for comment element\n");
2686 return E_NOTIMPL;
2689 nsres = nsIDOMElement_GetClientHeight(This->dom_element, p);
2690 assert(nsres == NS_OK);
2691 return S_OK;
2694 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2696 HTMLElement *This = impl_from_IHTMLElement2(iface);
2697 nsresult nsres;
2699 TRACE("(%p)->(%p)\n", This, p);
2701 if(!This->dom_element) {
2702 FIXME("comment element\n");
2703 return E_NOTIMPL;
2706 nsres = nsIDOMElement_GetClientWidth(This->dom_element, p);
2707 assert(nsres == NS_OK);
2708 return S_OK;
2711 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2713 HTMLElement *This = impl_from_IHTMLElement2(iface);
2714 nsresult nsres;
2716 TRACE("(%p)->(%p)\n", This, p);
2718 if(!This->dom_element) {
2719 FIXME("comment element\n");
2720 return E_NOTIMPL;
2723 nsres = nsIDOMElement_GetClientTop(This->dom_element, p);
2724 assert(nsres == NS_OK);
2726 TRACE("*p = %d\n", *p);
2727 return S_OK;
2730 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2732 HTMLElement *This = impl_from_IHTMLElement2(iface);
2733 nsresult nsres;
2735 TRACE("(%p)->(%p)\n", This, p);
2737 if(!This->dom_element) {
2738 FIXME("comment element\n");
2739 return E_NOTIMPL;
2742 nsres = nsIDOMElement_GetClientLeft(This->dom_element, p);
2743 assert(nsres == NS_OK);
2745 TRACE("*p = %d\n", *p);
2746 return S_OK;
2749 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2750 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2752 HTMLElement *This = impl_from_IHTMLElement2(iface);
2754 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2756 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2759 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2761 HTMLElement *This = impl_from_IHTMLElement2(iface);
2763 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2765 return detach_event(&This->node.event_target, event, pDisp);
2768 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2770 HTMLElement *This = impl_from_IHTMLElement2(iface);
2771 BSTR str;
2773 TRACE("(%p)->(%p)\n", This, p);
2775 if(This->node.vtbl->get_readystate) {
2776 HRESULT hres;
2778 hres = This->node.vtbl->get_readystate(&This->node, &str);
2779 if(FAILED(hres))
2780 return hres;
2781 }else {
2782 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2784 str = SysAllocString(completeW);
2785 if(!str)
2786 return E_OUTOFMEMORY;
2789 V_VT(p) = VT_BSTR;
2790 V_BSTR(p) = str;
2791 return S_OK;
2794 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2796 HTMLElement *This = impl_from_IHTMLElement2(iface);
2798 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2800 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2803 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2805 HTMLElement *This = impl_from_IHTMLElement2(iface);
2807 TRACE("(%p)->(%p)\n", This, p);
2809 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2812 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2814 HTMLElement *This = impl_from_IHTMLElement2(iface);
2815 FIXME("(%p)->()\n", This);
2816 return E_NOTIMPL;
2819 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2821 HTMLElement *This = impl_from_IHTMLElement2(iface);
2822 FIXME("(%p)->(%p)\n", This, p);
2823 return E_NOTIMPL;
2826 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2828 HTMLElement *This = impl_from_IHTMLElement2(iface);
2829 FIXME("(%p)->()\n", This);
2830 return E_NOTIMPL;
2833 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2835 HTMLElement *This = impl_from_IHTMLElement2(iface);
2836 FIXME("(%p)->(%p)\n", This, p);
2837 return E_NOTIMPL;
2840 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2842 HTMLElement *This = impl_from_IHTMLElement2(iface);
2843 FIXME("(%p)->()\n", This);
2844 return E_NOTIMPL;
2847 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2849 HTMLElement *This = impl_from_IHTMLElement2(iface);
2850 FIXME("(%p)->(%p)\n", This, p);
2851 return E_NOTIMPL;
2854 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2856 HTMLElement *This = impl_from_IHTMLElement2(iface);
2857 nsAString nsstr;
2858 nsresult nsres;
2860 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2862 if(!This->html_element) {
2863 FIXME("non-HTML element\n");
2864 return S_OK;
2867 nsAString_InitDepend(&nsstr, v);
2868 nsres = nsIDOMHTMLElement_SetDir(This->html_element, &nsstr);
2869 nsAString_Finish(&nsstr);
2870 if(NS_FAILED(nsres)) {
2871 ERR("SetDir failed: %08x\n", nsres);
2872 return E_FAIL;
2875 return S_OK;
2878 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2880 HTMLElement *This = impl_from_IHTMLElement2(iface);
2881 nsAString dir_str;
2882 nsresult nsres;
2884 TRACE("(%p)->(%p)\n", This, p);
2886 if(!This->html_element) {
2887 if(This->dom_element)
2888 FIXME("non-HTML element\n");
2889 *p = NULL;
2890 return S_OK;
2893 nsAString_Init(&dir_str, NULL);
2894 nsres = nsIDOMHTMLElement_GetDir(This->html_element, &dir_str);
2895 return return_nsstr(nsres, &dir_str, p);
2898 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2900 HTMLElement *This = impl_from_IHTMLElement2(iface);
2901 FIXME("(%p)->(%p)\n", This, range);
2902 return E_NOTIMPL;
2905 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2907 HTMLElement *This = impl_from_IHTMLElement2(iface);
2908 nsresult nsres;
2910 TRACE("(%p)->(%p)\n", This, p);
2912 if(!This->dom_element) {
2913 FIXME("comment element\n");
2914 return E_NOTIMPL;
2917 nsres = nsIDOMElement_GetScrollHeight(This->dom_element, p);
2918 assert(nsres == NS_OK);
2919 TRACE("*p = %d\n", *p);
2920 return S_OK;
2923 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2925 HTMLElement *This = impl_from_IHTMLElement2(iface);
2926 nsresult nsres;
2928 TRACE("(%p)->(%p)\n", This, p);
2930 if(!This->dom_element) {
2931 FIXME("comment element\n");
2932 return E_NOTIMPL;
2935 nsres = nsIDOMElement_GetScrollWidth(This->dom_element, p);
2936 assert(nsres == NS_OK);
2938 TRACE("*p = %d\n", *p);
2939 return S_OK;
2942 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2944 HTMLElement *This = impl_from_IHTMLElement2(iface);
2946 TRACE("(%p)->(%d)\n", This, v);
2948 if(!This->dom_element) {
2949 FIXME("comment element\n");
2950 return E_NOTIMPL;
2953 nsIDOMElement_SetScrollTop(This->dom_element, v);
2954 return S_OK;
2957 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2959 HTMLElement *This = impl_from_IHTMLElement2(iface);
2960 nsresult nsres;
2962 TRACE("(%p)->(%p)\n", This, p);
2964 if(!This->dom_element) {
2965 FIXME("comment element\n");
2966 return E_NOTIMPL;
2969 nsres = nsIDOMElement_GetScrollTop(This->dom_element, p);
2970 assert(nsres == NS_OK);
2972 TRACE("*p = %d\n", *p);
2973 return S_OK;
2976 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2978 HTMLElement *This = impl_from_IHTMLElement2(iface);
2980 TRACE("(%p)->(%d)\n", This, v);
2982 if(!This->dom_element) {
2983 FIXME("comment element\n");
2984 return E_NOTIMPL;
2987 nsIDOMElement_SetScrollLeft(This->dom_element, v);
2988 return S_OK;
2991 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2993 HTMLElement *This = impl_from_IHTMLElement2(iface);
2994 nsresult nsres;
2996 TRACE("(%p)->(%p)\n", This, p);
2998 if(!p)
2999 return E_INVALIDARG;
3001 if(!This->dom_element) {
3002 FIXME("comment element\n");
3003 return E_NOTIMPL;
3006 nsres = nsIDOMElement_GetScrollLeft(This->dom_element, p);
3007 assert(nsres == NS_OK);
3008 TRACE("*p = %d\n", *p);
3009 return S_OK;
3012 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
3014 HTMLElement *This = impl_from_IHTMLElement2(iface);
3015 FIXME("(%p)\n", This);
3016 return E_NOTIMPL;
3019 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
3021 HTMLElement *This = impl_from_IHTMLElement2(iface);
3022 FIXME("(%p)->(%p)\n", This, mergeThis);
3023 return E_NOTIMPL;
3026 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
3028 HTMLElement *This = impl_from_IHTMLElement2(iface);
3030 TRACE("(%p)->()\n", This);
3032 return set_node_event(&This->node, EVENTID_CONTEXTMENU, &v);
3035 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
3037 HTMLElement *This = impl_from_IHTMLElement2(iface);
3039 TRACE("(%p)->(%p)\n", This, p);
3041 return get_node_event(&This->node, EVENTID_CONTEXTMENU, p);
3044 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
3045 IHTMLElement *insertedElement, IHTMLElement **inserted)
3047 HTMLElement *This = impl_from_IHTMLElement2(iface);
3048 HTMLDOMNode *ret_node;
3049 HTMLElement *elem;
3050 HRESULT hres;
3052 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
3054 elem = unsafe_impl_from_IHTMLElement(insertedElement);
3055 if(!elem)
3056 return E_INVALIDARG;
3058 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
3059 if(FAILED(hres))
3060 return hres;
3062 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
3063 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
3064 return hres;
3067 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
3068 BSTR where, IHTMLElement **applied)
3070 HTMLElement *This = impl_from_IHTMLElement2(iface);
3071 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
3072 return E_NOTIMPL;
3075 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
3077 HTMLElement *This = impl_from_IHTMLElement2(iface);
3078 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
3079 return E_NOTIMPL;
3082 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
3083 BSTR newText, BSTR *oldText)
3085 HTMLElement *This = impl_from_IHTMLElement2(iface);
3086 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
3087 return E_NOTIMPL;
3090 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
3092 HTMLElement *This = impl_from_IHTMLElement2(iface);
3093 FIXME("(%p)->(%p)\n", This, p);
3094 return E_NOTIMPL;
3097 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
3098 VARIANT *pvarFactory, LONG *pCookie)
3100 HTMLElement *This = impl_from_IHTMLElement2(iface);
3101 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
3102 return E_NOTIMPL;
3105 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
3106 VARIANT_BOOL *pfResult)
3108 HTMLElement *This = impl_from_IHTMLElement2(iface);
3109 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
3110 return E_NOTIMPL;
3113 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
3115 HTMLElement *This = impl_from_IHTMLElement2(iface);
3117 FIXME("(%p)->(%p): hack\n", This, p);
3119 /* We can't implement correct behavior on top of Gecko (although we could
3120 try a bit harder). Making runtimeStyle behave like regular style is
3121 enough for most use cases. */
3122 if(!This->runtime_style) {
3123 HRESULT hres;
3125 hres = HTMLStyle_Create(This, &This->runtime_style);
3126 if(FAILED(hres))
3127 return hres;
3130 *p = &This->runtime_style->IHTMLStyle_iface;
3131 IHTMLStyle_AddRef(*p);
3132 return S_OK;
3135 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
3137 HTMLElement *This = impl_from_IHTMLElement2(iface);
3138 FIXME("(%p)->(%p)\n", This, p);
3139 return E_NOTIMPL;
3142 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
3144 HTMLElement *This = impl_from_IHTMLElement2(iface);
3145 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
3146 return E_NOTIMPL;
3149 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
3151 HTMLElement *This = impl_from_IHTMLElement2(iface);
3152 FIXME("(%p)->(%p)\n", This, p);
3153 return E_NOTIMPL;
3156 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
3158 HTMLElement *This = impl_from_IHTMLElement2(iface);
3159 FIXME("(%p)->()\n", This);
3160 return E_NOTIMPL;
3163 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3165 HTMLElement *This = impl_from_IHTMLElement2(iface);
3166 FIXME("(%p)->(%p)\n", This, p);
3167 return E_NOTIMPL;
3170 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3172 HTMLElement *This = impl_from_IHTMLElement2(iface);
3173 FIXME("(%p)->(%p)\n", This, p);
3174 return E_NOTIMPL;
3177 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3178 IHTMLElementCollection **pelColl)
3180 HTMLElement *This = impl_from_IHTMLElement2(iface);
3181 nsIDOMHTMLCollection *nscol;
3182 nsAString tag_str;
3183 nsresult nsres;
3185 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3187 if(!This->dom_element) {
3188 *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode);
3189 return S_OK;
3192 nsAString_InitDepend(&tag_str, v);
3193 nsres = nsIDOMElement_GetElementsByTagName(This->dom_element, &tag_str, &nscol);
3194 nsAString_Finish(&tag_str);
3195 if(NS_FAILED(nsres)) {
3196 ERR("GetElementByTagName failed: %08x\n", nsres);
3197 return E_FAIL;
3200 *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
3201 nsIDOMHTMLCollection_Release(nscol);
3202 return S_OK;
3205 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3206 HTMLElement2_QueryInterface,
3207 HTMLElement2_AddRef,
3208 HTMLElement2_Release,
3209 HTMLElement2_GetTypeInfoCount,
3210 HTMLElement2_GetTypeInfo,
3211 HTMLElement2_GetIDsOfNames,
3212 HTMLElement2_Invoke,
3213 HTMLElement2_get_scopeName,
3214 HTMLElement2_setCapture,
3215 HTMLElement2_releaseCapture,
3216 HTMLElement2_put_onlosecapture,
3217 HTMLElement2_get_onlosecapture,
3218 HTMLElement2_componentFromPoint,
3219 HTMLElement2_doScroll,
3220 HTMLElement2_put_onscroll,
3221 HTMLElement2_get_onscroll,
3222 HTMLElement2_put_ondrag,
3223 HTMLElement2_get_ondrag,
3224 HTMLElement2_put_ondragend,
3225 HTMLElement2_get_ondragend,
3226 HTMLElement2_put_ondragenter,
3227 HTMLElement2_get_ondragenter,
3228 HTMLElement2_put_ondragover,
3229 HTMLElement2_get_ondragover,
3230 HTMLElement2_put_ondragleave,
3231 HTMLElement2_get_ondragleave,
3232 HTMLElement2_put_ondrop,
3233 HTMLElement2_get_ondrop,
3234 HTMLElement2_put_onbeforecut,
3235 HTMLElement2_get_onbeforecut,
3236 HTMLElement2_put_oncut,
3237 HTMLElement2_get_oncut,
3238 HTMLElement2_put_onbeforecopy,
3239 HTMLElement2_get_onbeforecopy,
3240 HTMLElement2_put_oncopy,
3241 HTMLElement2_get_oncopy,
3242 HTMLElement2_put_onbeforepaste,
3243 HTMLElement2_get_onbeforepaste,
3244 HTMLElement2_put_onpaste,
3245 HTMLElement2_get_onpaste,
3246 HTMLElement2_get_currentStyle,
3247 HTMLElement2_put_onpropertychange,
3248 HTMLElement2_get_onpropertychange,
3249 HTMLElement2_getClientRects,
3250 HTMLElement2_getBoundingClientRect,
3251 HTMLElement2_setExpression,
3252 HTMLElement2_getExpression,
3253 HTMLElement2_removeExpression,
3254 HTMLElement2_put_tabIndex,
3255 HTMLElement2_get_tabIndex,
3256 HTMLElement2_focus,
3257 HTMLElement2_put_accessKey,
3258 HTMLElement2_get_accessKey,
3259 HTMLElement2_put_onblur,
3260 HTMLElement2_get_onblur,
3261 HTMLElement2_put_onfocus,
3262 HTMLElement2_get_onfocus,
3263 HTMLElement2_put_onresize,
3264 HTMLElement2_get_onresize,
3265 HTMLElement2_blur,
3266 HTMLElement2_addFilter,
3267 HTMLElement2_removeFilter,
3268 HTMLElement2_get_clientHeight,
3269 HTMLElement2_get_clientWidth,
3270 HTMLElement2_get_clientTop,
3271 HTMLElement2_get_clientLeft,
3272 HTMLElement2_attachEvent,
3273 HTMLElement2_detachEvent,
3274 HTMLElement2_get_readyState,
3275 HTMLElement2_put_onreadystatechange,
3276 HTMLElement2_get_onreadystatechange,
3277 HTMLElement2_put_onrowsdelete,
3278 HTMLElement2_get_onrowsdelete,
3279 HTMLElement2_put_onrowsinserted,
3280 HTMLElement2_get_onrowsinserted,
3281 HTMLElement2_put_oncellchange,
3282 HTMLElement2_get_oncellchange,
3283 HTMLElement2_put_dir,
3284 HTMLElement2_get_dir,
3285 HTMLElement2_createControlRange,
3286 HTMLElement2_get_scrollHeight,
3287 HTMLElement2_get_scrollWidth,
3288 HTMLElement2_put_scrollTop,
3289 HTMLElement2_get_scrollTop,
3290 HTMLElement2_put_scrollLeft,
3291 HTMLElement2_get_scrollLeft,
3292 HTMLElement2_clearAttributes,
3293 HTMLElement2_mergeAttributes,
3294 HTMLElement2_put_oncontextmenu,
3295 HTMLElement2_get_oncontextmenu,
3296 HTMLElement2_insertAdjacentElement,
3297 HTMLElement2_applyElement,
3298 HTMLElement2_getAdjacentText,
3299 HTMLElement2_replaceAdjacentText,
3300 HTMLElement2_get_canHandleChildren,
3301 HTMLElement2_addBehavior,
3302 HTMLElement2_removeBehavior,
3303 HTMLElement2_get_runtimeStyle,
3304 HTMLElement2_get_behaviorUrns,
3305 HTMLElement2_put_tagUrn,
3306 HTMLElement2_get_tagUrn,
3307 HTMLElement2_put_onbeforeeditfocus,
3308 HTMLElement2_get_onbeforeeditfocus,
3309 HTMLElement2_get_readyStateValue,
3310 HTMLElement2_getElementsByTagName,
3313 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3315 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3318 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3319 REFIID riid, void **ppv)
3321 HTMLElement *This = impl_from_IHTMLElement3(iface);
3322 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3325 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3327 HTMLElement *This = impl_from_IHTMLElement3(iface);
3328 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3331 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3333 HTMLElement *This = impl_from_IHTMLElement3(iface);
3334 return IHTMLElement_Release(&This->IHTMLElement_iface);
3337 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3339 HTMLElement *This = impl_from_IHTMLElement3(iface);
3340 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3343 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3344 LCID lcid, ITypeInfo **ppTInfo)
3346 HTMLElement *This = impl_from_IHTMLElement3(iface);
3347 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3350 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3351 LPOLESTR *rgszNames, UINT cNames,
3352 LCID lcid, DISPID *rgDispId)
3354 HTMLElement *This = impl_from_IHTMLElement3(iface);
3355 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3356 lcid, rgDispId);
3359 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3360 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3361 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3363 HTMLElement *This = impl_from_IHTMLElement3(iface);
3364 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3365 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3368 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3370 HTMLElement *This = impl_from_IHTMLElement3(iface);
3371 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3372 return E_NOTIMPL;
3375 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3377 HTMLElement *This = impl_from_IHTMLElement3(iface);
3378 FIXME("(%p)->(%p)\n", This, p);
3379 return E_NOTIMPL;
3382 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3384 HTMLElement *This = impl_from_IHTMLElement3(iface);
3385 FIXME("(%p)->(%p)\n", This, p);
3386 return E_NOTIMPL;
3389 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3391 HTMLElement *This = impl_from_IHTMLElement3(iface);
3392 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3393 return E_NOTIMPL;
3396 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3398 HTMLElement *This = impl_from_IHTMLElement3(iface);
3399 FIXME("(%p)->(%p)\n", This, p);
3400 return E_NOTIMPL;
3403 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3405 HTMLElement *This = impl_from_IHTMLElement3(iface);
3406 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3407 return E_NOTIMPL;
3410 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3412 HTMLElement *This = impl_from_IHTMLElement3(iface);
3413 FIXME("(%p)->(%p)\n", This, p);
3414 return E_NOTIMPL;
3417 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3419 HTMLElement *This = impl_from_IHTMLElement3(iface);
3420 FIXME("(%p)->(%x)\n", This, v);
3421 return E_NOTIMPL;
3424 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3426 HTMLElement *This = impl_from_IHTMLElement3(iface);
3427 FIXME("(%p)->(%p)\n", This, p);
3428 return E_NOTIMPL;
3431 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3433 HTMLElement *This = impl_from_IHTMLElement3(iface);
3434 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3435 return E_NOTIMPL;
3438 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3440 HTMLElement *This = impl_from_IHTMLElement3(iface);
3441 FIXME("(%p)->(%p)\n", This, p);
3442 return E_NOTIMPL;
3445 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3447 HTMLElement *This = impl_from_IHTMLElement3(iface);
3448 FIXME("(%p)\n", This);
3449 return E_NOTIMPL;
3452 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3454 HTMLElement *This = impl_from_IHTMLElement3(iface);
3455 nsresult nsres;
3456 nsAString str;
3458 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3460 if(!This->html_element) {
3461 FIXME("non-HTML element\n");
3462 return E_NOTIMPL;
3465 nsAString_InitDepend(&str, v);
3466 nsres = nsIDOMHTMLElement_SetContentEditable(This->html_element, &str);
3467 nsAString_Finish(&str);
3469 if (NS_FAILED(nsres)){
3470 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3471 return E_FAIL;
3474 return S_OK;
3477 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3479 HTMLElement *This = impl_from_IHTMLElement3(iface);
3480 nsresult nsres;
3481 nsAString str;
3483 TRACE("(%p)->(%p)\n", This, p);
3485 if(!This->html_element) {
3486 FIXME("non-HTML element\n");
3487 return E_NOTIMPL;
3490 nsAString_Init(&str, NULL);
3491 nsres = nsIDOMHTMLElement_GetContentEditable(This->html_element, &str);
3492 return return_nsstr(nsres, &str, p);
3495 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3497 HTMLElement *This = impl_from_IHTMLElement3(iface);
3498 FIXME("(%p)->(%p)\n", This, p);
3499 return E_NOTIMPL;
3502 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3504 HTMLElement *This = impl_from_IHTMLElement3(iface);
3505 FIXME("(%p)->(%x)\n", This, v);
3506 return E_NOTIMPL;
3509 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3511 HTMLElement *This = impl_from_IHTMLElement3(iface);
3512 FIXME("(%p)->(%p)\n", This, p);
3513 return E_NOTIMPL;
3516 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3518 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3520 HTMLElement *This = impl_from_IHTMLElement3(iface);
3521 VARIANT *var;
3522 HRESULT hres;
3524 TRACE("(%p)->(%x)\n", This, v);
3526 if(This->node.vtbl->put_disabled)
3527 return This->node.vtbl->put_disabled(&This->node, v);
3529 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3530 if(FAILED(hres))
3531 return hres;
3533 VariantClear(var);
3534 V_VT(var) = VT_BOOL;
3535 V_BOOL(var) = v;
3536 return S_OK;
3539 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3541 HTMLElement *This = impl_from_IHTMLElement3(iface);
3542 VARIANT *var;
3543 HRESULT hres;
3545 TRACE("(%p)->(%p)\n", This, p);
3547 if(This->node.vtbl->get_disabled)
3548 return This->node.vtbl->get_disabled(&This->node, p);
3550 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3551 if(hres == DISP_E_UNKNOWNNAME) {
3552 *p = VARIANT_FALSE;
3553 return S_OK;
3555 if(FAILED(hres))
3556 return hres;
3558 if(V_VT(var) != VT_BOOL) {
3559 FIXME("value is %s\n", debugstr_variant(var));
3560 return E_NOTIMPL;
3563 *p = V_BOOL(var);
3564 return S_OK;
3567 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3569 HTMLElement *This = impl_from_IHTMLElement3(iface);
3570 FIXME("(%p)->(%p)\n", This, p);
3571 return E_NOTIMPL;
3574 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3576 HTMLElement *This = impl_from_IHTMLElement3(iface);
3577 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3578 return E_NOTIMPL;
3581 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3583 HTMLElement *This = impl_from_IHTMLElement3(iface);
3584 FIXME("(%p)->(%p)\n", This, p);
3585 return E_NOTIMPL;
3588 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3590 HTMLElement *This = impl_from_IHTMLElement3(iface);
3591 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3592 return E_NOTIMPL;
3595 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3597 HTMLElement *This = impl_from_IHTMLElement3(iface);
3598 FIXME("(%p)->(%p)\n", This, p);
3599 return E_NOTIMPL;
3602 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3603 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3605 HTMLElement *This = impl_from_IHTMLElement3(iface);
3607 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3608 pfCancelled);
3610 return fire_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3613 static HRESULT WINAPI HTMLElement3_put_onresizestart(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_onresizestart(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_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3629 HTMLElement *This = impl_from_IHTMLElement3(iface);
3630 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3631 return E_NOTIMPL;
3634 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3636 HTMLElement *This = impl_from_IHTMLElement3(iface);
3637 FIXME("(%p)->(%p)\n", This, p);
3638 return E_NOTIMPL;
3641 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3643 HTMLElement *This = impl_from_IHTMLElement3(iface);
3644 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3645 return E_NOTIMPL;
3648 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3650 HTMLElement *This = impl_from_IHTMLElement3(iface);
3651 FIXME("(%p)->(%p)\n", This, p);
3652 return E_NOTIMPL;
3655 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3657 HTMLElement *This = impl_from_IHTMLElement3(iface);
3658 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3659 return E_NOTIMPL;
3662 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3664 HTMLElement *This = impl_from_IHTMLElement3(iface);
3665 FIXME("(%p)->(%p)\n", This, p);
3666 return E_NOTIMPL;
3669 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3671 HTMLElement *This = impl_from_IHTMLElement3(iface);
3672 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3673 return E_NOTIMPL;
3676 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3678 HTMLElement *This = impl_from_IHTMLElement3(iface);
3679 FIXME("(%p)->(%p)\n", This, p);
3680 return E_NOTIMPL;
3683 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3685 HTMLElement *This = impl_from_IHTMLElement3(iface);
3686 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3687 return E_NOTIMPL;
3690 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3692 HTMLElement *This = impl_from_IHTMLElement3(iface);
3693 FIXME("(%p)->(%p)\n", This, p);
3694 return E_NOTIMPL;
3697 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3699 HTMLElement *This = impl_from_IHTMLElement3(iface);
3700 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3701 return E_NOTIMPL;
3704 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3706 HTMLElement *This = impl_from_IHTMLElement3(iface);
3707 FIXME("(%p)->(%p)\n", This, p);
3708 return E_NOTIMPL;
3711 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3713 HTMLElement *This = impl_from_IHTMLElement3(iface);
3714 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3715 return E_NOTIMPL;
3718 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3720 HTMLElement *This = impl_from_IHTMLElement3(iface);
3721 FIXME("(%p)->(%p)\n", This, p);
3722 return E_NOTIMPL;
3725 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3727 HTMLElement *This = impl_from_IHTMLElement3(iface);
3728 FIXME("(%p)->(%p)\n", This, pfRet);
3729 return E_NOTIMPL;
3732 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3734 HTMLElement *This = impl_from_IHTMLElement3(iface);
3735 FIXME("(%p)->(%p)\n", This, p);
3736 return E_NOTIMPL;
3739 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3740 HTMLElement3_QueryInterface,
3741 HTMLElement3_AddRef,
3742 HTMLElement3_Release,
3743 HTMLElement3_GetTypeInfoCount,
3744 HTMLElement3_GetTypeInfo,
3745 HTMLElement3_GetIDsOfNames,
3746 HTMLElement3_Invoke,
3747 HTMLElement3_mergeAttributes,
3748 HTMLElement3_get_isMultiLine,
3749 HTMLElement3_get_canHaveHTML,
3750 HTMLElement3_put_onlayoutcomplete,
3751 HTMLElement3_get_onlayoutcomplete,
3752 HTMLElement3_put_onpage,
3753 HTMLElement3_get_onpage,
3754 HTMLElement3_put_inflateBlock,
3755 HTMLElement3_get_inflateBlock,
3756 HTMLElement3_put_onbeforedeactivate,
3757 HTMLElement3_get_onbeforedeactivate,
3758 HTMLElement3_setActive,
3759 HTMLElement3_put_contentEditable,
3760 HTMLElement3_get_contentEditable,
3761 HTMLElement3_get_isContentEditable,
3762 HTMLElement3_put_hideFocus,
3763 HTMLElement3_get_hideFocus,
3764 HTMLElement3_put_disabled,
3765 HTMLElement3_get_disabled,
3766 HTMLElement3_get_isDisabled,
3767 HTMLElement3_put_onmove,
3768 HTMLElement3_get_onmove,
3769 HTMLElement3_put_oncontrolselect,
3770 HTMLElement3_get_oncontrolselect,
3771 HTMLElement3_fireEvent,
3772 HTMLElement3_put_onresizestart,
3773 HTMLElement3_get_onresizestart,
3774 HTMLElement3_put_onresizeend,
3775 HTMLElement3_get_onresizeend,
3776 HTMLElement3_put_onmovestart,
3777 HTMLElement3_get_onmovestart,
3778 HTMLElement3_put_onmoveend,
3779 HTMLElement3_get_onmoveend,
3780 HTMLElement3_put_onmousecenter,
3781 HTMLElement3_get_onmousecenter,
3782 HTMLElement3_put_onmouseleave,
3783 HTMLElement3_get_onmouseleave,
3784 HTMLElement3_put_onactivate,
3785 HTMLElement3_get_onactivate,
3786 HTMLElement3_put_ondeactivate,
3787 HTMLElement3_get_ondeactivate,
3788 HTMLElement3_dragDrop,
3789 HTMLElement3_get_glyphMode
3792 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3794 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3797 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3798 REFIID riid, void **ppv)
3800 HTMLElement *This = impl_from_IHTMLElement4(iface);
3801 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3804 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3806 HTMLElement *This = impl_from_IHTMLElement4(iface);
3807 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3810 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3812 HTMLElement *This = impl_from_IHTMLElement4(iface);
3813 return IHTMLElement_Release(&This->IHTMLElement_iface);
3816 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3818 HTMLElement *This = impl_from_IHTMLElement4(iface);
3819 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3822 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3823 LCID lcid, ITypeInfo **ppTInfo)
3825 HTMLElement *This = impl_from_IHTMLElement4(iface);
3826 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3829 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3830 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3832 HTMLElement *This = impl_from_IHTMLElement4(iface);
3833 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3834 lcid, rgDispId);
3837 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3838 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3840 HTMLElement *This = impl_from_IHTMLElement4(iface);
3841 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3842 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3845 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3847 HTMLElement *This = impl_from_IHTMLElement4(iface);
3849 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3851 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3854 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3856 HTMLElement *This = impl_from_IHTMLElement4(iface);
3858 TRACE("(%p)->(%p)\n", This, p);
3860 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3863 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3865 HTMLElement *This = impl_from_IHTMLElement4(iface);
3866 FIXME("(%p)\n", This);
3867 return E_NOTIMPL;
3870 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3872 HTMLElement *This = impl_from_IHTMLElement4(iface);
3873 HTMLAttributeCollection *attrs;
3874 HRESULT hres;
3876 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3878 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3879 if(FAILED(hres))
3880 return hres;
3882 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3883 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3884 return hres;
3887 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3888 IHTMLDOMAttribute **ppretAttribute)
3890 HTMLElement *This = impl_from_IHTMLElement4(iface);
3891 HTMLDOMAttribute *attr, *iter, *replace = NULL;
3892 HTMLAttributeCollection *attrs;
3893 DISPID dispid;
3894 HRESULT hres;
3896 TRACE("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3898 attr = unsafe_impl_from_IHTMLDOMAttribute(pattr);
3899 if(!attr)
3900 return E_INVALIDARG;
3902 if(attr->elem) {
3903 WARN("Tried to set already attached attribute.\n");
3904 return E_INVALIDARG;
3907 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface,
3908 attr->name, fdexNameCaseInsensitive|fdexNameEnsure, &dispid);
3909 if(FAILED(hres))
3910 return hres;
3912 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3913 if(FAILED(hres))
3914 return hres;
3916 LIST_FOR_EACH_ENTRY(iter, &attrs->attrs, HTMLDOMAttribute, entry) {
3917 if(iter->dispid == dispid) {
3918 replace = iter;
3919 break;
3923 if(replace) {
3924 hres = get_elem_attr_value_by_dispid(This, dispid, &replace->value);
3925 if(FAILED(hres)) {
3926 WARN("could not get attr value: %08x\n", hres);
3927 V_VT(&replace->value) = VT_EMPTY;
3929 if(!replace->name) {
3930 replace->name = attr->name;
3931 attr->name = NULL;
3933 list_add_head(&replace->entry, &attr->entry);
3934 list_remove(&replace->entry);
3935 replace->elem = NULL;
3936 }else {
3937 list_add_tail(&attrs->attrs, &attr->entry);
3940 IHTMLDOMAttribute_AddRef(&attr->IHTMLDOMAttribute_iface);
3941 attr->elem = This;
3942 attr->dispid = dispid;
3944 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3946 hres = set_elem_attr_value_by_dispid(This, dispid, &attr->value);
3947 if(FAILED(hres))
3948 WARN("Could not set attribute value: %08x\n", hres);
3949 VariantClear(&attr->value);
3951 *ppretAttribute = replace ? &replace->IHTMLDOMAttribute_iface : NULL;
3952 return S_OK;
3955 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3956 IHTMLDOMAttribute **ppretAttribute)
3958 HTMLElement *This = impl_from_IHTMLElement4(iface);
3959 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3960 return E_NOTIMPL;
3963 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3965 HTMLElement *This = impl_from_IHTMLElement4(iface);
3967 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3969 return set_node_event(&This->node, EVENTID_BEFOREACTIVATE, &v);
3972 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3974 HTMLElement *This = impl_from_IHTMLElement4(iface);
3976 TRACE("(%p)->(%p)\n", This, p);
3978 return get_node_event(&This->node, EVENTID_BEFOREACTIVATE, p);
3981 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3983 HTMLElement *This = impl_from_IHTMLElement4(iface);
3985 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
3987 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3990 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3992 HTMLElement *This = impl_from_IHTMLElement4(iface);
3994 TRACE("(%p)->(%p)\n", This, p);
3996 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3999 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
4001 HTMLElement *This = impl_from_IHTMLElement4(iface);
4003 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4005 return set_node_event(&This->node, EVENTID_FOCUSOUT, &v);
4008 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
4010 HTMLElement *This = impl_from_IHTMLElement4(iface);
4012 TRACE("(%p)->(%p)\n", This, p);
4014 return get_node_event(&This->node, EVENTID_FOCUSOUT, p);
4017 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
4018 HTMLElement4_QueryInterface,
4019 HTMLElement4_AddRef,
4020 HTMLElement4_Release,
4021 HTMLElement4_GetTypeInfoCount,
4022 HTMLElement4_GetTypeInfo,
4023 HTMLElement4_GetIDsOfNames,
4024 HTMLElement4_Invoke,
4025 HTMLElement4_put_onmousewheel,
4026 HTMLElement4_get_onmousewheel,
4027 HTMLElement4_normalize,
4028 HTMLElement4_getAttributeNode,
4029 HTMLElement4_setAttributeNode,
4030 HTMLElement4_removeAttributeNode,
4031 HTMLElement4_put_onbeforeactivate,
4032 HTMLElement4_get_onbeforeactivate,
4033 HTMLElement4_put_onfocusin,
4034 HTMLElement4_get_onfocusin,
4035 HTMLElement4_put_onfocusout,
4036 HTMLElement4_get_onfocusout
4039 static inline HTMLElement *impl_from_IHTMLElement6(IHTMLElement6 *iface)
4041 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement6_iface);
4044 static HRESULT WINAPI HTMLElement6_QueryInterface(IHTMLElement6 *iface,
4045 REFIID riid, void **ppv)
4047 HTMLElement *This = impl_from_IHTMLElement6(iface);
4048 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4051 static ULONG WINAPI HTMLElement6_AddRef(IHTMLElement6 *iface)
4053 HTMLElement *This = impl_from_IHTMLElement6(iface);
4054 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4057 static ULONG WINAPI HTMLElement6_Release(IHTMLElement6 *iface)
4059 HTMLElement *This = impl_from_IHTMLElement6(iface);
4060 return IHTMLElement_Release(&This->IHTMLElement_iface);
4063 static HRESULT WINAPI HTMLElement6_GetTypeInfoCount(IHTMLElement6 *iface, UINT *pctinfo)
4065 HTMLElement *This = impl_from_IHTMLElement6(iface);
4066 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4069 static HRESULT WINAPI HTMLElement6_GetTypeInfo(IHTMLElement6 *iface, UINT iTInfo,
4070 LCID lcid, ITypeInfo **ppTInfo)
4072 HTMLElement *This = impl_from_IHTMLElement6(iface);
4073 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4076 static HRESULT WINAPI HTMLElement6_GetIDsOfNames(IHTMLElement6 *iface, REFIID riid,
4077 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4079 HTMLElement *This = impl_from_IHTMLElement6(iface);
4080 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4081 lcid, rgDispId);
4084 static HRESULT WINAPI HTMLElement6_Invoke(IHTMLElement6 *iface, DISPID dispIdMember, REFIID riid,
4085 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4087 HTMLElement *This = impl_from_IHTMLElement6(iface);
4088 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4089 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4092 static HRESULT WINAPI HTMLElement6_getAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *AttributeValue)
4094 HTMLElement *This = impl_from_IHTMLElement6(iface);
4095 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), AttributeValue);
4096 return E_NOTIMPL;
4099 static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4101 HTMLElement *This = impl_from_IHTMLElement6(iface);
4102 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName), debugstr_variant(pvarAttributeValue));
4103 return E_NOTIMPL;
4106 static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
4108 HTMLElement *This = impl_from_IHTMLElement6(iface);
4109 FIXME("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
4110 return E_NOTIMPL;
4113 static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
4115 HTMLElement *This = impl_from_IHTMLElement6(iface);
4116 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), ppretAttribute);
4117 return E_NOTIMPL;
4120 static HRESULT WINAPI HTMLElement6_setAttributeNodeNS(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4122 HTMLElement *This = impl_from_IHTMLElement6(iface);
4123 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
4124 return E_NOTIMPL;
4127 static HRESULT WINAPI HTMLElement6_hasAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, VARIANT_BOOL *pfHasAttribute)
4129 HTMLElement *This = impl_from_IHTMLElement6(iface);
4130 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(name), pfHasAttribute);
4131 return E_NOTIMPL;
4134 static HRESULT WINAPI HTMLElement6_getAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *AttributeValue)
4136 HTMLElement *This = impl_from_IHTMLElement6(iface);
4138 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), AttributeValue);
4140 return IHTMLElement_getAttribute(&This->IHTMLElement_iface, strAttributeName, 0, AttributeValue);
4143 static HRESULT WINAPI HTMLElement6_setAttribute(IHTMLElement6 *iface, BSTR strAttributeName, VARIANT *pvarAttributeValue)
4145 HTMLElement *This = impl_from_IHTMLElement6(iface);
4147 WARN("(%p)->(%s %p) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName), pvarAttributeValue);
4149 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, strAttributeName, *pvarAttributeValue, 0);
4152 static HRESULT WINAPI HTMLElement6_removeAttribute(IHTMLElement6 *iface, BSTR strAttributeName)
4154 HTMLElement *This = impl_from_IHTMLElement6(iface);
4155 VARIANT_BOOL success;
4157 WARN("(%p)->(%s) forwarding to IHTMLElement\n", This, debugstr_w(strAttributeName));
4159 return IHTMLElement_removeAttribute(&This->IHTMLElement_iface, strAttributeName, 0, &success);
4162 static HRESULT WINAPI HTMLElement6_getAttributeNode(IHTMLElement6 *iface, BSTR strAttributeName, IHTMLDOMAttribute2 **ppretAttribute)
4164 HTMLElement *This = impl_from_IHTMLElement6(iface);
4165 IHTMLDOMAttribute *attr;
4166 HRESULT hres;
4168 WARN("(%p)->(%s %p) forwarding to IHTMLElement4\n", This, debugstr_w(strAttributeName), ppretAttribute);
4170 hres = IHTMLElement4_getAttributeNode(&This->IHTMLElement4_iface, strAttributeName, &attr);
4171 if(FAILED(hres))
4172 return hres;
4174 if(attr) {
4175 hres = IHTMLDOMAttribute_QueryInterface(attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4176 IHTMLDOMAttribute_Release(attr);
4177 }else {
4178 *ppretAttribute = NULL;
4180 return hres;
4183 static HRESULT WINAPI HTMLElement6_setAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4185 HTMLElement *This = impl_from_IHTMLElement6(iface);
4186 IHTMLDOMAttribute *attr, *ret_attr;
4187 HRESULT hres;
4189 WARN("(%p)->(%p %p) forwarding to IHTMLElement4\n", This, pattr, ppretAttribute);
4191 hres = IHTMLDOMAttribute2_QueryInterface(pattr, &IID_IHTMLDOMAttribute, (void**)&attr);
4192 if(FAILED(hres))
4193 return hres;
4195 hres = IHTMLElement4_setAttributeNode(&This->IHTMLElement4_iface, attr, &ret_attr);
4196 if(FAILED(hres))
4197 return hres;
4199 if(ret_attr) {
4200 hres = IHTMLDOMAttribute_QueryInterface(ret_attr, &IID_IHTMLDOMAttribute2, (void**)ppretAttribute);
4201 IHTMLDOMAttribute_Release(ret_attr);
4202 }else {
4203 *ppretAttribute = NULL;
4205 return hres;
4208 static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHTMLDOMAttribute2 *pattr, IHTMLDOMAttribute2 **ppretAttribute)
4210 HTMLElement *This = impl_from_IHTMLElement6(iface);
4211 FIXME("(%p)->()\n", This);
4212 return E_NOTIMPL;
4215 static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *pfHasAttribute)
4217 HTMLElement *This = impl_from_IHTMLElement6(iface);
4218 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), pfHasAttribute);
4219 return E_NOTIMPL;
4222 static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
4224 HTMLElement *This = impl_from_IHTMLElement6(iface);
4225 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(varNS), debugstr_w(bstrLocalName), pelColl);
4226 return E_NOTIMPL;
4229 static HRESULT WINAPI HTMLElement6_get_tagName(IHTMLElement6 *iface, BSTR *p)
4231 HTMLElement *This = impl_from_IHTMLElement6(iface);
4233 TRACE("(%p)->(%p)\n", This, p);
4235 return IHTMLElement_get_tagName(&This->IHTMLElement_iface, p);
4238 static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
4240 HTMLElement *This = impl_from_IHTMLElement6(iface);
4242 TRACE("(%p)->(%p)\n", This, p);
4244 return IHTMLDOMNode_get_nodeName(&This->node.IHTMLDOMNode_iface, p);
4247 static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
4249 HTMLElement *This = impl_from_IHTMLElement6(iface);
4250 nsIDOMHTMLCollection *nscol = NULL;
4251 nsAString nsstr;
4252 nsresult nsres;
4254 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4256 if(This->dom_element) {
4257 nsAString_InitDepend(&nsstr, v);
4258 nsres = nsIDOMElement_GetElementsByClassName(This->dom_element, &nsstr, &nscol);
4259 nsAString_Finish(&nsstr);
4260 if(NS_FAILED(nsres)) {
4261 ERR("GetElementsByClassName failed: %08x\n", nsres);
4262 return E_FAIL;
4266 *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex));
4267 nsIDOMHTMLCollection_Release(nscol);
4268 return S_OK;
4271 static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)
4273 HTMLElement *This = impl_from_IHTMLElement6(iface);
4274 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pfMatches);
4275 return E_NOTIMPL;
4278 static HRESULT WINAPI HTMLElement6_put_onabort(IHTMLElement6 *iface, VARIANT v)
4280 HTMLElement *This = impl_from_IHTMLElement6(iface);
4282 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4284 return set_node_event(&This->node, EVENTID_ABORT, &v);
4287 static HRESULT WINAPI HTMLElement6_get_onabort(IHTMLElement6 *iface, VARIANT *p)
4289 HTMLElement *This = impl_from_IHTMLElement6(iface);
4291 TRACE("(%p)->(%p)\n", This, p);
4293 return get_node_event(&This->node, EVENTID_ABORT, p);
4296 static HRESULT WINAPI HTMLElement6_put_oncanplay(IHTMLElement6 *iface, VARIANT v)
4298 HTMLElement *This = impl_from_IHTMLElement6(iface);
4299 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4300 return E_NOTIMPL;
4303 static HRESULT WINAPI HTMLElement6_get_oncanplay(IHTMLElement6 *iface, VARIANT *p)
4305 HTMLElement *This = impl_from_IHTMLElement6(iface);
4306 FIXME("(%p)->(%p)\n", This, p);
4307 return E_NOTIMPL;
4310 static HRESULT WINAPI HTMLElement6_put_oncanplaythrough(IHTMLElement6 *iface, VARIANT v)
4312 HTMLElement *This = impl_from_IHTMLElement6(iface);
4313 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4314 return E_NOTIMPL;
4317 static HRESULT WINAPI HTMLElement6_get_oncanplaythrough(IHTMLElement6 *iface, VARIANT *p)
4319 HTMLElement *This = impl_from_IHTMLElement6(iface);
4320 FIXME("(%p)->(%p)\n", This, p);
4321 return E_NOTIMPL;
4324 static HRESULT WINAPI HTMLElement6_put_onchange(IHTMLElement6 *iface, VARIANT v)
4326 HTMLElement *This = impl_from_IHTMLElement6(iface);
4328 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4330 return set_node_event(&This->node, EVENTID_CHANGE, &v);
4333 static HRESULT WINAPI HTMLElement6_get_onchange(IHTMLElement6 *iface, VARIANT *p)
4335 HTMLElement *This = impl_from_IHTMLElement6(iface);
4337 TRACE("(%p)->(%p)\n", This, p);
4339 return get_node_event(&This->node, EVENTID_CHANGE, p);
4342 static HRESULT WINAPI HTMLElement6_put_ondurationchange(IHTMLElement6 *iface, VARIANT v)
4344 HTMLElement *This = impl_from_IHTMLElement6(iface);
4345 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4346 return E_NOTIMPL;
4349 static HRESULT WINAPI HTMLElement6_get_ondurationchange(IHTMLElement6 *iface, VARIANT *p)
4351 HTMLElement *This = impl_from_IHTMLElement6(iface);
4352 FIXME("(%p)->(%p)\n", This, p);
4353 return E_NOTIMPL;
4356 static HRESULT WINAPI HTMLElement6_put_onemptied(IHTMLElement6 *iface, VARIANT v)
4358 HTMLElement *This = impl_from_IHTMLElement6(iface);
4359 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4360 return E_NOTIMPL;
4363 static HRESULT WINAPI HTMLElement6_get_onemptied(IHTMLElement6 *iface, VARIANT *p)
4365 HTMLElement *This = impl_from_IHTMLElement6(iface);
4366 FIXME("(%p)->(%p)\n", This, p);
4367 return E_NOTIMPL;
4370 static HRESULT WINAPI HTMLElement6_put_onended(IHTMLElement6 *iface, VARIANT v)
4372 HTMLElement *This = impl_from_IHTMLElement6(iface);
4373 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4374 return E_NOTIMPL;
4377 static HRESULT WINAPI HTMLElement6_get_onended(IHTMLElement6 *iface, VARIANT *p)
4379 HTMLElement *This = impl_from_IHTMLElement6(iface);
4380 FIXME("(%p)->(%p)\n", This, p);
4381 return E_NOTIMPL;
4384 static HRESULT WINAPI HTMLElement6_put_onerror(IHTMLElement6 *iface, VARIANT v)
4386 HTMLElement *This = impl_from_IHTMLElement6(iface);
4388 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4390 return set_node_event(&This->node, EVENTID_ERROR, &v);
4393 static HRESULT WINAPI HTMLElement6_get_onerror(IHTMLElement6 *iface, VARIANT *p)
4395 HTMLElement *This = impl_from_IHTMLElement6(iface);
4397 TRACE("(%p)->(%p)\n", This, p);
4399 return get_node_event(&This->node, EVENTID_ERROR, p);
4402 static HRESULT WINAPI HTMLElement6_put_oninput(IHTMLElement6 *iface, VARIANT v)
4404 HTMLElement *This = impl_from_IHTMLElement6(iface);
4405 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4406 return E_NOTIMPL;
4409 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
4411 HTMLElement *This = impl_from_IHTMLElement6(iface);
4412 FIXME("(%p)->(%p)\n", This, p);
4413 return E_NOTIMPL;
4416 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
4418 HTMLElement *This = impl_from_IHTMLElement6(iface);
4420 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4422 return set_node_event(&This->node, EVENTID_LOAD, &v);
4425 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
4427 HTMLElement *This = impl_from_IHTMLElement6(iface);
4429 TRACE("(%p)->(%p)\n", This, p);
4431 return get_node_event(&This->node, EVENTID_LOAD, p);
4434 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
4436 HTMLElement *This = impl_from_IHTMLElement6(iface);
4437 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4438 return E_NOTIMPL;
4441 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
4443 HTMLElement *This = impl_from_IHTMLElement6(iface);
4444 FIXME("(%p)->(%p)\n", This, p);
4445 return E_NOTIMPL;
4448 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
4450 HTMLElement *This = impl_from_IHTMLElement6(iface);
4451 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4452 return E_NOTIMPL;
4455 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
4457 HTMLElement *This = impl_from_IHTMLElement6(iface);
4458 FIXME("(%p)->(%p)\n", This, p);
4459 return E_NOTIMPL;
4462 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
4464 HTMLElement *This = impl_from_IHTMLElement6(iface);
4465 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4466 return E_NOTIMPL;
4469 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
4471 HTMLElement *This = impl_from_IHTMLElement6(iface);
4472 FIXME("(%p)->(%p)\n", This, p);
4473 return E_NOTIMPL;
4476 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
4478 HTMLElement *This = impl_from_IHTMLElement6(iface);
4479 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4480 return E_NOTIMPL;
4483 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
4485 HTMLElement *This = impl_from_IHTMLElement6(iface);
4486 FIXME("(%p)->(%p)\n", This, p);
4487 return E_NOTIMPL;
4490 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
4492 HTMLElement *This = impl_from_IHTMLElement6(iface);
4493 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4494 return E_NOTIMPL;
4497 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
4499 HTMLElement *This = impl_from_IHTMLElement6(iface);
4500 FIXME("(%p)->(%p)\n", This, p);
4501 return E_NOTIMPL;
4504 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
4506 HTMLElement *This = impl_from_IHTMLElement6(iface);
4507 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4508 return E_NOTIMPL;
4511 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
4513 HTMLElement *This = impl_from_IHTMLElement6(iface);
4514 FIXME("(%p)->(%p)\n", This, p);
4515 return E_NOTIMPL;
4518 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
4520 HTMLElement *This = impl_from_IHTMLElement6(iface);
4521 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4522 return E_NOTIMPL;
4525 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
4527 HTMLElement *This = impl_from_IHTMLElement6(iface);
4528 FIXME("(%p)->(%p)\n", This, p);
4529 return E_NOTIMPL;
4532 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
4534 HTMLElement *This = impl_from_IHTMLElement6(iface);
4535 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4536 return E_NOTIMPL;
4539 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
4541 HTMLElement *This = impl_from_IHTMLElement6(iface);
4542 FIXME("(%p)->(%p)\n", This, p);
4543 return E_NOTIMPL;
4546 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
4548 HTMLElement *This = impl_from_IHTMLElement6(iface);
4549 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4550 return E_NOTIMPL;
4553 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
4555 HTMLElement *This = impl_from_IHTMLElement6(iface);
4556 FIXME("(%p)->(%p)\n", This, p);
4557 return E_NOTIMPL;
4560 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
4562 HTMLElement *This = impl_from_IHTMLElement6(iface);
4563 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4564 return E_NOTIMPL;
4567 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
4569 HTMLElement *This = impl_from_IHTMLElement6(iface);
4570 FIXME("(%p)->(%p)\n", This, p);
4571 return E_NOTIMPL;
4574 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
4576 HTMLElement *This = impl_from_IHTMLElement6(iface);
4577 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4578 return E_NOTIMPL;
4581 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
4583 HTMLElement *This = impl_from_IHTMLElement6(iface);
4584 FIXME("(%p)->(%p)\n", This, p);
4585 return E_NOTIMPL;
4588 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
4590 HTMLElement *This = impl_from_IHTMLElement6(iface);
4591 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4592 return E_NOTIMPL;
4595 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
4597 HTMLElement *This = impl_from_IHTMLElement6(iface);
4598 FIXME("(%p)->(%p)\n", This, p);
4599 return E_NOTIMPL;
4602 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
4604 HTMLElement *This = impl_from_IHTMLElement6(iface);
4605 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4606 return E_NOTIMPL;
4609 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
4611 HTMLElement *This = impl_from_IHTMLElement6(iface);
4612 FIXME("(%p)->(%p)\n", This, p);
4613 return E_NOTIMPL;
4616 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
4618 HTMLElement *This = impl_from_IHTMLElement6(iface);
4620 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4622 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
4625 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
4627 HTMLElement *This = impl_from_IHTMLElement6(iface);
4629 TRACE("(%p)->(%p)\n", This, p);
4631 return get_node_event(&This->node, EVENTID_SUBMIT, p);
4634 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
4636 HTMLElement *This = impl_from_IHTMLElement6(iface);
4637 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4638 return E_NOTIMPL;
4641 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
4643 HTMLElement *This = impl_from_IHTMLElement6(iface);
4644 FIXME("(%p)->(%p)\n", This, p);
4645 return E_NOTIMPL;
4648 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
4650 HTMLElement *This = impl_from_IHTMLElement6(iface);
4651 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4652 return E_NOTIMPL;
4655 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
4657 HTMLElement *This = impl_from_IHTMLElement6(iface);
4658 FIXME("(%p)->(%p)\n", This, p);
4659 return E_NOTIMPL;
4662 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
4664 HTMLElement *This = impl_from_IHTMLElement6(iface);
4665 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4666 return E_NOTIMPL;
4669 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
4671 HTMLElement *This = impl_from_IHTMLElement6(iface);
4672 FIXME("(%p)->(%p)\n", This, p);
4673 return E_NOTIMPL;
4676 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
4678 HTMLElement *This = impl_from_IHTMLElement6(iface);
4679 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4680 return E_NOTIMPL;
4683 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
4685 HTMLElement *This = impl_from_IHTMLElement6(iface);
4686 FIXME("(%p)->(%p)\n", This, p);
4687 return E_NOTIMPL;
4690 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
4692 HTMLElement *This = impl_from_IHTMLElement6(iface);
4693 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
4694 return E_NOTIMPL;
4697 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
4698 HTMLElement6_QueryInterface,
4699 HTMLElement6_AddRef,
4700 HTMLElement6_Release,
4701 HTMLElement6_GetTypeInfoCount,
4702 HTMLElement6_GetTypeInfo,
4703 HTMLElement6_GetIDsOfNames,
4704 HTMLElement6_Invoke,
4705 HTMLElement6_getAttributeNS,
4706 HTMLElement6_setAttributeNS,
4707 HTMLElement6_removeAttributeNS,
4708 HTMLElement6_getAttributeNodeNS,
4709 HTMLElement6_setAttributeNodeNS,
4710 HTMLElement6_hasAttributeNS,
4711 HTMLElement6_getAttribute,
4712 HTMLElement6_setAttribute,
4713 HTMLElement6_removeAttribute,
4714 HTMLElement6_getAttributeNode,
4715 HTMLElement6_setAttributeNode,
4716 HTMLElement6_removeAttributeNode,
4717 HTMLElement6_hasAttribute,
4718 HTMLElement6_getElementsByTagNameNS,
4719 HTMLElement6_get_tagName,
4720 HTMLElement6_get_nodeName,
4721 HTMLElement6_getElementsByClassName,
4722 HTMLElement6_msMatchesSelector,
4723 HTMLElement6_put_onabort,
4724 HTMLElement6_get_onabort,
4725 HTMLElement6_put_oncanplay,
4726 HTMLElement6_get_oncanplay,
4727 HTMLElement6_put_oncanplaythrough,
4728 HTMLElement6_get_oncanplaythrough,
4729 HTMLElement6_put_onchange,
4730 HTMLElement6_get_onchange,
4731 HTMLElement6_put_ondurationchange,
4732 HTMLElement6_get_ondurationchange,
4733 HTMLElement6_put_onemptied,
4734 HTMLElement6_get_onemptied,
4735 HTMLElement6_put_onended,
4736 HTMLElement6_get_onended,
4737 HTMLElement6_put_onerror,
4738 HTMLElement6_get_onerror,
4739 HTMLElement6_put_oninput,
4740 HTMLElement6_get_oninput,
4741 HTMLElement6_put_onload,
4742 HTMLElement6_get_onload,
4743 HTMLElement6_put_onloadeddata,
4744 HTMLElement6_get_onloadeddata,
4745 HTMLElement6_put_onloadedmetadata,
4746 HTMLElement6_get_onloadedmetadata,
4747 HTMLElement6_put_onloadstart,
4748 HTMLElement6_get_onloadstart,
4749 HTMLElement6_put_onpause,
4750 HTMLElement6_get_onpause,
4751 HTMLElement6_put_onplay,
4752 HTMLElement6_get_onplay,
4753 HTMLElement6_put_onplaying,
4754 HTMLElement6_get_onplaying,
4755 HTMLElement6_put_onprogress,
4756 HTMLElement6_get_onprogress,
4757 HTMLElement6_put_onratechange,
4758 HTMLElement6_get_onratechange,
4759 HTMLElement6_put_onreset,
4760 HTMLElement6_get_onreset,
4761 HTMLElement6_put_onseeked,
4762 HTMLElement6_get_onseeked,
4763 HTMLElement6_put_onseeking,
4764 HTMLElement6_get_onseeking,
4765 HTMLElement6_put_onselect,
4766 HTMLElement6_get_onselect,
4767 HTMLElement6_put_onstalled,
4768 HTMLElement6_get_onstalled,
4769 HTMLElement6_put_onsubmit,
4770 HTMLElement6_get_onsubmit,
4771 HTMLElement6_put_onsuspend,
4772 HTMLElement6_get_onsuspend,
4773 HTMLElement6_put_ontimeupdate,
4774 HTMLElement6_get_ontimeupdate,
4775 HTMLElement6_put_onvolumechange,
4776 HTMLElement6_get_onvolumechange,
4777 HTMLElement6_put_onwaiting,
4778 HTMLElement6_get_onwaiting,
4779 HTMLElement6_hasAttributes
4782 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
4784 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
4787 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
4789 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4790 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4793 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
4795 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4796 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4799 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
4801 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4802 return IHTMLElement_Release(&This->IHTMLElement_iface);
4805 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
4807 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4808 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4811 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
4812 LCID lcid, ITypeInfo **ppTInfo)
4814 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4815 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4818 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
4819 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4821 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4822 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4823 lcid, rgDispId);
4826 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
4827 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4829 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4830 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4831 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4834 HRESULT elem_unique_id(unsigned id, BSTR *p)
4836 WCHAR buf[32];
4838 static const WCHAR formatW[] = {'m','s','_','_','i','d','%','u',0};
4840 sprintfW(buf, formatW, id);
4841 *p = SysAllocString(buf);
4842 return *p ? S_OK : E_OUTOFMEMORY;
4845 static void ensure_unique_id(HTMLElement *elem)
4847 if(!elem->unique_id)
4848 elem->unique_id = ++elem->node.doc->unique_id;
4851 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
4853 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4855 TRACE("(%p)->(%p)\n", This, p);
4857 ensure_unique_id(This);
4858 *p = This->unique_id;
4859 return S_OK;
4862 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
4864 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4866 TRACE("(%p)->(%p)\n", This, p);
4868 ensure_unique_id(This);
4869 return elem_unique_id(This->unique_id, p);
4872 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
4873 HTMLUniqueName_QueryInterface,
4874 HTMLUniqueName_AddRef,
4875 HTMLUniqueName_Release,
4876 HTMLUniqueName_GetTypeInfoCount,
4877 HTMLUniqueName_GetTypeInfo,
4878 HTMLUniqueName_GetIDsOfNames,
4879 HTMLUniqueName_Invoke,
4880 HTMLUniqueName_get_uniqueNumber,
4881 HTMLUniqueName_get_uniqueID
4884 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
4886 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
4889 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
4891 HTMLElement *This = impl_from_IElementSelector(iface);
4892 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4895 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
4897 HTMLElement *This = impl_from_IElementSelector(iface);
4898 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4901 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
4903 HTMLElement *This = impl_from_IElementSelector(iface);
4904 return IHTMLElement_Release(&This->IHTMLElement_iface);
4907 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
4909 HTMLElement *This = impl_from_IElementSelector(iface);
4910 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4913 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
4914 LCID lcid, ITypeInfo **ppTInfo)
4916 HTMLElement *This = impl_from_IElementSelector(iface);
4917 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4920 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
4921 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4923 HTMLElement *This = impl_from_IElementSelector(iface);
4924 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
4927 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
4928 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4930 HTMLElement *This = impl_from_IElementSelector(iface);
4931 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4932 pDispParams, pVarResult, pExcepInfo, puArgErr);
4935 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
4937 HTMLElement *This = impl_from_IElementSelector(iface);
4938 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4939 return E_NOTIMPL;
4942 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4944 HTMLElement *This = impl_from_IElementSelector(iface);
4945 nsIDOMNodeList *node_list;
4946 nsAString nsstr;
4947 nsresult nsres;
4949 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4951 if(!This->dom_element) {
4952 FIXME("comment element\n");
4953 return E_NOTIMPL;
4956 nsAString_InitDepend(&nsstr, v);
4957 nsres = nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list);
4958 nsAString_Finish(&nsstr);
4959 if(NS_FAILED(nsres)) {
4960 ERR("QuerySelectorAll failed: %08x\n", nsres);
4961 return E_FAIL;
4964 *pel = create_child_collection(node_list);
4965 nsIDOMNodeList_Release(node_list);
4966 return *pel ? S_OK : E_OUTOFMEMORY;
4969 static const IElementSelectorVtbl ElementSelectorVtbl = {
4970 ElementSelector_QueryInterface,
4971 ElementSelector_AddRef,
4972 ElementSelector_Release,
4973 ElementSelector_GetTypeInfoCount,
4974 ElementSelector_GetTypeInfo,
4975 ElementSelector_GetIDsOfNames,
4976 ElementSelector_Invoke,
4977 ElementSelector_querySelector,
4978 ElementSelector_querySelectorAll
4981 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
4983 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
4986 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
4987 REFIID riid, void **ppv)
4989 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4990 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4993 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
4995 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4996 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4999 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5001 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5002 return IHTMLElement_Release(&This->IHTMLElement_iface);
5005 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5007 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5008 TRACE("(%p)->(%p)\n", This, ppTI);
5009 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
5012 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5014 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5015 FIXME("(%p)->(%u %p)\n", This, dwGuidKind, pGUID);
5016 return E_NOTIMPL;
5019 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5021 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5022 FIXME("(%p)->(%p)\n", This, pcti);
5023 *pcti = 1;
5024 return S_OK;
5027 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5028 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5030 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5031 FIXME("(%p)->(%u %x %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5032 return E_NOTIMPL;
5035 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5036 ProvideClassInfo_QueryInterface,
5037 ProvideClassInfo_AddRef,
5038 ProvideClassInfo_Release,
5039 ProvideClassInfo_GetClassInfo,
5040 ProvideClassInfo2_GetGUID,
5041 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5042 ProvideMultipleClassInfo_GetInfoOfIndex
5045 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
5047 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
5050 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
5052 HTMLElement *This = impl_from_IElementTraversal(iface);
5053 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5056 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
5058 HTMLElement *This = impl_from_IElementTraversal(iface);
5060 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5063 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
5065 HTMLElement *This = impl_from_IElementTraversal(iface);
5067 return IHTMLElement_Release(&This->IHTMLElement_iface);
5070 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
5072 HTMLElement *This = impl_from_IElementTraversal(iface);
5073 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5076 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
5077 LCID lcid, ITypeInfo **ppTInfo)
5079 HTMLElement *This = impl_from_IElementTraversal(iface);
5080 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5083 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
5084 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5086 HTMLElement *This = impl_from_IElementTraversal(iface);
5087 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5088 lcid, rgDispId);
5091 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
5092 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5094 HTMLElement *This = impl_from_IElementTraversal(iface);
5095 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5096 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5099 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
5101 HTMLElement *This = impl_from_IElementTraversal(iface);
5102 nsIDOMElement *nselem = NULL;
5103 HTMLElement *elem;
5104 HRESULT hres;
5106 TRACE("(%p)->(%p)\n", This, p);
5108 if(!This->dom_element) {
5109 *p = NULL;
5110 return S_OK;
5113 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
5114 if(!nselem) {
5115 *p = NULL;
5116 return S_OK;
5119 hres = get_element(nselem, &elem);
5120 nsIDOMElement_Release(nselem);
5121 if(FAILED(hres))
5122 return hres;
5124 *p = &elem->IHTMLElement_iface;
5125 return S_OK;
5128 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
5130 HTMLElement *This = impl_from_IElementTraversal(iface);
5131 FIXME("(%p)->(%p)\n", This, p);
5132 return E_NOTIMPL;
5135 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
5137 HTMLElement *This = impl_from_IElementTraversal(iface);
5138 FIXME("(%p)->(%p)\n", This, p);
5139 return E_NOTIMPL;
5142 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
5144 HTMLElement *This = impl_from_IElementTraversal(iface);
5145 FIXME("(%p)->(%p)\n", This, p);
5146 return E_NOTIMPL;
5149 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
5151 HTMLElement *This = impl_from_IElementTraversal(iface);
5152 FIXME("(%p)->(%p)\n", This, p);
5153 return E_NOTIMPL;
5156 static const IElementTraversalVtbl ElementTraversalVtbl = {
5157 ElementTraversal_QueryInterface,
5158 ElementTraversal_AddRef,
5159 ElementTraversal_Release,
5160 ElementTraversal_GetTypeInfoCount,
5161 ElementTraversal_GetTypeInfo,
5162 ElementTraversal_GetIDsOfNames,
5163 ElementTraversal_Invoke,
5164 ElementTraversal_get_firstElementChild,
5165 ElementTraversal_get_lastElementChild,
5166 ElementTraversal_get_previousElementSibling,
5167 ElementTraversal_get_nextElementSibling,
5168 ElementTraversal_get_childElementCount
5171 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5173 return CONTAINING_RECORD(iface, HTMLElement, node);
5176 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5178 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5180 if(IsEqualGUID(&IID_IUnknown, riid)) {
5181 *ppv = &This->IHTMLElement_iface;
5182 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
5183 *ppv = &This->IHTMLElement_iface;
5184 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
5185 *ppv = &This->IHTMLElement_iface;
5186 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
5187 *ppv = &This->IHTMLElement2_iface;
5188 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
5189 *ppv = &This->IHTMLElement3_iface;
5190 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
5191 *ppv = &This->IHTMLElement4_iface;
5192 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
5193 *ppv = &This->IHTMLElement6_iface;
5194 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
5195 *ppv = &This->IHTMLUniqueName_iface;
5196 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
5197 *ppv = &This->IElementSelector_iface;
5198 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
5199 *ppv = &This->IElementTraversal_iface;
5200 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
5201 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5202 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
5203 *ppv = &This->IProvideMultipleClassInfo_iface;
5204 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
5205 *ppv = &This->IProvideMultipleClassInfo_iface;
5206 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
5207 *ppv = &This->IProvideMultipleClassInfo_iface;
5208 }else {
5209 return HTMLDOMNode_QI(&This->node, riid, ppv);
5212 IUnknown_AddRef((IUnknown*)*ppv);
5213 return S_OK;
5216 void HTMLElement_destructor(HTMLDOMNode *iface)
5218 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5220 ConnectionPointContainer_Destroy(&This->cp_container);
5222 if(This->style) {
5223 This->style->elem = NULL;
5224 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
5226 if(This->runtime_style) {
5227 This->runtime_style->elem = NULL;
5228 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
5230 if(This->attrs) {
5231 HTMLDOMAttribute *attr;
5233 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
5234 attr->elem = NULL;
5236 This->attrs->elem = NULL;
5237 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
5240 heap_free(This->filter);
5242 HTMLDOMNode_destructor(&This->node);
5245 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5247 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5248 HTMLElement *new_elem;
5249 HRESULT hres;
5251 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
5252 if(FAILED(hres))
5253 return hres;
5255 if(This->filter) {
5256 new_elem->filter = heap_strdupW(This->filter);
5257 if(!new_elem->filter) {
5258 IHTMLElement_Release(&This->IHTMLElement_iface);
5259 return E_OUTOFMEMORY;
5263 *ret = &new_elem->node;
5264 return S_OK;
5267 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
5269 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5271 switch(eid) {
5272 case EVENTID_KEYDOWN: {
5273 nsIDOMKeyEvent *key_event;
5274 nsresult nsres;
5276 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
5277 if(NS_SUCCEEDED(nsres)) {
5278 UINT32 code = 0;
5280 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
5282 if(code == VK_F1 /* DOM_VK_F1 */) {
5283 DOMEvent *help_event;
5284 HRESULT hres;
5286 TRACE("F1 pressed\n");
5288 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
5289 if(SUCCEEDED(hres)) {
5290 dispatch_event(&This->node.event_target, help_event);
5291 IDOMEvent_Release(&help_event->IDOMEvent_iface);
5293 *prevent_default = TRUE;
5296 nsIDOMKeyEvent_Release(key_event);
5301 return S_OK;
5304 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
5306 const cpc_entry_t HTMLElement_cpc[] = {
5307 HTMLELEMENT_CPC,
5308 {NULL}
5311 static const NodeImplVtbl HTMLElementImplVtbl = {
5312 &CLSID_HTMLUnknownElement,
5313 HTMLElement_QI,
5314 HTMLElement_destructor,
5315 HTMLElement_cpc,
5316 HTMLElement_clone,
5317 HTMLElement_handle_event,
5318 HTMLElement_get_attr_col
5321 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
5323 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
5326 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
5327 DWORD grfdex, DISPID *pid)
5329 HTMLElement *This = impl_from_DispatchEx(dispex);
5331 if(This->node.vtbl->get_dispid)
5332 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
5334 return DISP_E_UNKNOWNNAME;
5337 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
5338 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
5339 IServiceProvider *caller)
5341 HTMLElement *This = impl_from_DispatchEx(dispex);
5343 if(This->node.vtbl->invoke)
5344 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
5345 params, res, ei, caller);
5347 ERR("(%p): element has no invoke method\n", This);
5348 return E_NOTIMPL;
5351 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
5353 HTMLElement *This = impl_from_DispatchEx(dispex);
5354 nsIDOMMozNamedAttrMap *attrs;
5355 nsIDOMAttr *attr;
5356 nsAString nsstr;
5357 const PRUnichar *str;
5358 BSTR name;
5359 VARIANT value;
5360 unsigned i;
5361 UINT32 len;
5362 DISPID id;
5363 nsresult nsres;
5364 HRESULT hres;
5366 if(!This->dom_element)
5367 return S_FALSE;
5369 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
5370 if(NS_FAILED(nsres))
5371 return E_FAIL;
5373 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
5374 if(NS_FAILED(nsres)) {
5375 nsIDOMMozNamedAttrMap_Release(attrs);
5376 return E_FAIL;
5379 nsAString_Init(&nsstr, NULL);
5380 for(i=0; i<len; i++) {
5381 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
5382 if(NS_FAILED(nsres))
5383 continue;
5385 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
5386 if(NS_FAILED(nsres)) {
5387 nsIDOMAttr_Release(attr);
5388 continue;
5391 nsAString_GetData(&nsstr, &str);
5392 name = SysAllocString(str);
5393 if(!name) {
5394 nsIDOMAttr_Release(attr);
5395 continue;
5398 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
5399 if(hres != DISP_E_UNKNOWNNAME) {
5400 nsIDOMAttr_Release(attr);
5401 SysFreeString(name);
5402 continue;
5405 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
5406 nsIDOMAttr_Release(attr);
5407 if(NS_FAILED(nsres)) {
5408 SysFreeString(name);
5409 continue;
5412 nsAString_GetData(&nsstr, &str);
5413 V_VT(&value) = VT_BSTR;
5414 if(*str) {
5415 V_BSTR(&value) = SysAllocString(str);
5416 if(!V_BSTR(&value)) {
5417 SysFreeString(name);
5418 continue;
5420 } else
5421 V_BSTR(&value) = NULL;
5423 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
5424 SysFreeString(name);
5425 VariantClear(&value);
5427 nsAString_Finish(&nsstr);
5429 nsIDOMMozNamedAttrMap_Release(attrs);
5430 return S_OK;
5433 static nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
5435 HTMLElement *This = impl_from_DispatchEx(dispex);
5436 return (nsISupports*)This->node.nsnode;
5439 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
5441 HTMLElement *This = impl_from_DispatchEx(dispex);
5442 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
5445 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
5447 HTMLElement *This = impl_from_DispatchEx(dispex);
5449 if(!This->node.vtbl->handle_event)
5450 return S_OK;
5451 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
5454 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
5456 HTMLElement *This = impl_from_DispatchEx(dispex);
5457 HTMLDOMNode *node;
5458 nsIDOMNode *nsnode;
5459 nsresult nsres;
5460 HRESULT hres;
5462 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
5463 assert(nsres == NS_OK);
5464 if(!nsnode)
5465 return NULL;
5467 hres = get_node(nsnode, TRUE, &node);
5468 nsIDOMNode_Release(nsnode);
5469 if(FAILED(hres))
5470 return NULL;
5472 return &node->event_target;
5475 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
5477 HTMLElement *This = impl_from_DispatchEx(dispex);
5478 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
5479 return &This->cp_container;
5482 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
5484 HTMLElement *This = impl_from_DispatchEx(dispex);
5485 return default_set_current_event(This->node.doc->window, event);
5488 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5490 static const dispex_hook_t elem2_ie11_hooks[] = {
5491 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
5492 {DISPID_UNKNOWN}
5495 HTMLDOMNode_init_dispex_info(info, mode);
5497 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
5499 if(mode >= COMPAT_MODE_IE8)
5500 dispex_info_add_interface(info, IElementSelector_tid, NULL);
5502 if(mode >= COMPAT_MODE_IE9) {
5503 dispex_info_add_interface(info, IHTMLElement6_tid, NULL);
5504 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
5508 static const tid_t HTMLElement_iface_tids[] = {
5509 HTMLELEMENT_TIDS,
5513 static event_target_vtbl_t HTMLElement_event_target_vtbl = {
5515 NULL,
5516 HTMLElement_get_dispid,
5517 HTMLElement_invoke,
5518 NULL,
5519 HTMLElement_populate_props
5521 HTMLElement_get_gecko_target,
5522 HTMLElement_bind_event,
5523 HTMLElement_get_parent_event_target,
5524 HTMLElement_handle_event_default,
5525 HTMLElement_get_cp_container,
5526 HTMLElement_set_current_event
5529 static dispex_static_data_t HTMLElement_dispex = {
5530 &HTMLElement_event_target_vtbl.dispex_vtbl,
5531 DispHTMLUnknownElement_tid,
5532 HTMLElement_iface_tids,
5533 HTMLElement_init_dispex_info
5536 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
5538 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
5539 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
5540 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
5541 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
5542 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
5543 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
5544 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
5545 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
5546 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
5548 if(dispex_data && !dispex_data->vtbl)
5549 dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl;
5551 if(nselem) {
5552 nsIDOMHTMLElement *html_element;
5553 nsresult nsres;
5555 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLElement_dispex);
5557 /* No AddRef, share reference with HTMLDOMNode */
5558 assert((nsIDOMNode*)nselem == This->node.nsnode);
5559 This->dom_element = nselem;
5561 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
5562 if(NS_SUCCEEDED(nsres)) {
5563 This->html_element = html_element;
5564 /* share reference with HTMLDOMNode */
5565 assert((nsIDOMNode*)html_element == This->node.nsnode);
5566 nsIDOMHTMLElement_Release(html_element);
5570 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
5573 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
5575 nsIDOMElement *nselem;
5576 nsAString tag_name_str;
5577 const PRUnichar *tag_name;
5578 const tag_desc_t *tag;
5579 HTMLElement *elem;
5580 nsresult nsres;
5581 HRESULT hres;
5583 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
5584 if(NS_FAILED(nsres)) {
5585 ERR("no nsIDOMElement iface\n");
5586 return E_FAIL;
5589 nsAString_Init(&tag_name_str, NULL);
5590 nsIDOMElement_GetTagName(nselem, &tag_name_str);
5592 nsAString_GetData(&tag_name_str, &tag_name);
5594 tag = get_tag_desc(tag_name);
5595 if(tag) {
5596 hres = tag->constructor(doc, (nsIDOMElement*)nselem, &elem);
5597 }else if(use_generic) {
5598 hres = HTMLGenericElement_Create(doc, (nsIDOMElement*)nselem, &elem);
5599 }else {
5600 elem = heap_alloc_zero(sizeof(HTMLElement));
5601 if(elem) {
5602 elem->node.vtbl = &HTMLElementImplVtbl;
5603 HTMLElement_Init(elem, doc, (nsIDOMElement*)nselem, &HTMLElement_dispex);
5604 hres = S_OK;
5605 }else {
5606 hres = E_OUTOFMEMORY;
5610 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
5612 nsIDOMElement_Release(nselem);
5613 nsAString_Finish(&tag_name_str);
5614 if(FAILED(hres))
5615 return hres;
5617 *ret = elem;
5618 return S_OK;
5621 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
5623 HTMLDOMNode *node;
5624 HRESULT hres;
5626 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5627 if(FAILED(hres))
5628 return hres;
5630 *ret = impl_from_HTMLDOMNode(node);
5631 return S_OK;
5634 /* interface IHTMLFiltersCollection */
5635 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
5637 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5639 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
5641 if(IsEqualGUID(&IID_IUnknown, riid)) {
5642 *ppv = &This->IHTMLFiltersCollection_iface;
5643 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
5644 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
5645 *ppv = &This->IHTMLFiltersCollection_iface;
5646 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5647 return *ppv ? S_OK : E_NOINTERFACE;
5648 }else {
5649 *ppv = NULL;
5650 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5651 return E_NOINTERFACE;
5654 IUnknown_AddRef((IUnknown*)*ppv);
5655 return S_OK;
5658 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
5660 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5661 LONG ref = InterlockedIncrement(&This->ref);
5663 TRACE("(%p) ref=%d\n", This, ref);
5665 return ref;
5668 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
5670 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5671 LONG ref = InterlockedDecrement(&This->ref);
5673 TRACE("(%p) ref=%d\n", This, ref);
5675 if(!ref)
5677 heap_free(This);
5680 return ref;
5683 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
5685 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5686 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5689 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
5690 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5692 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5693 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5696 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
5697 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5698 LCID lcid, DISPID *rgDispId)
5700 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5701 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5702 lcid, rgDispId);
5705 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
5706 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
5707 EXCEPINFO *pExcepInfo, UINT *puArgErr)
5709 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5710 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5711 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5714 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
5716 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5718 if(!p)
5719 return E_POINTER;
5721 FIXME("(%p)->(%p) Always returning 0\n", This, p);
5722 *p = 0;
5724 return S_OK;
5727 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
5729 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5730 FIXME("(%p)->(%p)\n", This, p);
5731 return E_NOTIMPL;
5734 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
5736 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5737 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
5738 return E_NOTIMPL;
5741 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
5742 HTMLFiltersCollection_QueryInterface,
5743 HTMLFiltersCollection_AddRef,
5744 HTMLFiltersCollection_Release,
5745 HTMLFiltersCollection_GetTypeInfoCount,
5746 HTMLFiltersCollection_GetTypeInfo,
5747 HTMLFiltersCollection_GetIDsOfNames,
5748 HTMLFiltersCollection_Invoke,
5749 HTMLFiltersCollection_get_length,
5750 HTMLFiltersCollection_get__newEnum,
5751 HTMLFiltersCollection_item
5754 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
5756 WCHAR *ptr;
5757 int idx = 0;
5759 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
5760 idx = idx*10 + (*ptr-'0');
5761 if(*ptr)
5762 return DISP_E_UNKNOWNNAME;
5764 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
5765 TRACE("ret %x\n", *dispid);
5766 return S_OK;
5769 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5770 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5772 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
5774 V_VT(res) = VT_DISPATCH;
5775 V_DISPATCH(res) = NULL;
5777 FIXME("always returning NULL\n");
5779 return S_OK;
5782 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
5783 NULL,
5784 HTMLFiltersCollection_get_dispid,
5785 HTMLFiltersCollection_invoke,
5786 NULL
5789 static const tid_t HTMLFiltersCollection_iface_tids[] = {
5790 IHTMLFiltersCollection_tid,
5793 static dispex_static_data_t HTMLFiltersCollection_dispex = {
5794 &HTMLFiltersCollection_dispex_vtbl,
5795 IHTMLFiltersCollection_tid,
5796 HTMLFiltersCollection_iface_tids
5799 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
5801 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
5803 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
5804 ret->ref = 1;
5806 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
5807 &HTMLFiltersCollection_dispex);
5809 return &ret->IHTMLFiltersCollection_iface;
5812 /* interface IHTMLAttributeCollection */
5813 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
5815 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
5818 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
5820 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5822 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5824 if(IsEqualGUID(&IID_IUnknown, riid)) {
5825 *ppv = &This->IHTMLAttributeCollection_iface;
5826 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
5827 *ppv = &This->IHTMLAttributeCollection_iface;
5828 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
5829 *ppv = &This->IHTMLAttributeCollection2_iface;
5830 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
5831 *ppv = &This->IHTMLAttributeCollection3_iface;
5832 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5833 return *ppv ? S_OK : E_NOINTERFACE;
5834 }else {
5835 *ppv = NULL;
5836 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5837 return E_NOINTERFACE;
5840 IUnknown_AddRef((IUnknown*)*ppv);
5841 return S_OK;
5844 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
5846 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5847 LONG ref = InterlockedIncrement(&This->ref);
5849 TRACE("(%p) ref=%d\n", This, ref);
5851 return ref;
5854 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
5856 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5857 LONG ref = InterlockedDecrement(&This->ref);
5859 TRACE("(%p) ref=%d\n", This, ref);
5861 if(!ref) {
5862 while(!list_empty(&This->attrs)) {
5863 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
5865 list_remove(&attr->entry);
5866 attr->elem = NULL;
5867 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
5870 heap_free(This);
5873 return ref;
5876 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
5878 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5879 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5882 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
5883 LCID lcid, ITypeInfo **ppTInfo)
5885 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5886 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5889 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
5890 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5892 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5893 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5894 lcid, rgDispId);
5897 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
5898 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5899 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5901 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5902 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5903 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5906 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
5908 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
5909 DISPID id = DISPID_STARTENUM;
5910 LONG len = -1;
5911 HRESULT hres;
5913 FIXME("filter non-enumerable attributes out\n");
5915 while(1) {
5916 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
5917 if(FAILED(hres))
5918 return hres;
5919 else if(hres == S_FALSE)
5920 break;
5922 len++;
5923 if(len == *idx)
5924 break;
5927 if(dispid) {
5928 *dispid = id;
5929 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
5932 *idx = len+1;
5933 return S_OK;
5936 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
5938 HRESULT hres;
5940 if(name[0]>='0' && name[0]<='9') {
5941 WCHAR *end_ptr;
5942 LONG idx;
5944 idx = strtoulW(name, &end_ptr, 10);
5945 if(!*end_ptr) {
5946 hres = get_attr_dispid_by_idx(This, &idx, id);
5947 if(SUCCEEDED(hres))
5948 return hres;
5952 if(!This->elem) {
5953 WARN("NULL elem\n");
5954 return E_UNEXPECTED;
5957 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
5958 name, fdexNameCaseInsensitive, id);
5959 return hres;
5962 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
5964 HTMLDOMAttribute *iter;
5965 LONG pos = 0;
5966 HRESULT hres;
5968 *attr = NULL;
5969 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
5970 if(iter->dispid == id) {
5971 *attr = iter;
5972 break;
5974 pos++;
5977 if(!*attr) {
5978 if(!This->elem) {
5979 WARN("NULL elem\n");
5980 return E_UNEXPECTED;
5983 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
5984 if(FAILED(hres))
5985 return hres;
5988 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
5989 if(list_pos)
5990 *list_pos = pos;
5991 return S_OK;
5994 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
5996 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5997 HRESULT hres;
5999 TRACE("(%p)->(%p)\n", This, p);
6001 *p = -1;
6002 hres = get_attr_dispid_by_idx(This, p, NULL);
6003 return hres;
6006 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
6008 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
6009 FIXME("(%p)->(%p)\n", This, p);
6010 return E_NOTIMPL;
6013 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
6015 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
6016 HTMLDOMAttribute *attr;
6017 DISPID id;
6018 HRESULT hres;
6020 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
6022 switch(V_VT(name)) {
6023 case VT_I4:
6024 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
6025 break;
6026 case VT_BSTR:
6027 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
6028 break;
6029 default:
6030 FIXME("unsupported name %s\n", debugstr_variant(name));
6031 hres = E_NOTIMPL;
6033 if(hres == DISP_E_UNKNOWNNAME)
6034 return E_INVALIDARG;
6035 if(FAILED(hres))
6036 return hres;
6038 hres = get_domattr(This, id, NULL, &attr);
6039 if(FAILED(hres))
6040 return hres;
6042 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
6043 return S_OK;
6046 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
6047 HTMLAttributeCollection_QueryInterface,
6048 HTMLAttributeCollection_AddRef,
6049 HTMLAttributeCollection_Release,
6050 HTMLAttributeCollection_GetTypeInfoCount,
6051 HTMLAttributeCollection_GetTypeInfo,
6052 HTMLAttributeCollection_GetIDsOfNames,
6053 HTMLAttributeCollection_Invoke,
6054 HTMLAttributeCollection_get_length,
6055 HTMLAttributeCollection__newEnum,
6056 HTMLAttributeCollection_item
6059 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
6061 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
6064 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
6066 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6067 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
6070 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
6072 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6073 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
6076 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
6078 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6079 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
6082 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
6084 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6085 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
6088 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
6089 LCID lcid, ITypeInfo **ppTInfo)
6091 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6092 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6095 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
6096 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6098 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6099 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6100 lcid, rgDispId);
6103 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
6104 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6105 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6107 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6108 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6109 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6112 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
6113 IHTMLDOMAttribute **newretNode)
6115 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6116 HTMLDOMAttribute *attr;
6117 DISPID id;
6118 HRESULT hres;
6120 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
6122 hres = get_attr_dispid_by_name(This, bstrName, &id);
6123 if(hres == DISP_E_UNKNOWNNAME) {
6124 *newretNode = NULL;
6125 return S_OK;
6126 } else if(FAILED(hres)) {
6127 return hres;
6130 hres = get_domattr(This, id, NULL, &attr);
6131 if(FAILED(hres))
6132 return hres;
6134 *newretNode = &attr->IHTMLDOMAttribute_iface;
6135 return S_OK;
6138 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
6139 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
6141 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6142 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
6143 return E_NOTIMPL;
6146 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
6147 BSTR bstrName, IHTMLDOMAttribute **newretNode)
6149 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6150 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
6151 return E_NOTIMPL;
6154 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
6155 HTMLAttributeCollection2_QueryInterface,
6156 HTMLAttributeCollection2_AddRef,
6157 HTMLAttributeCollection2_Release,
6158 HTMLAttributeCollection2_GetTypeInfoCount,
6159 HTMLAttributeCollection2_GetTypeInfo,
6160 HTMLAttributeCollection2_GetIDsOfNames,
6161 HTMLAttributeCollection2_Invoke,
6162 HTMLAttributeCollection2_getNamedItem,
6163 HTMLAttributeCollection2_setNamedItem,
6164 HTMLAttributeCollection2_removeNamedItem
6167 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
6169 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
6172 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
6174 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6175 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
6178 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
6180 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6181 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
6184 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
6186 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6187 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
6190 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
6192 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6193 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
6196 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
6197 LCID lcid, ITypeInfo **ppTInfo)
6199 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6200 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6203 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
6204 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6206 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6207 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6208 lcid, rgDispId);
6211 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
6212 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6213 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6215 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6216 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6217 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6220 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
6221 IHTMLDOMAttribute **ppNodeOut)
6223 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6224 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
6227 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
6228 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
6230 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6231 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
6232 return E_NOTIMPL;
6235 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
6236 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
6238 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6239 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
6240 return E_NOTIMPL;
6243 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
6245 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6246 HTMLDOMAttribute *attr;
6247 DISPID id;
6248 HRESULT hres;
6250 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
6252 hres = get_attr_dispid_by_idx(This, &index, &id);
6253 if(hres == DISP_E_UNKNOWNNAME)
6254 return E_INVALIDARG;
6255 if(FAILED(hres))
6256 return hres;
6258 hres = get_domattr(This, id, NULL, &attr);
6259 if(FAILED(hres))
6260 return hres;
6262 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
6263 return S_OK;
6266 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
6268 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6269 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
6272 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
6273 HTMLAttributeCollection3_QueryInterface,
6274 HTMLAttributeCollection3_AddRef,
6275 HTMLAttributeCollection3_Release,
6276 HTMLAttributeCollection3_GetTypeInfoCount,
6277 HTMLAttributeCollection3_GetTypeInfo,
6278 HTMLAttributeCollection3_GetIDsOfNames,
6279 HTMLAttributeCollection3_Invoke,
6280 HTMLAttributeCollection3_getNamedItem,
6281 HTMLAttributeCollection3_setNamedItem,
6282 HTMLAttributeCollection3_removeNamedItem,
6283 HTMLAttributeCollection3_item,
6284 HTMLAttributeCollection3_get_length
6287 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
6289 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
6292 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
6294 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
6295 HTMLDOMAttribute *attr;
6296 LONG pos;
6297 HRESULT hres;
6299 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
6301 hres = get_attr_dispid_by_name(This, name, dispid);
6302 if(FAILED(hres))
6303 return hres;
6305 hres = get_domattr(This, *dispid, &pos, &attr);
6306 if(FAILED(hres))
6307 return hres;
6308 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
6310 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
6311 return S_OK;
6314 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6315 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6317 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
6319 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
6321 switch(flags) {
6322 case DISPATCH_PROPERTYGET: {
6323 HTMLDOMAttribute *iter;
6324 DWORD pos;
6326 pos = id-MSHTML_DISPID_CUSTOM_MIN;
6328 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
6329 if(!pos) {
6330 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
6331 V_VT(res) = VT_DISPATCH;
6332 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
6333 return S_OK;
6335 pos--;
6338 WARN("invalid arg\n");
6339 return E_INVALIDARG;
6342 default:
6343 FIXME("unimplemented flags %x\n", flags);
6344 return E_NOTIMPL;
6348 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
6349 NULL,
6350 HTMLAttributeCollection_get_dispid,
6351 HTMLAttributeCollection_invoke,
6352 NULL
6355 static const tid_t HTMLAttributeCollection_iface_tids[] = {
6356 IHTMLAttributeCollection_tid,
6357 IHTMLAttributeCollection2_tid,
6358 IHTMLAttributeCollection3_tid,
6362 static dispex_static_data_t HTMLAttributeCollection_dispex = {
6363 &HTMLAttributeCollection_dispex_vtbl,
6364 DispHTMLAttributeCollection_tid,
6365 HTMLAttributeCollection_iface_tids
6368 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
6370 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6372 if(This->attrs) {
6373 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
6374 *ac = This->attrs;
6375 return S_OK;
6378 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
6379 if(!This->attrs)
6380 return E_OUTOFMEMORY;
6382 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
6383 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
6384 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
6385 This->attrs->ref = 2;
6387 This->attrs->elem = This;
6388 list_init(&This->attrs->attrs);
6389 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
6390 &HTMLAttributeCollection_dispex);
6392 *ac = This->attrs;
6393 return S_OK;