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 HRESULT
create_nselem(HTMLDocumentNode
*doc
, const WCHAR
*tag
, nsIDOMHTMLElement
**ret
)
43 nsIDOMElement
*nselem
;
52 nsAString_Init(&tag_str
, tag
);
53 nsres
= nsIDOMDocument_CreateElement(doc
->nsdoc
, &tag_str
, &nselem
);
54 nsAString_Finish(&tag_str
);
55 if(NS_FAILED(nsres
)) {
56 ERR("CreateElement failed: %08x\n", nsres
);
60 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLElement
, (void**)ret
);
61 nsIDOMElement_Release(nselem
);
62 if(NS_FAILED(nsres
)) {
63 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres
);
70 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
72 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
73 REFIID riid
, void **ppv
)
75 HTMLElement
*This
= HTMLELEM_THIS(iface
);
77 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->node
), riid
, ppv
);
80 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
82 HTMLElement
*This
= HTMLELEM_THIS(iface
);
84 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->node
));
87 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
89 HTMLElement
*This
= HTMLELEM_THIS(iface
);
91 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->node
));
94 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
96 HTMLElement
*This
= HTMLELEM_THIS(iface
);
97 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->node
.dispex
), pctinfo
);
100 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
101 LCID lcid
, ITypeInfo
**ppTInfo
)
103 HTMLElement
*This
= HTMLELEM_THIS(iface
);
104 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->node
.dispex
), iTInfo
, lcid
, ppTInfo
);
107 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
108 LPOLESTR
*rgszNames
, UINT cNames
,
109 LCID lcid
, DISPID
*rgDispId
)
111 HTMLElement
*This
= HTMLELEM_THIS(iface
);
112 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
115 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
116 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
117 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
119 HTMLElement
*This
= HTMLELEM_THIS(iface
);
120 return IDispatchEx_Invoke(DISPATCHEX(&This
->node
.dispex
), dispIdMember
, riid
, lcid
,
121 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
124 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
125 VARIANT AttributeValue
, LONG lFlags
)
127 HTMLElement
*This
= HTMLELEM_THIS(iface
);
129 DISPID dispid
, dispidNamed
= DISPID_PROPERTYPUT
;
130 DISPPARAMS dispParams
;
133 TRACE("(%p)->(%s . %08x)\n", This
, debugstr_w(strAttributeName
), lFlags
);
135 hres
= IDispatchEx_GetDispID(DISPATCHEX(&This
->node
.dispex
), strAttributeName
,
136 fdexNameCaseInsensitive
| fdexNameEnsure
, &dispid
);
140 dispParams
.cArgs
= 1;
141 dispParams
.cNamedArgs
= 1;
142 dispParams
.rgdispidNamedArgs
= &dispidNamed
;
143 dispParams
.rgvarg
= &AttributeValue
;
145 hres
= IDispatchEx_InvokeEx(DISPATCHEX(&This
->node
.dispex
), dispid
,
146 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYPUT
, &dispParams
,
151 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
152 LONG lFlags
, VARIANT
*AttributeValue
)
154 HTMLElement
*This
= HTMLELEM_THIS(iface
);
157 DISPPARAMS dispParams
= {NULL
, NULL
, 0, 0};
160 TRACE("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
162 hres
= IDispatchEx_GetDispID(DISPATCHEX(&This
->node
.dispex
), strAttributeName
,
163 fdexNameCaseInsensitive
, &dispid
);
164 if(hres
== DISP_E_UNKNOWNNAME
) {
165 V_VT(AttributeValue
) = VT_NULL
;
170 V_VT(AttributeValue
) = VT_NULL
;
174 hres
= IDispatchEx_InvokeEx(DISPATCHEX(&This
->node
.dispex
), dispid
,
175 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYGET
, &dispParams
,
176 AttributeValue
, &excep
, NULL
);
181 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
182 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
184 HTMLElement
*This
= HTMLELEM_THIS(iface
);
185 FIXME("(%p)->()\n", This
);
189 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
191 HTMLElement
*This
= HTMLELEM_THIS(iface
);
192 nsAString classname_str
;
195 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
198 FIXME("NULL nselem\n");
202 nsAString_Init(&classname_str
, v
);
203 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
204 nsAString_Finish(&classname_str
);
206 ERR("SetClassName failed: %08x\n", nsres
);
211 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
213 HTMLElement
*This
= HTMLELEM_THIS(iface
);
218 TRACE("(%p)->(%p)\n", This
, p
);
221 FIXME("NULL nselem\n");
225 nsAString_Init(&class_str
, NULL
);
226 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
228 if(NS_SUCCEEDED(nsres
)) {
229 const PRUnichar
*class;
230 nsAString_GetData(&class_str
, &class);
231 *p
= *class ? SysAllocString(class) : NULL
;
233 ERR("GetClassName failed: %08x\n", nsres
);
237 nsAString_Finish(&class_str
);
239 TRACE("className=%s\n", debugstr_w(*p
));
243 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
245 HTMLElement
*This
= HTMLELEM_THIS(iface
);
249 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
252 FIXME("nselem == NULL\n");
256 nsAString_Init(&id_str
, v
);
257 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
258 nsAString_Finish(&id_str
);
260 ERR("SetId failed: %08x\n", nsres
);
265 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
267 HTMLElement
*This
= HTMLELEM_THIS(iface
);
272 TRACE("(%p)->(%p)\n", This
, p
);
279 nsAString_Init(&id_str
, NULL
);
280 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
281 nsAString_GetData(&id_str
, &id
);
284 ERR("GetId failed: %08x\n", nsres
);
286 *p
= SysAllocString(id
);
288 nsAString_Finish(&id_str
);
292 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
294 HTMLElement
*This
= HTMLELEM_THIS(iface
);
295 const PRUnichar
*tag
;
299 TRACE("(%p)->(%p)\n", This
, p
);
302 static const WCHAR comment_tagW
[] = {'!',0};
304 WARN("NULL nselem, assuming comment\n");
306 *p
= SysAllocString(comment_tagW
);
310 nsAString_Init(&tag_str
, NULL
);
311 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
312 if(NS_SUCCEEDED(nsres
)) {
313 nsAString_GetData(&tag_str
, &tag
);
314 *p
= SysAllocString(tag
);
316 ERR("GetTagName failed: %08x\n", nsres
);
319 nsAString_Finish(&tag_str
);
324 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
326 HTMLElement
*This
= HTMLELEM_THIS(iface
);
330 TRACE("(%p)->(%p)\n", This
, p
);
332 hres
= IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This
->node
), &node
);
336 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
337 IHTMLDOMNode_Release(node
);
344 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
346 HTMLElement
*This
= HTMLELEM_THIS(iface
);
347 nsIDOMElementCSSInlineStyle
*nselemstyle
;
348 nsIDOMCSSStyleDeclaration
*nsstyle
;
351 TRACE("(%p)->(%p)\n", This
, p
);
354 FIXME("NULL nselem\n");
358 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMElementCSSInlineStyle
,
359 (void**)&nselemstyle
);
360 if(NS_FAILED(nsres
)) {
361 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres
);
365 nsres
= nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle
, &nsstyle
);
366 nsIDOMElementCSSInlineStyle_Release(nselemstyle
);
367 if(NS_FAILED(nsres
)) {
368 ERR("GetStyle failed: %08x\n", nsres
);
372 /* FIXME: Store style instead of creating a new instance in each call */
373 *p
= HTMLStyle_Create(nsstyle
);
375 nsIDOMCSSStyleDeclaration_Release(nsstyle
);
379 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
381 HTMLElement
*This
= HTMLELEM_THIS(iface
);
382 FIXME("(%p)->()\n", This
);
386 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
388 HTMLElement
*This
= HTMLELEM_THIS(iface
);
389 FIXME("(%p)->(%p)\n", This
, p
);
393 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
395 HTMLElement
*This
= HTMLELEM_THIS(iface
);
397 TRACE("(%p)->()\n", This
);
399 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
402 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
404 HTMLElement
*This
= HTMLELEM_THIS(iface
);
406 TRACE("(%p)->(%p)\n", This
, p
);
408 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
411 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
413 HTMLElement
*This
= HTMLELEM_THIS(iface
);
415 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
417 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
420 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
422 HTMLElement
*This
= HTMLELEM_THIS(iface
);
424 TRACE("(%p)->(%p)\n", This
, p
);
426 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
429 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
431 HTMLElement
*This
= HTMLELEM_THIS(iface
);
433 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
435 return set_node_event(&This
->node
, EVENTID_KEYDOWN
, &v
);
438 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
440 HTMLElement
*This
= HTMLELEM_THIS(iface
);
442 TRACE("(%p)->(%p)\n", This
, p
);
444 return get_node_event(&This
->node
, EVENTID_KEYDOWN
, p
);
447 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
449 HTMLElement
*This
= HTMLELEM_THIS(iface
);
451 TRACE("(%p)->()\n", This
);
453 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
456 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
458 HTMLElement
*This
= HTMLELEM_THIS(iface
);
459 FIXME("(%p)->(%p)\n", This
, p
);
463 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
465 HTMLElement
*This
= HTMLELEM_THIS(iface
);
466 FIXME("(%p)->()\n", This
);
470 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
472 HTMLElement
*This
= HTMLELEM_THIS(iface
);
473 FIXME("(%p)->(%p)\n", This
, p
);
477 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
479 HTMLElement
*This
= HTMLELEM_THIS(iface
);
481 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
483 return set_node_event(&This
->node
, EVENTID_MOUSEOUT
, &v
);
486 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
488 HTMLElement
*This
= HTMLELEM_THIS(iface
);
490 TRACE("(%p)->(%p)\n", This
, p
);
492 return get_node_event(&This
->node
, EVENTID_MOUSEOUT
, p
);
495 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
497 HTMLElement
*This
= HTMLELEM_THIS(iface
);
499 TRACE("(%p)->()\n", This
);
501 return set_node_event(&This
->node
, EVENTID_MOUSEOVER
, &v
);
504 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
506 HTMLElement
*This
= HTMLELEM_THIS(iface
);
508 TRACE("(%p)->(%p)\n", This
, p
);
510 return get_node_event(&This
->node
, EVENTID_MOUSEOVER
, p
);
513 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
515 HTMLElement
*This
= HTMLELEM_THIS(iface
);
516 FIXME("(%p)->()\n", This
);
520 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
522 HTMLElement
*This
= HTMLELEM_THIS(iface
);
523 FIXME("(%p)->(%p)\n", This
, p
);
527 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
529 HTMLElement
*This
= HTMLELEM_THIS(iface
);
531 TRACE("(%p)->()\n", This
);
533 return set_node_event(&This
->node
, EVENTID_MOUSEDOWN
, &v
);
536 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
538 HTMLElement
*This
= HTMLELEM_THIS(iface
);
540 TRACE("(%p)->(%p)\n", This
, p
);
542 return get_node_event(&This
->node
, EVENTID_MOUSEDOWN
, p
);
545 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
547 HTMLElement
*This
= HTMLELEM_THIS(iface
);
549 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
551 return set_node_event(&This
->node
, EVENTID_MOUSEUP
, &v
);
554 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
556 HTMLElement
*This
= HTMLELEM_THIS(iface
);
558 TRACE("(%p)->(%p)\n", This
, p
);
560 return get_node_event(&This
->node
, EVENTID_MOUSEUP
, p
);
563 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
565 HTMLElement
*This
= HTMLELEM_THIS(iface
);
567 TRACE("(%p)->(%p)\n", This
, p
);
572 *p
= (IDispatch
*)HTMLDOC(&This
->node
.doc
->basedoc
);
573 IDispatch_AddRef(*p
);
578 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
580 HTMLElement
*This
= HTMLELEM_THIS(iface
);
584 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
586 nsAString_Init(&title_str
, v
);
587 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
588 nsAString_Finish(&title_str
);
590 ERR("SetTitle failed: %08x\n", nsres
);
595 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
597 HTMLElement
*This
= HTMLELEM_THIS(iface
);
601 TRACE("(%p)->(%p)\n", This
, p
);
603 nsAString_Init(&title_str
, NULL
);
604 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
605 if(NS_SUCCEEDED(nsres
)) {
606 const PRUnichar
*title
;
608 nsAString_GetData(&title_str
, &title
);
609 *p
= *title
? SysAllocString(title
) : NULL
;
611 ERR("GetTitle failed: %08x\n", nsres
);
618 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
620 HTMLElement
*This
= HTMLELEM_THIS(iface
);
621 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
625 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
627 HTMLElement
*This
= HTMLELEM_THIS(iface
);
628 FIXME("(%p)->(%p)\n", This
, p
);
632 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
634 HTMLElement
*This
= HTMLELEM_THIS(iface
);
636 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
638 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
641 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
643 HTMLElement
*This
= HTMLELEM_THIS(iface
);
645 TRACE("(%p)->(%p)\n", This
, p
);
647 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
650 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
652 HTMLElement
*This
= HTMLELEM_THIS(iface
);
653 FIXME("(%p)->()\n", This
);
657 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
658 VARIANT_BOOL
*pfResult
)
660 HTMLElement
*This
= HTMLELEM_THIS(iface
);
661 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
665 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
667 HTMLElement
*This
= HTMLELEM_THIS(iface
);
668 FIXME("(%p)->(%p)\n", This
, p
);
672 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
674 HTMLElement
*This
= HTMLELEM_THIS(iface
);
675 FIXME("(%p)->(%p)\n", This
, p
);
679 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
681 HTMLElement
*This
= HTMLELEM_THIS(iface
);
682 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
686 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
688 HTMLElement
*This
= HTMLELEM_THIS(iface
);
689 FIXME("(%p)->(%p)\n", This
, p
);
693 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
695 HTMLElement
*This
= HTMLELEM_THIS(iface
);
696 FIXME("(%p)->(%p)\n", This
, p
);
700 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
702 HTMLElement
*This
= HTMLELEM_THIS(iface
);
703 nsIDOMNSHTMLElement
*nselem
;
707 TRACE("(%p)->(%p)\n", This
, p
);
709 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
710 if(NS_FAILED(nsres
)) {
711 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
715 nsres
= nsIDOMNSHTMLElement_GetOffsetTop(nselem
, &top
);
716 nsIDOMNSHTMLElement_Release(nselem
);
717 if(NS_FAILED(nsres
)) {
718 ERR("GetOffsetTop failed: %08x\n", nsres
);
726 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
728 HTMLElement
*This
= HTMLELEM_THIS(iface
);
729 nsIDOMNSHTMLElement
*nselem
;
733 TRACE("(%p)->(%p)\n", This
, p
);
735 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
736 if(NS_FAILED(nsres
)) {
737 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
741 nsres
= nsIDOMNSHTMLElement_GetOffsetWidth(nselem
, &offset
);
742 nsIDOMNSHTMLElement_Release(nselem
);
743 if(NS_FAILED(nsres
)) {
744 ERR("GetOffsetWidth failed: %08x\n", nsres
);
752 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
754 HTMLElement
*This
= HTMLELEM_THIS(iface
);
755 nsIDOMNSHTMLElement
*nselem
;
759 TRACE("(%p)->(%p)\n", This
, p
);
761 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
762 if(NS_FAILED(nsres
)) {
763 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
767 nsres
= nsIDOMNSHTMLElement_GetOffsetHeight(nselem
, &offset
);
768 nsIDOMNSHTMLElement_Release(nselem
);
769 if(NS_FAILED(nsres
)) {
770 ERR("GetOffsetHeight failed: %08x\n", nsres
);
778 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
780 HTMLElement
*This
= HTMLELEM_THIS(iface
);
781 FIXME("(%p)->(%p)\n", This
, p
);
785 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
787 HTMLElement
*This
= HTMLELEM_THIS(iface
);
788 nsIDOMNSHTMLElement
*nselem
;
792 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
795 FIXME("NULL nselem\n");
799 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
800 if(NS_FAILED(nsres
)) {
801 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
805 nsAString_Init(&html_str
, v
);
806 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
807 nsAString_Finish(&html_str
);
809 if(NS_FAILED(nsres
)) {
810 FIXME("SetInnerHtml failed %08x\n", nsres
);
817 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
819 HTMLElement
*This
= HTMLELEM_THIS(iface
);
820 nsIDOMNSHTMLElement
*nselem
;
824 TRACE("(%p)->(%p)\n", This
, p
);
827 FIXME("NULL nselem\n");
831 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
832 if(NS_FAILED(nsres
)) {
833 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
837 nsAString_Init(&html_str
, NULL
);
838 nsres
= nsIDOMNSHTMLElement_GetInnerHTML(nselem
, &html_str
);
839 if(NS_SUCCEEDED(nsres
)) {
840 const PRUnichar
*html
;
842 nsAString_GetData(&html_str
, &html
);
843 *p
= *html
? SysAllocString(html
) : NULL
;
845 FIXME("SetInnerHtml failed %08x\n", nsres
);
849 nsAString_Finish(&html_str
);
853 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
855 HTMLElement
*This
= HTMLELEM_THIS(iface
);
856 nsIDOMNode
*nschild
, *tmp
;
857 nsIDOMText
*text_node
;
861 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
864 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
865 if(NS_FAILED(nsres
)) {
866 ERR("GetLastChild failed: %08x\n", nsres
);
872 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
873 nsIDOMNode_Release(nschild
);
874 if(NS_FAILED(nsres
)) {
875 ERR("RemoveChild failed: %08x\n", nsres
);
878 nsIDOMNode_Release(tmp
);
881 nsAString_Init(&text_str
, v
);
882 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
883 nsAString_Finish(&text_str
);
884 if(NS_FAILED(nsres
)) {
885 ERR("CreateTextNode failed: %08x\n", nsres
);
889 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
890 if(NS_FAILED(nsres
)) {
891 ERR("AppendChild failed: %08x\n", nsres
);
895 nsIDOMNode_Release(tmp
);
899 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
901 HTMLElement
*This
= HTMLELEM_THIS(iface
);
903 TRACE("(%p)->(%p)\n", This
, p
);
905 return get_node_text(&This
->node
, p
);
908 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
910 HTMLElement
*This
= HTMLELEM_THIS(iface
);
911 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
915 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
917 HTMLElement
*This
= HTMLELEM_THIS(iface
);
921 WARN("(%p)->(%p) semi-stub\n", This
, p
);
923 nsAString_Init(&html_str
, NULL
);
924 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
925 if(SUCCEEDED(hres
)) {
926 const PRUnichar
*html
;
928 nsAString_GetData(&html_str
, &html
);
929 *p
= SysAllocString(html
);
931 hres
= E_OUTOFMEMORY
;
934 nsAString_Finish(&html_str
);
936 TRACE("ret %s\n", debugstr_w(*p
));
940 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
942 HTMLElement
*This
= HTMLELEM_THIS(iface
);
943 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
947 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
949 HTMLElement
*This
= HTMLELEM_THIS(iface
);
950 FIXME("(%p)->(%p)\n", This
, p
);
954 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
956 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
957 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
958 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
959 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
963 FIXME("NULL nselem\n");
967 if (!strcmpiW(where
, wszBeforeBegin
))
971 nsres
= nsIDOMNode_GetParentNode(This
->nselem
, &parent
);
972 if (!parent
) return E_INVALIDARG
;
973 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
,
974 (nsIDOMNode
*)This
->nselem
, &unused
);
975 if (unused
) nsIDOMNode_Release(unused
);
976 nsIDOMNode_Release(parent
);
978 else if (!strcmpiW(where
, wszAfterBegin
))
981 nsIDOMNode
*first_child
;
982 nsIDOMNode_GetFirstChild(This
->nselem
, &first_child
);
983 nsres
= nsIDOMNode_InsertBefore(This
->nselem
, nsnode
, first_child
, &unused
);
984 if (unused
) nsIDOMNode_Release(unused
);
985 if (first_child
) nsIDOMNode_Release(first_child
);
987 else if (!strcmpiW(where
, wszBeforeEnd
))
990 nsres
= nsIDOMNode_AppendChild(This
->nselem
, nsnode
, &unused
);
991 if (unused
) nsIDOMNode_Release(unused
);
993 else if (!strcmpiW(where
, wszAfterEnd
))
996 nsIDOMNode
*next_sibling
;
998 nsIDOMNode_GetParentNode(This
->nselem
, &parent
);
999 if (!parent
) return E_INVALIDARG
;
1001 nsIDOMNode_GetNextSibling(This
->nselem
, &next_sibling
);
1004 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
1005 nsIDOMNode_Release(next_sibling
);
1008 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
1009 nsIDOMNode_Release(parent
);
1010 if (unused
) nsIDOMNode_Release(unused
);
1014 ERR("invalid where: %s\n", debugstr_w(where
));
1015 return E_INVALIDARG
;
1018 if (NS_FAILED(nsres
))
1024 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1027 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1028 nsIDOMDocumentRange
*nsdocrange
;
1030 nsIDOMNSRange
*nsrange
;
1036 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1038 if(!This
->node
.doc
->nsdoc
) {
1039 WARN("NULL nsdoc\n");
1040 return E_UNEXPECTED
;
1043 nsres
= nsIDOMDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void **)&nsdocrange
);
1044 if(NS_FAILED(nsres
))
1046 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres
);
1049 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
1050 nsIDOMDocumentRange_Release(nsdocrange
);
1051 if(NS_FAILED(nsres
))
1053 ERR("CreateRange failed: %08x\n", nsres
);
1057 nsIDOMRange_SetStartBefore(range
, (nsIDOMNode
*)This
->nselem
);
1059 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
1060 nsIDOMRange_Release(range
);
1061 if(NS_FAILED(nsres
))
1063 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
1067 nsAString_Init(&ns_html
, html
);
1069 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1070 nsIDOMNSRange_Release(nsrange
);
1071 nsAString_Finish(&ns_html
);
1073 if(NS_FAILED(nsres
) || !nsnode
)
1075 ERR("CreateTextNode failed: %08x\n", nsres
);
1079 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1080 nsIDOMNode_Release(nsnode
);
1085 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1088 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1094 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1096 if(!This
->node
.doc
->nsdoc
) {
1097 WARN("NULL nsdoc\n");
1098 return E_UNEXPECTED
;
1102 nsAString_Init(&ns_text
, text
);
1103 nsres
= nsIDOMDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1104 nsAString_Finish(&ns_text
);
1106 if(NS_FAILED(nsres
) || !nsnode
)
1108 ERR("CreateTextNode failed: %08x\n", nsres
);
1112 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1113 nsIDOMNode_Release(nsnode
);
1118 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1120 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1121 FIXME("(%p)->(%p)\n", This
, p
);
1125 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1127 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1128 FIXME("(%p)->(%p)\n", This
, p
);
1132 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1134 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1136 TRACE("(%p)\n", This
);
1138 return call_event(&This
->node
, EVENTID_CLICK
);
1141 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1142 IHTMLFiltersCollection
**p
)
1144 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1145 FIXME("(%p)->(%p)\n", This
, p
);
1149 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1151 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1152 FIXME("(%p)->()\n", This
);
1156 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1158 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1159 FIXME("(%p)->(%p)\n", This
, p
);
1163 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1165 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1166 FIXME("(%p)->(%p)\n", This
, String
);
1170 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1172 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1173 FIXME("(%p)->()\n", This
);
1177 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1179 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1180 FIXME("(%p)->(%p)\n", This
, p
);
1184 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1186 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1187 FIXME("(%p)->()\n", This
);
1191 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1193 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1194 FIXME("(%p)->(%p)\n", This
, p
);
1198 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1200 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1201 FIXME("(%p)->()\n", This
);
1205 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1207 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1208 FIXME("(%p)->(%p)\n", This
, p
);
1212 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1214 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1215 FIXME("(%p)->()\n", This
);
1219 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1221 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1222 FIXME("(%p)->(%p)\n", This
, p
);
1226 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1228 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1229 FIXME("(%p)->()\n", This
);
1233 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1235 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1236 FIXME("(%p)->(%p)\n", This
, p
);
1240 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1242 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1243 FIXME("(%p)->()\n", This
);
1247 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1249 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1250 FIXME("(%p)->(%p)\n", This
, p
);
1254 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1256 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1257 FIXME("(%p)->()\n", This
);
1261 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1263 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1264 FIXME("(%p)->(%p)\n", This
, p
);
1268 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1270 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1271 FIXME("(%p)->()\n", This
);
1275 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1277 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1278 FIXME("(%p)->(%p)\n", This
, p
);
1282 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1284 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1285 FIXME("(%p)->()\n", This
);
1289 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1291 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1292 FIXME("(%p)->(%p)\n", This
, p
);
1296 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1298 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1299 nsIDOMNodeList
*nsnode_list
;
1302 TRACE("(%p)->(%p)\n", This
, p
);
1304 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1305 if(NS_FAILED(nsres
)) {
1306 ERR("GetChildNodes failed: %08x\n", nsres
);
1310 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, (IUnknown
*)HTMLELEM(This
), nsnode_list
);
1312 nsIDOMNodeList_Release(nsnode_list
);
1316 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1318 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1320 TRACE("(%p)->(%p)\n", This
, p
);
1322 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1326 #undef HTMLELEM_THIS
1328 static const IHTMLElementVtbl HTMLElementVtbl
= {
1329 HTMLElement_QueryInterface
,
1331 HTMLElement_Release
,
1332 HTMLElement_GetTypeInfoCount
,
1333 HTMLElement_GetTypeInfo
,
1334 HTMLElement_GetIDsOfNames
,
1336 HTMLElement_setAttribute
,
1337 HTMLElement_getAttribute
,
1338 HTMLElement_removeAttribute
,
1339 HTMLElement_put_className
,
1340 HTMLElement_get_className
,
1343 HTMLElement_get_tagName
,
1344 HTMLElement_get_parentElement
,
1345 HTMLElement_get_style
,
1346 HTMLElement_put_onhelp
,
1347 HTMLElement_get_onhelp
,
1348 HTMLElement_put_onclick
,
1349 HTMLElement_get_onclick
,
1350 HTMLElement_put_ondblclick
,
1351 HTMLElement_get_ondblclick
,
1352 HTMLElement_put_onkeydown
,
1353 HTMLElement_get_onkeydown
,
1354 HTMLElement_put_onkeyup
,
1355 HTMLElement_get_onkeyup
,
1356 HTMLElement_put_onkeypress
,
1357 HTMLElement_get_onkeypress
,
1358 HTMLElement_put_onmouseout
,
1359 HTMLElement_get_onmouseout
,
1360 HTMLElement_put_onmouseover
,
1361 HTMLElement_get_onmouseover
,
1362 HTMLElement_put_onmousemove
,
1363 HTMLElement_get_onmousemove
,
1364 HTMLElement_put_onmousedown
,
1365 HTMLElement_get_onmousedown
,
1366 HTMLElement_put_onmouseup
,
1367 HTMLElement_get_onmouseup
,
1368 HTMLElement_get_document
,
1369 HTMLElement_put_title
,
1370 HTMLElement_get_title
,
1371 HTMLElement_put_language
,
1372 HTMLElement_get_language
,
1373 HTMLElement_put_onselectstart
,
1374 HTMLElement_get_onselectstart
,
1375 HTMLElement_scrollIntoView
,
1376 HTMLElement_contains
,
1377 HTMLElement_get_sourceIndex
,
1378 HTMLElement_get_recordNumber
,
1379 HTMLElement_put_lang
,
1380 HTMLElement_get_lang
,
1381 HTMLElement_get_offsetLeft
,
1382 HTMLElement_get_offsetTop
,
1383 HTMLElement_get_offsetWidth
,
1384 HTMLElement_get_offsetHeight
,
1385 HTMLElement_get_offsetParent
,
1386 HTMLElement_put_innerHTML
,
1387 HTMLElement_get_innerHTML
,
1388 HTMLElement_put_innerText
,
1389 HTMLElement_get_innerText
,
1390 HTMLElement_put_outerHTML
,
1391 HTMLElement_get_outerHTML
,
1392 HTMLElement_put_outerText
,
1393 HTMLElement_get_outerText
,
1394 HTMLElement_insertAdjacentHTML
,
1395 HTMLElement_insertAdjacentText
,
1396 HTMLElement_get_parentTextEdit
,
1397 HTMLElement_get_isTextEdit
,
1399 HTMLElement_get_filters
,
1400 HTMLElement_put_ondragstart
,
1401 HTMLElement_get_ondragstart
,
1402 HTMLElement_toString
,
1403 HTMLElement_put_onbeforeupdate
,
1404 HTMLElement_get_onbeforeupdate
,
1405 HTMLElement_put_onafterupdate
,
1406 HTMLElement_get_onafterupdate
,
1407 HTMLElement_put_onerrorupdate
,
1408 HTMLElement_get_onerrorupdate
,
1409 HTMLElement_put_onrowexit
,
1410 HTMLElement_get_onrowexit
,
1411 HTMLElement_put_onrowenter
,
1412 HTMLElement_get_onrowenter
,
1413 HTMLElement_put_ondatasetchanged
,
1414 HTMLElement_get_ondatasetchanged
,
1415 HTMLElement_put_ondataavailable
,
1416 HTMLElement_get_ondataavailable
,
1417 HTMLElement_put_ondatasetcomplete
,
1418 HTMLElement_get_ondatasetcomplete
,
1419 HTMLElement_put_onfilterchange
,
1420 HTMLElement_get_onfilterchange
,
1421 HTMLElement_get_children
,
1425 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1427 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1431 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1432 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1433 *ppv
= HTMLELEM(This
);
1434 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1435 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1436 *ppv
= HTMLELEM(This
);
1437 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1438 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1439 *ppv
= HTMLELEM(This
);
1440 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1441 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1442 *ppv
= HTMLELEM2(This
);
1443 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1444 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1445 *ppv
= HTMLELEM3(This
);
1446 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1447 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1448 *ppv
= CONPTCONT(&This
->cp_container
);
1452 IHTMLElement_AddRef(HTMLELEM(This
));
1456 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1459 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1461 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1463 ConnectionPointContainer_Destroy(&This
->cp_container
);
1466 nsIDOMHTMLElement_Release(This
->nselem
);
1468 HTMLDOMNode_destructor(&This
->node
);
1471 static const NodeImplVtbl HTMLElementImplVtbl
= {
1473 HTMLElement_destructor
1476 static const tid_t HTMLElement_iface_tids
[] = {
1485 static dispex_static_data_t HTMLElement_dispex
= {
1487 DispHTMLUnknownElement_tid
,
1489 HTMLElement_iface_tids
1492 void HTMLElement_Init(HTMLElement
*This
, dispex_static_data_t
*dispex_data
)
1494 This
->lpHTMLElementVtbl
= &HTMLElementVtbl
;
1496 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)HTMLELEM(This
));
1498 HTMLElement2_Init(This
);
1499 HTMLElement3_Init(This
);
1501 init_dispex(&This
->node
.dispex
, (IUnknown
*)HTMLELEM(This
), dispex_data
? dispex_data
: &HTMLElement_dispex
);
1504 HTMLElement
*HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
)
1506 nsIDOMHTMLElement
*nselem
;
1507 HTMLElement
*ret
= NULL
;
1508 nsAString class_name_str
;
1509 const PRUnichar
*class_name
;
1512 static const WCHAR wszA
[] = {'A',0};
1513 static const WCHAR wszBODY
[] = {'B','O','D','Y',0};
1514 static const WCHAR wszIFRAME
[] = {'I','F','R','A','M','E',0};
1515 static const WCHAR wszIMG
[] = {'I','M','G',0};
1516 static const WCHAR wszINPUT
[] = {'I','N','P','U','T',0};
1517 static const WCHAR wszOPTION
[] = {'O','P','T','I','O','N',0};
1518 static const WCHAR wszSCRIPT
[] = {'S','C','R','I','P','T',0};
1519 static const WCHAR wszSELECT
[] = {'S','E','L','E','C','T',0};
1520 static const WCHAR wszTABLE
[] = {'T','A','B','L','E',0};
1521 static const WCHAR wszTR
[] = {'T','R',0};
1522 static const WCHAR wszTEXTAREA
[] = {'T','E','X','T','A','R','E','A',0};
1524 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1525 if(NS_FAILED(nsres
))
1528 nsAString_Init(&class_name_str
, NULL
);
1529 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1531 nsAString_GetData(&class_name_str
, &class_name
);
1533 if(!strcmpW(class_name
, wszA
))
1534 ret
= HTMLAnchorElement_Create(nselem
);
1535 else if(!strcmpW(class_name
, wszBODY
))
1536 ret
= HTMLBodyElement_Create(nselem
);
1537 else if(!strcmpW(class_name
, wszIFRAME
))
1538 ret
= HTMLIFrame_Create(nselem
);
1539 else if(!strcmpW(class_name
, wszIMG
))
1540 ret
= HTMLImgElement_Create(nselem
);
1541 else if(!strcmpW(class_name
, wszINPUT
))
1542 ret
= HTMLInputElement_Create(nselem
);
1543 else if(!strcmpW(class_name
, wszOPTION
))
1544 ret
= HTMLOptionElement_Create(nselem
);
1545 else if(!strcmpW(class_name
, wszSCRIPT
))
1546 ret
= HTMLScriptElement_Create(nselem
);
1547 else if(!strcmpW(class_name
, wszSELECT
))
1548 ret
= HTMLSelectElement_Create(nselem
);
1549 else if(!strcmpW(class_name
, wszTABLE
))
1550 ret
= HTMLTable_Create(nselem
);
1551 else if(!strcmpW(class_name
, wszTR
))
1552 ret
= HTMLTableRow_Create(nselem
);
1553 else if(!strcmpW(class_name
, wszTEXTAREA
))
1554 ret
= HTMLTextAreaElement_Create(nselem
);
1555 else if(use_generic
)
1556 ret
= HTMLGenericElement_Create(nselem
);
1559 ret
= heap_alloc_zero(sizeof(HTMLElement
));
1560 HTMLElement_Init(ret
, NULL
);
1561 ret
->node
.vtbl
= &HTMLElementImplVtbl
;
1564 TRACE("%s ret %p\n", debugstr_w(class_name
), ret
);
1566 nsAString_Finish(&class_name_str
);
1568 ret
->nselem
= nselem
;
1569 HTMLDOMNode_Init(doc
, &ret
->node
, (nsIDOMNode
*)nselem
);