mshtml: Properly return NULL parentElement.
[wine.git] / dlls / mshtml / htmlelem.c
blob6c948d320118fced271314f38d1bddd0e2182268
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 iframeW[] = {'I','F','R','A','M','E',0};
50 static const WCHAR imgW[] = {'I','M','G',0};
51 static const WCHAR inputW[] = {'I','N','P','U','T',0};
52 static const WCHAR labelW[] = {'L','A','B','E','L',0};
53 static const WCHAR linkW[] = {'L','I','N','K',0};
54 static const WCHAR metaW[] = {'M','E','T','A',0};
55 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
56 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
57 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
58 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
59 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
60 static const WCHAR tableW[] = {'T','A','B','L','E',0};
61 static const WCHAR tdW[] = {'T','D',0};
62 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
63 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
64 static const WCHAR trW[] = {'T','R',0};
66 typedef struct {
67 const WCHAR *name;
68 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
69 } tag_desc_t;
71 static const tag_desc_t tag_descs[] = {
72 {aW, HTMLAnchorElement_Create},
73 {areaW, HTMLAreaElement_Create},
74 {bodyW, HTMLBodyElement_Create},
75 {buttonW, HTMLButtonElement_Create},
76 {embedW, HTMLEmbedElement_Create},
77 {formW, HTMLFormElement_Create},
78 {frameW, HTMLFrameElement_Create},
79 {headW, HTMLHeadElement_Create},
80 {iframeW, HTMLIFrame_Create},
81 {imgW, HTMLImgElement_Create},
82 {inputW, HTMLInputElement_Create},
83 {labelW, HTMLLabelElement_Create},
84 {linkW, HTMLLinkElement_Create},
85 {metaW, HTMLMetaElement_Create},
86 {objectW, HTMLObjectElement_Create},
87 {optionW, HTMLOptionElement_Create},
88 {scriptW, HTMLScriptElement_Create},
89 {selectW, HTMLSelectElement_Create},
90 {styleW, HTMLStyleElement_Create},
91 {tableW, HTMLTable_Create},
92 {tdW, HTMLTableCell_Create},
93 {textareaW, HTMLTextAreaElement_Create},
94 {title_tagW, HTMLTitleElement_Create},
95 {trW, HTMLTableRow_Create}
98 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
100 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
101 int r;
103 while(min <= max) {
104 i = (min+max)/2;
105 r = strcmpW(tag_name, tag_descs[i].name);
106 if(!r)
107 return tag_descs+i;
109 if(r < 0)
110 max = i-1;
111 else
112 min = i+1;
115 return NULL;
118 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
120 nsIDOMDocumentFragment *nsfragment;
121 nsIDOMNode *nsparent;
122 nsIDOMRange *range;
123 nsAString html_str;
124 nsresult nsres;
125 HRESULT hres = S_OK;
127 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
128 if(NS_FAILED(nsres)) {
129 ERR("CreateRange failed: %08x\n", nsres);
130 return E_FAIL;
133 nsAString_InitDepend(&html_str, html);
134 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
135 nsIDOMRange_Release(range);
136 nsAString_Finish(&html_str);
137 if(NS_FAILED(nsres)) {
138 ERR("CreateContextualFragment failed: %08x\n", nsres);
139 return E_FAIL;
142 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
143 if(NS_SUCCEEDED(nsres) && nsparent) {
144 nsIDOMNode *nstmp;
146 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
147 nsIDOMNode_Release(nsparent);
148 if(NS_FAILED(nsres)) {
149 ERR("ReplaceChild failed: %08x\n", nsres);
150 hres = E_FAIL;
151 }else if(nstmp) {
152 nsIDOMNode_Release(nstmp);
154 }else {
155 ERR("GetParentNode failed: %08x\n", nsres);
156 hres = E_FAIL;
159 nsIDOMDocumentFragment_Release(nsfragment);
160 return hres;
163 nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
165 nsAString name_str;
166 nsresult nsres;
168 nsAString_InitDepend(&name_str, name);
169 nsAString_Init(val_str, NULL);
170 nsres = nsIDOMHTMLElement_GetAttribute(nselem, &name_str, val_str);
171 nsAString_Finish(&name_str);
172 if(NS_FAILED(nsres)) {
173 ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name), nsres);
174 nsAString_Finish(val_str);
175 return nsres;
178 nsAString_GetData(val_str, val);
179 return NS_OK;
182 HRESULT elem_string_attr_getter(HTMLElement *elem, const WCHAR *name, BOOL use_null, BSTR *p)
184 const PRUnichar *val;
185 nsAString val_str;
186 nsresult nsres;
187 HRESULT hres = S_OK;
189 nsres = get_elem_attr_value(elem->nselem, name, &val_str, &val);
190 if(NS_FAILED(nsres))
191 return E_FAIL;
193 TRACE("%s: returning %s\n", debugstr_w(name), debugstr_w(val));
195 if(*val || !use_null) {
196 *p = SysAllocString(val);
197 if(!*p)
198 hres = E_OUTOFMEMORY;
199 }else {
200 *p = NULL;
202 nsAString_Finish(&val_str);
203 return hres;
206 HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHAR *value)
208 nsAString name_str, val_str;
209 nsresult nsres;
211 nsAString_InitDepend(&name_str, name);
212 nsAString_InitDepend(&val_str, value);
213 nsres = nsIDOMHTMLElement_SetAttribute(elem->nselem, &name_str, &val_str);
214 nsAString_Finish(&name_str);
215 nsAString_Finish(&val_str);
217 if(NS_FAILED(nsres)) {
218 WARN("SetAttribute failed: %08x\n", nsres);
219 return E_FAIL;
222 return S_OK;
225 HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
227 static const WCHAR uninitializedW[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
228 static const WCHAR loadingW[] = {'l','o','a','d','i','n','g',0};
229 static const WCHAR loadedW[] = {'l','o','a','d','e','d',0};
230 static const WCHAR interactiveW[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
231 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
233 static const LPCWSTR readystate_strs[] = {
234 uninitializedW,
235 loadingW,
236 loadedW,
237 interactiveW,
238 completeW
241 assert(readystate <= READYSTATE_COMPLETE);
242 *p = SysAllocString(readystate_strs[readystate]);
243 return *p ? S_OK : E_OUTOFMEMORY;
246 typedef struct
248 DispatchEx dispex;
249 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
251 LONG ref;
252 } HTMLFiltersCollection;
254 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
256 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
259 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
261 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
263 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
266 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
268 nsIDOMElement *nselem;
269 nsAString tag_str;
270 nsresult nsres;
272 if(!doc->nsdoc) {
273 WARN("NULL nsdoc\n");
274 return E_UNEXPECTED;
277 nsAString_InitDepend(&tag_str, tag);
278 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
279 nsAString_Finish(&tag_str);
280 if(NS_FAILED(nsres)) {
281 ERR("CreateElement failed: %08x\n", nsres);
282 return E_FAIL;
285 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
286 nsIDOMElement_Release(nselem);
287 if(NS_FAILED(nsres)) {
288 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
289 return E_FAIL;
292 return S_OK;
295 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
297 nsIDOMHTMLElement *nselem;
298 HRESULT hres;
300 /* Use owner doc if called on document fragment */
301 if(!doc->nsdoc)
302 doc = doc->node.doc;
304 hres = create_nselem(doc, tag, &nselem);
305 if(FAILED(hres))
306 return hres;
308 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
309 nsIDOMHTMLElement_Release(nselem);
310 return hres;
313 typedef struct {
314 DispatchEx dispex;
315 IHTMLRect IHTMLRect_iface;
317 LONG ref;
319 nsIDOMClientRect *nsrect;
320 } HTMLRect;
322 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
324 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
327 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
329 HTMLRect *This = impl_from_IHTMLRect(iface);
331 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
333 if(IsEqualGUID(&IID_IUnknown, riid)) {
334 *ppv = &This->IHTMLRect_iface;
335 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
336 *ppv = &This->IHTMLRect_iface;
337 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
338 return *ppv ? S_OK : E_NOINTERFACE;
339 }else {
340 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
341 *ppv = NULL;
342 return E_NOINTERFACE;
345 IUnknown_AddRef((IUnknown*)*ppv);
346 return S_OK;
349 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
351 HTMLRect *This = impl_from_IHTMLRect(iface);
352 LONG ref = InterlockedIncrement(&This->ref);
354 TRACE("(%p) ref=%d\n", This, ref);
356 return ref;
359 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
361 HTMLRect *This = impl_from_IHTMLRect(iface);
362 LONG ref = InterlockedDecrement(&This->ref);
364 TRACE("(%p) ref=%d\n", This, ref);
366 if(!ref) {
367 if(This->nsrect)
368 nsIDOMClientRect_Release(This->nsrect);
369 heap_free(This);
372 return ref;
375 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
377 HTMLRect *This = impl_from_IHTMLRect(iface);
378 FIXME("(%p)->(%p)\n", This, pctinfo);
379 return E_NOTIMPL;
382 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
383 LCID lcid, ITypeInfo **ppTInfo)
385 HTMLRect *This = impl_from_IHTMLRect(iface);
387 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
390 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
391 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
393 HTMLRect *This = impl_from_IHTMLRect(iface);
395 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
396 lcid, rgDispId);
399 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
400 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
401 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
403 HTMLRect *This = impl_from_IHTMLRect(iface);
405 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
406 pDispParams, pVarResult, pExcepInfo, puArgErr);
409 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
411 HTMLRect *This = impl_from_IHTMLRect(iface);
412 FIXME("(%p)->(%d)\n", This, v);
413 return E_NOTIMPL;
416 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
418 HTMLRect *This = impl_from_IHTMLRect(iface);
419 float left;
420 nsresult nsres;
422 TRACE("(%p)->(%p)\n", This, p);
424 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
425 if(NS_FAILED(nsres)) {
426 ERR("GetLeft failed: %08x\n", nsres);
427 return E_FAIL;
430 *p = floor(left+0.5);
431 return S_OK;
434 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
436 HTMLRect *This = impl_from_IHTMLRect(iface);
437 FIXME("(%p)->(%d)\n", This, v);
438 return E_NOTIMPL;
441 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
443 HTMLRect *This = impl_from_IHTMLRect(iface);
444 float top;
445 nsresult nsres;
447 TRACE("(%p)->(%p)\n", This, p);
449 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
450 if(NS_FAILED(nsres)) {
451 ERR("GetTop failed: %08x\n", nsres);
452 return E_FAIL;
455 *p = floor(top+0.5);
456 return S_OK;
459 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
461 HTMLRect *This = impl_from_IHTMLRect(iface);
462 FIXME("(%p)->(%d)\n", This, v);
463 return E_NOTIMPL;
466 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
468 HTMLRect *This = impl_from_IHTMLRect(iface);
469 float right;
470 nsresult nsres;
472 TRACE("(%p)->(%p)\n", This, p);
474 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
475 if(NS_FAILED(nsres)) {
476 ERR("GetRight failed: %08x\n", nsres);
477 return E_FAIL;
480 *p = floor(right+0.5);
481 return S_OK;
484 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
486 HTMLRect *This = impl_from_IHTMLRect(iface);
487 FIXME("(%p)->(%d)\n", This, v);
488 return E_NOTIMPL;
491 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
493 HTMLRect *This = impl_from_IHTMLRect(iface);
494 float bottom;
495 nsresult nsres;
497 TRACE("(%p)->(%p)\n", This, p);
499 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
500 if(NS_FAILED(nsres)) {
501 ERR("GetBottom failed: %08x\n", nsres);
502 return E_FAIL;
505 *p = floor(bottom+0.5);
506 return S_OK;
509 static const IHTMLRectVtbl HTMLRectVtbl = {
510 HTMLRect_QueryInterface,
511 HTMLRect_AddRef,
512 HTMLRect_Release,
513 HTMLRect_GetTypeInfoCount,
514 HTMLRect_GetTypeInfo,
515 HTMLRect_GetIDsOfNames,
516 HTMLRect_Invoke,
517 HTMLRect_put_left,
518 HTMLRect_get_left,
519 HTMLRect_put_top,
520 HTMLRect_get_top,
521 HTMLRect_put_right,
522 HTMLRect_get_right,
523 HTMLRect_put_bottom,
524 HTMLRect_get_bottom
527 static const tid_t HTMLRect_iface_tids[] = {
528 IHTMLRect_tid,
531 static dispex_static_data_t HTMLRect_dispex = {
532 NULL,
533 IHTMLRect_tid,
534 NULL,
535 HTMLRect_iface_tids
538 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
540 HTMLRect *rect;
542 rect = heap_alloc_zero(sizeof(HTMLRect));
543 if(!rect)
544 return E_OUTOFMEMORY;
546 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
547 rect->ref = 1;
549 init_dispex(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex);
551 nsIDOMClientRect_AddRef(nsrect);
552 rect->nsrect = nsrect;
554 *ret = &rect->IHTMLRect_iface;
555 return S_OK;
558 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
559 REFIID riid, void **ppv)
561 HTMLElement *This = impl_from_IHTMLElement(iface);
563 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
566 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
568 HTMLElement *This = impl_from_IHTMLElement(iface);
570 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
573 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
575 HTMLElement *This = impl_from_IHTMLElement(iface);
577 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
580 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
582 HTMLElement *This = impl_from_IHTMLElement(iface);
583 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
586 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
587 LCID lcid, ITypeInfo **ppTInfo)
589 HTMLElement *This = impl_from_IHTMLElement(iface);
590 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
593 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
594 LPOLESTR *rgszNames, UINT cNames,
595 LCID lcid, DISPID *rgDispId)
597 HTMLElement *This = impl_from_IHTMLElement(iface);
598 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
599 lcid, rgDispId);
602 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
603 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
604 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
606 HTMLElement *This = impl_from_IHTMLElement(iface);
607 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
608 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
611 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
612 VARIANT AttributeValue, LONG lFlags)
614 HTMLElement *This = impl_from_IHTMLElement(iface);
615 HRESULT hres;
616 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
617 DISPPARAMS dispParams;
618 EXCEPINFO excep;
620 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
622 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
623 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
624 if(FAILED(hres))
625 return hres;
627 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
628 TRACE("Ignoring call on style attribute\n");
629 return S_OK;
632 dispParams.cArgs = 1;
633 dispParams.cNamedArgs = 1;
634 dispParams.rgdispidNamedArgs = &dispidNamed;
635 dispParams.rgvarg = &AttributeValue;
637 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, dispid,
638 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
641 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, DWORD flags, VARIANT *ret)
643 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
644 EXCEPINFO excep;
645 HRESULT hres;
647 hres = IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
648 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
649 if(FAILED(hres))
650 return hres;
652 if(flags & ATTRFLAG_ASSTRING) {
653 switch(V_VT(ret)) {
654 case VT_BSTR:
655 break;
656 case VT_DISPATCH:
657 IDispatch_Release(V_DISPATCH(ret));
658 V_VT(ret) = VT_BSTR;
659 V_BSTR(ret) = SysAllocString(NULL);
660 break;
661 default:
662 hres = VariantChangeType(ret, ret, 0, VT_BSTR);
663 if(FAILED(hres))
664 return hres;
668 return S_OK;
671 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
672 LONG lFlags, VARIANT *AttributeValue)
674 HTMLElement *This = impl_from_IHTMLElement(iface);
675 DISPID dispid;
676 HRESULT hres;
678 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
680 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
681 FIXME("Unsupported flags %x\n", lFlags);
683 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
684 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
685 if(hres == DISP_E_UNKNOWNNAME) {
686 V_VT(AttributeValue) = VT_NULL;
687 return S_OK;
690 if(FAILED(hres)) {
691 V_VT(AttributeValue) = VT_NULL;
692 return hres;
695 return get_elem_attr_value_by_dispid(This, dispid, lFlags, AttributeValue);
698 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
699 LONG lFlags, VARIANT_BOOL *pfSuccess)
701 HTMLElement *This = impl_from_IHTMLElement(iface);
702 DISPID id;
703 HRESULT hres;
705 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
707 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
708 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
709 if(hres == DISP_E_UNKNOWNNAME) {
710 *pfSuccess = VARIANT_FALSE;
711 return S_OK;
713 if(FAILED(hres))
714 return hres;
716 if(id == DISPID_IHTMLELEMENT_STYLE) {
717 IHTMLStyle *style;
719 TRACE("Special case: style\n");
721 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
722 if(FAILED(hres))
723 return hres;
725 hres = IHTMLStyle_put_cssText(style, NULL);
726 IHTMLStyle_Release(style);
727 if(FAILED(hres))
728 return hres;
730 *pfSuccess = VARIANT_TRUE;
731 return S_OK;
734 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
737 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
739 HTMLElement *This = impl_from_IHTMLElement(iface);
740 nsAString classname_str;
741 nsresult nsres;
743 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
745 if(!This->nselem) {
746 FIXME("NULL nselem\n");
747 return E_NOTIMPL;
750 nsAString_InitDepend(&classname_str, v);
751 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
752 nsAString_Finish(&classname_str);
753 if(NS_FAILED(nsres))
754 ERR("SetClassName failed: %08x\n", nsres);
756 return S_OK;
759 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
761 HTMLElement *This = impl_from_IHTMLElement(iface);
762 nsAString class_str;
763 nsresult nsres;
765 TRACE("(%p)->(%p)\n", This, p);
767 if(!This->nselem) {
768 FIXME("NULL nselem\n");
769 return E_NOTIMPL;
772 nsAString_Init(&class_str, NULL);
773 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
774 return return_nsstr(nsres, &class_str, p);
777 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
779 HTMLElement *This = impl_from_IHTMLElement(iface);
780 nsAString id_str;
781 nsresult nsres;
783 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
785 if(!This->nselem) {
786 FIXME("nselem == NULL\n");
787 return S_OK;
790 nsAString_InitDepend(&id_str, v);
791 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
792 nsAString_Finish(&id_str);
793 if(NS_FAILED(nsres))
794 ERR("SetId failed: %08x\n", nsres);
796 return S_OK;
799 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
801 HTMLElement *This = impl_from_IHTMLElement(iface);
802 nsAString id_str;
803 nsresult nsres;
805 TRACE("(%p)->(%p)\n", This, p);
807 if(!This->nselem) {
808 *p = NULL;
809 return S_OK;
812 nsAString_Init(&id_str, NULL);
813 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
814 return return_nsstr(nsres, &id_str, p);
817 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
819 HTMLElement *This = impl_from_IHTMLElement(iface);
820 nsAString tag_str;
821 nsresult nsres;
823 TRACE("(%p)->(%p)\n", This, p);
825 if(!This->nselem) {
826 static const WCHAR comment_tagW[] = {'!',0};
828 WARN("NULL nselem, assuming comment\n");
830 *p = SysAllocString(comment_tagW);
831 return *p ? S_OK : E_OUTOFMEMORY;
834 nsAString_Init(&tag_str, NULL);
835 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
836 return return_nsstr(nsres, &tag_str, p);
839 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
841 HTMLElement *This = impl_from_IHTMLElement(iface);
842 IHTMLDOMNode *node;
843 HRESULT hres;
845 TRACE("(%p)->(%p)\n", This, p);
847 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
848 if(FAILED(hres))
849 return hres;
851 if(!node) {
852 *p = NULL;
853 return S_OK;
856 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
857 IHTMLDOMNode_Release(node);
858 if(FAILED(hres))
859 *p = NULL;
861 return S_OK;
864 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
866 HTMLElement *This = impl_from_IHTMLElement(iface);
868 TRACE("(%p)->(%p)\n", This, p);
870 if(!This->style) {
871 HRESULT hres;
873 hres = HTMLStyle_Create(This, &This->style);
874 if(FAILED(hres))
875 return hres;
878 *p = &This->style->IHTMLStyle_iface;
879 IHTMLStyle_AddRef(*p);
880 return S_OK;
883 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
885 HTMLElement *This = impl_from_IHTMLElement(iface);
886 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
887 return E_NOTIMPL;
890 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
892 HTMLElement *This = impl_from_IHTMLElement(iface);
893 FIXME("(%p)->(%p)\n", This, p);
894 return E_NOTIMPL;
897 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
899 HTMLElement *This = impl_from_IHTMLElement(iface);
901 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
903 return set_node_event(&This->node, EVENTID_CLICK, &v);
906 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
908 HTMLElement *This = impl_from_IHTMLElement(iface);
910 TRACE("(%p)->(%p)\n", This, p);
912 return get_node_event(&This->node, EVENTID_CLICK, p);
915 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
917 HTMLElement *This = impl_from_IHTMLElement(iface);
919 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
921 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
924 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
926 HTMLElement *This = impl_from_IHTMLElement(iface);
928 TRACE("(%p)->(%p)\n", This, p);
930 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
933 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
935 HTMLElement *This = impl_from_IHTMLElement(iface);
937 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
939 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
942 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
944 HTMLElement *This = impl_from_IHTMLElement(iface);
946 TRACE("(%p)->(%p)\n", This, p);
948 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
951 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
953 HTMLElement *This = impl_from_IHTMLElement(iface);
955 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
957 return set_node_event(&This->node, EVENTID_KEYUP, &v);
960 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
962 HTMLElement *This = impl_from_IHTMLElement(iface);
963 FIXME("(%p)->(%p)\n", This, p);
964 return E_NOTIMPL;
967 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
969 HTMLElement *This = impl_from_IHTMLElement(iface);
971 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
973 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
976 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
978 HTMLElement *This = impl_from_IHTMLElement(iface);
980 TRACE("(%p)->(%p)\n", This, p);
982 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
985 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
987 HTMLElement *This = impl_from_IHTMLElement(iface);
989 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
991 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
994 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
996 HTMLElement *This = impl_from_IHTMLElement(iface);
998 TRACE("(%p)->(%p)\n", This, p);
1000 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1003 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1005 HTMLElement *This = impl_from_IHTMLElement(iface);
1007 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1009 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1012 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1014 HTMLElement *This = impl_from_IHTMLElement(iface);
1016 TRACE("(%p)->(%p)\n", This, p);
1018 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1021 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1023 HTMLElement *This = impl_from_IHTMLElement(iface);
1025 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1027 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1030 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1032 HTMLElement *This = impl_from_IHTMLElement(iface);
1034 TRACE("(%p)->(%p)\n", This, p);
1036 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1039 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1041 HTMLElement *This = impl_from_IHTMLElement(iface);
1043 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1045 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1048 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1050 HTMLElement *This = impl_from_IHTMLElement(iface);
1052 TRACE("(%p)->(%p)\n", This, p);
1054 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1057 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1059 HTMLElement *This = impl_from_IHTMLElement(iface);
1061 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1063 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1066 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1068 HTMLElement *This = impl_from_IHTMLElement(iface);
1070 TRACE("(%p)->(%p)\n", This, p);
1072 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1075 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1077 HTMLElement *This = impl_from_IHTMLElement(iface);
1079 TRACE("(%p)->(%p)\n", This, p);
1081 if(!p)
1082 return E_POINTER;
1084 if(This->node.vtbl->get_document)
1085 return This->node.vtbl->get_document(&This->node, p);
1087 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1088 IDispatch_AddRef(*p);
1089 return S_OK;
1092 static const WCHAR titleW[] = {'t','i','t','l','e',0};
1094 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1096 HTMLElement *This = impl_from_IHTMLElement(iface);
1097 nsAString title_str;
1098 nsresult nsres;
1100 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1102 if(!This->nselem) {
1103 VARIANT *var;
1104 HRESULT hres;
1106 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, TRUE, &var);
1107 if(FAILED(hres))
1108 return hres;
1110 VariantClear(var);
1111 V_VT(var) = VT_BSTR;
1112 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1113 return S_OK;
1116 nsAString_InitDepend(&title_str, v);
1117 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
1118 nsAString_Finish(&title_str);
1119 if(NS_FAILED(nsres))
1120 ERR("SetTitle failed: %08x\n", nsres);
1122 return S_OK;
1125 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1127 HTMLElement *This = impl_from_IHTMLElement(iface);
1128 nsAString title_str;
1129 nsresult nsres;
1131 TRACE("(%p)->(%p)\n", This, p);
1133 if(!This->nselem) {
1134 VARIANT *var;
1135 HRESULT hres;
1137 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, FALSE, &var);
1138 if(hres == DISP_E_UNKNOWNNAME) {
1139 *p = NULL;
1140 }else if(V_VT(var) != VT_BSTR) {
1141 FIXME("title = %s\n", debugstr_variant(var));
1142 return E_FAIL;
1143 }else {
1144 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1147 return S_OK;
1150 nsAString_Init(&title_str, NULL);
1151 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
1152 return return_nsstr(nsres, &title_str, p);
1155 static const WCHAR languageW[] = {'l','a','n','g','u','a','g','e',0};
1157 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1159 HTMLElement *This = impl_from_IHTMLElement(iface);
1161 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1163 return elem_string_attr_setter(This, languageW, v);
1166 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1168 HTMLElement *This = impl_from_IHTMLElement(iface);
1170 TRACE("(%p)->(%p)\n", This, p);
1172 return elem_string_attr_getter(This, languageW, TRUE, p);
1175 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1177 HTMLElement *This = impl_from_IHTMLElement(iface);
1179 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1181 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1184 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1186 HTMLElement *This = impl_from_IHTMLElement(iface);
1188 TRACE("(%p)->(%p)\n", This, p);
1190 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1193 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1195 HTMLElement *This = impl_from_IHTMLElement(iface);
1196 cpp_bool start = TRUE;
1197 nsresult nsres;
1199 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1201 switch(V_VT(&varargStart)) {
1202 case VT_EMPTY:
1203 case VT_ERROR:
1204 break;
1205 case VT_BOOL:
1206 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1207 break;
1208 default:
1209 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1212 if(!This->nselem) {
1213 FIXME("Unsupported for comments\n");
1214 return E_NOTIMPL;
1217 nsres = nsIDOMHTMLElement_ScrollIntoView(This->nselem, start, 1);
1218 assert(nsres == NS_OK);
1220 return S_OK;
1223 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1224 VARIANT_BOOL *pfResult)
1226 HTMLElement *This = impl_from_IHTMLElement(iface);
1227 cpp_bool result = FALSE;
1229 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1231 if(pChild) {
1232 HTMLElement *child;
1233 nsresult nsres;
1235 child = unsafe_impl_from_IHTMLElement(pChild);
1236 if(!child) {
1237 ERR("not our element\n");
1238 return E_FAIL;
1241 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1242 assert(nsres == NS_OK);
1245 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
1246 return S_OK;
1249 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1251 HTMLElement *This = impl_from_IHTMLElement(iface);
1253 TRACE("(%p)->(%p)\n", This, p);
1255 return get_elem_source_index(This, p);
1258 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1260 HTMLElement *This = impl_from_IHTMLElement(iface);
1261 FIXME("(%p)->(%p)\n", This, p);
1262 return E_NOTIMPL;
1265 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1267 HTMLElement *This = impl_from_IHTMLElement(iface);
1268 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1269 return E_NOTIMPL;
1272 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1274 HTMLElement *This = impl_from_IHTMLElement(iface);
1275 FIXME("(%p)->(%p)\n", This, p);
1276 return E_NOTIMPL;
1279 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1281 HTMLElement *This = impl_from_IHTMLElement(iface);
1282 nsresult nsres;
1284 TRACE("(%p)->(%p)\n", This, p);
1286 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, p);
1287 if(NS_FAILED(nsres)) {
1288 ERR("GetOffsetLeft failed: %08x\n", nsres);
1289 return E_FAIL;
1292 return S_OK;
1295 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1297 HTMLElement *This = impl_from_IHTMLElement(iface);
1298 nsresult nsres;
1300 TRACE("(%p)->(%p)\n", This, p);
1302 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, p);
1303 if(NS_FAILED(nsres)) {
1304 ERR("GetOffsetTop failed: %08x\n", nsres);
1305 return E_FAIL;
1308 return S_OK;
1311 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1313 HTMLElement *This = impl_from_IHTMLElement(iface);
1314 nsresult nsres;
1316 TRACE("(%p)->(%p)\n", This, p);
1318 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, p);
1319 if(NS_FAILED(nsres)) {
1320 ERR("GetOffsetWidth failed: %08x\n", nsres);
1321 return E_FAIL;
1324 return S_OK;
1327 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1329 HTMLElement *This = impl_from_IHTMLElement(iface);
1330 nsresult nsres;
1332 TRACE("(%p)->(%p)\n", This, p);
1334 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, p);
1335 if(NS_FAILED(nsres)) {
1336 ERR("GetOffsetHeight failed: %08x\n", nsres);
1337 return E_FAIL;
1340 return S_OK;
1343 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1345 HTMLElement *This = impl_from_IHTMLElement(iface);
1346 nsIDOMElement *nsparent;
1347 nsresult nsres;
1348 HRESULT hres;
1350 TRACE("(%p)->(%p)\n", This, p);
1352 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
1353 if(NS_FAILED(nsres)) {
1354 ERR("GetOffsetParent failed: %08x\n", nsres);
1355 return E_FAIL;
1358 if(nsparent) {
1359 HTMLDOMNode *node;
1361 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1362 nsIDOMElement_Release(nsparent);
1363 if(FAILED(hres))
1364 return hres;
1366 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1367 node_release(node);
1368 }else {
1369 *p = NULL;
1370 hres = S_OK;
1373 return hres;
1376 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1378 HTMLElement *This = impl_from_IHTMLElement(iface);
1379 nsAString html_str;
1380 nsresult nsres;
1382 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1384 if(!This->nselem) {
1385 FIXME("NULL nselem\n");
1386 return E_NOTIMPL;
1389 nsAString_InitDepend(&html_str, v);
1390 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
1391 nsAString_Finish(&html_str);
1392 if(NS_FAILED(nsres)) {
1393 FIXME("SetInnerHtml failed %08x\n", nsres);
1394 return E_FAIL;
1397 return S_OK;
1400 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1402 HTMLElement *This = impl_from_IHTMLElement(iface);
1403 nsAString html_str;
1404 nsresult nsres;
1406 TRACE("(%p)->(%p)\n", This, p);
1408 if(!This->nselem) {
1409 FIXME("NULL nselem\n");
1410 return E_NOTIMPL;
1413 nsAString_Init(&html_str, NULL);
1414 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
1415 return return_nsstr(nsres, &html_str, p);
1418 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1420 HTMLElement *This = impl_from_IHTMLElement(iface);
1421 nsIDOMNode *nschild, *tmp;
1422 nsIDOMText *text_node;
1423 nsAString text_str;
1424 nsresult nsres;
1426 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1428 while(1) {
1429 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1430 if(NS_FAILED(nsres)) {
1431 ERR("GetLastChild failed: %08x\n", nsres);
1432 return E_FAIL;
1434 if(!nschild)
1435 break;
1437 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1438 nsIDOMNode_Release(nschild);
1439 if(NS_FAILED(nsres)) {
1440 ERR("RemoveChild failed: %08x\n", nsres);
1441 return E_FAIL;
1443 nsIDOMNode_Release(tmp);
1446 nsAString_InitDepend(&text_str, v);
1447 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1448 nsAString_Finish(&text_str);
1449 if(NS_FAILED(nsres)) {
1450 ERR("CreateTextNode failed: %08x\n", nsres);
1451 return E_FAIL;
1454 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1455 if(NS_FAILED(nsres)) {
1456 ERR("AppendChild failed: %08x\n", nsres);
1457 return E_FAIL;
1460 nsIDOMNode_Release(tmp);
1461 return S_OK;
1464 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1466 HTMLElement *This = impl_from_IHTMLElement(iface);
1468 TRACE("(%p)->(%p)\n", This, p);
1470 return get_node_text(&This->node, p);
1473 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1475 HTMLElement *This = impl_from_IHTMLElement(iface);
1477 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1479 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1482 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1484 HTMLElement *This = impl_from_IHTMLElement(iface);
1485 nsAString html_str;
1486 HRESULT hres;
1488 WARN("(%p)->(%p) semi-stub\n", This, p);
1490 nsAString_Init(&html_str, NULL);
1491 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1492 if(SUCCEEDED(hres)) {
1493 const PRUnichar *html;
1495 nsAString_GetData(&html_str, &html);
1496 *p = SysAllocString(html);
1497 if(!*p)
1498 hres = E_OUTOFMEMORY;
1501 nsAString_Finish(&html_str);
1503 TRACE("ret %s\n", debugstr_w(*p));
1504 return hres;
1507 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1509 HTMLElement *This = impl_from_IHTMLElement(iface);
1510 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1511 return E_NOTIMPL;
1514 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1516 HTMLElement *This = impl_from_IHTMLElement(iface);
1517 FIXME("(%p)->(%p)\n", This, p);
1518 return E_NOTIMPL;
1521 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1523 nsIDOMNode *ret_nsnode;
1524 nsresult nsres;
1525 HRESULT hres = S_OK;
1527 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1528 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1529 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1530 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1532 if (!strcmpiW(where, beforebeginW)) {
1533 nsIDOMNode *parent;
1535 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1536 if(NS_FAILED(nsres))
1537 return E_FAIL;
1539 if(!parent)
1540 return E_INVALIDARG;
1542 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1543 nsIDOMNode_Release(parent);
1544 }else if(!strcmpiW(where, afterbeginW)) {
1545 nsIDOMNode *first_child;
1547 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1548 if(NS_FAILED(nsres))
1549 return E_FAIL;
1551 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1552 if(NS_FAILED(nsres))
1553 return E_FAIL;
1555 if (first_child)
1556 nsIDOMNode_Release(first_child);
1557 }else if (!strcmpiW(where, beforeendW)) {
1558 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1559 }else if (!strcmpiW(where, afterendW)) {
1560 nsIDOMNode *next_sibling, *parent;
1562 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1563 if(NS_FAILED(nsres))
1564 return E_FAIL;
1565 if(!parent)
1566 return E_INVALIDARG;
1568 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1569 if(NS_SUCCEEDED(nsres)) {
1570 if(next_sibling) {
1571 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1572 nsIDOMNode_Release(next_sibling);
1573 }else {
1574 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1578 nsIDOMNode_Release(parent);
1579 }else {
1580 ERR("invalid where: %s\n", debugstr_w(where));
1581 return E_INVALIDARG;
1584 if (NS_FAILED(nsres))
1585 return E_FAIL;
1587 if(ret_node)
1588 hres = get_node(This->node.doc, ret_nsnode, TRUE, ret_node);
1589 nsIDOMNode_Release(ret_nsnode);
1590 return hres;
1593 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1594 BSTR html)
1596 HTMLElement *This = impl_from_IHTMLElement(iface);
1597 nsIDOMRange *range;
1598 nsIDOMNode *nsnode;
1599 nsAString ns_html;
1600 nsresult nsres;
1601 HRESULT hr;
1603 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1605 if(!This->node.doc->nsdoc) {
1606 WARN("NULL nsdoc\n");
1607 return E_UNEXPECTED;
1610 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1611 if(NS_FAILED(nsres))
1613 ERR("CreateRange failed: %08x\n", nsres);
1614 return E_FAIL;
1617 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1619 nsAString_InitDepend(&ns_html, html);
1620 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1621 nsAString_Finish(&ns_html);
1622 nsIDOMRange_Release(range);
1624 if(NS_FAILED(nsres) || !nsnode)
1626 ERR("CreateTextNode failed: %08x\n", nsres);
1627 return E_FAIL;
1630 hr = insert_adjacent_node(This, where, nsnode, NULL);
1631 nsIDOMNode_Release(nsnode);
1632 return hr;
1635 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1636 BSTR text)
1638 HTMLElement *This = impl_from_IHTMLElement(iface);
1639 nsIDOMNode *nsnode;
1640 nsAString ns_text;
1641 nsresult nsres;
1642 HRESULT hr;
1644 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1646 if(!This->node.doc->nsdoc) {
1647 WARN("NULL nsdoc\n");
1648 return E_UNEXPECTED;
1652 nsAString_InitDepend(&ns_text, text);
1653 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1654 nsAString_Finish(&ns_text);
1656 if(NS_FAILED(nsres) || !nsnode)
1658 ERR("CreateTextNode failed: %08x\n", nsres);
1659 return E_FAIL;
1662 hr = insert_adjacent_node(This, where, nsnode, NULL);
1663 nsIDOMNode_Release(nsnode);
1665 return hr;
1668 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1670 HTMLElement *This = impl_from_IHTMLElement(iface);
1671 FIXME("(%p)->(%p)\n", This, p);
1672 return E_NOTIMPL;
1675 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1677 HTMLElement *This = impl_from_IHTMLElement(iface);
1679 TRACE("(%p)->(%p)\n", This, p);
1681 *p = This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node)
1682 ? VARIANT_TRUE : VARIANT_FALSE;
1683 return S_OK;
1686 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1688 HTMLElement *This = impl_from_IHTMLElement(iface);
1690 TRACE("(%p)\n", This);
1692 return call_fire_event(&This->node, EVENTID_CLICK);
1695 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1696 IHTMLFiltersCollection **p)
1698 HTMLElement *This = impl_from_IHTMLElement(iface);
1699 TRACE("(%p)->(%p)\n", This, p);
1701 if(!p)
1702 return E_POINTER;
1704 *p = HTMLFiltersCollection_Create();
1706 return S_OK;
1709 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1711 HTMLElement *This = impl_from_IHTMLElement(iface);
1712 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1713 return E_NOTIMPL;
1716 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1718 HTMLElement *This = impl_from_IHTMLElement(iface);
1719 FIXME("(%p)->(%p)\n", This, p);
1720 return E_NOTIMPL;
1723 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1725 HTMLElement *This = impl_from_IHTMLElement(iface);
1726 FIXME("(%p)->(%p)\n", This, String);
1727 return E_NOTIMPL;
1730 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1732 HTMLElement *This = impl_from_IHTMLElement(iface);
1733 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1734 return E_NOTIMPL;
1737 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1739 HTMLElement *This = impl_from_IHTMLElement(iface);
1740 FIXME("(%p)->(%p)\n", This, p);
1741 return E_NOTIMPL;
1744 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1746 HTMLElement *This = impl_from_IHTMLElement(iface);
1747 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1748 return E_NOTIMPL;
1751 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1753 HTMLElement *This = impl_from_IHTMLElement(iface);
1754 FIXME("(%p)->(%p)\n", This, p);
1755 return E_NOTIMPL;
1758 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1760 HTMLElement *This = impl_from_IHTMLElement(iface);
1761 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1762 return E_NOTIMPL;
1765 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1767 HTMLElement *This = impl_from_IHTMLElement(iface);
1768 FIXME("(%p)->(%p)\n", This, p);
1769 return E_NOTIMPL;
1772 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1774 HTMLElement *This = impl_from_IHTMLElement(iface);
1775 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1776 return E_NOTIMPL;
1779 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1781 HTMLElement *This = impl_from_IHTMLElement(iface);
1782 FIXME("(%p)->(%p)\n", This, p);
1783 return E_NOTIMPL;
1786 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1788 HTMLElement *This = impl_from_IHTMLElement(iface);
1789 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1790 return E_NOTIMPL;
1793 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1795 HTMLElement *This = impl_from_IHTMLElement(iface);
1796 FIXME("(%p)->(%p)\n", This, p);
1797 return E_NOTIMPL;
1800 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1802 HTMLElement *This = impl_from_IHTMLElement(iface);
1803 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1804 return E_NOTIMPL;
1807 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1809 HTMLElement *This = impl_from_IHTMLElement(iface);
1810 FIXME("(%p)->(%p)\n", This, p);
1811 return E_NOTIMPL;
1814 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1816 HTMLElement *This = impl_from_IHTMLElement(iface);
1818 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1820 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1823 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1825 HTMLElement *This = impl_from_IHTMLElement(iface);
1827 TRACE("(%p)->(%p)\n", This, p);
1829 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1832 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1834 HTMLElement *This = impl_from_IHTMLElement(iface);
1835 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1836 return E_NOTIMPL;
1839 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1841 HTMLElement *This = impl_from_IHTMLElement(iface);
1842 FIXME("(%p)->(%p)\n", This, p);
1843 return E_NOTIMPL;
1846 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1848 HTMLElement *This = impl_from_IHTMLElement(iface);
1849 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1850 return E_NOTIMPL;
1853 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1855 HTMLElement *This = impl_from_IHTMLElement(iface);
1856 FIXME("(%p)->(%p)\n", This, p);
1857 return E_NOTIMPL;
1860 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1862 HTMLElement *This = impl_from_IHTMLElement(iface);
1863 nsIDOMNodeList *nsnode_list;
1864 nsresult nsres;
1866 TRACE("(%p)->(%p)\n", This, p);
1868 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1869 if(NS_FAILED(nsres)) {
1870 ERR("GetChildNodes failed: %08x\n", nsres);
1871 return E_FAIL;
1874 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1876 nsIDOMNodeList_Release(nsnode_list);
1877 return S_OK;
1880 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1882 HTMLElement *This = impl_from_IHTMLElement(iface);
1884 TRACE("(%p)->(%p)\n", This, p);
1886 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1887 return S_OK;
1890 static const IHTMLElementVtbl HTMLElementVtbl = {
1891 HTMLElement_QueryInterface,
1892 HTMLElement_AddRef,
1893 HTMLElement_Release,
1894 HTMLElement_GetTypeInfoCount,
1895 HTMLElement_GetTypeInfo,
1896 HTMLElement_GetIDsOfNames,
1897 HTMLElement_Invoke,
1898 HTMLElement_setAttribute,
1899 HTMLElement_getAttribute,
1900 HTMLElement_removeAttribute,
1901 HTMLElement_put_className,
1902 HTMLElement_get_className,
1903 HTMLElement_put_id,
1904 HTMLElement_get_id,
1905 HTMLElement_get_tagName,
1906 HTMLElement_get_parentElement,
1907 HTMLElement_get_style,
1908 HTMLElement_put_onhelp,
1909 HTMLElement_get_onhelp,
1910 HTMLElement_put_onclick,
1911 HTMLElement_get_onclick,
1912 HTMLElement_put_ondblclick,
1913 HTMLElement_get_ondblclick,
1914 HTMLElement_put_onkeydown,
1915 HTMLElement_get_onkeydown,
1916 HTMLElement_put_onkeyup,
1917 HTMLElement_get_onkeyup,
1918 HTMLElement_put_onkeypress,
1919 HTMLElement_get_onkeypress,
1920 HTMLElement_put_onmouseout,
1921 HTMLElement_get_onmouseout,
1922 HTMLElement_put_onmouseover,
1923 HTMLElement_get_onmouseover,
1924 HTMLElement_put_onmousemove,
1925 HTMLElement_get_onmousemove,
1926 HTMLElement_put_onmousedown,
1927 HTMLElement_get_onmousedown,
1928 HTMLElement_put_onmouseup,
1929 HTMLElement_get_onmouseup,
1930 HTMLElement_get_document,
1931 HTMLElement_put_title,
1932 HTMLElement_get_title,
1933 HTMLElement_put_language,
1934 HTMLElement_get_language,
1935 HTMLElement_put_onselectstart,
1936 HTMLElement_get_onselectstart,
1937 HTMLElement_scrollIntoView,
1938 HTMLElement_contains,
1939 HTMLElement_get_sourceIndex,
1940 HTMLElement_get_recordNumber,
1941 HTMLElement_put_lang,
1942 HTMLElement_get_lang,
1943 HTMLElement_get_offsetLeft,
1944 HTMLElement_get_offsetTop,
1945 HTMLElement_get_offsetWidth,
1946 HTMLElement_get_offsetHeight,
1947 HTMLElement_get_offsetParent,
1948 HTMLElement_put_innerHTML,
1949 HTMLElement_get_innerHTML,
1950 HTMLElement_put_innerText,
1951 HTMLElement_get_innerText,
1952 HTMLElement_put_outerHTML,
1953 HTMLElement_get_outerHTML,
1954 HTMLElement_put_outerText,
1955 HTMLElement_get_outerText,
1956 HTMLElement_insertAdjacentHTML,
1957 HTMLElement_insertAdjacentText,
1958 HTMLElement_get_parentTextEdit,
1959 HTMLElement_get_isTextEdit,
1960 HTMLElement_click,
1961 HTMLElement_get_filters,
1962 HTMLElement_put_ondragstart,
1963 HTMLElement_get_ondragstart,
1964 HTMLElement_toString,
1965 HTMLElement_put_onbeforeupdate,
1966 HTMLElement_get_onbeforeupdate,
1967 HTMLElement_put_onafterupdate,
1968 HTMLElement_get_onafterupdate,
1969 HTMLElement_put_onerrorupdate,
1970 HTMLElement_get_onerrorupdate,
1971 HTMLElement_put_onrowexit,
1972 HTMLElement_get_onrowexit,
1973 HTMLElement_put_onrowenter,
1974 HTMLElement_get_onrowenter,
1975 HTMLElement_put_ondatasetchanged,
1976 HTMLElement_get_ondatasetchanged,
1977 HTMLElement_put_ondataavailable,
1978 HTMLElement_get_ondataavailable,
1979 HTMLElement_put_ondatasetcomplete,
1980 HTMLElement_get_ondatasetcomplete,
1981 HTMLElement_put_onfilterchange,
1982 HTMLElement_get_onfilterchange,
1983 HTMLElement_get_children,
1984 HTMLElement_get_all
1987 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1989 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1992 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
1994 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
1997 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
1998 REFIID riid, void **ppv)
2000 HTMLElement *This = impl_from_IHTMLElement2(iface);
2001 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2004 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2006 HTMLElement *This = impl_from_IHTMLElement2(iface);
2007 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2010 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2012 HTMLElement *This = impl_from_IHTMLElement2(iface);
2013 return IHTMLElement_Release(&This->IHTMLElement_iface);
2016 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2018 HTMLElement *This = impl_from_IHTMLElement2(iface);
2019 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2022 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2023 LCID lcid, ITypeInfo **ppTInfo)
2025 HTMLElement *This = impl_from_IHTMLElement2(iface);
2026 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2029 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2030 LPOLESTR *rgszNames, UINT cNames,
2031 LCID lcid, DISPID *rgDispId)
2033 HTMLElement *This = impl_from_IHTMLElement2(iface);
2034 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2035 lcid, rgDispId);
2038 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2039 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2040 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2042 HTMLElement *This = impl_from_IHTMLElement2(iface);
2043 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2044 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2047 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2049 HTMLElement *This = impl_from_IHTMLElement2(iface);
2050 FIXME("(%p)->(%p)\n", This, p);
2051 return E_NOTIMPL;
2054 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2056 HTMLElement *This = impl_from_IHTMLElement2(iface);
2057 FIXME("(%p)->(%x)\n", This, containerCapture);
2058 return E_NOTIMPL;
2061 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2063 HTMLElement *This = impl_from_IHTMLElement2(iface);
2064 FIXME("(%p)\n", This);
2065 return E_NOTIMPL;
2068 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2070 HTMLElement *This = impl_from_IHTMLElement2(iface);
2071 FIXME("(%p)->()\n", This);
2072 return E_NOTIMPL;
2075 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2077 HTMLElement *This = impl_from_IHTMLElement2(iface);
2078 FIXME("(%p)->(%p)\n", This, p);
2079 return E_NOTIMPL;
2082 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2083 LONG x, LONG y, BSTR *component)
2085 HTMLElement *This = impl_from_IHTMLElement2(iface);
2086 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2087 return E_NOTIMPL;
2090 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2092 HTMLElement *This = impl_from_IHTMLElement2(iface);
2094 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2096 if(!This->node.doc->content_ready
2097 || !This->node.doc->basedoc.doc_obj->in_place_active)
2098 return E_PENDING;
2100 WARN("stub\n");
2101 return S_OK;
2104 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2106 HTMLElement *This = impl_from_IHTMLElement2(iface);
2107 FIXME("(%p)->()\n", This);
2108 return E_NOTIMPL;
2111 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2113 HTMLElement *This = impl_from_IHTMLElement2(iface);
2114 FIXME("(%p)->(%p)\n", This, p);
2115 return E_NOTIMPL;
2118 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2120 HTMLElement *This = impl_from_IHTMLElement2(iface);
2122 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2124 return set_node_event(&This->node, EVENTID_DRAG, &v);
2127 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2129 HTMLElement *This = impl_from_IHTMLElement2(iface);
2131 TRACE("(%p)->(%p)\n", This, p);
2133 return get_node_event(&This->node, EVENTID_DRAG, p);
2136 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2138 HTMLElement *This = impl_from_IHTMLElement2(iface);
2139 FIXME("(%p)->()\n", This);
2140 return E_NOTIMPL;
2143 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2145 HTMLElement *This = impl_from_IHTMLElement2(iface);
2146 FIXME("(%p)->(%p)\n", This, p);
2147 return E_NOTIMPL;
2150 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2152 HTMLElement *This = impl_from_IHTMLElement2(iface);
2153 FIXME("(%p)->()\n", This);
2154 return E_NOTIMPL;
2157 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2159 HTMLElement *This = impl_from_IHTMLElement2(iface);
2160 FIXME("(%p)->(%p)\n", This, p);
2161 return E_NOTIMPL;
2164 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2166 HTMLElement *This = impl_from_IHTMLElement2(iface);
2167 FIXME("(%p)->()\n", This);
2168 return E_NOTIMPL;
2171 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2173 HTMLElement *This = impl_from_IHTMLElement2(iface);
2174 FIXME("(%p)->(%p)\n", This, p);
2175 return E_NOTIMPL;
2178 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2180 HTMLElement *This = impl_from_IHTMLElement2(iface);
2181 FIXME("(%p)->()\n", This);
2182 return E_NOTIMPL;
2185 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2187 HTMLElement *This = impl_from_IHTMLElement2(iface);
2188 FIXME("(%p)->(%p)\n", This, p);
2189 return E_NOTIMPL;
2192 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2194 HTMLElement *This = impl_from_IHTMLElement2(iface);
2195 FIXME("(%p)->()\n", This);
2196 return E_NOTIMPL;
2199 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2201 HTMLElement *This = impl_from_IHTMLElement2(iface);
2202 FIXME("(%p)->(%p)\n", This, p);
2203 return E_NOTIMPL;
2206 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2208 HTMLElement *This = impl_from_IHTMLElement2(iface);
2209 FIXME("(%p)->()\n", This);
2210 return E_NOTIMPL;
2213 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2215 HTMLElement *This = impl_from_IHTMLElement2(iface);
2216 FIXME("(%p)->(%p)\n", This, p);
2217 return E_NOTIMPL;
2220 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2222 HTMLElement *This = impl_from_IHTMLElement2(iface);
2223 FIXME("(%p)->()\n", This);
2224 return E_NOTIMPL;
2227 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2229 HTMLElement *This = impl_from_IHTMLElement2(iface);
2230 FIXME("(%p)->(%p)\n", This, p);
2231 return E_NOTIMPL;
2234 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2236 HTMLElement *This = impl_from_IHTMLElement2(iface);
2237 FIXME("(%p)->()\n", This);
2238 return E_NOTIMPL;
2241 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2243 HTMLElement *This = impl_from_IHTMLElement2(iface);
2244 FIXME("(%p)->(%p)\n", This, p);
2245 return E_NOTIMPL;
2248 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2250 HTMLElement *This = impl_from_IHTMLElement2(iface);
2251 FIXME("(%p)->()\n", This);
2252 return E_NOTIMPL;
2255 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2257 HTMLElement *This = impl_from_IHTMLElement2(iface);
2258 FIXME("(%p)->(%p)\n", This, p);
2259 return E_NOTIMPL;
2262 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2264 HTMLElement *This = impl_from_IHTMLElement2(iface);
2265 FIXME("(%p)->()\n", This);
2266 return E_NOTIMPL;
2269 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2271 HTMLElement *This = impl_from_IHTMLElement2(iface);
2272 FIXME("(%p)->(%p)\n", This, p);
2273 return E_NOTIMPL;
2276 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2278 HTMLElement *This = impl_from_IHTMLElement2(iface);
2280 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2282 return set_node_event(&This->node, EVENTID_PASTE, &v);
2285 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2287 HTMLElement *This = impl_from_IHTMLElement2(iface);
2289 TRACE("(%p)->(%p)\n", This, p);
2291 return get_node_event(&This->node, EVENTID_PASTE, p);
2294 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2296 HTMLElement *This = impl_from_IHTMLElement2(iface);
2298 TRACE("(%p)->(%p)\n", This, p);
2300 return HTMLCurrentStyle_Create(This, p);
2303 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2305 HTMLElement *This = impl_from_IHTMLElement2(iface);
2306 FIXME("(%p)->()\n", This);
2307 return E_NOTIMPL;
2310 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2312 HTMLElement *This = impl_from_IHTMLElement2(iface);
2313 FIXME("(%p)->(%p)\n", This, p);
2314 return E_NOTIMPL;
2317 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2319 HTMLElement *This = impl_from_IHTMLElement2(iface);
2320 FIXME("(%p)->(%p)\n", This, pRectCol);
2321 return E_NOTIMPL;
2324 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2326 HTMLElement *This = impl_from_IHTMLElement2(iface);
2327 nsIDOMClientRect *nsrect;
2328 nsresult nsres;
2329 HRESULT hres;
2331 TRACE("(%p)->(%p)\n", This, pRect);
2333 nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
2334 if(NS_FAILED(nsres) || !nsrect) {
2335 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2336 return E_FAIL;
2339 hres = create_html_rect(nsrect, pRect);
2341 nsIDOMClientRect_Release(nsrect);
2342 return hres;
2345 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2346 BSTR expression, BSTR language)
2348 HTMLElement *This = impl_from_IHTMLElement2(iface);
2349 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2350 debugstr_w(language));
2351 return E_NOTIMPL;
2354 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2355 VARIANT *expression)
2357 HTMLElement *This = impl_from_IHTMLElement2(iface);
2358 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2359 return E_NOTIMPL;
2362 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2363 VARIANT_BOOL *pfSuccess)
2365 HTMLElement *This = impl_from_IHTMLElement2(iface);
2366 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2367 return E_NOTIMPL;
2370 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2372 HTMLElement *This = impl_from_IHTMLElement2(iface);
2373 nsresult nsres;
2375 TRACE("(%p)->(%d)\n", This, v);
2377 nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
2378 if(NS_FAILED(nsres))
2379 ERR("GetTabIndex failed: %08x\n", nsres);
2381 return S_OK;
2384 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2386 HTMLElement *This = impl_from_IHTMLElement2(iface);
2387 LONG index;
2388 nsresult nsres;
2390 TRACE("(%p)->(%p)\n", This, p);
2392 nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
2393 if(NS_FAILED(nsres)) {
2394 ERR("GetTabIndex failed: %08x\n", nsres);
2395 return E_FAIL;
2398 *p = index;
2399 return S_OK;
2402 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2404 HTMLElement *This = impl_from_IHTMLElement2(iface);
2405 nsresult nsres;
2407 TRACE("(%p)\n", This);
2409 nsres = nsIDOMHTMLElement_Focus(This->nselem);
2410 if(NS_FAILED(nsres))
2411 ERR("Focus failed: %08x\n", nsres);
2413 return S_OK;
2416 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2418 HTMLElement *This = impl_from_IHTMLElement2(iface);
2419 VARIANT var;
2421 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2423 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2425 V_VT(&var) = VT_BSTR;
2426 V_BSTR(&var) = v;
2427 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2430 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2432 HTMLElement *This = impl_from_IHTMLElement2(iface);
2433 FIXME("(%p)->(%p)\n", This, p);
2434 return E_NOTIMPL;
2437 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2439 HTMLElement *This = impl_from_IHTMLElement2(iface);
2441 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2443 return set_node_event(&This->node, EVENTID_BLUR, &v);
2446 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2448 HTMLElement *This = impl_from_IHTMLElement2(iface);
2450 TRACE("(%p)->(%p)\n", This, p);
2452 return get_node_event(&This->node, EVENTID_BLUR, p);
2455 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2457 HTMLElement *This = impl_from_IHTMLElement2(iface);
2459 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2461 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2464 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2466 HTMLElement *This = impl_from_IHTMLElement2(iface);
2468 TRACE("(%p)->(%p)\n", This, p);
2470 return get_node_event(&This->node, EVENTID_FOCUS, p);
2473 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2475 HTMLElement *This = impl_from_IHTMLElement2(iface);
2476 FIXME("(%p)->()\n", This);
2477 return E_NOTIMPL;
2480 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2482 HTMLElement *This = impl_from_IHTMLElement2(iface);
2483 FIXME("(%p)->(%p)\n", This, p);
2484 return E_NOTIMPL;
2487 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2489 HTMLElement *This = impl_from_IHTMLElement2(iface);
2490 nsresult nsres;
2492 TRACE("(%p)\n", This);
2494 nsres = nsIDOMHTMLElement_Blur(This->nselem);
2495 if(NS_FAILED(nsres)) {
2496 ERR("Blur failed: %08x\n", nsres);
2497 return E_FAIL;
2500 return S_OK;
2503 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2505 HTMLElement *This = impl_from_IHTMLElement2(iface);
2506 FIXME("(%p)->(%p)\n", This, pUnk);
2507 return E_NOTIMPL;
2510 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2512 HTMLElement *This = impl_from_IHTMLElement2(iface);
2513 FIXME("(%p)->(%p)\n", This, pUnk);
2514 return E_NOTIMPL;
2517 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2519 HTMLElement *This = impl_from_IHTMLElement2(iface);
2520 nsresult nsres;
2522 TRACE("(%p)->(%p)\n", This, p);
2524 nsres = nsIDOMHTMLElement_GetClientHeight(This->nselem, p);
2525 assert(nsres == NS_OK);
2526 return S_OK;
2529 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2531 HTMLElement *This = impl_from_IHTMLElement2(iface);
2532 nsresult nsres;
2534 TRACE("(%p)->(%p)\n", This, p);
2536 nsres = nsIDOMHTMLElement_GetClientWidth(This->nselem, p);
2537 assert(nsres == NS_OK);
2538 return S_OK;
2541 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2543 HTMLElement *This = impl_from_IHTMLElement2(iface);
2544 nsresult nsres;
2546 TRACE("(%p)->(%p)\n", This, p);
2548 nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, p);
2549 assert(nsres == NS_OK);
2551 TRACE("*p = %d\n", *p);
2552 return S_OK;
2555 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2557 HTMLElement *This = impl_from_IHTMLElement2(iface);
2558 nsresult nsres;
2560 TRACE("(%p)->(%p)\n", This, p);
2562 nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, p);
2563 assert(nsres == NS_OK);
2565 TRACE("*p = %d\n", *p);
2566 return S_OK;
2569 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2570 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2572 HTMLElement *This = impl_from_IHTMLElement2(iface);
2574 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2576 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2579 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2581 HTMLElement *This = impl_from_IHTMLElement2(iface);
2583 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2585 return detach_event(&This->node.event_target, event, pDisp);
2588 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2590 HTMLElement *This = impl_from_IHTMLElement2(iface);
2591 BSTR str;
2593 TRACE("(%p)->(%p)\n", This, p);
2595 if(This->node.vtbl->get_readystate) {
2596 HRESULT hres;
2598 hres = This->node.vtbl->get_readystate(&This->node, &str);
2599 if(FAILED(hres))
2600 return hres;
2601 }else {
2602 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2604 str = SysAllocString(completeW);
2605 if(!str)
2606 return E_OUTOFMEMORY;
2609 V_VT(p) = VT_BSTR;
2610 V_BSTR(p) = str;
2611 return S_OK;
2614 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2616 HTMLElement *This = impl_from_IHTMLElement2(iface);
2618 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2620 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2623 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2625 HTMLElement *This = impl_from_IHTMLElement2(iface);
2627 TRACE("(%p)->(%p)\n", This, p);
2629 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2632 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2634 HTMLElement *This = impl_from_IHTMLElement2(iface);
2635 FIXME("(%p)->()\n", This);
2636 return E_NOTIMPL;
2639 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2641 HTMLElement *This = impl_from_IHTMLElement2(iface);
2642 FIXME("(%p)->(%p)\n", This, p);
2643 return E_NOTIMPL;
2646 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2648 HTMLElement *This = impl_from_IHTMLElement2(iface);
2649 FIXME("(%p)->()\n", This);
2650 return E_NOTIMPL;
2653 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2655 HTMLElement *This = impl_from_IHTMLElement2(iface);
2656 FIXME("(%p)->(%p)\n", This, p);
2657 return E_NOTIMPL;
2660 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2662 HTMLElement *This = impl_from_IHTMLElement2(iface);
2663 FIXME("(%p)->()\n", This);
2664 return E_NOTIMPL;
2667 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2669 HTMLElement *This = impl_from_IHTMLElement2(iface);
2670 FIXME("(%p)->(%p)\n", This, p);
2671 return E_NOTIMPL;
2674 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2676 HTMLElement *This = impl_from_IHTMLElement2(iface);
2677 nsAString nsstr;
2678 nsresult nsres;
2680 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2682 if(!This->nselem) {
2683 FIXME("Unsupported for comment nodes.\n");
2684 return S_OK;
2687 nsAString_InitDepend(&nsstr, v);
2688 nsres = nsIDOMHTMLElement_SetDir(This->nselem, &nsstr);
2689 nsAString_Finish(&nsstr);
2690 if(NS_FAILED(nsres)) {
2691 ERR("SetDir failed: %08x\n", nsres);
2692 return E_FAIL;
2695 return S_OK;
2698 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2700 HTMLElement *This = impl_from_IHTMLElement2(iface);
2701 nsAString dir_str;
2702 nsresult nsres;
2704 TRACE("(%p)->(%p)\n", This, p);
2706 if(!This->nselem) {
2707 *p = NULL;
2708 return S_OK;
2711 nsAString_Init(&dir_str, NULL);
2712 nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
2713 return return_nsstr(nsres, &dir_str, p);
2716 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2718 HTMLElement *This = impl_from_IHTMLElement2(iface);
2719 FIXME("(%p)->(%p)\n", This, range);
2720 return E_NOTIMPL;
2723 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2725 HTMLElement *This = impl_from_IHTMLElement2(iface);
2726 nsresult nsres;
2728 TRACE("(%p)->(%p)\n", This, p);
2730 nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, p);
2731 assert(nsres == NS_OK);
2733 TRACE("*p = %d\n", *p);
2734 return S_OK;
2737 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2739 HTMLElement *This = impl_from_IHTMLElement2(iface);
2740 nsresult nsres;
2742 TRACE("(%p)->(%p)\n", This, p);
2744 nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, p);
2745 assert(nsres == NS_OK);
2747 TRACE("*p = %d\n", *p);
2748 return S_OK;
2751 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2753 HTMLElement *This = impl_from_IHTMLElement2(iface);
2755 TRACE("(%p)->(%d)\n", This, v);
2757 if(!This->nselem) {
2758 FIXME("NULL nselem\n");
2759 return E_NOTIMPL;
2762 nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
2763 return S_OK;
2766 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2768 HTMLElement *This = impl_from_IHTMLElement2(iface);
2769 nsresult nsres;
2771 TRACE("(%p)->(%p)\n", This, p);
2773 nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, p);
2774 assert(nsres == NS_OK);
2776 TRACE("*p = %d\n", *p);
2777 return S_OK;
2780 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2782 HTMLElement *This = impl_from_IHTMLElement2(iface);
2784 TRACE("(%p)->(%d)\n", This, v);
2786 if(!This->nselem) {
2787 FIXME("NULL nselem\n");
2788 return E_NOTIMPL;
2791 nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
2792 return S_OK;
2795 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2797 HTMLElement *This = impl_from_IHTMLElement2(iface);
2798 nsresult nsres;
2800 TRACE("(%p)->(%p)\n", This, p);
2802 if(!p)
2803 return E_INVALIDARG;
2805 if(!This->nselem)
2807 FIXME("NULL nselem\n");
2808 return E_NOTIMPL;
2811 nsres = nsIDOMHTMLElement_GetScrollLeft(This->nselem, p);
2812 assert(nsres == NS_OK);
2814 TRACE("*p = %d\n", *p);
2815 return S_OK;
2818 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
2820 HTMLElement *This = impl_from_IHTMLElement2(iface);
2821 FIXME("(%p)\n", This);
2822 return E_NOTIMPL;
2825 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
2827 HTMLElement *This = impl_from_IHTMLElement2(iface);
2828 FIXME("(%p)->(%p)\n", This, mergeThis);
2829 return E_NOTIMPL;
2832 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
2834 HTMLElement *This = impl_from_IHTMLElement2(iface);
2835 FIXME("(%p)->()\n", This);
2836 return E_NOTIMPL;
2839 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
2841 HTMLElement *This = impl_from_IHTMLElement2(iface);
2842 FIXME("(%p)->(%p)\n", This, p);
2843 return E_NOTIMPL;
2846 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
2847 IHTMLElement *insertedElement, IHTMLElement **inserted)
2849 HTMLElement *This = impl_from_IHTMLElement2(iface);
2850 HTMLDOMNode *ret_node;
2851 HTMLElement *elem;
2852 HRESULT hres;
2854 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
2856 elem = unsafe_impl_from_IHTMLElement(insertedElement);
2857 if(!elem)
2858 return E_INVALIDARG;
2860 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
2861 if(FAILED(hres))
2862 return hres;
2864 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
2865 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
2866 return hres;
2869 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
2870 BSTR where, IHTMLElement **applied)
2872 HTMLElement *This = impl_from_IHTMLElement2(iface);
2873 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
2874 return E_NOTIMPL;
2877 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
2879 HTMLElement *This = impl_from_IHTMLElement2(iface);
2880 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
2881 return E_NOTIMPL;
2884 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
2885 BSTR newText, BSTR *oldText)
2887 HTMLElement *This = impl_from_IHTMLElement2(iface);
2888 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
2889 return E_NOTIMPL;
2892 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
2894 HTMLElement *This = impl_from_IHTMLElement2(iface);
2895 FIXME("(%p)->(%p)\n", This, p);
2896 return E_NOTIMPL;
2899 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
2900 VARIANT *pvarFactory, LONG *pCookie)
2902 HTMLElement *This = impl_from_IHTMLElement2(iface);
2903 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
2904 return E_NOTIMPL;
2907 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
2908 VARIANT_BOOL *pfResult)
2910 HTMLElement *This = impl_from_IHTMLElement2(iface);
2911 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
2912 return E_NOTIMPL;
2915 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
2917 HTMLElement *This = impl_from_IHTMLElement2(iface);
2919 FIXME("(%p)->(%p): hack\n", This, p);
2921 /* We can't implement correct behavior on top of Gecko (although we could
2922 try a bit harder). Making runtimeStyle behave like regular style is
2923 enough for most use cases. */
2924 if(!This->runtime_style) {
2925 HRESULT hres;
2927 hres = HTMLStyle_Create(This, &This->runtime_style);
2928 if(FAILED(hres))
2929 return hres;
2932 *p = &This->runtime_style->IHTMLStyle_iface;
2933 IHTMLStyle_AddRef(*p);
2934 return S_OK;
2937 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
2939 HTMLElement *This = impl_from_IHTMLElement2(iface);
2940 FIXME("(%p)->(%p)\n", This, p);
2941 return E_NOTIMPL;
2944 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
2946 HTMLElement *This = impl_from_IHTMLElement2(iface);
2947 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2948 return E_NOTIMPL;
2951 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
2953 HTMLElement *This = impl_from_IHTMLElement2(iface);
2954 FIXME("(%p)->(%p)\n", This, p);
2955 return E_NOTIMPL;
2958 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
2960 HTMLElement *This = impl_from_IHTMLElement2(iface);
2961 FIXME("(%p)->()\n", This);
2962 return E_NOTIMPL;
2965 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
2967 HTMLElement *This = impl_from_IHTMLElement2(iface);
2968 FIXME("(%p)->(%p)\n", This, p);
2969 return E_NOTIMPL;
2972 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
2974 HTMLElement *This = impl_from_IHTMLElement2(iface);
2975 FIXME("(%p)->(%p)\n", This, p);
2976 return E_NOTIMPL;
2979 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
2980 IHTMLElementCollection **pelColl)
2982 HTMLElement *This = impl_from_IHTMLElement2(iface);
2983 nsIDOMHTMLCollection *nscol;
2984 nsAString tag_str;
2985 nsresult nsres;
2987 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2989 nsAString_InitDepend(&tag_str, v);
2990 nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nscol);
2991 nsAString_Finish(&tag_str);
2992 if(NS_FAILED(nsres)) {
2993 ERR("GetElementByTagName failed: %08x\n", nsres);
2994 return E_FAIL;
2997 *pelColl = create_collection_from_htmlcol(This->node.doc, nscol);
2998 nsIDOMHTMLCollection_Release(nscol);
2999 return S_OK;
3002 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3003 HTMLElement2_QueryInterface,
3004 HTMLElement2_AddRef,
3005 HTMLElement2_Release,
3006 HTMLElement2_GetTypeInfoCount,
3007 HTMLElement2_GetTypeInfo,
3008 HTMLElement2_GetIDsOfNames,
3009 HTMLElement2_Invoke,
3010 HTMLElement2_get_scopeName,
3011 HTMLElement2_setCapture,
3012 HTMLElement2_releaseCapture,
3013 HTMLElement2_put_onlosecapture,
3014 HTMLElement2_get_onlosecapture,
3015 HTMLElement2_componentFromPoint,
3016 HTMLElement2_doScroll,
3017 HTMLElement2_put_onscroll,
3018 HTMLElement2_get_onscroll,
3019 HTMLElement2_put_ondrag,
3020 HTMLElement2_get_ondrag,
3021 HTMLElement2_put_ondragend,
3022 HTMLElement2_get_ondragend,
3023 HTMLElement2_put_ondragenter,
3024 HTMLElement2_get_ondragenter,
3025 HTMLElement2_put_ondragover,
3026 HTMLElement2_get_ondragover,
3027 HTMLElement2_put_ondragleave,
3028 HTMLElement2_get_ondragleave,
3029 HTMLElement2_put_ondrop,
3030 HTMLElement2_get_ondrop,
3031 HTMLElement2_put_onbeforecut,
3032 HTMLElement2_get_onbeforecut,
3033 HTMLElement2_put_oncut,
3034 HTMLElement2_get_oncut,
3035 HTMLElement2_put_onbeforecopy,
3036 HTMLElement2_get_onbeforecopy,
3037 HTMLElement2_put_oncopy,
3038 HTMLElement2_get_oncopy,
3039 HTMLElement2_put_onbeforepaste,
3040 HTMLElement2_get_onbeforepaste,
3041 HTMLElement2_put_onpaste,
3042 HTMLElement2_get_onpaste,
3043 HTMLElement2_get_currentStyle,
3044 HTMLElement2_put_onpropertychange,
3045 HTMLElement2_get_onpropertychange,
3046 HTMLElement2_getClientRects,
3047 HTMLElement2_getBoundingClientRect,
3048 HTMLElement2_setExpression,
3049 HTMLElement2_getExpression,
3050 HTMLElement2_removeExpression,
3051 HTMLElement2_put_tabIndex,
3052 HTMLElement2_get_tabIndex,
3053 HTMLElement2_focus,
3054 HTMLElement2_put_accessKey,
3055 HTMLElement2_get_accessKey,
3056 HTMLElement2_put_onblur,
3057 HTMLElement2_get_onblur,
3058 HTMLElement2_put_onfocus,
3059 HTMLElement2_get_onfocus,
3060 HTMLElement2_put_onresize,
3061 HTMLElement2_get_onresize,
3062 HTMLElement2_blur,
3063 HTMLElement2_addFilter,
3064 HTMLElement2_removeFilter,
3065 HTMLElement2_get_clientHeight,
3066 HTMLElement2_get_clientWidth,
3067 HTMLElement2_get_clientTop,
3068 HTMLElement2_get_clientLeft,
3069 HTMLElement2_attachEvent,
3070 HTMLElement2_detachEvent,
3071 HTMLElement2_get_readyState,
3072 HTMLElement2_put_onreadystatechange,
3073 HTMLElement2_get_onreadystatechange,
3074 HTMLElement2_put_onrowsdelete,
3075 HTMLElement2_get_onrowsdelete,
3076 HTMLElement2_put_onrowsinserted,
3077 HTMLElement2_get_onrowsinserted,
3078 HTMLElement2_put_oncellchange,
3079 HTMLElement2_get_oncellchange,
3080 HTMLElement2_put_dir,
3081 HTMLElement2_get_dir,
3082 HTMLElement2_createControlRange,
3083 HTMLElement2_get_scrollHeight,
3084 HTMLElement2_get_scrollWidth,
3085 HTMLElement2_put_scrollTop,
3086 HTMLElement2_get_scrollTop,
3087 HTMLElement2_put_scrollLeft,
3088 HTMLElement2_get_scrollLeft,
3089 HTMLElement2_clearAttributes,
3090 HTMLElement2_mergeAttributes,
3091 HTMLElement2_put_oncontextmenu,
3092 HTMLElement2_get_oncontextmenu,
3093 HTMLElement2_insertAdjacentElement,
3094 HTMLElement2_applyElement,
3095 HTMLElement2_getAdjacentText,
3096 HTMLElement2_replaceAdjacentText,
3097 HTMLElement2_get_canHandleChildren,
3098 HTMLElement2_addBehavior,
3099 HTMLElement2_removeBehavior,
3100 HTMLElement2_get_runtimeStyle,
3101 HTMLElement2_get_behaviorUrns,
3102 HTMLElement2_put_tagUrn,
3103 HTMLElement2_get_tagUrn,
3104 HTMLElement2_put_onbeforeeditfocus,
3105 HTMLElement2_get_onbeforeeditfocus,
3106 HTMLElement2_get_readyStateValue,
3107 HTMLElement2_getElementsByTagName,
3110 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3112 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3115 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3116 REFIID riid, void **ppv)
3118 HTMLElement *This = impl_from_IHTMLElement3(iface);
3119 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3122 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3124 HTMLElement *This = impl_from_IHTMLElement3(iface);
3125 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3128 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3130 HTMLElement *This = impl_from_IHTMLElement3(iface);
3131 return IHTMLElement_Release(&This->IHTMLElement_iface);
3134 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3136 HTMLElement *This = impl_from_IHTMLElement3(iface);
3137 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3140 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3141 LCID lcid, ITypeInfo **ppTInfo)
3143 HTMLElement *This = impl_from_IHTMLElement3(iface);
3144 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3147 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3148 LPOLESTR *rgszNames, UINT cNames,
3149 LCID lcid, DISPID *rgDispId)
3151 HTMLElement *This = impl_from_IHTMLElement3(iface);
3152 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3153 lcid, rgDispId);
3156 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3157 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3158 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3160 HTMLElement *This = impl_from_IHTMLElement3(iface);
3161 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3162 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3165 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3167 HTMLElement *This = impl_from_IHTMLElement3(iface);
3168 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3169 return E_NOTIMPL;
3172 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3174 HTMLElement *This = impl_from_IHTMLElement3(iface);
3175 FIXME("(%p)->(%p)\n", This, p);
3176 return E_NOTIMPL;
3179 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3181 HTMLElement *This = impl_from_IHTMLElement3(iface);
3182 FIXME("(%p)->(%p)\n", This, p);
3183 return E_NOTIMPL;
3186 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3188 HTMLElement *This = impl_from_IHTMLElement3(iface);
3189 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3190 return E_NOTIMPL;
3193 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3195 HTMLElement *This = impl_from_IHTMLElement3(iface);
3196 FIXME("(%p)->(%p)\n", This, p);
3197 return E_NOTIMPL;
3200 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3202 HTMLElement *This = impl_from_IHTMLElement3(iface);
3203 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3204 return E_NOTIMPL;
3207 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3209 HTMLElement *This = impl_from_IHTMLElement3(iface);
3210 FIXME("(%p)->(%p)\n", This, p);
3211 return E_NOTIMPL;
3214 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3216 HTMLElement *This = impl_from_IHTMLElement3(iface);
3217 FIXME("(%p)->(%x)\n", This, v);
3218 return E_NOTIMPL;
3221 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3223 HTMLElement *This = impl_from_IHTMLElement3(iface);
3224 FIXME("(%p)->(%p)\n", This, p);
3225 return E_NOTIMPL;
3228 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3230 HTMLElement *This = impl_from_IHTMLElement3(iface);
3231 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3232 return E_NOTIMPL;
3235 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3237 HTMLElement *This = impl_from_IHTMLElement3(iface);
3238 FIXME("(%p)->(%p)\n", This, p);
3239 return E_NOTIMPL;
3242 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3244 HTMLElement *This = impl_from_IHTMLElement3(iface);
3245 FIXME("(%p)\n", This);
3246 return E_NOTIMPL;
3249 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3251 HTMLElement *This = impl_from_IHTMLElement3(iface);
3252 nsresult nsres;
3253 nsAString str;
3255 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3257 nsAString_InitDepend(&str, v);
3258 nsres = nsIDOMHTMLElement_SetContentEditable(This->nselem, &str);
3259 nsAString_Finish(&str);
3261 if (NS_FAILED(nsres)){
3262 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3263 return E_FAIL;
3266 return S_OK;
3269 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3271 HTMLElement *This = impl_from_IHTMLElement3(iface);
3272 nsresult nsres;
3273 nsAString str;
3275 TRACE("(%p)->(%p)\n", This, p);
3277 nsAString_Init(&str, NULL);
3278 nsres = nsIDOMHTMLElement_GetContentEditable(This->nselem, &str);
3279 return return_nsstr(nsres, &str, p);
3282 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3284 HTMLElement *This = impl_from_IHTMLElement3(iface);
3285 FIXME("(%p)->(%p)\n", This, p);
3286 return E_NOTIMPL;
3289 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3291 HTMLElement *This = impl_from_IHTMLElement3(iface);
3292 FIXME("(%p)->(%x)\n", This, v);
3293 return E_NOTIMPL;
3296 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3298 HTMLElement *This = impl_from_IHTMLElement3(iface);
3299 FIXME("(%p)->(%p)\n", This, p);
3300 return E_NOTIMPL;
3303 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3305 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3307 HTMLElement *This = impl_from_IHTMLElement3(iface);
3308 VARIANT *var;
3309 HRESULT hres;
3311 TRACE("(%p)->(%x)\n", This, v);
3313 if(This->node.vtbl->put_disabled)
3314 return This->node.vtbl->put_disabled(&This->node, v);
3316 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3317 if(FAILED(hres))
3318 return hres;
3320 VariantClear(var);
3321 V_VT(var) = VT_BOOL;
3322 V_BOOL(var) = v;
3323 return S_OK;
3326 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3328 HTMLElement *This = impl_from_IHTMLElement3(iface);
3329 VARIANT *var;
3330 HRESULT hres;
3332 TRACE("(%p)->(%p)\n", This, p);
3334 if(This->node.vtbl->get_disabled)
3335 return This->node.vtbl->get_disabled(&This->node, p);
3337 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3338 if(hres == DISP_E_UNKNOWNNAME) {
3339 *p = VARIANT_FALSE;
3340 return S_OK;
3342 if(FAILED(hres))
3343 return hres;
3345 if(V_VT(var) != VT_BOOL) {
3346 FIXME("value is %s\n", debugstr_variant(var));
3347 return E_NOTIMPL;
3350 *p = V_BOOL(var);
3351 return S_OK;
3354 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3356 HTMLElement *This = impl_from_IHTMLElement3(iface);
3357 FIXME("(%p)->(%p)\n", This, p);
3358 return E_NOTIMPL;
3361 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3363 HTMLElement *This = impl_from_IHTMLElement3(iface);
3364 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3365 return E_NOTIMPL;
3368 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3370 HTMLElement *This = impl_from_IHTMLElement3(iface);
3371 FIXME("(%p)->(%p)\n", This, p);
3372 return E_NOTIMPL;
3375 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3377 HTMLElement *This = impl_from_IHTMLElement3(iface);
3378 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3379 return E_NOTIMPL;
3382 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3384 HTMLElement *This = impl_from_IHTMLElement3(iface);
3385 FIXME("(%p)->(%p)\n", This, p);
3386 return E_NOTIMPL;
3389 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3390 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3392 HTMLElement *This = impl_from_IHTMLElement3(iface);
3394 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3395 pfCancelled);
3397 return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3400 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
3402 HTMLElement *This = impl_from_IHTMLElement3(iface);
3403 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3404 return E_NOTIMPL;
3407 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
3409 HTMLElement *This = impl_from_IHTMLElement3(iface);
3410 FIXME("(%p)->(%p)\n", This, p);
3411 return E_NOTIMPL;
3414 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3416 HTMLElement *This = impl_from_IHTMLElement3(iface);
3417 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3418 return E_NOTIMPL;
3421 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3423 HTMLElement *This = impl_from_IHTMLElement3(iface);
3424 FIXME("(%p)->(%p)\n", This, p);
3425 return E_NOTIMPL;
3428 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3430 HTMLElement *This = impl_from_IHTMLElement3(iface);
3431 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3432 return E_NOTIMPL;
3435 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3437 HTMLElement *This = impl_from_IHTMLElement3(iface);
3438 FIXME("(%p)->(%p)\n", This, p);
3439 return E_NOTIMPL;
3442 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3444 HTMLElement *This = impl_from_IHTMLElement3(iface);
3445 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3446 return E_NOTIMPL;
3449 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3451 HTMLElement *This = impl_from_IHTMLElement3(iface);
3452 FIXME("(%p)->(%p)\n", This, p);
3453 return E_NOTIMPL;
3456 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3458 HTMLElement *This = impl_from_IHTMLElement3(iface);
3459 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3460 return E_NOTIMPL;
3463 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3465 HTMLElement *This = impl_from_IHTMLElement3(iface);
3466 FIXME("(%p)->(%p)\n", This, p);
3467 return E_NOTIMPL;
3470 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3472 HTMLElement *This = impl_from_IHTMLElement3(iface);
3473 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3474 return E_NOTIMPL;
3477 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3479 HTMLElement *This = impl_from_IHTMLElement3(iface);
3480 FIXME("(%p)->(%p)\n", This, p);
3481 return E_NOTIMPL;
3484 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3486 HTMLElement *This = impl_from_IHTMLElement3(iface);
3487 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3488 return E_NOTIMPL;
3491 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3493 HTMLElement *This = impl_from_IHTMLElement3(iface);
3494 FIXME("(%p)->(%p)\n", This, p);
3495 return E_NOTIMPL;
3498 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3500 HTMLElement *This = impl_from_IHTMLElement3(iface);
3501 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3502 return E_NOTIMPL;
3505 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3507 HTMLElement *This = impl_from_IHTMLElement3(iface);
3508 FIXME("(%p)->(%p)\n", This, p);
3509 return E_NOTIMPL;
3512 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3514 HTMLElement *This = impl_from_IHTMLElement3(iface);
3515 FIXME("(%p)->(%p)\n", This, pfRet);
3516 return E_NOTIMPL;
3519 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3521 HTMLElement *This = impl_from_IHTMLElement3(iface);
3522 FIXME("(%p)->(%p)\n", This, p);
3523 return E_NOTIMPL;
3526 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3527 HTMLElement3_QueryInterface,
3528 HTMLElement3_AddRef,
3529 HTMLElement3_Release,
3530 HTMLElement3_GetTypeInfoCount,
3531 HTMLElement3_GetTypeInfo,
3532 HTMLElement3_GetIDsOfNames,
3533 HTMLElement3_Invoke,
3534 HTMLElement3_mergeAttributes,
3535 HTMLElement3_get_isMultiLine,
3536 HTMLElement3_get_canHaveHTML,
3537 HTMLElement3_put_onlayoutcomplete,
3538 HTMLElement3_get_onlayoutcomplete,
3539 HTMLElement3_put_onpage,
3540 HTMLElement3_get_onpage,
3541 HTMLElement3_put_inflateBlock,
3542 HTMLElement3_get_inflateBlock,
3543 HTMLElement3_put_onbeforedeactivate,
3544 HTMLElement3_get_onbeforedeactivate,
3545 HTMLElement3_setActive,
3546 HTMLElement3_put_contentEditable,
3547 HTMLElement3_get_contentEditable,
3548 HTMLElement3_get_isContentEditable,
3549 HTMLElement3_put_hideFocus,
3550 HTMLElement3_get_hideFocus,
3551 HTMLElement3_put_disabled,
3552 HTMLElement3_get_disabled,
3553 HTMLElement3_get_isDisabled,
3554 HTMLElement3_put_onmove,
3555 HTMLElement3_get_onmove,
3556 HTMLElement3_put_oncontrolselect,
3557 HTMLElement3_get_oncontrolselect,
3558 HTMLElement3_fireEvent,
3559 HTMLElement3_put_onresizestart,
3560 HTMLElement3_get_onresizestart,
3561 HTMLElement3_put_onresizeend,
3562 HTMLElement3_get_onresizeend,
3563 HTMLElement3_put_onmovestart,
3564 HTMLElement3_get_onmovestart,
3565 HTMLElement3_put_onmoveend,
3566 HTMLElement3_get_onmoveend,
3567 HTMLElement3_put_onmousecenter,
3568 HTMLElement3_get_onmousecenter,
3569 HTMLElement3_put_onmouseleave,
3570 HTMLElement3_get_onmouseleave,
3571 HTMLElement3_put_onactivate,
3572 HTMLElement3_get_onactivate,
3573 HTMLElement3_put_ondeactivate,
3574 HTMLElement3_get_ondeactivate,
3575 HTMLElement3_dragDrop,
3576 HTMLElement3_get_glyphMode
3579 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3581 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3584 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3585 REFIID riid, void **ppv)
3587 HTMLElement *This = impl_from_IHTMLElement4(iface);
3588 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3591 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3593 HTMLElement *This = impl_from_IHTMLElement4(iface);
3594 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3597 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3599 HTMLElement *This = impl_from_IHTMLElement4(iface);
3600 return IHTMLElement_Release(&This->IHTMLElement_iface);
3603 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3605 HTMLElement *This = impl_from_IHTMLElement4(iface);
3606 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3609 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3610 LCID lcid, ITypeInfo **ppTInfo)
3612 HTMLElement *This = impl_from_IHTMLElement4(iface);
3613 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3616 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3617 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3619 HTMLElement *This = impl_from_IHTMLElement4(iface);
3620 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3621 lcid, rgDispId);
3624 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3625 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3627 HTMLElement *This = impl_from_IHTMLElement4(iface);
3628 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3629 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3632 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3634 HTMLElement *This = impl_from_IHTMLElement4(iface);
3636 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3638 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3641 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3643 HTMLElement *This = impl_from_IHTMLElement4(iface);
3645 TRACE("(%p)->(%p)\n", This, p);
3647 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3650 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3652 HTMLElement *This = impl_from_IHTMLElement4(iface);
3653 FIXME("(%p)\n", This);
3654 return E_NOTIMPL;
3657 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3659 HTMLElement *This = impl_from_IHTMLElement4(iface);
3660 HTMLAttributeCollection *attrs;
3661 HRESULT hres;
3663 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3665 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3666 if(FAILED(hres))
3667 return hres;
3669 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3670 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3671 return hres;
3674 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3675 IHTMLDOMAttribute **ppretAttribute)
3677 HTMLElement *This = impl_from_IHTMLElement4(iface);
3678 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3679 return E_NOTIMPL;
3682 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3683 IHTMLDOMAttribute **ppretAttribute)
3685 HTMLElement *This = impl_from_IHTMLElement4(iface);
3686 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3687 return E_NOTIMPL;
3690 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3692 HTMLElement *This = impl_from_IHTMLElement4(iface);
3693 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3694 return E_NOTIMPL;
3697 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3699 HTMLElement *This = impl_from_IHTMLElement4(iface);
3700 FIXME("(%p)->(%p)\n", This, p);
3701 return E_NOTIMPL;
3704 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3706 HTMLElement *This = impl_from_IHTMLElement4(iface);
3708 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3710 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3713 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3715 HTMLElement *This = impl_from_IHTMLElement4(iface);
3717 TRACE("(%p)->(%p)\n", This, p);
3719 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3722 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3724 HTMLElement *This = impl_from_IHTMLElement4(iface);
3725 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3726 return E_NOTIMPL;
3729 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3731 HTMLElement *This = impl_from_IHTMLElement4(iface);
3732 FIXME("(%p)->(%p)\n", This, p);
3733 return E_NOTIMPL;
3736 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3737 HTMLElement4_QueryInterface,
3738 HTMLElement4_AddRef,
3739 HTMLElement4_Release,
3740 HTMLElement4_GetTypeInfoCount,
3741 HTMLElement4_GetTypeInfo,
3742 HTMLElement4_GetIDsOfNames,
3743 HTMLElement4_Invoke,
3744 HTMLElement4_put_onmousewheel,
3745 HTMLElement4_get_onmousewheel,
3746 HTMLElement4_normalize,
3747 HTMLElement4_getAttributeNode,
3748 HTMLElement4_setAttributeNode,
3749 HTMLElement4_removeAttributeNode,
3750 HTMLElement4_put_onbeforeactivate,
3751 HTMLElement4_get_onbeforeactivate,
3752 HTMLElement4_put_onfocusin,
3753 HTMLElement4_get_onfocusin,
3754 HTMLElement4_put_onfocusout,
3755 HTMLElement4_get_onfocusout
3758 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
3760 return CONTAINING_RECORD(iface, HTMLElement, node);
3763 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
3765 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3767 if(IsEqualGUID(&IID_IUnknown, riid)) {
3768 *ppv = &This->IHTMLElement_iface;
3769 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
3770 *ppv = &This->IHTMLElement_iface;
3771 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
3772 *ppv = &This->IHTMLElement_iface;
3773 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
3774 *ppv = &This->IHTMLElement2_iface;
3775 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
3776 *ppv = &This->IHTMLElement3_iface;
3777 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
3778 *ppv = &This->IHTMLElement4_iface;
3779 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
3780 *ppv = &This->cp_container.IConnectionPointContainer_iface;
3781 }else {
3782 return HTMLDOMNode_QI(&This->node, riid, ppv);
3785 IUnknown_AddRef((IUnknown*)*ppv);
3786 return S_OK;
3789 void HTMLElement_destructor(HTMLDOMNode *iface)
3791 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3793 ConnectionPointContainer_Destroy(&This->cp_container);
3795 if(This->style) {
3796 This->style->elem = NULL;
3797 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
3799 if(This->runtime_style) {
3800 This->runtime_style->elem = NULL;
3801 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
3803 if(This->attrs) {
3804 HTMLDOMAttribute *attr;
3806 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
3807 attr->elem = NULL;
3809 This->attrs->elem = NULL;
3810 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
3813 heap_free(This->filter);
3815 HTMLDOMNode_destructor(&This->node);
3818 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
3820 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3821 HTMLElement *new_elem;
3822 HRESULT hres;
3824 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
3825 if(FAILED(hres))
3826 return hres;
3828 if(This->filter) {
3829 new_elem->filter = heap_strdupW(This->filter);
3830 if(!new_elem->filter) {
3831 IHTMLElement_Release(&This->IHTMLElement_iface);
3832 return E_OUTOFMEMORY;
3836 *ret = &new_elem->node;
3837 return S_OK;
3840 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
3842 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3844 switch(eid) {
3845 case EVENTID_KEYDOWN: {
3846 nsIDOMKeyEvent *key_event;
3847 nsresult nsres;
3849 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
3850 if(NS_SUCCEEDED(nsres)) {
3851 UINT32 code = 0;
3853 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
3855 switch(code) {
3856 case VK_F1: /* DOM_VK_F1 */
3857 TRACE("F1 pressed\n");
3858 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
3859 *prevent_default = TRUE;
3862 nsIDOMKeyEvent_Release(key_event);
3867 return S_OK;
3870 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
3872 const cpc_entry_t HTMLElement_cpc[] = {
3873 HTMLELEMENT_CPC,
3874 {NULL}
3877 static const NodeImplVtbl HTMLElementImplVtbl = {
3878 HTMLElement_QI,
3879 HTMLElement_destructor,
3880 HTMLElement_cpc,
3881 HTMLElement_clone,
3882 HTMLElement_handle_event,
3883 HTMLElement_get_attr_col
3886 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
3888 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
3891 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
3892 DWORD grfdex, DISPID *pid)
3894 HTMLElement *This = impl_from_DispatchEx(dispex);
3896 if(This->node.vtbl->get_dispid)
3897 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
3899 return DISP_E_UNKNOWNNAME;
3902 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
3903 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
3904 IServiceProvider *caller)
3906 HTMLElement *This = impl_from_DispatchEx(dispex);
3908 if(This->node.vtbl->invoke)
3909 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
3910 params, res, ei, caller);
3912 ERR("(%p): element has no invoke method\n", This);
3913 return E_NOTIMPL;
3916 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
3918 HTMLElement *This = impl_from_DispatchEx(dispex);
3919 nsIDOMMozNamedAttrMap *attrs;
3920 nsIDOMAttr *attr;
3921 nsAString nsstr;
3922 const PRUnichar *str;
3923 BSTR name;
3924 VARIANT value;
3925 unsigned i;
3926 UINT32 len;
3927 DISPID id;
3928 nsresult nsres;
3929 HRESULT hres;
3931 if(!This->nselem)
3932 return S_FALSE;
3934 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
3935 if(NS_FAILED(nsres))
3936 return E_FAIL;
3938 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
3939 if(NS_FAILED(nsres)) {
3940 nsIDOMMozNamedAttrMap_Release(attrs);
3941 return E_FAIL;
3944 nsAString_Init(&nsstr, NULL);
3945 for(i=0; i<len; i++) {
3946 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
3947 if(NS_FAILED(nsres))
3948 continue;
3950 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
3951 if(NS_FAILED(nsres)) {
3952 nsIDOMAttr_Release(attr);
3953 continue;
3956 nsAString_GetData(&nsstr, &str);
3957 name = SysAllocString(str);
3958 if(!name) {
3959 nsIDOMAttr_Release(attr);
3960 continue;
3963 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
3964 if(hres != DISP_E_UNKNOWNNAME) {
3965 nsIDOMAttr_Release(attr);
3966 SysFreeString(name);
3967 continue;
3970 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
3971 nsIDOMAttr_Release(attr);
3972 if(NS_FAILED(nsres)) {
3973 SysFreeString(name);
3974 continue;
3977 nsAString_GetData(&nsstr, &str);
3978 V_VT(&value) = VT_BSTR;
3979 if(*str) {
3980 V_BSTR(&value) = SysAllocString(str);
3981 if(!V_BSTR(&value)) {
3982 SysFreeString(name);
3983 continue;
3985 } else
3986 V_BSTR(&value) = NULL;
3988 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
3989 SysFreeString(name);
3990 VariantClear(&value);
3992 nsAString_Finish(&nsstr);
3994 nsIDOMMozNamedAttrMap_Release(attrs);
3995 return S_OK;
3998 static event_target_t **HTMLElement_get_event_target_ptr(DispatchEx *dispex)
4000 HTMLElement *This = impl_from_DispatchEx(dispex);
4001 return This->node.vtbl->get_event_target_ptr
4002 ? This->node.vtbl->get_event_target_ptr(&This->node)
4003 : &This->node.event_target.ptr;
4006 static void HTMLElement_bind_event(DispatchEx *dispex, int eid)
4008 HTMLElement *This = impl_from_DispatchEx(dispex);
4009 This->node.doc->node.event_target.dispex.data->vtbl->bind_event(&This->node.doc->node.event_target.dispex, eid);
4012 static const tid_t HTMLElement_iface_tids[] = {
4013 HTMLELEMENT_TIDS,
4017 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
4018 NULL,
4019 HTMLElement_get_dispid,
4020 HTMLElement_invoke,
4021 HTMLElement_populate_props,
4022 HTMLElement_get_event_target_ptr,
4023 HTMLElement_bind_event
4026 static dispex_static_data_t HTMLElement_dispex = {
4027 &HTMLElement_dispex_vtbl,
4028 DispHTMLUnknownElement_tid,
4029 NULL,
4030 HTMLElement_iface_tids
4033 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
4035 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
4036 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
4037 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
4038 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
4040 if(dispex_data && !dispex_data->vtbl)
4041 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
4042 init_dispex(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
4043 dispex_data ? dispex_data : &HTMLElement_dispex);
4045 if(nselem) {
4046 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
4048 /* No AddRef, share reference with HTMLDOMNode */
4049 assert((nsIDOMNode*)nselem == This->node.nsnode);
4050 This->nselem = nselem;
4053 This->node.cp_container = &This->cp_container;
4054 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
4057 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
4059 nsIDOMHTMLElement *nselem;
4060 nsAString class_name_str;
4061 const PRUnichar *class_name;
4062 const tag_desc_t *tag;
4063 HTMLElement *elem;
4064 nsresult nsres;
4065 HRESULT hres;
4067 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
4068 if(NS_FAILED(nsres))
4069 return E_FAIL;
4071 nsAString_Init(&class_name_str, NULL);
4072 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
4074 nsAString_GetData(&class_name_str, &class_name);
4076 tag = get_tag_desc(class_name);
4077 if(tag) {
4078 hres = tag->constructor(doc, nselem, &elem);
4079 }else if(use_generic) {
4080 hres = HTMLGenericElement_Create(doc, nselem, &elem);
4081 }else {
4082 elem = heap_alloc_zero(sizeof(HTMLElement));
4083 if(elem) {
4084 elem->node.vtbl = &HTMLElementImplVtbl;
4085 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
4086 hres = S_OK;
4087 }else {
4088 hres = E_OUTOFMEMORY;
4092 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
4094 nsIDOMHTMLElement_Release(nselem);
4095 nsAString_Finish(&class_name_str);
4096 if(FAILED(hres))
4097 return hres;
4099 *ret = elem;
4100 return S_OK;
4103 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
4105 HTMLDOMNode *node;
4106 HRESULT hres;
4108 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
4109 if(FAILED(hres))
4110 return hres;
4112 *ret = impl_from_HTMLDOMNode(node);
4113 return S_OK;
4116 /* interface IHTMLFiltersCollection */
4117 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
4119 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4121 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
4123 if(IsEqualGUID(&IID_IUnknown, riid)) {
4124 *ppv = &This->IHTMLFiltersCollection_iface;
4125 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
4126 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
4127 *ppv = &This->IHTMLFiltersCollection_iface;
4128 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4129 return *ppv ? S_OK : E_NOINTERFACE;
4130 }else {
4131 *ppv = NULL;
4132 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4133 return E_NOINTERFACE;
4136 IUnknown_AddRef((IUnknown*)*ppv);
4137 return S_OK;
4140 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
4142 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4143 LONG ref = InterlockedIncrement(&This->ref);
4145 TRACE("(%p) ref=%d\n", This, ref);
4147 return ref;
4150 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
4152 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4153 LONG ref = InterlockedDecrement(&This->ref);
4155 TRACE("(%p) ref=%d\n", This, ref);
4157 if(!ref)
4159 heap_free(This);
4162 return ref;
4165 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
4167 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4168 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4171 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
4172 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
4174 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4175 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4178 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
4179 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
4180 LCID lcid, DISPID *rgDispId)
4182 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4183 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4184 lcid, rgDispId);
4187 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
4188 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
4189 EXCEPINFO *pExcepInfo, UINT *puArgErr)
4191 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4192 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4193 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4196 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
4198 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4200 if(!p)
4201 return E_POINTER;
4203 FIXME("(%p)->(%p) Always returning 0\n", This, p);
4204 *p = 0;
4206 return S_OK;
4209 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
4211 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4212 FIXME("(%p)->(%p)\n", This, p);
4213 return E_NOTIMPL;
4216 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
4218 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4219 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
4220 return E_NOTIMPL;
4223 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
4224 HTMLFiltersCollection_QueryInterface,
4225 HTMLFiltersCollection_AddRef,
4226 HTMLFiltersCollection_Release,
4227 HTMLFiltersCollection_GetTypeInfoCount,
4228 HTMLFiltersCollection_GetTypeInfo,
4229 HTMLFiltersCollection_GetIDsOfNames,
4230 HTMLFiltersCollection_Invoke,
4231 HTMLFiltersCollection_get_length,
4232 HTMLFiltersCollection_get__newEnum,
4233 HTMLFiltersCollection_item
4236 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4238 WCHAR *ptr;
4239 int idx = 0;
4241 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
4242 idx = idx*10 + (*ptr-'0');
4243 if(*ptr)
4244 return DISP_E_UNKNOWNNAME;
4246 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
4247 TRACE("ret %x\n", *dispid);
4248 return S_OK;
4251 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4252 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4254 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
4256 V_VT(res) = VT_DISPATCH;
4257 V_DISPATCH(res) = NULL;
4259 FIXME("always returning NULL\n");
4261 return S_OK;
4264 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
4265 NULL,
4266 HTMLFiltersCollection_get_dispid,
4267 HTMLFiltersCollection_invoke,
4268 NULL
4271 static const tid_t HTMLFiltersCollection_iface_tids[] = {
4272 IHTMLFiltersCollection_tid,
4275 static dispex_static_data_t HTMLFiltersCollection_dispex = {
4276 &HTMLFiltersCollection_dispex_vtbl,
4277 IHTMLFiltersCollection_tid,
4278 NULL,
4279 HTMLFiltersCollection_iface_tids
4282 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
4284 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
4286 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
4287 ret->ref = 1;
4289 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
4290 &HTMLFiltersCollection_dispex);
4292 return &ret->IHTMLFiltersCollection_iface;
4295 /* interface IHTMLAttributeCollection */
4296 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
4298 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
4301 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
4303 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4305 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4307 if(IsEqualGUID(&IID_IUnknown, riid)) {
4308 *ppv = &This->IHTMLAttributeCollection_iface;
4309 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
4310 *ppv = &This->IHTMLAttributeCollection_iface;
4311 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
4312 *ppv = &This->IHTMLAttributeCollection2_iface;
4313 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
4314 *ppv = &This->IHTMLAttributeCollection3_iface;
4315 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4316 return *ppv ? S_OK : E_NOINTERFACE;
4317 }else {
4318 *ppv = NULL;
4319 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4320 return E_NOINTERFACE;
4323 IUnknown_AddRef((IUnknown*)*ppv);
4324 return S_OK;
4327 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
4329 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4330 LONG ref = InterlockedIncrement(&This->ref);
4332 TRACE("(%p) ref=%d\n", This, ref);
4334 return ref;
4337 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
4339 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4340 LONG ref = InterlockedDecrement(&This->ref);
4342 TRACE("(%p) ref=%d\n", This, ref);
4344 if(!ref) {
4345 while(!list_empty(&This->attrs)) {
4346 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
4348 list_remove(&attr->entry);
4349 attr->elem = NULL;
4350 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4353 heap_free(This);
4356 return ref;
4359 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
4361 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4362 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4365 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
4366 LCID lcid, ITypeInfo **ppTInfo)
4368 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4369 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4372 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
4373 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4375 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4376 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4377 lcid, rgDispId);
4380 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
4381 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4382 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4384 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4385 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4386 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4389 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
4391 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
4392 DISPID id = DISPID_STARTENUM;
4393 LONG len = -1;
4394 HRESULT hres;
4396 FIXME("filter non-enumerable attributes out\n");
4398 while(1) {
4399 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
4400 if(FAILED(hres))
4401 return hres;
4402 else if(hres == S_FALSE)
4403 break;
4405 len++;
4406 if(len == *idx)
4407 break;
4410 if(dispid) {
4411 *dispid = id;
4412 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
4415 *idx = len+1;
4416 return S_OK;
4419 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
4421 HRESULT hres;
4423 if(name[0]>='0' && name[0]<='9') {
4424 WCHAR *end_ptr;
4425 LONG idx;
4427 idx = strtoulW(name, &end_ptr, 10);
4428 if(!*end_ptr) {
4429 hres = get_attr_dispid_by_idx(This, &idx, id);
4430 if(SUCCEEDED(hres))
4431 return hres;
4435 if(!This->elem) {
4436 WARN("NULL elem\n");
4437 return E_UNEXPECTED;
4440 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
4441 name, fdexNameCaseInsensitive, id);
4442 return hres;
4445 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
4447 HTMLDOMAttribute *iter;
4448 LONG pos = 0;
4449 HRESULT hres;
4451 *attr = NULL;
4452 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4453 if(iter->dispid == id) {
4454 *attr = iter;
4455 break;
4457 pos++;
4460 if(!*attr) {
4461 if(!This->elem) {
4462 WARN("NULL elem\n");
4463 return E_UNEXPECTED;
4466 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
4467 if(FAILED(hres))
4468 return hres;
4471 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
4472 if(list_pos)
4473 *list_pos = pos;
4474 return S_OK;
4477 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
4479 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4480 HRESULT hres;
4482 TRACE("(%p)->(%p)\n", This, p);
4484 *p = -1;
4485 hres = get_attr_dispid_by_idx(This, p, NULL);
4486 return hres;
4489 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
4491 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4492 FIXME("(%p)->(%p)\n", This, p);
4493 return E_NOTIMPL;
4496 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
4498 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4499 HTMLDOMAttribute *attr;
4500 DISPID id;
4501 HRESULT hres;
4503 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
4505 switch(V_VT(name)) {
4506 case VT_I4:
4507 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
4508 break;
4509 case VT_BSTR:
4510 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
4511 break;
4512 default:
4513 FIXME("unsupported name %s\n", debugstr_variant(name));
4514 hres = E_NOTIMPL;
4516 if(hres == DISP_E_UNKNOWNNAME)
4517 return E_INVALIDARG;
4518 if(FAILED(hres))
4519 return hres;
4521 hres = get_domattr(This, id, NULL, &attr);
4522 if(FAILED(hres))
4523 return hres;
4525 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
4526 return S_OK;
4529 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
4530 HTMLAttributeCollection_QueryInterface,
4531 HTMLAttributeCollection_AddRef,
4532 HTMLAttributeCollection_Release,
4533 HTMLAttributeCollection_GetTypeInfoCount,
4534 HTMLAttributeCollection_GetTypeInfo,
4535 HTMLAttributeCollection_GetIDsOfNames,
4536 HTMLAttributeCollection_Invoke,
4537 HTMLAttributeCollection_get_length,
4538 HTMLAttributeCollection__newEnum,
4539 HTMLAttributeCollection_item
4542 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
4544 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
4547 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
4549 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4550 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4553 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
4555 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4556 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4559 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
4561 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4562 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4565 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
4567 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4568 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4571 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
4572 LCID lcid, ITypeInfo **ppTInfo)
4574 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4575 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4578 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
4579 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4581 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4582 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4583 lcid, rgDispId);
4586 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
4587 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4588 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4590 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4591 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4592 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4595 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
4596 IHTMLDOMAttribute **newretNode)
4598 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4599 HTMLDOMAttribute *attr;
4600 DISPID id;
4601 HRESULT hres;
4603 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4605 hres = get_attr_dispid_by_name(This, bstrName, &id);
4606 if(hres == DISP_E_UNKNOWNNAME) {
4607 *newretNode = NULL;
4608 return S_OK;
4609 } else if(FAILED(hres)) {
4610 return hres;
4613 hres = get_domattr(This, id, NULL, &attr);
4614 if(FAILED(hres))
4615 return hres;
4617 *newretNode = &attr->IHTMLDOMAttribute_iface;
4618 return S_OK;
4621 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
4622 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
4624 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4625 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
4626 return E_NOTIMPL;
4629 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
4630 BSTR bstrName, IHTMLDOMAttribute **newretNode)
4632 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4633 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4634 return E_NOTIMPL;
4637 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
4638 HTMLAttributeCollection2_QueryInterface,
4639 HTMLAttributeCollection2_AddRef,
4640 HTMLAttributeCollection2_Release,
4641 HTMLAttributeCollection2_GetTypeInfoCount,
4642 HTMLAttributeCollection2_GetTypeInfo,
4643 HTMLAttributeCollection2_GetIDsOfNames,
4644 HTMLAttributeCollection2_Invoke,
4645 HTMLAttributeCollection2_getNamedItem,
4646 HTMLAttributeCollection2_setNamedItem,
4647 HTMLAttributeCollection2_removeNamedItem
4650 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
4652 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
4655 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
4657 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4658 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4661 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
4663 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4664 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4667 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
4669 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4670 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4673 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
4675 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4676 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4679 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
4680 LCID lcid, ITypeInfo **ppTInfo)
4682 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4683 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4686 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
4687 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4689 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4690 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4691 lcid, rgDispId);
4694 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
4695 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4696 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4698 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4699 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4700 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4703 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
4704 IHTMLDOMAttribute **ppNodeOut)
4706 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4707 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
4710 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
4711 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
4713 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4714 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
4715 return E_NOTIMPL;
4718 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
4719 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
4721 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4722 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
4723 return E_NOTIMPL;
4726 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
4728 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4729 HTMLDOMAttribute *attr;
4730 DISPID id;
4731 HRESULT hres;
4733 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
4735 hres = get_attr_dispid_by_idx(This, &index, &id);
4736 if(hres == DISP_E_UNKNOWNNAME)
4737 return E_INVALIDARG;
4738 if(FAILED(hres))
4739 return hres;
4741 hres = get_domattr(This, id, NULL, &attr);
4742 if(FAILED(hres))
4743 return hres;
4745 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
4746 return S_OK;
4749 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
4751 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4752 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
4755 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
4756 HTMLAttributeCollection3_QueryInterface,
4757 HTMLAttributeCollection3_AddRef,
4758 HTMLAttributeCollection3_Release,
4759 HTMLAttributeCollection3_GetTypeInfoCount,
4760 HTMLAttributeCollection3_GetTypeInfo,
4761 HTMLAttributeCollection3_GetIDsOfNames,
4762 HTMLAttributeCollection3_Invoke,
4763 HTMLAttributeCollection3_getNamedItem,
4764 HTMLAttributeCollection3_setNamedItem,
4765 HTMLAttributeCollection3_removeNamedItem,
4766 HTMLAttributeCollection3_item,
4767 HTMLAttributeCollection3_get_length
4770 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
4772 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
4775 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4777 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4778 HTMLDOMAttribute *attr;
4779 LONG pos;
4780 HRESULT hres;
4782 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
4784 hres = get_attr_dispid_by_name(This, name, dispid);
4785 if(FAILED(hres))
4786 return hres;
4788 hres = get_domattr(This, *dispid, &pos, &attr);
4789 if(FAILED(hres))
4790 return hres;
4791 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4793 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
4794 return S_OK;
4797 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4798 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4800 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4802 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
4804 switch(flags) {
4805 case DISPATCH_PROPERTYGET: {
4806 HTMLDOMAttribute *iter;
4807 DWORD pos;
4809 pos = id-MSHTML_DISPID_CUSTOM_MIN;
4811 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4812 if(!pos) {
4813 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
4814 V_VT(res) = VT_DISPATCH;
4815 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
4816 return S_OK;
4818 pos--;
4821 WARN("invalid arg\n");
4822 return E_INVALIDARG;
4825 default:
4826 FIXME("unimplemented flags %x\n", flags);
4827 return E_NOTIMPL;
4831 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
4832 NULL,
4833 HTMLAttributeCollection_get_dispid,
4834 HTMLAttributeCollection_invoke,
4835 NULL
4838 static const tid_t HTMLAttributeCollection_iface_tids[] = {
4839 IHTMLAttributeCollection_tid,
4840 IHTMLAttributeCollection2_tid,
4841 IHTMLAttributeCollection3_tid,
4845 static dispex_static_data_t HTMLAttributeCollection_dispex = {
4846 &HTMLAttributeCollection_dispex_vtbl,
4847 DispHTMLAttributeCollection_tid,
4848 NULL,
4849 HTMLAttributeCollection_iface_tids
4852 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
4854 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4856 if(This->attrs) {
4857 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
4858 *ac = This->attrs;
4859 return S_OK;
4862 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
4863 if(!This->attrs)
4864 return E_OUTOFMEMORY;
4866 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
4867 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
4868 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
4869 This->attrs->ref = 2;
4871 This->attrs->elem = This;
4872 list_init(&This->attrs->attrs);
4873 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
4874 &HTMLAttributeCollection_dispex);
4876 *ac = This->attrs;
4877 return S_OK;