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);
1107 TRACE("(%p)\n", This);
1109 return call_event(&This->node, EVENTID_CLICK);
1112 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1113 IHTMLFiltersCollection **p)
1115 HTMLElement *This = HTMLELEM_THIS(iface);
1116 FIXME("(%p)->(%p)\n", This, p);
1120 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1122 HTMLElement *This = HTMLELEM_THIS(iface);
1123 FIXME("(%p)->()\n", This);
1127 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1129 HTMLElement *This = HTMLELEM_THIS(iface);
1130 FIXME("(%p)->(%p)\n", This, p);
1134 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1136 HTMLElement *This = HTMLELEM_THIS(iface);
1137 FIXME("(%p)->(%p)\n", This, String);
1141 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1143 HTMLElement *This = HTMLELEM_THIS(iface);
1144 FIXME("(%p)->()\n", This);
1148 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1150 HTMLElement *This = HTMLELEM_THIS(iface);
1151 FIXME("(%p)->(%p)\n", This, p);
1155 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1157 HTMLElement *This = HTMLELEM_THIS(iface);
1158 FIXME("(%p)->()\n", This);
1162 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1164 HTMLElement *This = HTMLELEM_THIS(iface);
1165 FIXME("(%p)->(%p)\n", This, p);
1169 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1171 HTMLElement *This = HTMLELEM_THIS(iface);
1172 FIXME("(%p)->()\n", This);
1176 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1178 HTMLElement *This = HTMLELEM_THIS(iface);
1179 FIXME("(%p)->(%p)\n", This, p);
1183 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1185 HTMLElement *This = HTMLELEM_THIS(iface);
1186 FIXME("(%p)->()\n", This);
1190 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1192 HTMLElement *This = HTMLELEM_THIS(iface);
1193 FIXME("(%p)->(%p)\n", This, p);
1197 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1199 HTMLElement *This = HTMLELEM_THIS(iface);
1200 FIXME("(%p)->()\n", This);
1204 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1206 HTMLElement *This = HTMLELEM_THIS(iface);
1207 FIXME("(%p)->(%p)\n", This, p);
1211 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1213 HTMLElement *This = HTMLELEM_THIS(iface);
1214 FIXME("(%p)->()\n", This);
1218 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1220 HTMLElement *This = HTMLELEM_THIS(iface);
1221 FIXME("(%p)->(%p)\n", This, p);
1225 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1227 HTMLElement *This = HTMLELEM_THIS(iface);
1228 FIXME("(%p)->()\n", This);
1232 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1234 HTMLElement *This = HTMLELEM_THIS(iface);
1235 FIXME("(%p)->(%p)\n", This, p);
1239 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1241 HTMLElement *This = HTMLELEM_THIS(iface);
1242 FIXME("(%p)->()\n", This);
1246 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1248 HTMLElement *This = HTMLELEM_THIS(iface);
1249 FIXME("(%p)->(%p)\n", This, p);
1253 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1255 HTMLElement *This = HTMLELEM_THIS(iface);
1256 FIXME("(%p)->()\n", This);
1260 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1262 HTMLElement *This = HTMLELEM_THIS(iface);
1263 FIXME("(%p)->(%p)\n", This, p);
1267 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1269 HTMLElement *This = HTMLELEM_THIS(iface);
1270 nsIDOMNodeList *nsnode_list;
1273 TRACE("(%p)->(%p)\n", This, p);
1275 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1276 if(NS_FAILED(nsres)) {
1277 ERR("GetChildNodes failed: %08x\n", nsres);
1281 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
1283 nsIDOMNodeList_Release(nsnode_list);
1287 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1289 HTMLElement *This = HTMLELEM_THIS(iface);
1291 TRACE("(%p)->(%p)\n", This, p);
1293 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1297 #undef HTMLELEM_THIS
1299 static const IHTMLElementVtbl HTMLElementVtbl = {
1300 HTMLElement_QueryInterface,
1302 HTMLElement_Release,
1303 HTMLElement_GetTypeInfoCount,
1304 HTMLElement_GetTypeInfo,
1305 HTMLElement_GetIDsOfNames,
1307 HTMLElement_setAttribute,
1308 HTMLElement_getAttribute,
1309 HTMLElement_removeAttribute,
1310 HTMLElement_put_className,
1311 HTMLElement_get_className,
1314 HTMLElement_get_tagName,
1315 HTMLElement_get_parentElement,
1316 HTMLElement_get_style,
1317 HTMLElement_put_onhelp,
1318 HTMLElement_get_onhelp,
1319 HTMLElement_put_onclick,
1320 HTMLElement_get_onclick,
1321 HTMLElement_put_ondblclick,
1322 HTMLElement_get_ondblclick,
1323 HTMLElement_put_onkeydown,
1324 HTMLElement_get_onkeydown,
1325 HTMLElement_put_onkeyup,
1326 HTMLElement_get_onkeyup,
1327 HTMLElement_put_onkeypress,
1328 HTMLElement_get_onkeypress,
1329 HTMLElement_put_onmouseout,
1330 HTMLElement_get_onmouseout,
1331 HTMLElement_put_onmouseover,
1332 HTMLElement_get_onmouseover,
1333 HTMLElement_put_onmousemove,
1334 HTMLElement_get_onmousemove,
1335 HTMLElement_put_onmousedown,
1336 HTMLElement_get_onmousedown,
1337 HTMLElement_put_onmouseup,
1338 HTMLElement_get_onmouseup,
1339 HTMLElement_get_document,
1340 HTMLElement_put_title,
1341 HTMLElement_get_title,
1342 HTMLElement_put_language,
1343 HTMLElement_get_language,
1344 HTMLElement_put_onselectstart,
1345 HTMLElement_get_onselectstart,
1346 HTMLElement_scrollIntoView,
1347 HTMLElement_contains,
1348 HTMLElement_get_sourceIndex,
1349 HTMLElement_get_recordNumber,
1350 HTMLElement_put_lang,
1351 HTMLElement_get_lang,
1352 HTMLElement_get_offsetLeft,
1353 HTMLElement_get_offsetTop,
1354 HTMLElement_get_offsetWidth,
1355 HTMLElement_get_offsetHeight,
1356 HTMLElement_get_offsetParent,
1357 HTMLElement_put_innerHTML,
1358 HTMLElement_get_innerHTML,
1359 HTMLElement_put_innerText,
1360 HTMLElement_get_innerText,
1361 HTMLElement_put_outerHTML,
1362 HTMLElement_get_outerHTML,
1363 HTMLElement_put_outerText,
1364 HTMLElement_get_outerText,
1365 HTMLElement_insertAdjacentHTML,
1366 HTMLElement_insertAdjacentText,
1367 HTMLElement_get_parentTextEdit,
1368 HTMLElement_get_isTextEdit,
1370 HTMLElement_get_filters,
1371 HTMLElement_put_ondragstart,
1372 HTMLElement_get_ondragstart,
1373 HTMLElement_toString,
1374 HTMLElement_put_onbeforeupdate,
1375 HTMLElement_get_onbeforeupdate,
1376 HTMLElement_put_onafterupdate,
1377 HTMLElement_get_onafterupdate,
1378 HTMLElement_put_onerrorupdate,
1379 HTMLElement_get_onerrorupdate,
1380 HTMLElement_put_onrowexit,
1381 HTMLElement_get_onrowexit,
1382 HTMLElement_put_onrowenter,
1383 HTMLElement_get_onrowenter,
1384 HTMLElement_put_ondatasetchanged,
1385 HTMLElement_get_ondatasetchanged,
1386 HTMLElement_put_ondataavailable,
1387 HTMLElement_get_ondataavailable,
1388 HTMLElement_put_ondatasetcomplete,
1389 HTMLElement_get_ondatasetcomplete,
1390 HTMLElement_put_onfilterchange,
1391 HTMLElement_get_onfilterchange,
1392 HTMLElement_get_children,
1396 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1398 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1402 if(IsEqualGUID(&IID_IUnknown, riid)) {
1403 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1404 *ppv = HTMLELEM(This);
1405 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1406 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1407 *ppv = HTMLELEM(This);
1408 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1409 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1410 *ppv = HTMLELEM(This);
1411 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1412 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1413 *ppv = HTMLELEM2(This);
1414 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1415 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1416 *ppv = HTMLELEM3(This);
1417 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1418 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1419 *ppv = CONPTCONT(&This->cp_container);
1423 IHTMLElement_AddRef(HTMLELEM(This));
1427 return HTMLDOMNode_QI(&This->node, riid, ppv);
1430 void HTMLElement_destructor(HTMLDOMNode *iface)
1432 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1434 ConnectionPointContainer_Destroy(&This->cp_container);
1437 nsIDOMHTMLElement_Release(This->nselem);
1439 HTMLDOMNode_destructor(&This->node);
1442 static const NodeImplVtbl HTMLElementImplVtbl = {
1444 HTMLElement_destructor
1447 static const tid_t HTMLElement_iface_tids[] = {
1456 static dispex_static_data_t HTMLElement_dispex = {
1458 DispHTMLUnknownElement_tid,
1460 HTMLElement_iface_tids
1463 void HTMLElement_Init(HTMLElement *This, dispex_static_data_t *dispex_data)
1465 This->lpHTMLElementVtbl = &HTMLElementVtbl;
1467 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
1469 HTMLElement2_Init(This);
1470 HTMLElement3_Init(This);
1472 init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), dispex_data ? dispex_data : &HTMLElement_dispex);
1475 HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic)
1477 nsIDOMHTMLElement *nselem;
1478 HTMLElement *ret = NULL;
1479 nsAString class_name_str;
1480 const PRUnichar *class_name;
1483 static const WCHAR wszA[] = {'A',0};
1484 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1485 static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0};
1486 static const WCHAR wszIMG[] = {'I','M','G',0};
1487 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1488 static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0};
1489 static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0};
1490 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1491 static const WCHAR wszTABLE[] = {'T','A','B','L','E',0};
1492 static const WCHAR wszTR[] = {'T','R',0};
1493 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1495 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1496 if(NS_FAILED(nsres))
1499 nsAString_Init(&class_name_str, NULL);
1500 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1502 nsAString_GetData(&class_name_str, &class_name);
1504 if(!strcmpW(class_name, wszA))
1505 ret = HTMLAnchorElement_Create(nselem);
1506 else if(!strcmpW(class_name, wszBODY))
1507 ret = HTMLBodyElement_Create(nselem);
1508 else if(!strcmpW(class_name, wszIFRAME))
1509 ret = HTMLIFrame_Create(nselem);
1510 else if(!strcmpW(class_name, wszIMG))
1511 ret = HTMLImgElement_Create(nselem);
1512 else if(!strcmpW(class_name, wszINPUT))
1513 ret = HTMLInputElement_Create(nselem);
1514 else if(!strcmpW(class_name, wszOPTION))
1515 ret = HTMLOptionElement_Create(nselem);
1516 else if(!strcmpW(class_name, wszSCRIPT))
1517 ret = HTMLScriptElement_Create(nselem);
1518 else if(!strcmpW(class_name, wszSELECT))
1519 ret = HTMLSelectElement_Create(nselem);
1520 else if(!strcmpW(class_name, wszTABLE))
1521 ret = HTMLTable_Create(nselem);
1522 else if(!strcmpW(class_name, wszTR))
1523 ret = HTMLTableRow_Create(nselem);
1524 else if(!strcmpW(class_name, wszTEXTAREA))
1525 ret = HTMLTextAreaElement_Create(nselem);
1526 else if(use_generic)
1527 ret = HTMLGenericElement_Create(nselem);
1530 ret = heap_alloc_zero(sizeof(HTMLElement));
1531 HTMLElement_Init(ret, NULL);
1532 ret->node.vtbl = &HTMLElementImplVtbl;
1535 TRACE("%s ret %p\n", debugstr_w(class_name), ret);
1537 nsAString_Finish(&class_name_str);
1539 ret->nselem = nselem;
1540 HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);