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);
103 VARIANT AttributeValueChanged;
105 WARN("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
108 FIXME("NULL nselem\n");
112 VariantInit(&AttributeValueChanged);
114 hres = VariantChangeType(&AttributeValueChanged, &AttributeValue, 0, VT_BSTR);
116 WARN("couldn't convert input attribute value %d to VT_BSTR\n", V_VT(&AttributeValue));
120 nsAString_Init(&attr_str, strAttributeName);
121 nsAString_Init(&value_str, V_BSTR(&AttributeValueChanged));
123 TRACE("setting %s to %s\n", debugstr_w(strAttributeName),
124 debugstr_w(V_BSTR(&AttributeValueChanged)));
126 nsres = nsIDOMHTMLElement_SetAttribute(This->nselem, &attr_str, &value_str);
127 nsAString_Finish(&attr_str);
128 nsAString_Finish(&value_str);
130 if(NS_SUCCEEDED(nsres)) {
133 ERR("SetAttribute failed: %08x\n", nsres);
140 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
141 LONG lFlags, VARIANT *AttributeValue)
143 HTMLElement *This = HTMLELEM_THIS(iface);
146 const PRUnichar *value;
150 WARN("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
153 FIXME("NULL nselem\n");
154 V_VT(AttributeValue) = VT_NULL;
158 V_VT(AttributeValue) = VT_NULL;
160 nsAString_Init(&attr_str, strAttributeName);
161 nsAString_Init(&value_str, NULL);
163 nsres = nsIDOMHTMLElement_GetAttribute(This->nselem, &attr_str, &value_str);
164 nsAString_Finish(&attr_str);
166 if(NS_SUCCEEDED(nsres)) {
167 static const WCHAR wszSRC[] = {'s','r','c',0};
168 nsAString_GetData(&value_str, &value);
169 if(!strcmpiW(strAttributeName, wszSRC))
174 hres = IHTMLDocument2_get_URL(HTMLDOC(&This->node.doc->basedoc), &bstrBaseUrl);
175 if(SUCCEEDED(hres)) {
176 hres = CoInternetCombineUrl(bstrBaseUrl, value,
177 URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
178 buffer, sizeof(buffer)/sizeof(WCHAR), &len, 0);
179 SysFreeString(bstrBaseUrl);
180 if(SUCCEEDED(hres)) {
181 V_VT(AttributeValue) = VT_BSTR;
182 V_BSTR(AttributeValue) = SysAllocString(buffer);
183 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
187 V_VT(AttributeValue) = VT_BSTR;
188 V_BSTR(AttributeValue) = SysAllocString(value);
189 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
192 ERR("GetAttribute failed: %08x\n", nsres);
196 nsAString_Finish(&value_str);
201 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
202 LONG lFlags, VARIANT_BOOL *pfSuccess)
204 HTMLElement *This = HTMLELEM_THIS(iface);
205 FIXME("(%p)->()\n", This);
209 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
211 HTMLElement *This = HTMLELEM_THIS(iface);
212 nsAString classname_str;
215 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
218 FIXME("NULL nselem\n");
222 nsAString_Init(&classname_str, v);
223 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
224 nsAString_Finish(&classname_str);
226 ERR("SetClassName failed: %08x\n", nsres);
231 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
233 HTMLElement *This = HTMLELEM_THIS(iface);
238 TRACE("(%p)->(%p)\n", This, p);
241 FIXME("NULL nselem\n");
245 nsAString_Init(&class_str, NULL);
246 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
248 if(NS_SUCCEEDED(nsres)) {
249 const PRUnichar *class;
250 nsAString_GetData(&class_str, &class);
251 *p = *class ? SysAllocString(class) : NULL;
253 ERR("GetClassName failed: %08x\n", nsres);
257 nsAString_Finish(&class_str);
259 TRACE("className=%s\n", debugstr_w(*p));
263 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
265 HTMLElement *This = HTMLELEM_THIS(iface);
269 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
272 FIXME("nselem == NULL\n");
276 nsAString_Init(&id_str, v);
277 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
278 nsAString_Finish(&id_str);
280 ERR("SetId failed: %08x\n", nsres);
285 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
287 HTMLElement *This = HTMLELEM_THIS(iface);
292 TRACE("(%p)->(%p)\n", This, p);
299 nsAString_Init(&id_str, NULL);
300 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
301 nsAString_GetData(&id_str, &id);
304 ERR("GetId failed: %08x\n", nsres);
306 *p = SysAllocString(id);
308 nsAString_Finish(&id_str);
312 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
314 HTMLElement *This = HTMLELEM_THIS(iface);
315 const PRUnichar *tag;
319 TRACE("(%p)->(%p)\n", This, p);
322 static const WCHAR comment_tagW[] = {'!',0};
324 WARN("NULL nselem, assuming comment\n");
326 *p = SysAllocString(comment_tagW);
330 nsAString_Init(&tag_str, NULL);
331 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
332 if(NS_SUCCEEDED(nsres)) {
333 nsAString_GetData(&tag_str, &tag);
334 *p = SysAllocString(tag);
336 ERR("GetTagName failed: %08x\n", nsres);
339 nsAString_Finish(&tag_str);
344 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
346 HTMLElement *This = HTMLELEM_THIS(iface);
350 TRACE("(%p)->(%p)\n", This, p);
352 hres = IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This->node), &node);
356 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
357 IHTMLDOMNode_Release(node);
364 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
366 HTMLElement *This = HTMLELEM_THIS(iface);
367 nsIDOMElementCSSInlineStyle *nselemstyle;
368 nsIDOMCSSStyleDeclaration *nsstyle;
371 TRACE("(%p)->(%p)\n", This, p);
374 FIXME("NULL nselem\n");
378 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
379 (void**)&nselemstyle);
380 if(NS_FAILED(nsres)) {
381 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
385 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
386 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
387 if(NS_FAILED(nsres)) {
388 ERR("GetStyle failed: %08x\n", nsres);
392 /* FIXME: Store style instead of creating a new instance in each call */
393 *p = HTMLStyle_Create(nsstyle);
395 nsIDOMCSSStyleDeclaration_Release(nsstyle);
399 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
401 HTMLElement *This = HTMLELEM_THIS(iface);
402 FIXME("(%p)->()\n", This);
406 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
408 HTMLElement *This = HTMLELEM_THIS(iface);
409 FIXME("(%p)->(%p)\n", This, p);
413 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
415 HTMLElement *This = HTMLELEM_THIS(iface);
417 TRACE("(%p)->()\n", This);
419 return set_node_event(&This->node, EVENTID_CLICK, &v);
422 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
424 HTMLElement *This = HTMLELEM_THIS(iface);
426 TRACE("(%p)->(%p)\n", This, p);
428 return get_node_event(&This->node, EVENTID_CLICK, p);
431 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
433 HTMLElement *This = HTMLELEM_THIS(iface);
435 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
437 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
440 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
442 HTMLElement *This = HTMLELEM_THIS(iface);
444 TRACE("(%p)->(%p)\n", This, p);
446 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
449 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
451 HTMLElement *This = HTMLELEM_THIS(iface);
453 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
455 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
458 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
460 HTMLElement *This = HTMLELEM_THIS(iface);
462 TRACE("(%p)->(%p)\n", This, p);
464 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
467 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
469 HTMLElement *This = HTMLELEM_THIS(iface);
471 TRACE("(%p)->()\n", This);
473 return set_node_event(&This->node, EVENTID_KEYUP, &v);
476 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
478 HTMLElement *This = HTMLELEM_THIS(iface);
479 FIXME("(%p)->(%p)\n", This, p);
483 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
485 HTMLElement *This = HTMLELEM_THIS(iface);
486 FIXME("(%p)->()\n", This);
490 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
492 HTMLElement *This = HTMLELEM_THIS(iface);
493 FIXME("(%p)->(%p)\n", This, p);
497 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
499 HTMLElement *This = HTMLELEM_THIS(iface);
501 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
503 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
506 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
508 HTMLElement *This = HTMLELEM_THIS(iface);
510 TRACE("(%p)->(%p)\n", This, p);
512 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
515 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
517 HTMLElement *This = HTMLELEM_THIS(iface);
519 TRACE("(%p)->()\n", This);
521 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
524 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
526 HTMLElement *This = HTMLELEM_THIS(iface);
528 TRACE("(%p)->(%p)\n", This, p);
530 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
533 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
535 HTMLElement *This = HTMLELEM_THIS(iface);
536 FIXME("(%p)->()\n", This);
540 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
542 HTMLElement *This = HTMLELEM_THIS(iface);
543 FIXME("(%p)->(%p)\n", This, p);
547 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
549 HTMLElement *This = HTMLELEM_THIS(iface);
551 TRACE("(%p)->()\n", This);
553 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
556 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
558 HTMLElement *This = HTMLELEM_THIS(iface);
560 TRACE("(%p)->(%p)\n", This, p);
562 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
565 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
567 HTMLElement *This = HTMLELEM_THIS(iface);
569 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
571 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
574 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
576 HTMLElement *This = HTMLELEM_THIS(iface);
578 TRACE("(%p)->(%p)\n", This, p);
580 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
583 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
585 HTMLElement *This = HTMLELEM_THIS(iface);
587 TRACE("(%p)->(%p)\n", This, p);
592 *p = (IDispatch*)HTMLDOC(&This->node.doc->basedoc);
593 IDispatch_AddRef(*p);
598 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
600 HTMLElement *This = HTMLELEM_THIS(iface);
604 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
606 nsAString_Init(&title_str, v);
607 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
608 nsAString_Finish(&title_str);
610 ERR("SetTitle failed: %08x\n", nsres);
615 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
617 HTMLElement *This = HTMLELEM_THIS(iface);
621 TRACE("(%p)->(%p)\n", This, p);
623 nsAString_Init(&title_str, NULL);
624 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
625 if(NS_SUCCEEDED(nsres)) {
626 const PRUnichar *title;
628 nsAString_GetData(&title_str, &title);
629 *p = *title ? SysAllocString(title) : NULL;
631 ERR("GetTitle failed: %08x\n", nsres);
638 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
640 HTMLElement *This = HTMLELEM_THIS(iface);
641 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
645 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
647 HTMLElement *This = HTMLELEM_THIS(iface);
648 FIXME("(%p)->(%p)\n", This, p);
652 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
654 HTMLElement *This = HTMLELEM_THIS(iface);
656 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
658 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
661 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
663 HTMLElement *This = HTMLELEM_THIS(iface);
665 TRACE("(%p)->(%p)\n", This, p);
667 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
670 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
672 HTMLElement *This = HTMLELEM_THIS(iface);
673 FIXME("(%p)->()\n", This);
677 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
678 VARIANT_BOOL *pfResult)
680 HTMLElement *This = HTMLELEM_THIS(iface);
681 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
685 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
687 HTMLElement *This = HTMLELEM_THIS(iface);
688 FIXME("(%p)->(%p)\n", This, p);
692 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
694 HTMLElement *This = HTMLELEM_THIS(iface);
695 FIXME("(%p)->(%p)\n", This, p);
699 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
701 HTMLElement *This = HTMLELEM_THIS(iface);
702 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
706 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
708 HTMLElement *This = HTMLELEM_THIS(iface);
709 FIXME("(%p)->(%p)\n", This, p);
713 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
715 HTMLElement *This = HTMLELEM_THIS(iface);
716 FIXME("(%p)->(%p)\n", This, p);
720 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
722 HTMLElement *This = HTMLELEM_THIS(iface);
723 nsIDOMNSHTMLElement *nselem;
727 TRACE("(%p)->(%p)\n", This, p);
729 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
730 if(NS_FAILED(nsres)) {
731 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
735 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
736 nsIDOMNSHTMLElement_Release(nselem);
737 if(NS_FAILED(nsres)) {
738 ERR("GetOffsetTop failed: %08x\n", nsres);
746 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
748 HTMLElement *This = HTMLELEM_THIS(iface);
749 nsIDOMNSHTMLElement *nselem;
753 TRACE("(%p)->(%p)\n", This, p);
755 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
756 if(NS_FAILED(nsres)) {
757 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
761 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
762 nsIDOMNSHTMLElement_Release(nselem);
763 if(NS_FAILED(nsres)) {
764 ERR("GetOffsetWidth failed: %08x\n", nsres);
772 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
774 HTMLElement *This = HTMLELEM_THIS(iface);
775 nsIDOMNSHTMLElement *nselem;
779 TRACE("(%p)->(%p)\n", This, p);
781 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
782 if(NS_FAILED(nsres)) {
783 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
787 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
788 nsIDOMNSHTMLElement_Release(nselem);
789 if(NS_FAILED(nsres)) {
790 ERR("GetOffsetHeight failed: %08x\n", nsres);
798 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
800 HTMLElement *This = HTMLELEM_THIS(iface);
801 FIXME("(%p)->(%p)\n", This, p);
805 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
807 HTMLElement *This = HTMLELEM_THIS(iface);
808 nsIDOMNSHTMLElement *nselem;
812 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
815 FIXME("NULL nselem\n");
819 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
820 if(NS_FAILED(nsres)) {
821 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
825 nsAString_Init(&html_str, v);
826 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
827 nsAString_Finish(&html_str);
829 if(NS_FAILED(nsres)) {
830 FIXME("SetInnerHtml failed %08x\n", nsres);
837 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
839 HTMLElement *This = HTMLELEM_THIS(iface);
840 nsIDOMNSHTMLElement *nselem;
844 TRACE("(%p)->(%p)\n", This, p);
847 FIXME("NULL nselem\n");
851 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
852 if(NS_FAILED(nsres)) {
853 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
857 nsAString_Init(&html_str, NULL);
858 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
859 if(NS_SUCCEEDED(nsres)) {
860 const PRUnichar *html;
862 nsAString_GetData(&html_str, &html);
863 *p = *html ? SysAllocString(html) : NULL;
865 FIXME("SetInnerHtml failed %08x\n", nsres);
869 nsAString_Finish(&html_str);
873 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
875 HTMLElement *This = HTMLELEM_THIS(iface);
876 nsIDOMNode *nschild, *tmp;
877 nsIDOMText *text_node;
881 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
884 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
885 if(NS_FAILED(nsres)) {
886 ERR("GetLastChild failed: %08x\n", nsres);
892 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
893 nsIDOMNode_Release(nschild);
894 if(NS_FAILED(nsres)) {
895 ERR("RemoveChild failed: %08x\n", nsres);
898 nsIDOMNode_Release(tmp);
901 nsAString_Init(&text_str, v);
902 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->basedoc.nsdoc, &text_str, &text_node);
903 nsAString_Finish(&text_str);
904 if(NS_FAILED(nsres)) {
905 ERR("CreateTextNode failed: %08x\n", nsres);
909 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
910 if(NS_FAILED(nsres)) {
911 ERR("AppendChild failed: %08x\n", nsres);
915 nsIDOMNode_Release(tmp);
919 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
921 HTMLElement *This = HTMLELEM_THIS(iface);
923 TRACE("(%p)->(%p)\n", This, p);
925 return get_node_text(&This->node, p);
928 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
930 HTMLElement *This = HTMLELEM_THIS(iface);
931 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
935 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
937 HTMLElement *This = HTMLELEM_THIS(iface);
941 WARN("(%p)->(%p) semi-stub\n", This, p);
943 nsAString_Init(&html_str, NULL);
944 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
945 if(SUCCEEDED(hres)) {
946 const PRUnichar *html;
948 nsAString_GetData(&html_str, &html);
949 *p = SysAllocString(html);
951 hres = E_OUTOFMEMORY;
954 nsAString_Finish(&html_str);
956 TRACE("ret %s\n", debugstr_w(*p));
960 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
962 HTMLElement *This = HTMLELEM_THIS(iface);
963 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
967 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
969 HTMLElement *This = HTMLELEM_THIS(iface);
970 FIXME("(%p)->(%p)\n", This, p);
974 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
976 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
977 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
978 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
979 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
983 FIXME("NULL nselem\n");
987 if (!strcmpiW(where, wszBeforeBegin))
991 nsres = nsIDOMNode_GetParentNode(This->nselem, &parent);
992 if (!parent) return E_INVALIDARG;
993 nsres = nsIDOMNode_InsertBefore(parent, nsnode,
994 (nsIDOMNode *)This->nselem, &unused);
995 if (unused) nsIDOMNode_Release(unused);
996 nsIDOMNode_Release(parent);
998 else if (!strcmpiW(where, wszAfterBegin))
1001 nsIDOMNode *first_child;
1002 nsIDOMNode_GetFirstChild(This->nselem, &first_child);
1003 nsres = nsIDOMNode_InsertBefore(This->nselem, nsnode, first_child, &unused);
1004 if (unused) nsIDOMNode_Release(unused);
1005 if (first_child) nsIDOMNode_Release(first_child);
1007 else if (!strcmpiW(where, wszBeforeEnd))
1010 nsres = nsIDOMNode_AppendChild(This->nselem, nsnode, &unused);
1011 if (unused) nsIDOMNode_Release(unused);
1013 else if (!strcmpiW(where, wszAfterEnd))
1016 nsIDOMNode *next_sibling;
1018 nsIDOMNode_GetParentNode(This->nselem, &parent);
1019 if (!parent) return E_INVALIDARG;
1021 nsIDOMNode_GetNextSibling(This->nselem, &next_sibling);
1024 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1025 nsIDOMNode_Release(next_sibling);
1028 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1029 nsIDOMNode_Release(parent);
1030 if (unused) nsIDOMNode_Release(unused);
1034 ERR("invalid where: %s\n", debugstr_w(where));
1035 return E_INVALIDARG;
1038 if (NS_FAILED(nsres))
1044 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1047 HTMLElement *This = HTMLELEM_THIS(iface);
1048 nsIDOMDocumentRange *nsdocrange;
1050 nsIDOMNSRange *nsrange;
1056 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1058 if(!This->node.doc->basedoc.nsdoc) {
1059 WARN("NULL nsdoc\n");
1060 return E_UNEXPECTED;
1063 nsres = nsIDOMDocument_QueryInterface(This->node.doc->basedoc.nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1064 if(NS_FAILED(nsres))
1066 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1069 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1070 nsIDOMDocumentRange_Release(nsdocrange);
1071 if(NS_FAILED(nsres))
1073 ERR("CreateRange failed: %08x\n", nsres);
1077 nsIDOMRange_SetStartBefore(range, (nsIDOMNode *)This->nselem);
1079 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1080 nsIDOMRange_Release(range);
1081 if(NS_FAILED(nsres))
1083 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1087 nsAString_Init(&ns_html, html);
1089 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1090 nsIDOMNSRange_Release(nsrange);
1091 nsAString_Finish(&ns_html);
1093 if(NS_FAILED(nsres) || !nsnode)
1095 ERR("CreateTextNode failed: %08x\n", nsres);
1099 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1100 nsIDOMNode_Release(nsnode);
1105 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1108 HTMLElement *This = HTMLELEM_THIS(iface);
1114 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1116 if(!This->node.doc->basedoc.nsdoc) {
1117 WARN("NULL nsdoc\n");
1118 return E_UNEXPECTED;
1122 nsAString_Init(&ns_text, text);
1123 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->basedoc.nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1124 nsAString_Finish(&ns_text);
1126 if(NS_FAILED(nsres) || !nsnode)
1128 ERR("CreateTextNode failed: %08x\n", nsres);
1132 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1133 nsIDOMNode_Release(nsnode);
1138 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1140 HTMLElement *This = HTMLELEM_THIS(iface);
1141 FIXME("(%p)->(%p)\n", This, p);
1145 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1147 HTMLElement *This = HTMLELEM_THIS(iface);
1148 FIXME("(%p)->(%p)\n", This, p);
1152 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1154 HTMLElement *This = HTMLELEM_THIS(iface);
1155 FIXME("(%p)\n", This);
1159 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1160 IHTMLFiltersCollection **p)
1162 HTMLElement *This = HTMLELEM_THIS(iface);
1163 FIXME("(%p)->(%p)\n", This, p);
1167 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1169 HTMLElement *This = HTMLELEM_THIS(iface);
1170 FIXME("(%p)->()\n", This);
1174 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1176 HTMLElement *This = HTMLELEM_THIS(iface);
1177 FIXME("(%p)->(%p)\n", This, p);
1181 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1183 HTMLElement *This = HTMLELEM_THIS(iface);
1184 FIXME("(%p)->(%p)\n", This, String);
1188 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1190 HTMLElement *This = HTMLELEM_THIS(iface);
1191 FIXME("(%p)->()\n", This);
1195 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1197 HTMLElement *This = HTMLELEM_THIS(iface);
1198 FIXME("(%p)->(%p)\n", This, p);
1202 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1204 HTMLElement *This = HTMLELEM_THIS(iface);
1205 FIXME("(%p)->()\n", This);
1209 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1211 HTMLElement *This = HTMLELEM_THIS(iface);
1212 FIXME("(%p)->(%p)\n", This, p);
1216 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1218 HTMLElement *This = HTMLELEM_THIS(iface);
1219 FIXME("(%p)->()\n", This);
1223 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1225 HTMLElement *This = HTMLELEM_THIS(iface);
1226 FIXME("(%p)->(%p)\n", This, p);
1230 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1232 HTMLElement *This = HTMLELEM_THIS(iface);
1233 FIXME("(%p)->()\n", This);
1237 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1239 HTMLElement *This = HTMLELEM_THIS(iface);
1240 FIXME("(%p)->(%p)\n", This, p);
1244 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1246 HTMLElement *This = HTMLELEM_THIS(iface);
1247 FIXME("(%p)->()\n", This);
1251 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1253 HTMLElement *This = HTMLELEM_THIS(iface);
1254 FIXME("(%p)->(%p)\n", This, p);
1258 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1260 HTMLElement *This = HTMLELEM_THIS(iface);
1261 FIXME("(%p)->()\n", This);
1265 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1267 HTMLElement *This = HTMLELEM_THIS(iface);
1268 FIXME("(%p)->(%p)\n", This, p);
1272 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1274 HTMLElement *This = HTMLELEM_THIS(iface);
1275 FIXME("(%p)->()\n", This);
1279 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1281 HTMLElement *This = HTMLELEM_THIS(iface);
1282 FIXME("(%p)->(%p)\n", This, p);
1286 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1288 HTMLElement *This = HTMLELEM_THIS(iface);
1289 FIXME("(%p)->()\n", This);
1293 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1295 HTMLElement *This = HTMLELEM_THIS(iface);
1296 FIXME("(%p)->(%p)\n", This, p);
1300 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1302 HTMLElement *This = HTMLELEM_THIS(iface);
1303 FIXME("(%p)->()\n", This);
1307 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1309 HTMLElement *This = HTMLELEM_THIS(iface);
1310 FIXME("(%p)->(%p)\n", This, p);
1314 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1316 HTMLElement *This = HTMLELEM_THIS(iface);
1317 nsIDOMNodeList *nsnode_list;
1320 TRACE("(%p)->(%p)\n", This, p);
1322 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1323 if(NS_FAILED(nsres)) {
1324 ERR("GetChildNodes failed: %08x\n", nsres);
1328 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
1330 nsIDOMNodeList_Release(nsnode_list);
1334 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1336 HTMLElement *This = HTMLELEM_THIS(iface);
1338 TRACE("(%p)->(%p)\n", This, p);
1340 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1344 #undef HTMLELEM_THIS
1346 static const IHTMLElementVtbl HTMLElementVtbl = {
1347 HTMLElement_QueryInterface,
1349 HTMLElement_Release,
1350 HTMLElement_GetTypeInfoCount,
1351 HTMLElement_GetTypeInfo,
1352 HTMLElement_GetIDsOfNames,
1354 HTMLElement_setAttribute,
1355 HTMLElement_getAttribute,
1356 HTMLElement_removeAttribute,
1357 HTMLElement_put_className,
1358 HTMLElement_get_className,
1361 HTMLElement_get_tagName,
1362 HTMLElement_get_parentElement,
1363 HTMLElement_get_style,
1364 HTMLElement_put_onhelp,
1365 HTMLElement_get_onhelp,
1366 HTMLElement_put_onclick,
1367 HTMLElement_get_onclick,
1368 HTMLElement_put_ondblclick,
1369 HTMLElement_get_ondblclick,
1370 HTMLElement_put_onkeydown,
1371 HTMLElement_get_onkeydown,
1372 HTMLElement_put_onkeyup,
1373 HTMLElement_get_onkeyup,
1374 HTMLElement_put_onkeypress,
1375 HTMLElement_get_onkeypress,
1376 HTMLElement_put_onmouseout,
1377 HTMLElement_get_onmouseout,
1378 HTMLElement_put_onmouseover,
1379 HTMLElement_get_onmouseover,
1380 HTMLElement_put_onmousemove,
1381 HTMLElement_get_onmousemove,
1382 HTMLElement_put_onmousedown,
1383 HTMLElement_get_onmousedown,
1384 HTMLElement_put_onmouseup,
1385 HTMLElement_get_onmouseup,
1386 HTMLElement_get_document,
1387 HTMLElement_put_title,
1388 HTMLElement_get_title,
1389 HTMLElement_put_language,
1390 HTMLElement_get_language,
1391 HTMLElement_put_onselectstart,
1392 HTMLElement_get_onselectstart,
1393 HTMLElement_scrollIntoView,
1394 HTMLElement_contains,
1395 HTMLElement_get_sourceIndex,
1396 HTMLElement_get_recordNumber,
1397 HTMLElement_put_lang,
1398 HTMLElement_get_lang,
1399 HTMLElement_get_offsetLeft,
1400 HTMLElement_get_offsetTop,
1401 HTMLElement_get_offsetWidth,
1402 HTMLElement_get_offsetHeight,
1403 HTMLElement_get_offsetParent,
1404 HTMLElement_put_innerHTML,
1405 HTMLElement_get_innerHTML,
1406 HTMLElement_put_innerText,
1407 HTMLElement_get_innerText,
1408 HTMLElement_put_outerHTML,
1409 HTMLElement_get_outerHTML,
1410 HTMLElement_put_outerText,
1411 HTMLElement_get_outerText,
1412 HTMLElement_insertAdjacentHTML,
1413 HTMLElement_insertAdjacentText,
1414 HTMLElement_get_parentTextEdit,
1415 HTMLElement_get_isTextEdit,
1417 HTMLElement_get_filters,
1418 HTMLElement_put_ondragstart,
1419 HTMLElement_get_ondragstart,
1420 HTMLElement_toString,
1421 HTMLElement_put_onbeforeupdate,
1422 HTMLElement_get_onbeforeupdate,
1423 HTMLElement_put_onafterupdate,
1424 HTMLElement_get_onafterupdate,
1425 HTMLElement_put_onerrorupdate,
1426 HTMLElement_get_onerrorupdate,
1427 HTMLElement_put_onrowexit,
1428 HTMLElement_get_onrowexit,
1429 HTMLElement_put_onrowenter,
1430 HTMLElement_get_onrowenter,
1431 HTMLElement_put_ondatasetchanged,
1432 HTMLElement_get_ondatasetchanged,
1433 HTMLElement_put_ondataavailable,
1434 HTMLElement_get_ondataavailable,
1435 HTMLElement_put_ondatasetcomplete,
1436 HTMLElement_get_ondatasetcomplete,
1437 HTMLElement_put_onfilterchange,
1438 HTMLElement_get_onfilterchange,
1439 HTMLElement_get_children,
1443 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1445 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1449 if(IsEqualGUID(&IID_IUnknown, riid)) {
1450 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1451 *ppv = HTMLELEM(This);
1452 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1453 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1454 *ppv = HTMLELEM(This);
1455 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1456 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1457 *ppv = HTMLELEM(This);
1458 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1459 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1460 *ppv = HTMLELEM2(This);
1461 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1462 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1463 *ppv = HTMLELEM3(This);
1464 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1465 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1466 *ppv = CONPTCONT(&This->cp_container);
1470 IHTMLElement_AddRef(HTMLELEM(This));
1474 return HTMLDOMNode_QI(&This->node, riid, ppv);
1477 void HTMLElement_destructor(HTMLDOMNode *iface)
1479 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1481 ConnectionPointContainer_Destroy(&This->cp_container);
1484 nsIDOMHTMLElement_Release(This->nselem);
1486 HTMLDOMNode_destructor(&This->node);
1489 static const NodeImplVtbl HTMLElementImplVtbl = {
1491 HTMLElement_destructor
1494 static const tid_t HTMLElement_iface_tids[] = {
1503 static dispex_static_data_t HTMLElement_dispex = {
1505 DispHTMLUnknownElement_tid,
1507 HTMLElement_iface_tids
1510 void HTMLElement_Init(HTMLElement *This)
1512 This->lpHTMLElementVtbl = &HTMLElementVtbl;
1514 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
1516 HTMLElement2_Init(This);
1517 HTMLElement3_Init(This);
1519 if(!This->node.dispex.data)
1520 init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), &HTMLElement_dispex);
1523 HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic)
1525 nsIDOMHTMLElement *nselem;
1526 HTMLElement *ret = NULL;
1527 nsAString class_name_str;
1528 const PRUnichar *class_name;
1531 static const WCHAR wszA[] = {'A',0};
1532 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1533 static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0};
1534 static const WCHAR wszIMG[] = {'I','M','G',0};
1535 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1536 static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0};
1537 static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0};
1538 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1539 static const WCHAR wszTABLE[] = {'T','A','B','L','E',0};
1540 static const WCHAR wszTR[] = {'T','R',0};
1541 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1543 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1544 if(NS_FAILED(nsres))
1547 nsAString_Init(&class_name_str, NULL);
1548 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1550 nsAString_GetData(&class_name_str, &class_name);
1552 if(!strcmpW(class_name, wszA))
1553 ret = HTMLAnchorElement_Create(nselem);
1554 else if(!strcmpW(class_name, wszBODY))
1555 ret = HTMLBodyElement_Create(nselem);
1556 else if(!strcmpW(class_name, wszIFRAME))
1557 ret = HTMLIFrame_Create(nselem);
1558 else if(!strcmpW(class_name, wszIMG))
1559 ret = HTMLImgElement_Create(nselem);
1560 else if(!strcmpW(class_name, wszINPUT))
1561 ret = HTMLInputElement_Create(nselem);
1562 else if(!strcmpW(class_name, wszOPTION))
1563 ret = HTMLOptionElement_Create(nselem);
1564 else if(!strcmpW(class_name, wszSCRIPT))
1565 ret = HTMLScriptElement_Create(nselem);
1566 else if(!strcmpW(class_name, wszSELECT))
1567 ret = HTMLSelectElement_Create(nselem);
1568 else if(!strcmpW(class_name, wszTABLE))
1569 ret = HTMLTable_Create(nselem);
1570 else if(!strcmpW(class_name, wszTR))
1571 ret = HTMLTableRow_Create(nselem);
1572 else if(!strcmpW(class_name, wszTEXTAREA))
1573 ret = HTMLTextAreaElement_Create(nselem);
1574 else if(use_generic)
1575 ret = HTMLGenericElement_Create(nselem);
1578 ret = heap_alloc_zero(sizeof(HTMLElement));
1579 HTMLElement_Init(ret);
1580 ret->node.vtbl = &HTMLElementImplVtbl;
1583 TRACE("%s ret %p\n", debugstr_w(class_name), ret);
1585 nsAString_Finish(&class_name_str);
1587 ret->nselem = nselem;
1588 HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);