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"
40 const IHTMLFiltersCollectionVtbl *lpHTMLFiltersCollectionVtbl;
43 } HTMLFiltersCollection;
45 #define HTMLFILTERSCOLLECTION(x) ((IHTMLFiltersCollection*) &(x)->lpHTMLFiltersCollectionVtbl)
47 #define HTMLFILTERSCOLLECTION_THIS(iface) \
48 DEFINE_THIS(HTMLFiltersCollection, HTMLFiltersCollection, iface)
50 IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
53 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
55 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
57 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
59 nsIDOMElement *nselem;
68 nsAString_InitDepend(&tag_str, tag);
69 nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
70 nsAString_Finish(&tag_str);
71 if(NS_FAILED(nsres)) {
72 ERR("CreateElement failed: %08x\n", nsres);
76 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
77 nsIDOMElement_Release(nselem);
78 if(NS_FAILED(nsres)) {
79 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
86 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
88 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
89 REFIID riid, void **ppv)
91 HTMLElement *This = HTMLELEM_THIS(iface);
93 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
96 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
98 HTMLElement *This = HTMLELEM_THIS(iface);
100 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->node));
103 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
105 HTMLElement *This = HTMLELEM_THIS(iface);
107 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->node));
110 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
112 HTMLElement *This = HTMLELEM_THIS(iface);
113 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
116 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
117 LCID lcid, ITypeInfo **ppTInfo)
119 HTMLElement *This = HTMLELEM_THIS(iface);
120 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
123 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
124 LPOLESTR *rgszNames, UINT cNames,
125 LCID lcid, DISPID *rgDispId)
127 HTMLElement *This = HTMLELEM_THIS(iface);
128 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
131 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
132 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
133 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
135 HTMLElement *This = HTMLELEM_THIS(iface);
136 return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid,
137 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
140 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
141 VARIANT AttributeValue, LONG lFlags)
143 HTMLElement *This = HTMLELEM_THIS(iface);
145 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
146 DISPPARAMS dispParams;
149 TRACE("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
151 hres = IDispatchEx_GetDispID(DISPATCHEX(&This->node.dispex), strAttributeName,
152 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
156 dispParams.cArgs = 1;
157 dispParams.cNamedArgs = 1;
158 dispParams.rgdispidNamedArgs = &dispidNamed;
159 dispParams.rgvarg = &AttributeValue;
161 hres = IDispatchEx_InvokeEx(DISPATCHEX(&This->node.dispex), dispid,
162 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams,
167 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
168 LONG lFlags, VARIANT *AttributeValue)
170 HTMLElement *This = HTMLELEM_THIS(iface);
173 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
176 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
178 hres = IDispatchEx_GetDispID(DISPATCHEX(&This->node.dispex), strAttributeName,
179 fdexNameCaseInsensitive, &dispid);
180 if(hres == DISP_E_UNKNOWNNAME) {
181 V_VT(AttributeValue) = VT_NULL;
186 V_VT(AttributeValue) = VT_NULL;
190 hres = IDispatchEx_InvokeEx(DISPATCHEX(&This->node.dispex), dispid,
191 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dispParams,
192 AttributeValue, &excep, NULL);
197 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
198 LONG lFlags, VARIANT_BOOL *pfSuccess)
200 HTMLElement *This = HTMLELEM_THIS(iface);
201 FIXME("(%p)->()\n", This);
205 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
207 HTMLElement *This = HTMLELEM_THIS(iface);
208 nsAString classname_str;
211 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
214 FIXME("NULL nselem\n");
218 nsAString_InitDepend(&classname_str, v);
219 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
220 nsAString_Finish(&classname_str);
222 ERR("SetClassName failed: %08x\n", nsres);
227 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
229 HTMLElement *This = HTMLELEM_THIS(iface);
234 TRACE("(%p)->(%p)\n", This, p);
237 FIXME("NULL nselem\n");
241 nsAString_Init(&class_str, NULL);
242 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
244 if(NS_SUCCEEDED(nsres)) {
245 const PRUnichar *class;
246 nsAString_GetData(&class_str, &class);
247 *p = *class ? SysAllocString(class) : NULL;
249 ERR("GetClassName failed: %08x\n", nsres);
253 nsAString_Finish(&class_str);
255 TRACE("className=%s\n", debugstr_w(*p));
259 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
261 HTMLElement *This = HTMLELEM_THIS(iface);
265 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
268 FIXME("nselem == NULL\n");
272 nsAString_InitDepend(&id_str, v);
273 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
274 nsAString_Finish(&id_str);
276 ERR("SetId failed: %08x\n", nsres);
281 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
283 HTMLElement *This = HTMLELEM_THIS(iface);
288 TRACE("(%p)->(%p)\n", This, p);
295 nsAString_Init(&id_str, NULL);
296 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
297 nsAString_GetData(&id_str, &id);
300 ERR("GetId failed: %08x\n", nsres);
302 *p = SysAllocString(id);
304 nsAString_Finish(&id_str);
308 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
310 HTMLElement *This = HTMLELEM_THIS(iface);
311 const PRUnichar *tag;
315 TRACE("(%p)->(%p)\n", This, p);
318 static const WCHAR comment_tagW[] = {'!',0};
320 WARN("NULL nselem, assuming comment\n");
322 *p = SysAllocString(comment_tagW);
326 nsAString_Init(&tag_str, NULL);
327 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
328 if(NS_SUCCEEDED(nsres)) {
329 nsAString_GetData(&tag_str, &tag);
330 *p = SysAllocString(tag);
332 ERR("GetTagName failed: %08x\n", nsres);
335 nsAString_Finish(&tag_str);
340 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
342 HTMLElement *This = HTMLELEM_THIS(iface);
346 TRACE("(%p)->(%p)\n", This, p);
348 hres = IHTMLDOMNode_get_parentNode(HTMLDOMNODE(&This->node), &node);
352 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
353 IHTMLDOMNode_Release(node);
360 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
362 HTMLElement *This = HTMLELEM_THIS(iface);
363 nsIDOMElementCSSInlineStyle *nselemstyle;
364 nsIDOMCSSStyleDeclaration *nsstyle;
367 TRACE("(%p)->(%p)\n", This, p);
370 FIXME("NULL nselem\n");
374 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
375 (void**)&nselemstyle);
376 if(NS_FAILED(nsres)) {
377 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
381 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
382 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
383 if(NS_FAILED(nsres)) {
384 ERR("GetStyle failed: %08x\n", nsres);
388 /* FIXME: Store style instead of creating a new instance in each call */
389 *p = HTMLStyle_Create(nsstyle);
391 nsIDOMCSSStyleDeclaration_Release(nsstyle);
395 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
397 HTMLElement *This = HTMLELEM_THIS(iface);
398 FIXME("(%p)->()\n", This);
402 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
404 HTMLElement *This = HTMLELEM_THIS(iface);
405 FIXME("(%p)->(%p)\n", This, p);
409 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
411 HTMLElement *This = HTMLELEM_THIS(iface);
413 TRACE("(%p)->()\n", This);
415 return set_node_event(&This->node, EVENTID_CLICK, &v);
418 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
420 HTMLElement *This = HTMLELEM_THIS(iface);
422 TRACE("(%p)->(%p)\n", This, p);
424 return get_node_event(&This->node, EVENTID_CLICK, p);
427 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
429 HTMLElement *This = HTMLELEM_THIS(iface);
431 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
433 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
436 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
438 HTMLElement *This = HTMLELEM_THIS(iface);
440 TRACE("(%p)->(%p)\n", This, p);
442 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
445 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
447 HTMLElement *This = HTMLELEM_THIS(iface);
449 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
451 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
454 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
456 HTMLElement *This = HTMLELEM_THIS(iface);
458 TRACE("(%p)->(%p)\n", This, p);
460 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
463 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
465 HTMLElement *This = HTMLELEM_THIS(iface);
467 TRACE("(%p)->()\n", This);
469 return set_node_event(&This->node, EVENTID_KEYUP, &v);
472 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
474 HTMLElement *This = HTMLELEM_THIS(iface);
475 FIXME("(%p)->(%p)\n", This, p);
479 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
481 HTMLElement *This = HTMLELEM_THIS(iface);
482 FIXME("(%p)->()\n", This);
486 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
488 HTMLElement *This = HTMLELEM_THIS(iface);
489 FIXME("(%p)->(%p)\n", This, p);
493 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
495 HTMLElement *This = HTMLELEM_THIS(iface);
497 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
499 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
502 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
504 HTMLElement *This = HTMLELEM_THIS(iface);
506 TRACE("(%p)->(%p)\n", This, p);
508 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
511 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
513 HTMLElement *This = HTMLELEM_THIS(iface);
515 TRACE("(%p)->()\n", This);
517 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
520 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
522 HTMLElement *This = HTMLELEM_THIS(iface);
524 TRACE("(%p)->(%p)\n", This, p);
526 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
529 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
531 HTMLElement *This = HTMLELEM_THIS(iface);
532 FIXME("(%p)->()\n", This);
536 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
538 HTMLElement *This = HTMLELEM_THIS(iface);
539 FIXME("(%p)->(%p)\n", This, p);
543 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
545 HTMLElement *This = HTMLELEM_THIS(iface);
547 TRACE("(%p)->()\n", This);
549 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
552 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
554 HTMLElement *This = HTMLELEM_THIS(iface);
556 TRACE("(%p)->(%p)\n", This, p);
558 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
561 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
563 HTMLElement *This = HTMLELEM_THIS(iface);
565 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
567 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
570 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
572 HTMLElement *This = HTMLELEM_THIS(iface);
574 TRACE("(%p)->(%p)\n", This, p);
576 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
579 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
581 HTMLElement *This = HTMLELEM_THIS(iface);
583 TRACE("(%p)->(%p)\n", This, p);
588 if(This->node.vtbl->get_document)
589 return This->node.vtbl->get_document(&This->node, p);
591 *p = (IDispatch*)HTMLDOC(&This->node.doc->basedoc);
592 IDispatch_AddRef(*p);
596 static const WCHAR titleW[] = {'t','i','t','l','e',0};
598 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
600 HTMLElement *This = HTMLELEM_THIS(iface);
604 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
610 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
616 V_BSTR(var) = v ? SysAllocString(v) : NULL;
620 nsAString_InitDepend(&title_str, v);
621 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
622 nsAString_Finish(&title_str);
624 ERR("SetTitle failed: %08x\n", nsres);
629 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
631 HTMLElement *This = HTMLELEM_THIS(iface);
635 TRACE("(%p)->(%p)\n", This, p);
641 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
642 if(hres == DISP_E_UNKNOWNNAME) {
644 }else if(V_VT(var) != VT_BSTR) {
645 FIXME("title = %s\n", debugstr_variant(var));
648 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
654 nsAString_Init(&title_str, NULL);
655 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
656 if(NS_SUCCEEDED(nsres)) {
657 const PRUnichar *title;
659 nsAString_GetData(&title_str, &title);
660 *p = *title ? SysAllocString(title) : NULL;
662 ERR("GetTitle failed: %08x\n", nsres);
669 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
671 HTMLElement *This = HTMLELEM_THIS(iface);
672 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
676 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
678 HTMLElement *This = HTMLELEM_THIS(iface);
679 FIXME("(%p)->(%p)\n", This, p);
683 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
685 HTMLElement *This = HTMLELEM_THIS(iface);
687 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
689 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
692 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
694 HTMLElement *This = HTMLELEM_THIS(iface);
696 TRACE("(%p)->(%p)\n", This, p);
698 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
701 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
703 HTMLElement *This = HTMLELEM_THIS(iface);
704 FIXME("(%p)->()\n", This);
708 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
709 VARIANT_BOOL *pfResult)
711 HTMLElement *This = HTMLELEM_THIS(iface);
712 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
716 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
718 HTMLElement *This = HTMLELEM_THIS(iface);
719 FIXME("(%p)->(%p)\n", This, p);
723 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
725 HTMLElement *This = HTMLELEM_THIS(iface);
726 FIXME("(%p)->(%p)\n", This, p);
730 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
732 HTMLElement *This = HTMLELEM_THIS(iface);
733 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
737 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
739 HTMLElement *This = HTMLELEM_THIS(iface);
740 FIXME("(%p)->(%p)\n", This, p);
744 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
746 HTMLElement *This = HTMLELEM_THIS(iface);
747 FIXME("(%p)->(%p)\n", This, p);
751 static HRESULT WINAPI HTMLElement_get_offsetTop(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_GetOffsetTop(nselem, &top);
767 nsIDOMNSHTMLElement_Release(nselem);
768 if(NS_FAILED(nsres)) {
769 ERR("GetOffsetTop failed: %08x\n", nsres);
777 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
779 HTMLElement *This = HTMLELEM_THIS(iface);
780 nsIDOMNSHTMLElement *nselem;
784 TRACE("(%p)->(%p)\n", This, p);
786 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
787 if(NS_FAILED(nsres)) {
788 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
792 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
793 nsIDOMNSHTMLElement_Release(nselem);
794 if(NS_FAILED(nsres)) {
795 ERR("GetOffsetWidth failed: %08x\n", nsres);
803 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
805 HTMLElement *This = HTMLELEM_THIS(iface);
806 nsIDOMNSHTMLElement *nselem;
810 TRACE("(%p)->(%p)\n", This, p);
812 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
813 if(NS_FAILED(nsres)) {
814 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
818 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
819 nsIDOMNSHTMLElement_Release(nselem);
820 if(NS_FAILED(nsres)) {
821 ERR("GetOffsetHeight failed: %08x\n", nsres);
829 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
831 HTMLElement *This = HTMLELEM_THIS(iface);
832 FIXME("(%p)->(%p)\n", This, p);
836 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
838 HTMLElement *This = HTMLELEM_THIS(iface);
839 nsIDOMNSHTMLElement *nselem;
843 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
846 FIXME("NULL nselem\n");
850 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
851 if(NS_FAILED(nsres)) {
852 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
856 nsAString_InitDepend(&html_str, v);
857 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
858 nsAString_Finish(&html_str);
860 if(NS_FAILED(nsres)) {
861 FIXME("SetInnerHtml failed %08x\n", nsres);
868 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
870 HTMLElement *This = HTMLELEM_THIS(iface);
871 nsIDOMNSHTMLElement *nselem;
875 TRACE("(%p)->(%p)\n", This, p);
878 FIXME("NULL nselem\n");
882 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
883 if(NS_FAILED(nsres)) {
884 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
888 nsAString_Init(&html_str, NULL);
889 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
890 if(NS_SUCCEEDED(nsres)) {
891 const PRUnichar *html;
893 nsAString_GetData(&html_str, &html);
894 *p = *html ? SysAllocString(html) : NULL;
896 FIXME("SetInnerHtml failed %08x\n", nsres);
900 nsAString_Finish(&html_str);
904 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
906 HTMLElement *This = HTMLELEM_THIS(iface);
907 nsIDOMNode *nschild, *tmp;
908 nsIDOMText *text_node;
912 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
915 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
916 if(NS_FAILED(nsres)) {
917 ERR("GetLastChild failed: %08x\n", nsres);
923 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
924 nsIDOMNode_Release(nschild);
925 if(NS_FAILED(nsres)) {
926 ERR("RemoveChild failed: %08x\n", nsres);
929 nsIDOMNode_Release(tmp);
932 nsAString_InitDepend(&text_str, v);
933 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
934 nsAString_Finish(&text_str);
935 if(NS_FAILED(nsres)) {
936 ERR("CreateTextNode failed: %08x\n", nsres);
940 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
941 if(NS_FAILED(nsres)) {
942 ERR("AppendChild failed: %08x\n", nsres);
946 nsIDOMNode_Release(tmp);
950 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
952 HTMLElement *This = HTMLELEM_THIS(iface);
954 TRACE("(%p)->(%p)\n", This, p);
956 return get_node_text(&This->node, p);
959 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
961 HTMLElement *This = HTMLELEM_THIS(iface);
962 nsIDOMDocumentFragment *nsfragment;
963 nsIDOMDocumentRange *nsdocrange;
964 nsIDOMNSRange *nsrange;
965 nsIDOMNode *nsparent;
971 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
973 nsres = nsIDOMHTMLDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
977 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
978 nsIDOMDocumentRange_Release(nsdocrange);
979 if(NS_FAILED(nsres)) {
980 ERR("CreateRange failed: %08x\n", nsres);
984 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
985 nsIDOMRange_Release(range);
986 if(NS_FAILED(nsres)) {
987 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
991 nsAString_InitDepend(&html_str, v);
992 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
993 nsIDOMNSRange_Release(nsrange);
994 nsAString_Finish(&html_str);
995 if(NS_FAILED(nsres)) {
996 ERR("CreateContextualFragment failed: %08x\n", nsres);
1000 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsparent);
1001 if(NS_SUCCEEDED(nsres) && nsparent) {
1004 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, This->node.nsnode, &nstmp);
1005 nsIDOMNode_Release(nsparent);
1006 if(NS_FAILED(nsres)) {
1007 ERR("ReplaceChild failed: %08x\n", nsres);
1010 nsIDOMNode_Release(nstmp);
1013 ERR("GetParentNode failed: %08x\n", nsres);
1017 nsIDOMDocumentFragment_Release(nsfragment);
1021 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1023 HTMLElement *This = HTMLELEM_THIS(iface);
1027 WARN("(%p)->(%p) semi-stub\n", This, p);
1029 nsAString_Init(&html_str, NULL);
1030 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1031 if(SUCCEEDED(hres)) {
1032 const PRUnichar *html;
1034 nsAString_GetData(&html_str, &html);
1035 *p = SysAllocString(html);
1037 hres = E_OUTOFMEMORY;
1040 nsAString_Finish(&html_str);
1042 TRACE("ret %s\n", debugstr_w(*p));
1046 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1048 HTMLElement *This = HTMLELEM_THIS(iface);
1049 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1053 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1055 HTMLElement *This = HTMLELEM_THIS(iface);
1056 FIXME("(%p)->(%p)\n", This, p);
1060 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1062 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1063 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1064 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1065 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1068 if (!strcmpiW(where, wszBeforeBegin))
1072 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1073 if (!parent) return E_INVALIDARG;
1074 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1075 if (unused) nsIDOMNode_Release(unused);
1076 nsIDOMNode_Release(parent);
1078 else if (!strcmpiW(where, wszAfterBegin))
1081 nsIDOMNode *first_child;
1082 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1083 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1084 if (unused) nsIDOMNode_Release(unused);
1085 if (first_child) nsIDOMNode_Release(first_child);
1087 else if (!strcmpiW(where, wszBeforeEnd))
1090 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1091 if (unused) nsIDOMNode_Release(unused);
1093 else if (!strcmpiW(where, wszAfterEnd))
1096 nsIDOMNode *next_sibling;
1098 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1099 if (!parent) return E_INVALIDARG;
1101 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1104 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1105 nsIDOMNode_Release(next_sibling);
1108 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1109 nsIDOMNode_Release(parent);
1110 if (unused) nsIDOMNode_Release(unused);
1114 ERR("invalid where: %s\n", debugstr_w(where));
1115 return E_INVALIDARG;
1118 if (NS_FAILED(nsres))
1124 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1127 HTMLElement *This = HTMLELEM_THIS(iface);
1128 nsIDOMDocumentRange *nsdocrange;
1130 nsIDOMNSRange *nsrange;
1136 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1138 if(!This->node.doc->nsdoc) {
1139 WARN("NULL nsdoc\n");
1140 return E_UNEXPECTED;
1143 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1144 if(NS_FAILED(nsres))
1146 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1149 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1150 nsIDOMDocumentRange_Release(nsdocrange);
1151 if(NS_FAILED(nsres))
1153 ERR("CreateRange failed: %08x\n", nsres);
1157 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1159 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1160 nsIDOMRange_Release(range);
1161 if(NS_FAILED(nsres))
1163 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1167 nsAString_InitDepend(&ns_html, html);
1169 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1170 nsIDOMNSRange_Release(nsrange);
1171 nsAString_Finish(&ns_html);
1173 if(NS_FAILED(nsres) || !nsnode)
1175 ERR("CreateTextNode failed: %08x\n", nsres);
1179 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1180 nsIDOMNode_Release(nsnode);
1185 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1188 HTMLElement *This = HTMLELEM_THIS(iface);
1194 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1196 if(!This->node.doc->nsdoc) {
1197 WARN("NULL nsdoc\n");
1198 return E_UNEXPECTED;
1202 nsAString_InitDepend(&ns_text, text);
1203 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1204 nsAString_Finish(&ns_text);
1206 if(NS_FAILED(nsres) || !nsnode)
1208 ERR("CreateTextNode failed: %08x\n", nsres);
1212 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1213 nsIDOMNode_Release(nsnode);
1218 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1220 HTMLElement *This = HTMLELEM_THIS(iface);
1221 FIXME("(%p)->(%p)\n", This, p);
1225 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1227 HTMLElement *This = HTMLELEM_THIS(iface);
1228 FIXME("(%p)->(%p)\n", This, p);
1232 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1234 HTMLElement *This = HTMLELEM_THIS(iface);
1236 TRACE("(%p)\n", This);
1238 return call_event(&This->node, EVENTID_CLICK);
1241 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1242 IHTMLFiltersCollection **p)
1244 HTMLElement *This = HTMLELEM_THIS(iface);
1245 TRACE("(%p)->(%p)\n", This, p);
1250 *p = HTMLFiltersCollection_Create();
1255 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1257 HTMLElement *This = HTMLELEM_THIS(iface);
1258 FIXME("(%p)->()\n", This);
1262 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1264 HTMLElement *This = HTMLELEM_THIS(iface);
1265 FIXME("(%p)->(%p)\n", This, p);
1269 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1271 HTMLElement *This = HTMLELEM_THIS(iface);
1272 FIXME("(%p)->(%p)\n", This, String);
1276 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1278 HTMLElement *This = HTMLELEM_THIS(iface);
1279 FIXME("(%p)->()\n", This);
1283 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1285 HTMLElement *This = HTMLELEM_THIS(iface);
1286 FIXME("(%p)->(%p)\n", This, p);
1290 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1292 HTMLElement *This = HTMLELEM_THIS(iface);
1293 FIXME("(%p)->()\n", This);
1297 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1299 HTMLElement *This = HTMLELEM_THIS(iface);
1300 FIXME("(%p)->(%p)\n", This, p);
1304 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1306 HTMLElement *This = HTMLELEM_THIS(iface);
1307 FIXME("(%p)->()\n", This);
1311 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1313 HTMLElement *This = HTMLELEM_THIS(iface);
1314 FIXME("(%p)->(%p)\n", This, p);
1318 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1320 HTMLElement *This = HTMLELEM_THIS(iface);
1321 FIXME("(%p)->()\n", This);
1325 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1327 HTMLElement *This = HTMLELEM_THIS(iface);
1328 FIXME("(%p)->(%p)\n", This, p);
1332 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1334 HTMLElement *This = HTMLELEM_THIS(iface);
1335 FIXME("(%p)->()\n", This);
1339 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1341 HTMLElement *This = HTMLELEM_THIS(iface);
1342 FIXME("(%p)->(%p)\n", This, p);
1346 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1348 HTMLElement *This = HTMLELEM_THIS(iface);
1349 FIXME("(%p)->()\n", This);
1353 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1355 HTMLElement *This = HTMLELEM_THIS(iface);
1356 FIXME("(%p)->(%p)\n", This, p);
1360 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1362 HTMLElement *This = HTMLELEM_THIS(iface);
1363 FIXME("(%p)->()\n", This);
1367 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1369 HTMLElement *This = HTMLELEM_THIS(iface);
1370 FIXME("(%p)->(%p)\n", This, p);
1374 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1376 HTMLElement *This = HTMLELEM_THIS(iface);
1377 FIXME("(%p)->()\n", This);
1381 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1383 HTMLElement *This = HTMLELEM_THIS(iface);
1384 FIXME("(%p)->(%p)\n", This, p);
1388 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1390 HTMLElement *This = HTMLELEM_THIS(iface);
1391 FIXME("(%p)->()\n", This);
1395 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1397 HTMLElement *This = HTMLELEM_THIS(iface);
1398 FIXME("(%p)->(%p)\n", This, p);
1402 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1404 HTMLElement *This = HTMLELEM_THIS(iface);
1405 nsIDOMNodeList *nsnode_list;
1408 TRACE("(%p)->(%p)\n", This, p);
1410 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1411 if(NS_FAILED(nsres)) {
1412 ERR("GetChildNodes failed: %08x\n", nsres);
1416 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
1418 nsIDOMNodeList_Release(nsnode_list);
1422 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1424 HTMLElement *This = HTMLELEM_THIS(iface);
1426 TRACE("(%p)->(%p)\n", This, p);
1428 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1432 static HRESULT HTMLElement_get_dispid(IUnknown *iface, BSTR name,
1433 DWORD grfdex, DISPID *pid)
1435 HTMLElement *This = HTMLELEM_THIS(iface);
1437 if(This->node.vtbl->get_dispid)
1438 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1440 return DISP_E_UNKNOWNNAME;
1443 static HRESULT HTMLElement_invoke(IUnknown *iface, DISPID id, LCID lcid,
1444 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1445 IServiceProvider *caller)
1447 HTMLElement *This = HTMLELEM_THIS(iface);
1449 if(This->node.vtbl->invoke)
1450 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1451 params, res, ei, caller);
1453 ERR("(%p): element has no invoke method\n", This);
1457 #undef HTMLELEM_THIS
1459 static const IHTMLElementVtbl HTMLElementVtbl = {
1460 HTMLElement_QueryInterface,
1462 HTMLElement_Release,
1463 HTMLElement_GetTypeInfoCount,
1464 HTMLElement_GetTypeInfo,
1465 HTMLElement_GetIDsOfNames,
1467 HTMLElement_setAttribute,
1468 HTMLElement_getAttribute,
1469 HTMLElement_removeAttribute,
1470 HTMLElement_put_className,
1471 HTMLElement_get_className,
1474 HTMLElement_get_tagName,
1475 HTMLElement_get_parentElement,
1476 HTMLElement_get_style,
1477 HTMLElement_put_onhelp,
1478 HTMLElement_get_onhelp,
1479 HTMLElement_put_onclick,
1480 HTMLElement_get_onclick,
1481 HTMLElement_put_ondblclick,
1482 HTMLElement_get_ondblclick,
1483 HTMLElement_put_onkeydown,
1484 HTMLElement_get_onkeydown,
1485 HTMLElement_put_onkeyup,
1486 HTMLElement_get_onkeyup,
1487 HTMLElement_put_onkeypress,
1488 HTMLElement_get_onkeypress,
1489 HTMLElement_put_onmouseout,
1490 HTMLElement_get_onmouseout,
1491 HTMLElement_put_onmouseover,
1492 HTMLElement_get_onmouseover,
1493 HTMLElement_put_onmousemove,
1494 HTMLElement_get_onmousemove,
1495 HTMLElement_put_onmousedown,
1496 HTMLElement_get_onmousedown,
1497 HTMLElement_put_onmouseup,
1498 HTMLElement_get_onmouseup,
1499 HTMLElement_get_document,
1500 HTMLElement_put_title,
1501 HTMLElement_get_title,
1502 HTMLElement_put_language,
1503 HTMLElement_get_language,
1504 HTMLElement_put_onselectstart,
1505 HTMLElement_get_onselectstart,
1506 HTMLElement_scrollIntoView,
1507 HTMLElement_contains,
1508 HTMLElement_get_sourceIndex,
1509 HTMLElement_get_recordNumber,
1510 HTMLElement_put_lang,
1511 HTMLElement_get_lang,
1512 HTMLElement_get_offsetLeft,
1513 HTMLElement_get_offsetTop,
1514 HTMLElement_get_offsetWidth,
1515 HTMLElement_get_offsetHeight,
1516 HTMLElement_get_offsetParent,
1517 HTMLElement_put_innerHTML,
1518 HTMLElement_get_innerHTML,
1519 HTMLElement_put_innerText,
1520 HTMLElement_get_innerText,
1521 HTMLElement_put_outerHTML,
1522 HTMLElement_get_outerHTML,
1523 HTMLElement_put_outerText,
1524 HTMLElement_get_outerText,
1525 HTMLElement_insertAdjacentHTML,
1526 HTMLElement_insertAdjacentText,
1527 HTMLElement_get_parentTextEdit,
1528 HTMLElement_get_isTextEdit,
1530 HTMLElement_get_filters,
1531 HTMLElement_put_ondragstart,
1532 HTMLElement_get_ondragstart,
1533 HTMLElement_toString,
1534 HTMLElement_put_onbeforeupdate,
1535 HTMLElement_get_onbeforeupdate,
1536 HTMLElement_put_onafterupdate,
1537 HTMLElement_get_onafterupdate,
1538 HTMLElement_put_onerrorupdate,
1539 HTMLElement_get_onerrorupdate,
1540 HTMLElement_put_onrowexit,
1541 HTMLElement_get_onrowexit,
1542 HTMLElement_put_onrowenter,
1543 HTMLElement_get_onrowenter,
1544 HTMLElement_put_ondatasetchanged,
1545 HTMLElement_get_ondatasetchanged,
1546 HTMLElement_put_ondataavailable,
1547 HTMLElement_get_ondataavailable,
1548 HTMLElement_put_ondatasetcomplete,
1549 HTMLElement_get_ondatasetcomplete,
1550 HTMLElement_put_onfilterchange,
1551 HTMLElement_get_onfilterchange,
1552 HTMLElement_get_children,
1556 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1558 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1562 if(IsEqualGUID(&IID_IUnknown, riid)) {
1563 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1564 *ppv = HTMLELEM(This);
1565 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1566 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1567 *ppv = HTMLELEM(This);
1568 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1569 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1570 *ppv = HTMLELEM(This);
1571 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1572 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1573 *ppv = HTMLELEM2(This);
1574 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1575 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1576 *ppv = HTMLELEM3(This);
1577 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1578 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1579 *ppv = CONPTCONT(&This->cp_container);
1583 IHTMLElement_AddRef(HTMLELEM(This));
1587 return HTMLDOMNode_QI(&This->node, riid, ppv);
1590 void HTMLElement_destructor(HTMLDOMNode *iface)
1592 HTMLElement *This = HTMLELEM_NODE_THIS(iface);
1594 ConnectionPointContainer_Destroy(&This->cp_container);
1597 nsIDOMHTMLElement_Release(This->nselem);
1599 HTMLDOMNode_destructor(&This->node);
1602 static const NodeImplVtbl HTMLElementImplVtbl = {
1604 HTMLElement_destructor
1607 static const tid_t HTMLElement_iface_tids[] = {
1612 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1614 HTMLElement_get_dispid,
1618 static dispex_static_data_t HTMLElement_dispex = {
1619 &HTMLElement_dispex_vtbl,
1620 DispHTMLUnknownElement_tid,
1622 HTMLElement_iface_tids
1625 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1627 This->lpHTMLElementVtbl = &HTMLElementVtbl;
1629 HTMLElement2_Init(This);
1630 HTMLElement3_Init(This);
1632 if(dispex_data && !dispex_data->vtbl)
1633 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1634 init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), dispex_data ? dispex_data : &HTMLElement_dispex);
1637 nsIDOMHTMLElement_AddRef(nselem);
1638 This->nselem = nselem;
1640 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1642 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
1645 HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic)
1647 nsIDOMHTMLElement *nselem;
1648 HTMLElement *ret = NULL;
1649 nsAString class_name_str;
1650 const PRUnichar *class_name;
1653 static const WCHAR wszA[] = {'A',0};
1654 static const WCHAR wszBODY[] = {'B','O','D','Y',0};
1655 static const WCHAR wszFORM[] = {'F','O','R','M',0};
1656 static const WCHAR wszFRAME[] = {'F','R','A','M','E',0};
1657 static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0};
1658 static const WCHAR wszIMG[] = {'I','M','G',0};
1659 static const WCHAR wszINPUT[] = {'I','N','P','U','T',0};
1660 static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0};
1661 static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0};
1662 static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0};
1663 static const WCHAR wszTABLE[] = {'T','A','B','L','E',0};
1664 static const WCHAR wszTR[] = {'T','R',0};
1665 static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0};
1667 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1668 if(NS_FAILED(nsres))
1671 nsAString_Init(&class_name_str, NULL);
1672 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1674 nsAString_GetData(&class_name_str, &class_name);
1676 if(!strcmpW(class_name, wszA))
1677 ret = HTMLAnchorElement_Create(doc, nselem);
1678 else if(!strcmpW(class_name, wszBODY))
1679 ret = HTMLBodyElement_Create(doc, nselem);
1680 else if(!strcmpW(class_name, wszFORM))
1681 ret = HTMLFormElement_Create(doc, nselem);
1682 else if(!strcmpW(class_name, wszFRAME))
1683 ret = HTMLFrameElement_Create(doc, nselem);
1684 else if(!strcmpW(class_name, wszIFRAME))
1685 ret = HTMLIFrame_Create(doc, nselem);
1686 else if(!strcmpW(class_name, wszIMG))
1687 ret = HTMLImgElement_Create(doc, nselem);
1688 else if(!strcmpW(class_name, wszINPUT))
1689 ret = HTMLInputElement_Create(doc, nselem);
1690 else if(!strcmpW(class_name, wszOPTION))
1691 ret = HTMLOptionElement_Create(doc, nselem);
1692 else if(!strcmpW(class_name, wszSCRIPT))
1693 ret = HTMLScriptElement_Create(doc, nselem);
1694 else if(!strcmpW(class_name, wszSELECT))
1695 ret = HTMLSelectElement_Create(doc, nselem);
1696 else if(!strcmpW(class_name, wszTABLE))
1697 ret = HTMLTable_Create(doc, nselem);
1698 else if(!strcmpW(class_name, wszTR))
1699 ret = HTMLTableRow_Create(doc, nselem);
1700 else if(!strcmpW(class_name, wszTEXTAREA))
1701 ret = HTMLTextAreaElement_Create(doc, nselem);
1702 else if(use_generic)
1703 ret = HTMLGenericElement_Create(doc, nselem);
1706 ret = heap_alloc_zero(sizeof(HTMLElement));
1707 HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex);
1708 ret->node.vtbl = &HTMLElementImplVtbl;
1711 TRACE("%s ret %p\n", debugstr_w(class_name), ret);
1713 nsIDOMElement_Release(nselem);
1714 nsAString_Finish(&class_name_str);
1719 /* interaface IHTMLFiltersCollection */
1720 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1722 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1724 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1726 if(IsEqualGUID(&IID_IUnknown, riid)) {
1727 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1728 *ppv = HTMLFILTERSCOLLECTION(This);
1729 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1730 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1731 *ppv = HTMLFILTERSCOLLECTION(This);
1732 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1733 return *ppv ? S_OK : E_NOINTERFACE;
1737 IUnknown_AddRef((IUnknown*)*ppv);
1741 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1742 return E_NOINTERFACE;
1745 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1747 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1748 LONG ref = InterlockedIncrement(&This->ref);
1750 TRACE("(%p) ref=%d\n", This, ref);
1755 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1757 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1758 LONG ref = InterlockedDecrement(&This->ref);
1760 TRACE("(%p) ref=%d\n", This, ref);
1770 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1772 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1773 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1776 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1777 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1779 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1780 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1783 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1784 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1785 LCID lcid, DISPID *rgDispId)
1787 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1788 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1791 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1792 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1793 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1795 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1796 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
1797 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1800 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1802 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1804 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1815 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1817 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1818 FIXME("(%p)->(%p)\n", This, p);
1822 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1824 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1825 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1829 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1830 HTMLFiltersCollection_QueryInterface,
1831 HTMLFiltersCollection_AddRef,
1832 HTMLFiltersCollection_Release,
1833 HTMLFiltersCollection_GetTypeInfoCount,
1834 HTMLFiltersCollection_GetTypeInfo,
1835 HTMLFiltersCollection_GetIDsOfNames,
1836 HTMLFiltersCollection_Invoke,
1837 HTMLFiltersCollection_get_length,
1838 HTMLFiltersCollection_get__newEnum,
1839 HTMLFiltersCollection_item
1842 static HRESULT HTMLFiltersCollection_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid)
1847 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1848 idx = idx*10 + (*ptr-'0');
1850 return DISP_E_UNKNOWNNAME;
1852 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1853 TRACE("ret %x\n", *dispid);
1857 static HRESULT HTMLFiltersCollection_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1858 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1860 HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
1862 TRACE("(%p)->(%x %x %x %p %p %p)\n", This, id, lcid, flags, params, res, ei);
1864 V_VT(res) = VT_DISPATCH;
1865 V_DISPATCH(res) = NULL;
1867 FIXME("always returning NULL\n");
1872 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
1874 HTMLFiltersCollection_get_dispid,
1875 HTMLFiltersCollection_invoke
1878 static const tid_t HTMLFiltersCollection_iface_tids[] = {
1879 IHTMLFiltersCollection_tid,
1882 static dispex_static_data_t HTMLFiltersCollection_dispex = {
1883 &HTMLFiltersCollection_dispex_vtbl,
1884 IHTMLFiltersCollection_tid,
1886 HTMLFiltersCollection_iface_tids
1889 IHTMLFiltersCollection *HTMLFiltersCollection_Create()
1891 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
1893 ret->lpHTMLFiltersCollectionVtbl = &HTMLFiltersCollectionVtbl;
1896 init_dispex(&ret->dispex, (IUnknown*)HTMLFILTERSCOLLECTION(ret), &HTMLFiltersCollection_dispex);
1898 return HTMLFILTERSCOLLECTION(ret);