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 if(This
->node
.vtbl
->get_document
)
573 return This
->node
.vtbl
->get_document(&This
->node
, p
);
575 *p
= (IDispatch
*)HTMLDOC(&This
->node
.doc
->basedoc
);
576 IDispatch_AddRef(*p
);
580 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
582 HTMLElement
*This
= HTMLELEM_THIS(iface
);
586 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
588 nsAString_Init(&title_str
, v
);
589 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
590 nsAString_Finish(&title_str
);
592 ERR("SetTitle failed: %08x\n", nsres
);
597 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
599 HTMLElement
*This
= HTMLELEM_THIS(iface
);
603 TRACE("(%p)->(%p)\n", This
, p
);
605 nsAString_Init(&title_str
, NULL
);
606 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
607 if(NS_SUCCEEDED(nsres
)) {
608 const PRUnichar
*title
;
610 nsAString_GetData(&title_str
, &title
);
611 *p
= *title
? SysAllocString(title
) : NULL
;
613 ERR("GetTitle failed: %08x\n", nsres
);
620 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
622 HTMLElement
*This
= HTMLELEM_THIS(iface
);
623 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
627 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
629 HTMLElement
*This
= HTMLELEM_THIS(iface
);
630 FIXME("(%p)->(%p)\n", This
, p
);
634 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
636 HTMLElement
*This
= HTMLELEM_THIS(iface
);
638 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
640 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
643 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
645 HTMLElement
*This
= HTMLELEM_THIS(iface
);
647 TRACE("(%p)->(%p)\n", This
, p
);
649 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
652 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
654 HTMLElement
*This
= HTMLELEM_THIS(iface
);
655 FIXME("(%p)->()\n", This
);
659 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
660 VARIANT_BOOL
*pfResult
)
662 HTMLElement
*This
= HTMLELEM_THIS(iface
);
663 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
667 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
669 HTMLElement
*This
= HTMLELEM_THIS(iface
);
670 FIXME("(%p)->(%p)\n", This
, p
);
674 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
676 HTMLElement
*This
= HTMLELEM_THIS(iface
);
677 FIXME("(%p)->(%p)\n", This
, p
);
681 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
683 HTMLElement
*This
= HTMLELEM_THIS(iface
);
684 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
688 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
690 HTMLElement
*This
= HTMLELEM_THIS(iface
);
691 FIXME("(%p)->(%p)\n", This
, p
);
695 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
697 HTMLElement
*This
= HTMLELEM_THIS(iface
);
698 FIXME("(%p)->(%p)\n", This
, p
);
702 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
704 HTMLElement
*This
= HTMLELEM_THIS(iface
);
705 nsIDOMNSHTMLElement
*nselem
;
709 TRACE("(%p)->(%p)\n", This
, p
);
711 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
712 if(NS_FAILED(nsres
)) {
713 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
717 nsres
= nsIDOMNSHTMLElement_GetOffsetTop(nselem
, &top
);
718 nsIDOMNSHTMLElement_Release(nselem
);
719 if(NS_FAILED(nsres
)) {
720 ERR("GetOffsetTop failed: %08x\n", nsres
);
728 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
730 HTMLElement
*This
= HTMLELEM_THIS(iface
);
731 nsIDOMNSHTMLElement
*nselem
;
735 TRACE("(%p)->(%p)\n", This
, p
);
737 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
738 if(NS_FAILED(nsres
)) {
739 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
743 nsres
= nsIDOMNSHTMLElement_GetOffsetWidth(nselem
, &offset
);
744 nsIDOMNSHTMLElement_Release(nselem
);
745 if(NS_FAILED(nsres
)) {
746 ERR("GetOffsetWidth failed: %08x\n", nsres
);
754 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
756 HTMLElement
*This
= HTMLELEM_THIS(iface
);
757 nsIDOMNSHTMLElement
*nselem
;
761 TRACE("(%p)->(%p)\n", This
, p
);
763 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
764 if(NS_FAILED(nsres
)) {
765 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
769 nsres
= nsIDOMNSHTMLElement_GetOffsetHeight(nselem
, &offset
);
770 nsIDOMNSHTMLElement_Release(nselem
);
771 if(NS_FAILED(nsres
)) {
772 ERR("GetOffsetHeight failed: %08x\n", nsres
);
780 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
782 HTMLElement
*This
= HTMLELEM_THIS(iface
);
783 FIXME("(%p)->(%p)\n", This
, p
);
787 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
789 HTMLElement
*This
= HTMLELEM_THIS(iface
);
790 nsIDOMNSHTMLElement
*nselem
;
794 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
797 FIXME("NULL nselem\n");
801 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
802 if(NS_FAILED(nsres
)) {
803 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
807 nsAString_Init(&html_str
, v
);
808 nsres
= nsIDOMNSHTMLElement_SetInnerHTML(nselem
, &html_str
);
809 nsAString_Finish(&html_str
);
811 if(NS_FAILED(nsres
)) {
812 FIXME("SetInnerHtml failed %08x\n", nsres
);
819 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
821 HTMLElement
*This
= HTMLELEM_THIS(iface
);
822 nsIDOMNSHTMLElement
*nselem
;
826 TRACE("(%p)->(%p)\n", This
, p
);
829 FIXME("NULL nselem\n");
833 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMNSHTMLElement
, (void**)&nselem
);
834 if(NS_FAILED(nsres
)) {
835 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres
);
839 nsAString_Init(&html_str
, NULL
);
840 nsres
= nsIDOMNSHTMLElement_GetInnerHTML(nselem
, &html_str
);
841 if(NS_SUCCEEDED(nsres
)) {
842 const PRUnichar
*html
;
844 nsAString_GetData(&html_str
, &html
);
845 *p
= *html
? SysAllocString(html
) : NULL
;
847 FIXME("SetInnerHtml failed %08x\n", nsres
);
851 nsAString_Finish(&html_str
);
855 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
857 HTMLElement
*This
= HTMLELEM_THIS(iface
);
858 nsIDOMNode
*nschild
, *tmp
;
859 nsIDOMText
*text_node
;
863 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
866 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
867 if(NS_FAILED(nsres
)) {
868 ERR("GetLastChild failed: %08x\n", nsres
);
874 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
875 nsIDOMNode_Release(nschild
);
876 if(NS_FAILED(nsres
)) {
877 ERR("RemoveChild failed: %08x\n", nsres
);
880 nsIDOMNode_Release(tmp
);
883 nsAString_Init(&text_str
, v
);
884 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
885 nsAString_Finish(&text_str
);
886 if(NS_FAILED(nsres
)) {
887 ERR("CreateTextNode failed: %08x\n", nsres
);
891 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
892 if(NS_FAILED(nsres
)) {
893 ERR("AppendChild failed: %08x\n", nsres
);
897 nsIDOMNode_Release(tmp
);
901 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
903 HTMLElement
*This
= HTMLELEM_THIS(iface
);
905 TRACE("(%p)->(%p)\n", This
, p
);
907 return get_node_text(&This
->node
, p
);
910 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
912 HTMLElement
*This
= HTMLELEM_THIS(iface
);
913 nsIDOMDocumentFragment
*nsfragment
;
914 nsIDOMDocumentRange
*nsdocrange
;
915 nsIDOMNSRange
*nsrange
;
916 nsIDOMNode
*nsparent
;
922 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
924 nsres
= nsIDOMHTMLDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
928 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
929 nsIDOMDocumentRange_Release(nsdocrange
);
930 if(NS_FAILED(nsres
)) {
931 ERR("CreateRange failed: %08x\n", nsres
);
935 nsres
= nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void**)&nsrange
);
936 nsIDOMRange_Release(range
);
937 if(NS_FAILED(nsres
)) {
938 ERR("Could not get nsIDOMNSRange: %08x\n", nsres
);
942 nsAString_Init(&html_str
, v
);
943 nsIDOMNSRange_CreateContextualFragment(nsrange
, &html_str
, &nsfragment
);
944 nsIDOMNSRange_Release(nsrange
);
945 nsAString_Finish(&html_str
);
946 if(NS_FAILED(nsres
)) {
947 ERR("CreateContextualFragment failed: %08x\n", nsres
);
951 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &nsparent
);
952 if(NS_SUCCEEDED(nsres
) && nsparent
) {
955 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, This
->node
.nsnode
, &nstmp
);
956 nsIDOMNode_Release(nsparent
);
957 if(NS_FAILED(nsres
)) {
958 ERR("ReplaceChild failed: %08x\n", nsres
);
961 nsIDOMNode_Release(nstmp
);
964 ERR("GetParentNode failed: %08x\n", nsres
);
968 nsIDOMDocumentFragment_Release(nsfragment
);
972 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
974 HTMLElement
*This
= HTMLELEM_THIS(iface
);
978 WARN("(%p)->(%p) semi-stub\n", This
, p
);
980 nsAString_Init(&html_str
, NULL
);
981 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
982 if(SUCCEEDED(hres
)) {
983 const PRUnichar
*html
;
985 nsAString_GetData(&html_str
, &html
);
986 *p
= SysAllocString(html
);
988 hres
= E_OUTOFMEMORY
;
991 nsAString_Finish(&html_str
);
993 TRACE("ret %s\n", debugstr_w(*p
));
997 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
999 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1000 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1004 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1006 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1007 FIXME("(%p)->(%p)\n", This
, p
);
1011 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
1013 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1014 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
1015 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
1016 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
1019 if (!strcmpiW(where
, wszBeforeBegin
))
1023 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1024 if (!parent
) return E_INVALIDARG
;
1025 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &unused
);
1026 if (unused
) nsIDOMNode_Release(unused
);
1027 nsIDOMNode_Release(parent
);
1029 else if (!strcmpiW(where
, wszAfterBegin
))
1032 nsIDOMNode
*first_child
;
1033 nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1034 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &unused
);
1035 if (unused
) nsIDOMNode_Release(unused
);
1036 if (first_child
) nsIDOMNode_Release(first_child
);
1038 else if (!strcmpiW(where
, wszBeforeEnd
))
1041 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &unused
);
1042 if (unused
) nsIDOMNode_Release(unused
);
1044 else if (!strcmpiW(where
, wszAfterEnd
))
1047 nsIDOMNode
*next_sibling
;
1049 nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1050 if (!parent
) return E_INVALIDARG
;
1052 nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1055 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
1056 nsIDOMNode_Release(next_sibling
);
1059 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
1060 nsIDOMNode_Release(parent
);
1061 if (unused
) nsIDOMNode_Release(unused
);
1065 ERR("invalid where: %s\n", debugstr_w(where
));
1066 return E_INVALIDARG
;
1069 if (NS_FAILED(nsres
))
1075 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1078 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1079 nsIDOMDocumentRange
*nsdocrange
;
1081 nsIDOMNSRange
*nsrange
;
1087 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1089 if(!This
->node
.doc
->nsdoc
) {
1090 WARN("NULL nsdoc\n");
1091 return E_UNEXPECTED
;
1094 nsres
= nsIDOMDocument_QueryInterface(This
->node
.doc
->nsdoc
, &IID_nsIDOMDocumentRange
, (void **)&nsdocrange
);
1095 if(NS_FAILED(nsres
))
1097 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres
);
1100 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &range
);
1101 nsIDOMDocumentRange_Release(nsdocrange
);
1102 if(NS_FAILED(nsres
))
1104 ERR("CreateRange failed: %08x\n", nsres
);
1108 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1110 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
1111 nsIDOMRange_Release(range
);
1112 if(NS_FAILED(nsres
))
1114 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
1118 nsAString_Init(&ns_html
, html
);
1120 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1121 nsIDOMNSRange_Release(nsrange
);
1122 nsAString_Finish(&ns_html
);
1124 if(NS_FAILED(nsres
) || !nsnode
)
1126 ERR("CreateTextNode failed: %08x\n", nsres
);
1130 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1131 nsIDOMNode_Release(nsnode
);
1136 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1139 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1145 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1147 if(!This
->node
.doc
->nsdoc
) {
1148 WARN("NULL nsdoc\n");
1149 return E_UNEXPECTED
;
1153 nsAString_Init(&ns_text
, text
);
1154 nsres
= nsIDOMDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1155 nsAString_Finish(&ns_text
);
1157 if(NS_FAILED(nsres
) || !nsnode
)
1159 ERR("CreateTextNode failed: %08x\n", nsres
);
1163 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1164 nsIDOMNode_Release(nsnode
);
1169 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1171 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1172 FIXME("(%p)->(%p)\n", This
, p
);
1176 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1178 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1179 FIXME("(%p)->(%p)\n", This
, p
);
1183 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1185 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1187 TRACE("(%p)\n", This
);
1189 return call_event(&This
->node
, EVENTID_CLICK
);
1192 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1193 IHTMLFiltersCollection
**p
)
1195 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1196 FIXME("(%p)->(%p)\n", This
, p
);
1200 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1202 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1203 FIXME("(%p)->()\n", This
);
1207 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1209 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1210 FIXME("(%p)->(%p)\n", This
, p
);
1214 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1216 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1217 FIXME("(%p)->(%p)\n", This
, String
);
1221 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1223 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1224 FIXME("(%p)->()\n", This
);
1228 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1230 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1231 FIXME("(%p)->(%p)\n", This
, p
);
1235 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1237 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1238 FIXME("(%p)->()\n", This
);
1242 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1244 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1245 FIXME("(%p)->(%p)\n", This
, p
);
1249 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1251 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1252 FIXME("(%p)->()\n", This
);
1256 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1258 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1259 FIXME("(%p)->(%p)\n", This
, p
);
1263 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1265 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1266 FIXME("(%p)->()\n", This
);
1270 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1272 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1273 FIXME("(%p)->(%p)\n", This
, p
);
1277 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1279 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1280 FIXME("(%p)->()\n", This
);
1284 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1286 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1287 FIXME("(%p)->(%p)\n", This
, p
);
1291 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1293 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1294 FIXME("(%p)->()\n", This
);
1298 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1300 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1301 FIXME("(%p)->(%p)\n", This
, p
);
1305 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1307 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1308 FIXME("(%p)->()\n", This
);
1312 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1314 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1315 FIXME("(%p)->(%p)\n", This
, p
);
1319 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1321 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1322 FIXME("(%p)->()\n", This
);
1326 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1328 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1329 FIXME("(%p)->(%p)\n", This
, p
);
1333 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1335 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1336 FIXME("(%p)->()\n", This
);
1340 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1342 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1343 FIXME("(%p)->(%p)\n", This
, p
);
1347 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1349 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1350 nsIDOMNodeList
*nsnode_list
;
1353 TRACE("(%p)->(%p)\n", This
, p
);
1355 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1356 if(NS_FAILED(nsres
)) {
1357 ERR("GetChildNodes failed: %08x\n", nsres
);
1361 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, (IUnknown
*)HTMLELEM(This
), nsnode_list
);
1363 nsIDOMNodeList_Release(nsnode_list
);
1367 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1369 HTMLElement
*This
= HTMLELEM_THIS(iface
);
1371 TRACE("(%p)->(%p)\n", This
, p
);
1373 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1377 #undef HTMLELEM_THIS
1379 static const IHTMLElementVtbl HTMLElementVtbl
= {
1380 HTMLElement_QueryInterface
,
1382 HTMLElement_Release
,
1383 HTMLElement_GetTypeInfoCount
,
1384 HTMLElement_GetTypeInfo
,
1385 HTMLElement_GetIDsOfNames
,
1387 HTMLElement_setAttribute
,
1388 HTMLElement_getAttribute
,
1389 HTMLElement_removeAttribute
,
1390 HTMLElement_put_className
,
1391 HTMLElement_get_className
,
1394 HTMLElement_get_tagName
,
1395 HTMLElement_get_parentElement
,
1396 HTMLElement_get_style
,
1397 HTMLElement_put_onhelp
,
1398 HTMLElement_get_onhelp
,
1399 HTMLElement_put_onclick
,
1400 HTMLElement_get_onclick
,
1401 HTMLElement_put_ondblclick
,
1402 HTMLElement_get_ondblclick
,
1403 HTMLElement_put_onkeydown
,
1404 HTMLElement_get_onkeydown
,
1405 HTMLElement_put_onkeyup
,
1406 HTMLElement_get_onkeyup
,
1407 HTMLElement_put_onkeypress
,
1408 HTMLElement_get_onkeypress
,
1409 HTMLElement_put_onmouseout
,
1410 HTMLElement_get_onmouseout
,
1411 HTMLElement_put_onmouseover
,
1412 HTMLElement_get_onmouseover
,
1413 HTMLElement_put_onmousemove
,
1414 HTMLElement_get_onmousemove
,
1415 HTMLElement_put_onmousedown
,
1416 HTMLElement_get_onmousedown
,
1417 HTMLElement_put_onmouseup
,
1418 HTMLElement_get_onmouseup
,
1419 HTMLElement_get_document
,
1420 HTMLElement_put_title
,
1421 HTMLElement_get_title
,
1422 HTMLElement_put_language
,
1423 HTMLElement_get_language
,
1424 HTMLElement_put_onselectstart
,
1425 HTMLElement_get_onselectstart
,
1426 HTMLElement_scrollIntoView
,
1427 HTMLElement_contains
,
1428 HTMLElement_get_sourceIndex
,
1429 HTMLElement_get_recordNumber
,
1430 HTMLElement_put_lang
,
1431 HTMLElement_get_lang
,
1432 HTMLElement_get_offsetLeft
,
1433 HTMLElement_get_offsetTop
,
1434 HTMLElement_get_offsetWidth
,
1435 HTMLElement_get_offsetHeight
,
1436 HTMLElement_get_offsetParent
,
1437 HTMLElement_put_innerHTML
,
1438 HTMLElement_get_innerHTML
,
1439 HTMLElement_put_innerText
,
1440 HTMLElement_get_innerText
,
1441 HTMLElement_put_outerHTML
,
1442 HTMLElement_get_outerHTML
,
1443 HTMLElement_put_outerText
,
1444 HTMLElement_get_outerText
,
1445 HTMLElement_insertAdjacentHTML
,
1446 HTMLElement_insertAdjacentText
,
1447 HTMLElement_get_parentTextEdit
,
1448 HTMLElement_get_isTextEdit
,
1450 HTMLElement_get_filters
,
1451 HTMLElement_put_ondragstart
,
1452 HTMLElement_get_ondragstart
,
1453 HTMLElement_toString
,
1454 HTMLElement_put_onbeforeupdate
,
1455 HTMLElement_get_onbeforeupdate
,
1456 HTMLElement_put_onafterupdate
,
1457 HTMLElement_get_onafterupdate
,
1458 HTMLElement_put_onerrorupdate
,
1459 HTMLElement_get_onerrorupdate
,
1460 HTMLElement_put_onrowexit
,
1461 HTMLElement_get_onrowexit
,
1462 HTMLElement_put_onrowenter
,
1463 HTMLElement_get_onrowenter
,
1464 HTMLElement_put_ondatasetchanged
,
1465 HTMLElement_get_ondatasetchanged
,
1466 HTMLElement_put_ondataavailable
,
1467 HTMLElement_get_ondataavailable
,
1468 HTMLElement_put_ondatasetcomplete
,
1469 HTMLElement_get_ondatasetcomplete
,
1470 HTMLElement_put_onfilterchange
,
1471 HTMLElement_get_onfilterchange
,
1472 HTMLElement_get_children
,
1476 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1478 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1482 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1483 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1484 *ppv
= HTMLELEM(This
);
1485 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1486 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1487 *ppv
= HTMLELEM(This
);
1488 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1489 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1490 *ppv
= HTMLELEM(This
);
1491 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1492 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1493 *ppv
= HTMLELEM2(This
);
1494 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1495 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1496 *ppv
= HTMLELEM3(This
);
1497 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1498 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1499 *ppv
= CONPTCONT(&This
->cp_container
);
1503 IHTMLElement_AddRef(HTMLELEM(This
));
1507 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1510 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1512 HTMLElement
*This
= HTMLELEM_NODE_THIS(iface
);
1514 ConnectionPointContainer_Destroy(&This
->cp_container
);
1517 nsIDOMHTMLElement_Release(This
->nselem
);
1519 HTMLDOMNode_destructor(&This
->node
);
1522 static const NodeImplVtbl HTMLElementImplVtbl
= {
1524 HTMLElement_destructor
1527 static const tid_t HTMLElement_iface_tids
[] = {
1536 static dispex_static_data_t HTMLElement_dispex
= {
1538 DispHTMLUnknownElement_tid
,
1540 HTMLElement_iface_tids
1543 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1545 This
->lpHTMLElementVtbl
= &HTMLElementVtbl
;
1547 HTMLElement2_Init(This
);
1548 HTMLElement3_Init(This
);
1550 init_dispex(&This
->node
.dispex
, (IUnknown
*)HTMLELEM(This
), dispex_data
? dispex_data
: &HTMLElement_dispex
);
1553 nsIDOMHTMLElement_AddRef(nselem
);
1554 This
->nselem
= nselem
;
1556 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1558 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)HTMLELEM(This
));
1561 HTMLElement
*HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
)
1563 nsIDOMHTMLElement
*nselem
;
1564 HTMLElement
*ret
= NULL
;
1565 nsAString class_name_str
;
1566 const PRUnichar
*class_name
;
1569 static const WCHAR wszA
[] = {'A',0};
1570 static const WCHAR wszBODY
[] = {'B','O','D','Y',0};
1571 static const WCHAR wszIFRAME
[] = {'I','F','R','A','M','E',0};
1572 static const WCHAR wszIMG
[] = {'I','M','G',0};
1573 static const WCHAR wszINPUT
[] = {'I','N','P','U','T',0};
1574 static const WCHAR wszOPTION
[] = {'O','P','T','I','O','N',0};
1575 static const WCHAR wszSCRIPT
[] = {'S','C','R','I','P','T',0};
1576 static const WCHAR wszSELECT
[] = {'S','E','L','E','C','T',0};
1577 static const WCHAR wszTABLE
[] = {'T','A','B','L','E',0};
1578 static const WCHAR wszTR
[] = {'T','R',0};
1579 static const WCHAR wszTEXTAREA
[] = {'T','E','X','T','A','R','E','A',0};
1581 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1582 if(NS_FAILED(nsres
))
1585 nsAString_Init(&class_name_str
, NULL
);
1586 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1588 nsAString_GetData(&class_name_str
, &class_name
);
1590 if(!strcmpW(class_name
, wszA
))
1591 ret
= HTMLAnchorElement_Create(doc
, nselem
);
1592 else if(!strcmpW(class_name
, wszBODY
))
1593 ret
= HTMLBodyElement_Create(doc
, nselem
);
1594 else if(!strcmpW(class_name
, wszIFRAME
))
1595 ret
= HTMLIFrame_Create(doc
, nselem
, NULL
);
1596 else if(!strcmpW(class_name
, wszIMG
))
1597 ret
= HTMLImgElement_Create(doc
, nselem
);
1598 else if(!strcmpW(class_name
, wszINPUT
))
1599 ret
= HTMLInputElement_Create(doc
, nselem
);
1600 else if(!strcmpW(class_name
, wszOPTION
))
1601 ret
= HTMLOptionElement_Create(doc
, nselem
);
1602 else if(!strcmpW(class_name
, wszSCRIPT
))
1603 ret
= HTMLScriptElement_Create(doc
, nselem
);
1604 else if(!strcmpW(class_name
, wszSELECT
))
1605 ret
= HTMLSelectElement_Create(doc
, nselem
);
1606 else if(!strcmpW(class_name
, wszTABLE
))
1607 ret
= HTMLTable_Create(doc
, nselem
);
1608 else if(!strcmpW(class_name
, wszTR
))
1609 ret
= HTMLTableRow_Create(doc
, nselem
);
1610 else if(!strcmpW(class_name
, wszTEXTAREA
))
1611 ret
= HTMLTextAreaElement_Create(doc
, nselem
);
1612 else if(use_generic
)
1613 ret
= HTMLGenericElement_Create(doc
, nselem
);
1616 ret
= heap_alloc_zero(sizeof(HTMLElement
));
1617 HTMLElement_Init(ret
, doc
, nselem
, NULL
);
1618 ret
->node
.vtbl
= &HTMLElementImplVtbl
;
1621 TRACE("%s ret %p\n", debugstr_w(class_name
), ret
);
1623 nsIDOMElement_Release(nselem
);
1624 nsAString_Finish(&class_name_str
);