2 * Copyright 2006 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
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "mshtml_private.h"
35 #include "htmlevent.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
41 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
43 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
44 REFIID riid, void **ppv)
46 HTMLElement *This = HTMLELEM_THIS(iface);
48 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
51 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
53 HTMLElement *This = HTMLELEM_THIS(iface);
55 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->node));
58 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
60 HTMLElement *This = HTMLELEM_THIS(iface);
62 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->node));
65 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
67 HTMLElement *This = HTMLELEM_THIS(iface);
68 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
71 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
72 LCID lcid, ITypeInfo **ppTInfo)
74 HTMLElement *This = HTMLELEM_THIS(iface);
75 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
78 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
79 LPOLESTR *rgszNames, UINT cNames,
80 LCID lcid, DISPID *rgDispId)
82 HTMLElement *This = HTMLELEM_THIS(iface);
83 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
86 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
87 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
88 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
90 HTMLElement *This = HTMLELEM_THIS(iface);
91 return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid,
92 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
95 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
96 VARIANT AttributeValue, LONG lFlags)
98 HTMLElement *This = HTMLELEM_THIS(iface);
100 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
101 DISPPARAMS dispParams;
104 TRACE("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
106 hres = IDispatchEx_GetDispID(DISPATCHEX(&This->node.dispex), strAttributeName,
107 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
111 dispParams.cArgs = 1;
112 dispParams.cNamedArgs = 1;
113 dispParams.rgdispidNamedArgs = &dispidNamed;
114 dispParams.rgvarg = &AttributeValue;
116 hres = IDispatchEx_InvokeEx(DISPATCHEX(&This->node.dispex), dispid,
117 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams,
122 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
123 LONG lFlags, VARIANT *AttributeValue)
125 HTMLElement *This = HTMLELEM_THIS(iface);
128 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
131 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
133 hres = IDispatchEx_GetDispID(DISPATCHEX(&This->node.dispex), strAttributeName,
134 fdexNameCaseInsensitive, &dispid);
135 if(hres == DISP_E_UNKNOWNNAME) {
136 V_VT(AttributeValue) = VT_NULL;
141 V_VT(AttributeValue) = VT_NULL;
145 hres = IDispatchEx_InvokeEx(DISPATCHEX(&This->node.dispex), dispid,
146 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dispParams,
147 AttributeValue, &excep, NULL);
152 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
153 LONG lFlags, VARIANT_BOOL *pfSuccess)
155 HTMLElement *This = HTMLELEM_THIS(iface);
156 FIXME("(%p)->()\n", This);
160 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
162 HTMLElement *This = HTMLELEM_THIS(iface);
163 nsAString classname_str;
166 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
169 FIXME("NULL nselem\n");
173 nsAString_Init(&classname_str, v);
174 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
175 nsAString_Finish(&classname_str);
177 ERR("SetClassName failed: %08x\n", nsres);
182 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
184 HTMLElement *This = HTMLELEM_THIS(iface);
189 TRACE("(%p)->(%p)\n", This, p);
192 FIXME("NULL nselem\n");
196 nsAString_Init(&class_str, NULL);
197 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
199 if(NS_SUCCEEDED(nsres)) {
200 const PRUnichar *class;
201 nsAString_GetData(&class_str, &class);
202 *p = *class ? SysAllocString(class) : NULL;
204 ERR("GetClassName failed: %08x\n", nsres);
208 nsAString_Finish(&class_str);
210 TRACE("className=%s\n", debugstr_w(*p));
214 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
216 HTMLElement *This = HTMLELEM_THIS(iface);
220 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
223 FIXME("nselem == NULL\n");
227 nsAString_Init(&id_str, v);
228 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
229 nsAString_Finish(&id_str);
231 ERR("SetId failed: %08x\n", nsres);
236 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
238 HTMLElement *This = HTMLELEM_THIS(iface);
243 TRACE("(%p)->(%p)\n", This, p);
250 nsAString_Init(&id_str, NULL);
251 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
252 nsAString_GetData(&id_str, &id);
255 ERR("GetId failed: %08x\n", nsres);
257 *p = SysAllocString(id);
259 nsAString_Finish(&id_str);
263 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
265 HTMLElement *This = HTMLELEM_THIS(iface);
266 const PRUnichar *tag;
270 TRACE("(%p)->(%p)\n", This, p);
273 static const WCHAR comment_tagW[] = {'!',0};
275 WARN("NULL nselem, assuming comment\n");
277 *p = SysAllocString(comment_tagW);
281 nsAString_Init(&tag_str, NULL);
282 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
283 if(NS_SUCCEEDED(nsres)) {
284 nsAString_GetData(&tag_str, &tag);
285 *p = SysAllocString(tag);
287 ERR("GetTagName failed: %08x\n", nsres);
290 nsAString_Finish(&tag_str);
295 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
297 HTMLElement *This = HTMLELEM_THIS(iface);
301 TRACE("(%p)->(%p)\n", This, p);
303 hres = IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This->node), &node);
307 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
308 IHTMLDOMNode_Release(node);
315 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
317 HTMLElement *This = HTMLELEM_THIS(iface);
318 nsIDOMElementCSSInlineStyle *nselemstyle;
319 nsIDOMCSSStyleDeclaration *nsstyle;
322 TRACE("(%p)->(%p)\n", This, p);
325 FIXME("NULL nselem\n");
329 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
330 (void**)&nselemstyle);
331 if(NS_FAILED(nsres)) {
332 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
336 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
337 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
338 if(NS_FAILED(nsres)) {
339 ERR("GetStyle failed: %08x\n", nsres);
343 /* FIXME: Store style instead of creating a new instance in each call */
344 *p = HTMLStyle_Create(nsstyle);
346 nsIDOMCSSStyleDeclaration_Release(nsstyle);
350 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
352 HTMLElement *This = HTMLELEM_THIS(iface);
353 FIXME("(%p)->()\n", This);
357 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
359 HTMLElement *This = HTMLELEM_THIS(iface);
360 FIXME("(%p)->(%p)\n", This, p);
364 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
366 HTMLElement *This = HTMLELEM_THIS(iface);
368 TRACE("(%p)->()\n", This);
370 return set_node_event(&This->node, EVENTID_CLICK, &v);
373 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
375 HTMLElement *This = HTMLELEM_THIS(iface);
377 TRACE("(%p)->(%p)\n", This, p);
379 return get_node_event(&This->node, EVENTID_CLICK, p);
382 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
384 HTMLElement *This = HTMLELEM_THIS(iface);
386 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
388 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
391 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
393 HTMLElement *This = HTMLELEM_THIS(iface);
395 TRACE("(%p)->(%p)\n", This, p);
397 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
400 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
402 HTMLElement *This = HTMLELEM_THIS(iface);
404 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
406 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
409 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
411 HTMLElement *This = HTMLELEM_THIS(iface);
413 TRACE("(%p)->(%p)\n", This, p);
415 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
418 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
420 HTMLElement *This = HTMLELEM_THIS(iface);
422 TRACE("(%p)->()\n", This);
424 return set_node_event(&This->node, EVENTID_KEYUP, &v);
427 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
429 HTMLElement *This = HTMLELEM_THIS(iface);
430 FIXME("(%p)->(%p)\n", This, p);
434 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
436 HTMLElement *This = HTMLELEM_THIS(iface);
437 FIXME("(%p)->()\n", This);
441 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
443 HTMLElement *This = HTMLELEM_THIS(iface);
444 FIXME("(%p)->(%p)\n", This, p);
448 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
450 HTMLElement *This = HTMLELEM_THIS(iface);
452 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
454 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
457 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
459 HTMLElement *This = HTMLELEM_THIS(iface);
461 TRACE("(%p)->(%p)\n", This, p);
463 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
466 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
468 HTMLElement *This = HTMLELEM_THIS(iface);
470 TRACE("(%p)->()\n", This);
472 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
475 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
477 HTMLElement *This = HTMLELEM_THIS(iface);
479 TRACE("(%p)->(%p)\n", This, p);
481 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
484 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
486 HTMLElement *This = HTMLELEM_THIS(iface);
487 FIXME("(%p)->()\n", This);
491 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
493 HTMLElement *This = HTMLELEM_THIS(iface);
494 FIXME("(%p)->(%p)\n", This, p);
498 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
500 HTMLElement *This = HTMLELEM_THIS(iface);
502 TRACE("(%p)->()\n", This);
504 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
507 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
509 HTMLElement *This = HTMLELEM_THIS(iface);
511 TRACE("(%p)->(%p)\n", This, p);
513 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
516 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
518 HTMLElement *This = HTMLELEM_THIS(iface);
520 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
522 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
525 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
527 HTMLElement *This = HTMLELEM_THIS(iface);
529 TRACE("(%p)->(%p)\n", This, p);
531 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
534 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
536 HTMLElement *This = HTMLELEM_THIS(iface);
538 TRACE("(%p)->(%p)\n", This, p);
543 *p = (IDispatch*)HTMLDOC(&This->node.doc->basedoc);
544 IDispatch_AddRef(*p);
549 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
551 HTMLElement *This = HTMLELEM_THIS(iface);
555 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
557 nsAString_Init(&title_str, v);
558 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
559 nsAString_Finish(&title_str);
561 ERR("SetTitle failed: %08x\n", nsres);
566 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
568 HTMLElement *This = HTMLELEM_THIS(iface);
572 TRACE("(%p)->(%p)\n", This, p);
574 nsAString_Init(&title_str, NULL);
575 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
576 if(NS_SUCCEEDED(nsres)) {
577 const PRUnichar *title;
579 nsAString_GetData(&title_str, &title);
580 *p = *title ? SysAllocString(title) : NULL;
582 ERR("GetTitle failed: %08x\n", nsres);
589 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
591 HTMLElement *This = HTMLELEM_THIS(iface);
592 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
596 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
598 HTMLElement *This = HTMLELEM_THIS(iface);
599 FIXME("(%p)->(%p)\n", This, p);
603 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
605 HTMLElement *This = HTMLELEM_THIS(iface);
607 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
609 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
612 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
614 HTMLElement *This = HTMLELEM_THIS(iface);
616 TRACE("(%p)->(%p)\n", This, p);
618 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
621 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
623 HTMLElement *This = HTMLELEM_THIS(iface);
624 FIXME("(%p)->()\n", This);
628 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
629 VARIANT_BOOL *pfResult)
631 HTMLElement *This = HTMLELEM_THIS(iface);
632 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
636 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
638 HTMLElement *This = HTMLELEM_THIS(iface);
639 FIXME("(%p)->(%p)\n", This, p);
643 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
645 HTMLElement *This = HTMLELEM_THIS(iface);
646 FIXME("(%p)->(%p)\n", This, p);
650 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
652 HTMLElement *This = HTMLELEM_THIS(iface);
653 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
657 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
659 HTMLElement *This = HTMLELEM_THIS(iface);
660 FIXME("(%p)->(%p)\n", This, p);
664 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
666 HTMLElement *This = HTMLELEM_THIS(iface);
667 FIXME("(%p)->(%p)\n", This, p);
671 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
673 HTMLElement *This = HTMLELEM_THIS(iface);
674 nsIDOMNSHTMLElement *nselem;
678 TRACE("(%p)->(%p)\n", This, p);
680 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
681 if(NS_FAILED(nsres)) {
682 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
686 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
687 nsIDOMNSHTMLElement_Release(nselem);
688 if(NS_FAILED(nsres)) {
689 ERR("GetOffsetTop failed: %08x\n", nsres);
697 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
699 HTMLElement *This = HTMLELEM_THIS(iface);
700 nsIDOMNSHTMLElement *nselem;
704 TRACE("(%p)->(%p)\n", This, p);
706 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
707 if(NS_FAILED(nsres)) {
708 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
712 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
713 nsIDOMNSHTMLElement_Release(nselem);
714 if(NS_FAILED(nsres)) {
715 ERR("GetOffsetWidth failed: %08x\n", nsres);
723 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
725 HTMLElement *This = HTMLELEM_THIS(iface);
726 nsIDOMNSHTMLElement *nselem;
730 TRACE("(%p)->(%p)\n", This, p);
732 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
733 if(NS_FAILED(nsres)) {
734 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
738 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
739 nsIDOMNSHTMLElement_Release(nselem);
740 if(NS_FAILED(nsres)) {
741 ERR("GetOffsetHeight failed: %08x\n", nsres);
749 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
751 HTMLElement *This = HTMLELEM_THIS(iface);
752 FIXME("(%p)->(%p)\n", This, p);
756 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
758 HTMLElement *This = HTMLELEM_THIS(iface);
759 nsIDOMNSHTMLElement *nselem;
763 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
766 FIXME("NULL nselem\n");
770 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
771 if(NS_FAILED(nsres)) {
772 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
776 nsAString_Init(&html_str, v);
777 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
778 nsAString_Finish(&html_str);
780 if(NS_FAILED(nsres)) {
781 FIXME("SetInnerHtml failed %08x\n", nsres);
788 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
790 HTMLElement *This = HTMLELEM_THIS(iface);
791 nsIDOMNSHTMLElement *nselem;
795 TRACE("(%p)->(%p)\n", This, p);
798 FIXME("NULL nselem\n");
802 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
803 if(NS_FAILED(nsres)) {
804 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
808 nsAString_Init(&html_str, NULL);
809 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
810 if(NS_SUCCEEDED(nsres)) {
811 const PRUnichar *html;
813 nsAString_GetData(&html_str, &html);
814 *p = *html ? SysAllocString(html) : NULL;
816 FIXME("SetInnerHtml failed %08x\n", nsres);
820 nsAString_Finish(&html_str);
824 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
826 HTMLElement *This = HTMLELEM_THIS(iface);
827 nsIDOMNode *nschild, *tmp;
828 nsIDOMText *text_node;
832 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
835 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
836 if(NS_FAILED(nsres)) {
837 ERR("GetLastChild failed: %08x\n", nsres);
843 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
844 nsIDOMNode_Release(nschild);
845 if(NS_FAILED(nsres)) {
846 ERR("RemoveChild failed: %08x\n", nsres);
849 nsIDOMNode_Release(tmp);
852 nsAString_Init(&text_str, v);
853 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->basedoc.nsdoc, &text_str, &text_node);
854 nsAString_Finish(&text_str);
855 if(NS_FAILED(nsres)) {
856 ERR("CreateTextNode failed: %08x\n", nsres);
860 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
861 if(NS_FAILED(nsres)) {
862 ERR("AppendChild failed: %08x\n", nsres);
866 nsIDOMNode_Release(tmp);
870 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
872 HTMLElement *This = HTMLELEM_THIS(iface);
874 TRACE("(%p)->(%p)\n", This, p);
876 return get_node_text(&This->node, p);
879 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
881 HTMLElement *This = HTMLELEM_THIS(iface);
882 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
886 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
888 HTMLElement *This = HTMLELEM_THIS(iface);
892 WARN("(%p)->(%p) semi-stub\n", This, p);
894 nsAString_Init(&html_str, NULL);
895 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
896 if(SUCCEEDED(hres)) {
897 const PRUnichar *html;
899 nsAString_GetData(&html_str, &html);
900 *p = SysAllocString(html);
902 hres = E_OUTOFMEMORY;
905 nsAString_Finish(&html_str);
907 TRACE("ret %s\n", debugstr_w(*p));
911 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
913 HTMLElement *This = HTMLELEM_THIS(iface);
914 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
918 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
920 HTMLElement *This = HTMLELEM_THIS(iface);
921 FIXME("(%p)->(%p)\n", This, p);
925 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
927 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
928 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
929 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
930 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
934 FIXME("NULL nselem\n");
938 if (!strcmpiW(where, wszBeforeBegin))
942 nsres = nsIDOMNode_GetParentNode(This->nselem, &parent);
943 if (!parent) return E_INVALIDARG;
944 nsres = nsIDOMNode_InsertBefore(parent, nsnode,
945 (nsIDOMNode *)This->nselem, &unused);
946 if (unused) nsIDOMNode_Release(unused);
947 nsIDOMNode_Release(parent);
949 else if (!strcmpiW(where, wszAfterBegin))
952 nsIDOMNode *first_child;
953 nsIDOMNode_GetFirstChild(This->nselem, &first_child);
954 nsres = nsIDOMNode_InsertBefore(This->nselem, nsnode, first_child, &unused);
955 if (unused) nsIDOMNode_Release(unused);
956 if (first_child) nsIDOMNode_Release(first_child);
958 else if (!strcmpiW(where, wszBeforeEnd))
961 nsres = nsIDOMNode_AppendChild(This->nselem, nsnode, &unused);
962 if (unused) nsIDOMNode_Release(unused);
964 else if (!strcmpiW(where, wszAfterEnd))
967 nsIDOMNode *next_sibling;
969 nsIDOMNode_GetParentNode(This->nselem, &parent);
970 if (!parent) return E_INVALIDARG;
972 nsIDOMNode_GetNextSibling(This->nselem, &next_sibling);
975 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
976 nsIDOMNode_Release(next_sibling);
979 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
980 nsIDOMNode_Release(parent);
981 if (unused) nsIDOMNode_Release(unused);
985 ERR("invalid where: %s\n", debugstr_w(where));
989 if (NS_FAILED(nsres))
995 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
998 HTMLElement *This = HTMLELEM_THIS(iface);
999 nsIDOMDocumentRange *nsdocrange;
1001 nsIDOMNSRange *nsrange;
1007 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1009 if(!This->node.doc->basedoc.nsdoc) {
1010 WARN("NULL nsdoc\n");
1011 return E_UNEXPECTED;
1014 nsres = nsIDOMDocument_QueryInterface(This->node.doc->basedoc.nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1015 if(NS_FAILED(nsres))
1017 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1020 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1021 nsIDOMDocumentRange_Release(nsdocrange);
1022 if(NS_FAILED(nsres))
1024 ERR("CreateRange failed: %08x\n", nsres);
1028 nsIDOMRange_SetStartBefore(range, (nsIDOMNode *)This->nselem);
1030 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1031 nsIDOMRange_Release(range);
1032 if(NS_FAILED(nsres))
1034 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1038 nsAString_Init(&ns_html, html);
1040 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1041 nsIDOMNSRange_Release(nsrange);
1042 nsAString_Finish(&ns_html);
1044 if(NS_FAILED(nsres) || !nsnode)
1046 ERR("CreateTextNode failed: %08x\n", nsres);
1050 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1051 nsIDOMNode_Release(nsnode);
1056 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1059 HTMLElement *This = HTMLELEM_THIS(iface);
1065 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1067 if(!This->node.doc->basedoc.nsdoc) {
1068 WARN("NULL nsdoc\n");
1069 return E_UNEXPECTED;
1073 nsAString_Init(&ns_text, text);
1074 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->basedoc.nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1075 nsAString_Finish(&ns_text);
1077 if(NS_FAILED(nsres) || !nsnode)
1079 ERR("CreateTextNode failed: %08x\n", nsres);
1083 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1084 nsIDOMNode_Release(nsnode);
1089 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1091 HTMLElement *This = HTMLELEM_THIS(iface);
1092 FIXME("(%p)->(%p)\n", This, p);
1096 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1098 HTMLElement *This = HTMLELEM_THIS(iface);
1099 FIXME("(%p)->(%p)\n", This, p);
1103 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1105 HTMLElement *This = HTMLELEM_THIS(iface);
1106 FIXME("(%p)\n", This);
1110 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1111 IHTMLFiltersCollection **p)
1113 HTMLElement *This = HTMLELEM_THIS(iface);
1114 FIXME("(%p)->(%p)\n", This, p);
1118 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1120 HTMLElement *This = HTMLELEM_THIS(iface);
1121 FIXME("(%p)->()\n", This);
1125 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1127 HTMLElement *This = HTMLELEM_THIS(iface);
1128 FIXME("(%p)->(%p)\n", This, p);
1132 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1134 HTMLElement *This = HTMLELEM_THIS(iface);
1135 FIXME("(%p)->(%p)\n", This, String);
1139 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1141 HTMLElement *This = HTMLELEM_THIS(iface);
1142 FIXME("(%p)->()\n", This);
1146 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1148 HTMLElement *This = HTMLELEM_THIS(iface);
1149 FIXME("(%p)->(%p)\n", This, p);
1153 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1155 HTMLElement *This = HTMLELEM_THIS(iface);
1156 FIXME("(%p)->()\n", This);
1160 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1162 HTMLElement *This = HTMLELEM_THIS(iface);
1163 FIXME("(%p)->(%p)\n", This, p);
1167 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1169 HTMLElement *This = HTMLELEM_THIS(iface);
1170 FIXME("(%p)->()\n", This);
1174 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1176 HTMLElement *This = HTMLELEM_THIS(iface);
1177 FIXME("(%p)->(%p)\n", This, p);
1181 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1183 HTMLElement *This = HTMLELEM_THIS(iface);
1184 FIXME("(%p)->()\n", This);
1188 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1190 HTMLElement *This = HTMLELEM_THIS(iface);
1191 FIXME("(%p)->(%p)\n", This, p);
1195 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1197 HTMLElement *This = HTMLELEM_THIS(iface);
1198 FIXME("(%p)->()\n", This);
1202 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1204 HTMLElement *This = HTMLELEM_THIS(iface);
1205 FIXME("(%p)->(%p)\n", This, p);
1209 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1211 HTMLElement *This = HTMLELEM_THIS(iface);
1212 FIXME("(%p)->()\n", This);
1216 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1218 HTMLElement *This = HTMLELEM_THIS(iface);
1219 FIXME("(%p)->(%p)\n", This, p);
1223 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1225 HTMLElement *This = HTMLELEM_THIS(iface);
1226 FIXME("(%p)->()\n", This);
1230 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1232 HTMLElement *This = HTMLELEM_THIS(iface);
1233 FIXME("(%p)->(%p)\n", This, p);
1237 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1239 HTMLElement *This = HTMLELEM_THIS(iface);
1240 FIXME("(%p)->()\n", This);
1244 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1246 HTMLElement *This = HTMLELEM_THIS(iface);
1247 FIXME("(%p)->(%p)\n", This, p);
1251 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1253 HTMLElement *This = HTMLELEM_THIS(iface);
1254 FIXME("(%p)->()\n", This);
1258 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1260 HTMLElement *This = HTMLELEM_THIS(iface);
1261 FIXME("(%p)->(%p)\n", This, p);
1265 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1267 HTMLElement *This = HTMLELEM_THIS(iface);
1268 nsIDOMNodeList *nsnode_list;
1271 TRACE("(%p)->(%p)\n", This, p);
1273 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1274 if(NS_FAILED(nsres)) {
1275 ERR("GetChildNodes failed: %08x\n", nsres);
1279 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
1281 nsIDOMNodeList_Release(nsnode_list);
1285 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1287 HTMLElement *This = HTMLELEM_THIS(iface);
1289 TRACE("(%p)->(%p)\n", This, p);
1291 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1295 #undef HTMLELEM_THIS
1297 static const IHTMLElementVtbl HTMLElementVtbl = {
1298 HTMLElement_QueryInterface,
1300 HTMLElement_Release,
1301 HTMLElement_GetTypeInfoCount,
1302 HTMLElement_GetTypeInfo,
1303 HTMLElement_GetIDsOfNames,
1305 HTMLElement_setAttribute,
1306 HTMLElement_getAttribute,
1307 HTMLElement_removeAttribute,
1308 HTMLElement_put_className,
1309 HTMLElement_get_className,
1312 HTMLElement_get_tagName,
1313 HTMLElement_get_parentElement,
1314 HTMLElement_get_style,
1315 HTMLElement_put_onhelp,
1316 HTMLElement_get_onhelp,
1317 HTMLElement_put_onclick,
1318 HTMLElement_get_onclick,
1319 HTMLElement_put_ondblclick,
1320 HTMLElement_get_ondblclick,
1321 HTMLElement_put_onkeydown,
1322 HTMLElement_get_onkeydown,
1323 HTMLElement_put_onkeyup,
1324 HTMLElement_get_onkeyup,
1325 HTMLElement_put_onkeypress,
1326 HTMLElement_get_onkeypress,
1327 HTMLElement_put_onmouseout,
1328 HTMLElement_get_onmouseout,
1329 HTMLElement_put_onmouseover,
1330 HTMLElement_get_onmouseover,
1331 HTMLElement_put_onmousemove,
1332 HTMLElement_get_onmousemove,
1333 HTMLElement_put_onmousedown,
1334 HTMLElement_get_onmousedown,
1335 HTMLElement_put_onmouseup,
1336 HTMLElement_get_onmouseup,
1337 HTMLElement_get_document,
1338 HTMLElement_put_title,
1339 HTMLElement_get_title,
1340 HTMLElement_put_language,
1341 HTMLElement_get_language,
1342 HTMLElement_put_onselectstart,
1343 HTMLElement_get_onselectstart,
1344 HTMLElement_scrollIntoView,
1345 HTMLElement_contains,
1346 HTMLElement_get_sourceIndex,
1347 HTMLElement_get_recordNumber,
1348 HTMLElement_put_lang,
1349 HTMLElement_get_lang,
1350 HTMLElement_get_offsetLeft,
1351 HTMLElement_get_offsetTop,
1352 HTMLElement_get_offsetWidth,
1353 HTMLElement_get_offsetHeight,
1354 HTMLElement_get_offsetParent,
1355 HTMLElement_put_innerHTML,
1356 HTMLElement_get_innerHTML,
1357 HTMLElement_put_innerText,
1358 HTMLElement_get_innerText,
1359 HTMLElement_put_outerHTML,
1360 HTMLElement_get_outerHTML,
1361 HTMLElement_put_outerText,
1362 HTMLElement_get_outerText,
1363 HTMLElement_insertAdjacentHTML,
1364 HTMLElement_insertAdjacentText,
1365 HTMLElement_get_parentTextEdit,
1366 HTMLElement_get_isTextEdit,
1368 HTMLElement_get_filters,
1369 HTMLElement_put_ondragstart,
1370 HTMLElement_get_ondragstart,
1371 HTMLElement_toString,
1372 HTMLElement_put_onbeforeupdate,
1373 HTMLElement_get_onbeforeupdate,
1374 HTMLElement_put_onafterupdate,
1375 HTMLElement_get_onafterupdate,
1376 HTMLElement_put_onerrorupdate,
1377 HTMLElement_get_onerrorupdate,
1378 HTMLElement_put_onrowexit,
1379 HTMLElement_get_onrowexit,
1380 HTMLElement_put_onrowenter,
1381 HTMLElement_get_onrowenter,
1382 HTMLElement_put_ondatasetchanged,
1383 HTMLElement_get_ondatasetchanged,
1384 HTMLElement_put_ondataavailable,
1385 HTMLElement_get_ondataavailable,
1386 HTMLElement_put_ondatasetcomplete,
1387 HTMLElement_get_ondatasetcomplete,
1388 HTMLElement_put_onfilterchange,
1389 HTMLElement_get_onfilterchange,
1390 HTMLElement_get_children,
1394 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1396 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1400 if(IsEqualGUID(&IID_IUnknown, riid)) {
1401 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1402 *ppv = HTMLELEM(This);
1403 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1404 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1405 *ppv = HTMLELEM(This);
1406 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1407 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1408 *ppv = HTMLELEM(This);
1409 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1410 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1411 *ppv = HTMLELEM2(This);
1412 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1413 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1414 *ppv = HTMLELEM3(This);
1415 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1416 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1417 *ppv = CONPTCONT(&This->cp_container);
1421 IHTMLElement_AddRef(HTMLELEM(This));
1425 return HTMLDOMNode_QI(&This->node, riid, ppv);
1428 void HTMLElement_destructor(HTMLDOMNode *iface)
1430 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1432 ConnectionPointContainer_Destroy(&This->cp_container);
1435 nsIDOMHTMLElement_Release(This->nselem);
1437 HTMLDOMNode_destructor(&This->node);
1440 static const NodeImplVtbl HTMLElementImplVtbl = {
1442 HTMLElement_destructor
1445 static const tid_t HTMLElement_iface_tids[] = {
1454 static dispex_static_data_t HTMLElement_dispex = {
1456 DispHTMLUnknownElement_tid,
1458 HTMLElement_iface_tids
1461 void HTMLElement_Init(HTMLElement *This, dispex_static_data_t *dispex_data)
1463 This->lpHTMLElementVtbl = &HTMLElementVtbl;
1465 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
1467 HTMLElement2_Init(This);
1468 HTMLElement3_Init(This);
1470 init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), dispex_data ? dispex_data : &HTMLElement_dispex);
1473 HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic)
1475 nsIDOMHTMLElement *nselem;
1476 HTMLElement *ret = NULL;
1477 nsAString class_name_str;
1478 const PRUnichar *class_name;
1481 static const WCHAR wszA[] = {'A',0};
1482 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1483 static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0};
1484 static const WCHAR wszIMG[] = {'I','M','G',0};
1485 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1486 static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0};
1487 static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0};
1488 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1489 static const WCHAR wszTABLE[] = {'T','A','B','L','E',0};
1490 static const WCHAR wszTR[] = {'T','R',0};
1491 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1493 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1494 if(NS_FAILED(nsres))
1497 nsAString_Init(&class_name_str, NULL);
1498 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1500 nsAString_GetData(&class_name_str, &class_name);
1502 if(!strcmpW(class_name, wszA))
1503 ret = HTMLAnchorElement_Create(nselem);
1504 else if(!strcmpW(class_name, wszBODY))
1505 ret = HTMLBodyElement_Create(nselem);
1506 else if(!strcmpW(class_name, wszIFRAME))
1507 ret = HTMLIFrame_Create(nselem);
1508 else if(!strcmpW(class_name, wszIMG))
1509 ret = HTMLImgElement_Create(nselem);
1510 else if(!strcmpW(class_name, wszINPUT))
1511 ret = HTMLInputElement_Create(nselem);
1512 else if(!strcmpW(class_name, wszOPTION))
1513 ret = HTMLOptionElement_Create(nselem);
1514 else if(!strcmpW(class_name, wszSCRIPT))
1515 ret = HTMLScriptElement_Create(nselem);
1516 else if(!strcmpW(class_name, wszSELECT))
1517 ret = HTMLSelectElement_Create(nselem);
1518 else if(!strcmpW(class_name, wszTABLE))
1519 ret = HTMLTable_Create(nselem);
1520 else if(!strcmpW(class_name, wszTR))
1521 ret = HTMLTableRow_Create(nselem);
1522 else if(!strcmpW(class_name, wszTEXTAREA))
1523 ret = HTMLTextAreaElement_Create(nselem);
1524 else if(use_generic)
1525 ret = HTMLGenericElement_Create(nselem);
1528 ret = heap_alloc_zero(sizeof(HTMLElement));
1529 HTMLElement_Init(ret, NULL);
1530 ret->node.vtbl = &HTMLElementImplVtbl;
1533 TRACE("%s ret %p\n", debugstr_w(class_name), ret);
1535 nsAString_Finish(&class_name_str);
1537 ret->nselem = nselem;
1538 HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);