include: Add event trace flags and guid to evntrace.h.
[wine.git] / dlls / mshtml / htmlelem.c
blobae2eeee1c32c15de499f961174f660bdc569c116
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 bodyW[] = {'B','O','D','Y',0};
43 static const WCHAR buttonW[] = {'B','U','T','T','O','N',0};
44 static const WCHAR embedW[] = {'E','M','B','E','D',0};
45 static const WCHAR formW[] = {'F','O','R','M',0};
46 static const WCHAR frameW[] = {'F','R','A','M','E',0};
47 static const WCHAR headW[] = {'H','E','A','D',0};
48 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
49 static const WCHAR imgW[] = {'I','M','G',0};
50 static const WCHAR inputW[] = {'I','N','P','U','T',0};
51 static const WCHAR labelW[] = {'L','A','B','E','L',0};
52 static const WCHAR linkW[] = {'L','I','N','K',0};
53 static const WCHAR metaW[] = {'M','E','T','A',0};
54 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
55 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
56 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
57 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
58 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
59 static const WCHAR tableW[] = {'T','A','B','L','E',0};
60 static const WCHAR tdW[] = {'T','D',0};
61 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
62 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
63 static const WCHAR trW[] = {'T','R',0};
65 typedef struct {
66 const WCHAR *name;
67 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
68 } tag_desc_t;
70 static const tag_desc_t tag_descs[] = {
71 {aW, HTMLAnchorElement_Create},
72 {bodyW, HTMLBodyElement_Create},
73 {buttonW, HTMLButtonElement_Create},
74 {embedW, HTMLEmbedElement_Create},
75 {formW, HTMLFormElement_Create},
76 {frameW, HTMLFrameElement_Create},
77 {headW, HTMLHeadElement_Create},
78 {iframeW, HTMLIFrame_Create},
79 {imgW, HTMLImgElement_Create},
80 {inputW, HTMLInputElement_Create},
81 {labelW, HTMLLabelElement_Create},
82 {linkW, HTMLLinkElement_Create},
83 {metaW, HTMLMetaElement_Create},
84 {objectW, HTMLObjectElement_Create},
85 {optionW, HTMLOptionElement_Create},
86 {scriptW, HTMLScriptElement_Create},
87 {selectW, HTMLSelectElement_Create},
88 {styleW, HTMLStyleElement_Create},
89 {tableW, HTMLTable_Create},
90 {tdW, HTMLTableCell_Create},
91 {textareaW, HTMLTextAreaElement_Create},
92 {title_tagW, HTMLTitleElement_Create},
93 {trW, HTMLTableRow_Create}
96 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
98 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
99 int r;
101 while(min <= max) {
102 i = (min+max)/2;
103 r = strcmpW(tag_name, tag_descs[i].name);
104 if(!r)
105 return tag_descs+i;
107 if(r < 0)
108 max = i-1;
109 else
110 min = i+1;
113 return NULL;
116 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
118 nsIDOMDocumentFragment *nsfragment;
119 nsIDOMNode *nsparent;
120 nsIDOMRange *range;
121 nsAString html_str;
122 nsresult nsres;
123 HRESULT hres = S_OK;
125 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
126 if(NS_FAILED(nsres)) {
127 ERR("CreateRange failed: %08x\n", nsres);
128 return E_FAIL;
131 nsAString_InitDepend(&html_str, html);
132 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
133 nsIDOMRange_Release(range);
134 nsAString_Finish(&html_str);
135 if(NS_FAILED(nsres)) {
136 ERR("CreateContextualFragment failed: %08x\n", nsres);
137 return E_FAIL;
140 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
141 if(NS_SUCCEEDED(nsres) && nsparent) {
142 nsIDOMNode *nstmp;
144 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
145 nsIDOMNode_Release(nsparent);
146 if(NS_FAILED(nsres)) {
147 ERR("ReplaceChild failed: %08x\n", nsres);
148 hres = E_FAIL;
149 }else if(nstmp) {
150 nsIDOMNode_Release(nstmp);
152 }else {
153 ERR("GetParentNode failed: %08x\n", nsres);
154 hres = E_FAIL;
157 nsIDOMDocumentFragment_Release(nsfragment);
158 return hres;
161 nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
163 nsAString name_str;
164 nsresult nsres;
166 nsAString_InitDepend(&name_str, name);
167 nsAString_Init(val_str, NULL);
168 nsres = nsIDOMHTMLElement_GetAttribute(nselem, &name_str, val_str);
169 nsAString_Finish(&name_str);
170 if(NS_FAILED(nsres)) {
171 ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name), nsres);
172 nsAString_Finish(val_str);
173 return nsres;
176 nsAString_GetData(val_str, val);
177 return NS_OK;
180 HRESULT elem_string_attr_getter(HTMLElement *elem, const WCHAR *name, BOOL use_null, BSTR *p)
182 const PRUnichar *val;
183 nsAString val_str;
184 nsresult nsres;
185 HRESULT hres = S_OK;
187 nsres = get_elem_attr_value(elem->nselem, name, &val_str, &val);
188 if(NS_FAILED(nsres))
189 return E_FAIL;
191 TRACE("%s: returning %s\n", debugstr_w(name), debugstr_w(val));
193 if(*val || !use_null) {
194 *p = SysAllocString(val);
195 if(!*p)
196 hres = E_OUTOFMEMORY;
197 }else {
198 *p = NULL;
200 nsAString_Finish(&val_str);
201 return hres;
204 HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHAR *value)
206 nsAString name_str, val_str;
207 nsresult nsres;
209 nsAString_InitDepend(&name_str, name);
210 nsAString_InitDepend(&val_str, value);
211 nsres = nsIDOMHTMLElement_SetAttribute(elem->nselem, &name_str, &val_str);
212 nsAString_Finish(&name_str);
213 nsAString_Finish(&val_str);
215 if(NS_FAILED(nsres)) {
216 WARN("SetAttribute failed: %08x\n", nsres);
217 return E_FAIL;
220 return S_OK;
223 HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
225 static const WCHAR uninitializedW[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
226 static const WCHAR loadingW[] = {'l','o','a','d','i','n','g',0};
227 static const WCHAR loadedW[] = {'l','o','a','d','e','d',0};
228 static const WCHAR interactiveW[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
229 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
231 static const LPCWSTR readystate_strs[] = {
232 uninitializedW,
233 loadingW,
234 loadedW,
235 interactiveW,
236 completeW
239 assert(readystate <= READYSTATE_COMPLETE);
240 *p = SysAllocString(readystate_strs[readystate]);
241 return *p ? S_OK : E_OUTOFMEMORY;
244 typedef struct
246 DispatchEx dispex;
247 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
249 LONG ref;
250 } HTMLFiltersCollection;
252 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
254 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
257 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
259 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
261 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
264 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
266 nsIDOMElement *nselem;
267 nsAString tag_str;
268 nsresult nsres;
270 if(!doc->nsdoc) {
271 WARN("NULL nsdoc\n");
272 return E_UNEXPECTED;
275 nsAString_InitDepend(&tag_str, tag);
276 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
277 nsAString_Finish(&tag_str);
278 if(NS_FAILED(nsres)) {
279 ERR("CreateElement failed: %08x\n", nsres);
280 return E_FAIL;
283 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
284 nsIDOMElement_Release(nselem);
285 if(NS_FAILED(nsres)) {
286 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
287 return E_FAIL;
290 return S_OK;
293 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
295 nsIDOMHTMLElement *nselem;
296 HRESULT hres;
298 /* Use owner doc if called on document fragment */
299 if(!doc->nsdoc)
300 doc = doc->node.doc;
302 hres = create_nselem(doc, tag, &nselem);
303 if(FAILED(hres))
304 return hres;
306 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
307 nsIDOMHTMLElement_Release(nselem);
308 return hres;
311 typedef struct {
312 DispatchEx dispex;
313 IHTMLRect IHTMLRect_iface;
315 LONG ref;
317 nsIDOMClientRect *nsrect;
318 } HTMLRect;
320 static inline HTMLRect *impl_from_IHTMLRect(IHTMLRect *iface)
322 return CONTAINING_RECORD(iface, HTMLRect, IHTMLRect_iface);
325 static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, void **ppv)
327 HTMLRect *This = impl_from_IHTMLRect(iface);
329 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
331 if(IsEqualGUID(&IID_IUnknown, riid)) {
332 *ppv = &This->IHTMLRect_iface;
333 }else if(IsEqualGUID(&IID_IHTMLRect, riid)) {
334 *ppv = &This->IHTMLRect_iface;
335 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
336 return *ppv ? S_OK : E_NOINTERFACE;
337 }else {
338 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
339 *ppv = NULL;
340 return E_NOINTERFACE;
343 IUnknown_AddRef((IUnknown*)*ppv);
344 return S_OK;
347 static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface)
349 HTMLRect *This = impl_from_IHTMLRect(iface);
350 LONG ref = InterlockedIncrement(&This->ref);
352 TRACE("(%p) ref=%d\n", This, ref);
354 return ref;
357 static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface)
359 HTMLRect *This = impl_from_IHTMLRect(iface);
360 LONG ref = InterlockedDecrement(&This->ref);
362 TRACE("(%p) ref=%d\n", This, ref);
364 if(!ref) {
365 if(This->nsrect)
366 nsIDOMClientRect_Release(This->nsrect);
367 heap_free(This);
370 return ref;
373 static HRESULT WINAPI HTMLRect_GetTypeInfoCount(IHTMLRect *iface, UINT *pctinfo)
375 HTMLRect *This = impl_from_IHTMLRect(iface);
376 FIXME("(%p)->(%p)\n", This, pctinfo);
377 return E_NOTIMPL;
380 static HRESULT WINAPI HTMLRect_GetTypeInfo(IHTMLRect *iface, UINT iTInfo,
381 LCID lcid, ITypeInfo **ppTInfo)
383 HTMLRect *This = impl_from_IHTMLRect(iface);
385 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
388 static HRESULT WINAPI HTMLRect_GetIDsOfNames(IHTMLRect *iface, REFIID riid,
389 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
391 HTMLRect *This = impl_from_IHTMLRect(iface);
393 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
394 lcid, rgDispId);
397 static HRESULT WINAPI HTMLRect_Invoke(IHTMLRect *iface, DISPID dispIdMember,
398 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
399 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
401 HTMLRect *This = impl_from_IHTMLRect(iface);
403 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
404 pDispParams, pVarResult, pExcepInfo, puArgErr);
407 static HRESULT WINAPI HTMLRect_put_left(IHTMLRect *iface, LONG v)
409 HTMLRect *This = impl_from_IHTMLRect(iface);
410 FIXME("(%p)->(%d)\n", This, v);
411 return E_NOTIMPL;
414 static HRESULT WINAPI HTMLRect_get_left(IHTMLRect *iface, LONG *p)
416 HTMLRect *This = impl_from_IHTMLRect(iface);
417 float left;
418 nsresult nsres;
420 TRACE("(%p)->(%p)\n", This, p);
422 nsres = nsIDOMClientRect_GetLeft(This->nsrect, &left);
423 if(NS_FAILED(nsres)) {
424 ERR("GetLeft failed: %08x\n", nsres);
425 return E_FAIL;
428 *p = floor(left+0.5);
429 return S_OK;
432 static HRESULT WINAPI HTMLRect_put_top(IHTMLRect *iface, LONG v)
434 HTMLRect *This = impl_from_IHTMLRect(iface);
435 FIXME("(%p)->(%d)\n", This, v);
436 return E_NOTIMPL;
439 static HRESULT WINAPI HTMLRect_get_top(IHTMLRect *iface, LONG *p)
441 HTMLRect *This = impl_from_IHTMLRect(iface);
442 float top;
443 nsresult nsres;
445 TRACE("(%p)->(%p)\n", This, p);
447 nsres = nsIDOMClientRect_GetTop(This->nsrect, &top);
448 if(NS_FAILED(nsres)) {
449 ERR("GetTop failed: %08x\n", nsres);
450 return E_FAIL;
453 *p = floor(top+0.5);
454 return S_OK;
457 static HRESULT WINAPI HTMLRect_put_right(IHTMLRect *iface, LONG v)
459 HTMLRect *This = impl_from_IHTMLRect(iface);
460 FIXME("(%p)->(%d)\n", This, v);
461 return E_NOTIMPL;
464 static HRESULT WINAPI HTMLRect_get_right(IHTMLRect *iface, LONG *p)
466 HTMLRect *This = impl_from_IHTMLRect(iface);
467 float right;
468 nsresult nsres;
470 TRACE("(%p)->(%p)\n", This, p);
472 nsres = nsIDOMClientRect_GetRight(This->nsrect, &right);
473 if(NS_FAILED(nsres)) {
474 ERR("GetRight failed: %08x\n", nsres);
475 return E_FAIL;
478 *p = floor(right+0.5);
479 return S_OK;
482 static HRESULT WINAPI HTMLRect_put_bottom(IHTMLRect *iface, LONG v)
484 HTMLRect *This = impl_from_IHTMLRect(iface);
485 FIXME("(%p)->(%d)\n", This, v);
486 return E_NOTIMPL;
489 static HRESULT WINAPI HTMLRect_get_bottom(IHTMLRect *iface, LONG *p)
491 HTMLRect *This = impl_from_IHTMLRect(iface);
492 float bottom;
493 nsresult nsres;
495 TRACE("(%p)->(%p)\n", This, p);
497 nsres = nsIDOMClientRect_GetBottom(This->nsrect, &bottom);
498 if(NS_FAILED(nsres)) {
499 ERR("GetBottom failed: %08x\n", nsres);
500 return E_FAIL;
503 *p = floor(bottom+0.5);
504 return S_OK;
507 static const IHTMLRectVtbl HTMLRectVtbl = {
508 HTMLRect_QueryInterface,
509 HTMLRect_AddRef,
510 HTMLRect_Release,
511 HTMLRect_GetTypeInfoCount,
512 HTMLRect_GetTypeInfo,
513 HTMLRect_GetIDsOfNames,
514 HTMLRect_Invoke,
515 HTMLRect_put_left,
516 HTMLRect_get_left,
517 HTMLRect_put_top,
518 HTMLRect_get_top,
519 HTMLRect_put_right,
520 HTMLRect_get_right,
521 HTMLRect_put_bottom,
522 HTMLRect_get_bottom
525 static const tid_t HTMLRect_iface_tids[] = {
526 IHTMLRect_tid,
529 static dispex_static_data_t HTMLRect_dispex = {
530 NULL,
531 IHTMLRect_tid,
532 NULL,
533 HTMLRect_iface_tids
536 static HRESULT create_html_rect(nsIDOMClientRect *nsrect, IHTMLRect **ret)
538 HTMLRect *rect;
540 rect = heap_alloc_zero(sizeof(HTMLRect));
541 if(!rect)
542 return E_OUTOFMEMORY;
544 rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl;
545 rect->ref = 1;
547 init_dispex(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex);
549 nsIDOMClientRect_AddRef(nsrect);
550 rect->nsrect = nsrect;
552 *ret = &rect->IHTMLRect_iface;
553 return S_OK;
556 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
557 REFIID riid, void **ppv)
559 HTMLElement *This = impl_from_IHTMLElement(iface);
561 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
564 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
566 HTMLElement *This = impl_from_IHTMLElement(iface);
568 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
571 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
573 HTMLElement *This = impl_from_IHTMLElement(iface);
575 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
578 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
580 HTMLElement *This = impl_from_IHTMLElement(iface);
581 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
584 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
585 LCID lcid, ITypeInfo **ppTInfo)
587 HTMLElement *This = impl_from_IHTMLElement(iface);
588 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
591 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
592 LPOLESTR *rgszNames, UINT cNames,
593 LCID lcid, DISPID *rgDispId)
595 HTMLElement *This = impl_from_IHTMLElement(iface);
596 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
597 lcid, rgDispId);
600 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
601 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
602 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
604 HTMLElement *This = impl_from_IHTMLElement(iface);
605 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
606 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
609 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
610 VARIANT AttributeValue, LONG lFlags)
612 HTMLElement *This = impl_from_IHTMLElement(iface);
613 HRESULT hres;
614 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
615 DISPPARAMS dispParams;
616 EXCEPINFO excep;
618 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
620 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
621 (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
622 if(FAILED(hres))
623 return hres;
625 if(dispid == DISPID_IHTMLELEMENT_STYLE) {
626 TRACE("Ignoring call on style attribute\n");
627 return S_OK;
630 dispParams.cArgs = 1;
631 dispParams.cNamedArgs = 1;
632 dispParams.rgdispidNamedArgs = &dispidNamed;
633 dispParams.rgvarg = &AttributeValue;
635 return IDispatchEx_InvokeEx(&This->node.event_target.dispex.IDispatchEx_iface, dispid,
636 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
639 HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, DWORD flags, VARIANT *ret)
641 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
642 EXCEPINFO excep;
643 HRESULT hres;
645 hres = IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
646 DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
647 if(FAILED(hres))
648 return hres;
650 if(flags & ATTRFLAG_ASSTRING) {
651 switch(V_VT(ret)) {
652 case VT_BSTR:
653 break;
654 case VT_DISPATCH:
655 IDispatch_Release(V_DISPATCH(ret));
656 V_VT(ret) = VT_BSTR;
657 V_BSTR(ret) = SysAllocString(NULL);
658 break;
659 default:
660 hres = VariantChangeType(ret, ret, 0, VT_BSTR);
661 if(FAILED(hres))
662 return hres;
666 return S_OK;
669 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
670 LONG lFlags, VARIANT *AttributeValue)
672 HTMLElement *This = impl_from_IHTMLElement(iface);
673 DISPID dispid;
674 HRESULT hres;
676 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
678 if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
679 FIXME("Unsupported flags %x\n", lFlags);
681 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
682 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
683 if(hres == DISP_E_UNKNOWNNAME) {
684 V_VT(AttributeValue) = VT_NULL;
685 return S_OK;
688 if(FAILED(hres)) {
689 V_VT(AttributeValue) = VT_NULL;
690 return hres;
693 return get_elem_attr_value_by_dispid(This, dispid, lFlags, AttributeValue);
696 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
697 LONG lFlags, VARIANT_BOOL *pfSuccess)
699 HTMLElement *This = impl_from_IHTMLElement(iface);
700 DISPID id;
701 HRESULT hres;
703 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
705 hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
706 lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
707 if(hres == DISP_E_UNKNOWNNAME) {
708 *pfSuccess = VARIANT_FALSE;
709 return S_OK;
711 if(FAILED(hres))
712 return hres;
714 if(id == DISPID_IHTMLELEMENT_STYLE) {
715 IHTMLStyle *style;
717 TRACE("Special case: style\n");
719 hres = IHTMLElement_get_style(&This->IHTMLElement_iface, &style);
720 if(FAILED(hres))
721 return hres;
723 hres = IHTMLStyle_put_cssText(style, NULL);
724 IHTMLStyle_Release(style);
725 if(FAILED(hres))
726 return hres;
728 *pfSuccess = VARIANT_TRUE;
729 return S_OK;
732 return remove_attribute(&This->node.event_target.dispex, id, pfSuccess);
735 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
737 HTMLElement *This = impl_from_IHTMLElement(iface);
738 nsAString classname_str;
739 nsresult nsres;
741 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
743 if(!This->nselem) {
744 FIXME("NULL nselem\n");
745 return E_NOTIMPL;
748 nsAString_InitDepend(&classname_str, v);
749 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
750 nsAString_Finish(&classname_str);
751 if(NS_FAILED(nsres))
752 ERR("SetClassName failed: %08x\n", nsres);
754 return S_OK;
757 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
759 HTMLElement *This = impl_from_IHTMLElement(iface);
760 nsAString class_str;
761 nsresult nsres;
763 TRACE("(%p)->(%p)\n", This, p);
765 if(!This->nselem) {
766 FIXME("NULL nselem\n");
767 return E_NOTIMPL;
770 nsAString_Init(&class_str, NULL);
771 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
772 return return_nsstr(nsres, &class_str, p);
775 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
777 HTMLElement *This = impl_from_IHTMLElement(iface);
778 nsAString id_str;
779 nsresult nsres;
781 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
783 if(!This->nselem) {
784 FIXME("nselem == NULL\n");
785 return S_OK;
788 nsAString_InitDepend(&id_str, v);
789 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
790 nsAString_Finish(&id_str);
791 if(NS_FAILED(nsres))
792 ERR("SetId failed: %08x\n", nsres);
794 return S_OK;
797 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
799 HTMLElement *This = impl_from_IHTMLElement(iface);
800 nsAString id_str;
801 nsresult nsres;
803 TRACE("(%p)->(%p)\n", This, p);
805 if(!This->nselem) {
806 *p = NULL;
807 return S_OK;
810 nsAString_Init(&id_str, NULL);
811 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
812 return return_nsstr(nsres, &id_str, p);
815 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
817 HTMLElement *This = impl_from_IHTMLElement(iface);
818 nsAString tag_str;
819 nsresult nsres;
821 TRACE("(%p)->(%p)\n", This, p);
823 if(!This->nselem) {
824 static const WCHAR comment_tagW[] = {'!',0};
826 WARN("NULL nselem, assuming comment\n");
828 *p = SysAllocString(comment_tagW);
829 return *p ? S_OK : E_OUTOFMEMORY;
832 nsAString_Init(&tag_str, NULL);
833 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
834 return return_nsstr(nsres, &tag_str, p);
837 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
839 HTMLElement *This = impl_from_IHTMLElement(iface);
840 IHTMLDOMNode *node;
841 HRESULT hres;
843 TRACE("(%p)->(%p)\n", This, p);
845 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
846 if(FAILED(hres))
847 return hres;
849 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
850 IHTMLDOMNode_Release(node);
851 if(FAILED(hres))
852 *p = NULL;
854 return S_OK;
857 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
859 HTMLElement *This = impl_from_IHTMLElement(iface);
861 TRACE("(%p)->(%p)\n", This, p);
863 if(!This->style) {
864 HRESULT hres;
866 hres = HTMLStyle_Create(This, &This->style);
867 if(FAILED(hres))
868 return hres;
871 *p = &This->style->IHTMLStyle_iface;
872 IHTMLStyle_AddRef(*p);
873 return S_OK;
876 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
878 HTMLElement *This = impl_from_IHTMLElement(iface);
879 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
880 return E_NOTIMPL;
883 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
885 HTMLElement *This = impl_from_IHTMLElement(iface);
886 FIXME("(%p)->(%p)\n", This, p);
887 return E_NOTIMPL;
890 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
892 HTMLElement *This = impl_from_IHTMLElement(iface);
894 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
896 return set_node_event(&This->node, EVENTID_CLICK, &v);
899 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
901 HTMLElement *This = impl_from_IHTMLElement(iface);
903 TRACE("(%p)->(%p)\n", This, p);
905 return get_node_event(&This->node, EVENTID_CLICK, p);
908 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
910 HTMLElement *This = impl_from_IHTMLElement(iface);
912 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
914 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
917 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
919 HTMLElement *This = impl_from_IHTMLElement(iface);
921 TRACE("(%p)->(%p)\n", This, p);
923 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
926 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
928 HTMLElement *This = impl_from_IHTMLElement(iface);
930 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
932 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
935 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
937 HTMLElement *This = impl_from_IHTMLElement(iface);
939 TRACE("(%p)->(%p)\n", This, p);
941 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
944 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
946 HTMLElement *This = impl_from_IHTMLElement(iface);
948 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
950 return set_node_event(&This->node, EVENTID_KEYUP, &v);
953 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
955 HTMLElement *This = impl_from_IHTMLElement(iface);
956 FIXME("(%p)->(%p)\n", This, p);
957 return E_NOTIMPL;
960 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
962 HTMLElement *This = impl_from_IHTMLElement(iface);
964 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
966 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
969 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
971 HTMLElement *This = impl_from_IHTMLElement(iface);
973 TRACE("(%p)->(%p)\n", This, p);
975 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
978 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
980 HTMLElement *This = impl_from_IHTMLElement(iface);
982 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
984 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
987 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
989 HTMLElement *This = impl_from_IHTMLElement(iface);
991 TRACE("(%p)->(%p)\n", This, p);
993 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
996 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
998 HTMLElement *This = impl_from_IHTMLElement(iface);
1000 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1002 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
1005 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
1007 HTMLElement *This = impl_from_IHTMLElement(iface);
1009 TRACE("(%p)->(%p)\n", This, p);
1011 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
1014 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
1016 HTMLElement *This = impl_from_IHTMLElement(iface);
1018 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1020 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
1023 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
1025 HTMLElement *This = impl_from_IHTMLElement(iface);
1027 TRACE("(%p)->(%p)\n", This, p);
1029 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
1032 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
1034 HTMLElement *This = impl_from_IHTMLElement(iface);
1036 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1038 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
1041 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
1043 HTMLElement *This = impl_from_IHTMLElement(iface);
1045 TRACE("(%p)->(%p)\n", This, p);
1047 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
1050 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
1052 HTMLElement *This = impl_from_IHTMLElement(iface);
1054 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1056 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
1059 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
1061 HTMLElement *This = impl_from_IHTMLElement(iface);
1063 TRACE("(%p)->(%p)\n", This, p);
1065 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
1068 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
1070 HTMLElement *This = impl_from_IHTMLElement(iface);
1072 TRACE("(%p)->(%p)\n", This, p);
1074 if(!p)
1075 return E_POINTER;
1077 if(This->node.vtbl->get_document)
1078 return This->node.vtbl->get_document(&This->node, p);
1080 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
1081 IDispatch_AddRef(*p);
1082 return S_OK;
1085 static const WCHAR titleW[] = {'t','i','t','l','e',0};
1087 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
1089 HTMLElement *This = impl_from_IHTMLElement(iface);
1090 nsAString title_str;
1091 nsresult nsres;
1093 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1095 if(!This->nselem) {
1096 VARIANT *var;
1097 HRESULT hres;
1099 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, TRUE, &var);
1100 if(FAILED(hres))
1101 return hres;
1103 VariantClear(var);
1104 V_VT(var) = VT_BSTR;
1105 V_BSTR(var) = v ? SysAllocString(v) : NULL;
1106 return S_OK;
1109 nsAString_InitDepend(&title_str, v);
1110 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
1111 nsAString_Finish(&title_str);
1112 if(NS_FAILED(nsres))
1113 ERR("SetTitle failed: %08x\n", nsres);
1115 return S_OK;
1118 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
1120 HTMLElement *This = impl_from_IHTMLElement(iface);
1121 nsAString title_str;
1122 nsresult nsres;
1124 TRACE("(%p)->(%p)\n", This, p);
1126 if(!This->nselem) {
1127 VARIANT *var;
1128 HRESULT hres;
1130 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, titleW, FALSE, &var);
1131 if(hres == DISP_E_UNKNOWNNAME) {
1132 *p = NULL;
1133 }else if(V_VT(var) != VT_BSTR) {
1134 FIXME("title = %s\n", debugstr_variant(var));
1135 return E_FAIL;
1136 }else {
1137 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
1140 return S_OK;
1143 nsAString_Init(&title_str, NULL);
1144 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
1145 return return_nsstr(nsres, &title_str, p);
1148 static const WCHAR languageW[] = {'l','a','n','g','u','a','g','e',0};
1150 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
1152 HTMLElement *This = impl_from_IHTMLElement(iface);
1154 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1156 return elem_string_attr_setter(This, languageW, v);
1159 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
1161 HTMLElement *This = impl_from_IHTMLElement(iface);
1163 TRACE("(%p)->(%p)\n", This, p);
1165 return elem_string_attr_getter(This, languageW, TRUE, p);
1168 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
1170 HTMLElement *This = impl_from_IHTMLElement(iface);
1172 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1174 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
1177 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
1179 HTMLElement *This = impl_from_IHTMLElement(iface);
1181 TRACE("(%p)->(%p)\n", This, p);
1183 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
1186 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
1188 HTMLElement *This = impl_from_IHTMLElement(iface);
1189 cpp_bool start = TRUE;
1190 nsresult nsres;
1192 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
1194 switch(V_VT(&varargStart)) {
1195 case VT_EMPTY:
1196 case VT_ERROR:
1197 break;
1198 case VT_BOOL:
1199 start = V_BOOL(&varargStart) != VARIANT_FALSE;
1200 break;
1201 default:
1202 FIXME("Unsupported argument %s\n", debugstr_variant(&varargStart));
1205 if(!This->nselem) {
1206 FIXME("Unsupported for comments\n");
1207 return E_NOTIMPL;
1210 nsres = nsIDOMHTMLElement_ScrollIntoView(This->nselem, start, 1);
1211 assert(nsres == NS_OK);
1213 return S_OK;
1216 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
1217 VARIANT_BOOL *pfResult)
1219 HTMLElement *This = impl_from_IHTMLElement(iface);
1220 cpp_bool result = FALSE;
1222 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
1224 if(pChild) {
1225 HTMLElement *child;
1226 nsresult nsres;
1228 child = unsafe_impl_from_IHTMLElement(pChild);
1229 if(!child) {
1230 ERR("not our element\n");
1231 return E_FAIL;
1234 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
1235 assert(nsres == NS_OK);
1238 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
1239 return S_OK;
1242 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
1244 HTMLElement *This = impl_from_IHTMLElement(iface);
1246 TRACE("(%p)->(%p)\n", This, p);
1248 return get_elem_source_index(This, p);
1251 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
1253 HTMLElement *This = impl_from_IHTMLElement(iface);
1254 FIXME("(%p)->(%p)\n", This, p);
1255 return E_NOTIMPL;
1258 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
1260 HTMLElement *This = impl_from_IHTMLElement(iface);
1261 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1262 return E_NOTIMPL;
1265 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
1267 HTMLElement *This = impl_from_IHTMLElement(iface);
1268 FIXME("(%p)->(%p)\n", This, p);
1269 return E_NOTIMPL;
1272 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
1274 HTMLElement *This = impl_from_IHTMLElement(iface);
1275 nsresult nsres;
1277 TRACE("(%p)->(%p)\n", This, p);
1279 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, p);
1280 if(NS_FAILED(nsres)) {
1281 ERR("GetOffsetLeft failed: %08x\n", nsres);
1282 return E_FAIL;
1285 return S_OK;
1288 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
1290 HTMLElement *This = impl_from_IHTMLElement(iface);
1291 nsresult nsres;
1293 TRACE("(%p)->(%p)\n", This, p);
1295 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, p);
1296 if(NS_FAILED(nsres)) {
1297 ERR("GetOffsetTop failed: %08x\n", nsres);
1298 return E_FAIL;
1301 return S_OK;
1304 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
1306 HTMLElement *This = impl_from_IHTMLElement(iface);
1307 nsresult nsres;
1309 TRACE("(%p)->(%p)\n", This, p);
1311 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, p);
1312 if(NS_FAILED(nsres)) {
1313 ERR("GetOffsetWidth failed: %08x\n", nsres);
1314 return E_FAIL;
1317 return S_OK;
1320 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
1322 HTMLElement *This = impl_from_IHTMLElement(iface);
1323 nsresult nsres;
1325 TRACE("(%p)->(%p)\n", This, p);
1327 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, p);
1328 if(NS_FAILED(nsres)) {
1329 ERR("GetOffsetHeight failed: %08x\n", nsres);
1330 return E_FAIL;
1333 return S_OK;
1336 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
1338 HTMLElement *This = impl_from_IHTMLElement(iface);
1339 nsIDOMElement *nsparent;
1340 nsresult nsres;
1341 HRESULT hres;
1343 TRACE("(%p)->(%p)\n", This, p);
1345 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
1346 if(NS_FAILED(nsres)) {
1347 ERR("GetOffsetParent failed: %08x\n", nsres);
1348 return E_FAIL;
1351 if(nsparent) {
1352 HTMLDOMNode *node;
1354 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1355 nsIDOMElement_Release(nsparent);
1356 if(FAILED(hres))
1357 return hres;
1359 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1360 node_release(node);
1361 }else {
1362 *p = NULL;
1363 hres = S_OK;
1366 return hres;
1369 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1371 HTMLElement *This = impl_from_IHTMLElement(iface);
1372 nsAString html_str;
1373 nsresult nsres;
1375 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1377 if(!This->nselem) {
1378 FIXME("NULL nselem\n");
1379 return E_NOTIMPL;
1382 nsAString_InitDepend(&html_str, v);
1383 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
1384 nsAString_Finish(&html_str);
1385 if(NS_FAILED(nsres)) {
1386 FIXME("SetInnerHtml failed %08x\n", nsres);
1387 return E_FAIL;
1390 return S_OK;
1393 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1395 HTMLElement *This = impl_from_IHTMLElement(iface);
1396 nsAString html_str;
1397 nsresult nsres;
1399 TRACE("(%p)->(%p)\n", This, p);
1401 if(!This->nselem) {
1402 FIXME("NULL nselem\n");
1403 return E_NOTIMPL;
1406 nsAString_Init(&html_str, NULL);
1407 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
1408 return return_nsstr(nsres, &html_str, p);
1411 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1413 HTMLElement *This = impl_from_IHTMLElement(iface);
1414 nsIDOMNode *nschild, *tmp;
1415 nsIDOMText *text_node;
1416 nsAString text_str;
1417 nsresult nsres;
1419 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1421 while(1) {
1422 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1423 if(NS_FAILED(nsres)) {
1424 ERR("GetLastChild failed: %08x\n", nsres);
1425 return E_FAIL;
1427 if(!nschild)
1428 break;
1430 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1431 nsIDOMNode_Release(nschild);
1432 if(NS_FAILED(nsres)) {
1433 ERR("RemoveChild failed: %08x\n", nsres);
1434 return E_FAIL;
1436 nsIDOMNode_Release(tmp);
1439 nsAString_InitDepend(&text_str, v);
1440 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1441 nsAString_Finish(&text_str);
1442 if(NS_FAILED(nsres)) {
1443 ERR("CreateTextNode failed: %08x\n", nsres);
1444 return E_FAIL;
1447 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1448 if(NS_FAILED(nsres)) {
1449 ERR("AppendChild failed: %08x\n", nsres);
1450 return E_FAIL;
1453 nsIDOMNode_Release(tmp);
1454 return S_OK;
1457 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1459 HTMLElement *This = impl_from_IHTMLElement(iface);
1461 TRACE("(%p)->(%p)\n", This, p);
1463 return get_node_text(&This->node, p);
1466 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1468 HTMLElement *This = impl_from_IHTMLElement(iface);
1470 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1472 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1475 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1477 HTMLElement *This = impl_from_IHTMLElement(iface);
1478 nsAString html_str;
1479 HRESULT hres;
1481 WARN("(%p)->(%p) semi-stub\n", This, p);
1483 nsAString_Init(&html_str, NULL);
1484 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1485 if(SUCCEEDED(hres)) {
1486 const PRUnichar *html;
1488 nsAString_GetData(&html_str, &html);
1489 *p = SysAllocString(html);
1490 if(!*p)
1491 hres = E_OUTOFMEMORY;
1494 nsAString_Finish(&html_str);
1496 TRACE("ret %s\n", debugstr_w(*p));
1497 return hres;
1500 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1502 HTMLElement *This = impl_from_IHTMLElement(iface);
1503 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1504 return E_NOTIMPL;
1507 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1509 HTMLElement *This = impl_from_IHTMLElement(iface);
1510 FIXME("(%p)->(%p)\n", This, p);
1511 return E_NOTIMPL;
1514 static HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1516 nsIDOMNode *ret_nsnode;
1517 nsresult nsres;
1518 HRESULT hres = S_OK;
1520 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1521 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1522 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1523 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1525 if (!strcmpiW(where, beforebeginW)) {
1526 nsIDOMNode *parent;
1528 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1529 if(NS_FAILED(nsres))
1530 return E_FAIL;
1532 if(!parent)
1533 return E_INVALIDARG;
1535 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1536 nsIDOMNode_Release(parent);
1537 }else if(!strcmpiW(where, afterbeginW)) {
1538 nsIDOMNode *first_child;
1540 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1541 if(NS_FAILED(nsres))
1542 return E_FAIL;
1544 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1545 if(NS_FAILED(nsres))
1546 return E_FAIL;
1548 if (first_child)
1549 nsIDOMNode_Release(first_child);
1550 }else if (!strcmpiW(where, beforeendW)) {
1551 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1552 }else if (!strcmpiW(where, afterendW)) {
1553 nsIDOMNode *next_sibling, *parent;
1555 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1556 if(NS_FAILED(nsres))
1557 return E_FAIL;
1558 if(!parent)
1559 return E_INVALIDARG;
1561 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1562 if(NS_SUCCEEDED(nsres)) {
1563 if(next_sibling) {
1564 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1565 nsIDOMNode_Release(next_sibling);
1566 }else {
1567 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1571 nsIDOMNode_Release(parent);
1572 }else {
1573 ERR("invalid where: %s\n", debugstr_w(where));
1574 return E_INVALIDARG;
1577 if (NS_FAILED(nsres))
1578 return E_FAIL;
1580 if(ret_node)
1581 hres = get_node(This->node.doc, ret_nsnode, TRUE, ret_node);
1582 nsIDOMNode_Release(ret_nsnode);
1583 return hres;
1586 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1587 BSTR html)
1589 HTMLElement *This = impl_from_IHTMLElement(iface);
1590 nsIDOMRange *range;
1591 nsIDOMNode *nsnode;
1592 nsAString ns_html;
1593 nsresult nsres;
1594 HRESULT hr;
1596 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1598 if(!This->node.doc->nsdoc) {
1599 WARN("NULL nsdoc\n");
1600 return E_UNEXPECTED;
1603 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1604 if(NS_FAILED(nsres))
1606 ERR("CreateRange failed: %08x\n", nsres);
1607 return E_FAIL;
1610 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1612 nsAString_InitDepend(&ns_html, html);
1613 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1614 nsAString_Finish(&ns_html);
1615 nsIDOMRange_Release(range);
1617 if(NS_FAILED(nsres) || !nsnode)
1619 ERR("CreateTextNode failed: %08x\n", nsres);
1620 return E_FAIL;
1623 hr = insert_adjacent_node(This, where, nsnode, NULL);
1624 nsIDOMNode_Release(nsnode);
1625 return hr;
1628 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1629 BSTR text)
1631 HTMLElement *This = impl_from_IHTMLElement(iface);
1632 nsIDOMNode *nsnode;
1633 nsAString ns_text;
1634 nsresult nsres;
1635 HRESULT hr;
1637 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1639 if(!This->node.doc->nsdoc) {
1640 WARN("NULL nsdoc\n");
1641 return E_UNEXPECTED;
1645 nsAString_InitDepend(&ns_text, text);
1646 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1647 nsAString_Finish(&ns_text);
1649 if(NS_FAILED(nsres) || !nsnode)
1651 ERR("CreateTextNode failed: %08x\n", nsres);
1652 return E_FAIL;
1655 hr = insert_adjacent_node(This, where, nsnode, NULL);
1656 nsIDOMNode_Release(nsnode);
1658 return hr;
1661 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1663 HTMLElement *This = impl_from_IHTMLElement(iface);
1664 FIXME("(%p)->(%p)\n", This, p);
1665 return E_NOTIMPL;
1668 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1670 HTMLElement *This = impl_from_IHTMLElement(iface);
1672 TRACE("(%p)->(%p)\n", This, p);
1674 *p = This->node.vtbl->is_text_edit && This->node.vtbl->is_text_edit(&This->node)
1675 ? VARIANT_TRUE : VARIANT_FALSE;
1676 return S_OK;
1679 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1681 HTMLElement *This = impl_from_IHTMLElement(iface);
1683 TRACE("(%p)\n", This);
1685 return call_fire_event(&This->node, EVENTID_CLICK);
1688 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1689 IHTMLFiltersCollection **p)
1691 HTMLElement *This = impl_from_IHTMLElement(iface);
1692 TRACE("(%p)->(%p)\n", This, p);
1694 if(!p)
1695 return E_POINTER;
1697 *p = HTMLFiltersCollection_Create();
1699 return S_OK;
1702 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1704 HTMLElement *This = impl_from_IHTMLElement(iface);
1705 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1706 return E_NOTIMPL;
1709 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1711 HTMLElement *This = impl_from_IHTMLElement(iface);
1712 FIXME("(%p)->(%p)\n", This, p);
1713 return E_NOTIMPL;
1716 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1718 HTMLElement *This = impl_from_IHTMLElement(iface);
1719 FIXME("(%p)->(%p)\n", This, String);
1720 return E_NOTIMPL;
1723 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1725 HTMLElement *This = impl_from_IHTMLElement(iface);
1726 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1727 return E_NOTIMPL;
1730 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1732 HTMLElement *This = impl_from_IHTMLElement(iface);
1733 FIXME("(%p)->(%p)\n", This, p);
1734 return E_NOTIMPL;
1737 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1739 HTMLElement *This = impl_from_IHTMLElement(iface);
1740 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1741 return E_NOTIMPL;
1744 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1746 HTMLElement *This = impl_from_IHTMLElement(iface);
1747 FIXME("(%p)->(%p)\n", This, p);
1748 return E_NOTIMPL;
1751 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1753 HTMLElement *This = impl_from_IHTMLElement(iface);
1754 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1755 return E_NOTIMPL;
1758 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1760 HTMLElement *This = impl_from_IHTMLElement(iface);
1761 FIXME("(%p)->(%p)\n", This, p);
1762 return E_NOTIMPL;
1765 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1767 HTMLElement *This = impl_from_IHTMLElement(iface);
1768 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1769 return E_NOTIMPL;
1772 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1774 HTMLElement *This = impl_from_IHTMLElement(iface);
1775 FIXME("(%p)->(%p)\n", This, p);
1776 return E_NOTIMPL;
1779 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1781 HTMLElement *This = impl_from_IHTMLElement(iface);
1782 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1783 return E_NOTIMPL;
1786 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1788 HTMLElement *This = impl_from_IHTMLElement(iface);
1789 FIXME("(%p)->(%p)\n", This, p);
1790 return E_NOTIMPL;
1793 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1795 HTMLElement *This = impl_from_IHTMLElement(iface);
1796 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1797 return E_NOTIMPL;
1800 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1802 HTMLElement *This = impl_from_IHTMLElement(iface);
1803 FIXME("(%p)->(%p)\n", This, p);
1804 return E_NOTIMPL;
1807 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1809 HTMLElement *This = impl_from_IHTMLElement(iface);
1811 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1813 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1816 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1818 HTMLElement *This = impl_from_IHTMLElement(iface);
1820 TRACE("(%p)->(%p)\n", This, p);
1822 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1825 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1827 HTMLElement *This = impl_from_IHTMLElement(iface);
1828 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1829 return E_NOTIMPL;
1832 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1834 HTMLElement *This = impl_from_IHTMLElement(iface);
1835 FIXME("(%p)->(%p)\n", This, p);
1836 return E_NOTIMPL;
1839 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1841 HTMLElement *This = impl_from_IHTMLElement(iface);
1842 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1843 return E_NOTIMPL;
1846 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1848 HTMLElement *This = impl_from_IHTMLElement(iface);
1849 FIXME("(%p)->(%p)\n", This, p);
1850 return E_NOTIMPL;
1853 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1855 HTMLElement *This = impl_from_IHTMLElement(iface);
1856 nsIDOMNodeList *nsnode_list;
1857 nsresult nsres;
1859 TRACE("(%p)->(%p)\n", This, p);
1861 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1862 if(NS_FAILED(nsres)) {
1863 ERR("GetChildNodes failed: %08x\n", nsres);
1864 return E_FAIL;
1867 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1869 nsIDOMNodeList_Release(nsnode_list);
1870 return S_OK;
1873 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1875 HTMLElement *This = impl_from_IHTMLElement(iface);
1877 TRACE("(%p)->(%p)\n", This, p);
1879 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1880 return S_OK;
1883 static const IHTMLElementVtbl HTMLElementVtbl = {
1884 HTMLElement_QueryInterface,
1885 HTMLElement_AddRef,
1886 HTMLElement_Release,
1887 HTMLElement_GetTypeInfoCount,
1888 HTMLElement_GetTypeInfo,
1889 HTMLElement_GetIDsOfNames,
1890 HTMLElement_Invoke,
1891 HTMLElement_setAttribute,
1892 HTMLElement_getAttribute,
1893 HTMLElement_removeAttribute,
1894 HTMLElement_put_className,
1895 HTMLElement_get_className,
1896 HTMLElement_put_id,
1897 HTMLElement_get_id,
1898 HTMLElement_get_tagName,
1899 HTMLElement_get_parentElement,
1900 HTMLElement_get_style,
1901 HTMLElement_put_onhelp,
1902 HTMLElement_get_onhelp,
1903 HTMLElement_put_onclick,
1904 HTMLElement_get_onclick,
1905 HTMLElement_put_ondblclick,
1906 HTMLElement_get_ondblclick,
1907 HTMLElement_put_onkeydown,
1908 HTMLElement_get_onkeydown,
1909 HTMLElement_put_onkeyup,
1910 HTMLElement_get_onkeyup,
1911 HTMLElement_put_onkeypress,
1912 HTMLElement_get_onkeypress,
1913 HTMLElement_put_onmouseout,
1914 HTMLElement_get_onmouseout,
1915 HTMLElement_put_onmouseover,
1916 HTMLElement_get_onmouseover,
1917 HTMLElement_put_onmousemove,
1918 HTMLElement_get_onmousemove,
1919 HTMLElement_put_onmousedown,
1920 HTMLElement_get_onmousedown,
1921 HTMLElement_put_onmouseup,
1922 HTMLElement_get_onmouseup,
1923 HTMLElement_get_document,
1924 HTMLElement_put_title,
1925 HTMLElement_get_title,
1926 HTMLElement_put_language,
1927 HTMLElement_get_language,
1928 HTMLElement_put_onselectstart,
1929 HTMLElement_get_onselectstart,
1930 HTMLElement_scrollIntoView,
1931 HTMLElement_contains,
1932 HTMLElement_get_sourceIndex,
1933 HTMLElement_get_recordNumber,
1934 HTMLElement_put_lang,
1935 HTMLElement_get_lang,
1936 HTMLElement_get_offsetLeft,
1937 HTMLElement_get_offsetTop,
1938 HTMLElement_get_offsetWidth,
1939 HTMLElement_get_offsetHeight,
1940 HTMLElement_get_offsetParent,
1941 HTMLElement_put_innerHTML,
1942 HTMLElement_get_innerHTML,
1943 HTMLElement_put_innerText,
1944 HTMLElement_get_innerText,
1945 HTMLElement_put_outerHTML,
1946 HTMLElement_get_outerHTML,
1947 HTMLElement_put_outerText,
1948 HTMLElement_get_outerText,
1949 HTMLElement_insertAdjacentHTML,
1950 HTMLElement_insertAdjacentText,
1951 HTMLElement_get_parentTextEdit,
1952 HTMLElement_get_isTextEdit,
1953 HTMLElement_click,
1954 HTMLElement_get_filters,
1955 HTMLElement_put_ondragstart,
1956 HTMLElement_get_ondragstart,
1957 HTMLElement_toString,
1958 HTMLElement_put_onbeforeupdate,
1959 HTMLElement_get_onbeforeupdate,
1960 HTMLElement_put_onafterupdate,
1961 HTMLElement_get_onafterupdate,
1962 HTMLElement_put_onerrorupdate,
1963 HTMLElement_get_onerrorupdate,
1964 HTMLElement_put_onrowexit,
1965 HTMLElement_get_onrowexit,
1966 HTMLElement_put_onrowenter,
1967 HTMLElement_get_onrowenter,
1968 HTMLElement_put_ondatasetchanged,
1969 HTMLElement_get_ondatasetchanged,
1970 HTMLElement_put_ondataavailable,
1971 HTMLElement_get_ondataavailable,
1972 HTMLElement_put_ondatasetcomplete,
1973 HTMLElement_get_ondatasetcomplete,
1974 HTMLElement_put_onfilterchange,
1975 HTMLElement_get_onfilterchange,
1976 HTMLElement_get_children,
1977 HTMLElement_get_all
1980 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1982 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1985 static inline HTMLElement *impl_from_IHTMLElement2(IHTMLElement2 *iface)
1987 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement2_iface);
1990 static HRESULT WINAPI HTMLElement2_QueryInterface(IHTMLElement2 *iface,
1991 REFIID riid, void **ppv)
1993 HTMLElement *This = impl_from_IHTMLElement2(iface);
1994 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
1997 static ULONG WINAPI HTMLElement2_AddRef(IHTMLElement2 *iface)
1999 HTMLElement *This = impl_from_IHTMLElement2(iface);
2000 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
2003 static ULONG WINAPI HTMLElement2_Release(IHTMLElement2 *iface)
2005 HTMLElement *This = impl_from_IHTMLElement2(iface);
2006 return IHTMLElement_Release(&This->IHTMLElement_iface);
2009 static HRESULT WINAPI HTMLElement2_GetTypeInfoCount(IHTMLElement2 *iface, UINT *pctinfo)
2011 HTMLElement *This = impl_from_IHTMLElement2(iface);
2012 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
2015 static HRESULT WINAPI HTMLElement2_GetTypeInfo(IHTMLElement2 *iface, UINT iTInfo,
2016 LCID lcid, ITypeInfo **ppTInfo)
2018 HTMLElement *This = impl_from_IHTMLElement2(iface);
2019 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2022 static HRESULT WINAPI HTMLElement2_GetIDsOfNames(IHTMLElement2 *iface, REFIID riid,
2023 LPOLESTR *rgszNames, UINT cNames,
2024 LCID lcid, DISPID *rgDispId)
2026 HTMLElement *This = impl_from_IHTMLElement2(iface);
2027 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2028 lcid, rgDispId);
2031 static HRESULT WINAPI HTMLElement2_Invoke(IHTMLElement2 *iface, DISPID dispIdMember,
2032 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2033 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2035 HTMLElement *This = impl_from_IHTMLElement2(iface);
2036 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2037 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2040 static HRESULT WINAPI HTMLElement2_get_scopeName(IHTMLElement2 *iface, BSTR *p)
2042 HTMLElement *This = impl_from_IHTMLElement2(iface);
2043 FIXME("(%p)->(%p)\n", This, p);
2044 return E_NOTIMPL;
2047 static HRESULT WINAPI HTMLElement2_setCapture(IHTMLElement2 *iface, VARIANT_BOOL containerCapture)
2049 HTMLElement *This = impl_from_IHTMLElement2(iface);
2050 FIXME("(%p)->(%x)\n", This, containerCapture);
2051 return E_NOTIMPL;
2054 static HRESULT WINAPI HTMLElement2_releaseCapture(IHTMLElement2 *iface)
2056 HTMLElement *This = impl_from_IHTMLElement2(iface);
2057 FIXME("(%p)\n", This);
2058 return E_NOTIMPL;
2061 static HRESULT WINAPI HTMLElement2_put_onlosecapture(IHTMLElement2 *iface, VARIANT v)
2063 HTMLElement *This = impl_from_IHTMLElement2(iface);
2064 FIXME("(%p)->()\n", This);
2065 return E_NOTIMPL;
2068 static HRESULT WINAPI HTMLElement2_get_onlosecapture(IHTMLElement2 *iface, VARIANT *p)
2070 HTMLElement *This = impl_from_IHTMLElement2(iface);
2071 FIXME("(%p)->(%p)\n", This, p);
2072 return E_NOTIMPL;
2075 static HRESULT WINAPI HTMLElement2_componentFromPoint(IHTMLElement2 *iface,
2076 LONG x, LONG y, BSTR *component)
2078 HTMLElement *This = impl_from_IHTMLElement2(iface);
2079 FIXME("(%p)->(%d %d %p)\n", This, x, y, component);
2080 return E_NOTIMPL;
2083 static HRESULT WINAPI HTMLElement2_doScroll(IHTMLElement2 *iface, VARIANT component)
2085 HTMLElement *This = impl_from_IHTMLElement2(iface);
2087 TRACE("(%p)->(%s)\n", This, debugstr_variant(&component));
2089 if(!This->node.doc->content_ready
2090 || !This->node.doc->basedoc.doc_obj->in_place_active)
2091 return E_PENDING;
2093 WARN("stub\n");
2094 return S_OK;
2097 static HRESULT WINAPI HTMLElement2_put_onscroll(IHTMLElement2 *iface, VARIANT v)
2099 HTMLElement *This = impl_from_IHTMLElement2(iface);
2100 FIXME("(%p)->()\n", This);
2101 return E_NOTIMPL;
2104 static HRESULT WINAPI HTMLElement2_get_onscroll(IHTMLElement2 *iface, VARIANT *p)
2106 HTMLElement *This = impl_from_IHTMLElement2(iface);
2107 FIXME("(%p)->(%p)\n", This, p);
2108 return E_NOTIMPL;
2111 static HRESULT WINAPI HTMLElement2_put_ondrag(IHTMLElement2 *iface, VARIANT v)
2113 HTMLElement *This = impl_from_IHTMLElement2(iface);
2115 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2117 return set_node_event(&This->node, EVENTID_DRAG, &v);
2120 static HRESULT WINAPI HTMLElement2_get_ondrag(IHTMLElement2 *iface, VARIANT *p)
2122 HTMLElement *This = impl_from_IHTMLElement2(iface);
2124 TRACE("(%p)->(%p)\n", This, p);
2126 return get_node_event(&This->node, EVENTID_DRAG, p);
2129 static HRESULT WINAPI HTMLElement2_put_ondragend(IHTMLElement2 *iface, VARIANT v)
2131 HTMLElement *This = impl_from_IHTMLElement2(iface);
2132 FIXME("(%p)->()\n", This);
2133 return E_NOTIMPL;
2136 static HRESULT WINAPI HTMLElement2_get_ondragend(IHTMLElement2 *iface, VARIANT *p)
2138 HTMLElement *This = impl_from_IHTMLElement2(iface);
2139 FIXME("(%p)->(%p)\n", This, p);
2140 return E_NOTIMPL;
2143 static HRESULT WINAPI HTMLElement2_put_ondragenter(IHTMLElement2 *iface, VARIANT v)
2145 HTMLElement *This = impl_from_IHTMLElement2(iface);
2146 FIXME("(%p)->()\n", This);
2147 return E_NOTIMPL;
2150 static HRESULT WINAPI HTMLElement2_get_ondragenter(IHTMLElement2 *iface, VARIANT *p)
2152 HTMLElement *This = impl_from_IHTMLElement2(iface);
2153 FIXME("(%p)->(%p)\n", This, p);
2154 return E_NOTIMPL;
2157 static HRESULT WINAPI HTMLElement2_put_ondragover(IHTMLElement2 *iface, VARIANT v)
2159 HTMLElement *This = impl_from_IHTMLElement2(iface);
2160 FIXME("(%p)->()\n", This);
2161 return E_NOTIMPL;
2164 static HRESULT WINAPI HTMLElement2_get_ondragover(IHTMLElement2 *iface, VARIANT *p)
2166 HTMLElement *This = impl_from_IHTMLElement2(iface);
2167 FIXME("(%p)->(%p)\n", This, p);
2168 return E_NOTIMPL;
2171 static HRESULT WINAPI HTMLElement2_put_ondragleave(IHTMLElement2 *iface, VARIANT v)
2173 HTMLElement *This = impl_from_IHTMLElement2(iface);
2174 FIXME("(%p)->()\n", This);
2175 return E_NOTIMPL;
2178 static HRESULT WINAPI HTMLElement2_get_ondragleave(IHTMLElement2 *iface, VARIANT *p)
2180 HTMLElement *This = impl_from_IHTMLElement2(iface);
2181 FIXME("(%p)->(%p)\n", This, p);
2182 return E_NOTIMPL;
2185 static HRESULT WINAPI HTMLElement2_put_ondrop(IHTMLElement2 *iface, VARIANT v)
2187 HTMLElement *This = impl_from_IHTMLElement2(iface);
2188 FIXME("(%p)->()\n", This);
2189 return E_NOTIMPL;
2192 static HRESULT WINAPI HTMLElement2_get_ondrop(IHTMLElement2 *iface, VARIANT *p)
2194 HTMLElement *This = impl_from_IHTMLElement2(iface);
2195 FIXME("(%p)->(%p)\n", This, p);
2196 return E_NOTIMPL;
2199 static HRESULT WINAPI HTMLElement2_put_onbeforecut(IHTMLElement2 *iface, VARIANT v)
2201 HTMLElement *This = impl_from_IHTMLElement2(iface);
2202 FIXME("(%p)->()\n", This);
2203 return E_NOTIMPL;
2206 static HRESULT WINAPI HTMLElement2_get_onbeforecut(IHTMLElement2 *iface, VARIANT *p)
2208 HTMLElement *This = impl_from_IHTMLElement2(iface);
2209 FIXME("(%p)->(%p)\n", This, p);
2210 return E_NOTIMPL;
2213 static HRESULT WINAPI HTMLElement2_put_oncut(IHTMLElement2 *iface, VARIANT v)
2215 HTMLElement *This = impl_from_IHTMLElement2(iface);
2216 FIXME("(%p)->()\n", This);
2217 return E_NOTIMPL;
2220 static HRESULT WINAPI HTMLElement2_get_oncut(IHTMLElement2 *iface, VARIANT *p)
2222 HTMLElement *This = impl_from_IHTMLElement2(iface);
2223 FIXME("(%p)->(%p)\n", This, p);
2224 return E_NOTIMPL;
2227 static HRESULT WINAPI HTMLElement2_put_onbeforecopy(IHTMLElement2 *iface, VARIANT v)
2229 HTMLElement *This = impl_from_IHTMLElement2(iface);
2230 FIXME("(%p)->()\n", This);
2231 return E_NOTIMPL;
2234 static HRESULT WINAPI HTMLElement2_get_onbeforecopy(IHTMLElement2 *iface, VARIANT *p)
2236 HTMLElement *This = impl_from_IHTMLElement2(iface);
2237 FIXME("(%p)->(%p)\n", This, p);
2238 return E_NOTIMPL;
2241 static HRESULT WINAPI HTMLElement2_put_oncopy(IHTMLElement2 *iface, VARIANT v)
2243 HTMLElement *This = impl_from_IHTMLElement2(iface);
2244 FIXME("(%p)->()\n", This);
2245 return E_NOTIMPL;
2248 static HRESULT WINAPI HTMLElement2_get_oncopy(IHTMLElement2 *iface, VARIANT *p)
2250 HTMLElement *This = impl_from_IHTMLElement2(iface);
2251 FIXME("(%p)->(%p)\n", This, p);
2252 return E_NOTIMPL;
2255 static HRESULT WINAPI HTMLElement2_put_onbeforepaste(IHTMLElement2 *iface, VARIANT v)
2257 HTMLElement *This = impl_from_IHTMLElement2(iface);
2258 FIXME("(%p)->()\n", This);
2259 return E_NOTIMPL;
2262 static HRESULT WINAPI HTMLElement2_get_onbeforepaste(IHTMLElement2 *iface, VARIANT *p)
2264 HTMLElement *This = impl_from_IHTMLElement2(iface);
2265 FIXME("(%p)->(%p)\n", This, p);
2266 return E_NOTIMPL;
2269 static HRESULT WINAPI HTMLElement2_put_onpaste(IHTMLElement2 *iface, VARIANT v)
2271 HTMLElement *This = impl_from_IHTMLElement2(iface);
2273 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2275 return set_node_event(&This->node, EVENTID_PASTE, &v);
2278 static HRESULT WINAPI HTMLElement2_get_onpaste(IHTMLElement2 *iface, VARIANT *p)
2280 HTMLElement *This = impl_from_IHTMLElement2(iface);
2282 TRACE("(%p)->(%p)\n", This, p);
2284 return get_node_event(&This->node, EVENTID_PASTE, p);
2287 static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLCurrentStyle **p)
2289 HTMLElement *This = impl_from_IHTMLElement2(iface);
2291 TRACE("(%p)->(%p)\n", This, p);
2293 return HTMLCurrentStyle_Create(This, p);
2296 static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v)
2298 HTMLElement *This = impl_from_IHTMLElement2(iface);
2299 FIXME("(%p)->()\n", This);
2300 return E_NOTIMPL;
2303 static HRESULT WINAPI HTMLElement2_get_onpropertychange(IHTMLElement2 *iface, VARIANT *p)
2305 HTMLElement *This = impl_from_IHTMLElement2(iface);
2306 FIXME("(%p)->(%p)\n", This, p);
2307 return E_NOTIMPL;
2310 static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRectCollection **pRectCol)
2312 HTMLElement *This = impl_from_IHTMLElement2(iface);
2313 FIXME("(%p)->(%p)\n", This, pRectCol);
2314 return E_NOTIMPL;
2317 static HRESULT WINAPI HTMLElement2_getBoundingClientRect(IHTMLElement2 *iface, IHTMLRect **pRect)
2319 HTMLElement *This = impl_from_IHTMLElement2(iface);
2320 nsIDOMClientRect *nsrect;
2321 nsresult nsres;
2322 HRESULT hres;
2324 TRACE("(%p)->(%p)\n", This, pRect);
2326 nsres = nsIDOMHTMLElement_GetBoundingClientRect(This->nselem, &nsrect);
2327 if(NS_FAILED(nsres) || !nsrect) {
2328 ERR("GetBoindingClientRect failed: %08x\n", nsres);
2329 return E_FAIL;
2332 hres = create_html_rect(nsrect, pRect);
2334 nsIDOMClientRect_Release(nsrect);
2335 return hres;
2338 static HRESULT WINAPI HTMLElement2_setExpression(IHTMLElement2 *iface, BSTR propname,
2339 BSTR expression, BSTR language)
2341 HTMLElement *This = impl_from_IHTMLElement2(iface);
2342 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(propname), debugstr_w(expression),
2343 debugstr_w(language));
2344 return E_NOTIMPL;
2347 static HRESULT WINAPI HTMLElement2_getExpression(IHTMLElement2 *iface, BSTR propname,
2348 VARIANT *expression)
2350 HTMLElement *This = impl_from_IHTMLElement2(iface);
2351 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), expression);
2352 return E_NOTIMPL;
2355 static HRESULT WINAPI HTMLElement2_removeExpression(IHTMLElement2 *iface, BSTR propname,
2356 VARIANT_BOOL *pfSuccess)
2358 HTMLElement *This = impl_from_IHTMLElement2(iface);
2359 FIXME("(%p)->(%s %p)\n", This, debugstr_w(propname), pfSuccess);
2360 return E_NOTIMPL;
2363 static HRESULT WINAPI HTMLElement2_put_tabIndex(IHTMLElement2 *iface, short v)
2365 HTMLElement *This = impl_from_IHTMLElement2(iface);
2366 nsresult nsres;
2368 TRACE("(%p)->(%d)\n", This, v);
2370 nsres = nsIDOMHTMLElement_SetTabIndex(This->nselem, v);
2371 if(NS_FAILED(nsres))
2372 ERR("GetTabIndex failed: %08x\n", nsres);
2374 return S_OK;
2377 static HRESULT WINAPI HTMLElement2_get_tabIndex(IHTMLElement2 *iface, short *p)
2379 HTMLElement *This = impl_from_IHTMLElement2(iface);
2380 LONG index;
2381 nsresult nsres;
2383 TRACE("(%p)->(%p)\n", This, p);
2385 nsres = nsIDOMHTMLElement_GetTabIndex(This->nselem, &index);
2386 if(NS_FAILED(nsres)) {
2387 ERR("GetTabIndex failed: %08x\n", nsres);
2388 return E_FAIL;
2391 *p = index;
2392 return S_OK;
2395 static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
2397 HTMLElement *This = impl_from_IHTMLElement2(iface);
2398 nsresult nsres;
2400 TRACE("(%p)\n", This);
2402 nsres = nsIDOMHTMLElement_Focus(This->nselem);
2403 if(NS_FAILED(nsres))
2404 ERR("Focus failed: %08x\n", nsres);
2406 return S_OK;
2409 static HRESULT WINAPI HTMLElement2_put_accessKey(IHTMLElement2 *iface, BSTR v)
2411 HTMLElement *This = impl_from_IHTMLElement2(iface);
2412 VARIANT var;
2414 static WCHAR accessKeyW[] = {'a','c','c','e','s','s','K','e','y',0};
2416 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2418 V_VT(&var) = VT_BSTR;
2419 V_BSTR(&var) = v;
2420 return IHTMLElement_setAttribute(&This->IHTMLElement_iface, accessKeyW, var, 0);
2423 static HRESULT WINAPI HTMLElement2_get_accessKey(IHTMLElement2 *iface, BSTR *p)
2425 HTMLElement *This = impl_from_IHTMLElement2(iface);
2426 FIXME("(%p)->(%p)\n", This, p);
2427 return E_NOTIMPL;
2430 static HRESULT WINAPI HTMLElement2_put_onblur(IHTMLElement2 *iface, VARIANT v)
2432 HTMLElement *This = impl_from_IHTMLElement2(iface);
2434 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2436 return set_node_event(&This->node, EVENTID_BLUR, &v);
2439 static HRESULT WINAPI HTMLElement2_get_onblur(IHTMLElement2 *iface, VARIANT *p)
2441 HTMLElement *This = impl_from_IHTMLElement2(iface);
2443 TRACE("(%p)->(%p)\n", This, p);
2445 return get_node_event(&This->node, EVENTID_BLUR, p);
2448 static HRESULT WINAPI HTMLElement2_put_onfocus(IHTMLElement2 *iface, VARIANT v)
2450 HTMLElement *This = impl_from_IHTMLElement2(iface);
2452 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2454 return set_node_event(&This->node, EVENTID_FOCUS, &v);
2457 static HRESULT WINAPI HTMLElement2_get_onfocus(IHTMLElement2 *iface, VARIANT *p)
2459 HTMLElement *This = impl_from_IHTMLElement2(iface);
2461 TRACE("(%p)->(%p)\n", This, p);
2463 return get_node_event(&This->node, EVENTID_FOCUS, p);
2466 static HRESULT WINAPI HTMLElement2_put_onresize(IHTMLElement2 *iface, VARIANT v)
2468 HTMLElement *This = impl_from_IHTMLElement2(iface);
2469 FIXME("(%p)->()\n", This);
2470 return E_NOTIMPL;
2473 static HRESULT WINAPI HTMLElement2_get_onresize(IHTMLElement2 *iface, VARIANT *p)
2475 HTMLElement *This = impl_from_IHTMLElement2(iface);
2476 FIXME("(%p)->(%p)\n", This, p);
2477 return E_NOTIMPL;
2480 static HRESULT WINAPI HTMLElement2_blur(IHTMLElement2 *iface)
2482 HTMLElement *This = impl_from_IHTMLElement2(iface);
2483 nsresult nsres;
2485 TRACE("(%p)\n", This);
2487 nsres = nsIDOMHTMLElement_Blur(This->nselem);
2488 if(NS_FAILED(nsres)) {
2489 ERR("Blur failed: %08x\n", nsres);
2490 return E_FAIL;
2493 return S_OK;
2496 static HRESULT WINAPI HTMLElement2_addFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2498 HTMLElement *This = impl_from_IHTMLElement2(iface);
2499 FIXME("(%p)->(%p)\n", This, pUnk);
2500 return E_NOTIMPL;
2503 static HRESULT WINAPI HTMLElement2_removeFilter(IHTMLElement2 *iface, IUnknown *pUnk)
2505 HTMLElement *This = impl_from_IHTMLElement2(iface);
2506 FIXME("(%p)->(%p)\n", This, pUnk);
2507 return E_NOTIMPL;
2510 static HRESULT WINAPI HTMLElement2_get_clientHeight(IHTMLElement2 *iface, LONG *p)
2512 HTMLElement *This = impl_from_IHTMLElement2(iface);
2513 nsresult nsres;
2515 TRACE("(%p)->(%p)\n", This, p);
2517 nsres = nsIDOMHTMLElement_GetClientHeight(This->nselem, p);
2518 assert(nsres == NS_OK);
2519 return S_OK;
2522 static HRESULT WINAPI HTMLElement2_get_clientWidth(IHTMLElement2 *iface, LONG *p)
2524 HTMLElement *This = impl_from_IHTMLElement2(iface);
2525 nsresult nsres;
2527 TRACE("(%p)->(%p)\n", This, p);
2529 nsres = nsIDOMHTMLElement_GetClientWidth(This->nselem, p);
2530 assert(nsres == NS_OK);
2531 return S_OK;
2534 static HRESULT WINAPI HTMLElement2_get_clientTop(IHTMLElement2 *iface, LONG *p)
2536 HTMLElement *This = impl_from_IHTMLElement2(iface);
2537 nsresult nsres;
2539 TRACE("(%p)->(%p)\n", This, p);
2541 nsres = nsIDOMHTMLElement_GetClientTop(This->nselem, p);
2542 assert(nsres == NS_OK);
2544 TRACE("*p = %d\n", *p);
2545 return S_OK;
2548 static HRESULT WINAPI HTMLElement2_get_clientLeft(IHTMLElement2 *iface, LONG *p)
2550 HTMLElement *This = impl_from_IHTMLElement2(iface);
2551 nsresult nsres;
2553 TRACE("(%p)->(%p)\n", This, p);
2555 nsres = nsIDOMHTMLElement_GetClientLeft(This->nselem, p);
2556 assert(nsres == NS_OK);
2558 TRACE("*p = %d\n", *p);
2559 return S_OK;
2562 static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
2563 IDispatch *pDisp, VARIANT_BOOL *pfResult)
2565 HTMLElement *This = impl_from_IHTMLElement2(iface);
2567 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2569 return attach_event(&This->node.event_target, event, pDisp, pfResult);
2572 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
2574 HTMLElement *This = impl_from_IHTMLElement2(iface);
2576 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2578 return detach_event(&This->node.event_target, event, pDisp);
2581 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
2583 HTMLElement *This = impl_from_IHTMLElement2(iface);
2584 BSTR str;
2586 TRACE("(%p)->(%p)\n", This, p);
2588 if(This->node.vtbl->get_readystate) {
2589 HRESULT hres;
2591 hres = This->node.vtbl->get_readystate(&This->node, &str);
2592 if(FAILED(hres))
2593 return hres;
2594 }else {
2595 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2597 str = SysAllocString(completeW);
2598 if(!str)
2599 return E_OUTOFMEMORY;
2602 V_VT(p) = VT_BSTR;
2603 V_BSTR(p) = str;
2604 return S_OK;
2607 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
2609 HTMLElement *This = impl_from_IHTMLElement2(iface);
2611 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
2613 return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
2616 static HRESULT WINAPI HTMLElement2_get_onreadystatechange(IHTMLElement2 *iface, VARIANT *p)
2618 HTMLElement *This = impl_from_IHTMLElement2(iface);
2620 TRACE("(%p)->(%p)\n", This, p);
2622 return get_node_event(&This->node, EVENTID_READYSTATECHANGE, p);
2625 static HRESULT WINAPI HTMLElement2_put_onrowsdelete(IHTMLElement2 *iface, VARIANT v)
2627 HTMLElement *This = impl_from_IHTMLElement2(iface);
2628 FIXME("(%p)->()\n", This);
2629 return E_NOTIMPL;
2632 static HRESULT WINAPI HTMLElement2_get_onrowsdelete(IHTMLElement2 *iface, VARIANT *p)
2634 HTMLElement *This = impl_from_IHTMLElement2(iface);
2635 FIXME("(%p)->(%p)\n", This, p);
2636 return E_NOTIMPL;
2639 static HRESULT WINAPI HTMLElement2_put_onrowsinserted(IHTMLElement2 *iface, VARIANT v)
2641 HTMLElement *This = impl_from_IHTMLElement2(iface);
2642 FIXME("(%p)->()\n", This);
2643 return E_NOTIMPL;
2646 static HRESULT WINAPI HTMLElement2_get_onrowsinserted(IHTMLElement2 *iface, VARIANT *p)
2648 HTMLElement *This = impl_from_IHTMLElement2(iface);
2649 FIXME("(%p)->(%p)\n", This, p);
2650 return E_NOTIMPL;
2653 static HRESULT WINAPI HTMLElement2_put_oncellchange(IHTMLElement2 *iface, VARIANT v)
2655 HTMLElement *This = impl_from_IHTMLElement2(iface);
2656 FIXME("(%p)->()\n", This);
2657 return E_NOTIMPL;
2660 static HRESULT WINAPI HTMLElement2_get_oncellchange(IHTMLElement2 *iface, VARIANT *p)
2662 HTMLElement *This = impl_from_IHTMLElement2(iface);
2663 FIXME("(%p)->(%p)\n", This, p);
2664 return E_NOTIMPL;
2667 static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
2669 HTMLElement *This = impl_from_IHTMLElement2(iface);
2670 nsAString nsstr;
2671 nsresult nsres;
2673 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
2675 if(!This->nselem) {
2676 FIXME("Unsupported for comment nodes.\n");
2677 return S_OK;
2680 nsAString_InitDepend(&nsstr, v);
2681 nsres = nsIDOMHTMLElement_SetDir(This->nselem, &nsstr);
2682 nsAString_Finish(&nsstr);
2683 if(NS_FAILED(nsres)) {
2684 ERR("SetDir failed: %08x\n", nsres);
2685 return E_FAIL;
2688 return S_OK;
2691 static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
2693 HTMLElement *This = impl_from_IHTMLElement2(iface);
2694 nsAString dir_str;
2695 nsresult nsres;
2697 TRACE("(%p)->(%p)\n", This, p);
2699 if(!This->nselem) {
2700 *p = NULL;
2701 return S_OK;
2704 nsAString_Init(&dir_str, NULL);
2705 nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
2706 return return_nsstr(nsres, &dir_str, p);
2709 static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
2711 HTMLElement *This = impl_from_IHTMLElement2(iface);
2712 FIXME("(%p)->(%p)\n", This, range);
2713 return E_NOTIMPL;
2716 static HRESULT WINAPI HTMLElement2_get_scrollHeight(IHTMLElement2 *iface, LONG *p)
2718 HTMLElement *This = impl_from_IHTMLElement2(iface);
2719 nsresult nsres;
2721 TRACE("(%p)->(%p)\n", This, p);
2723 nsres = nsIDOMHTMLElement_GetScrollHeight(This->nselem, p);
2724 assert(nsres == NS_OK);
2726 TRACE("*p = %d\n", *p);
2727 return S_OK;
2730 static HRESULT WINAPI HTMLElement2_get_scrollWidth(IHTMLElement2 *iface, LONG *p)
2732 HTMLElement *This = impl_from_IHTMLElement2(iface);
2733 nsresult nsres;
2735 TRACE("(%p)->(%p)\n", This, p);
2737 nsres = nsIDOMHTMLElement_GetScrollWidth(This->nselem, p);
2738 assert(nsres == NS_OK);
2740 TRACE("*p = %d\n", *p);
2741 return S_OK;
2744 static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, LONG v)
2746 HTMLElement *This = impl_from_IHTMLElement2(iface);
2748 TRACE("(%p)->(%d)\n", This, v);
2750 if(!This->nselem) {
2751 FIXME("NULL nselem\n");
2752 return E_NOTIMPL;
2755 nsIDOMHTMLElement_SetScrollTop(This->nselem, v);
2756 return S_OK;
2759 static HRESULT WINAPI HTMLElement2_get_scrollTop(IHTMLElement2 *iface, LONG *p)
2761 HTMLElement *This = impl_from_IHTMLElement2(iface);
2762 nsresult nsres;
2764 TRACE("(%p)->(%p)\n", This, p);
2766 nsres = nsIDOMHTMLElement_GetScrollTop(This->nselem, p);
2767 assert(nsres == NS_OK);
2769 TRACE("*p = %d\n", *p);
2770 return S_OK;
2773 static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, LONG v)
2775 HTMLElement *This = impl_from_IHTMLElement2(iface);
2777 TRACE("(%p)->(%d)\n", This, v);
2779 if(!This->nselem) {
2780 FIXME("NULL nselem\n");
2781 return E_NOTIMPL;
2784 nsIDOMHTMLElement_SetScrollLeft(This->nselem, v);
2785 return S_OK;
2788 static HRESULT WINAPI HTMLElement2_get_scrollLeft(IHTMLElement2 *iface, LONG *p)
2790 HTMLElement *This = impl_from_IHTMLElement2(iface);
2791 nsresult nsres;
2793 TRACE("(%p)->(%p)\n", This, p);
2795 if(!p)
2796 return E_INVALIDARG;
2798 if(!This->nselem)
2800 FIXME("NULL nselem\n");
2801 return E_NOTIMPL;
2804 nsres = nsIDOMHTMLElement_GetScrollLeft(This->nselem, p);
2805 assert(nsres == NS_OK);
2807 TRACE("*p = %d\n", *p);
2808 return S_OK;
2811 static HRESULT WINAPI HTMLElement2_clearAttributes(IHTMLElement2 *iface)
2813 HTMLElement *This = impl_from_IHTMLElement2(iface);
2814 FIXME("(%p)\n", This);
2815 return E_NOTIMPL;
2818 static HRESULT WINAPI HTMLElement2_mergeAttributes(IHTMLElement2 *iface, IHTMLElement *mergeThis)
2820 HTMLElement *This = impl_from_IHTMLElement2(iface);
2821 FIXME("(%p)->(%p)\n", This, mergeThis);
2822 return E_NOTIMPL;
2825 static HRESULT WINAPI HTMLElement2_put_oncontextmenu(IHTMLElement2 *iface, VARIANT v)
2827 HTMLElement *This = impl_from_IHTMLElement2(iface);
2828 FIXME("(%p)->()\n", This);
2829 return E_NOTIMPL;
2832 static HRESULT WINAPI HTMLElement2_get_oncontextmenu(IHTMLElement2 *iface, VARIANT *p)
2834 HTMLElement *This = impl_from_IHTMLElement2(iface);
2835 FIXME("(%p)->(%p)\n", This, p);
2836 return E_NOTIMPL;
2839 static HRESULT WINAPI HTMLElement2_insertAdjacentElement(IHTMLElement2 *iface, BSTR where,
2840 IHTMLElement *insertedElement, IHTMLElement **inserted)
2842 HTMLElement *This = impl_from_IHTMLElement2(iface);
2843 HTMLDOMNode *ret_node;
2844 HTMLElement *elem;
2845 HRESULT hres;
2847 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(where), insertedElement, inserted);
2849 elem = unsafe_impl_from_IHTMLElement(insertedElement);
2850 if(!elem)
2851 return E_INVALIDARG;
2853 hres = insert_adjacent_node(This, where, elem->node.nsnode, &ret_node);
2854 if(FAILED(hres))
2855 return hres;
2857 hres = IHTMLDOMNode_QueryInterface(&ret_node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)inserted);
2858 IHTMLDOMNode_Release(&ret_node->IHTMLDOMNode_iface);
2859 return hres;
2862 static HRESULT WINAPI HTMLElement2_applyElement(IHTMLElement2 *iface, IHTMLElement *apply,
2863 BSTR where, IHTMLElement **applied)
2865 HTMLElement *This = impl_from_IHTMLElement2(iface);
2866 FIXME("(%p)->(%p %s %p)\n", This, apply, debugstr_w(where), applied);
2867 return E_NOTIMPL;
2870 static HRESULT WINAPI HTMLElement2_getAdjacentText(IHTMLElement2 *iface, BSTR where, BSTR *text)
2872 HTMLElement *This = impl_from_IHTMLElement2(iface);
2873 FIXME("(%p)->(%s %p)\n", This, debugstr_w(where), text);
2874 return E_NOTIMPL;
2877 static HRESULT WINAPI HTMLElement2_replaceAdjacentText(IHTMLElement2 *iface, BSTR where,
2878 BSTR newText, BSTR *oldText)
2880 HTMLElement *This = impl_from_IHTMLElement2(iface);
2881 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(where), debugstr_w(newText), oldText);
2882 return E_NOTIMPL;
2885 static HRESULT WINAPI HTMLElement2_get_canHandleChildren(IHTMLElement2 *iface, VARIANT_BOOL *p)
2887 HTMLElement *This = impl_from_IHTMLElement2(iface);
2888 FIXME("(%p)->(%p)\n", This, p);
2889 return E_NOTIMPL;
2892 static HRESULT WINAPI HTMLElement2_addBehavior(IHTMLElement2 *iface, BSTR bstrUrl,
2893 VARIANT *pvarFactory, LONG *pCookie)
2895 HTMLElement *This = impl_from_IHTMLElement2(iface);
2896 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrUrl), pvarFactory, pCookie);
2897 return E_NOTIMPL;
2900 static HRESULT WINAPI HTMLElement2_removeBehavior(IHTMLElement2 *iface, LONG cookie,
2901 VARIANT_BOOL *pfResult)
2903 HTMLElement *This = impl_from_IHTMLElement2(iface);
2904 FIXME("(%p)->(%d %p)\n", This, cookie, pfResult);
2905 return E_NOTIMPL;
2908 static HRESULT WINAPI HTMLElement2_get_runtimeStyle(IHTMLElement2 *iface, IHTMLStyle **p)
2910 HTMLElement *This = impl_from_IHTMLElement2(iface);
2912 FIXME("(%p)->(%p): hack\n", This, p);
2914 /* We can't implement correct behavior on top of Gecko (although we could
2915 try a bit harder). Making runtimeStyle behave like regular style is
2916 enough for most use cases. */
2917 if(!This->runtime_style) {
2918 HRESULT hres;
2920 hres = HTMLStyle_Create(This, &This->runtime_style);
2921 if(FAILED(hres))
2922 return hres;
2925 *p = &This->runtime_style->IHTMLStyle_iface;
2926 IHTMLStyle_AddRef(*p);
2927 return S_OK;
2930 static HRESULT WINAPI HTMLElement2_get_behaviorUrns(IHTMLElement2 *iface, IDispatch **p)
2932 HTMLElement *This = impl_from_IHTMLElement2(iface);
2933 FIXME("(%p)->(%p)\n", This, p);
2934 return E_NOTIMPL;
2937 static HRESULT WINAPI HTMLElement2_put_tagUrn(IHTMLElement2 *iface, BSTR v)
2939 HTMLElement *This = impl_from_IHTMLElement2(iface);
2940 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2941 return E_NOTIMPL;
2944 static HRESULT WINAPI HTMLElement2_get_tagUrn(IHTMLElement2 *iface, BSTR *p)
2946 HTMLElement *This = impl_from_IHTMLElement2(iface);
2947 FIXME("(%p)->(%p)\n", This, p);
2948 return E_NOTIMPL;
2951 static HRESULT WINAPI HTMLElement2_put_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT vv)
2953 HTMLElement *This = impl_from_IHTMLElement2(iface);
2954 FIXME("(%p)->()\n", This);
2955 return E_NOTIMPL;
2958 static HRESULT WINAPI HTMLElement2_get_onbeforeeditfocus(IHTMLElement2 *iface, VARIANT *p)
2960 HTMLElement *This = impl_from_IHTMLElement2(iface);
2961 FIXME("(%p)->(%p)\n", This, p);
2962 return E_NOTIMPL;
2965 static HRESULT WINAPI HTMLElement2_get_readyStateValue(IHTMLElement2 *iface, LONG *p)
2967 HTMLElement *This = impl_from_IHTMLElement2(iface);
2968 FIXME("(%p)->(%p)\n", This, p);
2969 return E_NOTIMPL;
2972 static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v,
2973 IHTMLElementCollection **pelColl)
2975 HTMLElement *This = impl_from_IHTMLElement2(iface);
2976 nsIDOMHTMLCollection *nscol;
2977 nsAString tag_str;
2978 nsresult nsres;
2980 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2982 nsAString_InitDepend(&tag_str, v);
2983 nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nscol);
2984 nsAString_Finish(&tag_str);
2985 if(NS_FAILED(nsres)) {
2986 ERR("GetElementByTagName failed: %08x\n", nsres);
2987 return E_FAIL;
2990 *pelColl = create_collection_from_htmlcol(This->node.doc, nscol);
2991 nsIDOMHTMLCollection_Release(nscol);
2992 return S_OK;
2995 static const IHTMLElement2Vtbl HTMLElement2Vtbl = {
2996 HTMLElement2_QueryInterface,
2997 HTMLElement2_AddRef,
2998 HTMLElement2_Release,
2999 HTMLElement2_GetTypeInfoCount,
3000 HTMLElement2_GetTypeInfo,
3001 HTMLElement2_GetIDsOfNames,
3002 HTMLElement2_Invoke,
3003 HTMLElement2_get_scopeName,
3004 HTMLElement2_setCapture,
3005 HTMLElement2_releaseCapture,
3006 HTMLElement2_put_onlosecapture,
3007 HTMLElement2_get_onlosecapture,
3008 HTMLElement2_componentFromPoint,
3009 HTMLElement2_doScroll,
3010 HTMLElement2_put_onscroll,
3011 HTMLElement2_get_onscroll,
3012 HTMLElement2_put_ondrag,
3013 HTMLElement2_get_ondrag,
3014 HTMLElement2_put_ondragend,
3015 HTMLElement2_get_ondragend,
3016 HTMLElement2_put_ondragenter,
3017 HTMLElement2_get_ondragenter,
3018 HTMLElement2_put_ondragover,
3019 HTMLElement2_get_ondragover,
3020 HTMLElement2_put_ondragleave,
3021 HTMLElement2_get_ondragleave,
3022 HTMLElement2_put_ondrop,
3023 HTMLElement2_get_ondrop,
3024 HTMLElement2_put_onbeforecut,
3025 HTMLElement2_get_onbeforecut,
3026 HTMLElement2_put_oncut,
3027 HTMLElement2_get_oncut,
3028 HTMLElement2_put_onbeforecopy,
3029 HTMLElement2_get_onbeforecopy,
3030 HTMLElement2_put_oncopy,
3031 HTMLElement2_get_oncopy,
3032 HTMLElement2_put_onbeforepaste,
3033 HTMLElement2_get_onbeforepaste,
3034 HTMLElement2_put_onpaste,
3035 HTMLElement2_get_onpaste,
3036 HTMLElement2_get_currentStyle,
3037 HTMLElement2_put_onpropertychange,
3038 HTMLElement2_get_onpropertychange,
3039 HTMLElement2_getClientRects,
3040 HTMLElement2_getBoundingClientRect,
3041 HTMLElement2_setExpression,
3042 HTMLElement2_getExpression,
3043 HTMLElement2_removeExpression,
3044 HTMLElement2_put_tabIndex,
3045 HTMLElement2_get_tabIndex,
3046 HTMLElement2_focus,
3047 HTMLElement2_put_accessKey,
3048 HTMLElement2_get_accessKey,
3049 HTMLElement2_put_onblur,
3050 HTMLElement2_get_onblur,
3051 HTMLElement2_put_onfocus,
3052 HTMLElement2_get_onfocus,
3053 HTMLElement2_put_onresize,
3054 HTMLElement2_get_onresize,
3055 HTMLElement2_blur,
3056 HTMLElement2_addFilter,
3057 HTMLElement2_removeFilter,
3058 HTMLElement2_get_clientHeight,
3059 HTMLElement2_get_clientWidth,
3060 HTMLElement2_get_clientTop,
3061 HTMLElement2_get_clientLeft,
3062 HTMLElement2_attachEvent,
3063 HTMLElement2_detachEvent,
3064 HTMLElement2_get_readyState,
3065 HTMLElement2_put_onreadystatechange,
3066 HTMLElement2_get_onreadystatechange,
3067 HTMLElement2_put_onrowsdelete,
3068 HTMLElement2_get_onrowsdelete,
3069 HTMLElement2_put_onrowsinserted,
3070 HTMLElement2_get_onrowsinserted,
3071 HTMLElement2_put_oncellchange,
3072 HTMLElement2_get_oncellchange,
3073 HTMLElement2_put_dir,
3074 HTMLElement2_get_dir,
3075 HTMLElement2_createControlRange,
3076 HTMLElement2_get_scrollHeight,
3077 HTMLElement2_get_scrollWidth,
3078 HTMLElement2_put_scrollTop,
3079 HTMLElement2_get_scrollTop,
3080 HTMLElement2_put_scrollLeft,
3081 HTMLElement2_get_scrollLeft,
3082 HTMLElement2_clearAttributes,
3083 HTMLElement2_mergeAttributes,
3084 HTMLElement2_put_oncontextmenu,
3085 HTMLElement2_get_oncontextmenu,
3086 HTMLElement2_insertAdjacentElement,
3087 HTMLElement2_applyElement,
3088 HTMLElement2_getAdjacentText,
3089 HTMLElement2_replaceAdjacentText,
3090 HTMLElement2_get_canHandleChildren,
3091 HTMLElement2_addBehavior,
3092 HTMLElement2_removeBehavior,
3093 HTMLElement2_get_runtimeStyle,
3094 HTMLElement2_get_behaviorUrns,
3095 HTMLElement2_put_tagUrn,
3096 HTMLElement2_get_tagUrn,
3097 HTMLElement2_put_onbeforeeditfocus,
3098 HTMLElement2_get_onbeforeeditfocus,
3099 HTMLElement2_get_readyStateValue,
3100 HTMLElement2_getElementsByTagName,
3103 static inline HTMLElement *impl_from_IHTMLElement3(IHTMLElement3 *iface)
3105 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement3_iface);
3108 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
3109 REFIID riid, void **ppv)
3111 HTMLElement *This = impl_from_IHTMLElement3(iface);
3112 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3115 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
3117 HTMLElement *This = impl_from_IHTMLElement3(iface);
3118 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3121 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
3123 HTMLElement *This = impl_from_IHTMLElement3(iface);
3124 return IHTMLElement_Release(&This->IHTMLElement_iface);
3127 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
3129 HTMLElement *This = impl_from_IHTMLElement3(iface);
3130 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3133 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
3134 LCID lcid, ITypeInfo **ppTInfo)
3136 HTMLElement *This = impl_from_IHTMLElement3(iface);
3137 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3140 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
3141 LPOLESTR *rgszNames, UINT cNames,
3142 LCID lcid, DISPID *rgDispId)
3144 HTMLElement *This = impl_from_IHTMLElement3(iface);
3145 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3146 lcid, rgDispId);
3149 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
3150 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3151 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3153 HTMLElement *This = impl_from_IHTMLElement3(iface);
3154 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3155 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3158 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
3160 HTMLElement *This = impl_from_IHTMLElement3(iface);
3161 FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
3162 return E_NOTIMPL;
3165 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
3167 HTMLElement *This = impl_from_IHTMLElement3(iface);
3168 FIXME("(%p)->(%p)\n", This, p);
3169 return E_NOTIMPL;
3172 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
3174 HTMLElement *This = impl_from_IHTMLElement3(iface);
3175 FIXME("(%p)->(%p)\n", This, p);
3176 return E_NOTIMPL;
3179 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
3181 HTMLElement *This = impl_from_IHTMLElement3(iface);
3182 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3183 return E_NOTIMPL;
3186 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
3188 HTMLElement *This = impl_from_IHTMLElement3(iface);
3189 FIXME("(%p)->(%p)\n", This, p);
3190 return E_NOTIMPL;
3193 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
3195 HTMLElement *This = impl_from_IHTMLElement3(iface);
3196 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3197 return E_NOTIMPL;
3200 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
3202 HTMLElement *This = impl_from_IHTMLElement3(iface);
3203 FIXME("(%p)->(%p)\n", This, p);
3204 return E_NOTIMPL;
3207 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
3209 HTMLElement *This = impl_from_IHTMLElement3(iface);
3210 FIXME("(%p)->(%x)\n", This, v);
3211 return E_NOTIMPL;
3214 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
3216 HTMLElement *This = impl_from_IHTMLElement3(iface);
3217 FIXME("(%p)->(%p)\n", This, p);
3218 return E_NOTIMPL;
3221 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
3223 HTMLElement *This = impl_from_IHTMLElement3(iface);
3224 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3225 return E_NOTIMPL;
3228 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
3230 HTMLElement *This = impl_from_IHTMLElement3(iface);
3231 FIXME("(%p)->(%p)\n", This, p);
3232 return E_NOTIMPL;
3235 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
3237 HTMLElement *This = impl_from_IHTMLElement3(iface);
3238 FIXME("(%p)\n", This);
3239 return E_NOTIMPL;
3242 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
3244 HTMLElement *This = impl_from_IHTMLElement3(iface);
3245 nsresult nsres;
3246 nsAString str;
3248 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
3250 nsAString_InitDepend(&str, v);
3251 nsres = nsIDOMHTMLElement_SetContentEditable(This->nselem, &str);
3252 nsAString_Finish(&str);
3254 if (NS_FAILED(nsres)){
3255 ERR("SetContentEditable(%s) failed!\n", debugstr_w(v));
3256 return E_FAIL;
3259 return S_OK;
3262 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
3264 HTMLElement *This = impl_from_IHTMLElement3(iface);
3265 nsresult nsres;
3266 nsAString str;
3268 TRACE("(%p)->(%p)\n", This, p);
3270 nsAString_Init(&str, NULL);
3271 nsres = nsIDOMHTMLElement_GetContentEditable(This->nselem, &str);
3272 return return_nsstr(nsres, &str, p);
3275 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
3277 HTMLElement *This = impl_from_IHTMLElement3(iface);
3278 FIXME("(%p)->(%p)\n", This, p);
3279 return E_NOTIMPL;
3282 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
3284 HTMLElement *This = impl_from_IHTMLElement3(iface);
3285 FIXME("(%p)->(%x)\n", This, v);
3286 return E_NOTIMPL;
3289 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
3291 HTMLElement *This = impl_from_IHTMLElement3(iface);
3292 FIXME("(%p)->(%p)\n", This, p);
3293 return E_NOTIMPL;
3296 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
3298 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
3300 HTMLElement *This = impl_from_IHTMLElement3(iface);
3301 VARIANT *var;
3302 HRESULT hres;
3304 TRACE("(%p)->(%x)\n", This, v);
3306 if(This->node.vtbl->put_disabled)
3307 return This->node.vtbl->put_disabled(&This->node, v);
3309 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, TRUE, &var);
3310 if(FAILED(hres))
3311 return hres;
3313 VariantClear(var);
3314 V_VT(var) = VT_BOOL;
3315 V_BOOL(var) = v;
3316 return S_OK;
3319 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3321 HTMLElement *This = impl_from_IHTMLElement3(iface);
3322 VARIANT *var;
3323 HRESULT hres;
3325 TRACE("(%p)->(%p)\n", This, p);
3327 if(This->node.vtbl->get_disabled)
3328 return This->node.vtbl->get_disabled(&This->node, p);
3330 hres = dispex_get_dprop_ref(&This->node.event_target.dispex, disabledW, FALSE, &var);
3331 if(hres == DISP_E_UNKNOWNNAME) {
3332 *p = VARIANT_FALSE;
3333 return S_OK;
3335 if(FAILED(hres))
3336 return hres;
3338 if(V_VT(var) != VT_BOOL) {
3339 FIXME("value is %s\n", debugstr_variant(var));
3340 return E_NOTIMPL;
3343 *p = V_BOOL(var);
3344 return S_OK;
3347 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
3349 HTMLElement *This = impl_from_IHTMLElement3(iface);
3350 FIXME("(%p)->(%p)\n", This, p);
3351 return E_NOTIMPL;
3354 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
3356 HTMLElement *This = impl_from_IHTMLElement3(iface);
3357 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3358 return E_NOTIMPL;
3361 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
3363 HTMLElement *This = impl_from_IHTMLElement3(iface);
3364 FIXME("(%p)->(%p)\n", This, p);
3365 return E_NOTIMPL;
3368 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
3370 HTMLElement *This = impl_from_IHTMLElement3(iface);
3371 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3372 return E_NOTIMPL;
3375 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
3377 HTMLElement *This = impl_from_IHTMLElement3(iface);
3378 FIXME("(%p)->(%p)\n", This, p);
3379 return E_NOTIMPL;
3382 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
3383 VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
3385 HTMLElement *This = impl_from_IHTMLElement3(iface);
3387 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
3388 pfCancelled);
3390 return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
3393 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
3395 HTMLElement *This = impl_from_IHTMLElement3(iface);
3396 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3397 return E_NOTIMPL;
3400 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
3402 HTMLElement *This = impl_from_IHTMLElement3(iface);
3403 FIXME("(%p)->(%p)\n", This, p);
3404 return E_NOTIMPL;
3407 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
3409 HTMLElement *This = impl_from_IHTMLElement3(iface);
3410 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3411 return E_NOTIMPL;
3414 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
3416 HTMLElement *This = impl_from_IHTMLElement3(iface);
3417 FIXME("(%p)->(%p)\n", This, p);
3418 return E_NOTIMPL;
3421 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
3423 HTMLElement *This = impl_from_IHTMLElement3(iface);
3424 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3425 return E_NOTIMPL;
3428 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
3430 HTMLElement *This = impl_from_IHTMLElement3(iface);
3431 FIXME("(%p)->(%p)\n", This, p);
3432 return E_NOTIMPL;
3435 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
3437 HTMLElement *This = impl_from_IHTMLElement3(iface);
3438 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3439 return E_NOTIMPL;
3442 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
3444 HTMLElement *This = impl_from_IHTMLElement3(iface);
3445 FIXME("(%p)->(%p)\n", This, p);
3446 return E_NOTIMPL;
3449 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
3451 HTMLElement *This = impl_from_IHTMLElement3(iface);
3452 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3453 return E_NOTIMPL;
3456 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
3458 HTMLElement *This = impl_from_IHTMLElement3(iface);
3459 FIXME("(%p)->(%p)\n", This, p);
3460 return E_NOTIMPL;
3463 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
3465 HTMLElement *This = impl_from_IHTMLElement3(iface);
3466 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3467 return E_NOTIMPL;
3470 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
3472 HTMLElement *This = impl_from_IHTMLElement3(iface);
3473 FIXME("(%p)->(%p)\n", This, p);
3474 return E_NOTIMPL;
3477 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
3479 HTMLElement *This = impl_from_IHTMLElement3(iface);
3480 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3481 return E_NOTIMPL;
3484 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
3486 HTMLElement *This = impl_from_IHTMLElement3(iface);
3487 FIXME("(%p)->(%p)\n", This, p);
3488 return E_NOTIMPL;
3491 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
3493 HTMLElement *This = impl_from_IHTMLElement3(iface);
3494 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3495 return E_NOTIMPL;
3498 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
3500 HTMLElement *This = impl_from_IHTMLElement3(iface);
3501 FIXME("(%p)->(%p)\n", This, p);
3502 return E_NOTIMPL;
3505 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
3507 HTMLElement *This = impl_from_IHTMLElement3(iface);
3508 FIXME("(%p)->(%p)\n", This, pfRet);
3509 return E_NOTIMPL;
3512 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
3514 HTMLElement *This = impl_from_IHTMLElement3(iface);
3515 FIXME("(%p)->(%p)\n", This, p);
3516 return E_NOTIMPL;
3519 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
3520 HTMLElement3_QueryInterface,
3521 HTMLElement3_AddRef,
3522 HTMLElement3_Release,
3523 HTMLElement3_GetTypeInfoCount,
3524 HTMLElement3_GetTypeInfo,
3525 HTMLElement3_GetIDsOfNames,
3526 HTMLElement3_Invoke,
3527 HTMLElement3_mergeAttributes,
3528 HTMLElement3_get_isMultiLine,
3529 HTMLElement3_get_canHaveHTML,
3530 HTMLElement3_put_onlayoutcomplete,
3531 HTMLElement3_get_onlayoutcomplete,
3532 HTMLElement3_put_onpage,
3533 HTMLElement3_get_onpage,
3534 HTMLElement3_put_inflateBlock,
3535 HTMLElement3_get_inflateBlock,
3536 HTMLElement3_put_onbeforedeactivate,
3537 HTMLElement3_get_onbeforedeactivate,
3538 HTMLElement3_setActive,
3539 HTMLElement3_put_contentEditable,
3540 HTMLElement3_get_contentEditable,
3541 HTMLElement3_get_isContentEditable,
3542 HTMLElement3_put_hideFocus,
3543 HTMLElement3_get_hideFocus,
3544 HTMLElement3_put_disabled,
3545 HTMLElement3_get_disabled,
3546 HTMLElement3_get_isDisabled,
3547 HTMLElement3_put_onmove,
3548 HTMLElement3_get_onmove,
3549 HTMLElement3_put_oncontrolselect,
3550 HTMLElement3_get_oncontrolselect,
3551 HTMLElement3_fireEvent,
3552 HTMLElement3_put_onresizestart,
3553 HTMLElement3_get_onresizestart,
3554 HTMLElement3_put_onresizeend,
3555 HTMLElement3_get_onresizeend,
3556 HTMLElement3_put_onmovestart,
3557 HTMLElement3_get_onmovestart,
3558 HTMLElement3_put_onmoveend,
3559 HTMLElement3_get_onmoveend,
3560 HTMLElement3_put_onmousecenter,
3561 HTMLElement3_get_onmousecenter,
3562 HTMLElement3_put_onmouseleave,
3563 HTMLElement3_get_onmouseleave,
3564 HTMLElement3_put_onactivate,
3565 HTMLElement3_get_onactivate,
3566 HTMLElement3_put_ondeactivate,
3567 HTMLElement3_get_ondeactivate,
3568 HTMLElement3_dragDrop,
3569 HTMLElement3_get_glyphMode
3572 static inline HTMLElement *impl_from_IHTMLElement4(IHTMLElement4 *iface)
3574 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement4_iface);
3577 static HRESULT WINAPI HTMLElement4_QueryInterface(IHTMLElement4 *iface,
3578 REFIID riid, void **ppv)
3580 HTMLElement *This = impl_from_IHTMLElement4(iface);
3581 return IHTMLElement_QueryInterface(&This->IHTMLElement_iface, riid, ppv);
3584 static ULONG WINAPI HTMLElement4_AddRef(IHTMLElement4 *iface)
3586 HTMLElement *This = impl_from_IHTMLElement4(iface);
3587 return IHTMLElement_AddRef(&This->IHTMLElement_iface);
3590 static ULONG WINAPI HTMLElement4_Release(IHTMLElement4 *iface)
3592 HTMLElement *This = impl_from_IHTMLElement4(iface);
3593 return IHTMLElement_Release(&This->IHTMLElement_iface);
3596 static HRESULT WINAPI HTMLElement4_GetTypeInfoCount(IHTMLElement4 *iface, UINT *pctinfo)
3598 HTMLElement *This = impl_from_IHTMLElement4(iface);
3599 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
3602 static HRESULT WINAPI HTMLElement4_GetTypeInfo(IHTMLElement4 *iface, UINT iTInfo,
3603 LCID lcid, ITypeInfo **ppTInfo)
3605 HTMLElement *This = impl_from_IHTMLElement4(iface);
3606 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3609 static HRESULT WINAPI HTMLElement4_GetIDsOfNames(IHTMLElement4 *iface, REFIID riid,
3610 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3612 HTMLElement *This = impl_from_IHTMLElement4(iface);
3613 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
3614 lcid, rgDispId);
3617 static HRESULT WINAPI HTMLElement4_Invoke(IHTMLElement4 *iface, DISPID dispIdMember, REFIID riid,
3618 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3620 HTMLElement *This = impl_from_IHTMLElement4(iface);
3621 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
3622 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3625 static HRESULT WINAPI HTMLElement4_put_onmousewheel(IHTMLElement4 *iface, VARIANT v)
3627 HTMLElement *This = impl_from_IHTMLElement4(iface);
3629 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3631 return set_node_event(&This->node, EVENTID_MOUSEWHEEL, &v);
3634 static HRESULT WINAPI HTMLElement4_get_onmousewheel(IHTMLElement4 *iface, VARIANT *p)
3636 HTMLElement *This = impl_from_IHTMLElement4(iface);
3638 TRACE("(%p)->(%p)\n", This, p);
3640 return get_node_event(&This->node, EVENTID_MOUSEWHEEL, p);
3643 static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface)
3645 HTMLElement *This = impl_from_IHTMLElement4(iface);
3646 FIXME("(%p)\n", This);
3647 return E_NOTIMPL;
3650 static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute)
3652 HTMLElement *This = impl_from_IHTMLElement4(iface);
3653 HTMLAttributeCollection *attrs;
3654 HRESULT hres;
3656 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute);
3658 hres = HTMLElement_get_attr_col(&This->node, &attrs);
3659 if(FAILED(hres))
3660 return hres;
3662 hres = IHTMLAttributeCollection2_getNamedItem(&attrs->IHTMLAttributeCollection2_iface, bstrname, ppAttribute);
3663 IHTMLAttributeCollection_Release(&attrs->IHTMLAttributeCollection_iface);
3664 return hres;
3667 static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3668 IHTMLDOMAttribute **ppretAttribute)
3670 HTMLElement *This = impl_from_IHTMLElement4(iface);
3671 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3672 return E_NOTIMPL;
3675 static HRESULT WINAPI HTMLElement4_removeAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr,
3676 IHTMLDOMAttribute **ppretAttribute)
3678 HTMLElement *This = impl_from_IHTMLElement4(iface);
3679 FIXME("(%p)->(%p %p)\n", This, pattr, ppretAttribute);
3680 return E_NOTIMPL;
3683 static HRESULT WINAPI HTMLElement4_put_onbeforeactivate(IHTMLElement4 *iface, VARIANT v)
3685 HTMLElement *This = impl_from_IHTMLElement4(iface);
3686 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3687 return E_NOTIMPL;
3690 static HRESULT WINAPI HTMLElement4_get_onbeforeactivate(IHTMLElement4 *iface, VARIANT *p)
3692 HTMLElement *This = impl_from_IHTMLElement4(iface);
3693 FIXME("(%p)->(%p)\n", This, p);
3694 return E_NOTIMPL;
3697 static HRESULT WINAPI HTMLElement4_put_onfocusin(IHTMLElement4 *iface, VARIANT v)
3699 HTMLElement *This = impl_from_IHTMLElement4(iface);
3701 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
3703 return set_node_event(&This->node, EVENTID_FOCUSIN, &v);
3706 static HRESULT WINAPI HTMLElement4_get_onfocusin(IHTMLElement4 *iface, VARIANT *p)
3708 HTMLElement *This = impl_from_IHTMLElement4(iface);
3710 TRACE("(%p)->(%p)\n", This, p);
3712 return get_node_event(&This->node, EVENTID_FOCUSIN, p);
3715 static HRESULT WINAPI HTMLElement4_put_onfocusout(IHTMLElement4 *iface, VARIANT v)
3717 HTMLElement *This = impl_from_IHTMLElement4(iface);
3718 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3719 return E_NOTIMPL;
3722 static HRESULT WINAPI HTMLElement4_get_onfocusout(IHTMLElement4 *iface, VARIANT *p)
3724 HTMLElement *This = impl_from_IHTMLElement4(iface);
3725 FIXME("(%p)->(%p)\n", This, p);
3726 return E_NOTIMPL;
3729 static const IHTMLElement4Vtbl HTMLElement4Vtbl = {
3730 HTMLElement4_QueryInterface,
3731 HTMLElement4_AddRef,
3732 HTMLElement4_Release,
3733 HTMLElement4_GetTypeInfoCount,
3734 HTMLElement4_GetTypeInfo,
3735 HTMLElement4_GetIDsOfNames,
3736 HTMLElement4_Invoke,
3737 HTMLElement4_put_onmousewheel,
3738 HTMLElement4_get_onmousewheel,
3739 HTMLElement4_normalize,
3740 HTMLElement4_getAttributeNode,
3741 HTMLElement4_setAttributeNode,
3742 HTMLElement4_removeAttributeNode,
3743 HTMLElement4_put_onbeforeactivate,
3744 HTMLElement4_get_onbeforeactivate,
3745 HTMLElement4_put_onfocusin,
3746 HTMLElement4_get_onfocusin,
3747 HTMLElement4_put_onfocusout,
3748 HTMLElement4_get_onfocusout
3751 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
3753 return CONTAINING_RECORD(iface, HTMLElement, node);
3756 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
3758 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3760 if(IsEqualGUID(&IID_IUnknown, riid)) {
3761 *ppv = &This->IHTMLElement_iface;
3762 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
3763 *ppv = &This->IHTMLElement_iface;
3764 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
3765 *ppv = &This->IHTMLElement_iface;
3766 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
3767 *ppv = &This->IHTMLElement2_iface;
3768 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
3769 *ppv = &This->IHTMLElement3_iface;
3770 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
3771 *ppv = &This->IHTMLElement4_iface;
3772 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
3773 *ppv = &This->cp_container.IConnectionPointContainer_iface;
3774 }else {
3775 return HTMLDOMNode_QI(&This->node, riid, ppv);
3778 IUnknown_AddRef((IUnknown*)*ppv);
3779 return S_OK;
3782 void HTMLElement_destructor(HTMLDOMNode *iface)
3784 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3786 ConnectionPointContainer_Destroy(&This->cp_container);
3788 if(This->style) {
3789 This->style->elem = NULL;
3790 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
3792 if(This->runtime_style) {
3793 This->runtime_style->elem = NULL;
3794 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
3796 if(This->attrs) {
3797 HTMLDOMAttribute *attr;
3799 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
3800 attr->elem = NULL;
3802 This->attrs->elem = NULL;
3803 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
3806 heap_free(This->filter);
3808 HTMLDOMNode_destructor(&This->node);
3811 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
3813 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3814 HTMLElement *new_elem;
3815 HRESULT hres;
3817 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
3818 if(FAILED(hres))
3819 return hres;
3821 if(This->filter) {
3822 new_elem->filter = heap_strdupW(This->filter);
3823 if(!new_elem->filter) {
3824 IHTMLElement_Release(&This->IHTMLElement_iface);
3825 return E_OUTOFMEMORY;
3829 *ret = &new_elem->node;
3830 return S_OK;
3833 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
3835 HTMLElement *This = impl_from_HTMLDOMNode(iface);
3837 switch(eid) {
3838 case EVENTID_KEYDOWN: {
3839 nsIDOMKeyEvent *key_event;
3840 nsresult nsres;
3842 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
3843 if(NS_SUCCEEDED(nsres)) {
3844 UINT32 code = 0;
3846 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
3848 switch(code) {
3849 case VK_F1: /* DOM_VK_F1 */
3850 TRACE("F1 pressed\n");
3851 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
3852 *prevent_default = TRUE;
3855 nsIDOMKeyEvent_Release(key_event);
3860 return S_OK;
3863 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
3865 const cpc_entry_t HTMLElement_cpc[] = {
3866 HTMLELEMENT_CPC,
3867 {NULL}
3870 static const NodeImplVtbl HTMLElementImplVtbl = {
3871 HTMLElement_QI,
3872 HTMLElement_destructor,
3873 HTMLElement_cpc,
3874 HTMLElement_clone,
3875 HTMLElement_handle_event,
3876 HTMLElement_get_attr_col
3879 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
3881 return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex);
3884 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
3885 DWORD grfdex, DISPID *pid)
3887 HTMLElement *This = impl_from_DispatchEx(dispex);
3889 if(This->node.vtbl->get_dispid)
3890 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
3892 return DISP_E_UNKNOWNNAME;
3895 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
3896 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
3897 IServiceProvider *caller)
3899 HTMLElement *This = impl_from_DispatchEx(dispex);
3901 if(This->node.vtbl->invoke)
3902 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
3903 params, res, ei, caller);
3905 ERR("(%p): element has no invoke method\n", This);
3906 return E_NOTIMPL;
3909 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
3911 HTMLElement *This = impl_from_DispatchEx(dispex);
3912 nsIDOMMozNamedAttrMap *attrs;
3913 nsIDOMAttr *attr;
3914 nsAString nsstr;
3915 const PRUnichar *str;
3916 BSTR name;
3917 VARIANT value;
3918 unsigned i;
3919 UINT32 len;
3920 DISPID id;
3921 nsresult nsres;
3922 HRESULT hres;
3924 if(!This->nselem)
3925 return S_FALSE;
3927 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
3928 if(NS_FAILED(nsres))
3929 return E_FAIL;
3931 nsres = nsIDOMMozNamedAttrMap_GetLength(attrs, &len);
3932 if(NS_FAILED(nsres)) {
3933 nsIDOMMozNamedAttrMap_Release(attrs);
3934 return E_FAIL;
3937 nsAString_Init(&nsstr, NULL);
3938 for(i=0; i<len; i++) {
3939 nsres = nsIDOMMozNamedAttrMap_Item(attrs, i, &attr);
3940 if(NS_FAILED(nsres))
3941 continue;
3943 nsres = nsIDOMAttr_GetNodeName(attr, &nsstr);
3944 if(NS_FAILED(nsres)) {
3945 nsIDOMAttr_Release(attr);
3946 continue;
3949 nsAString_GetData(&nsstr, &str);
3950 name = SysAllocString(str);
3951 if(!name) {
3952 nsIDOMAttr_Release(attr);
3953 continue;
3956 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
3957 if(hres != DISP_E_UNKNOWNNAME) {
3958 nsIDOMAttr_Release(attr);
3959 SysFreeString(name);
3960 continue;
3963 nsres = nsIDOMAttr_GetNodeValue(attr, &nsstr);
3964 nsIDOMAttr_Release(attr);
3965 if(NS_FAILED(nsres)) {
3966 SysFreeString(name);
3967 continue;
3970 nsAString_GetData(&nsstr, &str);
3971 V_VT(&value) = VT_BSTR;
3972 if(*str) {
3973 V_BSTR(&value) = SysAllocString(str);
3974 if(!V_BSTR(&value)) {
3975 SysFreeString(name);
3976 continue;
3978 } else
3979 V_BSTR(&value) = NULL;
3981 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
3982 SysFreeString(name);
3983 VariantClear(&value);
3985 nsAString_Finish(&nsstr);
3987 nsIDOMMozNamedAttrMap_Release(attrs);
3988 return S_OK;
3991 static event_target_t **HTMLElement_get_event_target_ptr(DispatchEx *dispex)
3993 HTMLElement *This = impl_from_DispatchEx(dispex);
3994 return This->node.vtbl->get_event_target_ptr
3995 ? This->node.vtbl->get_event_target_ptr(&This->node)
3996 : &This->node.event_target.ptr;
3999 static void HTMLElement_bind_event(DispatchEx *dispex, int eid)
4001 HTMLElement *This = impl_from_DispatchEx(dispex);
4002 This->node.doc->node.event_target.dispex.data->vtbl->bind_event(&This->node.doc->node.event_target.dispex, eid);
4005 static const tid_t HTMLElement_iface_tids[] = {
4006 HTMLELEMENT_TIDS,
4010 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
4011 NULL,
4012 HTMLElement_get_dispid,
4013 HTMLElement_invoke,
4014 HTMLElement_populate_props,
4015 HTMLElement_get_event_target_ptr,
4016 HTMLElement_bind_event
4019 static dispex_static_data_t HTMLElement_dispex = {
4020 &HTMLElement_dispex_vtbl,
4021 DispHTMLUnknownElement_tid,
4022 NULL,
4023 HTMLElement_iface_tids
4026 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
4028 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
4029 This->IHTMLElement2_iface.lpVtbl = &HTMLElement2Vtbl;
4030 This->IHTMLElement3_iface.lpVtbl = &HTMLElement3Vtbl;
4031 This->IHTMLElement4_iface.lpVtbl = &HTMLElement4Vtbl;
4033 if(dispex_data && !dispex_data->vtbl)
4034 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
4035 init_dispex(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
4036 dispex_data ? dispex_data : &HTMLElement_dispex);
4038 if(nselem) {
4039 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
4041 /* No AddRef, share reference with HTMLDOMNode */
4042 assert((nsIDOMNode*)nselem == This->node.nsnode);
4043 This->nselem = nselem;
4046 This->node.cp_container = &This->cp_container;
4047 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
4050 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
4052 nsIDOMHTMLElement *nselem;
4053 nsAString class_name_str;
4054 const PRUnichar *class_name;
4055 const tag_desc_t *tag;
4056 HTMLElement *elem;
4057 nsresult nsres;
4058 HRESULT hres;
4060 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
4061 if(NS_FAILED(nsres))
4062 return E_FAIL;
4064 nsAString_Init(&class_name_str, NULL);
4065 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
4067 nsAString_GetData(&class_name_str, &class_name);
4069 tag = get_tag_desc(class_name);
4070 if(tag) {
4071 hres = tag->constructor(doc, nselem, &elem);
4072 }else if(use_generic) {
4073 hres = HTMLGenericElement_Create(doc, nselem, &elem);
4074 }else {
4075 elem = heap_alloc_zero(sizeof(HTMLElement));
4076 if(elem) {
4077 elem->node.vtbl = &HTMLElementImplVtbl;
4078 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
4079 hres = S_OK;
4080 }else {
4081 hres = E_OUTOFMEMORY;
4085 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
4087 nsIDOMHTMLElement_Release(nselem);
4088 nsAString_Finish(&class_name_str);
4089 if(FAILED(hres))
4090 return hres;
4092 *ret = elem;
4093 return S_OK;
4096 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
4098 HTMLDOMNode *node;
4099 HRESULT hres;
4101 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
4102 if(FAILED(hres))
4103 return hres;
4105 *ret = impl_from_HTMLDOMNode(node);
4106 return S_OK;
4109 /* interface IHTMLFiltersCollection */
4110 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
4112 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4114 TRACE("%p %s %p\n", This, debugstr_mshtml_guid(riid), ppv );
4116 if(IsEqualGUID(&IID_IUnknown, riid)) {
4117 *ppv = &This->IHTMLFiltersCollection_iface;
4118 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
4119 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
4120 *ppv = &This->IHTMLFiltersCollection_iface;
4121 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4122 return *ppv ? S_OK : E_NOINTERFACE;
4123 }else {
4124 *ppv = NULL;
4125 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4126 return E_NOINTERFACE;
4129 IUnknown_AddRef((IUnknown*)*ppv);
4130 return S_OK;
4133 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
4135 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4136 LONG ref = InterlockedIncrement(&This->ref);
4138 TRACE("(%p) ref=%d\n", This, ref);
4140 return ref;
4143 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
4145 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4146 LONG ref = InterlockedDecrement(&This->ref);
4148 TRACE("(%p) ref=%d\n", This, ref);
4150 if(!ref)
4152 heap_free(This);
4155 return ref;
4158 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
4160 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4161 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4164 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
4165 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
4167 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4168 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4171 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
4172 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
4173 LCID lcid, DISPID *rgDispId)
4175 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4176 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4177 lcid, rgDispId);
4180 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
4181 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
4182 EXCEPINFO *pExcepInfo, UINT *puArgErr)
4184 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4185 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4186 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4189 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
4191 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4193 if(!p)
4194 return E_POINTER;
4196 FIXME("(%p)->(%p) Always returning 0\n", This, p);
4197 *p = 0;
4199 return S_OK;
4202 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
4204 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4205 FIXME("(%p)->(%p)\n", This, p);
4206 return E_NOTIMPL;
4209 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
4211 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
4212 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
4213 return E_NOTIMPL;
4216 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
4217 HTMLFiltersCollection_QueryInterface,
4218 HTMLFiltersCollection_AddRef,
4219 HTMLFiltersCollection_Release,
4220 HTMLFiltersCollection_GetTypeInfoCount,
4221 HTMLFiltersCollection_GetTypeInfo,
4222 HTMLFiltersCollection_GetIDsOfNames,
4223 HTMLFiltersCollection_Invoke,
4224 HTMLFiltersCollection_get_length,
4225 HTMLFiltersCollection_get__newEnum,
4226 HTMLFiltersCollection_item
4229 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4231 WCHAR *ptr;
4232 int idx = 0;
4234 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
4235 idx = idx*10 + (*ptr-'0');
4236 if(*ptr)
4237 return DISP_E_UNKNOWNNAME;
4239 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
4240 TRACE("ret %x\n", *dispid);
4241 return S_OK;
4244 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
4245 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4247 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
4249 V_VT(res) = VT_DISPATCH;
4250 V_DISPATCH(res) = NULL;
4252 FIXME("always returning NULL\n");
4254 return S_OK;
4257 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
4258 NULL,
4259 HTMLFiltersCollection_get_dispid,
4260 HTMLFiltersCollection_invoke,
4261 NULL
4264 static const tid_t HTMLFiltersCollection_iface_tids[] = {
4265 IHTMLFiltersCollection_tid,
4268 static dispex_static_data_t HTMLFiltersCollection_dispex = {
4269 &HTMLFiltersCollection_dispex_vtbl,
4270 IHTMLFiltersCollection_tid,
4271 NULL,
4272 HTMLFiltersCollection_iface_tids
4275 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
4277 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
4279 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
4280 ret->ref = 1;
4282 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
4283 &HTMLFiltersCollection_dispex);
4285 return &ret->IHTMLFiltersCollection_iface;
4288 /* interface IHTMLAttributeCollection */
4289 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
4291 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
4294 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
4296 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4298 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4300 if(IsEqualGUID(&IID_IUnknown, riid)) {
4301 *ppv = &This->IHTMLAttributeCollection_iface;
4302 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
4303 *ppv = &This->IHTMLAttributeCollection_iface;
4304 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
4305 *ppv = &This->IHTMLAttributeCollection2_iface;
4306 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
4307 *ppv = &This->IHTMLAttributeCollection3_iface;
4308 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
4309 return *ppv ? S_OK : E_NOINTERFACE;
4310 }else {
4311 *ppv = NULL;
4312 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
4313 return E_NOINTERFACE;
4316 IUnknown_AddRef((IUnknown*)*ppv);
4317 return S_OK;
4320 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
4322 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4323 LONG ref = InterlockedIncrement(&This->ref);
4325 TRACE("(%p) ref=%d\n", This, ref);
4327 return ref;
4330 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
4332 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4333 LONG ref = InterlockedDecrement(&This->ref);
4335 TRACE("(%p) ref=%d\n", This, ref);
4337 if(!ref) {
4338 while(!list_empty(&This->attrs)) {
4339 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
4341 list_remove(&attr->entry);
4342 attr->elem = NULL;
4343 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4346 heap_free(This);
4349 return ref;
4352 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
4354 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4355 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4358 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
4359 LCID lcid, ITypeInfo **ppTInfo)
4361 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4362 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4365 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
4366 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4368 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4369 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4370 lcid, rgDispId);
4373 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
4374 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4375 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4377 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4378 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4379 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4382 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
4384 IDispatchEx *dispex = &This->elem->node.event_target.dispex.IDispatchEx_iface;
4385 DISPID id = DISPID_STARTENUM;
4386 LONG len = -1;
4387 HRESULT hres;
4389 FIXME("filter non-enumerable attributes out\n");
4391 while(1) {
4392 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
4393 if(FAILED(hres))
4394 return hres;
4395 else if(hres == S_FALSE)
4396 break;
4398 len++;
4399 if(len == *idx)
4400 break;
4403 if(dispid) {
4404 *dispid = id;
4405 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
4408 *idx = len+1;
4409 return S_OK;
4412 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
4414 HRESULT hres;
4416 if(name[0]>='0' && name[0]<='9') {
4417 WCHAR *end_ptr;
4418 LONG idx;
4420 idx = strtoulW(name, &end_ptr, 10);
4421 if(!*end_ptr) {
4422 hres = get_attr_dispid_by_idx(This, &idx, id);
4423 if(SUCCEEDED(hres))
4424 return hres;
4428 if(!This->elem) {
4429 WARN("NULL elem\n");
4430 return E_UNEXPECTED;
4433 hres = IDispatchEx_GetDispID(&This->elem->node.event_target.dispex.IDispatchEx_iface,
4434 name, fdexNameCaseInsensitive, id);
4435 return hres;
4438 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
4440 HTMLDOMAttribute *iter;
4441 LONG pos = 0;
4442 HRESULT hres;
4444 *attr = NULL;
4445 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4446 if(iter->dispid == id) {
4447 *attr = iter;
4448 break;
4450 pos++;
4453 if(!*attr) {
4454 if(!This->elem) {
4455 WARN("NULL elem\n");
4456 return E_UNEXPECTED;
4459 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
4460 if(FAILED(hres))
4461 return hres;
4464 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
4465 if(list_pos)
4466 *list_pos = pos;
4467 return S_OK;
4470 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
4472 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4473 HRESULT hres;
4475 TRACE("(%p)->(%p)\n", This, p);
4477 *p = -1;
4478 hres = get_attr_dispid_by_idx(This, p, NULL);
4479 return hres;
4482 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
4484 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4485 FIXME("(%p)->(%p)\n", This, p);
4486 return E_NOTIMPL;
4489 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
4491 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
4492 HTMLDOMAttribute *attr;
4493 DISPID id;
4494 HRESULT hres;
4496 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
4498 switch(V_VT(name)) {
4499 case VT_I4:
4500 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
4501 break;
4502 case VT_BSTR:
4503 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
4504 break;
4505 default:
4506 FIXME("unsupported name %s\n", debugstr_variant(name));
4507 hres = E_NOTIMPL;
4509 if(hres == DISP_E_UNKNOWNNAME)
4510 return E_INVALIDARG;
4511 if(FAILED(hres))
4512 return hres;
4514 hres = get_domattr(This, id, NULL, &attr);
4515 if(FAILED(hres))
4516 return hres;
4518 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
4519 return S_OK;
4522 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
4523 HTMLAttributeCollection_QueryInterface,
4524 HTMLAttributeCollection_AddRef,
4525 HTMLAttributeCollection_Release,
4526 HTMLAttributeCollection_GetTypeInfoCount,
4527 HTMLAttributeCollection_GetTypeInfo,
4528 HTMLAttributeCollection_GetIDsOfNames,
4529 HTMLAttributeCollection_Invoke,
4530 HTMLAttributeCollection_get_length,
4531 HTMLAttributeCollection__newEnum,
4532 HTMLAttributeCollection_item
4535 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
4537 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
4540 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
4542 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4543 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4546 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
4548 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4549 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4552 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
4554 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4555 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4558 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
4560 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4561 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4564 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
4565 LCID lcid, ITypeInfo **ppTInfo)
4567 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4568 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4571 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
4572 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4574 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4575 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4576 lcid, rgDispId);
4579 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
4580 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4581 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4583 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4584 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4585 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4588 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
4589 IHTMLDOMAttribute **newretNode)
4591 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4592 HTMLDOMAttribute *attr;
4593 DISPID id;
4594 HRESULT hres;
4596 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4598 hres = get_attr_dispid_by_name(This, bstrName, &id);
4599 if(hres == DISP_E_UNKNOWNNAME) {
4600 *newretNode = NULL;
4601 return S_OK;
4602 } else if(FAILED(hres)) {
4603 return hres;
4606 hres = get_domattr(This, id, NULL, &attr);
4607 if(FAILED(hres))
4608 return hres;
4610 *newretNode = &attr->IHTMLDOMAttribute_iface;
4611 return S_OK;
4614 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
4615 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
4617 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4618 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
4619 return E_NOTIMPL;
4622 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
4623 BSTR bstrName, IHTMLDOMAttribute **newretNode)
4625 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
4626 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
4627 return E_NOTIMPL;
4630 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
4631 HTMLAttributeCollection2_QueryInterface,
4632 HTMLAttributeCollection2_AddRef,
4633 HTMLAttributeCollection2_Release,
4634 HTMLAttributeCollection2_GetTypeInfoCount,
4635 HTMLAttributeCollection2_GetTypeInfo,
4636 HTMLAttributeCollection2_GetIDsOfNames,
4637 HTMLAttributeCollection2_Invoke,
4638 HTMLAttributeCollection2_getNamedItem,
4639 HTMLAttributeCollection2_setNamedItem,
4640 HTMLAttributeCollection2_removeNamedItem
4643 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
4645 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
4648 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
4650 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4651 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
4654 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
4656 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4657 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
4660 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
4662 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4663 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
4666 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
4668 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4669 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
4672 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
4673 LCID lcid, ITypeInfo **ppTInfo)
4675 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4676 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
4679 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
4680 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4682 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4683 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
4684 lcid, rgDispId);
4687 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
4688 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
4689 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
4691 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4692 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
4693 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4696 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
4697 IHTMLDOMAttribute **ppNodeOut)
4699 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4700 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
4703 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
4704 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
4706 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4707 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
4708 return E_NOTIMPL;
4711 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
4712 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
4714 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4715 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
4716 return E_NOTIMPL;
4719 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
4721 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4722 HTMLDOMAttribute *attr;
4723 DISPID id;
4724 HRESULT hres;
4726 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
4728 hres = get_attr_dispid_by_idx(This, &index, &id);
4729 if(hres == DISP_E_UNKNOWNNAME)
4730 return E_INVALIDARG;
4731 if(FAILED(hres))
4732 return hres;
4734 hres = get_domattr(This, id, NULL, &attr);
4735 if(FAILED(hres))
4736 return hres;
4738 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
4739 return S_OK;
4742 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
4744 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
4745 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
4748 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
4749 HTMLAttributeCollection3_QueryInterface,
4750 HTMLAttributeCollection3_AddRef,
4751 HTMLAttributeCollection3_Release,
4752 HTMLAttributeCollection3_GetTypeInfoCount,
4753 HTMLAttributeCollection3_GetTypeInfo,
4754 HTMLAttributeCollection3_GetIDsOfNames,
4755 HTMLAttributeCollection3_Invoke,
4756 HTMLAttributeCollection3_getNamedItem,
4757 HTMLAttributeCollection3_setNamedItem,
4758 HTMLAttributeCollection3_removeNamedItem,
4759 HTMLAttributeCollection3_item,
4760 HTMLAttributeCollection3_get_length
4763 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
4765 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
4768 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
4770 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4771 HTMLDOMAttribute *attr;
4772 LONG pos;
4773 HRESULT hres;
4775 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
4777 hres = get_attr_dispid_by_name(This, name, dispid);
4778 if(FAILED(hres))
4779 return hres;
4781 hres = get_domattr(This, *dispid, &pos, &attr);
4782 if(FAILED(hres))
4783 return hres;
4784 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
4786 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
4787 return S_OK;
4790 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
4791 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
4793 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
4795 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
4797 switch(flags) {
4798 case DISPATCH_PROPERTYGET: {
4799 HTMLDOMAttribute *iter;
4800 DWORD pos;
4802 pos = id-MSHTML_DISPID_CUSTOM_MIN;
4804 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
4805 if(!pos) {
4806 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
4807 V_VT(res) = VT_DISPATCH;
4808 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
4809 return S_OK;
4811 pos--;
4814 WARN("invalid arg\n");
4815 return E_INVALIDARG;
4818 default:
4819 FIXME("unimplemented flags %x\n", flags);
4820 return E_NOTIMPL;
4824 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
4825 NULL,
4826 HTMLAttributeCollection_get_dispid,
4827 HTMLAttributeCollection_invoke,
4828 NULL
4831 static const tid_t HTMLAttributeCollection_iface_tids[] = {
4832 IHTMLAttributeCollection_tid,
4833 IHTMLAttributeCollection2_tid,
4834 IHTMLAttributeCollection3_tid,
4838 static dispex_static_data_t HTMLAttributeCollection_dispex = {
4839 &HTMLAttributeCollection_dispex_vtbl,
4840 DispHTMLAttributeCollection_tid,
4841 NULL,
4842 HTMLAttributeCollection_iface_tids
4845 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
4847 HTMLElement *This = impl_from_HTMLDOMNode(iface);
4849 if(This->attrs) {
4850 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
4851 *ac = This->attrs;
4852 return S_OK;
4855 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
4856 if(!This->attrs)
4857 return E_OUTOFMEMORY;
4859 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
4860 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
4861 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
4862 This->attrs->ref = 2;
4864 This->attrs->elem = This;
4865 list_init(&This->attrs->attrs);
4866 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
4867 &HTMLAttributeCollection_dispex);
4869 *ac = This->attrs;
4870 return S_OK;