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"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
40 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
42 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
43 REFIID riid
, void **ppv
)
45 HTMLElement
*This
= HTMLELEM_THIS(iface
);
47 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->node
), riid
, ppv
);
50 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
52 HTMLElement
*This
= HTMLELEM_THIS(iface
);
54 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->node
));
57 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
59 HTMLElement
*This
= HTMLELEM_THIS(iface
);
61 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->node
));
64 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
66 HTMLElement
*This
= HTMLELEM_THIS(iface
);
67 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->node
.dispex
), pctinfo
);
70 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
71 LCID lcid
, ITypeInfo
**ppTInfo
)
73 HTMLElement
*This
= HTMLELEM_THIS(iface
);
74 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->node
.dispex
), iTInfo
, lcid
, ppTInfo
);
77 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
78 LPOLESTR
*rgszNames
, UINT cNames
,
79 LCID lcid
, DISPID
*rgDispId
)
81 HTMLElement
*This
= HTMLELEM_THIS(iface
);
82 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
85 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
86 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
87 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
89 HTMLElement
*This
= HTMLELEM_THIS(iface
);
90 return IDispatchEx_Invoke(DISPATCHEX(&This
->node
.dispex
), dispIdMember
, riid
, lcid
,
91 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
94 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
95 VARIANT AttributeValue
, LONG lFlags
)
97 HTMLElement
*This
= HTMLELEM_THIS(iface
);
102 VARIANT AttributeValueChanged
;
104 WARN("(%p)->(%s . %08x)\n", This
, debugstr_w(strAttributeName
), lFlags
);
107 FIXME("NULL nselem\n");
111 VariantInit(&AttributeValueChanged
);
113 hres
= VariantChangeType(&AttributeValueChanged
, &AttributeValue
, 0, VT_BSTR
);
115 WARN("couldn't convert input attribute value %d to VT_BSTR\n", V_VT(&AttributeValue
));
119 nsAString_Init(&attr_str
, strAttributeName
);
120 nsAString_Init(&value_str
, V_BSTR(&AttributeValueChanged
));
122 TRACE("setting %s to %s\n", debugstr_w(strAttributeName
),
123 debugstr_w(V_BSTR(&AttributeValueChanged
)));
125 nsres
= nsIDOMHTMLElement_SetAttribute(This
->nselem
, &attr_str
, &value_str
);
126 nsAString_Finish(&attr_str
);
127 nsAString_Finish(&value_str
);
129 if(NS_SUCCEEDED(nsres
)) {
132 ERR("SetAttribute failed: %08x\n", nsres
);
139 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
140 LONG lFlags
, VARIANT
*AttributeValue
)
142 HTMLElement
*This
= HTMLELEM_THIS(iface
);
145 const PRUnichar
*value
;
149 WARN("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
152 FIXME("NULL nselem\n");
153 V_VT(AttributeValue
) = VT_NULL
;
157 V_VT(AttributeValue
) = VT_NULL
;
159 nsAString_Init(&attr_str
, strAttributeName
);
160 nsAString_Init(&value_str
, NULL
);
162 nsres
= nsIDOMHTMLElement_GetAttribute(This
->nselem
, &attr_str
, &value_str
);
163 nsAString_Finish(&attr_str
);
165 if(NS_SUCCEEDED(nsres
)) {
166 static const WCHAR wszSRC
[] = {'s','r','c',0};
167 nsAString_GetData(&value_str
, &value
);
168 if(!strcmpiW(strAttributeName
, wszSRC
))
173 hres
= IHTMLDocument2_get_URL(HTMLDOC(This
->node
.doc
), &bstrBaseUrl
);
174 if(SUCCEEDED(hres
)) {
175 hres
= CoInternetCombineUrl(bstrBaseUrl
, value
,
176 URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
177 buffer
, sizeof(buffer
)/sizeof(WCHAR
), &len
, 0);
178 SysFreeString(bstrBaseUrl
);
179 if(SUCCEEDED(hres
)) {
180 V_VT(AttributeValue
) = VT_BSTR
;
181 V_BSTR(AttributeValue
) = SysAllocString(buffer
);
182 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue
)));
186 V_VT(AttributeValue
) = VT_BSTR
;
187 V_BSTR(AttributeValue
) = SysAllocString(value
);
188 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue
)));
191 ERR("GetAttribute failed: %08x\n", nsres
);
195 nsAString_Finish(&value_str
);
200 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
201 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
203 HTMLElement
*This
= HTMLELEM_THIS(iface
);
204 FIXME("(%p)->()\n", This
);
208 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
210 HTMLElement
*This
= HTMLELEM_THIS(iface
);
211 nsAString classname_str
;
214 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
217 FIXME("NULL nselem\n");
221 nsAString_Init(&classname_str
, v
);
222 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
223 nsAString_Finish(&classname_str
);
225 ERR("SetClassName failed: %08x\n", nsres
);
230 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
232 HTMLElement
*This
= HTMLELEM_THIS(iface
);
237 TRACE("(%p)->(%p)\n", This
, p
);
240 FIXME("NULL nselem\n");
244 nsAString_Init(&class_str
, NULL
);
245 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
247 if(NS_SUCCEEDED(nsres
)) {
248 const PRUnichar
*class;
249 nsAString_GetData(&class_str
, &class);
250 *p
= *class ? SysAllocString(class) : NULL
;
252 ERR("GetClassName failed: %08x\n", nsres
);
256 nsAString_Finish(&class_str
);
258 TRACE("className=%s\n", debugstr_w(*p
));
262 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
264 HTMLElement
*This
= HTMLELEM_THIS(iface
);
268 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
271 FIXME("nselem == NULL\n");
275 nsAString_Init(&id_str
, v
);
276 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
277 nsAString_Finish(&id_str
);
279 ERR("SetId failed: %08x\n", nsres
);
284 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
286 HTMLElement
*This
= HTMLELEM_THIS(iface
);
291 TRACE("(%p)->(%p)\n", This
, p
);
298 nsAString_Init(&id_str
, NULL
);
299 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
300 nsAString_GetData(&id_str
, &id
);
303 ERR("GetId failed: %08x\n", nsres
);
305 *p
= SysAllocString(id
);
307 nsAString_Finish(&id_str
);
311 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
313 HTMLElement
*This
= HTMLELEM_THIS(iface
);
314 const PRUnichar
*tag
;
318 TRACE("(%p)->(%p)\n", This
, p
);
321 static const WCHAR comment_tagW
[] = {'!',0};
323 WARN("NULL nselem, assuming comment\n");
325 *p
= SysAllocString(comment_tagW
);
329 nsAString_Init(&tag_str
, NULL
);
330 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
331 if(NS_SUCCEEDED(nsres
)) {
332 nsAString_GetData(&tag_str
, &tag
);
333 *p
= SysAllocString(tag
);
335 ERR("GetTagName failed: %08x\n", nsres
);
338 nsAString_Finish(&tag_str
);
343 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
345 HTMLElement
*This
= HTMLELEM_THIS(iface
);
349 TRACE("(%p)->(%p)\n", This
, p
);
351 hres
= IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This
->node
), &node
);
355 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
356 IHTMLDOMNode_Release(node
);
363 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
365 HTMLElement
*This
= HTMLELEM_THIS(iface
);
366 nsIDOMElementCSSInlineStyle
*nselemstyle
;
367 nsIDOMCSSStyleDeclaration
*nsstyle
;
370 TRACE("(%p)->(%p)\n", This
, p
);
373 FIXME("NULL nselem\n");
377 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMElementCSSInlineStyle
,
378 (void**)&nselemstyle
);
379 if(NS_FAILED(nsres
)) {
380 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres
);
384 nsres
= nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle
, &nsstyle
);
385 nsIDOMElementCSSInlineStyle_Release(nselemstyle
);
386 if(NS_FAILED(nsres
)) {
387 ERR("GetStyle failed: %08x\n", nsres
);
391 /* FIXME: Store style instead of creating a new instance in each call */
392 *p
= HTMLStyle_Create(nsstyle
);
394 nsIDOMCSSStyleDeclaration_Release(nsstyle
);
398 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
400 HTMLElement
*This
= HTMLELEM_THIS(iface
);
401 FIXME("(%p)->()\n", This
);
405 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
407 HTMLElement
*This
= HTMLELEM_THIS(iface
);
408 FIXME("(%p)->(%p)\n", This
, p
);
412 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
414 HTMLElement
*This
= HTMLELEM_THIS(iface
);
416 TRACE("(%p)->()\n", This
);
418 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
421 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
423 HTMLElement
*This
= HTMLELEM_THIS(iface
);
424 FIXME("(%p)->(%p)\n", This
, p
);
428 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
430 HTMLElement
*This
= HTMLELEM_THIS(iface
);
431 FIXME("(%p)->()\n", This
);
435 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
437 HTMLElement
*This
= HTMLELEM_THIS(iface
);
438 FIXME("(%p)->(%p)\n", This
, p
);
442 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
444 HTMLElement
*This
= HTMLELEM_THIS(iface
);
445 FIXME("(%p)->()\n", This
);
449 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
451 HTMLElement
*This
= HTMLELEM_THIS(iface
);
452 FIXME("(%p)->(%p)\n", This
, p
);
456 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
458 HTMLElement
*This
= HTMLELEM_THIS(iface
);
460 TRACE("(%p)->()\n", This
);
462 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
465 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
467 HTMLElement
*This
= HTMLELEM_THIS(iface
);
468 FIXME("(%p)->(%p)\n", This
, p
);
472 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
474 HTMLElement
*This
= HTMLELEM_THIS(iface
);
475 FIXME("(%p)->()\n", This
);
479 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
481 HTMLElement
*This
= HTMLELEM_THIS(iface
);
482 FIXME("(%p)->(%p)\n", This
, p
);
486 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
488 HTMLElement
*This
= HTMLELEM_THIS(iface
);
489 FIXME("(%p)->()\n", This
);
493 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
495 HTMLElement
*This
= HTMLELEM_THIS(iface
);
496 FIXME("(%p)->(%p)\n", This
, p
);
500 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
502 HTMLElement
*This
= HTMLELEM_THIS(iface
);
503 FIXME("(%p)->()\n", This
);
507 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
509 HTMLElement
*This
= HTMLELEM_THIS(iface
);
510 FIXME("(%p)->(%p)\n", This
, p
);
514 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
516 HTMLElement
*This
= HTMLELEM_THIS(iface
);
517 FIXME("(%p)->()\n", This
);
521 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
523 HTMLElement
*This
= HTMLELEM_THIS(iface
);
524 FIXME("(%p)->(%p)\n", This
, p
);
528 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
530 HTMLElement
*This
= HTMLELEM_THIS(iface
);
531 FIXME("(%p)->()\n", This
);
535 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
537 HTMLElement
*This
= HTMLELEM_THIS(iface
);
538 FIXME("(%p)->(%p)\n", This
, p
);
542 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
544 HTMLElement
*This
= HTMLELEM_THIS(iface
);
545 FIXME("(%p)->()\n", This
);
549 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
551 HTMLElement
*This
= HTMLELEM_THIS(iface
);
552 FIXME("(%p)->(%p)\n", This
, p
);
556 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
558 HTMLElement
*This
= HTMLELEM_THIS(iface
);
559 FIXME("(%p)->(%p)\n", This
, p
);
563 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
565 HTMLElement
*This
= HTMLELEM_THIS(iface
);
569 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
571 nsAString_Init(&title_str
, v
);
572 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
573 nsAString_Finish(&title_str
);
575 ERR("SetTitle failed: %08x\n", nsres
);
580 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
582 HTMLElement
*This
= HTMLELEM_THIS(iface
);
586 TRACE("(%p)->(%p)\n", This
, p
);
588 nsAString_Init(&title_str
, NULL
);
589 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
590 if(NS_SUCCEEDED(nsres
)) {
591 const PRUnichar
*title
;
593 nsAString_GetData(&title_str
, &title
);
594 *p
= *title
? SysAllocString(title
) : NULL
;
596 ERR("GetTitle failed: %08x\n", nsres
);
603 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
605 HTMLElement
*This
= HTMLELEM_THIS(iface
);
606 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
610 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
612 HTMLElement
*This
= HTMLELEM_THIS(iface
);
613 FIXME("(%p)->(%p)\n", This
, p
);
617 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
619 HTMLElement
*This
= HTMLELEM_THIS(iface
);
620 FIXME("(%p)->()\n", This
);
624 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
626 HTMLElement
*This
= HTMLELEM_THIS(iface
);
627 FIXME("(%p)->(%p)\n", This
, p
);
631 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
633 HTMLElement
*This
= HTMLELEM_THIS(iface
);
634 FIXME("(%p)->()\n", This
);
638 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
639 VARIANT_BOOL
*pfResult
)
641 HTMLElement
*This
= HTMLELEM_THIS(iface
);
642 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
646 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, long *p
)
648 HTMLElement
*This
= HTMLELEM_THIS(iface
);
649 FIXME("(%p)->(%p)\n", This
, p
);
653 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
655 HTMLElement
*This
= HTMLELEM_THIS(iface
);
656 FIXME("(%p)->(%p)\n", This
, p
);
660 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
662 HTMLElement
*This
= HTMLELEM_THIS(iface
);
663 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
667 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
669 HTMLElement
*This
= HTMLELEM_THIS(iface
);
670 FIXME("(%p)->(%p)\n", This
, p
);
674 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, long *p
)
676 HTMLElement
*This
= HTMLELEM_THIS(iface
);
677 FIXME("(%p)->(%p)\n", This
, p
);
681 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, long *p
)
683 HTMLElement
*This
= HTMLELEM_THIS(iface
);
684 nsIDOMNSHTMLElement
*nselem
;
688 TRACE("(%p)->(%p)\n", This
, p
);
690 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
691 if(NS_FAILED(nsres
)) {
692 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
696 nsres
= nsIDOMNSHTMLElement_GetOffsetTop(nselem
, &top
);
697 nsIDOMNSHTMLElement_Release(nselem
);
698 if(NS_FAILED(nsres
)) {
699 ERR("GetOffsetTop failed: %08x\n", nsres
);
707 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, long *p
)
709 HTMLElement
*This
= HTMLELEM_THIS(iface
);
710 nsIDOMNSHTMLElement
*nselem
;
714 TRACE("(%p)->(%p)\n", This
, p
);
716 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
717 if(NS_FAILED(nsres
)) {
718 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
722 nsres
= nsIDOMNSHTMLElement_GetOffsetWidth(nselem
, &offset
);
723 nsIDOMNSHTMLElement_Release(nselem
);
724 if(NS_FAILED(nsres
)) {
725 ERR("GetOffsetWidth failed: %08x\n", nsres
);
733 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, long *p
)
735 HTMLElement
*This
= HTMLELEM_THIS(iface
);
736 nsIDOMNSHTMLElement
*nselem
;
740 TRACE("(%p)->(%p)\n", This
, p
);
742 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
743 if(NS_FAILED(nsres
)) {
744 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
748 nsres
= nsIDOMNSHTMLElement_GetOffsetHeight(nselem
, &offset
);
749 nsIDOMNSHTMLElement_Release(nselem
);
750 if(NS_FAILED(nsres
)) {
751 ERR("GetOffsetHeight failed: %08x\n", nsres
);
759 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
761 HTMLElement
*This
= HTMLELEM_THIS(iface
);
762 FIXME("(%p)->(%p)\n", This
, p
);
766 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
768 HTMLElement
*This
= HTMLELEM_THIS(iface
);
769 nsIDOMNSHTMLElement
*nselem
;
773 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
776 FIXME("NULL nselem\n");
780 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
781 if(NS_FAILED(nsres
)) {
782 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
786 nsAString_Init(&html_str
, v
);
787 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
788 nsAString_Finish(&html_str
);
790 if(NS_FAILED(nsres
)) {
791 FIXME("SetInnerHtml failed %08x\n", nsres
);
798 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
800 HTMLElement
*This
= HTMLELEM_THIS(iface
);
801 FIXME("(%p)->(%p)\n", This
, p
);
805 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
807 HTMLElement
*This
= HTMLELEM_THIS(iface
);
808 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
812 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
814 HTMLElement
*This
= HTMLELEM_THIS(iface
);
815 FIXME("(%p)->(%p)\n", This
, p
);
819 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
821 HTMLElement
*This
= HTMLELEM_THIS(iface
);
822 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
826 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
828 HTMLElement
*This
= HTMLELEM_THIS(iface
);
829 FIXME("(%p)->(%p)\n", This
, p
);
833 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
835 HTMLElement
*This
= HTMLELEM_THIS(iface
);
836 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
840 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
842 HTMLElement
*This
= HTMLELEM_THIS(iface
);
843 FIXME("(%p)->(%p)\n", This
, p
);
847 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
849 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
850 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
851 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
852 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
856 FIXME("NULL nselem\n");
860 if (!strcmpiW(where
, wszBeforeBegin
))
864 nsres
= nsIDOMNode_GetParentNode(This
->nselem
, &parent
);
865 if (!parent
) return E_INVALIDARG
;
866 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
,
867 (nsIDOMNode
*)This
->nselem
, &unused
);
868 if (unused
) nsIDOMNode_Release(unused
);
869 nsIDOMNode_Release(parent
);
871 else if (!strcmpiW(where
, wszAfterBegin
))
874 nsIDOMNode
*first_child
;
875 nsIDOMNode_GetFirstChild(This
->nselem
, &first_child
);
876 nsres
= nsIDOMNode_InsertBefore(This
->nselem
, nsnode
, first_child
, &unused
);
877 if (unused
) nsIDOMNode_Release(unused
);
878 if (first_child
) nsIDOMNode_Release(first_child
);
880 else if (!strcmpiW(where
, wszBeforeEnd
))
883 nsres
= nsIDOMNode_AppendChild(This
->nselem
, nsnode
, &unused
);
884 if (unused
) nsIDOMNode_Release(unused
);
886 else if (!strcmpiW(where
, wszAfterEnd
))
889 nsIDOMNode
*next_sibling
;
891 nsIDOMNode_GetParentNode(This
->nselem
, &parent
);
892 if (!parent
) return E_INVALIDARG
;
894 nsIDOMNode_GetNextSibling(This
->nselem
, &next_sibling
);
897 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
898 nsIDOMNode_Release(next_sibling
);
901 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
902 nsIDOMNode_Release(parent
);
903 if (unused
) nsIDOMNode_Release(unused
);
907 ERR("invalid where: %s\n", debugstr_w(where
));
911 if (NS_FAILED(nsres
))
917 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
920 HTMLElement
*This
= HTMLELEM_THIS(iface
);
922 nsIDOMDocument
*nsdoc
;
923 nsIDOMDocumentRange
*nsdocrange
;
925 nsIDOMNSRange
*nsrange
;
930 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
932 nsres
= nsIWebNavigation_GetDocument(This
->node
.doc
->nscontainer
->navigation
, &nsdoc
);
935 ERR("GetDocument failed: %08x\n", nsres
);
939 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentRange
, (void **)&nsdocrange
);
940 nsIDOMDocument_Release(nsdoc
);
943 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres
);
946 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
947 nsIDOMDocumentRange_Release(nsdocrange
);
950 ERR("CreateRange failed: %08x\n", nsres
);
954 nsIDOMRange_SetStartBefore(range
, (nsIDOMNode
*)This
->nselem
);
956 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
957 nsIDOMRange_Release(range
);
960 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
964 nsAString_Init(&ns_html
, html
);
966 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
967 nsIDOMNSRange_Release(nsrange
);
968 nsAString_Finish(&ns_html
);
970 if(NS_FAILED(nsres
) || !nsnode
)
972 ERR("CreateTextNode failed: %08x\n", nsres
);
976 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
977 nsIDOMNode_Release(nsnode
);
982 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
985 HTMLElement
*This
= HTMLELEM_THIS(iface
);
987 nsIDOMDocument
*nsdoc
;
992 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
994 nsres
= nsIWebNavigation_GetDocument(This
->node
.doc
->nscontainer
->navigation
, &nsdoc
);
995 if(NS_FAILED(nsres
) || !nsdoc
)
997 ERR("GetDocument failed: %08x\n", nsres
);
1001 nsAString_Init(&ns_text
, text
);
1003 nsres
= nsIDOMDocument_CreateTextNode(nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1004 nsIDOMDocument_Release(nsdoc
);
1005 nsAString_Finish(&ns_text
);
1007 if(NS_FAILED(nsres
) || !nsnode
)
1009 ERR("CreateTextNode failed: %08x\n", nsres
);
1013 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1014 nsIDOMNode_Release(nsnode
);
1019 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1021 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1022 FIXME("(%p)->(%p)\n", This
, p
);
1026 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1028 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1029 FIXME("(%p)->(%p)\n", This
, p
);
1033 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1035 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1036 FIXME("(%p)\n", This
);
1040 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1041 IHTMLFiltersCollection
**p
)
1043 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1044 FIXME("(%p)->(%p)\n", This
, p
);
1048 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1050 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1051 FIXME("(%p)->()\n", This
);
1055 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1057 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1058 FIXME("(%p)->(%p)\n", This
, p
);
1062 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1064 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1065 FIXME("(%p)->(%p)\n", This
, String
);
1069 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1071 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1072 FIXME("(%p)->()\n", This
);
1076 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1078 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1079 FIXME("(%p)->(%p)\n", This
, p
);
1083 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1085 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1086 FIXME("(%p)->()\n", This
);
1090 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1092 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1093 FIXME("(%p)->(%p)\n", This
, p
);
1097 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1099 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1100 FIXME("(%p)->()\n", This
);
1104 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1106 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1107 FIXME("(%p)->(%p)\n", This
, p
);
1111 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1113 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1114 FIXME("(%p)->()\n", This
);
1118 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1120 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1121 FIXME("(%p)->(%p)\n", This
, p
);
1125 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1127 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1128 FIXME("(%p)->()\n", This
);
1132 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1134 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1135 FIXME("(%p)->(%p)\n", This
, p
);
1139 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1141 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1142 FIXME("(%p)->()\n", This
);
1146 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1148 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1149 FIXME("(%p)->(%p)\n", This
, p
);
1153 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1155 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1156 FIXME("(%p)->()\n", This
);
1160 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1162 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1163 FIXME("(%p)->(%p)\n", This
, p
);
1167 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1169 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1170 FIXME("(%p)->()\n", This
);
1174 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1176 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1177 FIXME("(%p)->(%p)\n", This
, p
);
1181 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1183 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1184 FIXME("(%p)->()\n", This
);
1188 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1190 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1191 FIXME("(%p)->(%p)\n", This
, p
);
1195 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1197 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1198 nsIDOMNodeList
*nsnode_list
;
1201 TRACE("(%p)->(%p)\n", This
, p
);
1203 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1204 if(NS_FAILED(nsres
)) {
1205 ERR("GetChildNodes failed: %08x\n", nsres
);
1209 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, (IUnknown
*)HTMLELEM(This
), nsnode_list
);
1211 nsIDOMNodeList_Release(nsnode_list
);
1215 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1217 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1219 TRACE("(%p)->(%p)\n", This
, p
);
1221 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1225 #undef HTMLELEM_THIS
1227 static const IHTMLElementVtbl HTMLElementVtbl
= {
1228 HTMLElement_QueryInterface
,
1230 HTMLElement_Release
,
1231 HTMLElement_GetTypeInfoCount
,
1232 HTMLElement_GetTypeInfo
,
1233 HTMLElement_GetIDsOfNames
,
1235 HTMLElement_setAttribute
,
1236 HTMLElement_getAttribute
,
1237 HTMLElement_removeAttribute
,
1238 HTMLElement_put_className
,
1239 HTMLElement_get_className
,
1242 HTMLElement_get_tagName
,
1243 HTMLElement_get_parentElement
,
1244 HTMLElement_get_style
,
1245 HTMLElement_put_onhelp
,
1246 HTMLElement_get_onhelp
,
1247 HTMLElement_put_onclick
,
1248 HTMLElement_get_onclick
,
1249 HTMLElement_put_ondblclick
,
1250 HTMLElement_get_ondblclick
,
1251 HTMLElement_put_onkeydown
,
1252 HTMLElement_get_onkeydown
,
1253 HTMLElement_put_onkeyup
,
1254 HTMLElement_get_onkeyup
,
1255 HTMLElement_put_onkeypress
,
1256 HTMLElement_get_onkeypress
,
1257 HTMLElement_put_onmouseout
,
1258 HTMLElement_get_onmouseout
,
1259 HTMLElement_put_onmouseover
,
1260 HTMLElement_get_onmouseover
,
1261 HTMLElement_put_onmousemove
,
1262 HTMLElement_get_onmousemove
,
1263 HTMLElement_put_onmousedown
,
1264 HTMLElement_get_onmousedown
,
1265 HTMLElement_put_onmouseup
,
1266 HTMLElement_get_onmouseup
,
1267 HTMLElement_get_document
,
1268 HTMLElement_put_title
,
1269 HTMLElement_get_title
,
1270 HTMLElement_put_language
,
1271 HTMLElement_get_language
,
1272 HTMLElement_put_onselectstart
,
1273 HTMLElement_get_onselectstart
,
1274 HTMLElement_scrollIntoView
,
1275 HTMLElement_contains
,
1276 HTMLElement_get_sourceIndex
,
1277 HTMLElement_get_recordNumber
,
1278 HTMLElement_put_lang
,
1279 HTMLElement_get_lang
,
1280 HTMLElement_get_offsetLeft
,
1281 HTMLElement_get_offsetTop
,
1282 HTMLElement_get_offsetWidth
,
1283 HTMLElement_get_offsetHeight
,
1284 HTMLElement_get_offsetParent
,
1285 HTMLElement_put_innerHTML
,
1286 HTMLElement_get_innerHTML
,
1287 HTMLElement_put_innerText
,
1288 HTMLElement_get_innerText
,
1289 HTMLElement_put_outerHTML
,
1290 HTMLElement_get_outerHTML
,
1291 HTMLElement_put_outerText
,
1292 HTMLElement_get_outerText
,
1293 HTMLElement_insertAdjacentHTML
,
1294 HTMLElement_insertAdjacentText
,
1295 HTMLElement_get_parentTextEdit
,
1296 HTMLElement_get_isTextEdit
,
1298 HTMLElement_get_filters
,
1299 HTMLElement_put_ondragstart
,
1300 HTMLElement_get_ondragstart
,
1301 HTMLElement_toString
,
1302 HTMLElement_put_onbeforeupdate
,
1303 HTMLElement_get_onbeforeupdate
,
1304 HTMLElement_put_onafterupdate
,
1305 HTMLElement_get_onafterupdate
,
1306 HTMLElement_put_onerrorupdate
,
1307 HTMLElement_get_onerrorupdate
,
1308 HTMLElement_put_onrowexit
,
1309 HTMLElement_get_onrowexit
,
1310 HTMLElement_put_onrowenter
,
1311 HTMLElement_get_onrowenter
,
1312 HTMLElement_put_ondatasetchanged
,
1313 HTMLElement_get_ondatasetchanged
,
1314 HTMLElement_put_ondataavailable
,
1315 HTMLElement_get_ondataavailable
,
1316 HTMLElement_put_ondatasetcomplete
,
1317 HTMLElement_get_ondatasetcomplete
,
1318 HTMLElement_put_onfilterchange
,
1319 HTMLElement_get_onfilterchange
,
1320 HTMLElement_get_children
,
1324 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1326 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1330 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1331 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1332 *ppv
= HTMLELEM(This
);
1333 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1334 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1335 *ppv
= HTMLELEM(This
);
1336 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1337 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1338 *ppv
= HTMLELEM(This
);
1339 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1340 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1341 *ppv
= HTMLELEM2(This
);
1342 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1343 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1344 *ppv
= HTMLELEM3(This
);
1345 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1346 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1347 *ppv
= CONPTCONT(&This
->cp_container
);
1351 IHTMLElement_AddRef(HTMLELEM(This
));
1355 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1358 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1360 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1362 ConnectionPointContainer_Destroy(&This
->cp_container
);
1365 nsIDOMHTMLElement_Release(This
->nselem
);
1367 HTMLDOMNode_destructor(&This
->node
);
1370 static const NodeImplVtbl HTMLElementImplVtbl
= {
1372 HTMLElement_destructor
1375 static const tid_t HTMLElement_iface_tids
[] = {
1383 static dispex_static_data_t HTMLElement_dispex
= {
1385 DispHTMLUnknownElement_tid
,
1387 HTMLElement_iface_tids
1390 void HTMLElement_Init(HTMLElement
*This
)
1392 This
->lpHTMLElementVtbl
= &HTMLElementVtbl
;
1394 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)HTMLELEM(This
));
1396 HTMLElement2_Init(This
);
1397 HTMLElement3_Init(This
);
1399 if(!This
->node
.dispex
.data
)
1400 init_dispex(&This
->node
.dispex
, (IUnknown
*)HTMLELEM(This
), &HTMLElement_dispex
);
1403 HTMLElement
*HTMLElement_Create(HTMLDocument
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
)
1405 nsIDOMHTMLElement
*nselem
;
1406 HTMLElement
*ret
= NULL
;
1407 nsAString class_name_str
;
1408 const PRUnichar
*class_name
;
1411 static const WCHAR wszA
[] = {'A',0};
1412 static const WCHAR wszBODY
[] = {'B','O','D','Y',0};
1413 static const WCHAR wszIFRAME
[] = {'I','F','R','A','M','E',0};
1414 static const WCHAR wszIMG
[] = {'I','M','G',0};
1415 static const WCHAR wszINPUT
[] = {'I','N','P','U','T',0};
1416 static const WCHAR wszOPTION
[] = {'O','P','T','I','O','N',0};
1417 static const WCHAR wszSCRIPT
[] = {'S','C','R','I','P','T',0};
1418 static const WCHAR wszSELECT
[] = {'S','E','L','E','C','T',0};
1419 static const WCHAR wszTABLE
[] = {'T','A','B','L','E',0};
1420 static const WCHAR wszTR
[] = {'T','R',0};
1421 static const WCHAR wszTEXTAREA
[] = {'T','E','X','T','A','R','E','A',0};
1423 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1424 if(NS_FAILED(nsres
))
1427 nsAString_Init(&class_name_str
, NULL
);
1428 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1430 nsAString_GetData(&class_name_str
, &class_name
);
1432 if(!strcmpW(class_name
, wszA
))
1433 ret
= HTMLAnchorElement_Create(nselem
);
1434 else if(!strcmpW(class_name
, wszBODY
))
1435 ret
= HTMLBodyElement_Create(nselem
);
1436 else if(!strcmpW(class_name
, wszIFRAME
))
1437 ret
= HTMLIFrame_Create(nselem
);
1438 else if(!strcmpW(class_name
, wszIMG
))
1439 ret
= HTMLImgElement_Create(nselem
);
1440 else if(!strcmpW(class_name
, wszINPUT
))
1441 ret
= HTMLInputElement_Create(nselem
);
1442 else if(!strcmpW(class_name
, wszOPTION
))
1443 ret
= HTMLOptionElement_Create(nselem
);
1444 else if(!strcmpW(class_name
, wszSCRIPT
))
1445 ret
= HTMLScriptElement_Create(nselem
);
1446 else if(!strcmpW(class_name
, wszSELECT
))
1447 ret
= HTMLSelectElement_Create(nselem
);
1448 else if(!strcmpW(class_name
, wszTABLE
))
1449 ret
= HTMLTable_Create(nselem
);
1450 else if(!strcmpW(class_name
, wszTR
))
1451 ret
= HTMLTableRow_Create(nselem
);
1452 else if(!strcmpW(class_name
, wszTEXTAREA
))
1453 ret
= HTMLTextAreaElement_Create(nselem
);
1454 else if(use_generic
)
1455 ret
= HTMLGenericElement_Create(nselem
);
1458 ret
= heap_alloc_zero(sizeof(HTMLElement
));
1459 HTMLElement_Init(ret
);
1460 ret
->node
.vtbl
= &HTMLElementImplVtbl
;
1463 TRACE("%s ret %p\n", debugstr_w(class_name
), ret
);
1465 nsAString_Finish(&class_name_str
);
1467 ret
->nselem
= nselem
;
1468 HTMLDOMNode_Init(doc
, &ret
->node
, (nsIDOMNode
*)nselem
);