mshtml: Stub out HTMLAreaElement.
[wine.git] / dlls / mshtml / htmlelem.c
blobcd561b5fb4216c34ea1021f92cc2389350ad8232
1 /*
2 * Copyright 2006-2010 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <assert.h>
21 #include <math.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winreg.h"
29 #include "ole2.h"
30 #include "shlwapi.h"
31 #include "mshtmdid.h"
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
37 #include "htmlstyle.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 static const WCHAR aW[] = {'A',0};
42 static const WCHAR areaW[] = {'A','R','E','A',0};
43 static const WCHAR bodyW[] = {'B','O','D','Y',0};
44 static const WCHAR buttonW[] = {'B','U','T','T','O','N',0};
45 static const WCHAR embedW[] = {'E','M','B','E','D',0};
46 static const WCHAR formW[] = {'F','O','R','M',0};
47 static const WCHAR frameW[] = {'F','R','A','M','E',0};
48 static const WCHAR headW[] = {'H','E','A','D',0};
49 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
50 static const WCHAR imgW[] = {'I','M','G',0};
51 static const WCHAR inputW[] = {'I','N','P','U','T',0};
52 static const WCHAR labelW[] = {'L','A','B','E','L',0};
53 static const WCHAR linkW[] = {'L','I','N','K',0};
54 static const WCHAR metaW[] = {'M','E','T','A',0};
55 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
56 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
57 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
58 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
59 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
60 static const WCHAR tableW[] = {'T','A','B','L','E',0};
61 static const WCHAR tdW[] = {'T','D',0};
62 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
63 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
64 static const WCHAR trW[] = {'T','R',0};
66 typedef struct {
67 const WCHAR *name;
68 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
69 } tag_desc_t;
71 static const tag_desc_t tag_descs[] = {
72 {aW, HTMLAnchorElement_Create},
73 {areaW, HTMLAreaElement_Create},
74 {bodyW, HTMLBodyElement_Create},
75 {buttonW, HTMLButtonElement_Create},
76 {embedW, HTMLEmbedElement_Create},
77 {formW, HTMLFormElement_Create},
78 {frameW, HTMLFrameElement_Create},
79 {headW, HTMLHeadElement_Create},
80 {iframeW, HTMLIFrame_Create},
81 {imgW, HTMLImgElement_Create},
82 {inputW, HTMLInputElement_Create},
83 {labelW, HTMLLabelElement_Create},
84 {linkW, HTMLLinkElement_Create},
85 {metaW, HTMLMetaElement_Create},
86 {objectW, HTMLObjectElement_Create},
87 {optionW, HTMLOptionElement_Create},
88 {scriptW, HTMLScriptElement_Create},
89 {selectW, HTMLSelectElement_Create},
90 {styleW, HTMLStyleElement_Create},
91 {tableW, HTMLTable_Create},
92 {tdW, HTMLTableCell_Create},
93 {textareaW, HTMLTextAreaElement_Create},
94 {title_tagW, HTMLTitleElement_Create},
95 {trW, HTMLTableRow_Create}
98 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
100 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
101 int r;
103 while(min <= max) {
104 i = (min+max)/2;
105 r = strcmpW(tag_name, tag_descs[i].name);
106 if(!r)
107 return tag_descs+i;
109 if(r < 0)
110 max = i-1;
111 else
112 min = i+1;
115 return NULL;
118 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
120 nsIDOMDocumentFragment *nsfragment;
121 nsIDOMNode *nsparent;
122 nsIDOMRange *range;
123 nsAString html_str;
124 nsresult nsres;
125 HRESULT hres = S_OK;
127 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
128 if(NS_FAILED(nsres)) {
129 ERR("CreateRange failed: %08x\n", nsres);
130 return E_FAIL;
133 nsAString_InitDepend(&html_str, html);
134 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
135 nsIDOMRange_Release(range);
136 nsAString_Finish(&html_str);
137 if(NS_FAILED(nsres)) {
138 ERR("CreateContextualFragment failed: %08x\n", nsres);
139 return E_FAIL;
142 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
143 if(NS_SUCCEEDED(nsres) && nsparent) {
144 nsIDOMNode *nstmp;
146 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
147 nsIDOMNode_Release(nsparent);
148 if(NS_FAILED(nsres)) {
149 ERR("ReplaceChild failed: %08x\n", nsres);
150 hres = E_FAIL;
151 }else if(nstmp) {
152 nsIDOMNode_Release(nstmp);
154 }else {
155 ERR("GetParentNode failed: %08x\n", nsres);
156 hres = E_FAIL;
159 nsIDOMDocumentFragment_Release(nsfragment);
160 return hres;
163 nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
165 nsAString name_str;
166 nsresult nsres;
168 nsAString_InitDepend(&name_str, name);
169 nsAString_Init(val_str, NULL);
170 nsres = nsIDOMHTMLElement_GetAttribute(nselem, &name_str, val_str);
171 nsAString_Finish(&name_str);
172 if(NS_FAILED(nsres)) {
173 ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name), nsres);
174 nsAString_Finish(val_str);
175 return nsres;
178 nsAString_GetData(val_str, val);
179 return NS_OK;
182 HRESULT elem_string_attr_getter(HTMLElement *elem, const WCHAR *name, BOOL use_null, BSTR *p)
184 const PRUnichar *val;
185 nsAString val_str;
186 nsresult nsres;
187 HRESULT hres = S_OK;
189 nsres = get_elem_attr_value(elem->nselem, name, &val_str, &val);
190 if(NS_FAILED(nsres))
191 return E_FAIL;
193 TRACE("%s: returning %s\n", debugstr_w(name), debugstr_w(val));
195 if(*val || !use_null) {
196 *p = SysAllocString(val);
197 if(!*p)
198 hres = E_OUTOFMEMORY;
199 }else {
200 *p = NULL;
202 nsAString_Finish(&val_str);
203 return hres;
206 HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHAR *value)
208 nsAString name_str, val_str;
209 nsresult nsres;
211 nsAString_InitDepend(&name_str, name);
212 nsAString_InitDepend(&val_str, value);
213 nsres = nsIDOMHTMLElement_SetAttribute(elem->nselem, &name_str, &val_str);
214 nsAString_Finish(&name_str);
215 nsAString_Finish(&val_str);
217 if(NS_FAILED(nsres)) {
218 WARN("SetAttribute failed: %08x\n", nsres);
219 return E_FAIL;
222 return S_OK;
225 HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
227 static const WCHAR uninitializedW[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
228 static const WCHAR loadingW[] = {'l','o','a','d','i','n','g',0};
229 static const WCHAR loadedW[] = {'l','o','a','d','e','d',0};
230 static const WCHAR interactiveW[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
231 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
233 static const LPCWSTR readystate_strs[] = {
234 uninitializedW,
235 loadingW,
236 loadedW,
237 interactiveW,
238 completeW
241 assert(readystate <= READYSTATE_COMPLETE);
242 *p = SysAllocString(readystate_strs[readystate]);
243 return *p ? S_OK : E_OUTOFMEMORY;
246 typedef struct
248 DispatchEx dispex;
249 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
251 LONG ref;
252 } HTMLFiltersCollection;
254 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
256 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
259 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
261 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
263 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
266 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
268 nsIDOMElement *nselem;
269 nsAString tag_str;
270 nsresult nsres;
272 if(!doc->nsdoc) {
273 WARN("NULL nsdoc\n");
274 return E_UNEXPECTED;
277 nsAString_InitDepend(&tag_str, tag);
278 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
279 nsAString_Finish(&tag_str);
280 if(NS_FAILED(nsres)) {
281 ERR("CreateElement failed: %08x\n", nsres);
282 return E_FAIL;
285 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
286 nsIDOMElement_Release(nselem);
287 if(NS_FAILED(nsres)) {
288 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
289 return E_FAIL;
292 return S_OK;
295 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
297 nsIDOMHTMLElement *nselem;
298 HRESULT hres;
300 /* Use owner doc if called on document fragment */
301 if(!doc->nsdoc)
302 doc = doc->node.doc;
304 hres = create_nselem(doc, tag, &nselem);
305 if(FAILED(hres))
306 return hres;
308 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
309 nsIDOMHTMLElement_Release(nselem);
310 return hres;
313 typedef struct {
314 DispatchEx dispex;
315 IHTMLRect IHTMLRect_iface;
317 LONG ref;
319 nsIDOMClientRect *nsrect;
320 } HTMLRect;
322 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
324 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
327 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
329 HTMLRect *This = impl_from_IHTMLRect(iface);
331 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
333 if(IsEqualGUID(&IID_IUnknown, riid)) {
334 *ppv = &This->IHTMLRect_iface;
335 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
336 *ppv = &This->IHTMLRect_iface;
337 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
338 return *ppv ? S_OK : E_NOINTERFACE;
339 }else {
340 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
341 *ppv = NULL;
342 return E_NOINTERFACE;
345 IUnknown_AddRef((IUnknown*)*ppv);
346 return S_OK;
349 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
351 HTMLRect *This = impl_from_IHTMLRect(iface);
352 LONG ref = InterlockedIncrement(&This->ref);
354 TRACE("(%p) ref=%d\n", This, ref);
356 return ref;
359 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
361 HTMLRect *This = impl_from_IHTMLRect(iface);
362 LONG ref = InterlockedDecrement(&This->ref);
364 TRACE("(%p) ref=%d\n", This, ref);
366 if(!ref) {
367 if(This->nsrect)
368 nsIDOMClientRect_Release(This->nsrect);
369 heap_free(This);
372 return ref;
375 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
377 HTMLRect *This = impl_from_IHTMLRect(iface);
378 FIXME("(%p)->(%p)\n", This, pctinfo);
379 return E_NOTIMPL;
382 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
383 LCID lcid, ITypeInfo **ppTInfo)
385 HTMLRect *This = impl_from_IHTMLRect(iface);
387 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
390 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
391 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
393 HTMLRect *This = impl_from_IHTMLRect(iface);
395 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
396 lcid, rgDispId);
399 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
400 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
401 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
403 HTMLRect *This = impl_from_IHTMLRect(iface);
405 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
406 pDispParams, pVarResult, pExcepInfo, puArgErr);
409 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
411 HTMLRect *This = impl_from_IHTMLRect(iface);
412 FIXME("(%p)->(%d)\n", This, v);
413 return E_NOTIMPL;
416 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
418 HTMLRect *This = impl_from_IHTMLRect(iface);
419 float left;
420 nsresult nsres;
422 TRACE("(%p)->(%p)\n", This, p);
424 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
425 if(NS_FAILED(nsres)) {
426 ERR("GetLeft failed: %08x\n", nsres);
427 return E_FAIL;
430 *p = floor(left+0.5);
431 return S_OK;
434 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
436 HTMLRect *This = impl_from_IHTMLRect(iface);
437 FIXME("(%p)->(%d)\n", This, v);
438 return E_NOTIMPL;
441 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
443 HTMLRect *This = impl_from_IHTMLRect(iface);
444 float top;
445 nsresult nsres;
447 TRACE("(%p)->(%p)\n", This, p);
449 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
450 if(NS_FAILED(nsres)) {
451 ERR("GetTop failed: %08x\n", nsres);
452 return E_FAIL;
455 *p = floor(top+0.5);
456 return S_OK;
459 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
461 HTMLRect *This = impl_from_IHTMLRect(iface);
462 FIXME("(%p)->(%d)\n", This, v);
463 return E_NOTIMPL;
466 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
468 HTMLRect *This = impl_from_IHTMLRect(iface);
469 float right;
470 nsresult nsres;
472 TRACE("(%p)->(%p)\n", This, p);
474 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
475 if(NS_FAILED(nsres)) {
476 ERR("GetRight failed: %08x\n", nsres);
477 return E_FAIL;
480 *p = floor(right+0.5);
481 return S_OK;
484 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
486 HTMLRect *This = impl_from_IHTMLRect(iface);
487 FIXME("(%p)->(%d)\n", This, v);
488 return E_NOTIMPL;
491 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
493 HTMLRect *This = impl_from_IHTMLRect(iface);
494 float bottom;
495 nsresult nsres;
497 TRACE("(%p)->(%p)\n", This, p);
499 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
500 if(NS_FAILED(nsres)) {
501 ERR("GetBottom failed: %08x\n", nsres);
502 return E_FAIL;
505 *p = floor(bottom+0.5);
506 return S_OK;
509 static const IHTMLRectVtbl HTMLRectVtbl = {
510 HTMLRect_QueryInterface,
511 HTMLRect_AddRef,
512 HTMLRect_Release,
513 HTMLRect_GetTypeInfoCount,
514 HTMLRect_GetTypeInfo,
515 HTMLRect_GetIDsOfNames,
516 HTMLRect_Invoke,
517 HTMLRect_put_left,
518 HTMLRect_get_left,
519 HTMLRect_put_top,
520 HTMLRect_get_top,
521 HTMLRect_put_right,
522 HTMLRect_get_right,
523 HTMLRect_put_bottom,
524 HTMLRect_get_bottom
527 static const tid_t HTMLRect_iface_tids[] = {
528 IHTMLRect_tid,
531 static dispex_static_data_t HTMLRect_dispex = {
532 NULL,
533 IHTMLRect_tid,
534 NULL,
535 HTMLRect_iface_tids
538 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
540 HTMLRect *rect;
542 rect = heap_alloc_zero(sizeof(HTMLRect));
543 if(!rect)
544 return E_OUTOFMEMORY;
546 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
547 rect->ref = 1;
549 init_dispex(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex);
551 nsIDOMClientRect_AddRef(nsrect);
552 rect->nsrect = nsrect;
554 *ret = &rect->IHTMLRect_iface;
555 return S_OK;
558 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
559 REFIID riid, void **ppv)
561 HTMLElement *This = impl_from_IHTMLElement(iface);
563 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
566 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
568 HTMLElement *This = impl_from_IHTMLElement(iface);
570 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
573 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
575 HTMLElement *This = impl_from_IHTMLElement(iface);
577 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
580 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
582 HTMLElement *This = impl_from_IHTMLElement(iface);
583 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
586 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
587 LCID lcid, ITypeInfo **ppTInfo)
589 HTMLElement *This = impl_from_IHTMLElement(iface);
590 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
593 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
594 LPOLESTR *rgszNames, UINT cNames,
595 LCID lcid, DISPID *rgDispId)
597 HTMLElement *This = impl_from_IHTMLElement(iface);
598 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
599 lcid, rgDispId);
602 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
603 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
604 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
606 HTMLElement *This = impl_from_IHTMLElement(iface);
607 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
608 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
611 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
612 VARIANT AttributeValue, LONG lFlags)
614 HTMLElement *This = impl_from_IHTMLElement(iface);
615 HRESULT hres;
616 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
617 DISPPARAMS dispParams;
618 EXCEPINFO excep;
620 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
622 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
623 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
624 if(FAILED(hres))
625 return hres;
627 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
628 TRACE("Ignoring call on style attribute\n");
629 return S_OK;
632 dispParams.cArgs = 1;
633 dispParams.cNamedArgs = 1;
634 dispParams.rgdispidNamedArgs = &dispidNamed;
635 dispParams.rgvarg = &AttributeValue;
637 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, dispid,
638 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
641 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, DWORD flags, VARIANT *ret)
643 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
644 EXCEPINFO excep;
645 HRESULT hres;
647 hres = IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
648 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
649 if(FAILED(hres))
650 return hres;
652 if(flags & ATTRFLAG_ASSTRING) {
653 switch(V_VT(ret)) {
654 case VT_BSTR:
655 break;
656 case VT_DISPATCH:
657 IDispatch_Release(V_DISPATCH(ret));
658 V_VT(ret) = VT_BSTR;
659 V_BSTR(ret) = SysAllocString(NULL);
660 break;
661 default:
662 hres = VariantChangeType(ret, ret, 0, VT_BSTR);
663 if(FAILED(hres))
664 return hres;
668 return S_OK;
671 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
672 LONG lFlags, VARIANT *AttributeValue)
674 HTMLElement *This = impl_from_IHTMLElement(iface);
675 DISPID dispid;
676 HRESULT hres;
678 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
680 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
681 FIXME("Unsupported flags %x\n", lFlags);
683 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
684 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
685 if(hres == DISP_E_UNKNOWNNAME) {
686 V_VT(AttributeValue) = VT_NULL;
687 return S_OK;
690 if(FAILED(hres)) {
691 V_VT(AttributeValue) = VT_NULL;
692 return hres;
695 return get_elem_attr_value_by_dispid(This, dispid, lFlags, AttributeValue);
698 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
699 LONG lFlags, VARIANT_BOOL *pfSuccess)
701 HTMLElement *This = impl_from_IHTMLElement(iface);
702 DISPID id;
703 HRESULT hres;
705 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
707 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
708 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
709 if(hres == DISP_E_UNKNOWNNAME) {
710 *pfSuccess = VARIANT_FALSE;
711 return S_OK;
713 if(FAILED(hres))
714 return hres;
716 if(id == DISPID_IHTMLELEMENT_STYLE) {
717 IHTMLStyle *style;
719 TRACE("Special case: style\n");
721 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
722 if(FAILED(hres))
723 return hres;
725 hres = IHTMLStyle_put_cssText(style, NULL);
726 IHTMLStyle_Release(style);
727 if(FAILED(hres))
728 return hres;
730 *pfSuccess = VARIANT_TRUE;
731 return S_OK;
734 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
737 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
739 HTMLElement *This = impl_from_IHTMLElement(iface);
740 nsAString classname_str;
741 nsresult nsres;
743 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
745 if(!This->nselem) {
746 FIXME("NULL nselem\n");
747 return E_NOTIMPL;
750 nsAString_InitDepend(&classname_str, v);
751 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
752 nsAString_Finish(&classname_str);
753 if(NS_FAILED(nsres))
754 ERR("SetClassName failed: %08x\n", nsres);
756 return S_OK;
759 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
761 HTMLElement *This = impl_from_IHTMLElement(iface);
762 nsAString class_str;
763 nsresult nsres;
765 TRACE("(%p)->(%p)\n", This, p);
767 if(!This->nselem) {
768 FIXME("NULL nselem\n");
769 return E_NOTIMPL;
772 nsAString_Init(&class_str, NULL);
773 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
774 return return_nsstr(nsres, &class_str, p);
777 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
779 HTMLElement *This = impl_from_IHTMLElement(iface);
780 nsAString id_str;
781 nsresult nsres;
783 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
785 if(!This->nselem) {
786 FIXME("nselem == NULL\n");
787 return S_OK;
790 nsAString_InitDepend(&id_str, v);
791 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
792 nsAString_Finish(&id_str);
793 if(NS_FAILED(nsres))
794 ERR("SetId failed: %08x\n", nsres);
796 return S_OK;
799 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
801 HTMLElement *This = impl_from_IHTMLElement(iface);
802 nsAString id_str;
803 nsresult nsres;
805 TRACE("(%p)->(%p)\n", This, p);
807 if(!This->nselem) {
808 *p = NULL;
809 return S_OK;
812 nsAString_Init(&id_str, NULL);
813 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
814 return return_nsstr(nsres, &id_str, p);
817 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
819 HTMLElement *This = impl_from_IHTMLElement(iface);
820 nsAString tag_str;
821 nsresult nsres;
823 TRACE("(%p)->(%p)\n", This, p);
825 if(!This->nselem) {
826 static const WCHAR comment_tagW[] = {'!',0};
828 WARN("NULL nselem, assuming comment\n");
830 *p = SysAllocString(comment_tagW);
831 return *p ? S_OK : E_OUTOFMEMORY;
834 nsAString_Init(&tag_str, NULL);
835 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
836 return return_nsstr(nsres, &tag_str, p);
839 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
841 HTMLElement *This = impl_from_IHTMLElement(iface);
842 IHTMLDOMNode *node;
843 HRESULT hres;
845 TRACE("(%p)->(%p)\n", This, p);
847 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
848 if(FAILED(hres))
849 return hres;
851 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
852 IHTMLDOMNode_Release(node);
853 if(FAILED(hres))
854 *p = NULL;
856 return S_OK;
859 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
861 HTMLElement *This = impl_from_IHTMLElement(iface);
863 TRACE("(%p)->(%p)\n", This, p);
865 if(!This->style) {
866 HRESULT hres;
868 hres = HTMLStyle_Create(This, &This->style);
869 if(FAILED(hres))
870 return hres;
873 *p = &This->style->IHTMLStyle_iface;
874 IHTMLStyle_AddRef(*p);
875 return S_OK;
878 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
880 HTMLElement *This = impl_from_IHTMLElement(iface);
881 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
882 return E_NOTIMPL;
885 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
887 HTMLElement *This = impl_from_IHTMLElement(iface);
888 FIXME("(%p)->(%p)\n", This, p);
889 return E_NOTIMPL;
892 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
894 HTMLElement *This = impl_from_IHTMLElement(iface);
896 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
898 return set_node_event(&This->node, EVENTID_CLICK, &v);
901 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
903 HTMLElement *This = impl_from_IHTMLElement(iface);
905 TRACE("(%p)->(%p)\n", This, p);
907 return get_node_event(&This->node, EVENTID_CLICK, p);
910 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
912 HTMLElement *This = impl_from_IHTMLElement(iface);
914 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
916 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
919 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
921 HTMLElement *This = impl_from_IHTMLElement(iface);
923 TRACE("(%p)->(%p)\n", This, p);
925 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
928 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
930 HTMLElement *This = impl_from_IHTMLElement(iface);
932 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
934 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
937 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
939 HTMLElement *This = impl_from_IHTMLElement(iface);
941 TRACE("(%p)->(%p)\n", This, p);
943 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
946 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
948 HTMLElement *This = impl_from_IHTMLElement(iface);
950 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
952 return set_node_event(&This->node, EVENTID_KEYUP, &v);
955 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
957 HTMLElement *This = impl_from_IHTMLElement(iface);
958 FIXME("(%p)->(%p)\n", This, p);
959 return E_NOTIMPL;
962 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
964 HTMLElement *This = impl_from_IHTMLElement(iface);
966 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
968 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
971 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
973 HTMLElement *This = impl_from_IHTMLElement(iface);
975 TRACE("(%p)->(%p)\n", This, p);
977 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
980 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
982 HTMLElement *This = impl_from_IHTMLElement(iface);
984 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
986 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
989 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
991 HTMLElement *This = impl_from_IHTMLElement(iface);
993 TRACE("(%p)->(%p)\n", This, p);
995 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
998 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
1000 HTMLElement *This = impl_from_IHTMLElement(iface);
1002 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1004 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1007 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1009 HTMLElement *This = impl_from_IHTMLElement(iface);
1011 TRACE("(%p)->(%p)\n", This, p);
1013 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1016 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1018 HTMLElement *This = impl_from_IHTMLElement(iface);
1020 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1022 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1025 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1027 HTMLElement *This = impl_from_IHTMLElement(iface);
1029 TRACE("(%p)->(%p)\n", This, p);
1031 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1034 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1036 HTMLElement *This = impl_from_IHTMLElement(iface);
1038 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1040 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1043 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1045 HTMLElement *This = impl_from_IHTMLElement(iface);
1047 TRACE("(%p)->(%p)\n", This, p);
1049 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1052 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1054 HTMLElement *This = impl_from_IHTMLElement(iface);
1056 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1058 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1061 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1063 HTMLElement *This = impl_from_IHTMLElement(iface);
1065 TRACE("(%p)->(%p)\n", This, p);
1067 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1070 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1072 HTMLElement *This = impl_from_IHTMLElement(iface);
1074 TRACE("(%p)->(%p)\n", This, p);
1076 if(!p)
1077 return E_POINTER;
1079 if(This->node.vtbl->get_document)
1080 return This->node.vtbl->get_document(&This->node, p);
1082 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1083 IDispatch_AddRef(*p);
1084 return S_OK;
1087 static const WCHAR titleW[] = {'t','i','t','l','e',0};
1089 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1091 HTMLElement *This = impl_from_IHTMLElement(iface);
1092 nsAString title_str;
1093 nsresult nsres;
1095 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1097 if(!This->nselem) {
1098 VARIANT *var;
1099 HRESULT hres;
1101 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, TRUE, &var);
1102 if(FAILED(hres))
1103 return hres;
1105 VariantClear(var);
1106 V_VT(var) = VT_BSTR;
1107 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1108 return S_OK;
1111 nsAString_InitDepend(&title_str, v);
1112 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
1113 nsAString_Finish(&title_str);
1114 if(NS_FAILED(nsres))
1115 ERR("SetTitle failed: %08x\n", nsres);
1117 return S_OK;
1120 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1122 HTMLElement *This = impl_from_IHTMLElement(iface);
1123 nsAString title_str;
1124 nsresult nsres;
1126 TRACE("(%p)->(%p)\n", This, p);
1128 if(!This->nselem) {
1129 VARIANT *var;
1130 HRESULT hres;
1132 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, FALSE, &var);
1133 if(hres == DISP_E_UNKNOWNNAME) {
1134 *p = NULL;
1135 }else if(V_VT(var) != VT_BSTR) {
1136 FIXME("title = %s\n", debugstr_variant(var));
1137 return E_FAIL;
1138 }else {
1139 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1142 return S_OK;
1145 nsAString_Init(&title_str, NULL);
1146 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
1147 return return_nsstr(nsres, &title_str, p);
1150 static const WCHAR languageW[] = {'l','a','n','g','u','a','g','e',0};
1152 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1154 HTMLElement *This = impl_from_IHTMLElement(iface);
1156 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1158 return elem_string_attr_setter(This, languageW, v);
1161 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1163 HTMLElement *This = impl_from_IHTMLElement(iface);
1165 TRACE("(%p)->(%p)\n", This, p);
1167 return elem_string_attr_getter(This, languageW, TRUE, p);
1170 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1172 HTMLElement *This = impl_from_IHTMLElement(iface);
1174 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1176 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1179 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1181 HTMLElement *This = impl_from_IHTMLElement(iface);
1183 TRACE("(%p)->(%p)\n", This, p);
1185 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1188 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1190 HTMLElement *This = impl_from_IHTMLElement(iface);
1191 cpp_bool start = TRUE;
1192 nsresult nsres;
1194 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1196 switch(V_VT(&varargStart)) {
1197 case VT_EMPTY:
1198 case VT_ERROR:
1199 break;
1200 case VT_BOOL:
1201 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1202 break;
1203 default:
1204 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1207 if(!This->nselem) {
1208 FIXME("Unsupported for comments\n");
1209 return E_NOTIMPL;
1212 nsres = nsIDOMHTMLElement_ScrollIntoView(This->nselem, start, 1);
1213 assert(nsres == NS_OK);
1215 return S_OK;
1218 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1219 VARIANT_BOOL *pfResult)
1221 HTMLElement *This = impl_from_IHTMLElement(iface);
1222 cpp_bool result = FALSE;
1224 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1226 if(pChild) {
1227 HTMLElement *child;
1228 nsresult nsres;
1230 child = unsafe_impl_from_IHTMLElement(pChild);
1231 if(!child) {
1232 ERR("not our element\n");
1233 return E_FAIL;
1236 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1237 assert(nsres == NS_OK);
1240 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
1241 return S_OK;
1244 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1246 HTMLElement *This = impl_from_IHTMLElement(iface);
1248 TRACE("(%p)->(%p)\n", This, p);
1250 return get_elem_source_index(This, p);
1253 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1255 HTMLElement *This = impl_from_IHTMLElement(iface);
1256 FIXME("(%p)->(%p)\n", This, p);
1257 return E_NOTIMPL;
1260 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1262 HTMLElement *This = impl_from_IHTMLElement(iface);
1263 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1264 return E_NOTIMPL;
1267 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1269 HTMLElement *This = impl_from_IHTMLElement(iface);
1270 FIXME("(%p)->(%p)\n", This, p);
1271 return E_NOTIMPL;
1274 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1276 HTMLElement *This = impl_from_IHTMLElement(iface);
1277 nsresult nsres;
1279 TRACE("(%p)->(%p)\n", This, p);
1281 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, p);
1282 if(NS_FAILED(nsres)) {
1283 ERR("GetOffsetLeft failed: %08x\n", nsres);
1284 return E_FAIL;
1287 return S_OK;
1290 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1292 HTMLElement *This = impl_from_IHTMLElement(iface);
1293 nsresult nsres;
1295 TRACE("(%p)->(%p)\n", This, p);
1297 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, p);
1298 if(NS_FAILED(nsres)) {
1299 ERR("GetOffsetTop failed: %08x\n", nsres);
1300 return E_FAIL;
1303 return S_OK;
1306 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1308 HTMLElement *This = impl_from_IHTMLElement(iface);
1309 nsresult nsres;
1311 TRACE("(%p)->(%p)\n", This, p);
1313 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, p);
1314 if(NS_FAILED(nsres)) {
1315 ERR("GetOffsetWidth failed: %08x\n", nsres);
1316 return E_FAIL;
1319 return S_OK;
1322 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1324 HTMLElement *This = impl_from_IHTMLElement(iface);
1325 nsresult nsres;
1327 TRACE("(%p)->(%p)\n", This, p);
1329 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, p);
1330 if(NS_FAILED(nsres)) {
1331 ERR("GetOffsetHeight failed: %08x\n", nsres);
1332 return E_FAIL;
1335 return S_OK;
1338 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1340 HTMLElement *This = impl_from_IHTMLElement(iface);
1341 nsIDOMElement *nsparent;
1342 nsresult nsres;
1343 HRESULT hres;
1345 TRACE("(%p)->(%p)\n", This, p);
1347 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
1348 if(NS_FAILED(nsres)) {
1349 ERR("GetOffsetParent failed: %08x\n", nsres);
1350 return E_FAIL;
1353 if(nsparent) {
1354 HTMLDOMNode *node;
1356 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1357 nsIDOMElement_Release(nsparent);
1358 if(FAILED(hres))
1359 return hres;
1361 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1362 node_release(node);
1363 }else {
1364 *p = NULL;
1365 hres = S_OK;
1368 return hres;
1371 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1373 HTMLElement *This = impl_from_IHTMLElement(iface);
1374 nsAString html_str;
1375 nsresult nsres;
1377 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1379 if(!This->nselem) {
1380 FIXME("NULL nselem\n");
1381 return E_NOTIMPL;
1384 nsAString_InitDepend(&html_str, v);
1385 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
1386 nsAString_Finish(&html_str);
1387 if(NS_FAILED(nsres)) {
1388 FIXME("SetInnerHtml failed %08x\n", nsres);
1389 return E_FAIL;
1392 return S_OK;
1395 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1397 HTMLElement *This = impl_from_IHTMLElement(iface);
1398 nsAString html_str;
1399 nsresult nsres;
1401 TRACE("(%p)->(%p)\n", This, p);
1403 if(!This->nselem) {
1404 FIXME("NULL nselem\n");
1405 return E_NOTIMPL;
1408 nsAString_Init(&html_str, NULL);
1409 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
1410 return return_nsstr(nsres, &html_str, p);
1413 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1415 HTMLElement *This = impl_from_IHTMLElement(iface);
1416 nsIDOMNode *nschild, *tmp;
1417 nsIDOMText *text_node;
1418 nsAString text_str;
1419 nsresult nsres;
1421 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1423 while(1) {
1424 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1425 if(NS_FAILED(nsres)) {
1426 ERR("GetLastChild failed: %08x\n", nsres);
1427 return E_FAIL;
1429 if(!nschild)
1430 break;
1432 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1433 nsIDOMNode_Release(nschild);
1434 if(NS_FAILED(nsres)) {
1435 ERR("RemoveChild failed: %08x\n", nsres);
1436 return E_FAIL;
1438 nsIDOMNode_Release(tmp);
1441 nsAString_InitDepend(&text_str, v);
1442 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1443 nsAString_Finish(&text_str);
1444 if(NS_FAILED(nsres)) {
1445 ERR("CreateTextNode failed: %08x\n", nsres);
1446 return E_FAIL;
1449 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1450 if(NS_FAILED(nsres)) {
1451 ERR("AppendChild failed: %08x\n", nsres);
1452 return E_FAIL;
1455 nsIDOMNode_Release(tmp);
1456 return S_OK;
1459 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1461 HTMLElement *This = impl_from_IHTMLElement(iface);
1463 TRACE("(%p)->(%p)\n", This, p);
1465 return get_node_text(&This->node, p);
1468 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1470 HTMLElement *This = impl_from_IHTMLElement(iface);
1472 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1474 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1477 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1479 HTMLElement *This = impl_from_IHTMLElement(iface);
1480 nsAString html_str;
1481 HRESULT hres;
1483 WARN("(%p)->(%p) semi-stub\n", This, p);
1485 nsAString_Init(&html_str, NULL);
1486 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1487 if(SUCCEEDED(hres)) {
1488 const PRUnichar *html;
1490 nsAString_GetData(&html_str, &html);
1491 *p = SysAllocString(html);
1492 if(!*p)
1493 hres = E_OUTOFMEMORY;
1496 nsAString_Finish(&html_str);
1498 TRACE("ret %s\n", debugstr_w(*p));
1499 return hres;
1502 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1504 HTMLElement *This = impl_from_IHTMLElement(iface);
1505 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1506 return E_NOTIMPL;
1509 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1511 HTMLElement *This = impl_from_IHTMLElement(iface);
1512 FIXME("(%p)->(%p)\n", This, p);
1513 return E_NOTIMPL;
1516 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1518 nsIDOMNode *ret_nsnode;
1519 nsresult nsres;
1520 HRESULT hres = S_OK;
1522 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1523 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1524 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1525 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1527 if (!strcmpiW(where, beforebeginW)) {
1528 nsIDOMNode *parent;
1530 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1531 if(NS_FAILED(nsres))
1532 return E_FAIL;
1534 if(!parent)
1535 return E_INVALIDARG;
1537 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1538 nsIDOMNode_Release(parent);
1539 }else if(!strcmpiW(where, afterbeginW)) {
1540 nsIDOMNode *first_child;
1542 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1543 if(NS_FAILED(nsres))
1544 return E_FAIL;
1546 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1547 if(NS_FAILED(nsres))
1548 return E_FAIL;
1550 if (first_child)
1551 nsIDOMNode_Release(first_child);
1552 }else if (!strcmpiW(where, beforeendW)) {
1553 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1554 }else if (!strcmpiW(where, afterendW)) {
1555 nsIDOMNode *next_sibling, *parent;
1557 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1558 if(NS_FAILED(nsres))
1559 return E_FAIL;
1560 if(!parent)
1561 return E_INVALIDARG;
1563 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1564 if(NS_SUCCEEDED(nsres)) {
1565 if(next_sibling) {
1566 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1567 nsIDOMNode_Release(next_sibling);
1568 }else {
1569 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1573 nsIDOMNode_Release(parent);
1574 }else {
1575 ERR("invalid where: %s\n", debugstr_w(where));
1576 return E_INVALIDARG;
1579 if (NS_FAILED(nsres))
1580 return E_FAIL;
1582 if(ret_node)
1583 hres = get_node(This->node.doc, ret_nsnode, TRUE, ret_node);
1584 nsIDOMNode_Release(ret_nsnode);
1585 return hres;
1588 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1589 BSTR html)
1591 HTMLElement *This = impl_from_IHTMLElement(iface);
1592 nsIDOMRange *range;
1593 nsIDOMNode *nsnode;
1594 nsAString ns_html;
1595 nsresult nsres;
1596 HRESULT hr;
1598 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1600 if(!This->node.doc->nsdoc) {
1601 WARN("NULL nsdoc\n");
1602 return E_UNEXPECTED;
1605 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1606 if(NS_FAILED(nsres))
1608 ERR("CreateRange failed: %08x\n", nsres);
1609 return E_FAIL;
1612 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1614 nsAString_InitDepend(&ns_html, html);
1615 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1616 nsAString_Finish(&ns_html);
1617 nsIDOMRange_Release(range);
1619 if(NS_FAILED(nsres) || !nsnode)
1621 ERR("CreateTextNode failed: %08x\n", nsres);
1622 return E_FAIL;
1625 hr = insert_adjacent_node(This, where, nsnode, NULL);
1626 nsIDOMNode_Release(nsnode);
1627 return hr;
1630 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1631 BSTR text)
1633 HTMLElement *This = impl_from_IHTMLElement(iface);
1634 nsIDOMNode *nsnode;
1635 nsAString ns_text;
1636 nsresult nsres;
1637 HRESULT hr;
1639 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1641 if(!This->node.doc->nsdoc) {
1642 WARN("NULL nsdoc\n");
1643 return E_UNEXPECTED;
1647 nsAString_InitDepend(&ns_text, text);
1648 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1649 nsAString_Finish(&ns_text);
1651 if(NS_FAILED(nsres) || !nsnode)
1653 ERR("CreateTextNode failed: %08x\n", nsres);
1654 return E_FAIL;
1657 hr = insert_adjacent_node(This, where, nsnode, NULL);
1658 nsIDOMNode_Release(nsnode);
1660 return hr;
1663 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1665 HTMLElement *This = impl_from_IHTMLElement(iface);
1666 FIXME("(%p)->(%p)\n", This, p);
1667 return E_NOTIMPL;
1670 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1672 HTMLElement *This = impl_from_IHTMLElement(iface);
1674 TRACE("(%p)->(%p)\n", This, p);
1676 *p = This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node)
1677 ? VARIANT_TRUE : VARIANT_FALSE;
1678 return S_OK;
1681 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1683 HTMLElement *This = impl_from_IHTMLElement(iface);
1685 TRACE("(%p)\n", This);
1687 return call_fire_event(&This->node, EVENTID_CLICK);
1690 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1691 IHTMLFiltersCollection **p)
1693 HTMLElement *This = impl_from_IHTMLElement(iface);
1694 TRACE("(%p)->(%p)\n", This, p);
1696 if(!p)
1697 return E_POINTER;
1699 *p = HTMLFiltersCollection_Create();
1701 return S_OK;
1704 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1706 HTMLElement *This = impl_from_IHTMLElement(iface);
1707 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1708 return E_NOTIMPL;
1711 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1713 HTMLElement *This = impl_from_IHTMLElement(iface);
1714 FIXME("(%p)->(%p)\n", This, p);
1715 return E_NOTIMPL;
1718 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1720 HTMLElement *This = impl_from_IHTMLElement(iface);
1721 FIXME("(%p)->(%p)\n", This, String);
1722 return E_NOTIMPL;
1725 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1727 HTMLElement *This = impl_from_IHTMLElement(iface);
1728 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1729 return E_NOTIMPL;
1732 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1734 HTMLElement *This = impl_from_IHTMLElement(iface);
1735 FIXME("(%p)->(%p)\n", This, p);
1736 return E_NOTIMPL;
1739 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1741 HTMLElement *This = impl_from_IHTMLElement(iface);
1742 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1743 return E_NOTIMPL;
1746 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1748 HTMLElement *This = impl_from_IHTMLElement(iface);
1749 FIXME("(%p)->(%p)\n", This, p);
1750 return E_NOTIMPL;
1753 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1755 HTMLElement *This = impl_from_IHTMLElement(iface);
1756 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1757 return E_NOTIMPL;
1760 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1762 HTMLElement *This = impl_from_IHTMLElement(iface);
1763 FIXME("(%p)->(%p)\n", This, p);
1764 return E_NOTIMPL;
1767 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1769 HTMLElement *This = impl_from_IHTMLElement(iface);
1770 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1771 return E_NOTIMPL;
1774 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1776 HTMLElement *This = impl_from_IHTMLElement(iface);
1777 FIXME("(%p)->(%p)\n", This, p);
1778 return E_NOTIMPL;
1781 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1783 HTMLElement *This = impl_from_IHTMLElement(iface);
1784 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1785 return E_NOTIMPL;
1788 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1790 HTMLElement *This = impl_from_IHTMLElement(iface);
1791 FIXME("(%p)->(%p)\n", This, p);
1792 return E_NOTIMPL;
1795 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1797 HTMLElement *This = impl_from_IHTMLElement(iface);
1798 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1799 return E_NOTIMPL;
1802 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1804 HTMLElement *This = impl_from_IHTMLElement(iface);
1805 FIXME("(%p)->(%p)\n", This, p);
1806 return E_NOTIMPL;
1809 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1811 HTMLElement *This = impl_from_IHTMLElement(iface);
1813 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1815 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1818 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1820 HTMLElement *This = impl_from_IHTMLElement(iface);
1822 TRACE("(%p)->(%p)\n", This, p);
1824 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1827 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1829 HTMLElement *This = impl_from_IHTMLElement(iface);
1830 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1831 return E_NOTIMPL;
1834 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1836 HTMLElement *This = impl_from_IHTMLElement(iface);
1837 FIXME("(%p)->(%p)\n", This, p);
1838 return E_NOTIMPL;
1841 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1843 HTMLElement *This = impl_from_IHTMLElement(iface);
1844 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1845 return E_NOTIMPL;
1848 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1850 HTMLElement *This = impl_from_IHTMLElement(iface);
1851 FIXME("(%p)->(%p)\n", This, p);
1852 return E_NOTIMPL;
1855 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1857 HTMLElement *This = impl_from_IHTMLElement(iface);
1858 nsIDOMNodeList *nsnode_list;
1859 nsresult nsres;
1861 TRACE("(%p)->(%p)\n", This, p);
1863 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1864 if(NS_FAILED(nsres)) {
1865 ERR("GetChildNodes failed: %08x\n", nsres);
1866 return E_FAIL;
1869 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1871 nsIDOMNodeList_Release(nsnode_list);
1872 return S_OK;
1875 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1877 HTMLElement *This = impl_from_IHTMLElement(iface);
1879 TRACE("(%p)->(%p)\n", This, p);
1881 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1882 return S_OK;
1885 static const IHTMLElementVtbl HTMLElementVtbl = {
1886 HTMLElement_QueryInterface,
1887 HTMLElement_AddRef,
1888 HTMLElement_Release,
1889 HTMLElement_GetTypeInfoCount,
1890 HTMLElement_GetTypeInfo,
1891 HTMLElement_GetIDsOfNames,
1892 HTMLElement_Invoke,
1893 HTMLElement_setAttribute,
1894 HTMLElement_getAttribute,
1895 HTMLElement_removeAttribute,
1896 HTMLElement_put_className,
1897 HTMLElement_get_className,
1898 HTMLElement_put_id,
1899 HTMLElement_get_id,
1900 HTMLElement_get_tagName,
1901 HTMLElement_get_parentElement,
1902 HTMLElement_get_style,
1903 HTMLElement_put_onhelp,
1904 HTMLElement_get_onhelp,
1905 HTMLElement_put_onclick,
1906 HTMLElement_get_onclick,
1907 HTMLElement_put_ondblclick,
1908 HTMLElement_get_ondblclick,
1909 HTMLElement_put_onkeydown,
1910 HTMLElement_get_onkeydown,
1911 HTMLElement_put_onkeyup,
1912 HTMLElement_get_onkeyup,
1913 HTMLElement_put_onkeypress,
1914 HTMLElement_get_onkeypress,
1915 HTMLElement_put_onmouseout,
1916 HTMLElement_get_onmouseout,
1917 HTMLElement_put_onmouseover,
1918 HTMLElement_get_onmouseover,
1919 HTMLElement_put_onmousemove,
1920 HTMLElement_get_onmousemove,
1921 HTMLElement_put_onmousedown,
1922 HTMLElement_get_onmousedown,
1923 HTMLElement_put_onmouseup,
1924 HTMLElement_get_onmouseup,
1925 HTMLElement_get_document,
1926 HTMLElement_put_title,
1927 HTMLElement_get_title,
1928 HTMLElement_put_language,
1929 HTMLElement_get_language,
1930 HTMLElement_put_onselectstart,
1931 HTMLElement_get_onselectstart,
1932 HTMLElement_scrollIntoView,
1933 HTMLElement_contains,
1934 HTMLElement_get_sourceIndex,
1935 HTMLElement_get_recordNumber,
1936 HTMLElement_put_lang,
1937 HTMLElement_get_lang,
1938 HTMLElement_get_offsetLeft,
1939 HTMLElement_get_offsetTop,
1940 HTMLElement_get_offsetWidth,
1941 HTMLElement_get_offsetHeight,
1942 HTMLElement_get_offsetParent,
1943 HTMLElement_put_innerHTML,
1944 HTMLElement_get_innerHTML,
1945 HTMLElement_put_innerText,
1946 HTMLElement_get_innerText,
1947 HTMLElement_put_outerHTML,
1948 HTMLElement_get_outerHTML,
1949 HTMLElement_put_outerText,
1950 HTMLElement_get_outerText,
1951 HTMLElement_insertAdjacentHTML,
1952 HTMLElement_insertAdjacentText,
1953 HTMLElement_get_parentTextEdit,
1954 HTMLElement_get_isTextEdit,
1955 HTMLElement_click,
1956 HTMLElement_get_filters,
1957 HTMLElement_put_ondragstart,
1958 HTMLElement_get_ondragstart,
1959 HTMLElement_toString,
1960 HTMLElement_put_onbeforeupdate,
1961 HTMLElement_get_onbeforeupdate,
1962 HTMLElement_put_onafterupdate,
1963 HTMLElement_get_onafterupdate,
1964 HTMLElement_put_onerrorupdate,
1965 HTMLElement_get_onerrorupdate,
1966 HTMLElement_put_onrowexit,
1967 HTMLElement_get_onrowexit,
1968 HTMLElement_put_onrowenter,
1969 HTMLElement_get_onrowenter,
1970 HTMLElement_put_ondatasetchanged,
1971 HTMLElement_get_ondatasetchanged,
1972 HTMLElement_put_ondataavailable,
1973 HTMLElement_get_ondataavailable,
1974 HTMLElement_put_ondatasetcomplete,
1975 HTMLElement_get_ondatasetcomplete,
1976 HTMLElement_put_onfilterchange,
1977 HTMLElement_get_onfilterchange,
1978 HTMLElement_get_children,
1979 HTMLElement_get_all
1982 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1984 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1987 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
1989 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
1992 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
1993 REFIID riid, void **ppv)
1995 HTMLElement *This = impl_from_IHTMLElement2(iface);
1996 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
1999 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
2001 HTMLElement *This = impl_from_IHTMLElement2(iface);
2002 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2005 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2007 HTMLElement *This = impl_from_IHTMLElement2(iface);
2008 return IHTMLElement_Release(&This->IHTMLElement_iface);
2011 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2013 HTMLElement *This = impl_from_IHTMLElement2(iface);
2014 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2017 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2018 LCID lcid, ITypeInfo **ppTInfo)
2020 HTMLElement *This = impl_from_IHTMLElement2(iface);
2021 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2024 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2025 LPOLESTR *rgszNames, UINT cNames,
2026 LCID lcid, DISPID *rgDispId)
2028 HTMLElement *This = impl_from_IHTMLElement2(iface);
2029 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2030 lcid, rgDispId);
2033 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2034 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2035 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2037 HTMLElement *This = impl_from_IHTMLElement2(iface);
2038 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2039 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2042 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2044 HTMLElement *This = impl_from_IHTMLElement2(iface);
2045 FIXME("(%p)->(%p)\n", This, p);
2046 return E_NOTIMPL;
2049 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2051 HTMLElement *This = impl_from_IHTMLElement2(iface);
2052 FIXME("(%p)->(%x)\n", This, containerCapture);
2053 return E_NOTIMPL;
2056 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2058 HTMLElement *This = impl_from_IHTMLElement2(iface);
2059 FIXME("(%p)\n", This);
2060 return E_NOTIMPL;
2063 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2065 HTMLElement *This = impl_from_IHTMLElement2(iface);
2066 FIXME("(%p)->()\n", This);
2067 return E_NOTIMPL;
2070 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2072 HTMLElement *This = impl_from_IHTMLElement2(iface);
2073 FIXME("(%p)->(%p)\n", This, p);
2074 return E_NOTIMPL;
2077 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2078 LONG x, LONG y, BSTR *component)
2080 HTMLElement *This = impl_from_IHTMLElement2(iface);
2081 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2082 return E_NOTIMPL;
2085 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2087 HTMLElement *This = impl_from_IHTMLElement2(iface);
2089 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2091 if(!This->node.doc->content_ready
2092 || !This->node.doc->basedoc.doc_obj->in_place_active)
2093 return E_PENDING;
2095 WARN("stub\n");
2096 return S_OK;
2099 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2101 HTMLElement *This = impl_from_IHTMLElement2(iface);
2102 FIXME("(%p)->()\n", This);
2103 return E_NOTIMPL;
2106 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2108 HTMLElement *This = impl_from_IHTMLElement2(iface);
2109 FIXME("(%p)->(%p)\n", This, p);
2110 return E_NOTIMPL;
2113 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2115 HTMLElement *This = impl_from_IHTMLElement2(iface);
2117 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2119 return set_node_event(&This->node, EVENTID_DRAG, &v);
2122 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2124 HTMLElement *This = impl_from_IHTMLElement2(iface);
2126 TRACE("(%p)->(%p)\n", This, p);
2128 return get_node_event(&This->node, EVENTID_DRAG, p);
2131 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2133 HTMLElement *This = impl_from_IHTMLElement2(iface);
2134 FIXME("(%p)->()\n", This);
2135 return E_NOTIMPL;
2138 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2140 HTMLElement *This = impl_from_IHTMLElement2(iface);
2141 FIXME("(%p)->(%p)\n", This, p);
2142 return E_NOTIMPL;
2145 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2147 HTMLElement *This = impl_from_IHTMLElement2(iface);
2148 FIXME("(%p)->()\n", This);
2149 return E_NOTIMPL;
2152 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2154 HTMLElement *This = impl_from_IHTMLElement2(iface);
2155 FIXME("(%p)->(%p)\n", This, p);
2156 return E_NOTIMPL;
2159 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2161 HTMLElement *This = impl_from_IHTMLElement2(iface);
2162 FIXME("(%p)->()\n", This);
2163 return E_NOTIMPL;
2166 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2168 HTMLElement *This = impl_from_IHTMLElement2(iface);
2169 FIXME("(%p)->(%p)\n", This, p);
2170 return E_NOTIMPL;
2173 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2175 HTMLElement *This = impl_from_IHTMLElement2(iface);
2176 FIXME("(%p)->()\n", This);
2177 return E_NOTIMPL;
2180 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2182 HTMLElement *This = impl_from_IHTMLElement2(iface);
2183 FIXME("(%p)->(%p)\n", This, p);
2184 return E_NOTIMPL;
2187 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2189 HTMLElement *This = impl_from_IHTMLElement2(iface);
2190 FIXME("(%p)->()\n", This);
2191 return E_NOTIMPL;
2194 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2196 HTMLElement *This = impl_from_IHTMLElement2(iface);
2197 FIXME("(%p)->(%p)\n", This, p);
2198 return E_NOTIMPL;
2201 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2203 HTMLElement *This = impl_from_IHTMLElement2(iface);
2204 FIXME("(%p)->()\n", This);
2205 return E_NOTIMPL;
2208 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2210 HTMLElement *This = impl_from_IHTMLElement2(iface);
2211 FIXME("(%p)->(%p)\n", This, p);
2212 return E_NOTIMPL;
2215 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2217 HTMLElement *This = impl_from_IHTMLElement2(iface);
2218 FIXME("(%p)->()\n", This);
2219 return E_NOTIMPL;
2222 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2224 HTMLElement *This = impl_from_IHTMLElement2(iface);
2225 FIXME("(%p)->(%p)\n", This, p);
2226 return E_NOTIMPL;
2229 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2231 HTMLElement *This = impl_from_IHTMLElement2(iface);
2232 FIXME("(%p)->()\n", This);
2233 return E_NOTIMPL;
2236 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2238 HTMLElement *This = impl_from_IHTMLElement2(iface);
2239 FIXME("(%p)->(%p)\n", This, p);
2240 return E_NOTIMPL;
2243 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2245 HTMLElement *This = impl_from_IHTMLElement2(iface);
2246 FIXME("(%p)->()\n", This);
2247 return E_NOTIMPL;
2250 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2252 HTMLElement *This = impl_from_IHTMLElement2(iface);
2253 FIXME("(%p)->(%p)\n", This, p);
2254 return E_NOTIMPL;
2257 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2259 HTMLElement *This = impl_from_IHTMLElement2(iface);
2260 FIXME("(%p)->()\n", This);
2261 return E_NOTIMPL;
2264 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2266 HTMLElement *This = impl_from_IHTMLElement2(iface);
2267 FIXME("(%p)->(%p)\n", This, p);
2268 return E_NOTIMPL;
2271 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2273 HTMLElement *This = impl_from_IHTMLElement2(iface);
2275 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2277 return set_node_event(&This->node, EVENTID_PASTE, &v);
2280 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2282 HTMLElement *This = impl_from_IHTMLElement2(iface);
2284 TRACE("(%p)->(%p)\n", This, p);
2286 return get_node_event(&This->node, EVENTID_PASTE, p);
2289 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2291 HTMLElement *This = impl_from_IHTMLElement2(iface);
2293 TRACE("(%p)->(%p)\n", This, p);
2295 return HTMLCurrentStyle_Create(This, p);
2298 static HRESULT WINAPI HTMLElement2_put_onpropertychange(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_onpropertychange(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_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2314 HTMLElement *This = impl_from_IHTMLElement2(iface);
2315 FIXME("(%p)->(%p)\n", This, pRectCol);
2316 return E_NOTIMPL;
2319 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2321 HTMLElement *This = impl_from_IHTMLElement2(iface);
2322 nsIDOMClientRect *nsrect;
2323 nsresult nsres;
2324 HRESULT hres;
2326 TRACE("(%p)->(%p)\n", This, pRect);
2328 nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
2329 if(NS_FAILED(nsres) || !nsrect) {
2330 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2331 return E_FAIL;
2334 hres = create_html_rect(nsrect, pRect);
2336 nsIDOMClientRect_Release(nsrect);
2337 return hres;
2340 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2341 BSTR expression, BSTR language)
2343 HTMLElement *This = impl_from_IHTMLElement2(iface);
2344 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2345 debugstr_w(language));
2346 return E_NOTIMPL;
2349 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2350 VARIANT *expression)
2352 HTMLElement *This = impl_from_IHTMLElement2(iface);
2353 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2354 return E_NOTIMPL;
2357 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2358 VARIANT_BOOL *pfSuccess)
2360 HTMLElement *This = impl_from_IHTMLElement2(iface);
2361 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2362 return E_NOTIMPL;
2365 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2367 HTMLElement *This = impl_from_IHTMLElement2(iface);
2368 nsresult nsres;
2370 TRACE("(%p)->(%d)\n", This, v);
2372 nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
2373 if(NS_FAILED(nsres))
2374 ERR("GetTabIndex failed: %08x\n", nsres);
2376 return S_OK;
2379 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2381 HTMLElement *This = impl_from_IHTMLElement2(iface);
2382 LONG index;
2383 nsresult nsres;
2385 TRACE("(%p)->(%p)\n", This, p);
2387 nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
2388 if(NS_FAILED(nsres)) {
2389 ERR("GetTabIndex failed: %08x\n", nsres);
2390 return E_FAIL;
2393 *p = index;
2394 return S_OK;
2397 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2399 HTMLElement *This = impl_from_IHTMLElement2(iface);
2400 nsresult nsres;
2402 TRACE("(%p)\n", This);
2404 nsres = nsIDOMHTMLElement_Focus(This->nselem);
2405 if(NS_FAILED(nsres))
2406 ERR("Focus failed: %08x\n", nsres);
2408 return S_OK;
2411 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2413 HTMLElement *This = impl_from_IHTMLElement2(iface);
2414 VARIANT var;
2416 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2418 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2420 V_VT(&var) = VT_BSTR;
2421 V_BSTR(&var) = v;
2422 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2425 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2427 HTMLElement *This = impl_from_IHTMLElement2(iface);
2428 FIXME("(%p)->(%p)\n", This, p);
2429 return E_NOTIMPL;
2432 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2434 HTMLElement *This = impl_from_IHTMLElement2(iface);
2436 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2438 return set_node_event(&This->node, EVENTID_BLUR, &v);
2441 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2443 HTMLElement *This = impl_from_IHTMLElement2(iface);
2445 TRACE("(%p)->(%p)\n", This, p);
2447 return get_node_event(&This->node, EVENTID_BLUR, p);
2450 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2452 HTMLElement *This = impl_from_IHTMLElement2(iface);
2454 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2456 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2459 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2461 HTMLElement *This = impl_from_IHTMLElement2(iface);
2463 TRACE("(%p)->(%p)\n", This, p);
2465 return get_node_event(&This->node, EVENTID_FOCUS, p);
2468 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2470 HTMLElement *This = impl_from_IHTMLElement2(iface);
2471 FIXME("(%p)->()\n", This);
2472 return E_NOTIMPL;
2475 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2477 HTMLElement *This = impl_from_IHTMLElement2(iface);
2478 FIXME("(%p)->(%p)\n", This, p);
2479 return E_NOTIMPL;
2482 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2484 HTMLElement *This = impl_from_IHTMLElement2(iface);
2485 nsresult nsres;
2487 TRACE("(%p)\n", This);
2489 nsres = nsIDOMHTMLElement_Blur(This->nselem);
2490 if(NS_FAILED(nsres)) {
2491 ERR("Blur failed: %08x\n", nsres);
2492 return E_FAIL;
2495 return S_OK;
2498 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2500 HTMLElement *This = impl_from_IHTMLElement2(iface);
2501 FIXME("(%p)->(%p)\n", This, pUnk);
2502 return E_NOTIMPL;
2505 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2507 HTMLElement *This = impl_from_IHTMLElement2(iface);
2508 FIXME("(%p)->(%p)\n", This, pUnk);
2509 return E_NOTIMPL;
2512 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2514 HTMLElement *This = impl_from_IHTMLElement2(iface);
2515 nsresult nsres;
2517 TRACE("(%p)->(%p)\n", This, p);
2519 nsres = nsIDOMHTMLElement_GetClientHeight(This->nselem, p);
2520 assert(nsres == NS_OK);
2521 return S_OK;
2524 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2526 HTMLElement *This = impl_from_IHTMLElement2(iface);
2527 nsresult nsres;
2529 TRACE("(%p)->(%p)\n", This, p);
2531 nsres = nsIDOMHTMLElement_GetClientWidth(This->nselem, p);
2532 assert(nsres == NS_OK);
2533 return S_OK;
2536 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2538 HTMLElement *This = impl_from_IHTMLElement2(iface);
2539 nsresult nsres;
2541 TRACE("(%p)->(%p)\n", This, p);
2543 nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, p);
2544 assert(nsres == NS_OK);
2546 TRACE("*p = %d\n", *p);
2547 return S_OK;
2550 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2552 HTMLElement *This = impl_from_IHTMLElement2(iface);
2553 nsresult nsres;
2555 TRACE("(%p)->(%p)\n", This, p);
2557 nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, p);
2558 assert(nsres == NS_OK);
2560 TRACE("*p = %d\n", *p);
2561 return S_OK;
2564 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2565 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2567 HTMLElement *This = impl_from_IHTMLElement2(iface);
2569 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2571 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2574 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2576 HTMLElement *This = impl_from_IHTMLElement2(iface);
2578 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2580 return detach_event(&This->node.event_target, event, pDisp);
2583 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2585 HTMLElement *This = impl_from_IHTMLElement2(iface);
2586 BSTR str;
2588 TRACE("(%p)->(%p)\n", This, p);
2590 if(This->node.vtbl->get_readystate) {
2591 HRESULT hres;
2593 hres = This->node.vtbl->get_readystate(&This->node, &str);
2594 if(FAILED(hres))
2595 return hres;
2596 }else {
2597 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2599 str = SysAllocString(completeW);
2600 if(!str)
2601 return E_OUTOFMEMORY;
2604 V_VT(p) = VT_BSTR;
2605 V_BSTR(p) = str;
2606 return S_OK;
2609 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2611 HTMLElement *This = impl_from_IHTMLElement2(iface);
2613 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2615 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2618 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2620 HTMLElement *This = impl_from_IHTMLElement2(iface);
2622 TRACE("(%p)->(%p)\n", This, p);
2624 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2627 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2629 HTMLElement *This = impl_from_IHTMLElement2(iface);
2630 FIXME("(%p)->()\n", This);
2631 return E_NOTIMPL;
2634 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2636 HTMLElement *This = impl_from_IHTMLElement2(iface);
2637 FIXME("(%p)->(%p)\n", This, p);
2638 return E_NOTIMPL;
2641 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2643 HTMLElement *This = impl_from_IHTMLElement2(iface);
2644 FIXME("(%p)->()\n", This);
2645 return E_NOTIMPL;
2648 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2650 HTMLElement *This = impl_from_IHTMLElement2(iface);
2651 FIXME("(%p)->(%p)\n", This, p);
2652 return E_NOTIMPL;
2655 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2657 HTMLElement *This = impl_from_IHTMLElement2(iface);
2658 FIXME("(%p)->()\n", This);
2659 return E_NOTIMPL;
2662 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2664 HTMLElement *This = impl_from_IHTMLElement2(iface);
2665 FIXME("(%p)->(%p)\n", This, p);
2666 return E_NOTIMPL;
2669 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2671 HTMLElement *This = impl_from_IHTMLElement2(iface);
2672 nsAString nsstr;
2673 nsresult nsres;
2675 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2677 if(!This->nselem) {
2678 FIXME("Unsupported for comment nodes.\n");
2679 return S_OK;
2682 nsAString_InitDepend(&nsstr, v);
2683 nsres = nsIDOMHTMLElement_SetDir(This->nselem, &nsstr);
2684 nsAString_Finish(&nsstr);
2685 if(NS_FAILED(nsres)) {
2686 ERR("SetDir failed: %08x\n", nsres);
2687 return E_FAIL;
2690 return S_OK;
2693 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2695 HTMLElement *This = impl_from_IHTMLElement2(iface);
2696 nsAString dir_str;
2697 nsresult nsres;
2699 TRACE("(%p)->(%p)\n", This, p);
2701 if(!This->nselem) {
2702 *p = NULL;
2703 return S_OK;
2706 nsAString_Init(&dir_str, NULL);
2707 nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
2708 return return_nsstr(nsres, &dir_str, p);
2711 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2713 HTMLElement *This = impl_from_IHTMLElement2(iface);
2714 FIXME("(%p)->(%p)\n", This, range);
2715 return E_NOTIMPL;
2718 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2720 HTMLElement *This = impl_from_IHTMLElement2(iface);
2721 nsresult nsres;
2723 TRACE("(%p)->(%p)\n", This, p);
2725 nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, p);
2726 assert(nsres == NS_OK);
2728 TRACE("*p = %d\n", *p);
2729 return S_OK;
2732 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2734 HTMLElement *This = impl_from_IHTMLElement2(iface);
2735 nsresult nsres;
2737 TRACE("(%p)->(%p)\n", This, p);
2739 nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, p);
2740 assert(nsres == NS_OK);
2742 TRACE("*p = %d\n", *p);
2743 return S_OK;
2746 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2748 HTMLElement *This = impl_from_IHTMLElement2(iface);
2750 TRACE("(%p)->(%d)\n", This, v);
2752 if(!This->nselem) {
2753 FIXME("NULL nselem\n");
2754 return E_NOTIMPL;
2757 nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
2758 return S_OK;
2761 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2763 HTMLElement *This = impl_from_IHTMLElement2(iface);
2764 nsresult nsres;
2766 TRACE("(%p)->(%p)\n", This, p);
2768 nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, p);
2769 assert(nsres == NS_OK);
2771 TRACE("*p = %d\n", *p);
2772 return S_OK;
2775 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2777 HTMLElement *This = impl_from_IHTMLElement2(iface);
2779 TRACE("(%p)->(%d)\n", This, v);
2781 if(!This->nselem) {
2782 FIXME("NULL nselem\n");
2783 return E_NOTIMPL;
2786 nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
2787 return S_OK;
2790 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2792 HTMLElement *This = impl_from_IHTMLElement2(iface);
2793 nsresult nsres;
2795 TRACE("(%p)->(%p)\n", This, p);
2797 if(!p)
2798 return E_INVALIDARG;
2800 if(!This->nselem)
2802 FIXME("NULL nselem\n");
2803 return E_NOTIMPL;
2806 nsres = nsIDOMHTMLElement_GetScrollLeft(This->nselem, p);
2807 assert(nsres == NS_OK);
2809 TRACE("*p = %d\n", *p);
2810 return S_OK;
2813 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
2815 HTMLElement *This = impl_from_IHTMLElement2(iface);
2816 FIXME("(%p)\n", This);
2817 return E_NOTIMPL;
2820 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
2822 HTMLElement *This = impl_from_IHTMLElement2(iface);
2823 FIXME("(%p)->(%p)\n", This, mergeThis);
2824 return E_NOTIMPL;
2827 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
2829 HTMLElement *This = impl_from_IHTMLElement2(iface);
2830 FIXME("(%p)->()\n", This);
2831 return E_NOTIMPL;
2834 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
2836 HTMLElement *This = impl_from_IHTMLElement2(iface);
2837 FIXME("(%p)->(%p)\n", This, p);
2838 return E_NOTIMPL;
2841 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
2842 IHTMLElement *insertedElement, IHTMLElement **inserted)
2844 HTMLElement *This = impl_from_IHTMLElement2(iface);
2845 HTMLDOMNode *ret_node;
2846 HTMLElement *elem;
2847 HRESULT hres;
2849 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
2851 elem = unsafe_impl_from_IHTMLElement(insertedElement);
2852 if(!elem)
2853 return E_INVALIDARG;
2855 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
2856 if(FAILED(hres))
2857 return hres;
2859 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
2860 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
2861 return hres;
2864 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
2865 BSTR where, IHTMLElement **applied)
2867 HTMLElement *This = impl_from_IHTMLElement2(iface);
2868 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
2869 return E_NOTIMPL;
2872 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
2874 HTMLElement *This = impl_from_IHTMLElement2(iface);
2875 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
2876 return E_NOTIMPL;
2879 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
2880 BSTR newText, BSTR *oldText)
2882 HTMLElement *This = impl_from_IHTMLElement2(iface);
2883 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
2884 return E_NOTIMPL;
2887 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
2889 HTMLElement *This = impl_from_IHTMLElement2(iface);
2890 FIXME("(%p)->(%p)\n", This, p);
2891 return E_NOTIMPL;
2894 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
2895 VARIANT *pvarFactory, LONG *pCookie)
2897 HTMLElement *This = impl_from_IHTMLElement2(iface);
2898 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
2899 return E_NOTIMPL;
2902 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
2903 VARIANT_BOOL *pfResult)
2905 HTMLElement *This = impl_from_IHTMLElement2(iface);
2906 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
2907 return E_NOTIMPL;
2910 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
2912 HTMLElement *This = impl_from_IHTMLElement2(iface);
2914 FIXME("(%p)->(%p): hack\n", This, p);
2916 /* We can't implement correct behavior on top of Gecko (although we could
2917 try a bit harder). Making runtimeStyle behave like regular style is
2918 enough for most use cases. */
2919 if(!This->runtime_style) {
2920 HRESULT hres;
2922 hres = HTMLStyle_Create(This, &This->runtime_style);
2923 if(FAILED(hres))
2924 return hres;
2927 *p = &This->runtime_style->IHTMLStyle_iface;
2928 IHTMLStyle_AddRef(*p);
2929 return S_OK;
2932 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
2934 HTMLElement *This = impl_from_IHTMLElement2(iface);
2935 FIXME("(%p)->(%p)\n", This, p);
2936 return E_NOTIMPL;
2939 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
2941 HTMLElement *This = impl_from_IHTMLElement2(iface);
2942 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2943 return E_NOTIMPL;
2946 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
2948 HTMLElement *This = impl_from_IHTMLElement2(iface);
2949 FIXME("(%p)->(%p)\n", This, p);
2950 return E_NOTIMPL;
2953 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
2955 HTMLElement *This = impl_from_IHTMLElement2(iface);
2956 FIXME("(%p)->()\n", This);
2957 return E_NOTIMPL;
2960 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
2962 HTMLElement *This = impl_from_IHTMLElement2(iface);
2963 FIXME("(%p)->(%p)\n", This, p);
2964 return E_NOTIMPL;
2967 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
2969 HTMLElement *This = impl_from_IHTMLElement2(iface);
2970 FIXME("(%p)->(%p)\n", This, p);
2971 return E_NOTIMPL;
2974 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
2975 IHTMLElementCollection **pelColl)
2977 HTMLElement *This = impl_from_IHTMLElement2(iface);
2978 nsIDOMHTMLCollection *nscol;
2979 nsAString tag_str;
2980 nsresult nsres;
2982 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2984 nsAString_InitDepend(&tag_str, v);
2985 nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nscol);
2986 nsAString_Finish(&tag_str);
2987 if(NS_FAILED(nsres)) {
2988 ERR("GetElementByTagName failed: %08x\n", nsres);
2989 return E_FAIL;
2992 *pelColl = create_collection_from_htmlcol(This->node.doc, nscol);
2993 nsIDOMHTMLCollection_Release(nscol);
2994 return S_OK;
2997 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
2998 HTMLElement2_QueryInterface,
2999 HTMLElement2_AddRef,
3000 HTMLElement2_Release,
3001 HTMLElement2_GetTypeInfoCount,
3002 HTMLElement2_GetTypeInfo,
3003 HTMLElement2_GetIDsOfNames,
3004 HTMLElement2_Invoke,
3005 HTMLElement2_get_scopeName,
3006 HTMLElement2_setCapture,
3007 HTMLElement2_releaseCapture,
3008 HTMLElement2_put_onlosecapture,
3009 HTMLElement2_get_onlosecapture,
3010 HTMLElement2_componentFromPoint,
3011 HTMLElement2_doScroll,
3012 HTMLElement2_put_onscroll,
3013 HTMLElement2_get_onscroll,
3014 HTMLElement2_put_ondrag,
3015 HTMLElement2_get_ondrag,
3016 HTMLElement2_put_ondragend,
3017 HTMLElement2_get_ondragend,
3018 HTMLElement2_put_ondragenter,
3019 HTMLElement2_get_ondragenter,
3020 HTMLElement2_put_ondragover,
3021 HTMLElement2_get_ondragover,
3022 HTMLElement2_put_ondragleave,
3023 HTMLElement2_get_ondragleave,
3024 HTMLElement2_put_ondrop,
3025 HTMLElement2_get_ondrop,
3026 HTMLElement2_put_onbeforecut,
3027 HTMLElement2_get_onbeforecut,
3028 HTMLElement2_put_oncut,
3029 HTMLElement2_get_oncut,
3030 HTMLElement2_put_onbeforecopy,
3031 HTMLElement2_get_onbeforecopy,
3032 HTMLElement2_put_oncopy,
3033 HTMLElement2_get_oncopy,
3034 HTMLElement2_put_onbeforepaste,
3035 HTMLElement2_get_onbeforepaste,
3036 HTMLElement2_put_onpaste,
3037 HTMLElement2_get_onpaste,
3038 HTMLElement2_get_currentStyle,
3039 HTMLElement2_put_onpropertychange,
3040 HTMLElement2_get_onpropertychange,
3041 HTMLElement2_getClientRects,
3042 HTMLElement2_getBoundingClientRect,
3043 HTMLElement2_setExpression,
3044 HTMLElement2_getExpression,
3045 HTMLElement2_removeExpression,
3046 HTMLElement2_put_tabIndex,
3047 HTMLElement2_get_tabIndex,
3048 HTMLElement2_focus,
3049 HTMLElement2_put_accessKey,
3050 HTMLElement2_get_accessKey,
3051 HTMLElement2_put_onblur,
3052 HTMLElement2_get_onblur,
3053 HTMLElement2_put_onfocus,
3054 HTMLElement2_get_onfocus,
3055 HTMLElement2_put_onresize,
3056 HTMLElement2_get_onresize,
3057 HTMLElement2_blur,
3058 HTMLElement2_addFilter,
3059 HTMLElement2_removeFilter,
3060 HTMLElement2_get_clientHeight,
3061 HTMLElement2_get_clientWidth,
3062 HTMLElement2_get_clientTop,
3063 HTMLElement2_get_clientLeft,
3064 HTMLElement2_attachEvent,
3065 HTMLElement2_detachEvent,
3066 HTMLElement2_get_readyState,
3067 HTMLElement2_put_onreadystatechange,
3068 HTMLElement2_get_onreadystatechange,
3069 HTMLElement2_put_onrowsdelete,
3070 HTMLElement2_get_onrowsdelete,
3071 HTMLElement2_put_onrowsinserted,
3072 HTMLElement2_get_onrowsinserted,
3073 HTMLElement2_put_oncellchange,
3074 HTMLElement2_get_oncellchange,
3075 HTMLElement2_put_dir,
3076 HTMLElement2_get_dir,
3077 HTMLElement2_createControlRange,
3078 HTMLElement2_get_scrollHeight,
3079 HTMLElement2_get_scrollWidth,
3080 HTMLElement2_put_scrollTop,
3081 HTMLElement2_get_scrollTop,
3082 HTMLElement2_put_scrollLeft,
3083 HTMLElement2_get_scrollLeft,
3084 HTMLElement2_clearAttributes,
3085 HTMLElement2_mergeAttributes,
3086 HTMLElement2_put_oncontextmenu,
3087 HTMLElement2_get_oncontextmenu,
3088 HTMLElement2_insertAdjacentElement,
3089 HTMLElement2_applyElement,
3090 HTMLElement2_getAdjacentText,
3091 HTMLElement2_replaceAdjacentText,
3092 HTMLElement2_get_canHandleChildren,
3093 HTMLElement2_addBehavior,
3094 HTMLElement2_removeBehavior,
3095 HTMLElement2_get_runtimeStyle,
3096 HTMLElement2_get_behaviorUrns,
3097 HTMLElement2_put_tagUrn,
3098 HTMLElement2_get_tagUrn,
3099 HTMLElement2_put_onbeforeeditfocus,
3100 HTMLElement2_get_onbeforeeditfocus,
3101 HTMLElement2_get_readyStateValue,
3102 HTMLElement2_getElementsByTagName,
3105 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3107 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3110 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3111 REFIID riid, void **ppv)
3113 HTMLElement *This = impl_from_IHTMLElement3(iface);
3114 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3117 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3119 HTMLElement *This = impl_from_IHTMLElement3(iface);
3120 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3123 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3125 HTMLElement *This = impl_from_IHTMLElement3(iface);
3126 return IHTMLElement_Release(&This->IHTMLElement_iface);
3129 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3131 HTMLElement *This = impl_from_IHTMLElement3(iface);
3132 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3135 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3136 LCID lcid, ITypeInfo **ppTInfo)
3138 HTMLElement *This = impl_from_IHTMLElement3(iface);
3139 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3142 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3143 LPOLESTR *rgszNames, UINT cNames,
3144 LCID lcid, DISPID *rgDispId)
3146 HTMLElement *This = impl_from_IHTMLElement3(iface);
3147 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3148 lcid, rgDispId);
3151 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3152 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3153 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3155 HTMLElement *This = impl_from_IHTMLElement3(iface);
3156 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3157 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3160 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3162 HTMLElement *This = impl_from_IHTMLElement3(iface);
3163 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3164 return E_NOTIMPL;
3167 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3169 HTMLElement *This = impl_from_IHTMLElement3(iface);
3170 FIXME("(%p)->(%p)\n", This, p);
3171 return E_NOTIMPL;
3174 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3176 HTMLElement *This = impl_from_IHTMLElement3(iface);
3177 FIXME("(%p)->(%p)\n", This, p);
3178 return E_NOTIMPL;
3181 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3183 HTMLElement *This = impl_from_IHTMLElement3(iface);
3184 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3185 return E_NOTIMPL;
3188 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3190 HTMLElement *This = impl_from_IHTMLElement3(iface);
3191 FIXME("(%p)->(%p)\n", This, p);
3192 return E_NOTIMPL;
3195 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3197 HTMLElement *This = impl_from_IHTMLElement3(iface);
3198 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3199 return E_NOTIMPL;
3202 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3204 HTMLElement *This = impl_from_IHTMLElement3(iface);
3205 FIXME("(%p)->(%p)\n", This, p);
3206 return E_NOTIMPL;
3209 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3211 HTMLElement *This = impl_from_IHTMLElement3(iface);
3212 FIXME("(%p)->(%x)\n", This, v);
3213 return E_NOTIMPL;
3216 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3218 HTMLElement *This = impl_from_IHTMLElement3(iface);
3219 FIXME("(%p)->(%p)\n", This, p);
3220 return E_NOTIMPL;
3223 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3225 HTMLElement *This = impl_from_IHTMLElement3(iface);
3226 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3227 return E_NOTIMPL;
3230 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3232 HTMLElement *This = impl_from_IHTMLElement3(iface);
3233 FIXME("(%p)->(%p)\n", This, p);
3234 return E_NOTIMPL;
3237 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3239 HTMLElement *This = impl_from_IHTMLElement3(iface);
3240 FIXME("(%p)\n", This);
3241 return E_NOTIMPL;
3244 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3246 HTMLElement *This = impl_from_IHTMLElement3(iface);
3247 nsresult nsres;
3248 nsAString str;
3250 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3252 nsAString_InitDepend(&str, v);
3253 nsres = nsIDOMHTMLElement_SetContentEditable(This->nselem, &str);
3254 nsAString_Finish(&str);
3256 if (NS_FAILED(nsres)){
3257 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3258 return E_FAIL;
3261 return S_OK;
3264 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3266 HTMLElement *This = impl_from_IHTMLElement3(iface);
3267 nsresult nsres;
3268 nsAString str;
3270 TRACE("(%p)->(%p)\n", This, p);
3272 nsAString_Init(&str, NULL);
3273 nsres = nsIDOMHTMLElement_GetContentEditable(This->nselem, &str);
3274 return return_nsstr(nsres, &str, p);
3277 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3279 HTMLElement *This = impl_from_IHTMLElement3(iface);
3280 FIXME("(%p)->(%p)\n", This, p);
3281 return E_NOTIMPL;
3284 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3286 HTMLElement *This = impl_from_IHTMLElement3(iface);
3287 FIXME("(%p)->(%x)\n", This, v);
3288 return E_NOTIMPL;
3291 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3293 HTMLElement *This = impl_from_IHTMLElement3(iface);
3294 FIXME("(%p)->(%p)\n", This, p);
3295 return E_NOTIMPL;
3298 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3300 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3302 HTMLElement *This = impl_from_IHTMLElement3(iface);
3303 VARIANT *var;
3304 HRESULT hres;
3306 TRACE("(%p)->(%x)\n", This, v);
3308 if(This->node.vtbl->put_disabled)
3309 return This->node.vtbl->put_disabled(&This->node, v);
3311 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3312 if(FAILED(hres))
3313 return hres;
3315 VariantClear(var);
3316 V_VT(var) = VT_BOOL;
3317 V_BOOL(var) = v;
3318 return S_OK;
3321 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3323 HTMLElement *This = impl_from_IHTMLElement3(iface);
3324 VARIANT *var;
3325 HRESULT hres;
3327 TRACE("(%p)->(%p)\n", This, p);
3329 if(This->node.vtbl->get_disabled)
3330 return This->node.vtbl->get_disabled(&This->node, p);
3332 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3333 if(hres == DISP_E_UNKNOWNNAME) {
3334 *p = VARIANT_FALSE;
3335 return S_OK;
3337 if(FAILED(hres))
3338 return hres;
3340 if(V_VT(var) != VT_BOOL) {
3341 FIXME("value is %s\n", debugstr_variant(var));
3342 return E_NOTIMPL;
3345 *p = V_BOOL(var);
3346 return S_OK;
3349 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3351 HTMLElement *This = impl_from_IHTMLElement3(iface);
3352 FIXME("(%p)->(%p)\n", This, p);
3353 return E_NOTIMPL;
3356 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3358 HTMLElement *This = impl_from_IHTMLElement3(iface);
3359 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3360 return E_NOTIMPL;
3363 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3365 HTMLElement *This = impl_from_IHTMLElement3(iface);
3366 FIXME("(%p)->(%p)\n", This, p);
3367 return E_NOTIMPL;
3370 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3372 HTMLElement *This = impl_from_IHTMLElement3(iface);
3373 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3374 return E_NOTIMPL;
3377 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3379 HTMLElement *This = impl_from_IHTMLElement3(iface);
3380 FIXME("(%p)->(%p)\n", This, p);
3381 return E_NOTIMPL;
3384 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3385 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3387 HTMLElement *This = impl_from_IHTMLElement3(iface);
3389 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3390 pfCancelled);
3392 return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3395 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
3397 HTMLElement *This = impl_from_IHTMLElement3(iface);
3398 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3399 return E_NOTIMPL;
3402 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
3404 HTMLElement *This = impl_from_IHTMLElement3(iface);
3405 FIXME("(%p)->(%p)\n", This, p);
3406 return E_NOTIMPL;
3409 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3411 HTMLElement *This = impl_from_IHTMLElement3(iface);
3412 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3413 return E_NOTIMPL;
3416 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3418 HTMLElement *This = impl_from_IHTMLElement3(iface);
3419 FIXME("(%p)->(%p)\n", This, p);
3420 return E_NOTIMPL;
3423 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3425 HTMLElement *This = impl_from_IHTMLElement3(iface);
3426 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3427 return E_NOTIMPL;
3430 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3432 HTMLElement *This = impl_from_IHTMLElement3(iface);
3433 FIXME("(%p)->(%p)\n", This, p);
3434 return E_NOTIMPL;
3437 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3439 HTMLElement *This = impl_from_IHTMLElement3(iface);
3440 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3441 return E_NOTIMPL;
3444 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3446 HTMLElement *This = impl_from_IHTMLElement3(iface);
3447 FIXME("(%p)->(%p)\n", This, p);
3448 return E_NOTIMPL;
3451 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3453 HTMLElement *This = impl_from_IHTMLElement3(iface);
3454 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3455 return E_NOTIMPL;
3458 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3460 HTMLElement *This = impl_from_IHTMLElement3(iface);
3461 FIXME("(%p)->(%p)\n", This, p);
3462 return E_NOTIMPL;
3465 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3467 HTMLElement *This = impl_from_IHTMLElement3(iface);
3468 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3469 return E_NOTIMPL;
3472 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3474 HTMLElement *This = impl_from_IHTMLElement3(iface);
3475 FIXME("(%p)->(%p)\n", This, p);
3476 return E_NOTIMPL;
3479 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3481 HTMLElement *This = impl_from_IHTMLElement3(iface);
3482 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3483 return E_NOTIMPL;
3486 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3488 HTMLElement *This = impl_from_IHTMLElement3(iface);
3489 FIXME("(%p)->(%p)\n", This, p);
3490 return E_NOTIMPL;
3493 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3495 HTMLElement *This = impl_from_IHTMLElement3(iface);
3496 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3497 return E_NOTIMPL;
3500 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3502 HTMLElement *This = impl_from_IHTMLElement3(iface);
3503 FIXME("(%p)->(%p)\n", This, p);
3504 return E_NOTIMPL;
3507 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3509 HTMLElement *This = impl_from_IHTMLElement3(iface);
3510 FIXME("(%p)->(%p)\n", This, pfRet);
3511 return E_NOTIMPL;
3514 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3516 HTMLElement *This = impl_from_IHTMLElement3(iface);
3517 FIXME("(%p)->(%p)\n", This, p);
3518 return E_NOTIMPL;
3521 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3522 HTMLElement3_QueryInterface,
3523 HTMLElement3_AddRef,
3524 HTMLElement3_Release,
3525 HTMLElement3_GetTypeInfoCount,
3526 HTMLElement3_GetTypeInfo,
3527 HTMLElement3_GetIDsOfNames,
3528 HTMLElement3_Invoke,
3529 HTMLElement3_mergeAttributes,
3530 HTMLElement3_get_isMultiLine,
3531 HTMLElement3_get_canHaveHTML,
3532 HTMLElement3_put_onlayoutcomplete,
3533 HTMLElement3_get_onlayoutcomplete,
3534 HTMLElement3_put_onpage,
3535 HTMLElement3_get_onpage,
3536 HTMLElement3_put_inflateBlock,
3537 HTMLElement3_get_inflateBlock,
3538 HTMLElement3_put_onbeforedeactivate,
3539 HTMLElement3_get_onbeforedeactivate,
3540 HTMLElement3_setActive,
3541 HTMLElement3_put_contentEditable,
3542 HTMLElement3_get_contentEditable,
3543 HTMLElement3_get_isContentEditable,
3544 HTMLElement3_put_hideFocus,
3545 HTMLElement3_get_hideFocus,
3546 HTMLElement3_put_disabled,
3547 HTMLElement3_get_disabled,
3548 HTMLElement3_get_isDisabled,
3549 HTMLElement3_put_onmove,
3550 HTMLElement3_get_onmove,
3551 HTMLElement3_put_oncontrolselect,
3552 HTMLElement3_get_oncontrolselect,
3553 HTMLElement3_fireEvent,
3554 HTMLElement3_put_onresizestart,
3555 HTMLElement3_get_onresizestart,
3556 HTMLElement3_put_onresizeend,
3557 HTMLElement3_get_onresizeend,
3558 HTMLElement3_put_onmovestart,
3559 HTMLElement3_get_onmovestart,
3560 HTMLElement3_put_onmoveend,
3561 HTMLElement3_get_onmoveend,
3562 HTMLElement3_put_onmousecenter,
3563 HTMLElement3_get_onmousecenter,
3564 HTMLElement3_put_onmouseleave,
3565 HTMLElement3_get_onmouseleave,
3566 HTMLElement3_put_onactivate,
3567 HTMLElement3_get_onactivate,
3568 HTMLElement3_put_ondeactivate,
3569 HTMLElement3_get_ondeactivate,
3570 HTMLElement3_dragDrop,
3571 HTMLElement3_get_glyphMode
3574 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3576 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3579 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3580 REFIID riid, void **ppv)
3582 HTMLElement *This = impl_from_IHTMLElement4(iface);
3583 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3586 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3588 HTMLElement *This = impl_from_IHTMLElement4(iface);
3589 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3592 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3594 HTMLElement *This = impl_from_IHTMLElement4(iface);
3595 return IHTMLElement_Release(&This->IHTMLElement_iface);
3598 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3600 HTMLElement *This = impl_from_IHTMLElement4(iface);
3601 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3604 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3605 LCID lcid, ITypeInfo **ppTInfo)
3607 HTMLElement *This = impl_from_IHTMLElement4(iface);
3608 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3611 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3612 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3614 HTMLElement *This = impl_from_IHTMLElement4(iface);
3615 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3616 lcid, rgDispId);
3619 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3620 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3622 HTMLElement *This = impl_from_IHTMLElement4(iface);
3623 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3624 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3627 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3629 HTMLElement *This = impl_from_IHTMLElement4(iface);
3631 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3633 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3636 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3638 HTMLElement *This = impl_from_IHTMLElement4(iface);
3640 TRACE("(%p)->(%p)\n", This, p);
3642 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3645 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3647 HTMLElement *This = impl_from_IHTMLElement4(iface);
3648 FIXME("(%p)\n", This);
3649 return E_NOTIMPL;
3652 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3654 HTMLElement *This = impl_from_IHTMLElement4(iface);
3655 HTMLAttributeCollection *attrs;
3656 HRESULT hres;
3658 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3660 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3661 if(FAILED(hres))
3662 return hres;
3664 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3665 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3666 return hres;
3669 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3670 IHTMLDOMAttribute **ppretAttribute)
3672 HTMLElement *This = impl_from_IHTMLElement4(iface);
3673 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3674 return E_NOTIMPL;
3677 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3678 IHTMLDOMAttribute **ppretAttribute)
3680 HTMLElement *This = impl_from_IHTMLElement4(iface);
3681 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3682 return E_NOTIMPL;
3685 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3687 HTMLElement *This = impl_from_IHTMLElement4(iface);
3688 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3689 return E_NOTIMPL;
3692 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3694 HTMLElement *This = impl_from_IHTMLElement4(iface);
3695 FIXME("(%p)->(%p)\n", This, p);
3696 return E_NOTIMPL;
3699 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3701 HTMLElement *This = impl_from_IHTMLElement4(iface);
3703 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3705 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3708 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3710 HTMLElement *This = impl_from_IHTMLElement4(iface);
3712 TRACE("(%p)->(%p)\n", This, p);
3714 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3717 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3719 HTMLElement *This = impl_from_IHTMLElement4(iface);
3720 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3721 return E_NOTIMPL;
3724 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3726 HTMLElement *This = impl_from_IHTMLElement4(iface);
3727 FIXME("(%p)->(%p)\n", This, p);
3728 return E_NOTIMPL;
3731 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3732 HTMLElement4_QueryInterface,
3733 HTMLElement4_AddRef,
3734 HTMLElement4_Release,
3735 HTMLElement4_GetTypeInfoCount,
3736 HTMLElement4_GetTypeInfo,
3737 HTMLElement4_GetIDsOfNames,
3738 HTMLElement4_Invoke,
3739 HTMLElement4_put_onmousewheel,
3740 HTMLElement4_get_onmousewheel,
3741 HTMLElement4_normalize,
3742 HTMLElement4_getAttributeNode,
3743 HTMLElement4_setAttributeNode,
3744 HTMLElement4_removeAttributeNode,
3745 HTMLElement4_put_onbeforeactivate,
3746 HTMLElement4_get_onbeforeactivate,
3747 HTMLElement4_put_onfocusin,
3748 HTMLElement4_get_onfocusin,
3749 HTMLElement4_put_onfocusout,
3750 HTMLElement4_get_onfocusout
3753 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
3755 return CONTAINING_RECORD(iface, HTMLElement, node);
3758 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
3760 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3762 if(IsEqualGUID(&IID_IUnknown, riid)) {
3763 *ppv = &This->IHTMLElement_iface;
3764 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
3765 *ppv = &This->IHTMLElement_iface;
3766 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
3767 *ppv = &This->IHTMLElement_iface;
3768 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
3769 *ppv = &This->IHTMLElement2_iface;
3770 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
3771 *ppv = &This->IHTMLElement3_iface;
3772 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
3773 *ppv = &This->IHTMLElement4_iface;
3774 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
3775 *ppv = &This->cp_container.IConnectionPointContainer_iface;
3776 }else {
3777 return HTMLDOMNode_QI(&This->node, riid, ppv);
3780 IUnknown_AddRef((IUnknown*)*ppv);
3781 return S_OK;
3784 void HTMLElement_destructor(HTMLDOMNode *iface)
3786 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3788 ConnectionPointContainer_Destroy(&This->cp_container);
3790 if(This->style) {
3791 This->style->elem = NULL;
3792 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
3794 if(This->runtime_style) {
3795 This->runtime_style->elem = NULL;
3796 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
3798 if(This->attrs) {
3799 HTMLDOMAttribute *attr;
3801 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
3802 attr->elem = NULL;
3804 This->attrs->elem = NULL;
3805 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
3808 heap_free(This->filter);
3810 HTMLDOMNode_destructor(&This->node);
3813 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
3815 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3816 HTMLElement *new_elem;
3817 HRESULT hres;
3819 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
3820 if(FAILED(hres))
3821 return hres;
3823 if(This->filter) {
3824 new_elem->filter = heap_strdupW(This->filter);
3825 if(!new_elem->filter) {
3826 IHTMLElement_Release(&This->IHTMLElement_iface);
3827 return E_OUTOFMEMORY;
3831 *ret = &new_elem->node;
3832 return S_OK;
3835 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
3837 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3839 switch(eid) {
3840 case EVENTID_KEYDOWN: {
3841 nsIDOMKeyEvent *key_event;
3842 nsresult nsres;
3844 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
3845 if(NS_SUCCEEDED(nsres)) {
3846 UINT32 code = 0;
3848 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
3850 switch(code) {
3851 case VK_F1: /* DOM_VK_F1 */
3852 TRACE("F1 pressed\n");
3853 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
3854 *prevent_default = TRUE;
3857 nsIDOMKeyEvent_Release(key_event);
3862 return S_OK;
3865 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
3867 const cpc_entry_t HTMLElement_cpc[] = {
3868 HTMLELEMENT_CPC,
3869 {NULL}
3872 static const NodeImplVtbl HTMLElementImplVtbl = {
3873 HTMLElement_QI,
3874 HTMLElement_destructor,
3875 HTMLElement_cpc,
3876 HTMLElement_clone,
3877 HTMLElement_handle_event,
3878 HTMLElement_get_attr_col
3881 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
3883 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
3886 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
3887 DWORD grfdex, DISPID *pid)
3889 HTMLElement *This = impl_from_DispatchEx(dispex);
3891 if(This->node.vtbl->get_dispid)
3892 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
3894 return DISP_E_UNKNOWNNAME;
3897 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
3898 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
3899 IServiceProvider *caller)
3901 HTMLElement *This = impl_from_DispatchEx(dispex);
3903 if(This->node.vtbl->invoke)
3904 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
3905 params, res, ei, caller);
3907 ERR("(%p): element has no invoke method\n", This);
3908 return E_NOTIMPL;
3911 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
3913 HTMLElement *This = impl_from_DispatchEx(dispex);
3914 nsIDOMMozNamedAttrMap *attrs;
3915 nsIDOMAttr *attr;
3916 nsAString nsstr;
3917 const PRUnichar *str;
3918 BSTR name;
3919 VARIANT value;
3920 unsigned i;
3921 UINT32 len;
3922 DISPID id;
3923 nsresult nsres;
3924 HRESULT hres;
3926 if(!This->nselem)
3927 return S_FALSE;
3929 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
3930 if(NS_FAILED(nsres))
3931 return E_FAIL;
3933 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
3934 if(NS_FAILED(nsres)) {
3935 nsIDOMMozNamedAttrMap_Release(attrs);
3936 return E_FAIL;
3939 nsAString_Init(&nsstr, NULL);
3940 for(i=0; i<len; i++) {
3941 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
3942 if(NS_FAILED(nsres))
3943 continue;
3945 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
3946 if(NS_FAILED(nsres)) {
3947 nsIDOMAttr_Release(attr);
3948 continue;
3951 nsAString_GetData(&nsstr, &str);
3952 name = SysAllocString(str);
3953 if(!name) {
3954 nsIDOMAttr_Release(attr);
3955 continue;
3958 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
3959 if(hres != DISP_E_UNKNOWNNAME) {
3960 nsIDOMAttr_Release(attr);
3961 SysFreeString(name);
3962 continue;
3965 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
3966 nsIDOMAttr_Release(attr);
3967 if(NS_FAILED(nsres)) {
3968 SysFreeString(name);
3969 continue;
3972 nsAString_GetData(&nsstr, &str);
3973 V_VT(&value) = VT_BSTR;
3974 if(*str) {
3975 V_BSTR(&value) = SysAllocString(str);
3976 if(!V_BSTR(&value)) {
3977 SysFreeString(name);
3978 continue;
3980 } else
3981 V_BSTR(&value) = NULL;
3983 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
3984 SysFreeString(name);
3985 VariantClear(&value);
3987 nsAString_Finish(&nsstr);
3989 nsIDOMMozNamedAttrMap_Release(attrs);
3990 return S_OK;
3993 static event_target_t **HTMLElement_get_event_target_ptr(DispatchEx *dispex)
3995 HTMLElement *This = impl_from_DispatchEx(dispex);
3996 return This->node.vtbl->get_event_target_ptr
3997 ? This->node.vtbl->get_event_target_ptr(&This->node)
3998 : &This->node.event_target.ptr;
4001 static void HTMLElement_bind_event(DispatchEx *dispex, int eid)
4003 HTMLElement *This = impl_from_DispatchEx(dispex);
4004 This->node.doc->node.event_target.dispex.data->vtbl->bind_event(&This->node.doc->node.event_target.dispex, eid);
4007 static const tid_t HTMLElement_iface_tids[] = {
4008 HTMLELEMENT_TIDS,
4012 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
4013 NULL,
4014 HTMLElement_get_dispid,
4015 HTMLElement_invoke,
4016 HTMLElement_populate_props,
4017 HTMLElement_get_event_target_ptr,
4018 HTMLElement_bind_event
4021 static dispex_static_data_t HTMLElement_dispex = {
4022 &HTMLElement_dispex_vtbl,
4023 DispHTMLUnknownElement_tid,
4024 NULL,
4025 HTMLElement_iface_tids
4028 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
4030 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
4031 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
4032 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
4033 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
4035 if(dispex_data && !dispex_data->vtbl)
4036 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
4037 init_dispex(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
4038 dispex_data ? dispex_data : &HTMLElement_dispex);
4040 if(nselem) {
4041 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
4043 /* No AddRef, share reference with HTMLDOMNode */
4044 assert((nsIDOMNode*)nselem == This->node.nsnode);
4045 This->nselem = nselem;
4048 This->node.cp_container = &This->cp_container;
4049 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
4052 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
4054 nsIDOMHTMLElement *nselem;
4055 nsAString class_name_str;
4056 const PRUnichar *class_name;
4057 const tag_desc_t *tag;
4058 HTMLElement *elem;
4059 nsresult nsres;
4060 HRESULT hres;
4062 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
4063 if(NS_FAILED(nsres))
4064 return E_FAIL;
4066 nsAString_Init(&class_name_str, NULL);
4067 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
4069 nsAString_GetData(&class_name_str, &class_name);
4071 tag = get_tag_desc(class_name);
4072 if(tag) {
4073 hres = tag->constructor(doc, nselem, &elem);
4074 }else if(use_generic) {
4075 hres = HTMLGenericElement_Create(doc, nselem, &elem);
4076 }else {
4077 elem = heap_alloc_zero(sizeof(HTMLElement));
4078 if(elem) {
4079 elem->node.vtbl = &HTMLElementImplVtbl;
4080 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
4081 hres = S_OK;
4082 }else {
4083 hres = E_OUTOFMEMORY;
4087 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
4089 nsIDOMHTMLElement_Release(nselem);
4090 nsAString_Finish(&class_name_str);
4091 if(FAILED(hres))
4092 return hres;
4094 *ret = elem;
4095 return S_OK;
4098 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
4100 HTMLDOMNode *node;
4101 HRESULT hres;
4103 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
4104 if(FAILED(hres))
4105 return hres;
4107 *ret = impl_from_HTMLDOMNode(node);
4108 return S_OK;
4111 /* interface IHTMLFiltersCollection */
4112 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
4114 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4116 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
4118 if(IsEqualGUID(&IID_IUnknown, riid)) {
4119 *ppv = &This->IHTMLFiltersCollection_iface;
4120 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
4121 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
4122 *ppv = &This->IHTMLFiltersCollection_iface;
4123 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4124 return *ppv ? S_OK : E_NOINTERFACE;
4125 }else {
4126 *ppv = NULL;
4127 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4128 return E_NOINTERFACE;
4131 IUnknown_AddRef((IUnknown*)*ppv);
4132 return S_OK;
4135 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
4137 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4138 LONG ref = InterlockedIncrement(&This->ref);
4140 TRACE("(%p) ref=%d\n", This, ref);
4142 return ref;
4145 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
4147 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4148 LONG ref = InterlockedDecrement(&This->ref);
4150 TRACE("(%p) ref=%d\n", This, ref);
4152 if(!ref)
4154 heap_free(This);
4157 return ref;
4160 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
4162 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4163 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4166 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
4167 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
4169 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4170 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4173 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
4174 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
4175 LCID lcid, DISPID *rgDispId)
4177 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4178 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4179 lcid, rgDispId);
4182 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
4183 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
4184 EXCEPINFO *pExcepInfo, UINT *puArgErr)
4186 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4187 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4188 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4191 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
4193 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4195 if(!p)
4196 return E_POINTER;
4198 FIXME("(%p)->(%p) Always returning 0\n", This, p);
4199 *p = 0;
4201 return S_OK;
4204 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
4206 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4207 FIXME("(%p)->(%p)\n", This, p);
4208 return E_NOTIMPL;
4211 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
4213 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4214 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
4215 return E_NOTIMPL;
4218 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
4219 HTMLFiltersCollection_QueryInterface,
4220 HTMLFiltersCollection_AddRef,
4221 HTMLFiltersCollection_Release,
4222 HTMLFiltersCollection_GetTypeInfoCount,
4223 HTMLFiltersCollection_GetTypeInfo,
4224 HTMLFiltersCollection_GetIDsOfNames,
4225 HTMLFiltersCollection_Invoke,
4226 HTMLFiltersCollection_get_length,
4227 HTMLFiltersCollection_get__newEnum,
4228 HTMLFiltersCollection_item
4231 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4233 WCHAR *ptr;
4234 int idx = 0;
4236 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
4237 idx = idx*10 + (*ptr-'0');
4238 if(*ptr)
4239 return DISP_E_UNKNOWNNAME;
4241 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
4242 TRACE("ret %x\n", *dispid);
4243 return S_OK;
4246 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4247 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4249 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
4251 V_VT(res) = VT_DISPATCH;
4252 V_DISPATCH(res) = NULL;
4254 FIXME("always returning NULL\n");
4256 return S_OK;
4259 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
4260 NULL,
4261 HTMLFiltersCollection_get_dispid,
4262 HTMLFiltersCollection_invoke,
4263 NULL
4266 static const tid_t HTMLFiltersCollection_iface_tids[] = {
4267 IHTMLFiltersCollection_tid,
4270 static dispex_static_data_t HTMLFiltersCollection_dispex = {
4271 &HTMLFiltersCollection_dispex_vtbl,
4272 IHTMLFiltersCollection_tid,
4273 NULL,
4274 HTMLFiltersCollection_iface_tids
4277 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
4279 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
4281 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
4282 ret->ref = 1;
4284 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
4285 &HTMLFiltersCollection_dispex);
4287 return &ret->IHTMLFiltersCollection_iface;
4290 /* interface IHTMLAttributeCollection */
4291 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
4293 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
4296 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
4298 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4300 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4302 if(IsEqualGUID(&IID_IUnknown, riid)) {
4303 *ppv = &This->IHTMLAttributeCollection_iface;
4304 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
4305 *ppv = &This->IHTMLAttributeCollection_iface;
4306 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
4307 *ppv = &This->IHTMLAttributeCollection2_iface;
4308 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
4309 *ppv = &This->IHTMLAttributeCollection3_iface;
4310 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4311 return *ppv ? S_OK : E_NOINTERFACE;
4312 }else {
4313 *ppv = NULL;
4314 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4315 return E_NOINTERFACE;
4318 IUnknown_AddRef((IUnknown*)*ppv);
4319 return S_OK;
4322 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
4324 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4325 LONG ref = InterlockedIncrement(&This->ref);
4327 TRACE("(%p) ref=%d\n", This, ref);
4329 return ref;
4332 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
4334 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4335 LONG ref = InterlockedDecrement(&This->ref);
4337 TRACE("(%p) ref=%d\n", This, ref);
4339 if(!ref) {
4340 while(!list_empty(&This->attrs)) {
4341 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
4343 list_remove(&attr->entry);
4344 attr->elem = NULL;
4345 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4348 heap_free(This);
4351 return ref;
4354 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
4356 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4357 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4360 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
4361 LCID lcid, ITypeInfo **ppTInfo)
4363 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4364 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4367 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
4368 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4370 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4371 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4372 lcid, rgDispId);
4375 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
4376 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4377 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4379 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4380 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4381 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4384 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
4386 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
4387 DISPID id = DISPID_STARTENUM;
4388 LONG len = -1;
4389 HRESULT hres;
4391 FIXME("filter non-enumerable attributes out\n");
4393 while(1) {
4394 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
4395 if(FAILED(hres))
4396 return hres;
4397 else if(hres == S_FALSE)
4398 break;
4400 len++;
4401 if(len == *idx)
4402 break;
4405 if(dispid) {
4406 *dispid = id;
4407 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
4410 *idx = len+1;
4411 return S_OK;
4414 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
4416 HRESULT hres;
4418 if(name[0]>='0' && name[0]<='9') {
4419 WCHAR *end_ptr;
4420 LONG idx;
4422 idx = strtoulW(name, &end_ptr, 10);
4423 if(!*end_ptr) {
4424 hres = get_attr_dispid_by_idx(This, &idx, id);
4425 if(SUCCEEDED(hres))
4426 return hres;
4430 if(!This->elem) {
4431 WARN("NULL elem\n");
4432 return E_UNEXPECTED;
4435 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
4436 name, fdexNameCaseInsensitive, id);
4437 return hres;
4440 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
4442 HTMLDOMAttribute *iter;
4443 LONG pos = 0;
4444 HRESULT hres;
4446 *attr = NULL;
4447 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4448 if(iter->dispid == id) {
4449 *attr = iter;
4450 break;
4452 pos++;
4455 if(!*attr) {
4456 if(!This->elem) {
4457 WARN("NULL elem\n");
4458 return E_UNEXPECTED;
4461 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
4462 if(FAILED(hres))
4463 return hres;
4466 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
4467 if(list_pos)
4468 *list_pos = pos;
4469 return S_OK;
4472 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
4474 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4475 HRESULT hres;
4477 TRACE("(%p)->(%p)\n", This, p);
4479 *p = -1;
4480 hres = get_attr_dispid_by_idx(This, p, NULL);
4481 return hres;
4484 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
4486 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4487 FIXME("(%p)->(%p)\n", This, p);
4488 return E_NOTIMPL;
4491 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
4493 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4494 HTMLDOMAttribute *attr;
4495 DISPID id;
4496 HRESULT hres;
4498 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
4500 switch(V_VT(name)) {
4501 case VT_I4:
4502 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
4503 break;
4504 case VT_BSTR:
4505 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
4506 break;
4507 default:
4508 FIXME("unsupported name %s\n", debugstr_variant(name));
4509 hres = E_NOTIMPL;
4511 if(hres == DISP_E_UNKNOWNNAME)
4512 return E_INVALIDARG;
4513 if(FAILED(hres))
4514 return hres;
4516 hres = get_domattr(This, id, NULL, &attr);
4517 if(FAILED(hres))
4518 return hres;
4520 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
4521 return S_OK;
4524 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
4525 HTMLAttributeCollection_QueryInterface,
4526 HTMLAttributeCollection_AddRef,
4527 HTMLAttributeCollection_Release,
4528 HTMLAttributeCollection_GetTypeInfoCount,
4529 HTMLAttributeCollection_GetTypeInfo,
4530 HTMLAttributeCollection_GetIDsOfNames,
4531 HTMLAttributeCollection_Invoke,
4532 HTMLAttributeCollection_get_length,
4533 HTMLAttributeCollection__newEnum,
4534 HTMLAttributeCollection_item
4537 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
4539 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
4542 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
4544 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4545 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4548 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
4550 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4551 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4554 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
4556 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4557 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4560 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
4562 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4563 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4566 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
4567 LCID lcid, ITypeInfo **ppTInfo)
4569 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4570 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4573 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
4574 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4576 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4577 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4578 lcid, rgDispId);
4581 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
4582 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4583 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4585 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4586 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4587 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4590 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
4591 IHTMLDOMAttribute **newretNode)
4593 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4594 HTMLDOMAttribute *attr;
4595 DISPID id;
4596 HRESULT hres;
4598 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4600 hres = get_attr_dispid_by_name(This, bstrName, &id);
4601 if(hres == DISP_E_UNKNOWNNAME) {
4602 *newretNode = NULL;
4603 return S_OK;
4604 } else if(FAILED(hres)) {
4605 return hres;
4608 hres = get_domattr(This, id, NULL, &attr);
4609 if(FAILED(hres))
4610 return hres;
4612 *newretNode = &attr->IHTMLDOMAttribute_iface;
4613 return S_OK;
4616 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
4617 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
4619 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4620 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
4621 return E_NOTIMPL;
4624 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
4625 BSTR bstrName, IHTMLDOMAttribute **newretNode)
4627 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4628 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4629 return E_NOTIMPL;
4632 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
4633 HTMLAttributeCollection2_QueryInterface,
4634 HTMLAttributeCollection2_AddRef,
4635 HTMLAttributeCollection2_Release,
4636 HTMLAttributeCollection2_GetTypeInfoCount,
4637 HTMLAttributeCollection2_GetTypeInfo,
4638 HTMLAttributeCollection2_GetIDsOfNames,
4639 HTMLAttributeCollection2_Invoke,
4640 HTMLAttributeCollection2_getNamedItem,
4641 HTMLAttributeCollection2_setNamedItem,
4642 HTMLAttributeCollection2_removeNamedItem
4645 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
4647 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
4650 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
4652 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4653 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4656 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
4658 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4659 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4662 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
4664 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4665 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4668 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
4670 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4671 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4674 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
4675 LCID lcid, ITypeInfo **ppTInfo)
4677 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4678 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4681 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
4682 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4684 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4685 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4686 lcid, rgDispId);
4689 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
4690 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4691 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4693 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4694 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4695 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4698 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
4699 IHTMLDOMAttribute **ppNodeOut)
4701 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4702 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
4705 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
4706 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
4708 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4709 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
4710 return E_NOTIMPL;
4713 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
4714 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
4716 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4717 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
4718 return E_NOTIMPL;
4721 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
4723 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4724 HTMLDOMAttribute *attr;
4725 DISPID id;
4726 HRESULT hres;
4728 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
4730 hres = get_attr_dispid_by_idx(This, &index, &id);
4731 if(hres == DISP_E_UNKNOWNNAME)
4732 return E_INVALIDARG;
4733 if(FAILED(hres))
4734 return hres;
4736 hres = get_domattr(This, id, NULL, &attr);
4737 if(FAILED(hres))
4738 return hres;
4740 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
4741 return S_OK;
4744 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
4746 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4747 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
4750 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
4751 HTMLAttributeCollection3_QueryInterface,
4752 HTMLAttributeCollection3_AddRef,
4753 HTMLAttributeCollection3_Release,
4754 HTMLAttributeCollection3_GetTypeInfoCount,
4755 HTMLAttributeCollection3_GetTypeInfo,
4756 HTMLAttributeCollection3_GetIDsOfNames,
4757 HTMLAttributeCollection3_Invoke,
4758 HTMLAttributeCollection3_getNamedItem,
4759 HTMLAttributeCollection3_setNamedItem,
4760 HTMLAttributeCollection3_removeNamedItem,
4761 HTMLAttributeCollection3_item,
4762 HTMLAttributeCollection3_get_length
4765 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
4767 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
4770 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4772 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4773 HTMLDOMAttribute *attr;
4774 LONG pos;
4775 HRESULT hres;
4777 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
4779 hres = get_attr_dispid_by_name(This, name, dispid);
4780 if(FAILED(hres))
4781 return hres;
4783 hres = get_domattr(This, *dispid, &pos, &attr);
4784 if(FAILED(hres))
4785 return hres;
4786 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4788 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
4789 return S_OK;
4792 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4793 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4795 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4797 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
4799 switch(flags) {
4800 case DISPATCH_PROPERTYGET: {
4801 HTMLDOMAttribute *iter;
4802 DWORD pos;
4804 pos = id-MSHTML_DISPID_CUSTOM_MIN;
4806 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4807 if(!pos) {
4808 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
4809 V_VT(res) = VT_DISPATCH;
4810 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
4811 return S_OK;
4813 pos--;
4816 WARN("invalid arg\n");
4817 return E_INVALIDARG;
4820 default:
4821 FIXME("unimplemented flags %x\n", flags);
4822 return E_NOTIMPL;
4826 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
4827 NULL,
4828 HTMLAttributeCollection_get_dispid,
4829 HTMLAttributeCollection_invoke,
4830 NULL
4833 static const tid_t HTMLAttributeCollection_iface_tids[] = {
4834 IHTMLAttributeCollection_tid,
4835 IHTMLAttributeCollection2_tid,
4836 IHTMLAttributeCollection3_tid,
4840 static dispex_static_data_t HTMLAttributeCollection_dispex = {
4841 &HTMLAttributeCollection_dispex_vtbl,
4842 DispHTMLAttributeCollection_tid,
4843 NULL,
4844 HTMLAttributeCollection_iface_tids
4847 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
4849 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4851 if(This->attrs) {
4852 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
4853 *ac = This->attrs;
4854 return S_OK;
4857 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
4858 if(!This->attrs)
4859 return E_OUTOFMEMORY;
4861 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
4862 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
4863 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
4864 This->attrs->ref = 2;
4866 This->attrs->elem = This;
4867 list_init(&This->attrs->attrs);
4868 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
4869 &HTMLAttributeCollection_dispex);
4871 *ac = This->attrs;
4872 return S_OK;