wined3d: Remove fbo_entry->d3d_depth_stencil.
[wine.git] / dlls / mshtml / htmlelem.c
blobcb0b8642f5279406552d460c31278d058e80c321
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 static const WCHAR nullW[] = {'n','u','l','l',0};
649 hres = IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
650 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
651 if(FAILED(hres))
652 return hres;
654 if(flags & ATTRFLAG_ASSTRING) {
655 switch(V_VT(ret)) {
656 case VT_BSTR:
657 break;
658 case VT_NULL:
659 V_BSTR(ret) = SysAllocString(nullW);
660 if(!V_BSTR(ret))
661 return E_OUTOFMEMORY;
662 V_VT(ret) = VT_BSTR;
663 break;
664 case VT_DISPATCH:
665 IDispatch_Release(V_DISPATCH(ret));
666 V_VT(ret) = VT_BSTR;
667 V_BSTR(ret) = SysAllocString(NULL);
668 break;
669 default:
670 hres = VariantChangeType(ret, ret, 0, VT_BSTR);
671 if(FAILED(hres))
672 return hres;
676 return S_OK;
679 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
680 LONG lFlags, VARIANT *AttributeValue)
682 HTMLElement *This = impl_from_IHTMLElement(iface);
683 DISPID dispid;
684 HRESULT hres;
686 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
688 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
689 FIXME("Unsupported flags %x\n", lFlags);
691 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
692 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
693 if(hres == DISP_E_UNKNOWNNAME) {
694 V_VT(AttributeValue) = VT_NULL;
695 return S_OK;
698 if(FAILED(hres)) {
699 V_VT(AttributeValue) = VT_NULL;
700 return hres;
703 return get_elem_attr_value_by_dispid(This, dispid, lFlags, AttributeValue);
706 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
707 LONG lFlags, VARIANT_BOOL *pfSuccess)
709 HTMLElement *This = impl_from_IHTMLElement(iface);
710 DISPID id;
711 HRESULT hres;
713 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
715 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
716 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
717 if(hres == DISP_E_UNKNOWNNAME) {
718 *pfSuccess = VARIANT_FALSE;
719 return S_OK;
721 if(FAILED(hres))
722 return hres;
724 if(id == DISPID_IHTMLELEMENT_STYLE) {
725 IHTMLStyle *style;
727 TRACE("Special case: style\n");
729 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
730 if(FAILED(hres))
731 return hres;
733 hres = IHTMLStyle_put_cssText(style, NULL);
734 IHTMLStyle_Release(style);
735 if(FAILED(hres))
736 return hres;
738 *pfSuccess = VARIANT_TRUE;
739 return S_OK;
742 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
745 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
747 HTMLElement *This = impl_from_IHTMLElement(iface);
748 nsAString classname_str;
749 nsresult nsres;
751 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
753 if(!This->nselem) {
754 FIXME("NULL nselem\n");
755 return E_NOTIMPL;
758 nsAString_InitDepend(&classname_str, v);
759 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
760 nsAString_Finish(&classname_str);
761 if(NS_FAILED(nsres))
762 ERR("SetClassName failed: %08x\n", nsres);
764 return S_OK;
767 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
769 HTMLElement *This = impl_from_IHTMLElement(iface);
770 nsAString class_str;
771 nsresult nsres;
773 TRACE("(%p)->(%p)\n", This, p);
775 if(!This->nselem) {
776 FIXME("NULL nselem\n");
777 return E_NOTIMPL;
780 nsAString_Init(&class_str, NULL);
781 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
782 return return_nsstr(nsres, &class_str, p);
785 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
787 HTMLElement *This = impl_from_IHTMLElement(iface);
788 nsAString id_str;
789 nsresult nsres;
791 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
793 if(!This->nselem) {
794 FIXME("nselem == NULL\n");
795 return S_OK;
798 nsAString_InitDepend(&id_str, v);
799 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
800 nsAString_Finish(&id_str);
801 if(NS_FAILED(nsres))
802 ERR("SetId failed: %08x\n", nsres);
804 return S_OK;
807 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
809 HTMLElement *This = impl_from_IHTMLElement(iface);
810 nsAString id_str;
811 nsresult nsres;
813 TRACE("(%p)->(%p)\n", This, p);
815 if(!This->nselem) {
816 *p = NULL;
817 return S_OK;
820 nsAString_Init(&id_str, NULL);
821 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
822 return return_nsstr(nsres, &id_str, p);
825 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
827 HTMLElement *This = impl_from_IHTMLElement(iface);
828 nsAString tag_str;
829 nsresult nsres;
831 TRACE("(%p)->(%p)\n", This, p);
833 if(!This->nselem) {
834 static const WCHAR comment_tagW[] = {'!',0};
836 WARN("NULL nselem, assuming comment\n");
838 *p = SysAllocString(comment_tagW);
839 return *p ? S_OK : E_OUTOFMEMORY;
842 nsAString_Init(&tag_str, NULL);
843 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
844 return return_nsstr(nsres, &tag_str, p);
847 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
849 HTMLElement *This = impl_from_IHTMLElement(iface);
850 IHTMLDOMNode *node;
851 HRESULT hres;
853 TRACE("(%p)->(%p)\n", This, p);
855 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
856 if(FAILED(hres))
857 return hres;
859 if(!node) {
860 *p = NULL;
861 return S_OK;
864 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
865 IHTMLDOMNode_Release(node);
866 if(FAILED(hres))
867 *p = NULL;
869 return S_OK;
872 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
874 HTMLElement *This = impl_from_IHTMLElement(iface);
876 TRACE("(%p)->(%p)\n", This, p);
878 if(!This->style) {
879 HRESULT hres;
881 hres = HTMLStyle_Create(This, &This->style);
882 if(FAILED(hres))
883 return hres;
886 *p = &This->style->IHTMLStyle_iface;
887 IHTMLStyle_AddRef(*p);
888 return S_OK;
891 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
893 HTMLElement *This = impl_from_IHTMLElement(iface);
894 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
895 return E_NOTIMPL;
898 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
900 HTMLElement *This = impl_from_IHTMLElement(iface);
901 FIXME("(%p)->(%p)\n", This, p);
902 return E_NOTIMPL;
905 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
907 HTMLElement *This = impl_from_IHTMLElement(iface);
909 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
911 return set_node_event(&This->node, EVENTID_CLICK, &v);
914 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
916 HTMLElement *This = impl_from_IHTMLElement(iface);
918 TRACE("(%p)->(%p)\n", This, p);
920 return get_node_event(&This->node, EVENTID_CLICK, p);
923 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
925 HTMLElement *This = impl_from_IHTMLElement(iface);
927 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
929 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
932 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
934 HTMLElement *This = impl_from_IHTMLElement(iface);
936 TRACE("(%p)->(%p)\n", This, p);
938 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
941 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
943 HTMLElement *This = impl_from_IHTMLElement(iface);
945 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
947 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
950 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
952 HTMLElement *This = impl_from_IHTMLElement(iface);
954 TRACE("(%p)->(%p)\n", This, p);
956 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
959 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
961 HTMLElement *This = impl_from_IHTMLElement(iface);
963 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
965 return set_node_event(&This->node, EVENTID_KEYUP, &v);
968 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
970 HTMLElement *This = impl_from_IHTMLElement(iface);
971 FIXME("(%p)->(%p)\n", This, p);
972 return E_NOTIMPL;
975 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
977 HTMLElement *This = impl_from_IHTMLElement(iface);
979 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
981 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
984 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
986 HTMLElement *This = impl_from_IHTMLElement(iface);
988 TRACE("(%p)->(%p)\n", This, p);
990 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
993 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
995 HTMLElement *This = impl_from_IHTMLElement(iface);
997 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
999 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
1002 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
1004 HTMLElement *This = impl_from_IHTMLElement(iface);
1006 TRACE("(%p)->(%p)\n", This, p);
1008 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
1011 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1013 HTMLElement *This = impl_from_IHTMLElement(iface);
1015 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1017 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1020 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1022 HTMLElement *This = impl_from_IHTMLElement(iface);
1024 TRACE("(%p)->(%p)\n", This, p);
1026 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1029 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1031 HTMLElement *This = impl_from_IHTMLElement(iface);
1033 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1035 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1038 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1040 HTMLElement *This = impl_from_IHTMLElement(iface);
1042 TRACE("(%p)->(%p)\n", This, p);
1044 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1047 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1049 HTMLElement *This = impl_from_IHTMLElement(iface);
1051 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1053 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1056 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1058 HTMLElement *This = impl_from_IHTMLElement(iface);
1060 TRACE("(%p)->(%p)\n", This, p);
1062 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1065 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1067 HTMLElement *This = impl_from_IHTMLElement(iface);
1069 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1071 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1074 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1076 HTMLElement *This = impl_from_IHTMLElement(iface);
1078 TRACE("(%p)->(%p)\n", This, p);
1080 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1083 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1085 HTMLElement *This = impl_from_IHTMLElement(iface);
1087 TRACE("(%p)->(%p)\n", This, p);
1089 if(!p)
1090 return E_POINTER;
1092 if(This->node.vtbl->get_document)
1093 return This->node.vtbl->get_document(&This->node, p);
1095 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1096 IDispatch_AddRef(*p);
1097 return S_OK;
1100 static const WCHAR titleW[] = {'t','i','t','l','e',0};
1102 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1104 HTMLElement *This = impl_from_IHTMLElement(iface);
1105 nsAString title_str;
1106 nsresult nsres;
1108 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1110 if(!This->nselem) {
1111 VARIANT *var;
1112 HRESULT hres;
1114 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, TRUE, &var);
1115 if(FAILED(hres))
1116 return hres;
1118 VariantClear(var);
1119 V_VT(var) = VT_BSTR;
1120 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1121 return S_OK;
1124 nsAString_InitDepend(&title_str, v);
1125 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
1126 nsAString_Finish(&title_str);
1127 if(NS_FAILED(nsres))
1128 ERR("SetTitle failed: %08x\n", nsres);
1130 return S_OK;
1133 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1135 HTMLElement *This = impl_from_IHTMLElement(iface);
1136 nsAString title_str;
1137 nsresult nsres;
1139 TRACE("(%p)->(%p)\n", This, p);
1141 if(!This->nselem) {
1142 VARIANT *var;
1143 HRESULT hres;
1145 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, FALSE, &var);
1146 if(hres == DISP_E_UNKNOWNNAME) {
1147 *p = NULL;
1148 }else if(V_VT(var) != VT_BSTR) {
1149 FIXME("title = %s\n", debugstr_variant(var));
1150 return E_FAIL;
1151 }else {
1152 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1155 return S_OK;
1158 nsAString_Init(&title_str, NULL);
1159 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
1160 return return_nsstr(nsres, &title_str, p);
1163 static const WCHAR languageW[] = {'l','a','n','g','u','a','g','e',0};
1165 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1167 HTMLElement *This = impl_from_IHTMLElement(iface);
1169 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1171 return elem_string_attr_setter(This, languageW, v);
1174 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1176 HTMLElement *This = impl_from_IHTMLElement(iface);
1178 TRACE("(%p)->(%p)\n", This, p);
1180 return elem_string_attr_getter(This, languageW, TRUE, p);
1183 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1185 HTMLElement *This = impl_from_IHTMLElement(iface);
1187 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1189 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1192 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1194 HTMLElement *This = impl_from_IHTMLElement(iface);
1196 TRACE("(%p)->(%p)\n", This, p);
1198 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1201 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1203 HTMLElement *This = impl_from_IHTMLElement(iface);
1204 cpp_bool start = TRUE;
1205 nsresult nsres;
1207 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1209 switch(V_VT(&varargStart)) {
1210 case VT_EMPTY:
1211 case VT_ERROR:
1212 break;
1213 case VT_BOOL:
1214 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1215 break;
1216 default:
1217 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1220 if(!This->nselem) {
1221 FIXME("Unsupported for comments\n");
1222 return E_NOTIMPL;
1225 nsres = nsIDOMHTMLElement_ScrollIntoView(This->nselem, start, 1);
1226 assert(nsres == NS_OK);
1228 return S_OK;
1231 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1232 VARIANT_BOOL *pfResult)
1234 HTMLElement *This = impl_from_IHTMLElement(iface);
1235 cpp_bool result = FALSE;
1237 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1239 if(pChild) {
1240 HTMLElement *child;
1241 nsresult nsres;
1243 child = unsafe_impl_from_IHTMLElement(pChild);
1244 if(!child) {
1245 ERR("not our element\n");
1246 return E_FAIL;
1249 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1250 assert(nsres == NS_OK);
1253 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
1254 return S_OK;
1257 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1259 HTMLElement *This = impl_from_IHTMLElement(iface);
1261 TRACE("(%p)->(%p)\n", This, p);
1263 return get_elem_source_index(This, p);
1266 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1268 HTMLElement *This = impl_from_IHTMLElement(iface);
1269 FIXME("(%p)->(%p)\n", This, p);
1270 return E_NOTIMPL;
1273 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1275 HTMLElement *This = impl_from_IHTMLElement(iface);
1276 nsAString nsstr;
1277 nsresult nsres;
1279 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1281 if(!This->nselem) {
1282 FIXME("NULL nselem\n");
1283 return E_NOTIMPL;
1286 nsAString_InitDepend(&nsstr, v);
1287 nsres = nsIDOMHTMLElement_SetLang(This->nselem, &nsstr);
1288 nsAString_Finish(&nsstr);
1289 if(NS_FAILED(nsres)) {
1290 ERR("SetLang failed: %08x\n", nsres);
1291 return E_FAIL;
1294 return S_OK;
1297 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1299 HTMLElement *This = impl_from_IHTMLElement(iface);
1300 nsAString nsstr;
1301 nsresult nsres;
1303 TRACE("(%p)->(%p)\n", This, p);
1305 if(!This->nselem) {
1306 FIXME("NULL nselem\n");
1307 return E_NOTIMPL;
1310 nsAString_Init(&nsstr, NULL);
1311 nsres = nsIDOMHTMLElement_GetLang(This->nselem, &nsstr);
1312 return return_nsstr(nsres, &nsstr, p);
1315 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1317 HTMLElement *This = impl_from_IHTMLElement(iface);
1318 nsresult nsres;
1320 TRACE("(%p)->(%p)\n", This, p);
1322 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, p);
1323 if(NS_FAILED(nsres)) {
1324 ERR("GetOffsetLeft failed: %08x\n", nsres);
1325 return E_FAIL;
1328 return S_OK;
1331 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1333 HTMLElement *This = impl_from_IHTMLElement(iface);
1334 nsresult nsres;
1336 TRACE("(%p)->(%p)\n", This, p);
1338 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, p);
1339 if(NS_FAILED(nsres)) {
1340 ERR("GetOffsetTop failed: %08x\n", nsres);
1341 return E_FAIL;
1344 return S_OK;
1347 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1349 HTMLElement *This = impl_from_IHTMLElement(iface);
1350 nsresult nsres;
1352 TRACE("(%p)->(%p)\n", This, p);
1354 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, p);
1355 if(NS_FAILED(nsres)) {
1356 ERR("GetOffsetWidth failed: %08x\n", nsres);
1357 return E_FAIL;
1360 return S_OK;
1363 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1365 HTMLElement *This = impl_from_IHTMLElement(iface);
1366 nsresult nsres;
1368 TRACE("(%p)->(%p)\n", This, p);
1370 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, p);
1371 if(NS_FAILED(nsres)) {
1372 ERR("GetOffsetHeight failed: %08x\n", nsres);
1373 return E_FAIL;
1376 return S_OK;
1379 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1381 HTMLElement *This = impl_from_IHTMLElement(iface);
1382 nsIDOMElement *nsparent;
1383 nsresult nsres;
1384 HRESULT hres;
1386 TRACE("(%p)->(%p)\n", This, p);
1388 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
1389 if(NS_FAILED(nsres)) {
1390 ERR("GetOffsetParent failed: %08x\n", nsres);
1391 return E_FAIL;
1394 if(nsparent) {
1395 HTMLDOMNode *node;
1397 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1398 nsIDOMElement_Release(nsparent);
1399 if(FAILED(hres))
1400 return hres;
1402 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1403 node_release(node);
1404 }else {
1405 *p = NULL;
1406 hres = S_OK;
1409 return hres;
1412 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1414 HTMLElement *This = impl_from_IHTMLElement(iface);
1415 nsAString html_str;
1416 nsresult nsres;
1418 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1420 if(!This->nselem) {
1421 FIXME("NULL nselem\n");
1422 return E_NOTIMPL;
1425 nsAString_InitDepend(&html_str, v);
1426 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
1427 nsAString_Finish(&html_str);
1428 if(NS_FAILED(nsres)) {
1429 FIXME("SetInnerHtml failed %08x\n", nsres);
1430 return E_FAIL;
1433 return S_OK;
1436 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1438 HTMLElement *This = impl_from_IHTMLElement(iface);
1439 nsAString html_str;
1440 nsresult nsres;
1442 TRACE("(%p)->(%p)\n", This, p);
1444 if(!This->nselem) {
1445 FIXME("NULL nselem\n");
1446 return E_NOTIMPL;
1449 nsAString_Init(&html_str, NULL);
1450 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
1451 return return_nsstr(nsres, &html_str, p);
1454 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1456 HTMLElement *This = impl_from_IHTMLElement(iface);
1457 nsIDOMNode *nschild, *tmp;
1458 nsIDOMText *text_node;
1459 nsAString text_str;
1460 nsresult nsres;
1462 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1464 while(1) {
1465 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1466 if(NS_FAILED(nsres)) {
1467 ERR("GetLastChild failed: %08x\n", nsres);
1468 return E_FAIL;
1470 if(!nschild)
1471 break;
1473 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1474 nsIDOMNode_Release(nschild);
1475 if(NS_FAILED(nsres)) {
1476 ERR("RemoveChild failed: %08x\n", nsres);
1477 return E_FAIL;
1479 nsIDOMNode_Release(tmp);
1482 nsAString_InitDepend(&text_str, v);
1483 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1484 nsAString_Finish(&text_str);
1485 if(NS_FAILED(nsres)) {
1486 ERR("CreateTextNode failed: %08x\n", nsres);
1487 return E_FAIL;
1490 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1491 if(NS_FAILED(nsres)) {
1492 ERR("AppendChild failed: %08x\n", nsres);
1493 return E_FAIL;
1496 nsIDOMNode_Release(tmp);
1497 return S_OK;
1500 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1502 HTMLElement *This = impl_from_IHTMLElement(iface);
1504 TRACE("(%p)->(%p)\n", This, p);
1506 return get_node_text(&This->node, p);
1509 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1511 HTMLElement *This = impl_from_IHTMLElement(iface);
1513 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1515 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1518 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1520 HTMLElement *This = impl_from_IHTMLElement(iface);
1521 nsAString html_str;
1522 HRESULT hres;
1524 WARN("(%p)->(%p) semi-stub\n", This, p);
1526 nsAString_Init(&html_str, NULL);
1527 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1528 if(SUCCEEDED(hres)) {
1529 const PRUnichar *html;
1531 nsAString_GetData(&html_str, &html);
1532 *p = SysAllocString(html);
1533 if(!*p)
1534 hres = E_OUTOFMEMORY;
1537 nsAString_Finish(&html_str);
1539 TRACE("ret %s\n", debugstr_w(*p));
1540 return hres;
1543 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1545 HTMLElement *This = impl_from_IHTMLElement(iface);
1546 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1547 return E_NOTIMPL;
1550 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1552 HTMLElement *This = impl_from_IHTMLElement(iface);
1553 FIXME("(%p)->(%p)\n", This, p);
1554 return E_NOTIMPL;
1557 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1559 nsIDOMNode *ret_nsnode;
1560 nsresult nsres;
1561 HRESULT hres = S_OK;
1563 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1564 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1565 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1566 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1568 if (!strcmpiW(where, beforebeginW)) {
1569 nsIDOMNode *parent;
1571 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1572 if(NS_FAILED(nsres))
1573 return E_FAIL;
1575 if(!parent)
1576 return E_INVALIDARG;
1578 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1579 nsIDOMNode_Release(parent);
1580 }else if(!strcmpiW(where, afterbeginW)) {
1581 nsIDOMNode *first_child;
1583 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1584 if(NS_FAILED(nsres))
1585 return E_FAIL;
1587 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1588 if(NS_FAILED(nsres))
1589 return E_FAIL;
1591 if (first_child)
1592 nsIDOMNode_Release(first_child);
1593 }else if (!strcmpiW(where, beforeendW)) {
1594 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1595 }else if (!strcmpiW(where, afterendW)) {
1596 nsIDOMNode *next_sibling, *parent;
1598 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1599 if(NS_FAILED(nsres))
1600 return E_FAIL;
1601 if(!parent)
1602 return E_INVALIDARG;
1604 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1605 if(NS_SUCCEEDED(nsres)) {
1606 if(next_sibling) {
1607 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1608 nsIDOMNode_Release(next_sibling);
1609 }else {
1610 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1614 nsIDOMNode_Release(parent);
1615 }else {
1616 ERR("invalid where: %s\n", debugstr_w(where));
1617 return E_INVALIDARG;
1620 if (NS_FAILED(nsres))
1621 return E_FAIL;
1623 if(ret_node)
1624 hres = get_node(This->node.doc, ret_nsnode, TRUE, ret_node);
1625 nsIDOMNode_Release(ret_nsnode);
1626 return hres;
1629 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1630 BSTR html)
1632 HTMLElement *This = impl_from_IHTMLElement(iface);
1633 nsIDOMRange *range;
1634 nsIDOMNode *nsnode;
1635 nsAString ns_html;
1636 nsresult nsres;
1637 HRESULT hr;
1639 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1641 if(!This->node.doc->nsdoc) {
1642 WARN("NULL nsdoc\n");
1643 return E_UNEXPECTED;
1646 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1647 if(NS_FAILED(nsres))
1649 ERR("CreateRange failed: %08x\n", nsres);
1650 return E_FAIL;
1653 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1655 nsAString_InitDepend(&ns_html, html);
1656 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1657 nsAString_Finish(&ns_html);
1658 nsIDOMRange_Release(range);
1660 if(NS_FAILED(nsres) || !nsnode)
1662 ERR("CreateTextNode failed: %08x\n", nsres);
1663 return E_FAIL;
1666 hr = insert_adjacent_node(This, where, nsnode, NULL);
1667 nsIDOMNode_Release(nsnode);
1668 return hr;
1671 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1672 BSTR text)
1674 HTMLElement *This = impl_from_IHTMLElement(iface);
1675 nsIDOMNode *nsnode;
1676 nsAString ns_text;
1677 nsresult nsres;
1678 HRESULT hr;
1680 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1682 if(!This->node.doc->nsdoc) {
1683 WARN("NULL nsdoc\n");
1684 return E_UNEXPECTED;
1688 nsAString_InitDepend(&ns_text, text);
1689 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1690 nsAString_Finish(&ns_text);
1692 if(NS_FAILED(nsres) || !nsnode)
1694 ERR("CreateTextNode failed: %08x\n", nsres);
1695 return E_FAIL;
1698 hr = insert_adjacent_node(This, where, nsnode, NULL);
1699 nsIDOMNode_Release(nsnode);
1701 return hr;
1704 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1706 HTMLElement *This = impl_from_IHTMLElement(iface);
1707 FIXME("(%p)->(%p)\n", This, p);
1708 return E_NOTIMPL;
1711 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1713 HTMLElement *This = impl_from_IHTMLElement(iface);
1715 TRACE("(%p)->(%p)\n", This, p);
1717 *p = This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node)
1718 ? VARIANT_TRUE : VARIANT_FALSE;
1719 return S_OK;
1722 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1724 HTMLElement *This = impl_from_IHTMLElement(iface);
1726 TRACE("(%p)\n", This);
1728 return call_fire_event(&This->node, EVENTID_CLICK);
1731 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1732 IHTMLFiltersCollection **p)
1734 HTMLElement *This = impl_from_IHTMLElement(iface);
1735 TRACE("(%p)->(%p)\n", This, p);
1737 if(!p)
1738 return E_POINTER;
1740 *p = HTMLFiltersCollection_Create();
1742 return S_OK;
1745 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1747 HTMLElement *This = impl_from_IHTMLElement(iface);
1748 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1749 return E_NOTIMPL;
1752 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1754 HTMLElement *This = impl_from_IHTMLElement(iface);
1755 FIXME("(%p)->(%p)\n", This, p);
1756 return E_NOTIMPL;
1759 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1761 HTMLElement *This = impl_from_IHTMLElement(iface);
1762 FIXME("(%p)->(%p)\n", This, String);
1763 return E_NOTIMPL;
1766 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1768 HTMLElement *This = impl_from_IHTMLElement(iface);
1769 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1770 return E_NOTIMPL;
1773 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1775 HTMLElement *This = impl_from_IHTMLElement(iface);
1776 FIXME("(%p)->(%p)\n", This, p);
1777 return E_NOTIMPL;
1780 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1782 HTMLElement *This = impl_from_IHTMLElement(iface);
1783 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1784 return E_NOTIMPL;
1787 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1789 HTMLElement *This = impl_from_IHTMLElement(iface);
1790 FIXME("(%p)->(%p)\n", This, p);
1791 return E_NOTIMPL;
1794 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1796 HTMLElement *This = impl_from_IHTMLElement(iface);
1797 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1798 return E_NOTIMPL;
1801 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1803 HTMLElement *This = impl_from_IHTMLElement(iface);
1804 FIXME("(%p)->(%p)\n", This, p);
1805 return E_NOTIMPL;
1808 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1810 HTMLElement *This = impl_from_IHTMLElement(iface);
1811 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1812 return E_NOTIMPL;
1815 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1817 HTMLElement *This = impl_from_IHTMLElement(iface);
1818 FIXME("(%p)->(%p)\n", This, p);
1819 return E_NOTIMPL;
1822 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1824 HTMLElement *This = impl_from_IHTMLElement(iface);
1825 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1826 return E_NOTIMPL;
1829 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1831 HTMLElement *This = impl_from_IHTMLElement(iface);
1832 FIXME("(%p)->(%p)\n", This, p);
1833 return E_NOTIMPL;
1836 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1838 HTMLElement *This = impl_from_IHTMLElement(iface);
1839 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1840 return E_NOTIMPL;
1843 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1845 HTMLElement *This = impl_from_IHTMLElement(iface);
1846 FIXME("(%p)->(%p)\n", This, p);
1847 return E_NOTIMPL;
1850 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1852 HTMLElement *This = impl_from_IHTMLElement(iface);
1854 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1856 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1859 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1861 HTMLElement *This = impl_from_IHTMLElement(iface);
1863 TRACE("(%p)->(%p)\n", This, p);
1865 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1868 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1870 HTMLElement *This = impl_from_IHTMLElement(iface);
1871 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1872 return E_NOTIMPL;
1875 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1877 HTMLElement *This = impl_from_IHTMLElement(iface);
1878 FIXME("(%p)->(%p)\n", This, p);
1879 return E_NOTIMPL;
1882 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1884 HTMLElement *This = impl_from_IHTMLElement(iface);
1885 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1886 return E_NOTIMPL;
1889 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1891 HTMLElement *This = impl_from_IHTMLElement(iface);
1892 FIXME("(%p)->(%p)\n", This, p);
1893 return E_NOTIMPL;
1896 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1898 HTMLElement *This = impl_from_IHTMLElement(iface);
1899 nsIDOMNodeList *nsnode_list;
1900 nsresult nsres;
1902 TRACE("(%p)->(%p)\n", This, p);
1904 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1905 if(NS_FAILED(nsres)) {
1906 ERR("GetChildNodes failed: %08x\n", nsres);
1907 return E_FAIL;
1910 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1912 nsIDOMNodeList_Release(nsnode_list);
1913 return S_OK;
1916 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1918 HTMLElement *This = impl_from_IHTMLElement(iface);
1920 TRACE("(%p)->(%p)\n", This, p);
1922 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1923 return S_OK;
1926 static const IHTMLElementVtbl HTMLElementVtbl = {
1927 HTMLElement_QueryInterface,
1928 HTMLElement_AddRef,
1929 HTMLElement_Release,
1930 HTMLElement_GetTypeInfoCount,
1931 HTMLElement_GetTypeInfo,
1932 HTMLElement_GetIDsOfNames,
1933 HTMLElement_Invoke,
1934 HTMLElement_setAttribute,
1935 HTMLElement_getAttribute,
1936 HTMLElement_removeAttribute,
1937 HTMLElement_put_className,
1938 HTMLElement_get_className,
1939 HTMLElement_put_id,
1940 HTMLElement_get_id,
1941 HTMLElement_get_tagName,
1942 HTMLElement_get_parentElement,
1943 HTMLElement_get_style,
1944 HTMLElement_put_onhelp,
1945 HTMLElement_get_onhelp,
1946 HTMLElement_put_onclick,
1947 HTMLElement_get_onclick,
1948 HTMLElement_put_ondblclick,
1949 HTMLElement_get_ondblclick,
1950 HTMLElement_put_onkeydown,
1951 HTMLElement_get_onkeydown,
1952 HTMLElement_put_onkeyup,
1953 HTMLElement_get_onkeyup,
1954 HTMLElement_put_onkeypress,
1955 HTMLElement_get_onkeypress,
1956 HTMLElement_put_onmouseout,
1957 HTMLElement_get_onmouseout,
1958 HTMLElement_put_onmouseover,
1959 HTMLElement_get_onmouseover,
1960 HTMLElement_put_onmousemove,
1961 HTMLElement_get_onmousemove,
1962 HTMLElement_put_onmousedown,
1963 HTMLElement_get_onmousedown,
1964 HTMLElement_put_onmouseup,
1965 HTMLElement_get_onmouseup,
1966 HTMLElement_get_document,
1967 HTMLElement_put_title,
1968 HTMLElement_get_title,
1969 HTMLElement_put_language,
1970 HTMLElement_get_language,
1971 HTMLElement_put_onselectstart,
1972 HTMLElement_get_onselectstart,
1973 HTMLElement_scrollIntoView,
1974 HTMLElement_contains,
1975 HTMLElement_get_sourceIndex,
1976 HTMLElement_get_recordNumber,
1977 HTMLElement_put_lang,
1978 HTMLElement_get_lang,
1979 HTMLElement_get_offsetLeft,
1980 HTMLElement_get_offsetTop,
1981 HTMLElement_get_offsetWidth,
1982 HTMLElement_get_offsetHeight,
1983 HTMLElement_get_offsetParent,
1984 HTMLElement_put_innerHTML,
1985 HTMLElement_get_innerHTML,
1986 HTMLElement_put_innerText,
1987 HTMLElement_get_innerText,
1988 HTMLElement_put_outerHTML,
1989 HTMLElement_get_outerHTML,
1990 HTMLElement_put_outerText,
1991 HTMLElement_get_outerText,
1992 HTMLElement_insertAdjacentHTML,
1993 HTMLElement_insertAdjacentText,
1994 HTMLElement_get_parentTextEdit,
1995 HTMLElement_get_isTextEdit,
1996 HTMLElement_click,
1997 HTMLElement_get_filters,
1998 HTMLElement_put_ondragstart,
1999 HTMLElement_get_ondragstart,
2000 HTMLElement_toString,
2001 HTMLElement_put_onbeforeupdate,
2002 HTMLElement_get_onbeforeupdate,
2003 HTMLElement_put_onafterupdate,
2004 HTMLElement_get_onafterupdate,
2005 HTMLElement_put_onerrorupdate,
2006 HTMLElement_get_onerrorupdate,
2007 HTMLElement_put_onrowexit,
2008 HTMLElement_get_onrowexit,
2009 HTMLElement_put_onrowenter,
2010 HTMLElement_get_onrowenter,
2011 HTMLElement_put_ondatasetchanged,
2012 HTMLElement_get_ondatasetchanged,
2013 HTMLElement_put_ondataavailable,
2014 HTMLElement_get_ondataavailable,
2015 HTMLElement_put_ondatasetcomplete,
2016 HTMLElement_get_ondatasetcomplete,
2017 HTMLElement_put_onfilterchange,
2018 HTMLElement_get_onfilterchange,
2019 HTMLElement_get_children,
2020 HTMLElement_get_all
2023 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
2025 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
2028 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
2030 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
2033 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
2034 REFIID riid, void **ppv)
2036 HTMLElement *This = impl_from_IHTMLElement2(iface);
2037 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
2040 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2042 HTMLElement *This = impl_from_IHTMLElement2(iface);
2043 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2046 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2048 HTMLElement *This = impl_from_IHTMLElement2(iface);
2049 return IHTMLElement_Release(&This->IHTMLElement_iface);
2052 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2054 HTMLElement *This = impl_from_IHTMLElement2(iface);
2055 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2058 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2059 LCID lcid, ITypeInfo **ppTInfo)
2061 HTMLElement *This = impl_from_IHTMLElement2(iface);
2062 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2065 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2066 LPOLESTR *rgszNames, UINT cNames,
2067 LCID lcid, DISPID *rgDispId)
2069 HTMLElement *This = impl_from_IHTMLElement2(iface);
2070 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2071 lcid, rgDispId);
2074 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2075 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2076 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2078 HTMLElement *This = impl_from_IHTMLElement2(iface);
2079 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2080 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2083 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2085 HTMLElement *This = impl_from_IHTMLElement2(iface);
2086 FIXME("(%p)->(%p)\n", This, p);
2087 return E_NOTIMPL;
2090 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2092 HTMLElement *This = impl_from_IHTMLElement2(iface);
2093 FIXME("(%p)->(%x)\n", This, containerCapture);
2094 return E_NOTIMPL;
2097 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2099 HTMLElement *This = impl_from_IHTMLElement2(iface);
2100 FIXME("(%p)\n", This);
2101 return E_NOTIMPL;
2104 static HRESULT WINAPI HTMLElement2_put_onlosecapture(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_onlosecapture(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_componentFromPoint(IHTMLElement2 *iface,
2119 LONG x, LONG y, BSTR *component)
2121 HTMLElement *This = impl_from_IHTMLElement2(iface);
2122 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2123 return E_NOTIMPL;
2126 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2128 HTMLElement *This = impl_from_IHTMLElement2(iface);
2130 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2132 if(!This->node.doc->content_ready
2133 || !This->node.doc->basedoc.doc_obj->in_place_active)
2134 return E_PENDING;
2136 WARN("stub\n");
2137 return S_OK;
2140 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2142 HTMLElement *This = impl_from_IHTMLElement2(iface);
2143 FIXME("(%p)->()\n", This);
2144 return E_NOTIMPL;
2147 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2149 HTMLElement *This = impl_from_IHTMLElement2(iface);
2150 FIXME("(%p)->(%p)\n", This, p);
2151 return E_NOTIMPL;
2154 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2156 HTMLElement *This = impl_from_IHTMLElement2(iface);
2158 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2160 return set_node_event(&This->node, EVENTID_DRAG, &v);
2163 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2165 HTMLElement *This = impl_from_IHTMLElement2(iface);
2167 TRACE("(%p)->(%p)\n", This, p);
2169 return get_node_event(&This->node, EVENTID_DRAG, p);
2172 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2174 HTMLElement *This = impl_from_IHTMLElement2(iface);
2175 FIXME("(%p)->()\n", This);
2176 return E_NOTIMPL;
2179 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2181 HTMLElement *This = impl_from_IHTMLElement2(iface);
2182 FIXME("(%p)->(%p)\n", This, p);
2183 return E_NOTIMPL;
2186 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2188 HTMLElement *This = impl_from_IHTMLElement2(iface);
2189 FIXME("(%p)->()\n", This);
2190 return E_NOTIMPL;
2193 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2195 HTMLElement *This = impl_from_IHTMLElement2(iface);
2196 FIXME("(%p)->(%p)\n", This, p);
2197 return E_NOTIMPL;
2200 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2202 HTMLElement *This = impl_from_IHTMLElement2(iface);
2203 FIXME("(%p)->()\n", This);
2204 return E_NOTIMPL;
2207 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2209 HTMLElement *This = impl_from_IHTMLElement2(iface);
2210 FIXME("(%p)->(%p)\n", This, p);
2211 return E_NOTIMPL;
2214 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2216 HTMLElement *This = impl_from_IHTMLElement2(iface);
2217 FIXME("(%p)->()\n", This);
2218 return E_NOTIMPL;
2221 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2223 HTMLElement *This = impl_from_IHTMLElement2(iface);
2224 FIXME("(%p)->(%p)\n", This, p);
2225 return E_NOTIMPL;
2228 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2230 HTMLElement *This = impl_from_IHTMLElement2(iface);
2231 FIXME("(%p)->()\n", This);
2232 return E_NOTIMPL;
2235 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2237 HTMLElement *This = impl_from_IHTMLElement2(iface);
2238 FIXME("(%p)->(%p)\n", This, p);
2239 return E_NOTIMPL;
2242 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2244 HTMLElement *This = impl_from_IHTMLElement2(iface);
2245 FIXME("(%p)->()\n", This);
2246 return E_NOTIMPL;
2249 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2251 HTMLElement *This = impl_from_IHTMLElement2(iface);
2252 FIXME("(%p)->(%p)\n", This, p);
2253 return E_NOTIMPL;
2256 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2258 HTMLElement *This = impl_from_IHTMLElement2(iface);
2259 FIXME("(%p)->()\n", This);
2260 return E_NOTIMPL;
2263 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2265 HTMLElement *This = impl_from_IHTMLElement2(iface);
2266 FIXME("(%p)->(%p)\n", This, p);
2267 return E_NOTIMPL;
2270 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2272 HTMLElement *This = impl_from_IHTMLElement2(iface);
2273 FIXME("(%p)->()\n", This);
2274 return E_NOTIMPL;
2277 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2279 HTMLElement *This = impl_from_IHTMLElement2(iface);
2280 FIXME("(%p)->(%p)\n", This, p);
2281 return E_NOTIMPL;
2284 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2286 HTMLElement *This = impl_from_IHTMLElement2(iface);
2287 FIXME("(%p)->()\n", This);
2288 return E_NOTIMPL;
2291 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2293 HTMLElement *This = impl_from_IHTMLElement2(iface);
2294 FIXME("(%p)->(%p)\n", This, p);
2295 return E_NOTIMPL;
2298 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2300 HTMLElement *This = impl_from_IHTMLElement2(iface);
2301 FIXME("(%p)->()\n", This);
2302 return E_NOTIMPL;
2305 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2307 HTMLElement *This = impl_from_IHTMLElement2(iface);
2308 FIXME("(%p)->(%p)\n", This, p);
2309 return E_NOTIMPL;
2312 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2314 HTMLElement *This = impl_from_IHTMLElement2(iface);
2316 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2318 return set_node_event(&This->node, EVENTID_PASTE, &v);
2321 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2323 HTMLElement *This = impl_from_IHTMLElement2(iface);
2325 TRACE("(%p)->(%p)\n", This, p);
2327 return get_node_event(&This->node, EVENTID_PASTE, p);
2330 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2332 HTMLElement *This = impl_from_IHTMLElement2(iface);
2334 TRACE("(%p)->(%p)\n", This, p);
2336 return HTMLCurrentStyle_Create(This, p);
2339 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2341 HTMLElement *This = impl_from_IHTMLElement2(iface);
2342 FIXME("(%p)->()\n", This);
2343 return E_NOTIMPL;
2346 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2348 HTMLElement *This = impl_from_IHTMLElement2(iface);
2349 FIXME("(%p)->(%p)\n", This, p);
2350 return E_NOTIMPL;
2353 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2355 HTMLElement *This = impl_from_IHTMLElement2(iface);
2356 FIXME("(%p)->(%p)\n", This, pRectCol);
2357 return E_NOTIMPL;
2360 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2362 HTMLElement *This = impl_from_IHTMLElement2(iface);
2363 nsIDOMClientRect *nsrect;
2364 nsresult nsres;
2365 HRESULT hres;
2367 TRACE("(%p)->(%p)\n", This, pRect);
2369 nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
2370 if(NS_FAILED(nsres) || !nsrect) {
2371 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2372 return E_FAIL;
2375 hres = create_html_rect(nsrect, pRect);
2377 nsIDOMClientRect_Release(nsrect);
2378 return hres;
2381 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2382 BSTR expression, BSTR language)
2384 HTMLElement *This = impl_from_IHTMLElement2(iface);
2385 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2386 debugstr_w(language));
2387 return E_NOTIMPL;
2390 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2391 VARIANT *expression)
2393 HTMLElement *This = impl_from_IHTMLElement2(iface);
2394 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2395 return E_NOTIMPL;
2398 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2399 VARIANT_BOOL *pfSuccess)
2401 HTMLElement *This = impl_from_IHTMLElement2(iface);
2402 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2403 return E_NOTIMPL;
2406 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2408 HTMLElement *This = impl_from_IHTMLElement2(iface);
2409 nsresult nsres;
2411 TRACE("(%p)->(%d)\n", This, v);
2413 nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
2414 if(NS_FAILED(nsres))
2415 ERR("GetTabIndex failed: %08x\n", nsres);
2417 return S_OK;
2420 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2422 HTMLElement *This = impl_from_IHTMLElement2(iface);
2423 LONG index;
2424 nsresult nsres;
2426 TRACE("(%p)->(%p)\n", This, p);
2428 nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
2429 if(NS_FAILED(nsres)) {
2430 ERR("GetTabIndex failed: %08x\n", nsres);
2431 return E_FAIL;
2434 *p = index;
2435 return S_OK;
2438 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2440 HTMLElement *This = impl_from_IHTMLElement2(iface);
2441 nsresult nsres;
2443 TRACE("(%p)\n", This);
2445 nsres = nsIDOMHTMLElement_Focus(This->nselem);
2446 if(NS_FAILED(nsres))
2447 ERR("Focus failed: %08x\n", nsres);
2449 return S_OK;
2452 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2454 HTMLElement *This = impl_from_IHTMLElement2(iface);
2455 VARIANT var;
2457 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2459 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2461 V_VT(&var) = VT_BSTR;
2462 V_BSTR(&var) = v;
2463 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2466 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2468 HTMLElement *This = impl_from_IHTMLElement2(iface);
2469 FIXME("(%p)->(%p)\n", This, p);
2470 return E_NOTIMPL;
2473 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2475 HTMLElement *This = impl_from_IHTMLElement2(iface);
2477 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2479 return set_node_event(&This->node, EVENTID_BLUR, &v);
2482 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2484 HTMLElement *This = impl_from_IHTMLElement2(iface);
2486 TRACE("(%p)->(%p)\n", This, p);
2488 return get_node_event(&This->node, EVENTID_BLUR, p);
2491 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2493 HTMLElement *This = impl_from_IHTMLElement2(iface);
2495 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2497 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2500 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2502 HTMLElement *This = impl_from_IHTMLElement2(iface);
2504 TRACE("(%p)->(%p)\n", This, p);
2506 return get_node_event(&This->node, EVENTID_FOCUS, p);
2509 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2511 HTMLElement *This = impl_from_IHTMLElement2(iface);
2512 FIXME("(%p)->()\n", This);
2513 return E_NOTIMPL;
2516 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2518 HTMLElement *This = impl_from_IHTMLElement2(iface);
2519 FIXME("(%p)->(%p)\n", This, p);
2520 return E_NOTIMPL;
2523 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2525 HTMLElement *This = impl_from_IHTMLElement2(iface);
2526 nsresult nsres;
2528 TRACE("(%p)\n", This);
2530 nsres = nsIDOMHTMLElement_Blur(This->nselem);
2531 if(NS_FAILED(nsres)) {
2532 ERR("Blur failed: %08x\n", nsres);
2533 return E_FAIL;
2536 return S_OK;
2539 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2541 HTMLElement *This = impl_from_IHTMLElement2(iface);
2542 FIXME("(%p)->(%p)\n", This, pUnk);
2543 return E_NOTIMPL;
2546 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2548 HTMLElement *This = impl_from_IHTMLElement2(iface);
2549 FIXME("(%p)->(%p)\n", This, pUnk);
2550 return E_NOTIMPL;
2553 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2555 HTMLElement *This = impl_from_IHTMLElement2(iface);
2556 nsresult nsres;
2558 TRACE("(%p)->(%p)\n", This, p);
2560 nsres = nsIDOMHTMLElement_GetClientHeight(This->nselem, p);
2561 assert(nsres == NS_OK);
2562 return S_OK;
2565 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2567 HTMLElement *This = impl_from_IHTMLElement2(iface);
2568 nsresult nsres;
2570 TRACE("(%p)->(%p)\n", This, p);
2572 nsres = nsIDOMHTMLElement_GetClientWidth(This->nselem, p);
2573 assert(nsres == NS_OK);
2574 return S_OK;
2577 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2579 HTMLElement *This = impl_from_IHTMLElement2(iface);
2580 nsresult nsres;
2582 TRACE("(%p)->(%p)\n", This, p);
2584 nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, p);
2585 assert(nsres == NS_OK);
2587 TRACE("*p = %d\n", *p);
2588 return S_OK;
2591 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2593 HTMLElement *This = impl_from_IHTMLElement2(iface);
2594 nsresult nsres;
2596 TRACE("(%p)->(%p)\n", This, p);
2598 nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, p);
2599 assert(nsres == NS_OK);
2601 TRACE("*p = %d\n", *p);
2602 return S_OK;
2605 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2606 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2608 HTMLElement *This = impl_from_IHTMLElement2(iface);
2610 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2612 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2615 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2617 HTMLElement *This = impl_from_IHTMLElement2(iface);
2619 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2621 return detach_event(&This->node.event_target, event, pDisp);
2624 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2626 HTMLElement *This = impl_from_IHTMLElement2(iface);
2627 BSTR str;
2629 TRACE("(%p)->(%p)\n", This, p);
2631 if(This->node.vtbl->get_readystate) {
2632 HRESULT hres;
2634 hres = This->node.vtbl->get_readystate(&This->node, &str);
2635 if(FAILED(hres))
2636 return hres;
2637 }else {
2638 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2640 str = SysAllocString(completeW);
2641 if(!str)
2642 return E_OUTOFMEMORY;
2645 V_VT(p) = VT_BSTR;
2646 V_BSTR(p) = str;
2647 return S_OK;
2650 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2652 HTMLElement *This = impl_from_IHTMLElement2(iface);
2654 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2656 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2659 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2661 HTMLElement *This = impl_from_IHTMLElement2(iface);
2663 TRACE("(%p)->(%p)\n", This, p);
2665 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2668 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2670 HTMLElement *This = impl_from_IHTMLElement2(iface);
2671 FIXME("(%p)->()\n", This);
2672 return E_NOTIMPL;
2675 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2677 HTMLElement *This = impl_from_IHTMLElement2(iface);
2678 FIXME("(%p)->(%p)\n", This, p);
2679 return E_NOTIMPL;
2682 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2684 HTMLElement *This = impl_from_IHTMLElement2(iface);
2685 FIXME("(%p)->()\n", This);
2686 return E_NOTIMPL;
2689 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2691 HTMLElement *This = impl_from_IHTMLElement2(iface);
2692 FIXME("(%p)->(%p)\n", This, p);
2693 return E_NOTIMPL;
2696 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2698 HTMLElement *This = impl_from_IHTMLElement2(iface);
2699 FIXME("(%p)->()\n", This);
2700 return E_NOTIMPL;
2703 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2705 HTMLElement *This = impl_from_IHTMLElement2(iface);
2706 FIXME("(%p)->(%p)\n", This, p);
2707 return E_NOTIMPL;
2710 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2712 HTMLElement *This = impl_from_IHTMLElement2(iface);
2713 nsAString nsstr;
2714 nsresult nsres;
2716 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2718 if(!This->nselem) {
2719 FIXME("Unsupported for comment nodes.\n");
2720 return S_OK;
2723 nsAString_InitDepend(&nsstr, v);
2724 nsres = nsIDOMHTMLElement_SetDir(This->nselem, &nsstr);
2725 nsAString_Finish(&nsstr);
2726 if(NS_FAILED(nsres)) {
2727 ERR("SetDir failed: %08x\n", nsres);
2728 return E_FAIL;
2731 return S_OK;
2734 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2736 HTMLElement *This = impl_from_IHTMLElement2(iface);
2737 nsAString dir_str;
2738 nsresult nsres;
2740 TRACE("(%p)->(%p)\n", This, p);
2742 if(!This->nselem) {
2743 *p = NULL;
2744 return S_OK;
2747 nsAString_Init(&dir_str, NULL);
2748 nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
2749 return return_nsstr(nsres, &dir_str, p);
2752 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2754 HTMLElement *This = impl_from_IHTMLElement2(iface);
2755 FIXME("(%p)->(%p)\n", This, range);
2756 return E_NOTIMPL;
2759 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2761 HTMLElement *This = impl_from_IHTMLElement2(iface);
2762 nsresult nsres;
2764 TRACE("(%p)->(%p)\n", This, p);
2766 nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, p);
2767 assert(nsres == NS_OK);
2769 TRACE("*p = %d\n", *p);
2770 return S_OK;
2773 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2775 HTMLElement *This = impl_from_IHTMLElement2(iface);
2776 nsresult nsres;
2778 TRACE("(%p)->(%p)\n", This, p);
2780 nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, p);
2781 assert(nsres == NS_OK);
2783 TRACE("*p = %d\n", *p);
2784 return S_OK;
2787 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2789 HTMLElement *This = impl_from_IHTMLElement2(iface);
2791 TRACE("(%p)->(%d)\n", This, v);
2793 if(!This->nselem) {
2794 FIXME("NULL nselem\n");
2795 return E_NOTIMPL;
2798 nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
2799 return S_OK;
2802 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2804 HTMLElement *This = impl_from_IHTMLElement2(iface);
2805 nsresult nsres;
2807 TRACE("(%p)->(%p)\n", This, p);
2809 nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, p);
2810 assert(nsres == NS_OK);
2812 TRACE("*p = %d\n", *p);
2813 return S_OK;
2816 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2818 HTMLElement *This = impl_from_IHTMLElement2(iface);
2820 TRACE("(%p)->(%d)\n", This, v);
2822 if(!This->nselem) {
2823 FIXME("NULL nselem\n");
2824 return E_NOTIMPL;
2827 nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
2828 return S_OK;
2831 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2833 HTMLElement *This = impl_from_IHTMLElement2(iface);
2834 nsresult nsres;
2836 TRACE("(%p)->(%p)\n", This, p);
2838 if(!p)
2839 return E_INVALIDARG;
2841 if(!This->nselem)
2843 FIXME("NULL nselem\n");
2844 return E_NOTIMPL;
2847 nsres = nsIDOMHTMLElement_GetScrollLeft(This->nselem, p);
2848 assert(nsres == NS_OK);
2850 TRACE("*p = %d\n", *p);
2851 return S_OK;
2854 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
2856 HTMLElement *This = impl_from_IHTMLElement2(iface);
2857 FIXME("(%p)\n", This);
2858 return E_NOTIMPL;
2861 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
2863 HTMLElement *This = impl_from_IHTMLElement2(iface);
2864 FIXME("(%p)->(%p)\n", This, mergeThis);
2865 return E_NOTIMPL;
2868 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
2870 HTMLElement *This = impl_from_IHTMLElement2(iface);
2871 FIXME("(%p)->()\n", This);
2872 return E_NOTIMPL;
2875 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
2877 HTMLElement *This = impl_from_IHTMLElement2(iface);
2878 FIXME("(%p)->(%p)\n", This, p);
2879 return E_NOTIMPL;
2882 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
2883 IHTMLElement *insertedElement, IHTMLElement **inserted)
2885 HTMLElement *This = impl_from_IHTMLElement2(iface);
2886 HTMLDOMNode *ret_node;
2887 HTMLElement *elem;
2888 HRESULT hres;
2890 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
2892 elem = unsafe_impl_from_IHTMLElement(insertedElement);
2893 if(!elem)
2894 return E_INVALIDARG;
2896 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
2897 if(FAILED(hres))
2898 return hres;
2900 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
2901 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
2902 return hres;
2905 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
2906 BSTR where, IHTMLElement **applied)
2908 HTMLElement *This = impl_from_IHTMLElement2(iface);
2909 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
2910 return E_NOTIMPL;
2913 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
2915 HTMLElement *This = impl_from_IHTMLElement2(iface);
2916 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
2917 return E_NOTIMPL;
2920 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
2921 BSTR newText, BSTR *oldText)
2923 HTMLElement *This = impl_from_IHTMLElement2(iface);
2924 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
2925 return E_NOTIMPL;
2928 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
2930 HTMLElement *This = impl_from_IHTMLElement2(iface);
2931 FIXME("(%p)->(%p)\n", This, p);
2932 return E_NOTIMPL;
2935 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
2936 VARIANT *pvarFactory, LONG *pCookie)
2938 HTMLElement *This = impl_from_IHTMLElement2(iface);
2939 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
2940 return E_NOTIMPL;
2943 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
2944 VARIANT_BOOL *pfResult)
2946 HTMLElement *This = impl_from_IHTMLElement2(iface);
2947 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
2948 return E_NOTIMPL;
2951 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
2953 HTMLElement *This = impl_from_IHTMLElement2(iface);
2955 FIXME("(%p)->(%p): hack\n", This, p);
2957 /* We can't implement correct behavior on top of Gecko (although we could
2958 try a bit harder). Making runtimeStyle behave like regular style is
2959 enough for most use cases. */
2960 if(!This->runtime_style) {
2961 HRESULT hres;
2963 hres = HTMLStyle_Create(This, &This->runtime_style);
2964 if(FAILED(hres))
2965 return hres;
2968 *p = &This->runtime_style->IHTMLStyle_iface;
2969 IHTMLStyle_AddRef(*p);
2970 return S_OK;
2973 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
2975 HTMLElement *This = impl_from_IHTMLElement2(iface);
2976 FIXME("(%p)->(%p)\n", This, p);
2977 return E_NOTIMPL;
2980 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
2982 HTMLElement *This = impl_from_IHTMLElement2(iface);
2983 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2984 return E_NOTIMPL;
2987 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
2989 HTMLElement *This = impl_from_IHTMLElement2(iface);
2990 FIXME("(%p)->(%p)\n", This, p);
2991 return E_NOTIMPL;
2994 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
2996 HTMLElement *This = impl_from_IHTMLElement2(iface);
2997 FIXME("(%p)->()\n", This);
2998 return E_NOTIMPL;
3001 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
3003 HTMLElement *This = impl_from_IHTMLElement2(iface);
3004 FIXME("(%p)->(%p)\n", This, p);
3005 return E_NOTIMPL;
3008 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
3010 HTMLElement *This = impl_from_IHTMLElement2(iface);
3011 FIXME("(%p)->(%p)\n", This, p);
3012 return E_NOTIMPL;
3015 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
3016 IHTMLElementCollection **pelColl)
3018 HTMLElement *This = impl_from_IHTMLElement2(iface);
3019 nsIDOMHTMLCollection *nscol;
3020 nsAString tag_str;
3021 nsresult nsres;
3023 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
3025 nsAString_InitDepend(&tag_str, v);
3026 nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nscol);
3027 nsAString_Finish(&tag_str);
3028 if(NS_FAILED(nsres)) {
3029 ERR("GetElementByTagName failed: %08x\n", nsres);
3030 return E_FAIL;
3033 *pelColl = create_collection_from_htmlcol(This->node.doc, nscol);
3034 nsIDOMHTMLCollection_Release(nscol);
3035 return S_OK;
3038 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
3039 HTMLElement2_QueryInterface,
3040 HTMLElement2_AddRef,
3041 HTMLElement2_Release,
3042 HTMLElement2_GetTypeInfoCount,
3043 HTMLElement2_GetTypeInfo,
3044 HTMLElement2_GetIDsOfNames,
3045 HTMLElement2_Invoke,
3046 HTMLElement2_get_scopeName,
3047 HTMLElement2_setCapture,
3048 HTMLElement2_releaseCapture,
3049 HTMLElement2_put_onlosecapture,
3050 HTMLElement2_get_onlosecapture,
3051 HTMLElement2_componentFromPoint,
3052 HTMLElement2_doScroll,
3053 HTMLElement2_put_onscroll,
3054 HTMLElement2_get_onscroll,
3055 HTMLElement2_put_ondrag,
3056 HTMLElement2_get_ondrag,
3057 HTMLElement2_put_ondragend,
3058 HTMLElement2_get_ondragend,
3059 HTMLElement2_put_ondragenter,
3060 HTMLElement2_get_ondragenter,
3061 HTMLElement2_put_ondragover,
3062 HTMLElement2_get_ondragover,
3063 HTMLElement2_put_ondragleave,
3064 HTMLElement2_get_ondragleave,
3065 HTMLElement2_put_ondrop,
3066 HTMLElement2_get_ondrop,
3067 HTMLElement2_put_onbeforecut,
3068 HTMLElement2_get_onbeforecut,
3069 HTMLElement2_put_oncut,
3070 HTMLElement2_get_oncut,
3071 HTMLElement2_put_onbeforecopy,
3072 HTMLElement2_get_onbeforecopy,
3073 HTMLElement2_put_oncopy,
3074 HTMLElement2_get_oncopy,
3075 HTMLElement2_put_onbeforepaste,
3076 HTMLElement2_get_onbeforepaste,
3077 HTMLElement2_put_onpaste,
3078 HTMLElement2_get_onpaste,
3079 HTMLElement2_get_currentStyle,
3080 HTMLElement2_put_onpropertychange,
3081 HTMLElement2_get_onpropertychange,
3082 HTMLElement2_getClientRects,
3083 HTMLElement2_getBoundingClientRect,
3084 HTMLElement2_setExpression,
3085 HTMLElement2_getExpression,
3086 HTMLElement2_removeExpression,
3087 HTMLElement2_put_tabIndex,
3088 HTMLElement2_get_tabIndex,
3089 HTMLElement2_focus,
3090 HTMLElement2_put_accessKey,
3091 HTMLElement2_get_accessKey,
3092 HTMLElement2_put_onblur,
3093 HTMLElement2_get_onblur,
3094 HTMLElement2_put_onfocus,
3095 HTMLElement2_get_onfocus,
3096 HTMLElement2_put_onresize,
3097 HTMLElement2_get_onresize,
3098 HTMLElement2_blur,
3099 HTMLElement2_addFilter,
3100 HTMLElement2_removeFilter,
3101 HTMLElement2_get_clientHeight,
3102 HTMLElement2_get_clientWidth,
3103 HTMLElement2_get_clientTop,
3104 HTMLElement2_get_clientLeft,
3105 HTMLElement2_attachEvent,
3106 HTMLElement2_detachEvent,
3107 HTMLElement2_get_readyState,
3108 HTMLElement2_put_onreadystatechange,
3109 HTMLElement2_get_onreadystatechange,
3110 HTMLElement2_put_onrowsdelete,
3111 HTMLElement2_get_onrowsdelete,
3112 HTMLElement2_put_onrowsinserted,
3113 HTMLElement2_get_onrowsinserted,
3114 HTMLElement2_put_oncellchange,
3115 HTMLElement2_get_oncellchange,
3116 HTMLElement2_put_dir,
3117 HTMLElement2_get_dir,
3118 HTMLElement2_createControlRange,
3119 HTMLElement2_get_scrollHeight,
3120 HTMLElement2_get_scrollWidth,
3121 HTMLElement2_put_scrollTop,
3122 HTMLElement2_get_scrollTop,
3123 HTMLElement2_put_scrollLeft,
3124 HTMLElement2_get_scrollLeft,
3125 HTMLElement2_clearAttributes,
3126 HTMLElement2_mergeAttributes,
3127 HTMLElement2_put_oncontextmenu,
3128 HTMLElement2_get_oncontextmenu,
3129 HTMLElement2_insertAdjacentElement,
3130 HTMLElement2_applyElement,
3131 HTMLElement2_getAdjacentText,
3132 HTMLElement2_replaceAdjacentText,
3133 HTMLElement2_get_canHandleChildren,
3134 HTMLElement2_addBehavior,
3135 HTMLElement2_removeBehavior,
3136 HTMLElement2_get_runtimeStyle,
3137 HTMLElement2_get_behaviorUrns,
3138 HTMLElement2_put_tagUrn,
3139 HTMLElement2_get_tagUrn,
3140 HTMLElement2_put_onbeforeeditfocus,
3141 HTMLElement2_get_onbeforeeditfocus,
3142 HTMLElement2_get_readyStateValue,
3143 HTMLElement2_getElementsByTagName,
3146 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3148 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3151 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3152 REFIID riid, void **ppv)
3154 HTMLElement *This = impl_from_IHTMLElement3(iface);
3155 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3158 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3160 HTMLElement *This = impl_from_IHTMLElement3(iface);
3161 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3164 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3166 HTMLElement *This = impl_from_IHTMLElement3(iface);
3167 return IHTMLElement_Release(&This->IHTMLElement_iface);
3170 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3172 HTMLElement *This = impl_from_IHTMLElement3(iface);
3173 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3176 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3177 LCID lcid, ITypeInfo **ppTInfo)
3179 HTMLElement *This = impl_from_IHTMLElement3(iface);
3180 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3183 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3184 LPOLESTR *rgszNames, UINT cNames,
3185 LCID lcid, DISPID *rgDispId)
3187 HTMLElement *This = impl_from_IHTMLElement3(iface);
3188 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3189 lcid, rgDispId);
3192 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3193 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3194 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3196 HTMLElement *This = impl_from_IHTMLElement3(iface);
3197 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3198 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3201 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3203 HTMLElement *This = impl_from_IHTMLElement3(iface);
3204 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3205 return E_NOTIMPL;
3208 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3210 HTMLElement *This = impl_from_IHTMLElement3(iface);
3211 FIXME("(%p)->(%p)\n", This, p);
3212 return E_NOTIMPL;
3215 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3217 HTMLElement *This = impl_from_IHTMLElement3(iface);
3218 FIXME("(%p)->(%p)\n", This, p);
3219 return E_NOTIMPL;
3222 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3224 HTMLElement *This = impl_from_IHTMLElement3(iface);
3225 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3226 return E_NOTIMPL;
3229 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3231 HTMLElement *This = impl_from_IHTMLElement3(iface);
3232 FIXME("(%p)->(%p)\n", This, p);
3233 return E_NOTIMPL;
3236 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3238 HTMLElement *This = impl_from_IHTMLElement3(iface);
3239 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3240 return E_NOTIMPL;
3243 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3245 HTMLElement *This = impl_from_IHTMLElement3(iface);
3246 FIXME("(%p)->(%p)\n", This, p);
3247 return E_NOTIMPL;
3250 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3252 HTMLElement *This = impl_from_IHTMLElement3(iface);
3253 FIXME("(%p)->(%x)\n", This, v);
3254 return E_NOTIMPL;
3257 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3259 HTMLElement *This = impl_from_IHTMLElement3(iface);
3260 FIXME("(%p)->(%p)\n", This, p);
3261 return E_NOTIMPL;
3264 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3266 HTMLElement *This = impl_from_IHTMLElement3(iface);
3267 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3268 return E_NOTIMPL;
3271 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3273 HTMLElement *This = impl_from_IHTMLElement3(iface);
3274 FIXME("(%p)->(%p)\n", This, p);
3275 return E_NOTIMPL;
3278 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3280 HTMLElement *This = impl_from_IHTMLElement3(iface);
3281 FIXME("(%p)\n", This);
3282 return E_NOTIMPL;
3285 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3287 HTMLElement *This = impl_from_IHTMLElement3(iface);
3288 nsresult nsres;
3289 nsAString str;
3291 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3293 nsAString_InitDepend(&str, v);
3294 nsres = nsIDOMHTMLElement_SetContentEditable(This->nselem, &str);
3295 nsAString_Finish(&str);
3297 if (NS_FAILED(nsres)){
3298 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3299 return E_FAIL;
3302 return S_OK;
3305 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3307 HTMLElement *This = impl_from_IHTMLElement3(iface);
3308 nsresult nsres;
3309 nsAString str;
3311 TRACE("(%p)->(%p)\n", This, p);
3313 nsAString_Init(&str, NULL);
3314 nsres = nsIDOMHTMLElement_GetContentEditable(This->nselem, &str);
3315 return return_nsstr(nsres, &str, p);
3318 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3320 HTMLElement *This = impl_from_IHTMLElement3(iface);
3321 FIXME("(%p)->(%p)\n", This, p);
3322 return E_NOTIMPL;
3325 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3327 HTMLElement *This = impl_from_IHTMLElement3(iface);
3328 FIXME("(%p)->(%x)\n", This, v);
3329 return E_NOTIMPL;
3332 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3334 HTMLElement *This = impl_from_IHTMLElement3(iface);
3335 FIXME("(%p)->(%p)\n", This, p);
3336 return E_NOTIMPL;
3339 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3341 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3343 HTMLElement *This = impl_from_IHTMLElement3(iface);
3344 VARIANT *var;
3345 HRESULT hres;
3347 TRACE("(%p)->(%x)\n", This, v);
3349 if(This->node.vtbl->put_disabled)
3350 return This->node.vtbl->put_disabled(&This->node, v);
3352 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3353 if(FAILED(hres))
3354 return hres;
3356 VariantClear(var);
3357 V_VT(var) = VT_BOOL;
3358 V_BOOL(var) = v;
3359 return S_OK;
3362 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3364 HTMLElement *This = impl_from_IHTMLElement3(iface);
3365 VARIANT *var;
3366 HRESULT hres;
3368 TRACE("(%p)->(%p)\n", This, p);
3370 if(This->node.vtbl->get_disabled)
3371 return This->node.vtbl->get_disabled(&This->node, p);
3373 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3374 if(hres == DISP_E_UNKNOWNNAME) {
3375 *p = VARIANT_FALSE;
3376 return S_OK;
3378 if(FAILED(hres))
3379 return hres;
3381 if(V_VT(var) != VT_BOOL) {
3382 FIXME("value is %s\n", debugstr_variant(var));
3383 return E_NOTIMPL;
3386 *p = V_BOOL(var);
3387 return S_OK;
3390 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3392 HTMLElement *This = impl_from_IHTMLElement3(iface);
3393 FIXME("(%p)->(%p)\n", This, p);
3394 return E_NOTIMPL;
3397 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3399 HTMLElement *This = impl_from_IHTMLElement3(iface);
3400 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3401 return E_NOTIMPL;
3404 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3406 HTMLElement *This = impl_from_IHTMLElement3(iface);
3407 FIXME("(%p)->(%p)\n", This, p);
3408 return E_NOTIMPL;
3411 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3413 HTMLElement *This = impl_from_IHTMLElement3(iface);
3414 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3415 return E_NOTIMPL;
3418 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3420 HTMLElement *This = impl_from_IHTMLElement3(iface);
3421 FIXME("(%p)->(%p)\n", This, p);
3422 return E_NOTIMPL;
3425 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3426 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3428 HTMLElement *This = impl_from_IHTMLElement3(iface);
3430 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3431 pfCancelled);
3433 return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3436 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
3438 HTMLElement *This = impl_from_IHTMLElement3(iface);
3439 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3440 return E_NOTIMPL;
3443 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
3445 HTMLElement *This = impl_from_IHTMLElement3(iface);
3446 FIXME("(%p)->(%p)\n", This, p);
3447 return E_NOTIMPL;
3450 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3452 HTMLElement *This = impl_from_IHTMLElement3(iface);
3453 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3454 return E_NOTIMPL;
3457 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3459 HTMLElement *This = impl_from_IHTMLElement3(iface);
3460 FIXME("(%p)->(%p)\n", This, p);
3461 return E_NOTIMPL;
3464 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3466 HTMLElement *This = impl_from_IHTMLElement3(iface);
3467 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3468 return E_NOTIMPL;
3471 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3473 HTMLElement *This = impl_from_IHTMLElement3(iface);
3474 FIXME("(%p)->(%p)\n", This, p);
3475 return E_NOTIMPL;
3478 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3480 HTMLElement *This = impl_from_IHTMLElement3(iface);
3481 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3482 return E_NOTIMPL;
3485 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3487 HTMLElement *This = impl_from_IHTMLElement3(iface);
3488 FIXME("(%p)->(%p)\n", This, p);
3489 return E_NOTIMPL;
3492 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3494 HTMLElement *This = impl_from_IHTMLElement3(iface);
3495 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3496 return E_NOTIMPL;
3499 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3501 HTMLElement *This = impl_from_IHTMLElement3(iface);
3502 FIXME("(%p)->(%p)\n", This, p);
3503 return E_NOTIMPL;
3506 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3508 HTMLElement *This = impl_from_IHTMLElement3(iface);
3509 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3510 return E_NOTIMPL;
3513 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3515 HTMLElement *This = impl_from_IHTMLElement3(iface);
3516 FIXME("(%p)->(%p)\n", This, p);
3517 return E_NOTIMPL;
3520 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3522 HTMLElement *This = impl_from_IHTMLElement3(iface);
3523 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3524 return E_NOTIMPL;
3527 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3529 HTMLElement *This = impl_from_IHTMLElement3(iface);
3530 FIXME("(%p)->(%p)\n", This, p);
3531 return E_NOTIMPL;
3534 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3536 HTMLElement *This = impl_from_IHTMLElement3(iface);
3537 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3538 return E_NOTIMPL;
3541 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3543 HTMLElement *This = impl_from_IHTMLElement3(iface);
3544 FIXME("(%p)->(%p)\n", This, p);
3545 return E_NOTIMPL;
3548 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3550 HTMLElement *This = impl_from_IHTMLElement3(iface);
3551 FIXME("(%p)->(%p)\n", This, pfRet);
3552 return E_NOTIMPL;
3555 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3557 HTMLElement *This = impl_from_IHTMLElement3(iface);
3558 FIXME("(%p)->(%p)\n", This, p);
3559 return E_NOTIMPL;
3562 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3563 HTMLElement3_QueryInterface,
3564 HTMLElement3_AddRef,
3565 HTMLElement3_Release,
3566 HTMLElement3_GetTypeInfoCount,
3567 HTMLElement3_GetTypeInfo,
3568 HTMLElement3_GetIDsOfNames,
3569 HTMLElement3_Invoke,
3570 HTMLElement3_mergeAttributes,
3571 HTMLElement3_get_isMultiLine,
3572 HTMLElement3_get_canHaveHTML,
3573 HTMLElement3_put_onlayoutcomplete,
3574 HTMLElement3_get_onlayoutcomplete,
3575 HTMLElement3_put_onpage,
3576 HTMLElement3_get_onpage,
3577 HTMLElement3_put_inflateBlock,
3578 HTMLElement3_get_inflateBlock,
3579 HTMLElement3_put_onbeforedeactivate,
3580 HTMLElement3_get_onbeforedeactivate,
3581 HTMLElement3_setActive,
3582 HTMLElement3_put_contentEditable,
3583 HTMLElement3_get_contentEditable,
3584 HTMLElement3_get_isContentEditable,
3585 HTMLElement3_put_hideFocus,
3586 HTMLElement3_get_hideFocus,
3587 HTMLElement3_put_disabled,
3588 HTMLElement3_get_disabled,
3589 HTMLElement3_get_isDisabled,
3590 HTMLElement3_put_onmove,
3591 HTMLElement3_get_onmove,
3592 HTMLElement3_put_oncontrolselect,
3593 HTMLElement3_get_oncontrolselect,
3594 HTMLElement3_fireEvent,
3595 HTMLElement3_put_onresizestart,
3596 HTMLElement3_get_onresizestart,
3597 HTMLElement3_put_onresizeend,
3598 HTMLElement3_get_onresizeend,
3599 HTMLElement3_put_onmovestart,
3600 HTMLElement3_get_onmovestart,
3601 HTMLElement3_put_onmoveend,
3602 HTMLElement3_get_onmoveend,
3603 HTMLElement3_put_onmousecenter,
3604 HTMLElement3_get_onmousecenter,
3605 HTMLElement3_put_onmouseleave,
3606 HTMLElement3_get_onmouseleave,
3607 HTMLElement3_put_onactivate,
3608 HTMLElement3_get_onactivate,
3609 HTMLElement3_put_ondeactivate,
3610 HTMLElement3_get_ondeactivate,
3611 HTMLElement3_dragDrop,
3612 HTMLElement3_get_glyphMode
3615 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3617 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3620 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3621 REFIID riid, void **ppv)
3623 HTMLElement *This = impl_from_IHTMLElement4(iface);
3624 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3627 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3629 HTMLElement *This = impl_from_IHTMLElement4(iface);
3630 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3633 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3635 HTMLElement *This = impl_from_IHTMLElement4(iface);
3636 return IHTMLElement_Release(&This->IHTMLElement_iface);
3639 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3641 HTMLElement *This = impl_from_IHTMLElement4(iface);
3642 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3645 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3646 LCID lcid, ITypeInfo **ppTInfo)
3648 HTMLElement *This = impl_from_IHTMLElement4(iface);
3649 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3652 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3653 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3655 HTMLElement *This = impl_from_IHTMLElement4(iface);
3656 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3657 lcid, rgDispId);
3660 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3661 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3663 HTMLElement *This = impl_from_IHTMLElement4(iface);
3664 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3665 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3668 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3670 HTMLElement *This = impl_from_IHTMLElement4(iface);
3672 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3674 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3677 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3679 HTMLElement *This = impl_from_IHTMLElement4(iface);
3681 TRACE("(%p)->(%p)\n", This, p);
3683 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3686 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3688 HTMLElement *This = impl_from_IHTMLElement4(iface);
3689 FIXME("(%p)\n", This);
3690 return E_NOTIMPL;
3693 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3695 HTMLElement *This = impl_from_IHTMLElement4(iface);
3696 HTMLAttributeCollection *attrs;
3697 HRESULT hres;
3699 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3701 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3702 if(FAILED(hres))
3703 return hres;
3705 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3706 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3707 return hres;
3710 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3711 IHTMLDOMAttribute **ppretAttribute)
3713 HTMLElement *This = impl_from_IHTMLElement4(iface);
3714 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3715 return E_NOTIMPL;
3718 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3719 IHTMLDOMAttribute **ppretAttribute)
3721 HTMLElement *This = impl_from_IHTMLElement4(iface);
3722 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3723 return E_NOTIMPL;
3726 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3728 HTMLElement *This = impl_from_IHTMLElement4(iface);
3729 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3730 return E_NOTIMPL;
3733 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3735 HTMLElement *This = impl_from_IHTMLElement4(iface);
3736 FIXME("(%p)->(%p)\n", This, p);
3737 return E_NOTIMPL;
3740 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3742 HTMLElement *This = impl_from_IHTMLElement4(iface);
3744 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3746 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3749 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3751 HTMLElement *This = impl_from_IHTMLElement4(iface);
3753 TRACE("(%p)->(%p)\n", This, p);
3755 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3758 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3760 HTMLElement *This = impl_from_IHTMLElement4(iface);
3761 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3762 return E_NOTIMPL;
3765 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3767 HTMLElement *This = impl_from_IHTMLElement4(iface);
3768 FIXME("(%p)->(%p)\n", This, p);
3769 return E_NOTIMPL;
3772 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3773 HTMLElement4_QueryInterface,
3774 HTMLElement4_AddRef,
3775 HTMLElement4_Release,
3776 HTMLElement4_GetTypeInfoCount,
3777 HTMLElement4_GetTypeInfo,
3778 HTMLElement4_GetIDsOfNames,
3779 HTMLElement4_Invoke,
3780 HTMLElement4_put_onmousewheel,
3781 HTMLElement4_get_onmousewheel,
3782 HTMLElement4_normalize,
3783 HTMLElement4_getAttributeNode,
3784 HTMLElement4_setAttributeNode,
3785 HTMLElement4_removeAttributeNode,
3786 HTMLElement4_put_onbeforeactivate,
3787 HTMLElement4_get_onbeforeactivate,
3788 HTMLElement4_put_onfocusin,
3789 HTMLElement4_get_onfocusin,
3790 HTMLElement4_put_onfocusout,
3791 HTMLElement4_get_onfocusout
3794 static inline HTMLElement *impl_from_IHTMLUniqueName(IHTMLUniqueName *iface)
3796 return CONTAINING_RECORD(iface, HTMLElement, IHTMLUniqueName_iface);
3799 static HRESULT WINAPI HTMLUniqueName_QueryInterface(IHTMLUniqueName *iface, REFIID riid, void **ppv)
3801 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3802 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3805 static ULONG WINAPI HTMLUniqueName_AddRef(IHTMLUniqueName *iface)
3807 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3808 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3811 static ULONG WINAPI HTMLUniqueName_Release(IHTMLUniqueName *iface)
3813 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3814 return IHTMLElement_Release(&This->IHTMLElement_iface);
3817 static HRESULT WINAPI HTMLUniqueName_GetTypeInfoCount(IHTMLUniqueName *iface, UINT *pctinfo)
3819 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3820 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3823 static HRESULT WINAPI HTMLUniqueName_GetTypeInfo(IHTMLUniqueName *iface, UINT iTInfo,
3824 LCID lcid, ITypeInfo **ppTInfo)
3826 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3827 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3830 static HRESULT WINAPI HTMLUniqueName_GetIDsOfNames(IHTMLUniqueName *iface, REFIID riid,
3831 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3833 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3834 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3835 lcid, rgDispId);
3838 static HRESULT WINAPI HTMLUniqueName_Invoke(IHTMLUniqueName *iface, DISPID dispIdMember, REFIID riid,
3839 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3841 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3842 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3843 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3846 HRESULT elem_unique_id(unsigned id, BSTR *p)
3848 WCHAR buf[32];
3850 static const WCHAR formatW[] = {'m','s','_','_','i','d','%','u',0};
3852 sprintfW(buf, formatW, id);
3853 *p = SysAllocString(buf);
3854 return *p ? S_OK : E_OUTOFMEMORY;
3857 static void ensure_unique_id(HTMLElement *elem)
3859 if(!elem->unique_id)
3860 elem->unique_id = ++elem->node.doc->unique_id;
3863 static HRESULT WINAPI HTMLUniqueName_get_uniqueNumber(IHTMLUniqueName *iface, LONG *p)
3865 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3867 TRACE("(%p)->(%p)\n", This, p);
3869 ensure_unique_id(This);
3870 *p = This->unique_id;
3871 return S_OK;
3874 static HRESULT WINAPI HTMLUniqueName_get_uniqueID(IHTMLUniqueName *iface, BSTR *p)
3876 HTMLElement *This = impl_from_IHTMLUniqueName(iface);
3878 TRACE("(%p)->(%p)\n", This, p);
3880 ensure_unique_id(This);
3881 return elem_unique_id(This->unique_id, p);
3884 static const IHTMLUniqueNameVtbl HTMLUniqueNameVtbl = {
3885 HTMLUniqueName_QueryInterface,
3886 HTMLUniqueName_AddRef,
3887 HTMLUniqueName_Release,
3888 HTMLUniqueName_GetTypeInfoCount,
3889 HTMLUniqueName_GetTypeInfo,
3890 HTMLUniqueName_GetIDsOfNames,
3891 HTMLUniqueName_Invoke,
3892 HTMLUniqueName_get_uniqueNumber,
3893 HTMLUniqueName_get_uniqueID
3896 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
3898 return CONTAINING_RECORD(iface, HTMLElement, node);
3901 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
3903 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3905 if(IsEqualGUID(&IID_IUnknown, riid)) {
3906 *ppv = &This->IHTMLElement_iface;
3907 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
3908 *ppv = &This->IHTMLElement_iface;
3909 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
3910 *ppv = &This->IHTMLElement_iface;
3911 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
3912 *ppv = &This->IHTMLElement2_iface;
3913 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
3914 *ppv = &This->IHTMLElement3_iface;
3915 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
3916 *ppv = &This->IHTMLElement4_iface;
3917 }else if(IsEqualGUID(&IID_IHTMLUniqueName, riid)) {
3918 *ppv = &This->IHTMLUniqueName_iface;
3919 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
3920 *ppv = &This->cp_container.IConnectionPointContainer_iface;
3921 }else {
3922 return HTMLDOMNode_QI(&This->node, riid, ppv);
3925 IUnknown_AddRef((IUnknown*)*ppv);
3926 return S_OK;
3929 void HTMLElement_destructor(HTMLDOMNode *iface)
3931 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3933 ConnectionPointContainer_Destroy(&This->cp_container);
3935 if(This->style) {
3936 This->style->elem = NULL;
3937 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
3939 if(This->runtime_style) {
3940 This->runtime_style->elem = NULL;
3941 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
3943 if(This->attrs) {
3944 HTMLDOMAttribute *attr;
3946 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
3947 attr->elem = NULL;
3949 This->attrs->elem = NULL;
3950 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
3953 heap_free(This->filter);
3955 HTMLDOMNode_destructor(&This->node);
3958 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
3960 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3961 HTMLElement *new_elem;
3962 HRESULT hres;
3964 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
3965 if(FAILED(hres))
3966 return hres;
3968 if(This->filter) {
3969 new_elem->filter = heap_strdupW(This->filter);
3970 if(!new_elem->filter) {
3971 IHTMLElement_Release(&This->IHTMLElement_iface);
3972 return E_OUTOFMEMORY;
3976 *ret = &new_elem->node;
3977 return S_OK;
3980 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
3982 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3984 switch(eid) {
3985 case EVENTID_KEYDOWN: {
3986 nsIDOMKeyEvent *key_event;
3987 nsresult nsres;
3989 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
3990 if(NS_SUCCEEDED(nsres)) {
3991 UINT32 code = 0;
3993 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
3995 switch(code) {
3996 case VK_F1: /* DOM_VK_F1 */
3997 TRACE("F1 pressed\n");
3998 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
3999 *prevent_default = TRUE;
4002 nsIDOMKeyEvent_Release(key_event);
4007 return S_OK;
4010 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
4012 const cpc_entry_t HTMLElement_cpc[] = {
4013 HTMLELEMENT_CPC,
4014 {NULL}
4017 static const NodeImplVtbl HTMLElementImplVtbl = {
4018 HTMLElement_QI,
4019 HTMLElement_destructor,
4020 HTMLElement_cpc,
4021 HTMLElement_clone,
4022 HTMLElement_handle_event,
4023 HTMLElement_get_attr_col
4026 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
4028 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
4031 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
4032 DWORD grfdex, DISPID *pid)
4034 HTMLElement *This = impl_from_DispatchEx(dispex);
4036 if(This->node.vtbl->get_dispid)
4037 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
4039 return DISP_E_UNKNOWNNAME;
4042 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4043 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
4044 IServiceProvider *caller)
4046 HTMLElement *This = impl_from_DispatchEx(dispex);
4048 if(This->node.vtbl->invoke)
4049 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
4050 params, res, ei, caller);
4052 ERR("(%p): element has no invoke method\n", This);
4053 return E_NOTIMPL;
4056 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
4058 HTMLElement *This = impl_from_DispatchEx(dispex);
4059 nsIDOMMozNamedAttrMap *attrs;
4060 nsIDOMAttr *attr;
4061 nsAString nsstr;
4062 const PRUnichar *str;
4063 BSTR name;
4064 VARIANT value;
4065 unsigned i;
4066 UINT32 len;
4067 DISPID id;
4068 nsresult nsres;
4069 HRESULT hres;
4071 if(!This->nselem)
4072 return S_FALSE;
4074 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
4075 if(NS_FAILED(nsres))
4076 return E_FAIL;
4078 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
4079 if(NS_FAILED(nsres)) {
4080 nsIDOMMozNamedAttrMap_Release(attrs);
4081 return E_FAIL;
4084 nsAString_Init(&nsstr, NULL);
4085 for(i=0; i<len; i++) {
4086 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
4087 if(NS_FAILED(nsres))
4088 continue;
4090 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
4091 if(NS_FAILED(nsres)) {
4092 nsIDOMAttr_Release(attr);
4093 continue;
4096 nsAString_GetData(&nsstr, &str);
4097 name = SysAllocString(str);
4098 if(!name) {
4099 nsIDOMAttr_Release(attr);
4100 continue;
4103 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
4104 if(hres != DISP_E_UNKNOWNNAME) {
4105 nsIDOMAttr_Release(attr);
4106 SysFreeString(name);
4107 continue;
4110 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
4111 nsIDOMAttr_Release(attr);
4112 if(NS_FAILED(nsres)) {
4113 SysFreeString(name);
4114 continue;
4117 nsAString_GetData(&nsstr, &str);
4118 V_VT(&value) = VT_BSTR;
4119 if(*str) {
4120 V_BSTR(&value) = SysAllocString(str);
4121 if(!V_BSTR(&value)) {
4122 SysFreeString(name);
4123 continue;
4125 } else
4126 V_BSTR(&value) = NULL;
4128 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
4129 SysFreeString(name);
4130 VariantClear(&value);
4132 nsAString_Finish(&nsstr);
4134 nsIDOMMozNamedAttrMap_Release(attrs);
4135 return S_OK;
4138 static event_target_t **HTMLElement_get_event_target_ptr(DispatchEx *dispex)
4140 HTMLElement *This = impl_from_DispatchEx(dispex);
4141 return This->node.vtbl->get_event_target_ptr
4142 ? This->node.vtbl->get_event_target_ptr(&This->node)
4143 : &This->node.event_target.ptr;
4146 static void HTMLElement_bind_event(DispatchEx *dispex, int eid)
4148 HTMLElement *This = impl_from_DispatchEx(dispex);
4149 This->node.doc->node.event_target.dispex.data->vtbl->bind_event(&This->node.doc->node.event_target.dispex, eid);
4152 static const tid_t HTMLElement_iface_tids[] = {
4153 HTMLELEMENT_TIDS,
4157 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
4158 NULL,
4159 HTMLElement_get_dispid,
4160 HTMLElement_invoke,
4161 HTMLElement_populate_props,
4162 HTMLElement_get_event_target_ptr,
4163 HTMLElement_bind_event
4166 static dispex_static_data_t HTMLElement_dispex = {
4167 &HTMLElement_dispex_vtbl,
4168 DispHTMLUnknownElement_tid,
4169 NULL,
4170 HTMLElement_iface_tids
4173 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
4175 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
4176 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
4177 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
4178 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
4179 This->IHTMLUniqueName_iface.lpVtbl = &HTMLUniqueNameVtbl;
4181 if(dispex_data && !dispex_data->vtbl)
4182 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
4183 init_dispex(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
4184 dispex_data ? dispex_data : &HTMLElement_dispex);
4186 if(nselem) {
4187 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
4189 /* No AddRef, share reference with HTMLDOMNode */
4190 assert((nsIDOMNode*)nselem == This->node.nsnode);
4191 This->nselem = nselem;
4194 This->node.cp_container = &This->cp_container;
4195 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
4198 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
4200 nsIDOMHTMLElement *nselem;
4201 nsAString class_name_str;
4202 const PRUnichar *class_name;
4203 const tag_desc_t *tag;
4204 HTMLElement *elem;
4205 nsresult nsres;
4206 HRESULT hres;
4208 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
4209 if(NS_FAILED(nsres))
4210 return E_FAIL;
4212 nsAString_Init(&class_name_str, NULL);
4213 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
4215 nsAString_GetData(&class_name_str, &class_name);
4217 tag = get_tag_desc(class_name);
4218 if(tag) {
4219 hres = tag->constructor(doc, nselem, &elem);
4220 }else if(use_generic) {
4221 hres = HTMLGenericElement_Create(doc, nselem, &elem);
4222 }else {
4223 elem = heap_alloc_zero(sizeof(HTMLElement));
4224 if(elem) {
4225 elem->node.vtbl = &HTMLElementImplVtbl;
4226 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
4227 hres = S_OK;
4228 }else {
4229 hres = E_OUTOFMEMORY;
4233 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
4235 nsIDOMHTMLElement_Release(nselem);
4236 nsAString_Finish(&class_name_str);
4237 if(FAILED(hres))
4238 return hres;
4240 *ret = elem;
4241 return S_OK;
4244 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
4246 HTMLDOMNode *node;
4247 HRESULT hres;
4249 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
4250 if(FAILED(hres))
4251 return hres;
4253 *ret = impl_from_HTMLDOMNode(node);
4254 return S_OK;
4257 /* interface IHTMLFiltersCollection */
4258 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
4260 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4262 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
4264 if(IsEqualGUID(&IID_IUnknown, riid)) {
4265 *ppv = &This->IHTMLFiltersCollection_iface;
4266 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
4267 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
4268 *ppv = &This->IHTMLFiltersCollection_iface;
4269 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4270 return *ppv ? S_OK : E_NOINTERFACE;
4271 }else {
4272 *ppv = NULL;
4273 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4274 return E_NOINTERFACE;
4277 IUnknown_AddRef((IUnknown*)*ppv);
4278 return S_OK;
4281 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
4283 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4284 LONG ref = InterlockedIncrement(&This->ref);
4286 TRACE("(%p) ref=%d\n", This, ref);
4288 return ref;
4291 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
4293 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4294 LONG ref = InterlockedDecrement(&This->ref);
4296 TRACE("(%p) ref=%d\n", This, ref);
4298 if(!ref)
4300 heap_free(This);
4303 return ref;
4306 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
4308 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4309 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4312 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
4313 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
4315 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4316 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4319 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
4320 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
4321 LCID lcid, DISPID *rgDispId)
4323 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4324 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4325 lcid, rgDispId);
4328 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
4329 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
4330 EXCEPINFO *pExcepInfo, UINT *puArgErr)
4332 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4333 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4334 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4337 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
4339 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4341 if(!p)
4342 return E_POINTER;
4344 FIXME("(%p)->(%p) Always returning 0\n", This, p);
4345 *p = 0;
4347 return S_OK;
4350 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
4352 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4353 FIXME("(%p)->(%p)\n", This, p);
4354 return E_NOTIMPL;
4357 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
4359 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4360 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
4361 return E_NOTIMPL;
4364 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
4365 HTMLFiltersCollection_QueryInterface,
4366 HTMLFiltersCollection_AddRef,
4367 HTMLFiltersCollection_Release,
4368 HTMLFiltersCollection_GetTypeInfoCount,
4369 HTMLFiltersCollection_GetTypeInfo,
4370 HTMLFiltersCollection_GetIDsOfNames,
4371 HTMLFiltersCollection_Invoke,
4372 HTMLFiltersCollection_get_length,
4373 HTMLFiltersCollection_get__newEnum,
4374 HTMLFiltersCollection_item
4377 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4379 WCHAR *ptr;
4380 int idx = 0;
4382 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
4383 idx = idx*10 + (*ptr-'0');
4384 if(*ptr)
4385 return DISP_E_UNKNOWNNAME;
4387 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
4388 TRACE("ret %x\n", *dispid);
4389 return S_OK;
4392 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4393 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4395 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
4397 V_VT(res) = VT_DISPATCH;
4398 V_DISPATCH(res) = NULL;
4400 FIXME("always returning NULL\n");
4402 return S_OK;
4405 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
4406 NULL,
4407 HTMLFiltersCollection_get_dispid,
4408 HTMLFiltersCollection_invoke,
4409 NULL
4412 static const tid_t HTMLFiltersCollection_iface_tids[] = {
4413 IHTMLFiltersCollection_tid,
4416 static dispex_static_data_t HTMLFiltersCollection_dispex = {
4417 &HTMLFiltersCollection_dispex_vtbl,
4418 IHTMLFiltersCollection_tid,
4419 NULL,
4420 HTMLFiltersCollection_iface_tids
4423 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
4425 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
4427 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
4428 ret->ref = 1;
4430 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
4431 &HTMLFiltersCollection_dispex);
4433 return &ret->IHTMLFiltersCollection_iface;
4436 /* interface IHTMLAttributeCollection */
4437 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
4439 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
4442 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
4444 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4446 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4448 if(IsEqualGUID(&IID_IUnknown, riid)) {
4449 *ppv = &This->IHTMLAttributeCollection_iface;
4450 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
4451 *ppv = &This->IHTMLAttributeCollection_iface;
4452 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
4453 *ppv = &This->IHTMLAttributeCollection2_iface;
4454 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
4455 *ppv = &This->IHTMLAttributeCollection3_iface;
4456 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4457 return *ppv ? S_OK : E_NOINTERFACE;
4458 }else {
4459 *ppv = NULL;
4460 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4461 return E_NOINTERFACE;
4464 IUnknown_AddRef((IUnknown*)*ppv);
4465 return S_OK;
4468 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
4470 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4471 LONG ref = InterlockedIncrement(&This->ref);
4473 TRACE("(%p) ref=%d\n", This, ref);
4475 return ref;
4478 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
4480 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4481 LONG ref = InterlockedDecrement(&This->ref);
4483 TRACE("(%p) ref=%d\n", This, ref);
4485 if(!ref) {
4486 while(!list_empty(&This->attrs)) {
4487 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
4489 list_remove(&attr->entry);
4490 attr->elem = NULL;
4491 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4494 heap_free(This);
4497 return ref;
4500 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
4502 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4503 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4506 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
4507 LCID lcid, ITypeInfo **ppTInfo)
4509 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4510 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4513 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
4514 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4516 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4517 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4518 lcid, rgDispId);
4521 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
4522 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4523 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4525 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4526 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4527 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4530 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
4532 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
4533 DISPID id = DISPID_STARTENUM;
4534 LONG len = -1;
4535 HRESULT hres;
4537 FIXME("filter non-enumerable attributes out\n");
4539 while(1) {
4540 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
4541 if(FAILED(hres))
4542 return hres;
4543 else if(hres == S_FALSE)
4544 break;
4546 len++;
4547 if(len == *idx)
4548 break;
4551 if(dispid) {
4552 *dispid = id;
4553 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
4556 *idx = len+1;
4557 return S_OK;
4560 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
4562 HRESULT hres;
4564 if(name[0]>='0' && name[0]<='9') {
4565 WCHAR *end_ptr;
4566 LONG idx;
4568 idx = strtoulW(name, &end_ptr, 10);
4569 if(!*end_ptr) {
4570 hres = get_attr_dispid_by_idx(This, &idx, id);
4571 if(SUCCEEDED(hres))
4572 return hres;
4576 if(!This->elem) {
4577 WARN("NULL elem\n");
4578 return E_UNEXPECTED;
4581 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
4582 name, fdexNameCaseInsensitive, id);
4583 return hres;
4586 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
4588 HTMLDOMAttribute *iter;
4589 LONG pos = 0;
4590 HRESULT hres;
4592 *attr = NULL;
4593 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4594 if(iter->dispid == id) {
4595 *attr = iter;
4596 break;
4598 pos++;
4601 if(!*attr) {
4602 if(!This->elem) {
4603 WARN("NULL elem\n");
4604 return E_UNEXPECTED;
4607 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
4608 if(FAILED(hres))
4609 return hres;
4612 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
4613 if(list_pos)
4614 *list_pos = pos;
4615 return S_OK;
4618 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
4620 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4621 HRESULT hres;
4623 TRACE("(%p)->(%p)\n", This, p);
4625 *p = -1;
4626 hres = get_attr_dispid_by_idx(This, p, NULL);
4627 return hres;
4630 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
4632 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4633 FIXME("(%p)->(%p)\n", This, p);
4634 return E_NOTIMPL;
4637 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
4639 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4640 HTMLDOMAttribute *attr;
4641 DISPID id;
4642 HRESULT hres;
4644 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
4646 switch(V_VT(name)) {
4647 case VT_I4:
4648 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
4649 break;
4650 case VT_BSTR:
4651 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
4652 break;
4653 default:
4654 FIXME("unsupported name %s\n", debugstr_variant(name));
4655 hres = E_NOTIMPL;
4657 if(hres == DISP_E_UNKNOWNNAME)
4658 return E_INVALIDARG;
4659 if(FAILED(hres))
4660 return hres;
4662 hres = get_domattr(This, id, NULL, &attr);
4663 if(FAILED(hres))
4664 return hres;
4666 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
4667 return S_OK;
4670 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
4671 HTMLAttributeCollection_QueryInterface,
4672 HTMLAttributeCollection_AddRef,
4673 HTMLAttributeCollection_Release,
4674 HTMLAttributeCollection_GetTypeInfoCount,
4675 HTMLAttributeCollection_GetTypeInfo,
4676 HTMLAttributeCollection_GetIDsOfNames,
4677 HTMLAttributeCollection_Invoke,
4678 HTMLAttributeCollection_get_length,
4679 HTMLAttributeCollection__newEnum,
4680 HTMLAttributeCollection_item
4683 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
4685 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
4688 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
4690 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4691 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4694 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
4696 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4697 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4700 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
4702 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4703 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4706 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
4708 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4709 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4712 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
4713 LCID lcid, ITypeInfo **ppTInfo)
4715 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4716 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4719 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
4720 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4722 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4723 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4724 lcid, rgDispId);
4727 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
4728 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4729 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4731 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4732 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4733 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4736 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
4737 IHTMLDOMAttribute **newretNode)
4739 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4740 HTMLDOMAttribute *attr;
4741 DISPID id;
4742 HRESULT hres;
4744 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4746 hres = get_attr_dispid_by_name(This, bstrName, &id);
4747 if(hres == DISP_E_UNKNOWNNAME) {
4748 *newretNode = NULL;
4749 return S_OK;
4750 } else if(FAILED(hres)) {
4751 return hres;
4754 hres = get_domattr(This, id, NULL, &attr);
4755 if(FAILED(hres))
4756 return hres;
4758 *newretNode = &attr->IHTMLDOMAttribute_iface;
4759 return S_OK;
4762 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
4763 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
4765 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4766 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
4767 return E_NOTIMPL;
4770 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
4771 BSTR bstrName, IHTMLDOMAttribute **newretNode)
4773 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4774 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4775 return E_NOTIMPL;
4778 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
4779 HTMLAttributeCollection2_QueryInterface,
4780 HTMLAttributeCollection2_AddRef,
4781 HTMLAttributeCollection2_Release,
4782 HTMLAttributeCollection2_GetTypeInfoCount,
4783 HTMLAttributeCollection2_GetTypeInfo,
4784 HTMLAttributeCollection2_GetIDsOfNames,
4785 HTMLAttributeCollection2_Invoke,
4786 HTMLAttributeCollection2_getNamedItem,
4787 HTMLAttributeCollection2_setNamedItem,
4788 HTMLAttributeCollection2_removeNamedItem
4791 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
4793 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
4796 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
4798 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4799 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4802 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
4804 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4805 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4808 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
4810 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4811 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4814 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
4816 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4817 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4820 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
4821 LCID lcid, ITypeInfo **ppTInfo)
4823 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4824 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4827 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
4828 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4830 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4831 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4832 lcid, rgDispId);
4835 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
4836 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4837 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4839 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4840 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4841 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4844 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
4845 IHTMLDOMAttribute **ppNodeOut)
4847 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4848 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
4851 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
4852 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
4854 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4855 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
4856 return E_NOTIMPL;
4859 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
4860 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
4862 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4863 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
4864 return E_NOTIMPL;
4867 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
4869 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4870 HTMLDOMAttribute *attr;
4871 DISPID id;
4872 HRESULT hres;
4874 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
4876 hres = get_attr_dispid_by_idx(This, &index, &id);
4877 if(hres == DISP_E_UNKNOWNNAME)
4878 return E_INVALIDARG;
4879 if(FAILED(hres))
4880 return hres;
4882 hres = get_domattr(This, id, NULL, &attr);
4883 if(FAILED(hres))
4884 return hres;
4886 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
4887 return S_OK;
4890 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
4892 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4893 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
4896 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
4897 HTMLAttributeCollection3_QueryInterface,
4898 HTMLAttributeCollection3_AddRef,
4899 HTMLAttributeCollection3_Release,
4900 HTMLAttributeCollection3_GetTypeInfoCount,
4901 HTMLAttributeCollection3_GetTypeInfo,
4902 HTMLAttributeCollection3_GetIDsOfNames,
4903 HTMLAttributeCollection3_Invoke,
4904 HTMLAttributeCollection3_getNamedItem,
4905 HTMLAttributeCollection3_setNamedItem,
4906 HTMLAttributeCollection3_removeNamedItem,
4907 HTMLAttributeCollection3_item,
4908 HTMLAttributeCollection3_get_length
4911 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
4913 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
4916 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4918 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4919 HTMLDOMAttribute *attr;
4920 LONG pos;
4921 HRESULT hres;
4923 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
4925 hres = get_attr_dispid_by_name(This, name, dispid);
4926 if(FAILED(hres))
4927 return hres;
4929 hres = get_domattr(This, *dispid, &pos, &attr);
4930 if(FAILED(hres))
4931 return hres;
4932 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4934 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
4935 return S_OK;
4938 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4939 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4941 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4943 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
4945 switch(flags) {
4946 case DISPATCH_PROPERTYGET: {
4947 HTMLDOMAttribute *iter;
4948 DWORD pos;
4950 pos = id-MSHTML_DISPID_CUSTOM_MIN;
4952 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4953 if(!pos) {
4954 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
4955 V_VT(res) = VT_DISPATCH;
4956 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
4957 return S_OK;
4959 pos--;
4962 WARN("invalid arg\n");
4963 return E_INVALIDARG;
4966 default:
4967 FIXME("unimplemented flags %x\n", flags);
4968 return E_NOTIMPL;
4972 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
4973 NULL,
4974 HTMLAttributeCollection_get_dispid,
4975 HTMLAttributeCollection_invoke,
4976 NULL
4979 static const tid_t HTMLAttributeCollection_iface_tids[] = {
4980 IHTMLAttributeCollection_tid,
4981 IHTMLAttributeCollection2_tid,
4982 IHTMLAttributeCollection3_tid,
4986 static dispex_static_data_t HTMLAttributeCollection_dispex = {
4987 &HTMLAttributeCollection_dispex_vtbl,
4988 DispHTMLAttributeCollection_tid,
4989 NULL,
4990 HTMLAttributeCollection_iface_tids
4993 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
4995 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4997 if(This->attrs) {
4998 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
4999 *ac = This->attrs;
5000 return S_OK;
5003 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
5004 if(!This->attrs)
5005 return E_OUTOFMEMORY;
5007 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
5008 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
5009 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
5010 This->attrs->ref = 2;
5012 This->attrs->elem = This;
5013 list_init(&This->attrs->attrs);
5014 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
5015 &HTMLAttributeCollection_dispex);
5017 *ac = This->attrs;
5018 return S_OK;