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"
36 #include "htmlstyle.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 static const WCHAR aW[] = {'A',0};
41 static const WCHAR bodyW[] = {'B','O','D','Y',0};
42 static const WCHAR embedW[] = {'E','M','B','E','D',0};
43 static const WCHAR formW[] = {'F','O','R','M',0};
44 static const WCHAR frameW[] = {'F','R','A','M','E',0};
45 static const WCHAR headW[] = {'H','E','A','D',0};
46 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
47 static const WCHAR imgW[] = {'I','M','G',0};
48 static const WCHAR inputW[] = {'I','N','P','U','T',0};
49 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
50 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
51 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
52 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
53 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
54 static const WCHAR tableW[] = {'T','A','B','L','E',0};
55 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
56 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
57 static const WCHAR trW[] = {'T','R',0};
61 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
64 static const tag_desc_t tag_descs[] = {
65 {aW, HTMLAnchorElement_Create},
66 {bodyW, HTMLBodyElement_Create},
67 {embedW, HTMLEmbedElement_Create},
68 {formW, HTMLFormElement_Create},
69 {frameW, HTMLFrameElement_Create},
70 {headW, HTMLHeadElement_Create},
71 {iframeW, HTMLIFrame_Create},
72 {imgW, HTMLImgElement_Create},
73 {inputW, HTMLInputElement_Create},
74 {objectW, HTMLObjectElement_Create},
75 {optionW, HTMLOptionElement_Create},
76 {scriptW, HTMLScriptElement_Create},
77 {selectW, HTMLSelectElement_Create},
78 {styleW, HTMLStyleElement_Create},
79 {tableW, HTMLTable_Create},
80 {textareaW, HTMLTextAreaElement_Create},
81 {title_tagW, HTMLTitleElement_Create},
82 {trW, HTMLTableRow_Create}
85 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
87 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
92 r = strcmpW(tag_name, tag_descs[i].name);
105 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
107 nsIDOMDocumentFragment *nsfragment;
108 nsIDOMDocumentRange *nsdocrange;
109 nsIDOMNSRange *nsrange;
110 nsIDOMNode *nsparent;
116 nsres = nsIDOMHTMLDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
120 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
121 nsIDOMDocumentRange_Release(nsdocrange);
122 if(NS_FAILED(nsres)) {
123 ERR("CreateRange failed: %08x\n", nsres);
127 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
128 nsIDOMRange_Release(range);
129 if(NS_FAILED(nsres)) {
130 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
134 nsAString_InitDepend(&html_str, html);
135 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
136 nsIDOMNSRange_Release(nsrange);
137 nsAString_Finish(&html_str);
138 if(NS_FAILED(nsres)) {
139 ERR("CreateContextualFragment failed: %08x\n", nsres);
143 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
144 if(NS_SUCCEEDED(nsres) && nsparent) {
147 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
148 nsIDOMNode_Release(nsparent);
149 if(NS_FAILED(nsres)) {
150 ERR("ReplaceChild failed: %08x\n", nsres);
153 nsIDOMNode_Release(nstmp);
156 ERR("GetParentNode failed: %08x\n", nsres);
160 nsIDOMDocumentFragment_Release(nsfragment);
167 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
170 } HTMLFiltersCollection;
172 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
174 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
177 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
179 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
181 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
184 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
186 nsIDOMElement *nselem;
191 WARN("NULL nsdoc\n");
195 nsAString_InitDepend(&tag_str, tag);
196 nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
197 nsAString_Finish(&tag_str);
198 if(NS_FAILED(nsres)) {
199 ERR("CreateElement failed: %08x\n", nsres);
203 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
204 nsIDOMElement_Release(nselem);
205 if(NS_FAILED(nsres)) {
206 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
213 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
214 REFIID riid, void **ppv)
216 HTMLElement *This = impl_from_IHTMLElement(iface);
218 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
221 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
223 HTMLElement *This = impl_from_IHTMLElement(iface);
225 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
228 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
230 HTMLElement *This = impl_from_IHTMLElement(iface);
232 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
235 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
237 HTMLElement *This = impl_from_IHTMLElement(iface);
238 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
241 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
242 LCID lcid, ITypeInfo **ppTInfo)
244 HTMLElement *This = impl_from_IHTMLElement(iface);
245 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
248 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
249 LPOLESTR *rgszNames, UINT cNames,
250 LCID lcid, DISPID *rgDispId)
252 HTMLElement *This = impl_from_IHTMLElement(iface);
253 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
257 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
258 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
259 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
261 HTMLElement *This = impl_from_IHTMLElement(iface);
262 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
263 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
266 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
267 VARIANT AttributeValue, LONG lFlags)
269 HTMLElement *This = impl_from_IHTMLElement(iface);
271 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
272 DISPPARAMS dispParams;
275 TRACE("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
277 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
278 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
282 dispParams.cArgs = 1;
283 dispParams.cNamedArgs = 1;
284 dispParams.rgdispidNamedArgs = &dispidNamed;
285 dispParams.rgvarg = &AttributeValue;
287 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
288 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
292 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
293 LONG lFlags, VARIANT *AttributeValue)
295 HTMLElement *This = impl_from_IHTMLElement(iface);
298 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
301 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
303 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
304 fdexNameCaseInsensitive, &dispid);
305 if(hres == DISP_E_UNKNOWNNAME) {
306 V_VT(AttributeValue) = VT_NULL;
311 V_VT(AttributeValue) = VT_NULL;
315 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
316 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
321 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
322 LONG lFlags, VARIANT_BOOL *pfSuccess)
324 HTMLElement *This = impl_from_IHTMLElement(iface);
326 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
328 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
331 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
333 HTMLElement *This = impl_from_IHTMLElement(iface);
334 nsAString classname_str;
337 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
340 FIXME("NULL nselem\n");
344 nsAString_InitDepend(&classname_str, v);
345 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
346 nsAString_Finish(&classname_str);
348 ERR("SetClassName failed: %08x\n", nsres);
353 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
355 HTMLElement *This = impl_from_IHTMLElement(iface);
360 TRACE("(%p)->(%p)\n", This, p);
363 FIXME("NULL nselem\n");
367 nsAString_Init(&class_str, NULL);
368 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
370 if(NS_SUCCEEDED(nsres)) {
371 const PRUnichar *class;
372 nsAString_GetData(&class_str, &class);
373 *p = *class ? SysAllocString(class) : NULL;
375 ERR("GetClassName failed: %08x\n", nsres);
379 nsAString_Finish(&class_str);
381 TRACE("className=%s\n", debugstr_w(*p));
385 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
387 HTMLElement *This = impl_from_IHTMLElement(iface);
391 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
394 FIXME("nselem == NULL\n");
398 nsAString_InitDepend(&id_str, v);
399 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
400 nsAString_Finish(&id_str);
402 ERR("SetId failed: %08x\n", nsres);
407 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
409 HTMLElement *This = impl_from_IHTMLElement(iface);
414 TRACE("(%p)->(%p)\n", This, p);
421 nsAString_Init(&id_str, NULL);
422 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
423 nsAString_GetData(&id_str, &id);
426 ERR("GetId failed: %08x\n", nsres);
428 *p = SysAllocString(id);
430 nsAString_Finish(&id_str);
434 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
436 HTMLElement *This = impl_from_IHTMLElement(iface);
437 const PRUnichar *tag;
441 TRACE("(%p)->(%p)\n", This, p);
444 static const WCHAR comment_tagW[] = {'!',0};
446 WARN("NULL nselem, assuming comment\n");
448 *p = SysAllocString(comment_tagW);
452 nsAString_Init(&tag_str, NULL);
453 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
454 if(NS_SUCCEEDED(nsres)) {
455 nsAString_GetData(&tag_str, &tag);
456 *p = SysAllocString(tag);
458 ERR("GetTagName failed: %08x\n", nsres);
461 nsAString_Finish(&tag_str);
466 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
468 HTMLElement *This = impl_from_IHTMLElement(iface);
472 TRACE("(%p)->(%p)\n", This, p);
474 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
478 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
479 IHTMLDOMNode_Release(node);
486 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
488 HTMLElement *This = impl_from_IHTMLElement(iface);
490 TRACE("(%p)->(%p)\n", This, p);
493 nsIDOMElementCSSInlineStyle *nselemstyle;
494 nsIDOMCSSStyleDeclaration *nsstyle;
499 FIXME("NULL nselem\n");
503 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
504 (void**)&nselemstyle);
505 if(NS_FAILED(nsres)) {
506 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
510 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
511 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
512 if(NS_FAILED(nsres)) {
513 ERR("GetStyle failed: %08x\n", nsres);
517 hres = HTMLStyle_Create(nsstyle, &This->style);
518 nsIDOMCSSStyleDeclaration_Release(nsstyle);
523 *p = &This->style->IHTMLStyle_iface;
524 IHTMLStyle_AddRef(*p);
528 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
530 HTMLElement *This = impl_from_IHTMLElement(iface);
531 FIXME("(%p)->()\n", This);
535 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
537 HTMLElement *This = impl_from_IHTMLElement(iface);
538 FIXME("(%p)->(%p)\n", This, p);
542 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
544 HTMLElement *This = impl_from_IHTMLElement(iface);
546 TRACE("(%p)->()\n", This);
548 return set_node_event(&This->node, EVENTID_CLICK, &v);
551 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
553 HTMLElement *This = impl_from_IHTMLElement(iface);
555 TRACE("(%p)->(%p)\n", This, p);
557 return get_node_event(&This->node, EVENTID_CLICK, p);
560 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
562 HTMLElement *This = impl_from_IHTMLElement(iface);
564 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
566 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
569 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
571 HTMLElement *This = impl_from_IHTMLElement(iface);
573 TRACE("(%p)->(%p)\n", This, p);
575 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
578 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
580 HTMLElement *This = impl_from_IHTMLElement(iface);
582 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
584 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
587 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
589 HTMLElement *This = impl_from_IHTMLElement(iface);
591 TRACE("(%p)->(%p)\n", This, p);
593 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
596 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
598 HTMLElement *This = impl_from_IHTMLElement(iface);
600 TRACE("(%p)->()\n", This);
602 return set_node_event(&This->node, EVENTID_KEYUP, &v);
605 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
607 HTMLElement *This = impl_from_IHTMLElement(iface);
608 FIXME("(%p)->(%p)\n", This, p);
612 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
614 HTMLElement *This = impl_from_IHTMLElement(iface);
615 FIXME("(%p)->()\n", This);
619 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
621 HTMLElement *This = impl_from_IHTMLElement(iface);
622 FIXME("(%p)->(%p)\n", This, p);
626 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
628 HTMLElement *This = impl_from_IHTMLElement(iface);
630 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
632 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
635 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
637 HTMLElement *This = impl_from_IHTMLElement(iface);
639 TRACE("(%p)->(%p)\n", This, p);
641 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
644 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
646 HTMLElement *This = impl_from_IHTMLElement(iface);
648 TRACE("(%p)->()\n", This);
650 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
653 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
655 HTMLElement *This = impl_from_IHTMLElement(iface);
657 TRACE("(%p)->(%p)\n", This, p);
659 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
662 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
664 HTMLElement *This = impl_from_IHTMLElement(iface);
666 TRACE("(%p)->()\n", This);
668 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
671 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
673 HTMLElement *This = impl_from_IHTMLElement(iface);
675 TRACE("(%p)->(%p)\n", This, p);
677 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
680 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
682 HTMLElement *This = impl_from_IHTMLElement(iface);
684 TRACE("(%p)->()\n", This);
686 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
689 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
691 HTMLElement *This = impl_from_IHTMLElement(iface);
693 TRACE("(%p)->(%p)\n", This, p);
695 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
698 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
700 HTMLElement *This = impl_from_IHTMLElement(iface);
702 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
704 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
707 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
709 HTMLElement *This = impl_from_IHTMLElement(iface);
711 TRACE("(%p)->(%p)\n", This, p);
713 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
716 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
718 HTMLElement *This = impl_from_IHTMLElement(iface);
720 TRACE("(%p)->(%p)\n", This, p);
725 if(This->node.vtbl->get_document)
726 return This->node.vtbl->get_document(&This->node, p);
728 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
729 IDispatch_AddRef(*p);
733 static const WCHAR titleW[] = {'t','i','t','l','e',0};
735 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
737 HTMLElement *This = impl_from_IHTMLElement(iface);
741 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
747 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
753 V_BSTR(var) = v ? SysAllocString(v) : NULL;
757 nsAString_InitDepend(&title_str, v);
758 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
759 nsAString_Finish(&title_str);
761 ERR("SetTitle failed: %08x\n", nsres);
766 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
768 HTMLElement *This = impl_from_IHTMLElement(iface);
772 TRACE("(%p)->(%p)\n", This, p);
778 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
779 if(hres == DISP_E_UNKNOWNNAME) {
781 }else if(V_VT(var) != VT_BSTR) {
782 FIXME("title = %s\n", debugstr_variant(var));
785 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
791 nsAString_Init(&title_str, NULL);
792 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
793 if(NS_SUCCEEDED(nsres)) {
794 const PRUnichar *title;
796 nsAString_GetData(&title_str, &title);
797 *p = *title ? SysAllocString(title) : NULL;
799 ERR("GetTitle failed: %08x\n", nsres);
806 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
808 HTMLElement *This = impl_from_IHTMLElement(iface);
809 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
813 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
815 HTMLElement *This = impl_from_IHTMLElement(iface);
816 FIXME("(%p)->(%p)\n", This, p);
820 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
822 HTMLElement *This = impl_from_IHTMLElement(iface);
824 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
826 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
829 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
831 HTMLElement *This = impl_from_IHTMLElement(iface);
833 TRACE("(%p)->(%p)\n", This, p);
835 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
838 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
840 HTMLElement *This = impl_from_IHTMLElement(iface);
841 FIXME("(%p)->()\n", This);
845 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
846 VARIANT_BOOL *pfResult)
848 HTMLElement *This = impl_from_IHTMLElement(iface);
849 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
853 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
855 HTMLElement *This = impl_from_IHTMLElement(iface);
856 FIXME("(%p)->(%p)\n", This, p);
860 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
862 HTMLElement *This = impl_from_IHTMLElement(iface);
863 FIXME("(%p)->(%p)\n", This, p);
867 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
869 HTMLElement *This = impl_from_IHTMLElement(iface);
870 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
874 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
876 HTMLElement *This = impl_from_IHTMLElement(iface);
877 FIXME("(%p)->(%p)\n", This, p);
881 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
883 HTMLElement *This = impl_from_IHTMLElement(iface);
884 nsIDOMNSHTMLElement *nselem;
885 PRInt32 off_left = 0;
888 TRACE("(%p)->(%p)\n", This, p);
890 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
891 if(NS_FAILED(nsres)) {
892 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
896 nsres = nsIDOMNSHTMLElement_GetOffsetLeft(nselem, &off_left);
897 nsIDOMNSHTMLElement_Release(nselem);
898 if(NS_FAILED(nsres)) {
899 ERR("GetOffsetLeft failed: %08x\n", nsres);
907 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
909 HTMLElement *This = impl_from_IHTMLElement(iface);
910 nsIDOMNSHTMLElement *nselem;
914 TRACE("(%p)->(%p)\n", This, p);
916 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
917 if(NS_FAILED(nsres)) {
918 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
922 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
923 nsIDOMNSHTMLElement_Release(nselem);
924 if(NS_FAILED(nsres)) {
925 ERR("GetOffsetTop failed: %08x\n", nsres);
933 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
935 HTMLElement *This = impl_from_IHTMLElement(iface);
936 nsIDOMNSHTMLElement *nselem;
940 TRACE("(%p)->(%p)\n", This, p);
942 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
943 if(NS_FAILED(nsres)) {
944 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
948 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
949 nsIDOMNSHTMLElement_Release(nselem);
950 if(NS_FAILED(nsres)) {
951 ERR("GetOffsetWidth failed: %08x\n", nsres);
959 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
961 HTMLElement *This = impl_from_IHTMLElement(iface);
962 nsIDOMNSHTMLElement *nselem;
966 TRACE("(%p)->(%p)\n", This, p);
968 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
969 if(NS_FAILED(nsres)) {
970 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
974 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
975 nsIDOMNSHTMLElement_Release(nselem);
976 if(NS_FAILED(nsres)) {
977 ERR("GetOffsetHeight failed: %08x\n", nsres);
985 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
987 HTMLElement *This = impl_from_IHTMLElement(iface);
988 nsIDOMNSHTMLElement *nselem;
989 nsIDOMElement *nsparent;
993 TRACE("(%p)->(%p)\n", This, p);
995 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
996 if(NS_FAILED(nsres)) {
997 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
1001 nsres = nsIDOMNSHTMLElement_GetOffsetParent(nselem, &nsparent);
1002 nsIDOMNSHTMLElement_Release(nselem);
1003 if(NS_FAILED(nsres)) {
1004 ERR("GetOffsetParent failed: %08x\n", nsres);
1011 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
1012 nsIDOMElement_Release(nsparent);
1016 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1025 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
1027 HTMLElement *This = impl_from_IHTMLElement(iface);
1028 nsIDOMNSHTMLElement *nselem;
1032 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1035 FIXME("NULL nselem\n");
1039 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
1040 if(NS_FAILED(nsres)) {
1041 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
1045 nsAString_InitDepend(&html_str, v);
1046 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
1047 nsAString_Finish(&html_str);
1049 if(NS_FAILED(nsres)) {
1050 FIXME("SetInnerHtml failed %08x\n", nsres);
1057 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
1059 HTMLElement *This = impl_from_IHTMLElement(iface);
1060 nsIDOMNSHTMLElement *nselem;
1064 TRACE("(%p)->(%p)\n", This, p);
1067 FIXME("NULL nselem\n");
1071 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
1072 if(NS_FAILED(nsres)) {
1073 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
1077 nsAString_Init(&html_str, NULL);
1078 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
1079 if(NS_SUCCEEDED(nsres)) {
1080 const PRUnichar *html;
1082 nsAString_GetData(&html_str, &html);
1083 *p = *html ? SysAllocString(html) : NULL;
1085 FIXME("SetInnerHtml failed %08x\n", nsres);
1089 nsAString_Finish(&html_str);
1093 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1095 HTMLElement *This = impl_from_IHTMLElement(iface);
1096 nsIDOMNode *nschild, *tmp;
1097 nsIDOMText *text_node;
1101 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1104 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1105 if(NS_FAILED(nsres)) {
1106 ERR("GetLastChild failed: %08x\n", nsres);
1112 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1113 nsIDOMNode_Release(nschild);
1114 if(NS_FAILED(nsres)) {
1115 ERR("RemoveChild failed: %08x\n", nsres);
1118 nsIDOMNode_Release(tmp);
1121 nsAString_InitDepend(&text_str, v);
1122 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1123 nsAString_Finish(&text_str);
1124 if(NS_FAILED(nsres)) {
1125 ERR("CreateTextNode failed: %08x\n", nsres);
1129 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1130 if(NS_FAILED(nsres)) {
1131 ERR("AppendChild failed: %08x\n", nsres);
1135 nsIDOMNode_Release(tmp);
1139 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1141 HTMLElement *This = impl_from_IHTMLElement(iface);
1143 TRACE("(%p)->(%p)\n", This, p);
1145 return get_node_text(&This->node, p);
1148 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1150 HTMLElement *This = impl_from_IHTMLElement(iface);
1152 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1154 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1157 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1159 HTMLElement *This = impl_from_IHTMLElement(iface);
1163 WARN("(%p)->(%p) semi-stub\n", This, p);
1165 nsAString_Init(&html_str, NULL);
1166 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1167 if(SUCCEEDED(hres)) {
1168 const PRUnichar *html;
1170 nsAString_GetData(&html_str, &html);
1171 *p = SysAllocString(html);
1173 hres = E_OUTOFMEMORY;
1176 nsAString_Finish(&html_str);
1178 TRACE("ret %s\n", debugstr_w(*p));
1182 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1184 HTMLElement *This = impl_from_IHTMLElement(iface);
1185 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1189 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1191 HTMLElement *This = impl_from_IHTMLElement(iface);
1192 FIXME("(%p)->(%p)\n", This, p);
1196 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1198 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1199 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1200 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1201 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1204 if (!strcmpiW(where, wszBeforeBegin))
1208 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1209 if (!parent) return E_INVALIDARG;
1210 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1211 if (unused) nsIDOMNode_Release(unused);
1212 nsIDOMNode_Release(parent);
1214 else if (!strcmpiW(where, wszAfterBegin))
1217 nsIDOMNode *first_child;
1218 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1219 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1220 if (unused) nsIDOMNode_Release(unused);
1221 if (first_child) nsIDOMNode_Release(first_child);
1223 else if (!strcmpiW(where, wszBeforeEnd))
1226 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1227 if (unused) nsIDOMNode_Release(unused);
1229 else if (!strcmpiW(where, wszAfterEnd))
1232 nsIDOMNode *next_sibling;
1234 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1235 if (!parent) return E_INVALIDARG;
1237 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1240 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1241 nsIDOMNode_Release(next_sibling);
1244 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1245 nsIDOMNode_Release(parent);
1246 if (unused) nsIDOMNode_Release(unused);
1250 ERR("invalid where: %s\n", debugstr_w(where));
1251 return E_INVALIDARG;
1254 if (NS_FAILED(nsres))
1260 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1263 HTMLElement *This = impl_from_IHTMLElement(iface);
1264 nsIDOMDocumentRange *nsdocrange;
1266 nsIDOMNSRange *nsrange;
1272 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1274 if(!This->node.doc->nsdoc) {
1275 WARN("NULL nsdoc\n");
1276 return E_UNEXPECTED;
1279 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1280 if(NS_FAILED(nsres))
1282 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1285 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1286 nsIDOMDocumentRange_Release(nsdocrange);
1287 if(NS_FAILED(nsres))
1289 ERR("CreateRange failed: %08x\n", nsres);
1293 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1295 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1296 nsIDOMRange_Release(range);
1297 if(NS_FAILED(nsres))
1299 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1303 nsAString_InitDepend(&ns_html, html);
1305 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1306 nsIDOMNSRange_Release(nsrange);
1307 nsAString_Finish(&ns_html);
1309 if(NS_FAILED(nsres) || !nsnode)
1311 ERR("CreateTextNode failed: %08x\n", nsres);
1315 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1316 nsIDOMNode_Release(nsnode);
1321 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1324 HTMLElement *This = impl_from_IHTMLElement(iface);
1330 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1332 if(!This->node.doc->nsdoc) {
1333 WARN("NULL nsdoc\n");
1334 return E_UNEXPECTED;
1338 nsAString_InitDepend(&ns_text, text);
1339 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1340 nsAString_Finish(&ns_text);
1342 if(NS_FAILED(nsres) || !nsnode)
1344 ERR("CreateTextNode failed: %08x\n", nsres);
1348 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1349 nsIDOMNode_Release(nsnode);
1354 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1356 HTMLElement *This = impl_from_IHTMLElement(iface);
1357 FIXME("(%p)->(%p)\n", This, p);
1361 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1363 HTMLElement *This = impl_from_IHTMLElement(iface);
1364 FIXME("(%p)->(%p)\n", This, p);
1368 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1370 HTMLElement *This = impl_from_IHTMLElement(iface);
1372 TRACE("(%p)\n", This);
1374 return call_fire_event(&This->node, EVENTID_CLICK);
1377 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1378 IHTMLFiltersCollection **p)
1380 HTMLElement *This = impl_from_IHTMLElement(iface);
1381 TRACE("(%p)->(%p)\n", This, p);
1386 *p = HTMLFiltersCollection_Create();
1391 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1393 HTMLElement *This = impl_from_IHTMLElement(iface);
1394 FIXME("(%p)->()\n", This);
1398 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1400 HTMLElement *This = impl_from_IHTMLElement(iface);
1401 FIXME("(%p)->(%p)\n", This, p);
1405 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1407 HTMLElement *This = impl_from_IHTMLElement(iface);
1408 FIXME("(%p)->(%p)\n", This, String);
1412 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1414 HTMLElement *This = impl_from_IHTMLElement(iface);
1415 FIXME("(%p)->()\n", This);
1419 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1421 HTMLElement *This = impl_from_IHTMLElement(iface);
1422 FIXME("(%p)->(%p)\n", This, p);
1426 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1428 HTMLElement *This = impl_from_IHTMLElement(iface);
1429 FIXME("(%p)->()\n", This);
1433 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1435 HTMLElement *This = impl_from_IHTMLElement(iface);
1436 FIXME("(%p)->(%p)\n", This, p);
1440 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1442 HTMLElement *This = impl_from_IHTMLElement(iface);
1443 FIXME("(%p)->()\n", This);
1447 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1449 HTMLElement *This = impl_from_IHTMLElement(iface);
1450 FIXME("(%p)->(%p)\n", This, p);
1454 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1456 HTMLElement *This = impl_from_IHTMLElement(iface);
1457 FIXME("(%p)->()\n", This);
1461 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1463 HTMLElement *This = impl_from_IHTMLElement(iface);
1464 FIXME("(%p)->(%p)\n", This, p);
1468 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1470 HTMLElement *This = impl_from_IHTMLElement(iface);
1471 FIXME("(%p)->()\n", This);
1475 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1477 HTMLElement *This = impl_from_IHTMLElement(iface);
1478 FIXME("(%p)->(%p)\n", This, p);
1482 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1484 HTMLElement *This = impl_from_IHTMLElement(iface);
1485 FIXME("(%p)->()\n", This);
1489 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1491 HTMLElement *This = impl_from_IHTMLElement(iface);
1492 FIXME("(%p)->(%p)\n", This, p);
1496 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1498 HTMLElement *This = impl_from_IHTMLElement(iface);
1499 FIXME("(%p)->()\n", This);
1503 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1505 HTMLElement *This = impl_from_IHTMLElement(iface);
1506 FIXME("(%p)->(%p)\n", This, p);
1510 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1512 HTMLElement *This = impl_from_IHTMLElement(iface);
1513 FIXME("(%p)->()\n", This);
1517 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1519 HTMLElement *This = impl_from_IHTMLElement(iface);
1520 FIXME("(%p)->(%p)\n", This, p);
1524 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1526 HTMLElement *This = impl_from_IHTMLElement(iface);
1527 FIXME("(%p)->()\n", This);
1531 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1533 HTMLElement *This = impl_from_IHTMLElement(iface);
1534 FIXME("(%p)->(%p)\n", This, p);
1538 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1540 HTMLElement *This = impl_from_IHTMLElement(iface);
1541 nsIDOMNodeList *nsnode_list;
1544 TRACE("(%p)->(%p)\n", This, p);
1546 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1547 if(NS_FAILED(nsres)) {
1548 ERR("GetChildNodes failed: %08x\n", nsres);
1552 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
1553 (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
1555 nsIDOMNodeList_Release(nsnode_list);
1559 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1561 HTMLElement *This = impl_from_IHTMLElement(iface);
1563 TRACE("(%p)->(%p)\n", This, p);
1565 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1569 static const IHTMLElementVtbl HTMLElementVtbl = {
1570 HTMLElement_QueryInterface,
1572 HTMLElement_Release,
1573 HTMLElement_GetTypeInfoCount,
1574 HTMLElement_GetTypeInfo,
1575 HTMLElement_GetIDsOfNames,
1577 HTMLElement_setAttribute,
1578 HTMLElement_getAttribute,
1579 HTMLElement_removeAttribute,
1580 HTMLElement_put_className,
1581 HTMLElement_get_className,
1584 HTMLElement_get_tagName,
1585 HTMLElement_get_parentElement,
1586 HTMLElement_get_style,
1587 HTMLElement_put_onhelp,
1588 HTMLElement_get_onhelp,
1589 HTMLElement_put_onclick,
1590 HTMLElement_get_onclick,
1591 HTMLElement_put_ondblclick,
1592 HTMLElement_get_ondblclick,
1593 HTMLElement_put_onkeydown,
1594 HTMLElement_get_onkeydown,
1595 HTMLElement_put_onkeyup,
1596 HTMLElement_get_onkeyup,
1597 HTMLElement_put_onkeypress,
1598 HTMLElement_get_onkeypress,
1599 HTMLElement_put_onmouseout,
1600 HTMLElement_get_onmouseout,
1601 HTMLElement_put_onmouseover,
1602 HTMLElement_get_onmouseover,
1603 HTMLElement_put_onmousemove,
1604 HTMLElement_get_onmousemove,
1605 HTMLElement_put_onmousedown,
1606 HTMLElement_get_onmousedown,
1607 HTMLElement_put_onmouseup,
1608 HTMLElement_get_onmouseup,
1609 HTMLElement_get_document,
1610 HTMLElement_put_title,
1611 HTMLElement_get_title,
1612 HTMLElement_put_language,
1613 HTMLElement_get_language,
1614 HTMLElement_put_onselectstart,
1615 HTMLElement_get_onselectstart,
1616 HTMLElement_scrollIntoView,
1617 HTMLElement_contains,
1618 HTMLElement_get_sourceIndex,
1619 HTMLElement_get_recordNumber,
1620 HTMLElement_put_lang,
1621 HTMLElement_get_lang,
1622 HTMLElement_get_offsetLeft,
1623 HTMLElement_get_offsetTop,
1624 HTMLElement_get_offsetWidth,
1625 HTMLElement_get_offsetHeight,
1626 HTMLElement_get_offsetParent,
1627 HTMLElement_put_innerHTML,
1628 HTMLElement_get_innerHTML,
1629 HTMLElement_put_innerText,
1630 HTMLElement_get_innerText,
1631 HTMLElement_put_outerHTML,
1632 HTMLElement_get_outerHTML,
1633 HTMLElement_put_outerText,
1634 HTMLElement_get_outerText,
1635 HTMLElement_insertAdjacentHTML,
1636 HTMLElement_insertAdjacentText,
1637 HTMLElement_get_parentTextEdit,
1638 HTMLElement_get_isTextEdit,
1640 HTMLElement_get_filters,
1641 HTMLElement_put_ondragstart,
1642 HTMLElement_get_ondragstart,
1643 HTMLElement_toString,
1644 HTMLElement_put_onbeforeupdate,
1645 HTMLElement_get_onbeforeupdate,
1646 HTMLElement_put_onafterupdate,
1647 HTMLElement_get_onafterupdate,
1648 HTMLElement_put_onerrorupdate,
1649 HTMLElement_get_onerrorupdate,
1650 HTMLElement_put_onrowexit,
1651 HTMLElement_get_onrowexit,
1652 HTMLElement_put_onrowenter,
1653 HTMLElement_get_onrowenter,
1654 HTMLElement_put_ondatasetchanged,
1655 HTMLElement_get_ondatasetchanged,
1656 HTMLElement_put_ondataavailable,
1657 HTMLElement_get_ondataavailable,
1658 HTMLElement_put_ondatasetcomplete,
1659 HTMLElement_get_ondatasetcomplete,
1660 HTMLElement_put_onfilterchange,
1661 HTMLElement_get_onfilterchange,
1662 HTMLElement_get_children,
1666 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1668 return CONTAINING_RECORD(iface, HTMLElement, node);
1671 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1673 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1677 if(IsEqualGUID(&IID_IUnknown, riid)) {
1678 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1679 *ppv = &This->IHTMLElement_iface;
1680 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1681 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1682 *ppv = &This->IHTMLElement_iface;
1683 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1684 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1685 *ppv = &This->IHTMLElement_iface;
1686 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1687 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1688 *ppv = &This->IHTMLElement2_iface;
1689 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1690 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1691 *ppv = &This->IHTMLElement3_iface;
1692 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1693 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1694 *ppv = &This->IHTMLElement4_iface;
1695 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1696 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1697 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1701 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1705 return HTMLDOMNode_QI(&This->node, riid, ppv);
1708 void HTMLElement_destructor(HTMLDOMNode *iface)
1710 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1711 HTMLDOMAttribute *attr;
1713 while(!list_empty(&This->attrs)) {
1714 attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
1716 list_remove(&attr->entry);
1718 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
1721 ConnectionPointContainer_Destroy(&This->cp_container);
1724 nsIDOMHTMLElement_Release(This->nselem);
1726 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1728 HTMLDOMNode_destructor(&This->node);
1731 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1733 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1734 HTMLElement *new_elem;
1737 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1741 IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
1742 *ret = &new_elem->node;
1746 static const NodeImplVtbl HTMLElementImplVtbl = {
1748 HTMLElement_destructor,
1752 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1754 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1757 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1758 DWORD grfdex, DISPID *pid)
1760 HTMLElement *This = impl_from_DispatchEx(dispex);
1762 if(This->node.vtbl->get_dispid)
1763 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1765 return DISP_E_UNKNOWNNAME;
1768 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1769 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1770 IServiceProvider *caller)
1772 HTMLElement *This = impl_from_DispatchEx(dispex);
1774 if(This->node.vtbl->invoke)
1775 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1776 params, res, ei, caller);
1778 ERR("(%p): element has no invoke method\n", This);
1782 static const tid_t HTMLElement_iface_tids[] = {
1787 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1789 HTMLElement_get_dispid,
1793 static dispex_static_data_t HTMLElement_dispex = {
1794 &HTMLElement_dispex_vtbl,
1795 DispHTMLUnknownElement_tid,
1797 HTMLElement_iface_tids
1800 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1802 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1804 HTMLElement2_Init(This);
1805 HTMLElement3_Init(This);
1807 if(dispex_data && !dispex_data->vtbl)
1808 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1809 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1810 dispex_data ? dispex_data : &HTMLElement_dispex);
1813 nsIDOMHTMLElement_AddRef(nselem);
1814 This->nselem = nselem;
1815 list_init(&This->attrs);
1817 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1819 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1822 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1824 nsIDOMHTMLElement *nselem;
1825 nsAString class_name_str;
1826 const PRUnichar *class_name;
1827 const tag_desc_t *tag;
1832 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1833 if(NS_FAILED(nsres))
1836 nsAString_Init(&class_name_str, NULL);
1837 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1839 nsAString_GetData(&class_name_str, &class_name);
1841 tag = get_tag_desc(class_name);
1843 hres = tag->constructor(doc, nselem, &elem);
1844 }else if(use_generic) {
1845 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1847 elem = heap_alloc_zero(sizeof(HTMLElement));
1849 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1850 elem->node.vtbl = &HTMLElementImplVtbl;
1853 hres = E_OUTOFMEMORY;
1857 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1859 nsIDOMElement_Release(nselem);
1860 nsAString_Finish(&class_name_str);
1868 /* interface IHTMLFiltersCollection */
1869 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1871 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1873 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1875 if(IsEqualGUID(&IID_IUnknown, riid)) {
1876 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1877 *ppv = &This->IHTMLFiltersCollection_iface;
1878 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1879 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1880 *ppv = &This->IHTMLFiltersCollection_iface;
1881 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1882 return *ppv ? S_OK : E_NOINTERFACE;
1886 IUnknown_AddRef((IUnknown*)*ppv);
1890 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1891 return E_NOINTERFACE;
1894 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1896 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1897 LONG ref = InterlockedIncrement(&This->ref);
1899 TRACE("(%p) ref=%d\n", This, ref);
1904 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1906 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1907 LONG ref = InterlockedDecrement(&This->ref);
1909 TRACE("(%p) ref=%d\n", This, ref);
1919 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1921 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1922 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1925 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1926 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1928 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1929 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1932 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1933 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1934 LCID lcid, DISPID *rgDispId)
1936 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1937 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1941 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1942 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1943 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1945 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1946 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1947 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1950 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1952 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1957 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1963 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1965 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1966 FIXME("(%p)->(%p)\n", This, p);
1970 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1972 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1973 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1977 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1978 HTMLFiltersCollection_QueryInterface,
1979 HTMLFiltersCollection_AddRef,
1980 HTMLFiltersCollection_Release,
1981 HTMLFiltersCollection_GetTypeInfoCount,
1982 HTMLFiltersCollection_GetTypeInfo,
1983 HTMLFiltersCollection_GetIDsOfNames,
1984 HTMLFiltersCollection_Invoke,
1985 HTMLFiltersCollection_get_length,
1986 HTMLFiltersCollection_get__newEnum,
1987 HTMLFiltersCollection_item
1990 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1995 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1996 idx = idx*10 + (*ptr-'0');
1998 return DISP_E_UNKNOWNNAME;
2000 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
2001 TRACE("ret %x\n", *dispid);
2005 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2006 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2008 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
2010 V_VT(res) = VT_DISPATCH;
2011 V_DISPATCH(res) = NULL;
2013 FIXME("always returning NULL\n");
2018 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
2020 HTMLFiltersCollection_get_dispid,
2021 HTMLFiltersCollection_invoke
2024 static const tid_t HTMLFiltersCollection_iface_tids[] = {
2025 IHTMLFiltersCollection_tid,
2028 static dispex_static_data_t HTMLFiltersCollection_dispex = {
2029 &HTMLFiltersCollection_dispex_vtbl,
2030 IHTMLFiltersCollection_tid,
2032 HTMLFiltersCollection_iface_tids
2035 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
2037 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
2039 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2042 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2043 &HTMLFiltersCollection_dispex);
2045 return &ret->IHTMLFiltersCollection_iface;