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
);
44 static void elem_vector_add(elem_vector
*buf
, HTMLElement
*elem
)
46 if(buf
->len
== buf
->size
) {
48 buf
->buf
= heap_realloc(buf
->buf
, buf
->size
*sizeof(HTMLElement
**));
51 buf
->buf
[buf
->len
++] = elem
;
54 static void elem_vector_normalize(elem_vector
*buf
)
59 }else if(buf
->size
> buf
->len
) {
60 buf
->buf
= heap_realloc(buf
->buf
, buf
->len
*sizeof(HTMLElement
**));
66 static BOOL
is_elem_node(nsIDOMNode
*node
)
70 nsIDOMNode_GetNodeType(node
, &type
);
72 return type
== ELEMENT_NODE
|| type
== COMMENT_NODE
;
75 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
77 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
79 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
80 REFIID riid
, void **ppv
)
82 HTMLElement
*This
= HTMLELEM_THIS(iface
);
84 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->node
), riid
, ppv
);
87 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
89 HTMLElement
*This
= HTMLELEM_THIS(iface
);
91 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->node
));
94 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
96 HTMLElement
*This
= HTMLELEM_THIS(iface
);
98 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->node
));
101 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
103 HTMLElement
*This
= HTMLELEM_THIS(iface
);
104 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->node
.dispex
), pctinfo
);
107 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
108 LCID lcid
, ITypeInfo
**ppTInfo
)
110 HTMLElement
*This
= HTMLELEM_THIS(iface
);
111 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->node
.dispex
), iTInfo
, lcid
, ppTInfo
);
114 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
115 LPOLESTR
*rgszNames
, UINT cNames
,
116 LCID lcid
, DISPID
*rgDispId
)
118 HTMLElement
*This
= HTMLELEM_THIS(iface
);
119 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
122 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
123 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
124 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
126 HTMLElement
*This
= HTMLELEM_THIS(iface
);
127 return IDispatchEx_Invoke(DISPATCHEX(&This
->node
.dispex
), dispIdMember
, riid
, lcid
,
128 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
131 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
132 VARIANT AttributeValue
, LONG lFlags
)
134 HTMLElement
*This
= HTMLELEM_THIS(iface
);
139 VARIANT AttributeValueChanged
;
141 WARN("(%p)->(%s . %08x)\n", This
, debugstr_w(strAttributeName
), lFlags
);
144 FIXME("NULL nselem\n");
148 VariantInit(&AttributeValueChanged
);
150 hres
= VariantChangeType(&AttributeValueChanged
, &AttributeValue
, 0, VT_BSTR
);
152 WARN("couldn't convert input attribute value %d to VT_BSTR\n", V_VT(&AttributeValue
));
156 nsAString_Init(&attr_str
, strAttributeName
);
157 nsAString_Init(&value_str
, V_BSTR(&AttributeValueChanged
));
159 TRACE("setting %s to %s\n", debugstr_w(strAttributeName
),
160 debugstr_w(V_BSTR(&AttributeValueChanged
)));
162 nsres
= nsIDOMHTMLElement_SetAttribute(This
->nselem
, &attr_str
, &value_str
);
163 nsAString_Finish(&attr_str
);
164 nsAString_Finish(&value_str
);
166 if(NS_SUCCEEDED(nsres
)) {
169 ERR("SetAttribute failed: %08x\n", nsres
);
176 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
177 LONG lFlags
, VARIANT
*AttributeValue
)
179 HTMLElement
*This
= HTMLELEM_THIS(iface
);
182 const PRUnichar
*value
;
186 WARN("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
189 FIXME("NULL nselem\n");
190 V_VT(AttributeValue
) = VT_NULL
;
194 V_VT(AttributeValue
) = VT_NULL
;
196 nsAString_Init(&attr_str
, strAttributeName
);
197 nsAString_Init(&value_str
, NULL
);
199 nsres
= nsIDOMHTMLElement_GetAttribute(This
->nselem
, &attr_str
, &value_str
);
200 nsAString_Finish(&attr_str
);
202 if(NS_SUCCEEDED(nsres
)) {
203 static const WCHAR wszSRC
[] = {'s','r','c',0};
204 nsAString_GetData(&value_str
, &value
);
205 if(!strcmpiW(strAttributeName
, wszSRC
))
210 hres
= IHTMLDocument2_get_URL(HTMLDOC(This
->node
.doc
), &bstrBaseUrl
);
211 if(SUCCEEDED(hres
)) {
212 hres
= CoInternetCombineUrl(bstrBaseUrl
, value
,
213 URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
214 buffer
, sizeof(buffer
)/sizeof(WCHAR
), &len
, 0);
215 SysFreeString(bstrBaseUrl
);
216 if(SUCCEEDED(hres
)) {
217 V_VT(AttributeValue
) = VT_BSTR
;
218 V_BSTR(AttributeValue
) = SysAllocString(buffer
);
219 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue
)));
223 V_VT(AttributeValue
) = VT_BSTR
;
224 V_BSTR(AttributeValue
) = SysAllocString(value
);
225 TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue
)));
228 ERR("GetAttribute failed: %08x\n", nsres
);
232 nsAString_Finish(&value_str
);
237 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
238 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
240 HTMLElement
*This
= HTMLELEM_THIS(iface
);
241 FIXME("(%p)->()\n", This
);
245 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
247 HTMLElement
*This
= HTMLELEM_THIS(iface
);
248 nsAString classname_str
;
251 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
254 FIXME("NULL nselem\n");
258 nsAString_Init(&classname_str
, v
);
259 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
260 nsAString_Finish(&classname_str
);
262 ERR("SetClassName failed: %08x\n", nsres
);
267 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
269 HTMLElement
*This
= HTMLELEM_THIS(iface
);
274 TRACE("(%p)->(%p)\n", This
, p
);
277 FIXME("NULL nselem\n");
281 nsAString_Init(&class_str
, NULL
);
282 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
284 if(NS_SUCCEEDED(nsres
)) {
285 const PRUnichar
*class;
286 nsAString_GetData(&class_str
, &class);
287 *p
= *class ? SysAllocString(class) : NULL
;
289 ERR("GetClassName failed: %08x\n", nsres
);
293 nsAString_Finish(&class_str
);
295 TRACE("className=%s\n", debugstr_w(*p
));
299 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
301 HTMLElement
*This
= HTMLELEM_THIS(iface
);
305 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
308 FIXME("nselem == NULL\n");
312 nsAString_Init(&id_str
, v
);
313 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
314 nsAString_Finish(&id_str
);
316 ERR("SetId failed: %08x\n", nsres
);
321 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
323 HTMLElement
*This
= HTMLELEM_THIS(iface
);
328 TRACE("(%p)->(%p)\n", This
, p
);
335 nsAString_Init(&id_str
, NULL
);
336 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
337 nsAString_GetData(&id_str
, &id
);
340 ERR("GetId failed: %08x\n", nsres
);
342 *p
= SysAllocString(id
);
344 nsAString_Finish(&id_str
);
348 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
350 HTMLElement
*This
= HTMLELEM_THIS(iface
);
351 const PRUnichar
*tag
;
355 TRACE("(%p)->(%p)\n", This
, p
);
358 static const WCHAR comment_tagW
[] = {'!',0};
360 WARN("NULL nselem, assuming comment\n");
362 *p
= SysAllocString(comment_tagW
);
366 nsAString_Init(&tag_str
, NULL
);
367 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
368 if(NS_SUCCEEDED(nsres
)) {
369 nsAString_GetData(&tag_str
, &tag
);
370 *p
= SysAllocString(tag
);
372 ERR("GetTagName failed: %08x\n", nsres
);
375 nsAString_Finish(&tag_str
);
380 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
382 HTMLElement
*This
= HTMLELEM_THIS(iface
);
386 TRACE("(%p)->(%p)\n", This
, p
);
388 hres
= IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This
->node
), &node
);
392 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
393 IHTMLDOMNode_Release(node
);
400 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
402 HTMLElement
*This
= HTMLELEM_THIS(iface
);
403 nsIDOMElementCSSInlineStyle
*nselemstyle
;
404 nsIDOMCSSStyleDeclaration
*nsstyle
;
407 TRACE("(%p)->(%p)\n", This
, p
);
410 FIXME("NULL nselem\n");
414 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMElementCSSInlineStyle
,
415 (void**)&nselemstyle
);
416 if(NS_FAILED(nsres
)) {
417 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres
);
421 nsres
= nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle
, &nsstyle
);
422 nsIDOMElementCSSInlineStyle_Release(nselemstyle
);
423 if(NS_FAILED(nsres
)) {
424 ERR("GetStyle failed: %08x\n", nsres
);
428 /* FIXME: Store style instead of creating a new instance in each call */
429 *p
= HTMLStyle_Create(nsstyle
);
431 nsIDOMCSSStyleDeclaration_Release(nsstyle
);
435 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
437 HTMLElement
*This
= HTMLELEM_THIS(iface
);
438 FIXME("(%p)->()\n", This
);
442 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
444 HTMLElement
*This
= HTMLELEM_THIS(iface
);
445 FIXME("(%p)->(%p)\n", This
, p
);
449 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
451 HTMLElement
*This
= HTMLELEM_THIS(iface
);
453 TRACE("(%p)->()\n", This
);
455 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
458 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
460 HTMLElement
*This
= HTMLELEM_THIS(iface
);
461 FIXME("(%p)->(%p)\n", This
, p
);
465 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
467 HTMLElement
*This
= HTMLELEM_THIS(iface
);
468 FIXME("(%p)->()\n", This
);
472 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
474 HTMLElement
*This
= HTMLELEM_THIS(iface
);
475 FIXME("(%p)->(%p)\n", This
, p
);
479 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
481 HTMLElement
*This
= HTMLELEM_THIS(iface
);
482 FIXME("(%p)->()\n", This
);
486 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
488 HTMLElement
*This
= HTMLELEM_THIS(iface
);
489 FIXME("(%p)->(%p)\n", This
, p
);
493 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
495 HTMLElement
*This
= HTMLELEM_THIS(iface
);
497 TRACE("(%p)->()\n", This
);
499 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
502 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
504 HTMLElement
*This
= HTMLELEM_THIS(iface
);
505 FIXME("(%p)->(%p)\n", This
, p
);
509 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
511 HTMLElement
*This
= HTMLELEM_THIS(iface
);
512 FIXME("(%p)->()\n", This
);
516 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
518 HTMLElement
*This
= HTMLELEM_THIS(iface
);
519 FIXME("(%p)->(%p)\n", This
, p
);
523 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
525 HTMLElement
*This
= HTMLELEM_THIS(iface
);
526 FIXME("(%p)->()\n", This
);
530 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
532 HTMLElement
*This
= HTMLELEM_THIS(iface
);
533 FIXME("(%p)->(%p)\n", This
, p
);
537 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
539 HTMLElement
*This
= HTMLELEM_THIS(iface
);
540 FIXME("(%p)->()\n", This
);
544 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
546 HTMLElement
*This
= HTMLELEM_THIS(iface
);
547 FIXME("(%p)->(%p)\n", This
, p
);
551 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
553 HTMLElement
*This
= HTMLELEM_THIS(iface
);
554 FIXME("(%p)->()\n", This
);
558 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
560 HTMLElement
*This
= HTMLELEM_THIS(iface
);
561 FIXME("(%p)->(%p)\n", This
, p
);
565 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
567 HTMLElement
*This
= HTMLELEM_THIS(iface
);
568 FIXME("(%p)->()\n", This
);
572 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
574 HTMLElement
*This
= HTMLELEM_THIS(iface
);
575 FIXME("(%p)->(%p)\n", This
, p
);
579 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
581 HTMLElement
*This
= HTMLELEM_THIS(iface
);
582 FIXME("(%p)->()\n", This
);
586 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
588 HTMLElement
*This
= HTMLELEM_THIS(iface
);
589 FIXME("(%p)->(%p)\n", This
, p
);
593 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
595 HTMLElement
*This
= HTMLELEM_THIS(iface
);
596 FIXME("(%p)->(%p)\n", This
, p
);
600 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
602 HTMLElement
*This
= HTMLELEM_THIS(iface
);
606 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
608 nsAString_Init(&title_str
, v
);
609 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
610 nsAString_Finish(&title_str
);
612 ERR("SetTitle failed: %08x\n", nsres
);
617 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
619 HTMLElement
*This
= HTMLELEM_THIS(iface
);
623 TRACE("(%p)->(%p)\n", This
, p
);
625 nsAString_Init(&title_str
, NULL
);
626 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
627 if(NS_SUCCEEDED(nsres
)) {
628 const PRUnichar
*title
;
630 nsAString_GetData(&title_str
, &title
);
631 *p
= *title
? SysAllocString(title
) : NULL
;
633 ERR("GetTitle failed: %08x\n", nsres
);
640 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
642 HTMLElement
*This
= HTMLELEM_THIS(iface
);
643 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
647 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
649 HTMLElement
*This
= HTMLELEM_THIS(iface
);
650 FIXME("(%p)->(%p)\n", This
, p
);
654 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
656 HTMLElement
*This
= HTMLELEM_THIS(iface
);
657 FIXME("(%p)->()\n", This
);
661 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
663 HTMLElement
*This
= HTMLELEM_THIS(iface
);
664 FIXME("(%p)->(%p)\n", This
, p
);
668 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
670 HTMLElement
*This
= HTMLELEM_THIS(iface
);
671 FIXME("(%p)->()\n", This
);
675 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
676 VARIANT_BOOL
*pfResult
)
678 HTMLElement
*This
= HTMLELEM_THIS(iface
);
679 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
683 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, long *p
)
685 HTMLElement
*This
= HTMLELEM_THIS(iface
);
686 FIXME("(%p)->(%p)\n", This
, p
);
690 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
692 HTMLElement
*This
= HTMLELEM_THIS(iface
);
693 FIXME("(%p)->(%p)\n", This
, p
);
697 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
699 HTMLElement
*This
= HTMLELEM_THIS(iface
);
700 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
704 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
706 HTMLElement
*This
= HTMLELEM_THIS(iface
);
707 FIXME("(%p)->(%p)\n", This
, p
);
711 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, long *p
)
713 HTMLElement
*This
= HTMLELEM_THIS(iface
);
714 FIXME("(%p)->(%p)\n", This
, p
);
718 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, long *p
)
720 HTMLElement
*This
= HTMLELEM_THIS(iface
);
721 nsIDOMNSHTMLElement
*nselem
;
725 TRACE("(%p)->(%p)\n", This
, p
);
727 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
728 if(NS_FAILED(nsres
)) {
729 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
733 nsres
= nsIDOMNSHTMLElement_GetOffsetTop(nselem
, &top
);
734 nsIDOMNSHTMLElement_Release(nselem
);
735 if(NS_FAILED(nsres
)) {
736 ERR("GetOffsetTop failed: %08x\n", nsres
);
744 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, long *p
)
746 HTMLElement
*This
= HTMLELEM_THIS(iface
);
747 FIXME("(%p)->(%p)\n", This
, p
);
751 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, long *p
)
753 HTMLElement
*This
= HTMLELEM_THIS(iface
);
754 nsIDOMNSHTMLElement
*nselem
;
758 TRACE("(%p)->(%p)\n", This
, p
);
760 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
761 if(NS_FAILED(nsres
)) {
762 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
766 nsres
= nsIDOMNSHTMLElement_GetOffsetHeight(nselem
, &offset
);
767 nsIDOMNSHTMLElement_Release(nselem
);
768 if(NS_FAILED(nsres
)) {
769 ERR("GetOffsetHeight failed: %08x\n", nsres
);
777 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
779 HTMLElement
*This
= HTMLELEM_THIS(iface
);
780 FIXME("(%p)->(%p)\n", This
, p
);
784 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
786 HTMLElement
*This
= HTMLELEM_THIS(iface
);
787 nsIDOMNSHTMLElement
*nselem
;
791 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
794 FIXME("NULL nselem\n");
798 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
799 if(NS_FAILED(nsres
)) {
800 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
804 nsAString_Init(&html_str
, v
);
805 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
806 nsAString_Finish(&html_str
);
808 if(NS_FAILED(nsres
)) {
809 FIXME("SetInnerHtml failed %08x\n", nsres
);
816 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
818 HTMLElement
*This
= HTMLELEM_THIS(iface
);
819 FIXME("(%p)->(%p)\n", This
, p
);
823 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
825 HTMLElement
*This
= HTMLELEM_THIS(iface
);
826 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
830 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
832 HTMLElement
*This
= HTMLELEM_THIS(iface
);
833 FIXME("(%p)->(%p)\n", This
, p
);
837 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
839 HTMLElement
*This
= HTMLELEM_THIS(iface
);
840 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
844 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
846 HTMLElement
*This
= HTMLELEM_THIS(iface
);
847 FIXME("(%p)->(%p)\n", This
, p
);
851 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
853 HTMLElement
*This
= HTMLELEM_THIS(iface
);
854 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
858 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
860 HTMLElement
*This
= HTMLELEM_THIS(iface
);
861 FIXME("(%p)->(%p)\n", This
, p
);
865 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
867 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
868 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
869 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
870 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
874 FIXME("NULL nselem\n");
878 if (!strcmpiW(where
, wszBeforeBegin
))
882 nsres
= nsIDOMNode_GetParentNode(This
->nselem
, &parent
);
883 if (!parent
) return E_INVALIDARG
;
884 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
,
885 (nsIDOMNode
*)This
->nselem
, &unused
);
886 if (unused
) nsIDOMNode_Release(unused
);
887 nsIDOMNode_Release(parent
);
889 else if (!strcmpiW(where
, wszAfterBegin
))
892 nsIDOMNode
*first_child
;
893 nsIDOMNode_GetFirstChild(This
->nselem
, &first_child
);
894 nsres
= nsIDOMNode_InsertBefore(This
->nselem
, nsnode
, first_child
, &unused
);
895 if (unused
) nsIDOMNode_Release(unused
);
896 if (first_child
) nsIDOMNode_Release(first_child
);
898 else if (!strcmpiW(where
, wszBeforeEnd
))
901 nsres
= nsIDOMNode_AppendChild(This
->nselem
, nsnode
, &unused
);
902 if (unused
) nsIDOMNode_Release(unused
);
904 else if (!strcmpiW(where
, wszAfterEnd
))
907 nsIDOMNode
*next_sibling
;
909 nsIDOMNode_GetParentNode(This
->nselem
, &parent
);
910 if (!parent
) return E_INVALIDARG
;
912 nsIDOMNode_GetNextSibling(This
->nselem
, &next_sibling
);
915 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
916 nsIDOMNode_Release(next_sibling
);
919 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
920 nsIDOMNode_Release(parent
);
921 if (unused
) nsIDOMNode_Release(unused
);
925 ERR("invalid where: %s\n", debugstr_w(where
));
929 if (NS_FAILED(nsres
))
935 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
938 HTMLElement
*This
= HTMLELEM_THIS(iface
);
940 nsIDOMDocument
*nsdoc
;
941 nsIDOMDocumentRange
*nsdocrange
;
943 nsIDOMNSRange
*nsrange
;
948 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
950 nsres
= nsIWebNavigation_GetDocument(This
->node
.doc
->nscontainer
->navigation
, &nsdoc
);
953 ERR("GetDocument failed: %08x\n", nsres
);
957 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentRange
, (void **)&nsdocrange
);
958 nsIDOMDocument_Release(nsdoc
);
961 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres
);
964 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
965 nsIDOMDocumentRange_Release(nsdocrange
);
968 ERR("CreateRange failed: %08x\n", nsres
);
972 nsIDOMRange_SetStartBefore(range
, (nsIDOMNode
*)This
->nselem
);
974 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
975 nsIDOMRange_Release(range
);
978 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
982 nsAString_Init(&ns_html
, html
);
984 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
985 nsIDOMNSRange_Release(nsrange
);
986 nsAString_Finish(&ns_html
);
988 if(NS_FAILED(nsres
) || !nsnode
)
990 ERR("CreateTextNode failed: %08x\n", nsres
);
994 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
995 nsIDOMNode_Release(nsnode
);
1000 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1003 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1005 nsIDOMDocument
*nsdoc
;
1010 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1012 nsres
= nsIWebNavigation_GetDocument(This
->node
.doc
->nscontainer
->navigation
, &nsdoc
);
1013 if(NS_FAILED(nsres
) || !nsdoc
)
1015 ERR("GetDocument failed: %08x\n", nsres
);
1019 nsAString_Init(&ns_text
, text
);
1021 nsres
= nsIDOMDocument_CreateTextNode(nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1022 nsIDOMDocument_Release(nsdoc
);
1023 nsAString_Finish(&ns_text
);
1025 if(NS_FAILED(nsres
) || !nsnode
)
1027 ERR("CreateTextNode failed: %08x\n", nsres
);
1031 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1032 nsIDOMNode_Release(nsnode
);
1037 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1039 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1040 FIXME("(%p)->(%p)\n", This
, p
);
1044 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1046 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1047 FIXME("(%p)->(%p)\n", This
, p
);
1051 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1053 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1054 FIXME("(%p)\n", This
);
1058 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1059 IHTMLFiltersCollection
**p
)
1061 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1062 FIXME("(%p)->(%p)\n", This
, p
);
1066 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1068 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1069 FIXME("(%p)->()\n", This
);
1073 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1075 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1076 FIXME("(%p)->(%p)\n", This
, p
);
1080 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1082 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1083 FIXME("(%p)->(%p)\n", This
, String
);
1087 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1089 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1090 FIXME("(%p)->()\n", This
);
1094 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1096 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1097 FIXME("(%p)->(%p)\n", This
, p
);
1101 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1103 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1104 FIXME("(%p)->()\n", This
);
1108 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1110 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1111 FIXME("(%p)->(%p)\n", This
, p
);
1115 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1117 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1118 FIXME("(%p)->()\n", This
);
1122 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1124 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1125 FIXME("(%p)->(%p)\n", This
, p
);
1129 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1131 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1132 FIXME("(%p)->()\n", This
);
1136 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1138 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1139 FIXME("(%p)->(%p)\n", This
, p
);
1143 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1145 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1146 FIXME("(%p)->()\n", This
);
1150 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1152 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1153 FIXME("(%p)->(%p)\n", This
, p
);
1157 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1159 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1160 FIXME("(%p)->()\n", This
);
1164 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1166 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1167 FIXME("(%p)->(%p)\n", This
, p
);
1171 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1173 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1174 FIXME("(%p)->()\n", This
);
1178 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1180 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1181 FIXME("(%p)->(%p)\n", This
, p
);
1185 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1187 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1188 FIXME("(%p)->()\n", This
);
1192 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1194 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1195 FIXME("(%p)->(%p)\n", This
, p
);
1199 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1201 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1202 FIXME("(%p)->()\n", This
);
1206 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1208 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1209 FIXME("(%p)->(%p)\n", This
, p
);
1213 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1215 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1216 nsIDOMNodeList
*nsnode_list
;
1219 TRACE("(%p)->(%p)\n", This
, p
);
1221 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1222 if(NS_FAILED(nsres
)) {
1223 ERR("GetChildNodes failed: %08x\n", nsres
);
1227 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, (IUnknown
*)HTMLELEM(This
), nsnode_list
);
1229 nsIDOMNodeList_Release(nsnode_list
);
1233 static void create_all_list(HTMLDocument
*doc
, HTMLDOMNode
*elem
, elem_vector
*buf
)
1235 nsIDOMNodeList
*nsnode_list
;
1237 PRUint32 list_len
= 0, i
;
1240 nsres
= nsIDOMNode_GetChildNodes(elem
->nsnode
, &nsnode_list
);
1241 if(NS_FAILED(nsres
)) {
1242 ERR("GetChildNodes failed: %08x\n", nsres
);
1246 nsIDOMNodeList_GetLength(nsnode_list
, &list_len
);
1250 for(i
=0; i
<list_len
; i
++) {
1251 nsres
= nsIDOMNodeList_Item(nsnode_list
, i
, &iter
);
1252 if(NS_FAILED(nsres
)) {
1253 ERR("Item failed: %08x\n", nsres
);
1257 if(is_elem_node(iter
)) {
1258 HTMLDOMNode
*node
= get_node(doc
, iter
, TRUE
);
1260 elem_vector_add(buf
, HTMLELEM_NODE_THIS(node
));
1261 create_all_list(doc
, node
, buf
);
1266 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1268 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1269 elem_vector buf
= {NULL
, 0, 8};
1271 TRACE("(%p)->(%p)\n", This
, p
);
1273 buf
.buf
= heap_alloc(buf
.size
*sizeof(HTMLElement
**));
1275 create_all_list(This
->node
.doc
, &This
->node
, &buf
);
1276 elem_vector_normalize(&buf
);
1278 *p
= (IDispatch
*)HTMLElementCollection_Create((IUnknown
*)HTMLELEM(This
), buf
.buf
, buf
.len
);
1282 #undef HTMLELEM_THIS
1284 static const IHTMLElementVtbl HTMLElementVtbl
= {
1285 HTMLElement_QueryInterface
,
1287 HTMLElement_Release
,
1288 HTMLElement_GetTypeInfoCount
,
1289 HTMLElement_GetTypeInfo
,
1290 HTMLElement_GetIDsOfNames
,
1292 HTMLElement_setAttribute
,
1293 HTMLElement_getAttribute
,
1294 HTMLElement_removeAttribute
,
1295 HTMLElement_put_className
,
1296 HTMLElement_get_className
,
1299 HTMLElement_get_tagName
,
1300 HTMLElement_get_parentElement
,
1301 HTMLElement_get_style
,
1302 HTMLElement_put_onhelp
,
1303 HTMLElement_get_onhelp
,
1304 HTMLElement_put_onclick
,
1305 HTMLElement_get_onclick
,
1306 HTMLElement_put_ondblclick
,
1307 HTMLElement_get_ondblclick
,
1308 HTMLElement_put_onkeydown
,
1309 HTMLElement_get_onkeydown
,
1310 HTMLElement_put_onkeyup
,
1311 HTMLElement_get_onkeyup
,
1312 HTMLElement_put_onkeypress
,
1313 HTMLElement_get_onkeypress
,
1314 HTMLElement_put_onmouseout
,
1315 HTMLElement_get_onmouseout
,
1316 HTMLElement_put_onmouseover
,
1317 HTMLElement_get_onmouseover
,
1318 HTMLElement_put_onmousemove
,
1319 HTMLElement_get_onmousemove
,
1320 HTMLElement_put_onmousedown
,
1321 HTMLElement_get_onmousedown
,
1322 HTMLElement_put_onmouseup
,
1323 HTMLElement_get_onmouseup
,
1324 HTMLElement_get_document
,
1325 HTMLElement_put_title
,
1326 HTMLElement_get_title
,
1327 HTMLElement_put_language
,
1328 HTMLElement_get_language
,
1329 HTMLElement_put_onselectstart
,
1330 HTMLElement_get_onselectstart
,
1331 HTMLElement_scrollIntoView
,
1332 HTMLElement_contains
,
1333 HTMLElement_get_sourceIndex
,
1334 HTMLElement_get_recordNumber
,
1335 HTMLElement_put_lang
,
1336 HTMLElement_get_lang
,
1337 HTMLElement_get_offsetLeft
,
1338 HTMLElement_get_offsetTop
,
1339 HTMLElement_get_offsetWidth
,
1340 HTMLElement_get_offsetHeight
,
1341 HTMLElement_get_offsetParent
,
1342 HTMLElement_put_innerHTML
,
1343 HTMLElement_get_innerHTML
,
1344 HTMLElement_put_innerText
,
1345 HTMLElement_get_innerText
,
1346 HTMLElement_put_outerHTML
,
1347 HTMLElement_get_outerHTML
,
1348 HTMLElement_put_outerText
,
1349 HTMLElement_get_outerText
,
1350 HTMLElement_insertAdjacentHTML
,
1351 HTMLElement_insertAdjacentText
,
1352 HTMLElement_get_parentTextEdit
,
1353 HTMLElement_get_isTextEdit
,
1355 HTMLElement_get_filters
,
1356 HTMLElement_put_ondragstart
,
1357 HTMLElement_get_ondragstart
,
1358 HTMLElement_toString
,
1359 HTMLElement_put_onbeforeupdate
,
1360 HTMLElement_get_onbeforeupdate
,
1361 HTMLElement_put_onafterupdate
,
1362 HTMLElement_get_onafterupdate
,
1363 HTMLElement_put_onerrorupdate
,
1364 HTMLElement_get_onerrorupdate
,
1365 HTMLElement_put_onrowexit
,
1366 HTMLElement_get_onrowexit
,
1367 HTMLElement_put_onrowenter
,
1368 HTMLElement_get_onrowenter
,
1369 HTMLElement_put_ondatasetchanged
,
1370 HTMLElement_get_ondatasetchanged
,
1371 HTMLElement_put_ondataavailable
,
1372 HTMLElement_get_ondataavailable
,
1373 HTMLElement_put_ondatasetcomplete
,
1374 HTMLElement_get_ondatasetcomplete
,
1375 HTMLElement_put_onfilterchange
,
1376 HTMLElement_get_onfilterchange
,
1377 HTMLElement_get_children
,
1381 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1383 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1387 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1388 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1389 *ppv
= HTMLELEM(This
);
1390 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1391 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1392 *ppv
= HTMLELEM(This
);
1393 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1394 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1395 *ppv
= HTMLELEM(This
);
1396 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1397 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1398 *ppv
= HTMLELEM2(This
);
1399 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1400 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1401 *ppv
= CONPTCONT(&This
->cp_container
);
1405 IHTMLElement_AddRef(HTMLELEM(This
));
1409 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1412 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1414 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1416 ConnectionPointContainer_Destroy(&This
->cp_container
);
1419 nsIDOMHTMLElement_Release(This
->nselem
);
1421 HTMLDOMNode_destructor(&This
->node
);
1424 static const NodeImplVtbl HTMLElementImplVtbl
= {
1426 HTMLElement_destructor
1429 static const tid_t HTMLElement_iface_tids
[] = {
1437 static dispex_static_data_t HTMLElement_dispex
= {
1439 DispHTMLUnknownElement_tid
,
1441 HTMLElement_iface_tids
1444 void HTMLElement_Init(HTMLElement
*This
)
1446 This
->lpHTMLElementVtbl
= &HTMLElementVtbl
;
1448 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)HTMLELEM(This
));
1450 HTMLElement2_Init(This
);
1452 if(!This
->node
.dispex
.data
)
1453 init_dispex(&This
->node
.dispex
, (IUnknown
*)HTMLELEM(This
), &HTMLElement_dispex
);
1456 HTMLElement
*HTMLElement_Create(HTMLDocument
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
)
1458 nsIDOMHTMLElement
*nselem
;
1459 HTMLElement
*ret
= NULL
;
1460 nsAString class_name_str
;
1461 const PRUnichar
*class_name
;
1464 static const WCHAR wszA
[] = {'A',0};
1465 static const WCHAR wszBODY
[] = {'B','O','D','Y',0};
1466 static const WCHAR wszIMG
[] = {'I','M','G',0};
1467 static const WCHAR wszINPUT
[] = {'I','N','P','U','T',0};
1468 static const WCHAR wszOPTION
[] = {'O','P','T','I','O','N',0};
1469 static const WCHAR wszSCRIPT
[] = {'S','C','R','I','P','T',0};
1470 static const WCHAR wszSELECT
[] = {'S','E','L','E','C','T',0};
1471 static const WCHAR wszTABLE
[] = {'T','A','B','L','E',0};
1472 static const WCHAR wszTR
[] = {'T','R',0};
1473 static const WCHAR wszTEXTAREA
[] = {'T','E','X','T','A','R','E','A',0};
1475 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1476 if(NS_FAILED(nsres
))
1479 nsAString_Init(&class_name_str
, NULL
);
1480 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1482 nsAString_GetData(&class_name_str
, &class_name
);
1484 if(!strcmpW(class_name
, wszA
))
1485 ret
= HTMLAnchorElement_Create(nselem
);
1486 else if(!strcmpW(class_name
, wszBODY
))
1487 ret
= HTMLBodyElement_Create(nselem
);
1488 else if(!strcmpW(class_name
, wszIMG
))
1489 ret
= HTMLImgElement_Create(nselem
);
1490 else if(!strcmpW(class_name
, wszINPUT
))
1491 ret
= HTMLInputElement_Create(nselem
);
1492 else if(!strcmpW(class_name
, wszOPTION
))
1493 ret
= HTMLOptionElement_Create(nselem
);
1494 else if(!strcmpW(class_name
, wszSCRIPT
))
1495 ret
= HTMLScriptElement_Create(nselem
);
1496 else if(!strcmpW(class_name
, wszSELECT
))
1497 ret
= HTMLSelectElement_Create(nselem
);
1498 else if(!strcmpW(class_name
, wszTABLE
))
1499 ret
= HTMLTable_Create(nselem
);
1500 else if(!strcmpW(class_name
, wszTR
))
1501 ret
= HTMLTableRow_Create(nselem
);
1502 else if(!strcmpW(class_name
, wszTEXTAREA
))
1503 ret
= HTMLTextAreaElement_Create(nselem
);
1504 else if(use_generic
)
1505 ret
= HTMLGenericElement_Create(nselem
);
1508 ret
= heap_alloc_zero(sizeof(HTMLElement
));
1509 HTMLElement_Init(ret
);
1510 ret
->node
.vtbl
= &HTMLElementImplVtbl
;
1513 TRACE("%s ret %p\n", debugstr_w(class_name
), ret
);
1515 nsAString_Finish(&class_name_str
);
1517 ret
->nselem
= nselem
;
1518 HTMLDOMNode_Init(doc
, &ret
->node
, (nsIDOMNode
*)nselem
);