winedump: Consistently print hex numbers with leading zeros and 'h' suffix.
[wine.git] / dlls / mshtml / htmlelem.c
blob40e558c62a0d46b8fccb5df421bae34cf0adaa83
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);
4406 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4408 return set_node_event(&This->node, EVENTID_INPUT, &v);
4411 static HRESULT WINAPI HTMLElement6_get_oninput(IHTMLElement6 *iface, VARIANT *p)
4413 HTMLElement *This = impl_from_IHTMLElement6(iface);
4415 TRACE("(%p)->(%p)\n", This, p);
4417 return get_node_event(&This->node, EVENTID_INPUT, p);
4420 static HRESULT WINAPI HTMLElement6_put_onload(IHTMLElement6 *iface, VARIANT v)
4422 HTMLElement *This = impl_from_IHTMLElement6(iface);
4424 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4426 return set_node_event(&This->node, EVENTID_LOAD, &v);
4429 static HRESULT WINAPI HTMLElement6_get_onload(IHTMLElement6 *iface, VARIANT *p)
4431 HTMLElement *This = impl_from_IHTMLElement6(iface);
4433 TRACE("(%p)->(%p)\n", This, p);
4435 return get_node_event(&This->node, EVENTID_LOAD, p);
4438 static HRESULT WINAPI HTMLElement6_put_onloadeddata(IHTMLElement6 *iface, VARIANT v)
4440 HTMLElement *This = impl_from_IHTMLElement6(iface);
4441 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4442 return E_NOTIMPL;
4445 static HRESULT WINAPI HTMLElement6_get_onloadeddata(IHTMLElement6 *iface, VARIANT *p)
4447 HTMLElement *This = impl_from_IHTMLElement6(iface);
4448 FIXME("(%p)->(%p)\n", This, p);
4449 return E_NOTIMPL;
4452 static HRESULT WINAPI HTMLElement6_put_onloadedmetadata(IHTMLElement6 *iface, VARIANT v)
4454 HTMLElement *This = impl_from_IHTMLElement6(iface);
4455 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4456 return E_NOTIMPL;
4459 static HRESULT WINAPI HTMLElement6_get_onloadedmetadata(IHTMLElement6 *iface, VARIANT *p)
4461 HTMLElement *This = impl_from_IHTMLElement6(iface);
4462 FIXME("(%p)->(%p)\n", This, p);
4463 return E_NOTIMPL;
4466 static HRESULT WINAPI HTMLElement6_put_onloadstart(IHTMLElement6 *iface, VARIANT v)
4468 HTMLElement *This = impl_from_IHTMLElement6(iface);
4469 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4470 return E_NOTIMPL;
4473 static HRESULT WINAPI HTMLElement6_get_onloadstart(IHTMLElement6 *iface, VARIANT *p)
4475 HTMLElement *This = impl_from_IHTMLElement6(iface);
4476 FIXME("(%p)->(%p)\n", This, p);
4477 return E_NOTIMPL;
4480 static HRESULT WINAPI HTMLElement6_put_onpause(IHTMLElement6 *iface, VARIANT v)
4482 HTMLElement *This = impl_from_IHTMLElement6(iface);
4483 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4484 return E_NOTIMPL;
4487 static HRESULT WINAPI HTMLElement6_get_onpause(IHTMLElement6 *iface, VARIANT *p)
4489 HTMLElement *This = impl_from_IHTMLElement6(iface);
4490 FIXME("(%p)->(%p)\n", This, p);
4491 return E_NOTIMPL;
4494 static HRESULT WINAPI HTMLElement6_put_onplay(IHTMLElement6 *iface, VARIANT v)
4496 HTMLElement *This = impl_from_IHTMLElement6(iface);
4497 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4498 return E_NOTIMPL;
4501 static HRESULT WINAPI HTMLElement6_get_onplay(IHTMLElement6 *iface, VARIANT *p)
4503 HTMLElement *This = impl_from_IHTMLElement6(iface);
4504 FIXME("(%p)->(%p)\n", This, p);
4505 return E_NOTIMPL;
4508 static HRESULT WINAPI HTMLElement6_put_onplaying(IHTMLElement6 *iface, VARIANT v)
4510 HTMLElement *This = impl_from_IHTMLElement6(iface);
4511 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4512 return E_NOTIMPL;
4515 static HRESULT WINAPI HTMLElement6_get_onplaying(IHTMLElement6 *iface, VARIANT *p)
4517 HTMLElement *This = impl_from_IHTMLElement6(iface);
4518 FIXME("(%p)->(%p)\n", This, p);
4519 return E_NOTIMPL;
4522 static HRESULT WINAPI HTMLElement6_put_onprogress(IHTMLElement6 *iface, VARIANT v)
4524 HTMLElement *This = impl_from_IHTMLElement6(iface);
4525 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4526 return E_NOTIMPL;
4529 static HRESULT WINAPI HTMLElement6_get_onprogress(IHTMLElement6 *iface, VARIANT *p)
4531 HTMLElement *This = impl_from_IHTMLElement6(iface);
4532 FIXME("(%p)->(%p)\n", This, p);
4533 return E_NOTIMPL;
4536 static HRESULT WINAPI HTMLElement6_put_onratechange(IHTMLElement6 *iface, VARIANT v)
4538 HTMLElement *This = impl_from_IHTMLElement6(iface);
4539 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4540 return E_NOTIMPL;
4543 static HRESULT WINAPI HTMLElement6_get_onratechange(IHTMLElement6 *iface, VARIANT *p)
4545 HTMLElement *This = impl_from_IHTMLElement6(iface);
4546 FIXME("(%p)->(%p)\n", This, p);
4547 return E_NOTIMPL;
4550 static HRESULT WINAPI HTMLElement6_put_onreset(IHTMLElement6 *iface, VARIANT v)
4552 HTMLElement *This = impl_from_IHTMLElement6(iface);
4553 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4554 return E_NOTIMPL;
4557 static HRESULT WINAPI HTMLElement6_get_onreset(IHTMLElement6 *iface, VARIANT *p)
4559 HTMLElement *This = impl_from_IHTMLElement6(iface);
4560 FIXME("(%p)->(%p)\n", This, p);
4561 return E_NOTIMPL;
4564 static HRESULT WINAPI HTMLElement6_put_onseeked(IHTMLElement6 *iface, VARIANT v)
4566 HTMLElement *This = impl_from_IHTMLElement6(iface);
4567 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4568 return E_NOTIMPL;
4571 static HRESULT WINAPI HTMLElement6_get_onseeked(IHTMLElement6 *iface, VARIANT *p)
4573 HTMLElement *This = impl_from_IHTMLElement6(iface);
4574 FIXME("(%p)->(%p)\n", This, p);
4575 return E_NOTIMPL;
4578 static HRESULT WINAPI HTMLElement6_put_onseeking(IHTMLElement6 *iface, VARIANT v)
4580 HTMLElement *This = impl_from_IHTMLElement6(iface);
4581 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4582 return E_NOTIMPL;
4585 static HRESULT WINAPI HTMLElement6_get_onseeking(IHTMLElement6 *iface, VARIANT *p)
4587 HTMLElement *This = impl_from_IHTMLElement6(iface);
4588 FIXME("(%p)->(%p)\n", This, p);
4589 return E_NOTIMPL;
4592 static HRESULT WINAPI HTMLElement6_put_onselect(IHTMLElement6 *iface, VARIANT v)
4594 HTMLElement *This = impl_from_IHTMLElement6(iface);
4595 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4596 return E_NOTIMPL;
4599 static HRESULT WINAPI HTMLElement6_get_onselect(IHTMLElement6 *iface, VARIANT *p)
4601 HTMLElement *This = impl_from_IHTMLElement6(iface);
4602 FIXME("(%p)->(%p)\n", This, p);
4603 return E_NOTIMPL;
4606 static HRESULT WINAPI HTMLElement6_put_onstalled(IHTMLElement6 *iface, VARIANT v)
4608 HTMLElement *This = impl_from_IHTMLElement6(iface);
4609 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4610 return E_NOTIMPL;
4613 static HRESULT WINAPI HTMLElement6_get_onstalled(IHTMLElement6 *iface, VARIANT *p)
4615 HTMLElement *This = impl_from_IHTMLElement6(iface);
4616 FIXME("(%p)->(%p)\n", This, p);
4617 return E_NOTIMPL;
4620 static HRESULT WINAPI HTMLElement6_put_onsubmit(IHTMLElement6 *iface, VARIANT v)
4622 HTMLElement *This = impl_from_IHTMLElement6(iface);
4624 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
4626 return set_node_event(&This->node, EVENTID_SUBMIT, &v);
4629 static HRESULT WINAPI HTMLElement6_get_onsubmit(IHTMLElement6 *iface, VARIANT *p)
4631 HTMLElement *This = impl_from_IHTMLElement6(iface);
4633 TRACE("(%p)->(%p)\n", This, p);
4635 return get_node_event(&This->node, EVENTID_SUBMIT, p);
4638 static HRESULT WINAPI HTMLElement6_put_onsuspend(IHTMLElement6 *iface, VARIANT v)
4640 HTMLElement *This = impl_from_IHTMLElement6(iface);
4641 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4642 return E_NOTIMPL;
4645 static HRESULT WINAPI HTMLElement6_get_onsuspend(IHTMLElement6 *iface, VARIANT *p)
4647 HTMLElement *This = impl_from_IHTMLElement6(iface);
4648 FIXME("(%p)->(%p)\n", This, p);
4649 return E_NOTIMPL;
4652 static HRESULT WINAPI HTMLElement6_put_ontimeupdate(IHTMLElement6 *iface, VARIANT v)
4654 HTMLElement *This = impl_from_IHTMLElement6(iface);
4655 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4656 return E_NOTIMPL;
4659 static HRESULT WINAPI HTMLElement6_get_ontimeupdate(IHTMLElement6 *iface, VARIANT *p)
4661 HTMLElement *This = impl_from_IHTMLElement6(iface);
4662 FIXME("(%p)->(%p)\n", This, p);
4663 return E_NOTIMPL;
4666 static HRESULT WINAPI HTMLElement6_put_onvolumechange(IHTMLElement6 *iface, VARIANT v)
4668 HTMLElement *This = impl_from_IHTMLElement6(iface);
4669 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4670 return E_NOTIMPL;
4673 static HRESULT WINAPI HTMLElement6_get_onvolumechange(IHTMLElement6 *iface, VARIANT *p)
4675 HTMLElement *This = impl_from_IHTMLElement6(iface);
4676 FIXME("(%p)->(%p)\n", This, p);
4677 return E_NOTIMPL;
4680 static HRESULT WINAPI HTMLElement6_put_onwaiting(IHTMLElement6 *iface, VARIANT v)
4682 HTMLElement *This = impl_from_IHTMLElement6(iface);
4683 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
4684 return E_NOTIMPL;
4687 static HRESULT WINAPI HTMLElement6_get_onwaiting(IHTMLElement6 *iface, VARIANT *p)
4689 HTMLElement *This = impl_from_IHTMLElement6(iface);
4690 FIXME("(%p)->(%p)\n", This, p);
4691 return E_NOTIMPL;
4694 static HRESULT WINAPI HTMLElement6_hasAttributes(IHTMLElement6 *iface, VARIANT_BOOL *pfHasAttributes)
4696 HTMLElement *This = impl_from_IHTMLElement6(iface);
4697 FIXME("(%p)->(%p)\n", This, pfHasAttributes);
4698 return E_NOTIMPL;
4701 static const IHTMLElement6Vtbl HTMLElement6Vtbl = {
4702 HTMLElement6_QueryInterface,
4703 HTMLElement6_AddRef,
4704 HTMLElement6_Release,
4705 HTMLElement6_GetTypeInfoCount,
4706 HTMLElement6_GetTypeInfo,
4707 HTMLElement6_GetIDsOfNames,
4708 HTMLElement6_Invoke,
4709 HTMLElement6_getAttributeNS,
4710 HTMLElement6_setAttributeNS,
4711 HTMLElement6_removeAttributeNS,
4712 HTMLElement6_getAttributeNodeNS,
4713 HTMLElement6_setAttributeNodeNS,
4714 HTMLElement6_hasAttributeNS,
4715 HTMLElement6_getAttribute,
4716 HTMLElement6_setAttribute,
4717 HTMLElement6_removeAttribute,
4718 HTMLElement6_getAttributeNode,
4719 HTMLElement6_setAttributeNode,
4720 HTMLElement6_removeAttributeNode,
4721 HTMLElement6_hasAttribute,
4722 HTMLElement6_getElementsByTagNameNS,
4723 HTMLElement6_get_tagName,
4724 HTMLElement6_get_nodeName,
4725 HTMLElement6_getElementsByClassName,
4726 HTMLElement6_msMatchesSelector,
4727 HTMLElement6_put_onabort,
4728 HTMLElement6_get_onabort,
4729 HTMLElement6_put_oncanplay,
4730 HTMLElement6_get_oncanplay,
4731 HTMLElement6_put_oncanplaythrough,
4732 HTMLElement6_get_oncanplaythrough,
4733 HTMLElement6_put_onchange,
4734 HTMLElement6_get_onchange,
4735 HTMLElement6_put_ondurationchange,
4736 HTMLElement6_get_ondurationchange,
4737 HTMLElement6_put_onemptied,
4738 HTMLElement6_get_onemptied,
4739 HTMLElement6_put_onended,
4740 HTMLElement6_get_onended,
4741 HTMLElement6_put_onerror,
4742 HTMLElement6_get_onerror,
4743 HTMLElement6_put_oninput,
4744 HTMLElement6_get_oninput,
4745 HTMLElement6_put_onload,
4746 HTMLElement6_get_onload,
4747 HTMLElement6_put_onloadeddata,
4748 HTMLElement6_get_onloadeddata,
4749 HTMLElement6_put_onloadedmetadata,
4750 HTMLElement6_get_onloadedmetadata,
4751 HTMLElement6_put_onloadstart,
4752 HTMLElement6_get_onloadstart,
4753 HTMLElement6_put_onpause,
4754 HTMLElement6_get_onpause,
4755 HTMLElement6_put_onplay,
4756 HTMLElement6_get_onplay,
4757 HTMLElement6_put_onplaying,
4758 HTMLElement6_get_onplaying,
4759 HTMLElement6_put_onprogress,
4760 HTMLElement6_get_onprogress,
4761 HTMLElement6_put_onratechange,
4762 HTMLElement6_get_onratechange,
4763 HTMLElement6_put_onreset,
4764 HTMLElement6_get_onreset,
4765 HTMLElement6_put_onseeked,
4766 HTMLElement6_get_onseeked,
4767 HTMLElement6_put_onseeking,
4768 HTMLElement6_get_onseeking,
4769 HTMLElement6_put_onselect,
4770 HTMLElement6_get_onselect,
4771 HTMLElement6_put_onstalled,
4772 HTMLElement6_get_onstalled,
4773 HTMLElement6_put_onsubmit,
4774 HTMLElement6_get_onsubmit,
4775 HTMLElement6_put_onsuspend,
4776 HTMLElement6_get_onsuspend,
4777 HTMLElement6_put_ontimeupdate,
4778 HTMLElement6_get_ontimeupdate,
4779 HTMLElement6_put_onvolumechange,
4780 HTMLElement6_get_onvolumechange,
4781 HTMLElement6_put_onwaiting,
4782 HTMLElement6_get_onwaiting,
4783 HTMLElement6_hasAttributes
4786 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
4788 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
4791 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
4793 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4794 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4797 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
4799 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4800 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4803 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
4805 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4806 return IHTMLElement_Release(&This->IHTMLElement_iface);
4809 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
4811 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4812 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4815 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
4816 LCID lcid, ITypeInfo **ppTInfo)
4818 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4819 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4822 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
4823 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4825 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4826 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4827 lcid, rgDispId);
4830 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
4831 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4833 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4834 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4835 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4838 HRESULT elem_unique_id(unsigned id, BSTR *p)
4840 WCHAR buf[32];
4842 static const WCHAR formatW[] = {'m','s','_','_','i','d','%','u',0};
4844 sprintfW(buf, formatW, id);
4845 *p = SysAllocString(buf);
4846 return *p ? S_OK : E_OUTOFMEMORY;
4849 static void ensure_unique_id(HTMLElement *elem)
4851 if(!elem->unique_id)
4852 elem->unique_id = ++elem->node.doc->unique_id;
4855 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
4857 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4859 TRACE("(%p)->(%p)\n", This, p);
4861 ensure_unique_id(This);
4862 *p = This->unique_id;
4863 return S_OK;
4866 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
4868 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
4870 TRACE("(%p)->(%p)\n", This, p);
4872 ensure_unique_id(This);
4873 return elem_unique_id(This->unique_id, p);
4876 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
4877 HTMLUniqueName_QueryInterface,
4878 HTMLUniqueName_AddRef,
4879 HTMLUniqueName_Release,
4880 HTMLUniqueName_GetTypeInfoCount,
4881 HTMLUniqueName_GetTypeInfo,
4882 HTMLUniqueName_GetIDsOfNames,
4883 HTMLUniqueName_Invoke,
4884 HTMLUniqueName_get_uniqueNumber,
4885 HTMLUniqueName_get_uniqueID
4888 static inline HTMLElement *impl_from_IElementSelector(IElementSelector *iface)
4890 return CONTAINING_RECORD(iface, HTMLElement, IElementSelector_iface);
4893 static HRESULT WINAPI ElementSelector_QueryInterface(IElementSelector *iface, REFIID riid, void **ppv)
4895 HTMLElement *This = impl_from_IElementSelector(iface);
4896 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4899 static ULONG WINAPI ElementSelector_AddRef(IElementSelector *iface)
4901 HTMLElement *This = impl_from_IElementSelector(iface);
4902 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
4905 static ULONG WINAPI ElementSelector_Release(IElementSelector *iface)
4907 HTMLElement *This = impl_from_IElementSelector(iface);
4908 return IHTMLElement_Release(&This->IHTMLElement_iface);
4911 static HRESULT WINAPI ElementSelector_GetTypeInfoCount(IElementSelector *iface, UINT *pctinfo)
4913 HTMLElement *This = impl_from_IElementSelector(iface);
4914 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
4917 static HRESULT WINAPI ElementSelector_GetTypeInfo(IElementSelector *iface, UINT iTInfo,
4918 LCID lcid, ITypeInfo **ppTInfo)
4920 HTMLElement *This = impl_from_IElementSelector(iface);
4921 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4924 static HRESULT WINAPI ElementSelector_GetIDsOfNames(IElementSelector *iface, REFIID riid,
4925 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4927 HTMLElement *This = impl_from_IElementSelector(iface);
4928 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
4931 static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dispIdMember, REFIID riid,
4932 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4934 HTMLElement *This = impl_from_IElementSelector(iface);
4935 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
4936 pDispParams, pVarResult, pExcepInfo, puArgErr);
4939 static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
4941 HTMLElement *This = impl_from_IElementSelector(iface);
4942 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4943 return E_NOTIMPL;
4946 static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
4948 HTMLElement *This = impl_from_IElementSelector(iface);
4949 nsIDOMNodeList *node_list;
4950 nsAString nsstr;
4951 nsresult nsres;
4953 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
4955 if(!This->dom_element) {
4956 FIXME("comment element\n");
4957 return E_NOTIMPL;
4960 nsAString_InitDepend(&nsstr, v);
4961 nsres = nsIDOMElement_QuerySelectorAll(This->dom_element, &nsstr, &node_list);
4962 nsAString_Finish(&nsstr);
4963 if(NS_FAILED(nsres)) {
4964 ERR("QuerySelectorAll failed: %08x\n", nsres);
4965 return E_FAIL;
4968 *pel = create_child_collection(node_list);
4969 nsIDOMNodeList_Release(node_list);
4970 return *pel ? S_OK : E_OUTOFMEMORY;
4973 static const IElementSelectorVtbl ElementSelectorVtbl = {
4974 ElementSelector_QueryInterface,
4975 ElementSelector_AddRef,
4976 ElementSelector_Release,
4977 ElementSelector_GetTypeInfoCount,
4978 ElementSelector_GetTypeInfo,
4979 ElementSelector_GetIDsOfNames,
4980 ElementSelector_Invoke,
4981 ElementSelector_querySelector,
4982 ElementSelector_querySelectorAll
4985 static inline HTMLElement *impl_from_IProvideMultipleClassInfo(IProvideMultipleClassInfo *iface)
4987 return CONTAINING_RECORD(iface, HTMLElement, IProvideMultipleClassInfo_iface);
4990 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideMultipleClassInfo *iface,
4991 REFIID riid, void **ppv)
4993 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
4994 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
4997 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideMultipleClassInfo *iface)
4999 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5000 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5003 static ULONG WINAPI ProvideClassInfo_Release(IProvideMultipleClassInfo *iface)
5005 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5006 return IHTMLElement_Release(&This->IHTMLElement_iface);
5009 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideMultipleClassInfo *iface, ITypeInfo **ppTI)
5011 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5012 TRACE("(%p)->(%p)\n", This, ppTI);
5013 return get_class_typeinfo(This->node.vtbl->clsid, ppTI);
5016 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideMultipleClassInfo *iface, DWORD dwGuidKind, GUID *pGUID)
5018 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5019 FIXME("(%p)->(%u %p)\n", This, dwGuidKind, pGUID);
5020 return E_NOTIMPL;
5023 static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo *iface, ULONG *pcti)
5025 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5026 FIXME("(%p)->(%p)\n", This, pcti);
5027 *pcti = 1;
5028 return S_OK;
5031 static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo *iface, ULONG iti,
5032 DWORD dwFlags, ITypeInfo **pptiCoClass, DWORD *pdwTIFlags, ULONG *pcdispidReserved, IID *piidPrimary, IID *piidSource)
5034 HTMLElement *This = impl_from_IProvideMultipleClassInfo(iface);
5035 FIXME("(%p)->(%u %x %p %p %p %p %p)\n", This, iti, dwFlags, pptiCoClass, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
5036 return E_NOTIMPL;
5039 static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl = {
5040 ProvideClassInfo_QueryInterface,
5041 ProvideClassInfo_AddRef,
5042 ProvideClassInfo_Release,
5043 ProvideClassInfo_GetClassInfo,
5044 ProvideClassInfo2_GetGUID,
5045 ProvideMultipleClassInfo_GetMultiTypeInfoCount,
5046 ProvideMultipleClassInfo_GetInfoOfIndex
5049 static inline HTMLElement *impl_from_IElementTraversal(IElementTraversal *iface)
5051 return CONTAINING_RECORD(iface, HTMLElement, IElementTraversal_iface);
5054 static HRESULT WINAPI ElementTraversal_QueryInterface(IElementTraversal *iface, REFIID riid, void **ppv)
5056 HTMLElement *This = impl_from_IElementTraversal(iface);
5057 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
5060 static ULONG WINAPI ElementTraversal_AddRef(IElementTraversal *iface)
5062 HTMLElement *This = impl_from_IElementTraversal(iface);
5064 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
5067 static ULONG WINAPI ElementTraversal_Release(IElementTraversal *iface)
5069 HTMLElement *This = impl_from_IElementTraversal(iface);
5071 return IHTMLElement_Release(&This->IHTMLElement_iface);
5074 static HRESULT WINAPI ElementTraversal_GetTypeInfoCount(IElementTraversal *iface, UINT *pctinfo)
5076 HTMLElement *This = impl_from_IElementTraversal(iface);
5077 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
5080 static HRESULT WINAPI ElementTraversal_GetTypeInfo(IElementTraversal *iface, UINT iTInfo,
5081 LCID lcid, ITypeInfo **ppTInfo)
5083 HTMLElement *This = impl_from_IElementTraversal(iface);
5084 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5087 static HRESULT WINAPI ElementTraversal_GetIDsOfNames(IElementTraversal *iface, REFIID riid,
5088 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5090 HTMLElement *This = impl_from_IElementTraversal(iface);
5091 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5092 lcid, rgDispId);
5095 static HRESULT WINAPI ElementTraversal_Invoke(IElementTraversal *iface, DISPID dispIdMember, REFIID riid,
5096 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5098 HTMLElement *This = impl_from_IElementTraversal(iface);
5099 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5100 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5103 static HRESULT WINAPI ElementTraversal_get_firstElementChild(IElementTraversal *iface, IHTMLElement **p)
5105 HTMLElement *This = impl_from_IElementTraversal(iface);
5106 nsIDOMElement *nselem = NULL;
5107 HTMLElement *elem;
5108 HRESULT hres;
5110 TRACE("(%p)->(%p)\n", This, p);
5112 if(!This->dom_element) {
5113 *p = NULL;
5114 return S_OK;
5117 nsIDOMElement_GetFirstElementChild(This->dom_element, &nselem);
5118 if(!nselem) {
5119 *p = NULL;
5120 return S_OK;
5123 hres = get_element(nselem, &elem);
5124 nsIDOMElement_Release(nselem);
5125 if(FAILED(hres))
5126 return hres;
5128 *p = &elem->IHTMLElement_iface;
5129 return S_OK;
5132 static HRESULT WINAPI ElementTraversal_get_lastElementChild(IElementTraversal *iface, IHTMLElement **p)
5134 HTMLElement *This = impl_from_IElementTraversal(iface);
5135 FIXME("(%p)->(%p)\n", This, p);
5136 return E_NOTIMPL;
5139 static HRESULT WINAPI ElementTraversal_get_previousElementSibling(IElementTraversal *iface, IHTMLElement **p)
5141 HTMLElement *This = impl_from_IElementTraversal(iface);
5142 FIXME("(%p)->(%p)\n", This, p);
5143 return E_NOTIMPL;
5146 static HRESULT WINAPI ElementTraversal_get_nextElementSibling(IElementTraversal *iface, IHTMLElement **p)
5148 HTMLElement *This = impl_from_IElementTraversal(iface);
5149 FIXME("(%p)->(%p)\n", This, p);
5150 return E_NOTIMPL;
5153 static HRESULT WINAPI ElementTraversal_get_childElementCount(IElementTraversal *iface, LONG *p)
5155 HTMLElement *This = impl_from_IElementTraversal(iface);
5156 FIXME("(%p)->(%p)\n", This, p);
5157 return E_NOTIMPL;
5160 static const IElementTraversalVtbl ElementTraversalVtbl = {
5161 ElementTraversal_QueryInterface,
5162 ElementTraversal_AddRef,
5163 ElementTraversal_Release,
5164 ElementTraversal_GetTypeInfoCount,
5165 ElementTraversal_GetTypeInfo,
5166 ElementTraversal_GetIDsOfNames,
5167 ElementTraversal_Invoke,
5168 ElementTraversal_get_firstElementChild,
5169 ElementTraversal_get_lastElementChild,
5170 ElementTraversal_get_previousElementSibling,
5171 ElementTraversal_get_nextElementSibling,
5172 ElementTraversal_get_childElementCount
5175 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
5177 return CONTAINING_RECORD(iface, HTMLElement, node);
5180 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
5182 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5184 if(IsEqualGUID(&IID_IUnknown, riid)) {
5185 *ppv = &This->IHTMLElement_iface;
5186 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
5187 *ppv = &This->IHTMLElement_iface;
5188 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
5189 *ppv = &This->IHTMLElement_iface;
5190 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
5191 *ppv = &This->IHTMLElement2_iface;
5192 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
5193 *ppv = &This->IHTMLElement3_iface;
5194 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
5195 *ppv = &This->IHTMLElement4_iface;
5196 }else if(IsEqualGUID(&IID_IHTMLElement6, riid)) {
5197 *ppv = &This->IHTMLElement6_iface;
5198 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
5199 *ppv = &This->IHTMLUniqueName_iface;
5200 }else if(IsEqualGUID(&IID_IElementSelector, riid)) {
5201 *ppv = &This->IElementSelector_iface;
5202 }else if(IsEqualGUID(&IID_IElementTraversal, riid)) {
5203 *ppv = &This->IElementTraversal_iface;
5204 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
5205 *ppv = &This->cp_container.IConnectionPointContainer_iface;
5206 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
5207 *ppv = &This->IProvideMultipleClassInfo_iface;
5208 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
5209 *ppv = &This->IProvideMultipleClassInfo_iface;
5210 }else if(IsEqualGUID(&IID_IProvideMultipleClassInfo, riid)) {
5211 *ppv = &This->IProvideMultipleClassInfo_iface;
5212 }else {
5213 return HTMLDOMNode_QI(&This->node, riid, ppv);
5216 IUnknown_AddRef((IUnknown*)*ppv);
5217 return S_OK;
5220 void HTMLElement_destructor(HTMLDOMNode *iface)
5222 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5224 ConnectionPointContainer_Destroy(&This->cp_container);
5226 if(This->style) {
5227 This->style->elem = NULL;
5228 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
5230 if(This->runtime_style) {
5231 This->runtime_style->elem = NULL;
5232 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
5234 if(This->attrs) {
5235 HTMLDOMAttribute *attr;
5237 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
5238 attr->elem = NULL;
5240 This->attrs->elem = NULL;
5241 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
5244 heap_free(This->filter);
5246 HTMLDOMNode_destructor(&This->node);
5249 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
5251 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5252 HTMLElement *new_elem;
5253 HRESULT hres;
5255 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
5256 if(FAILED(hres))
5257 return hres;
5259 if(This->filter) {
5260 new_elem->filter = heap_strdupW(This->filter);
5261 if(!new_elem->filter) {
5262 IHTMLElement_Release(&This->IHTMLElement_iface);
5263 return E_OUTOFMEMORY;
5267 *ret = &new_elem->node;
5268 return S_OK;
5271 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
5273 HTMLElement *This = impl_from_HTMLDOMNode(iface);
5275 switch(eid) {
5276 case EVENTID_KEYDOWN: {
5277 nsIDOMKeyEvent *key_event;
5278 nsresult nsres;
5280 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
5281 if(NS_SUCCEEDED(nsres)) {
5282 UINT32 code = 0;
5284 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
5286 if(code == VK_F1 /* DOM_VK_F1 */) {
5287 DOMEvent *help_event;
5288 HRESULT hres;
5290 TRACE("F1 pressed\n");
5292 hres = create_document_event(This->node.doc, EVENTID_HELP, &help_event);
5293 if(SUCCEEDED(hres)) {
5294 dispatch_event(&This->node.event_target, help_event);
5295 IDOMEvent_Release(&help_event->IDOMEvent_iface);
5297 *prevent_default = TRUE;
5300 nsIDOMKeyEvent_Release(key_event);
5305 return S_OK;
5308 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
5310 const cpc_entry_t HTMLElement_cpc[] = {
5311 HTMLELEMENT_CPC,
5312 {NULL}
5315 static const NodeImplVtbl HTMLElementImplVtbl = {
5316 &CLSID_HTMLUnknownElement,
5317 HTMLElement_QI,
5318 HTMLElement_destructor,
5319 HTMLElement_cpc,
5320 HTMLElement_clone,
5321 HTMLElement_handle_event,
5322 HTMLElement_get_attr_col
5325 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
5327 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
5330 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
5331 DWORD grfdex, DISPID *pid)
5333 HTMLElement *This = impl_from_DispatchEx(dispex);
5335 if(This->node.vtbl->get_dispid)
5336 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
5338 return DISP_E_UNKNOWNNAME;
5341 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
5342 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
5343 IServiceProvider *caller)
5345 HTMLElement *This = impl_from_DispatchEx(dispex);
5347 if(This->node.vtbl->invoke)
5348 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
5349 params, res, ei, caller);
5351 ERR("(%p): element has no invoke method\n", This);
5352 return E_NOTIMPL;
5355 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
5357 HTMLElement *This = impl_from_DispatchEx(dispex);
5358 nsIDOMMozNamedAttrMap *attrs;
5359 nsIDOMAttr *attr;
5360 nsAString nsstr;
5361 const PRUnichar *str;
5362 BSTR name;
5363 VARIANT value;
5364 unsigned i;
5365 UINT32 len;
5366 DISPID id;
5367 nsresult nsres;
5368 HRESULT hres;
5370 if(!This->dom_element)
5371 return S_FALSE;
5373 nsres = nsIDOMElement_GetAttributes(This->dom_element, &attrs);
5374 if(NS_FAILED(nsres))
5375 return E_FAIL;
5377 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
5378 if(NS_FAILED(nsres)) {
5379 nsIDOMMozNamedAttrMap_Release(attrs);
5380 return E_FAIL;
5383 nsAString_Init(&nsstr, NULL);
5384 for(i=0; i<len; i++) {
5385 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
5386 if(NS_FAILED(nsres))
5387 continue;
5389 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
5390 if(NS_FAILED(nsres)) {
5391 nsIDOMAttr_Release(attr);
5392 continue;
5395 nsAString_GetData(&nsstr, &str);
5396 name = SysAllocString(str);
5397 if(!name) {
5398 nsIDOMAttr_Release(attr);
5399 continue;
5402 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
5403 if(hres != DISP_E_UNKNOWNNAME) {
5404 nsIDOMAttr_Release(attr);
5405 SysFreeString(name);
5406 continue;
5409 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
5410 nsIDOMAttr_Release(attr);
5411 if(NS_FAILED(nsres)) {
5412 SysFreeString(name);
5413 continue;
5416 nsAString_GetData(&nsstr, &str);
5417 V_VT(&value) = VT_BSTR;
5418 if(*str) {
5419 V_BSTR(&value) = SysAllocString(str);
5420 if(!V_BSTR(&value)) {
5421 SysFreeString(name);
5422 continue;
5424 } else
5425 V_BSTR(&value) = NULL;
5427 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
5428 SysFreeString(name);
5429 VariantClear(&value);
5431 nsAString_Finish(&nsstr);
5433 nsIDOMMozNamedAttrMap_Release(attrs);
5434 return S_OK;
5437 static nsISupports *HTMLElement_get_gecko_target(DispatchEx *dispex)
5439 HTMLElement *This = impl_from_DispatchEx(dispex);
5440 return (nsISupports*)This->node.nsnode;
5443 static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
5445 HTMLElement *This = impl_from_DispatchEx(dispex);
5446 ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
5449 static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
5451 HTMLElement *This = impl_from_DispatchEx(dispex);
5453 if(!This->node.vtbl->handle_event)
5454 return S_OK;
5455 return This->node.vtbl->handle_event(&This->node, eid, nsevent, prevent_default);
5458 static EventTarget *HTMLElement_get_parent_event_target(DispatchEx *dispex)
5460 HTMLElement *This = impl_from_DispatchEx(dispex);
5461 HTMLDOMNode *node;
5462 nsIDOMNode *nsnode;
5463 nsresult nsres;
5464 HRESULT hres;
5466 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode);
5467 assert(nsres == NS_OK);
5468 if(!nsnode)
5469 return NULL;
5471 hres = get_node(nsnode, TRUE, &node);
5472 nsIDOMNode_Release(nsnode);
5473 if(FAILED(hres))
5474 return NULL;
5476 return &node->event_target;
5479 static ConnectionPointContainer *HTMLElement_get_cp_container(DispatchEx *dispex)
5481 HTMLElement *This = impl_from_DispatchEx(dispex);
5482 IConnectionPointContainer_AddRef(&This->cp_container.IConnectionPointContainer_iface);
5483 return &This->cp_container;
5486 static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
5488 HTMLElement *This = impl_from_DispatchEx(dispex);
5489 return default_set_current_event(This->node.doc->window, event);
5492 void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
5494 static const dispex_hook_t elem2_ie11_hooks[] = {
5495 {DISPID_IHTMLELEMENT2_DOSCROLL, NULL},
5496 {DISPID_UNKNOWN}
5499 HTMLDOMNode_init_dispex_info(info, mode);
5501 dispex_info_add_interface(info, IHTMLElement2_tid, mode >= COMPAT_MODE_IE11 ? elem2_ie11_hooks : NULL);
5503 if(mode >= COMPAT_MODE_IE8)
5504 dispex_info_add_interface(info, IElementSelector_tid, NULL);
5506 if(mode >= COMPAT_MODE_IE9) {
5507 dispex_info_add_interface(info, IHTMLElement6_tid, NULL);
5508 dispex_info_add_interface(info, IElementTraversal_tid, NULL);
5512 static const tid_t HTMLElement_iface_tids[] = {
5513 HTMLELEMENT_TIDS,
5517 static event_target_vtbl_t HTMLElement_event_target_vtbl = {
5519 NULL,
5520 HTMLElement_get_dispid,
5521 HTMLElement_invoke,
5522 NULL,
5523 HTMLElement_populate_props
5525 HTMLElement_get_gecko_target,
5526 HTMLElement_bind_event,
5527 HTMLElement_get_parent_event_target,
5528 HTMLElement_handle_event_default,
5529 HTMLElement_get_cp_container,
5530 HTMLElement_set_current_event
5533 static dispex_static_data_t HTMLElement_dispex = {
5534 &HTMLElement_event_target_vtbl.dispex_vtbl,
5535 DispHTMLUnknownElement_tid,
5536 HTMLElement_iface_tids,
5537 HTMLElement_init_dispex_info
5540 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *nselem, dispex_static_data_t *dispex_data)
5542 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
5543 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
5544 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
5545 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
5546 This->IHTMLElement6_iface.lpVtbl = &HTMLElement6Vtbl;
5547 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
5548 This->IElementSelector_iface.lpVtbl = &ElementSelectorVtbl;
5549 This->IElementTraversal_iface.lpVtbl = &ElementTraversalVtbl;
5550 This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
5552 if(dispex_data && !dispex_data->vtbl)
5553 dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl;
5555 if(nselem) {
5556 nsIDOMHTMLElement *html_element;
5557 nsresult nsres;
5559 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLElement_dispex);
5561 /* No AddRef, share reference with HTMLDOMNode */
5562 assert((nsIDOMNode*)nselem == This->node.nsnode);
5563 This->dom_element = nselem;
5565 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_element);
5566 if(NS_SUCCEEDED(nsres)) {
5567 This->html_element = html_element;
5568 /* share reference with HTMLDOMNode */
5569 assert((nsIDOMNode*)html_element == This->node.nsnode);
5570 nsIDOMHTMLElement_Release(html_element);
5574 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
5577 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
5579 nsIDOMElement *nselem;
5580 nsAString tag_name_str;
5581 const PRUnichar *tag_name;
5582 const tag_desc_t *tag;
5583 HTMLElement *elem;
5584 nsresult nsres;
5585 HRESULT hres;
5587 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
5588 if(NS_FAILED(nsres)) {
5589 ERR("no nsIDOMElement iface\n");
5590 return E_FAIL;
5593 nsAString_Init(&tag_name_str, NULL);
5594 nsIDOMElement_GetTagName(nselem, &tag_name_str);
5596 nsAString_GetData(&tag_name_str, &tag_name);
5598 tag = get_tag_desc(tag_name);
5599 if(tag) {
5600 hres = tag->constructor(doc, (nsIDOMElement*)nselem, &elem);
5601 }else if(use_generic) {
5602 hres = HTMLGenericElement_Create(doc, (nsIDOMElement*)nselem, &elem);
5603 }else {
5604 elem = heap_alloc_zero(sizeof(HTMLElement));
5605 if(elem) {
5606 elem->node.vtbl = &HTMLElementImplVtbl;
5607 HTMLElement_Init(elem, doc, (nsIDOMElement*)nselem, &HTMLElement_dispex);
5608 hres = S_OK;
5609 }else {
5610 hres = E_OUTOFMEMORY;
5614 TRACE("%s ret %p\n", debugstr_w(tag_name), elem);
5616 nsIDOMElement_Release(nselem);
5617 nsAString_Finish(&tag_name_str);
5618 if(FAILED(hres))
5619 return hres;
5621 *ret = elem;
5622 return S_OK;
5625 HRESULT get_element(nsIDOMElement *nselem, HTMLElement **ret)
5627 HTMLDOMNode *node;
5628 HRESULT hres;
5630 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
5631 if(FAILED(hres))
5632 return hres;
5634 *ret = impl_from_HTMLDOMNode(node);
5635 return S_OK;
5638 /* interface IHTMLFiltersCollection */
5639 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
5641 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5643 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
5645 if(IsEqualGUID(&IID_IUnknown, riid)) {
5646 *ppv = &This->IHTMLFiltersCollection_iface;
5647 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
5648 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
5649 *ppv = &This->IHTMLFiltersCollection_iface;
5650 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5651 return *ppv ? S_OK : E_NOINTERFACE;
5652 }else {
5653 *ppv = NULL;
5654 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5655 return E_NOINTERFACE;
5658 IUnknown_AddRef((IUnknown*)*ppv);
5659 return S_OK;
5662 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
5664 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5665 LONG ref = InterlockedIncrement(&This->ref);
5667 TRACE("(%p) ref=%d\n", This, ref);
5669 return ref;
5672 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
5674 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5675 LONG ref = InterlockedDecrement(&This->ref);
5677 TRACE("(%p) ref=%d\n", This, ref);
5679 if(!ref)
5681 heap_free(This);
5684 return ref;
5687 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
5689 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5690 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5693 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
5694 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
5696 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5697 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5700 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
5701 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
5702 LCID lcid, DISPID *rgDispId)
5704 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5705 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5706 lcid, rgDispId);
5709 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
5710 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
5711 EXCEPINFO *pExcepInfo, UINT *puArgErr)
5713 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5714 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5715 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5718 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
5720 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5722 if(!p)
5723 return E_POINTER;
5725 FIXME("(%p)->(%p) Always returning 0\n", This, p);
5726 *p = 0;
5728 return S_OK;
5731 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
5733 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5734 FIXME("(%p)->(%p)\n", This, p);
5735 return E_NOTIMPL;
5738 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
5740 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
5741 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
5742 return E_NOTIMPL;
5745 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
5746 HTMLFiltersCollection_QueryInterface,
5747 HTMLFiltersCollection_AddRef,
5748 HTMLFiltersCollection_Release,
5749 HTMLFiltersCollection_GetTypeInfoCount,
5750 HTMLFiltersCollection_GetTypeInfo,
5751 HTMLFiltersCollection_GetIDsOfNames,
5752 HTMLFiltersCollection_Invoke,
5753 HTMLFiltersCollection_get_length,
5754 HTMLFiltersCollection_get__newEnum,
5755 HTMLFiltersCollection_item
5758 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
5760 WCHAR *ptr;
5761 int idx = 0;
5763 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
5764 idx = idx*10 + (*ptr-'0');
5765 if(*ptr)
5766 return DISP_E_UNKNOWNNAME;
5768 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
5769 TRACE("ret %x\n", *dispid);
5770 return S_OK;
5773 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
5774 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
5776 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
5778 V_VT(res) = VT_DISPATCH;
5779 V_DISPATCH(res) = NULL;
5781 FIXME("always returning NULL\n");
5783 return S_OK;
5786 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
5787 NULL,
5788 HTMLFiltersCollection_get_dispid,
5789 HTMLFiltersCollection_invoke,
5790 NULL
5793 static const tid_t HTMLFiltersCollection_iface_tids[] = {
5794 IHTMLFiltersCollection_tid,
5797 static dispex_static_data_t HTMLFiltersCollection_dispex = {
5798 &HTMLFiltersCollection_dispex_vtbl,
5799 IHTMLFiltersCollection_tid,
5800 HTMLFiltersCollection_iface_tids
5803 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
5805 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
5807 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
5808 ret->ref = 1;
5810 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
5811 &HTMLFiltersCollection_dispex);
5813 return &ret->IHTMLFiltersCollection_iface;
5816 /* interface IHTMLAttributeCollection */
5817 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
5819 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
5822 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
5824 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5826 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5828 if(IsEqualGUID(&IID_IUnknown, riid)) {
5829 *ppv = &This->IHTMLAttributeCollection_iface;
5830 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
5831 *ppv = &This->IHTMLAttributeCollection_iface;
5832 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
5833 *ppv = &This->IHTMLAttributeCollection2_iface;
5834 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
5835 *ppv = &This->IHTMLAttributeCollection3_iface;
5836 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
5837 return *ppv ? S_OK : E_NOINTERFACE;
5838 }else {
5839 *ppv = NULL;
5840 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
5841 return E_NOINTERFACE;
5844 IUnknown_AddRef((IUnknown*)*ppv);
5845 return S_OK;
5848 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
5850 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5851 LONG ref = InterlockedIncrement(&This->ref);
5853 TRACE("(%p) ref=%d\n", This, ref);
5855 return ref;
5858 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
5860 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5861 LONG ref = InterlockedDecrement(&This->ref);
5863 TRACE("(%p) ref=%d\n", This, ref);
5865 if(!ref) {
5866 while(!list_empty(&This->attrs)) {
5867 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
5869 list_remove(&attr->entry);
5870 attr->elem = NULL;
5871 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
5874 heap_free(This);
5877 return ref;
5880 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
5882 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5883 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
5886 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
5887 LCID lcid, ITypeInfo **ppTInfo)
5889 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5890 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
5893 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
5894 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5896 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5897 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
5898 lcid, rgDispId);
5901 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
5902 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
5903 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
5905 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
5906 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
5907 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
5910 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
5912 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
5913 DISPID id = DISPID_STARTENUM;
5914 LONG len = -1;
5915 HRESULT hres;
5917 FIXME("filter non-enumerable attributes out\n");
5919 while(1) {
5920 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
5921 if(FAILED(hres))
5922 return hres;
5923 else if(hres == S_FALSE)
5924 break;
5926 len++;
5927 if(len == *idx)
5928 break;
5931 if(dispid) {
5932 *dispid = id;
5933 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
5936 *idx = len+1;
5937 return S_OK;
5940 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
5942 HRESULT hres;
5944 if(name[0]>='0' && name[0]<='9') {
5945 WCHAR *end_ptr;
5946 LONG idx;
5948 idx = strtoulW(name, &end_ptr, 10);
5949 if(!*end_ptr) {
5950 hres = get_attr_dispid_by_idx(This, &idx, id);
5951 if(SUCCEEDED(hres))
5952 return hres;
5956 if(!This->elem) {
5957 WARN("NULL elem\n");
5958 return E_UNEXPECTED;
5961 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
5962 name, fdexNameCaseInsensitive, id);
5963 return hres;
5966 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
5968 HTMLDOMAttribute *iter;
5969 LONG pos = 0;
5970 HRESULT hres;
5972 *attr = NULL;
5973 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
5974 if(iter->dispid == id) {
5975 *attr = iter;
5976 break;
5978 pos++;
5981 if(!*attr) {
5982 if(!This->elem) {
5983 WARN("NULL elem\n");
5984 return E_UNEXPECTED;
5987 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
5988 if(FAILED(hres))
5989 return hres;
5992 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
5993 if(list_pos)
5994 *list_pos = pos;
5995 return S_OK;
5998 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
6000 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
6001 HRESULT hres;
6003 TRACE("(%p)->(%p)\n", This, p);
6005 *p = -1;
6006 hres = get_attr_dispid_by_idx(This, p, NULL);
6007 return hres;
6010 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
6012 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
6013 FIXME("(%p)->(%p)\n", This, p);
6014 return E_NOTIMPL;
6017 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
6019 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
6020 HTMLDOMAttribute *attr;
6021 DISPID id;
6022 HRESULT hres;
6024 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
6026 switch(V_VT(name)) {
6027 case VT_I4:
6028 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
6029 break;
6030 case VT_BSTR:
6031 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
6032 break;
6033 default:
6034 FIXME("unsupported name %s\n", debugstr_variant(name));
6035 hres = E_NOTIMPL;
6037 if(hres == DISP_E_UNKNOWNNAME)
6038 return E_INVALIDARG;
6039 if(FAILED(hres))
6040 return hres;
6042 hres = get_domattr(This, id, NULL, &attr);
6043 if(FAILED(hres))
6044 return hres;
6046 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
6047 return S_OK;
6050 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
6051 HTMLAttributeCollection_QueryInterface,
6052 HTMLAttributeCollection_AddRef,
6053 HTMLAttributeCollection_Release,
6054 HTMLAttributeCollection_GetTypeInfoCount,
6055 HTMLAttributeCollection_GetTypeInfo,
6056 HTMLAttributeCollection_GetIDsOfNames,
6057 HTMLAttributeCollection_Invoke,
6058 HTMLAttributeCollection_get_length,
6059 HTMLAttributeCollection__newEnum,
6060 HTMLAttributeCollection_item
6063 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
6065 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
6068 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
6070 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6071 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
6074 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
6076 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6077 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
6080 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
6082 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6083 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
6086 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
6088 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6089 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
6092 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
6093 LCID lcid, ITypeInfo **ppTInfo)
6095 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6096 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6099 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
6100 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6102 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6103 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6104 lcid, rgDispId);
6107 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
6108 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6109 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6111 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6112 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6113 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6116 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
6117 IHTMLDOMAttribute **newretNode)
6119 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6120 HTMLDOMAttribute *attr;
6121 DISPID id;
6122 HRESULT hres;
6124 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
6126 hres = get_attr_dispid_by_name(This, bstrName, &id);
6127 if(hres == DISP_E_UNKNOWNNAME) {
6128 *newretNode = NULL;
6129 return S_OK;
6130 } else if(FAILED(hres)) {
6131 return hres;
6134 hres = get_domattr(This, id, NULL, &attr);
6135 if(FAILED(hres))
6136 return hres;
6138 *newretNode = &attr->IHTMLDOMAttribute_iface;
6139 return S_OK;
6142 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
6143 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
6145 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6146 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
6147 return E_NOTIMPL;
6150 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
6151 BSTR bstrName, IHTMLDOMAttribute **newretNode)
6153 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
6154 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
6155 return E_NOTIMPL;
6158 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
6159 HTMLAttributeCollection2_QueryInterface,
6160 HTMLAttributeCollection2_AddRef,
6161 HTMLAttributeCollection2_Release,
6162 HTMLAttributeCollection2_GetTypeInfoCount,
6163 HTMLAttributeCollection2_GetTypeInfo,
6164 HTMLAttributeCollection2_GetIDsOfNames,
6165 HTMLAttributeCollection2_Invoke,
6166 HTMLAttributeCollection2_getNamedItem,
6167 HTMLAttributeCollection2_setNamedItem,
6168 HTMLAttributeCollection2_removeNamedItem
6171 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
6173 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
6176 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
6178 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6179 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
6182 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
6184 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6185 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
6188 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
6190 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6191 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
6194 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
6196 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6197 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
6200 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
6201 LCID lcid, ITypeInfo **ppTInfo)
6203 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6204 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
6207 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
6208 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
6210 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6211 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
6212 lcid, rgDispId);
6215 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
6216 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
6217 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
6219 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6220 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
6221 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
6224 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
6225 IHTMLDOMAttribute **ppNodeOut)
6227 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6228 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
6231 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
6232 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
6234 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6235 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
6236 return E_NOTIMPL;
6239 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
6240 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
6242 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6243 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
6244 return E_NOTIMPL;
6247 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
6249 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6250 HTMLDOMAttribute *attr;
6251 DISPID id;
6252 HRESULT hres;
6254 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
6256 hres = get_attr_dispid_by_idx(This, &index, &id);
6257 if(hres == DISP_E_UNKNOWNNAME)
6258 return E_INVALIDARG;
6259 if(FAILED(hres))
6260 return hres;
6262 hres = get_domattr(This, id, NULL, &attr);
6263 if(FAILED(hres))
6264 return hres;
6266 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
6267 return S_OK;
6270 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
6272 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
6273 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
6276 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
6277 HTMLAttributeCollection3_QueryInterface,
6278 HTMLAttributeCollection3_AddRef,
6279 HTMLAttributeCollection3_Release,
6280 HTMLAttributeCollection3_GetTypeInfoCount,
6281 HTMLAttributeCollection3_GetTypeInfo,
6282 HTMLAttributeCollection3_GetIDsOfNames,
6283 HTMLAttributeCollection3_Invoke,
6284 HTMLAttributeCollection3_getNamedItem,
6285 HTMLAttributeCollection3_setNamedItem,
6286 HTMLAttributeCollection3_removeNamedItem,
6287 HTMLAttributeCollection3_item,
6288 HTMLAttributeCollection3_get_length
6291 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
6293 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
6296 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
6298 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
6299 HTMLDOMAttribute *attr;
6300 LONG pos;
6301 HRESULT hres;
6303 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
6305 hres = get_attr_dispid_by_name(This, name, dispid);
6306 if(FAILED(hres))
6307 return hres;
6309 hres = get_domattr(This, *dispid, &pos, &attr);
6310 if(FAILED(hres))
6311 return hres;
6312 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
6314 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
6315 return S_OK;
6318 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
6319 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
6321 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
6323 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
6325 switch(flags) {
6326 case DISPATCH_PROPERTYGET: {
6327 HTMLDOMAttribute *iter;
6328 DWORD pos;
6330 pos = id-MSHTML_DISPID_CUSTOM_MIN;
6332 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
6333 if(!pos) {
6334 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
6335 V_VT(res) = VT_DISPATCH;
6336 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
6337 return S_OK;
6339 pos--;
6342 WARN("invalid arg\n");
6343 return E_INVALIDARG;
6346 default:
6347 FIXME("unimplemented flags %x\n", flags);
6348 return E_NOTIMPL;
6352 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
6353 NULL,
6354 HTMLAttributeCollection_get_dispid,
6355 HTMLAttributeCollection_invoke,
6356 NULL
6359 static const tid_t HTMLAttributeCollection_iface_tids[] = {
6360 IHTMLAttributeCollection_tid,
6361 IHTMLAttributeCollection2_tid,
6362 IHTMLAttributeCollection3_tid,
6366 static dispex_static_data_t HTMLAttributeCollection_dispex = {
6367 &HTMLAttributeCollection_dispex_vtbl,
6368 DispHTMLAttributeCollection_tid,
6369 HTMLAttributeCollection_iface_tids
6372 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
6374 HTMLElement *This = impl_from_HTMLDOMNode(iface);
6376 if(This->attrs) {
6377 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
6378 *ac = This->attrs;
6379 return S_OK;
6382 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
6383 if(!This->attrs)
6384 return E_OUTOFMEMORY;
6386 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
6387 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
6388 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
6389 This->attrs->ref = 2;
6391 This->attrs->elem = This;
6392 list_init(&This->attrs->attrs);
6393 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
6394 &HTMLAttributeCollection_dispex);
6396 *ac = This->attrs;
6397 return S_OK;