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"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
35 #include "htmlstyle.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 static const WCHAR aW[] = {'A',0};
40 static const WCHAR bodyW[] = {'B','O','D','Y',0};
41 static const WCHAR embedW[] = {'E','M','B','E','D',0};
42 static const WCHAR formW[] = {'F','O','R','M',0};
43 static const WCHAR frameW[] = {'F','R','A','M','E',0};
44 static const WCHAR headW[] = {'H','E','A','D',0};
45 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
46 static const WCHAR imgW[] = {'I','M','G',0};
47 static const WCHAR inputW[] = {'I','N','P','U','T',0};
48 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
49 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
50 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
51 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
52 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
53 static const WCHAR tableW[] = {'T','A','B','L','E',0};
54 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
55 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
56 static const WCHAR trW[] = {'T','R',0};
60 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
63 static const tag_desc_t tag_descs[] = {
64 {aW, HTMLAnchorElement_Create},
65 {bodyW, HTMLBodyElement_Create},
66 {embedW, HTMLEmbedElement_Create},
67 {formW, HTMLFormElement_Create},
68 {frameW, HTMLFrameElement_Create},
69 {headW, HTMLHeadElement_Create},
70 {iframeW, HTMLIFrame_Create},
71 {imgW, HTMLImgElement_Create},
72 {inputW, HTMLInputElement_Create},
73 {objectW, HTMLObjectElement_Create},
74 {optionW, HTMLOptionElement_Create},
75 {scriptW, HTMLScriptElement_Create},
76 {selectW, HTMLSelectElement_Create},
77 {styleW, HTMLStyleElement_Create},
78 {tableW, HTMLTable_Create},
79 {textareaW, HTMLTextAreaElement_Create},
80 {title_tagW, HTMLTitleElement_Create},
81 {trW, HTMLTableRow_Create}
84 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
86 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
91 r = strcmpW(tag_name, tag_descs[i].name);
104 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
106 nsIDOMDocumentFragment *nsfragment;
107 nsIDOMDocumentRange *nsdocrange;
108 nsIDOMNSRange *nsrange;
109 nsIDOMNode *nsparent;
115 nsres = nsIDOMHTMLDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
119 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
120 nsIDOMDocumentRange_Release(nsdocrange);
121 if(NS_FAILED(nsres)) {
122 ERR("CreateRange failed: %08x\n", nsres);
126 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
127 nsIDOMRange_Release(range);
128 if(NS_FAILED(nsres)) {
129 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
133 nsAString_InitDepend(&html_str, html);
134 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
135 nsIDOMNSRange_Release(nsrange);
136 nsAString_Finish(&html_str);
137 if(NS_FAILED(nsres)) {
138 ERR("CreateContextualFragment failed: %08x\n", nsres);
142 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
143 if(NS_SUCCEEDED(nsres) && nsparent) {
146 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
147 nsIDOMNode_Release(nsparent);
148 if(NS_FAILED(nsres)) {
149 ERR("ReplaceChild failed: %08x\n", nsres);
152 nsIDOMNode_Release(nstmp);
155 ERR("GetParentNode failed: %08x\n", nsres);
159 nsIDOMDocumentFragment_Release(nsfragment);
166 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
169 } HTMLFiltersCollection;
171 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
173 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
176 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
178 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
180 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
183 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
185 nsIDOMElement *nselem;
190 WARN("NULL nsdoc\n");
194 nsAString_InitDepend(&tag_str, tag);
195 nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
196 nsAString_Finish(&tag_str);
197 if(NS_FAILED(nsres)) {
198 ERR("CreateElement failed: %08x\n", nsres);
202 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
203 nsIDOMElement_Release(nselem);
204 if(NS_FAILED(nsres)) {
205 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
212 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
213 REFIID riid, void **ppv)
215 HTMLElement *This = impl_from_IHTMLElement(iface);
217 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
220 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
222 HTMLElement *This = impl_from_IHTMLElement(iface);
224 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
227 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
229 HTMLElement *This = impl_from_IHTMLElement(iface);
231 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
234 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
236 HTMLElement *This = impl_from_IHTMLElement(iface);
237 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
240 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
241 LCID lcid, ITypeInfo **ppTInfo)
243 HTMLElement *This = impl_from_IHTMLElement(iface);
244 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
247 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
248 LPOLESTR *rgszNames, UINT cNames,
249 LCID lcid, DISPID *rgDispId)
251 HTMLElement *This = impl_from_IHTMLElement(iface);
252 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
256 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
257 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
258 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
260 HTMLElement *This = impl_from_IHTMLElement(iface);
261 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
262 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
265 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
266 VARIANT AttributeValue, LONG lFlags)
268 HTMLElement *This = impl_from_IHTMLElement(iface);
270 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
271 DISPPARAMS dispParams;
274 TRACE("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
276 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
277 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
281 dispParams.cArgs = 1;
282 dispParams.cNamedArgs = 1;
283 dispParams.rgdispidNamedArgs = &dispidNamed;
284 dispParams.rgvarg = &AttributeValue;
286 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
287 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
291 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
292 LONG lFlags, VARIANT *AttributeValue)
294 HTMLElement *This = impl_from_IHTMLElement(iface);
297 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
300 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
302 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
303 fdexNameCaseInsensitive, &dispid);
304 if(hres == DISP_E_UNKNOWNNAME) {
305 V_VT(AttributeValue) = VT_NULL;
310 V_VT(AttributeValue) = VT_NULL;
314 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
315 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
320 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
321 LONG lFlags, VARIANT_BOOL *pfSuccess)
323 HTMLElement *This = impl_from_IHTMLElement(iface);
325 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
327 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
330 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
332 HTMLElement *This = impl_from_IHTMLElement(iface);
333 nsAString classname_str;
336 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
339 FIXME("NULL nselem\n");
343 nsAString_InitDepend(&classname_str, v);
344 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
345 nsAString_Finish(&classname_str);
347 ERR("SetClassName failed: %08x\n", nsres);
352 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
354 HTMLElement *This = impl_from_IHTMLElement(iface);
359 TRACE("(%p)->(%p)\n", This, p);
362 FIXME("NULL nselem\n");
366 nsAString_Init(&class_str, NULL);
367 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
369 if(NS_SUCCEEDED(nsres)) {
370 const PRUnichar *class;
371 nsAString_GetData(&class_str, &class);
372 *p = *class ? SysAllocString(class) : NULL;
374 ERR("GetClassName failed: %08x\n", nsres);
378 nsAString_Finish(&class_str);
380 TRACE("className=%s\n", debugstr_w(*p));
384 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
386 HTMLElement *This = impl_from_IHTMLElement(iface);
390 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
393 FIXME("nselem == NULL\n");
397 nsAString_InitDepend(&id_str, v);
398 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
399 nsAString_Finish(&id_str);
401 ERR("SetId failed: %08x\n", nsres);
406 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
408 HTMLElement *This = impl_from_IHTMLElement(iface);
413 TRACE("(%p)->(%p)\n", This, p);
420 nsAString_Init(&id_str, NULL);
421 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
422 nsAString_GetData(&id_str, &id);
425 ERR("GetId failed: %08x\n", nsres);
427 *p = SysAllocString(id);
429 nsAString_Finish(&id_str);
433 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
435 HTMLElement *This = impl_from_IHTMLElement(iface);
436 const PRUnichar *tag;
440 TRACE("(%p)->(%p)\n", This, p);
443 static const WCHAR comment_tagW[] = {'!',0};
445 WARN("NULL nselem, assuming comment\n");
447 *p = SysAllocString(comment_tagW);
451 nsAString_Init(&tag_str, NULL);
452 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
453 if(NS_SUCCEEDED(nsres)) {
454 nsAString_GetData(&tag_str, &tag);
455 *p = SysAllocString(tag);
457 ERR("GetTagName failed: %08x\n", nsres);
460 nsAString_Finish(&tag_str);
465 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
467 HTMLElement *This = impl_from_IHTMLElement(iface);
471 TRACE("(%p)->(%p)\n", This, p);
473 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
477 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
478 IHTMLDOMNode_Release(node);
485 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
487 HTMLElement *This = impl_from_IHTMLElement(iface);
489 TRACE("(%p)->(%p)\n", This, p);
492 nsIDOMElementCSSInlineStyle *nselemstyle;
493 nsIDOMCSSStyleDeclaration *nsstyle;
498 FIXME("NULL nselem\n");
502 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
503 (void**)&nselemstyle);
504 if(NS_FAILED(nsres)) {
505 ERR("Could not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
509 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
510 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
511 if(NS_FAILED(nsres)) {
512 ERR("GetStyle failed: %08x\n", nsres);
516 hres = HTMLStyle_Create(nsstyle, &This->style);
517 nsIDOMCSSStyleDeclaration_Release(nsstyle);
522 *p = &This->style->IHTMLStyle_iface;
523 IHTMLStyle_AddRef(*p);
527 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
529 HTMLElement *This = impl_from_IHTMLElement(iface);
530 FIXME("(%p)->()\n", This);
534 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
536 HTMLElement *This = impl_from_IHTMLElement(iface);
537 FIXME("(%p)->(%p)\n", This, p);
541 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
543 HTMLElement *This = impl_from_IHTMLElement(iface);
545 TRACE("(%p)->()\n", This);
547 return set_node_event(&This->node, EVENTID_CLICK, &v);
550 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
552 HTMLElement *This = impl_from_IHTMLElement(iface);
554 TRACE("(%p)->(%p)\n", This, p);
556 return get_node_event(&This->node, EVENTID_CLICK, p);
559 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
561 HTMLElement *This = impl_from_IHTMLElement(iface);
563 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
565 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
568 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
570 HTMLElement *This = impl_from_IHTMLElement(iface);
572 TRACE("(%p)->(%p)\n", This, p);
574 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
577 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
579 HTMLElement *This = impl_from_IHTMLElement(iface);
581 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
583 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
586 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
588 HTMLElement *This = impl_from_IHTMLElement(iface);
590 TRACE("(%p)->(%p)\n", This, p);
592 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
595 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
597 HTMLElement *This = impl_from_IHTMLElement(iface);
599 TRACE("(%p)->()\n", This);
601 return set_node_event(&This->node, EVENTID_KEYUP, &v);
604 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
606 HTMLElement *This = impl_from_IHTMLElement(iface);
607 FIXME("(%p)->(%p)\n", This, p);
611 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
613 HTMLElement *This = impl_from_IHTMLElement(iface);
614 FIXME("(%p)->()\n", This);
618 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
620 HTMLElement *This = impl_from_IHTMLElement(iface);
621 FIXME("(%p)->(%p)\n", This, p);
625 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
627 HTMLElement *This = impl_from_IHTMLElement(iface);
629 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
631 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
634 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
636 HTMLElement *This = impl_from_IHTMLElement(iface);
638 TRACE("(%p)->(%p)\n", This, p);
640 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
643 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
645 HTMLElement *This = impl_from_IHTMLElement(iface);
647 TRACE("(%p)->()\n", This);
649 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
652 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
654 HTMLElement *This = impl_from_IHTMLElement(iface);
656 TRACE("(%p)->(%p)\n", This, p);
658 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
661 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
663 HTMLElement *This = impl_from_IHTMLElement(iface);
665 TRACE("(%p)->()\n", This);
667 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
670 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
672 HTMLElement *This = impl_from_IHTMLElement(iface);
674 TRACE("(%p)->(%p)\n", This, p);
676 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
679 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
681 HTMLElement *This = impl_from_IHTMLElement(iface);
683 TRACE("(%p)->()\n", This);
685 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
688 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
690 HTMLElement *This = impl_from_IHTMLElement(iface);
692 TRACE("(%p)->(%p)\n", This, p);
694 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
697 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
699 HTMLElement *This = impl_from_IHTMLElement(iface);
701 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
703 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
706 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
708 HTMLElement *This = impl_from_IHTMLElement(iface);
710 TRACE("(%p)->(%p)\n", This, p);
712 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
715 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
717 HTMLElement *This = impl_from_IHTMLElement(iface);
719 TRACE("(%p)->(%p)\n", This, p);
724 if(This->node.vtbl->get_document)
725 return This->node.vtbl->get_document(&This->node, p);
727 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
728 IDispatch_AddRef(*p);
732 static const WCHAR titleW[] = {'t','i','t','l','e',0};
734 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
736 HTMLElement *This = impl_from_IHTMLElement(iface);
740 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
746 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
752 V_BSTR(var) = v ? SysAllocString(v) : NULL;
756 nsAString_InitDepend(&title_str, v);
757 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
758 nsAString_Finish(&title_str);
760 ERR("SetTitle failed: %08x\n", nsres);
765 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
767 HTMLElement *This = impl_from_IHTMLElement(iface);
771 TRACE("(%p)->(%p)\n", This, p);
777 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
778 if(hres == DISP_E_UNKNOWNNAME) {
780 }else if(V_VT(var) != VT_BSTR) {
781 FIXME("title = %s\n", debugstr_variant(var));
784 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
790 nsAString_Init(&title_str, NULL);
791 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
792 if(NS_SUCCEEDED(nsres)) {
793 const PRUnichar *title;
795 nsAString_GetData(&title_str, &title);
796 *p = *title ? SysAllocString(title) : NULL;
798 ERR("GetTitle failed: %08x\n", nsres);
805 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
807 HTMLElement *This = impl_from_IHTMLElement(iface);
808 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
812 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
814 HTMLElement *This = impl_from_IHTMLElement(iface);
815 FIXME("(%p)->(%p)\n", This, p);
819 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
821 HTMLElement *This = impl_from_IHTMLElement(iface);
823 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
825 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
828 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
830 HTMLElement *This = impl_from_IHTMLElement(iface);
832 TRACE("(%p)->(%p)\n", This, p);
834 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
837 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
839 HTMLElement *This = impl_from_IHTMLElement(iface);
840 FIXME("(%p)->()\n", This);
844 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
845 VARIANT_BOOL *pfResult)
847 HTMLElement *This = impl_from_IHTMLElement(iface);
848 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
852 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
854 HTMLElement *This = impl_from_IHTMLElement(iface);
855 FIXME("(%p)->(%p)\n", This, p);
859 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
861 HTMLElement *This = impl_from_IHTMLElement(iface);
862 FIXME("(%p)->(%p)\n", This, p);
866 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
868 HTMLElement *This = impl_from_IHTMLElement(iface);
869 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
873 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
875 HTMLElement *This = impl_from_IHTMLElement(iface);
876 FIXME("(%p)->(%p)\n", This, p);
880 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
882 HTMLElement *This = impl_from_IHTMLElement(iface);
883 nsIDOMNSHTMLElement *nselem;
884 PRInt32 off_left = 0;
887 TRACE("(%p)->(%p)\n", This, p);
889 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
890 if(NS_FAILED(nsres)) {
891 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
895 nsres = nsIDOMNSHTMLElement_GetOffsetLeft(nselem, &off_left);
896 nsIDOMNSHTMLElement_Release(nselem);
897 if(NS_FAILED(nsres)) {
898 ERR("GetOffsetLeft failed: %08x\n", nsres);
906 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
908 HTMLElement *This = impl_from_IHTMLElement(iface);
909 nsIDOMNSHTMLElement *nselem;
913 TRACE("(%p)->(%p)\n", This, p);
915 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
916 if(NS_FAILED(nsres)) {
917 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
921 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
922 nsIDOMNSHTMLElement_Release(nselem);
923 if(NS_FAILED(nsres)) {
924 ERR("GetOffsetTop failed: %08x\n", nsres);
932 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
934 HTMLElement *This = impl_from_IHTMLElement(iface);
935 nsIDOMNSHTMLElement *nselem;
939 TRACE("(%p)->(%p)\n", This, p);
941 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
942 if(NS_FAILED(nsres)) {
943 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
947 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
948 nsIDOMNSHTMLElement_Release(nselem);
949 if(NS_FAILED(nsres)) {
950 ERR("GetOffsetWidth failed: %08x\n", nsres);
958 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
960 HTMLElement *This = impl_from_IHTMLElement(iface);
961 nsIDOMNSHTMLElement *nselem;
965 TRACE("(%p)->(%p)\n", This, p);
967 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
968 if(NS_FAILED(nsres)) {
969 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
973 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
974 nsIDOMNSHTMLElement_Release(nselem);
975 if(NS_FAILED(nsres)) {
976 ERR("GetOffsetHeight failed: %08x\n", nsres);
984 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
986 HTMLElement *This = impl_from_IHTMLElement(iface);
987 nsIDOMNSHTMLElement *nselem;
988 nsIDOMElement *nsparent;
992 TRACE("(%p)->(%p)\n", This, p);
994 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
995 if(NS_FAILED(nsres)) {
996 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
1000 nsres = nsIDOMNSHTMLElement_GetOffsetParent(nselem, &nsparent);
1001 nsIDOMNSHTMLElement_Release(nselem);
1002 if(NS_FAILED(nsres)) {
1003 ERR("GetOffsetParent failed: %08x\n", nsres);
1010 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1011 nsIDOMElement_Release(nsparent);
1015 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1024 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1026 HTMLElement *This = impl_from_IHTMLElement(iface);
1027 nsIDOMNSHTMLElement *nselem;
1031 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1034 FIXME("NULL nselem\n");
1038 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
1039 if(NS_FAILED(nsres)) {
1040 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
1044 nsAString_InitDepend(&html_str, v);
1045 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
1046 nsAString_Finish(&html_str);
1048 if(NS_FAILED(nsres)) {
1049 FIXME("SetInnerHtml failed %08x\n", nsres);
1056 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1058 HTMLElement *This = impl_from_IHTMLElement(iface);
1059 nsIDOMNSHTMLElement *nselem;
1063 TRACE("(%p)->(%p)\n", This, p);
1066 FIXME("NULL nselem\n");
1070 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
1071 if(NS_FAILED(nsres)) {
1072 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
1076 nsAString_Init(&html_str, NULL);
1077 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
1078 if(NS_SUCCEEDED(nsres)) {
1079 const PRUnichar *html;
1081 nsAString_GetData(&html_str, &html);
1082 *p = *html ? SysAllocString(html) : NULL;
1084 FIXME("SetInnerHtml failed %08x\n", nsres);
1088 nsAString_Finish(&html_str);
1092 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1094 HTMLElement *This = impl_from_IHTMLElement(iface);
1095 nsIDOMNode *nschild, *tmp;
1096 nsIDOMText *text_node;
1100 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1103 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1104 if(NS_FAILED(nsres)) {
1105 ERR("GetLastChild failed: %08x\n", nsres);
1111 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1112 nsIDOMNode_Release(nschild);
1113 if(NS_FAILED(nsres)) {
1114 ERR("RemoveChild failed: %08x\n", nsres);
1117 nsIDOMNode_Release(tmp);
1120 nsAString_InitDepend(&text_str, v);
1121 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1122 nsAString_Finish(&text_str);
1123 if(NS_FAILED(nsres)) {
1124 ERR("CreateTextNode failed: %08x\n", nsres);
1128 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1129 if(NS_FAILED(nsres)) {
1130 ERR("AppendChild failed: %08x\n", nsres);
1134 nsIDOMNode_Release(tmp);
1138 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1140 HTMLElement *This = impl_from_IHTMLElement(iface);
1142 TRACE("(%p)->(%p)\n", This, p);
1144 return get_node_text(&This->node, p);
1147 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1149 HTMLElement *This = impl_from_IHTMLElement(iface);
1151 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1153 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1156 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1158 HTMLElement *This = impl_from_IHTMLElement(iface);
1162 WARN("(%p)->(%p) semi-stub\n", This, p);
1164 nsAString_Init(&html_str, NULL);
1165 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1166 if(SUCCEEDED(hres)) {
1167 const PRUnichar *html;
1169 nsAString_GetData(&html_str, &html);
1170 *p = SysAllocString(html);
1172 hres = E_OUTOFMEMORY;
1175 nsAString_Finish(&html_str);
1177 TRACE("ret %s\n", debugstr_w(*p));
1181 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1183 HTMLElement *This = impl_from_IHTMLElement(iface);
1184 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1188 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1190 HTMLElement *This = impl_from_IHTMLElement(iface);
1191 FIXME("(%p)->(%p)\n", This, p);
1195 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1197 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1198 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1199 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1200 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1203 if (!strcmpiW(where, wszBeforeBegin))
1207 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1208 if (!parent) return E_INVALIDARG;
1209 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1210 if (unused) nsIDOMNode_Release(unused);
1211 nsIDOMNode_Release(parent);
1213 else if (!strcmpiW(where, wszAfterBegin))
1216 nsIDOMNode *first_child;
1217 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1218 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1219 if (unused) nsIDOMNode_Release(unused);
1220 if (first_child) nsIDOMNode_Release(first_child);
1222 else if (!strcmpiW(where, wszBeforeEnd))
1225 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1226 if (unused) nsIDOMNode_Release(unused);
1228 else if (!strcmpiW(where, wszAfterEnd))
1231 nsIDOMNode *next_sibling;
1233 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1234 if (!parent) return E_INVALIDARG;
1236 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1239 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1240 nsIDOMNode_Release(next_sibling);
1243 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1244 nsIDOMNode_Release(parent);
1245 if (unused) nsIDOMNode_Release(unused);
1249 ERR("invalid where: %s\n", debugstr_w(where));
1250 return E_INVALIDARG;
1253 if (NS_FAILED(nsres))
1259 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1262 HTMLElement *This = impl_from_IHTMLElement(iface);
1263 nsIDOMDocumentRange *nsdocrange;
1265 nsIDOMNSRange *nsrange;
1271 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1273 if(!This->node.doc->nsdoc) {
1274 WARN("NULL nsdoc\n");
1275 return E_UNEXPECTED;
1278 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1279 if(NS_FAILED(nsres))
1281 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1284 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1285 nsIDOMDocumentRange_Release(nsdocrange);
1286 if(NS_FAILED(nsres))
1288 ERR("CreateRange failed: %08x\n", nsres);
1292 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1294 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1295 nsIDOMRange_Release(range);
1296 if(NS_FAILED(nsres))
1298 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1302 nsAString_InitDepend(&ns_html, html);
1304 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1305 nsIDOMNSRange_Release(nsrange);
1306 nsAString_Finish(&ns_html);
1308 if(NS_FAILED(nsres) || !nsnode)
1310 ERR("CreateTextNode failed: %08x\n", nsres);
1314 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1315 nsIDOMNode_Release(nsnode);
1320 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1323 HTMLElement *This = impl_from_IHTMLElement(iface);
1329 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1331 if(!This->node.doc->nsdoc) {
1332 WARN("NULL nsdoc\n");
1333 return E_UNEXPECTED;
1337 nsAString_InitDepend(&ns_text, text);
1338 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1339 nsAString_Finish(&ns_text);
1341 if(NS_FAILED(nsres) || !nsnode)
1343 ERR("CreateTextNode failed: %08x\n", nsres);
1347 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1348 nsIDOMNode_Release(nsnode);
1353 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1355 HTMLElement *This = impl_from_IHTMLElement(iface);
1356 FIXME("(%p)->(%p)\n", This, p);
1360 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1362 HTMLElement *This = impl_from_IHTMLElement(iface);
1363 FIXME("(%p)->(%p)\n", This, p);
1367 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1369 HTMLElement *This = impl_from_IHTMLElement(iface);
1371 TRACE("(%p)\n", This);
1373 return call_fire_event(&This->node, EVENTID_CLICK);
1376 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1377 IHTMLFiltersCollection **p)
1379 HTMLElement *This = impl_from_IHTMLElement(iface);
1380 TRACE("(%p)->(%p)\n", This, p);
1385 *p = HTMLFiltersCollection_Create();
1390 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1392 HTMLElement *This = impl_from_IHTMLElement(iface);
1393 FIXME("(%p)->()\n", This);
1397 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1399 HTMLElement *This = impl_from_IHTMLElement(iface);
1400 FIXME("(%p)->(%p)\n", This, p);
1404 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1406 HTMLElement *This = impl_from_IHTMLElement(iface);
1407 FIXME("(%p)->(%p)\n", This, String);
1411 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1413 HTMLElement *This = impl_from_IHTMLElement(iface);
1414 FIXME("(%p)->()\n", This);
1418 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1420 HTMLElement *This = impl_from_IHTMLElement(iface);
1421 FIXME("(%p)->(%p)\n", This, p);
1425 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1427 HTMLElement *This = impl_from_IHTMLElement(iface);
1428 FIXME("(%p)->()\n", This);
1432 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1434 HTMLElement *This = impl_from_IHTMLElement(iface);
1435 FIXME("(%p)->(%p)\n", This, p);
1439 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1441 HTMLElement *This = impl_from_IHTMLElement(iface);
1442 FIXME("(%p)->()\n", This);
1446 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1448 HTMLElement *This = impl_from_IHTMLElement(iface);
1449 FIXME("(%p)->(%p)\n", This, p);
1453 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1455 HTMLElement *This = impl_from_IHTMLElement(iface);
1456 FIXME("(%p)->()\n", This);
1460 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1462 HTMLElement *This = impl_from_IHTMLElement(iface);
1463 FIXME("(%p)->(%p)\n", This, p);
1467 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1469 HTMLElement *This = impl_from_IHTMLElement(iface);
1470 FIXME("(%p)->()\n", This);
1474 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1476 HTMLElement *This = impl_from_IHTMLElement(iface);
1477 FIXME("(%p)->(%p)\n", This, p);
1481 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1483 HTMLElement *This = impl_from_IHTMLElement(iface);
1484 FIXME("(%p)->()\n", This);
1488 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1490 HTMLElement *This = impl_from_IHTMLElement(iface);
1491 FIXME("(%p)->(%p)\n", This, p);
1495 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1497 HTMLElement *This = impl_from_IHTMLElement(iface);
1498 FIXME("(%p)->()\n", This);
1502 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1504 HTMLElement *This = impl_from_IHTMLElement(iface);
1505 FIXME("(%p)->(%p)\n", This, p);
1509 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1511 HTMLElement *This = impl_from_IHTMLElement(iface);
1512 FIXME("(%p)->()\n", This);
1516 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1518 HTMLElement *This = impl_from_IHTMLElement(iface);
1519 FIXME("(%p)->(%p)\n", This, p);
1523 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1525 HTMLElement *This = impl_from_IHTMLElement(iface);
1526 FIXME("(%p)->()\n", This);
1530 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1532 HTMLElement *This = impl_from_IHTMLElement(iface);
1533 FIXME("(%p)->(%p)\n", This, p);
1537 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1539 HTMLElement *This = impl_from_IHTMLElement(iface);
1540 nsIDOMNodeList *nsnode_list;
1543 TRACE("(%p)->(%p)\n", This, p);
1545 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1546 if(NS_FAILED(nsres)) {
1547 ERR("GetChildNodes failed: %08x\n", nsres);
1551 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
1552 (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
1554 nsIDOMNodeList_Release(nsnode_list);
1558 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1560 HTMLElement *This = impl_from_IHTMLElement(iface);
1562 TRACE("(%p)->(%p)\n", This, p);
1564 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1568 static const IHTMLElementVtbl HTMLElementVtbl = {
1569 HTMLElement_QueryInterface,
1571 HTMLElement_Release,
1572 HTMLElement_GetTypeInfoCount,
1573 HTMLElement_GetTypeInfo,
1574 HTMLElement_GetIDsOfNames,
1576 HTMLElement_setAttribute,
1577 HTMLElement_getAttribute,
1578 HTMLElement_removeAttribute,
1579 HTMLElement_put_className,
1580 HTMLElement_get_className,
1583 HTMLElement_get_tagName,
1584 HTMLElement_get_parentElement,
1585 HTMLElement_get_style,
1586 HTMLElement_put_onhelp,
1587 HTMLElement_get_onhelp,
1588 HTMLElement_put_onclick,
1589 HTMLElement_get_onclick,
1590 HTMLElement_put_ondblclick,
1591 HTMLElement_get_ondblclick,
1592 HTMLElement_put_onkeydown,
1593 HTMLElement_get_onkeydown,
1594 HTMLElement_put_onkeyup,
1595 HTMLElement_get_onkeyup,
1596 HTMLElement_put_onkeypress,
1597 HTMLElement_get_onkeypress,
1598 HTMLElement_put_onmouseout,
1599 HTMLElement_get_onmouseout,
1600 HTMLElement_put_onmouseover,
1601 HTMLElement_get_onmouseover,
1602 HTMLElement_put_onmousemove,
1603 HTMLElement_get_onmousemove,
1604 HTMLElement_put_onmousedown,
1605 HTMLElement_get_onmousedown,
1606 HTMLElement_put_onmouseup,
1607 HTMLElement_get_onmouseup,
1608 HTMLElement_get_document,
1609 HTMLElement_put_title,
1610 HTMLElement_get_title,
1611 HTMLElement_put_language,
1612 HTMLElement_get_language,
1613 HTMLElement_put_onselectstart,
1614 HTMLElement_get_onselectstart,
1615 HTMLElement_scrollIntoView,
1616 HTMLElement_contains,
1617 HTMLElement_get_sourceIndex,
1618 HTMLElement_get_recordNumber,
1619 HTMLElement_put_lang,
1620 HTMLElement_get_lang,
1621 HTMLElement_get_offsetLeft,
1622 HTMLElement_get_offsetTop,
1623 HTMLElement_get_offsetWidth,
1624 HTMLElement_get_offsetHeight,
1625 HTMLElement_get_offsetParent,
1626 HTMLElement_put_innerHTML,
1627 HTMLElement_get_innerHTML,
1628 HTMLElement_put_innerText,
1629 HTMLElement_get_innerText,
1630 HTMLElement_put_outerHTML,
1631 HTMLElement_get_outerHTML,
1632 HTMLElement_put_outerText,
1633 HTMLElement_get_outerText,
1634 HTMLElement_insertAdjacentHTML,
1635 HTMLElement_insertAdjacentText,
1636 HTMLElement_get_parentTextEdit,
1637 HTMLElement_get_isTextEdit,
1639 HTMLElement_get_filters,
1640 HTMLElement_put_ondragstart,
1641 HTMLElement_get_ondragstart,
1642 HTMLElement_toString,
1643 HTMLElement_put_onbeforeupdate,
1644 HTMLElement_get_onbeforeupdate,
1645 HTMLElement_put_onafterupdate,
1646 HTMLElement_get_onafterupdate,
1647 HTMLElement_put_onerrorupdate,
1648 HTMLElement_get_onerrorupdate,
1649 HTMLElement_put_onrowexit,
1650 HTMLElement_get_onrowexit,
1651 HTMLElement_put_onrowenter,
1652 HTMLElement_get_onrowenter,
1653 HTMLElement_put_ondatasetchanged,
1654 HTMLElement_get_ondatasetchanged,
1655 HTMLElement_put_ondataavailable,
1656 HTMLElement_get_ondataavailable,
1657 HTMLElement_put_ondatasetcomplete,
1658 HTMLElement_get_ondatasetcomplete,
1659 HTMLElement_put_onfilterchange,
1660 HTMLElement_get_onfilterchange,
1661 HTMLElement_get_children,
1665 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1667 return CONTAINING_RECORD(iface, HTMLElement, node);
1670 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1672 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1676 if(IsEqualGUID(&IID_IUnknown, riid)) {
1677 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1678 *ppv = &This->IHTMLElement_iface;
1679 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1680 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1681 *ppv = &This->IHTMLElement_iface;
1682 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1683 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1684 *ppv = &This->IHTMLElement_iface;
1685 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1686 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1687 *ppv = &This->IHTMLElement2_iface;
1688 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1689 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1690 *ppv = &This->IHTMLElement3_iface;
1691 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1692 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1693 *ppv = &This->IHTMLElement4_iface;
1694 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1695 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1696 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1700 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1704 return HTMLDOMNode_QI(&This->node, riid, ppv);
1707 void HTMLElement_destructor(HTMLDOMNode *iface)
1709 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1710 HTMLDOMAttribute *attr;
1712 while(!list_empty(&This->attrs)) {
1713 attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
1715 list_remove(&attr->entry);
1717 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
1720 ConnectionPointContainer_Destroy(&This->cp_container);
1723 nsIDOMHTMLElement_Release(This->nselem);
1725 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1727 HTMLDOMNode_destructor(&This->node);
1730 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1732 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1733 HTMLElement *new_elem;
1736 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1740 IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
1741 *ret = &new_elem->node;
1745 static const NodeImplVtbl HTMLElementImplVtbl = {
1747 HTMLElement_destructor,
1751 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1753 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1756 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1757 DWORD grfdex, DISPID *pid)
1759 HTMLElement *This = impl_from_DispatchEx(dispex);
1761 if(This->node.vtbl->get_dispid)
1762 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1764 return DISP_E_UNKNOWNNAME;
1767 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1768 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1769 IServiceProvider *caller)
1771 HTMLElement *This = impl_from_DispatchEx(dispex);
1773 if(This->node.vtbl->invoke)
1774 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1775 params, res, ei, caller);
1777 ERR("(%p): element has no invoke method\n", This);
1781 static const tid_t HTMLElement_iface_tids[] = {
1786 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1788 HTMLElement_get_dispid,
1792 static dispex_static_data_t HTMLElement_dispex = {
1793 &HTMLElement_dispex_vtbl,
1794 DispHTMLUnknownElement_tid,
1796 HTMLElement_iface_tids
1799 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1801 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1803 HTMLElement2_Init(This);
1804 HTMLElement3_Init(This);
1806 if(dispex_data && !dispex_data->vtbl)
1807 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1808 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1809 dispex_data ? dispex_data : &HTMLElement_dispex);
1812 nsIDOMHTMLElement_AddRef(nselem);
1813 This->nselem = nselem;
1814 list_init(&This->attrs);
1816 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1818 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1821 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1823 nsIDOMHTMLElement *nselem;
1824 nsAString class_name_str;
1825 const PRUnichar *class_name;
1826 const tag_desc_t *tag;
1831 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1832 if(NS_FAILED(nsres))
1835 nsAString_Init(&class_name_str, NULL);
1836 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1838 nsAString_GetData(&class_name_str, &class_name);
1840 tag = get_tag_desc(class_name);
1842 hres = tag->constructor(doc, nselem, &elem);
1843 }else if(use_generic) {
1844 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1846 elem = heap_alloc_zero(sizeof(HTMLElement));
1848 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1849 elem->node.vtbl = &HTMLElementImplVtbl;
1852 hres = E_OUTOFMEMORY;
1856 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1858 nsIDOMElement_Release(nselem);
1859 nsAString_Finish(&class_name_str);
1867 /* interface IHTMLFiltersCollection */
1868 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1870 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1872 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1874 if(IsEqualGUID(&IID_IUnknown, riid)) {
1875 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1876 *ppv = &This->IHTMLFiltersCollection_iface;
1877 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1878 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1879 *ppv = &This->IHTMLFiltersCollection_iface;
1880 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1881 return *ppv ? S_OK : E_NOINTERFACE;
1885 IUnknown_AddRef((IUnknown*)*ppv);
1889 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1890 return E_NOINTERFACE;
1893 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1895 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1896 LONG ref = InterlockedIncrement(&This->ref);
1898 TRACE("(%p) ref=%d\n", This, ref);
1903 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1905 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1906 LONG ref = InterlockedDecrement(&This->ref);
1908 TRACE("(%p) ref=%d\n", This, ref);
1918 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1920 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1921 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1924 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1925 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1927 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1928 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1931 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1932 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1933 LCID lcid, DISPID *rgDispId)
1935 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1936 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1940 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1941 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1942 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1944 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1945 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1946 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1949 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1951 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1956 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1962 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1964 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1965 FIXME("(%p)->(%p)\n", This, p);
1969 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1971 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1972 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1976 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1977 HTMLFiltersCollection_QueryInterface,
1978 HTMLFiltersCollection_AddRef,
1979 HTMLFiltersCollection_Release,
1980 HTMLFiltersCollection_GetTypeInfoCount,
1981 HTMLFiltersCollection_GetTypeInfo,
1982 HTMLFiltersCollection_GetIDsOfNames,
1983 HTMLFiltersCollection_Invoke,
1984 HTMLFiltersCollection_get_length,
1985 HTMLFiltersCollection_get__newEnum,
1986 HTMLFiltersCollection_item
1989 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1994 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1995 idx = idx*10 + (*ptr-'0');
1997 return DISP_E_UNKNOWNNAME;
1999 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
2000 TRACE("ret %x\n", *dispid);
2004 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2005 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2007 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
2009 V_VT(res) = VT_DISPATCH;
2010 V_DISPATCH(res) = NULL;
2012 FIXME("always returning NULL\n");
2017 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
2019 HTMLFiltersCollection_get_dispid,
2020 HTMLFiltersCollection_invoke
2023 static const tid_t HTMLFiltersCollection_iface_tids[] = {
2024 IHTMLFiltersCollection_tid,
2027 static dispex_static_data_t HTMLFiltersCollection_dispex = {
2028 &HTMLFiltersCollection_dispex_vtbl,
2029 IHTMLFiltersCollection_tid,
2031 HTMLFiltersCollection_iface_tids
2034 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
2036 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
2038 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2041 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2042 &HTMLFiltersCollection_dispex);
2044 return &ret->IHTMLFiltersCollection_iface;