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 static const WCHAR aW[] = {'A',0};
39 static const WCHAR bodyW[] = {'B','O','D','Y',0};
40 static const WCHAR embedW[] = {'E','M','B','E','D',0};
41 static const WCHAR formW[] = {'F','O','R','M',0};
42 static const WCHAR frameW[] = {'F','R','A','M','E',0};
43 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
44 static const WCHAR imgW[] = {'I','M','G',0};
45 static const WCHAR inputW[] = {'I','N','P','U','T',0};
46 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
47 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
48 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
49 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
50 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
51 static const WCHAR tableW[] = {'T','A','B','L','E',0};
52 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
53 static const WCHAR trW[] = {'T','R',0};
57 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
60 static const tag_desc_t tag_descs[] = {
61 {aW, HTMLAnchorElement_Create},
62 {bodyW, HTMLBodyElement_Create},
63 {embedW, HTMLEmbedElement_Create},
64 {formW, HTMLFormElement_Create},
65 {frameW, HTMLFrameElement_Create},
66 {iframeW, HTMLIFrame_Create},
67 {imgW, HTMLImgElement_Create},
68 {inputW, HTMLInputElement_Create},
69 {objectW, HTMLObjectElement_Create},
70 {optionW, HTMLOptionElement_Create},
71 {scriptW, HTMLScriptElement_Create},
72 {selectW, HTMLSelectElement_Create},
73 {styleW, HTMLStyleElement_Create},
74 {tableW, HTMLTable_Create},
75 {textareaW, HTMLTextAreaElement_Create},
76 {trW, HTMLTableRow_Create}
79 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
81 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
86 r = strcmpW(tag_name, tag_descs[i].name);
102 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
105 } HTMLFiltersCollection;
107 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
109 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
112 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
115 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
117 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
119 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
122 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
124 nsIDOMElement *nselem;
129 WARN("NULL nsdoc\n");
133 nsAString_InitDepend(&tag_str, tag);
134 nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
135 nsAString_Finish(&tag_str);
136 if(NS_FAILED(nsres)) {
137 ERR("CreateElement failed: %08x\n", nsres);
141 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
142 nsIDOMElement_Release(nselem);
143 if(NS_FAILED(nsres)) {
144 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
151 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
152 REFIID riid, void **ppv)
154 HTMLElement *This = impl_from_IHTMLElement(iface);
156 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
159 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
161 HTMLElement *This = impl_from_IHTMLElement(iface);
163 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
166 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
168 HTMLElement *This = impl_from_IHTMLElement(iface);
170 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
173 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
175 HTMLElement *This = impl_from_IHTMLElement(iface);
176 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
179 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
180 LCID lcid, ITypeInfo **ppTInfo)
182 HTMLElement *This = impl_from_IHTMLElement(iface);
183 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
186 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
187 LPOLESTR *rgszNames, UINT cNames,
188 LCID lcid, DISPID *rgDispId)
190 HTMLElement *This = impl_from_IHTMLElement(iface);
191 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
195 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
196 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
197 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
199 HTMLElement *This = impl_from_IHTMLElement(iface);
200 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
201 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
204 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
205 VARIANT AttributeValue, LONG lFlags)
207 HTMLElement *This = impl_from_IHTMLElement(iface);
209 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
210 DISPPARAMS dispParams;
213 TRACE("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
215 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
216 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
220 dispParams.cArgs = 1;
221 dispParams.cNamedArgs = 1;
222 dispParams.rgdispidNamedArgs = &dispidNamed;
223 dispParams.rgvarg = &AttributeValue;
225 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
226 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
230 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
231 LONG lFlags, VARIANT *AttributeValue)
233 HTMLElement *This = impl_from_IHTMLElement(iface);
236 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
239 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
241 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
242 fdexNameCaseInsensitive, &dispid);
243 if(hres == DISP_E_UNKNOWNNAME) {
244 V_VT(AttributeValue) = VT_NULL;
249 V_VT(AttributeValue) = VT_NULL;
253 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
254 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
259 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
260 LONG lFlags, VARIANT_BOOL *pfSuccess)
262 HTMLElement *This = impl_from_IHTMLElement(iface);
264 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
266 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
269 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
271 HTMLElement *This = impl_from_IHTMLElement(iface);
272 nsAString classname_str;
275 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
278 FIXME("NULL nselem\n");
282 nsAString_InitDepend(&classname_str, v);
283 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
284 nsAString_Finish(&classname_str);
286 ERR("SetClassName failed: %08x\n", nsres);
291 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
293 HTMLElement *This = impl_from_IHTMLElement(iface);
298 TRACE("(%p)->(%p)\n", This, p);
301 FIXME("NULL nselem\n");
305 nsAString_Init(&class_str, NULL);
306 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
308 if(NS_SUCCEEDED(nsres)) {
309 const PRUnichar *class;
310 nsAString_GetData(&class_str, &class);
311 *p = *class ? SysAllocString(class) : NULL;
313 ERR("GetClassName failed: %08x\n", nsres);
317 nsAString_Finish(&class_str);
319 TRACE("className=%s\n", debugstr_w(*p));
323 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
325 HTMLElement *This = impl_from_IHTMLElement(iface);
329 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
332 FIXME("nselem == NULL\n");
336 nsAString_InitDepend(&id_str, v);
337 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
338 nsAString_Finish(&id_str);
340 ERR("SetId failed: %08x\n", nsres);
345 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
347 HTMLElement *This = impl_from_IHTMLElement(iface);
352 TRACE("(%p)->(%p)\n", This, p);
359 nsAString_Init(&id_str, NULL);
360 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
361 nsAString_GetData(&id_str, &id);
364 ERR("GetId failed: %08x\n", nsres);
366 *p = SysAllocString(id);
368 nsAString_Finish(&id_str);
372 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
374 HTMLElement *This = impl_from_IHTMLElement(iface);
375 const PRUnichar *tag;
379 TRACE("(%p)->(%p)\n", This, p);
382 static const WCHAR comment_tagW[] = {'!',0};
384 WARN("NULL nselem, assuming comment\n");
386 *p = SysAllocString(comment_tagW);
390 nsAString_Init(&tag_str, NULL);
391 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
392 if(NS_SUCCEEDED(nsres)) {
393 nsAString_GetData(&tag_str, &tag);
394 *p = SysAllocString(tag);
396 ERR("GetTagName failed: %08x\n", nsres);
399 nsAString_Finish(&tag_str);
404 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
406 HTMLElement *This = impl_from_IHTMLElement(iface);
410 TRACE("(%p)->(%p)\n", This, p);
412 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
416 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
417 IHTMLDOMNode_Release(node);
424 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
426 HTMLElement *This = impl_from_IHTMLElement(iface);
428 TRACE("(%p)->(%p)\n", This, p);
431 nsIDOMElementCSSInlineStyle *nselemstyle;
432 nsIDOMCSSStyleDeclaration *nsstyle;
437 FIXME("NULL nselem\n");
441 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
442 (void**)&nselemstyle);
443 if(NS_FAILED(nsres)) {
444 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
448 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
449 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
450 if(NS_FAILED(nsres)) {
451 ERR("GetStyle failed: %08x\n", nsres);
455 hres = HTMLStyle_Create(nsstyle, &This->style);
456 nsIDOMCSSStyleDeclaration_Release(nsstyle);
461 *p = &This->style->IHTMLStyle_iface;
462 IHTMLStyle_AddRef(*p);
466 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
468 HTMLElement *This = impl_from_IHTMLElement(iface);
469 FIXME("(%p)->()\n", This);
473 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
475 HTMLElement *This = impl_from_IHTMLElement(iface);
476 FIXME("(%p)->(%p)\n", This, p);
480 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
482 HTMLElement *This = impl_from_IHTMLElement(iface);
484 TRACE("(%p)->()\n", This);
486 return set_node_event(&This->node, EVENTID_CLICK, &v);
489 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
491 HTMLElement *This = impl_from_IHTMLElement(iface);
493 TRACE("(%p)->(%p)\n", This, p);
495 return get_node_event(&This->node, EVENTID_CLICK, p);
498 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
500 HTMLElement *This = impl_from_IHTMLElement(iface);
502 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
504 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
507 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
509 HTMLElement *This = impl_from_IHTMLElement(iface);
511 TRACE("(%p)->(%p)\n", This, p);
513 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
516 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
518 HTMLElement *This = impl_from_IHTMLElement(iface);
520 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
522 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
525 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
527 HTMLElement *This = impl_from_IHTMLElement(iface);
529 TRACE("(%p)->(%p)\n", This, p);
531 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
534 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
536 HTMLElement *This = impl_from_IHTMLElement(iface);
538 TRACE("(%p)->()\n", This);
540 return set_node_event(&This->node, EVENTID_KEYUP, &v);
543 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
545 HTMLElement *This = impl_from_IHTMLElement(iface);
546 FIXME("(%p)->(%p)\n", This, p);
550 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
552 HTMLElement *This = impl_from_IHTMLElement(iface);
553 FIXME("(%p)->()\n", This);
557 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
559 HTMLElement *This = impl_from_IHTMLElement(iface);
560 FIXME("(%p)->(%p)\n", This, p);
564 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
566 HTMLElement *This = impl_from_IHTMLElement(iface);
568 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
570 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
573 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
575 HTMLElement *This = impl_from_IHTMLElement(iface);
577 TRACE("(%p)->(%p)\n", This, p);
579 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
582 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
584 HTMLElement *This = impl_from_IHTMLElement(iface);
586 TRACE("(%p)->()\n", This);
588 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
591 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
593 HTMLElement *This = impl_from_IHTMLElement(iface);
595 TRACE("(%p)->(%p)\n", This, p);
597 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
600 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
602 HTMLElement *This = impl_from_IHTMLElement(iface);
604 TRACE("(%p)->()\n", This);
606 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
609 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
611 HTMLElement *This = impl_from_IHTMLElement(iface);
613 TRACE("(%p)->(%p)\n", This, p);
615 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
618 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
620 HTMLElement *This = impl_from_IHTMLElement(iface);
622 TRACE("(%p)->()\n", This);
624 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
627 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
629 HTMLElement *This = impl_from_IHTMLElement(iface);
631 TRACE("(%p)->(%p)\n", This, p);
633 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
636 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
638 HTMLElement *This = impl_from_IHTMLElement(iface);
640 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
642 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
645 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
647 HTMLElement *This = impl_from_IHTMLElement(iface);
649 TRACE("(%p)->(%p)\n", This, p);
651 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
654 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
656 HTMLElement *This = impl_from_IHTMLElement(iface);
658 TRACE("(%p)->(%p)\n", This, p);
663 if(This->node.vtbl->get_document)
664 return This->node.vtbl->get_document(&This->node, p);
666 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
667 IDispatch_AddRef(*p);
671 static const WCHAR titleW[] = {'t','i','t','l','e',0};
673 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
675 HTMLElement *This = impl_from_IHTMLElement(iface);
679 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
685 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
691 V_BSTR(var) = v ? SysAllocString(v) : NULL;
695 nsAString_InitDepend(&title_str, v);
696 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
697 nsAString_Finish(&title_str);
699 ERR("SetTitle failed: %08x\n", nsres);
704 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
706 HTMLElement *This = impl_from_IHTMLElement(iface);
710 TRACE("(%p)->(%p)\n", This, p);
716 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
717 if(hres == DISP_E_UNKNOWNNAME) {
719 }else if(V_VT(var) != VT_BSTR) {
720 FIXME("title = %s\n", debugstr_variant(var));
723 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
729 nsAString_Init(&title_str, NULL);
730 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
731 if(NS_SUCCEEDED(nsres)) {
732 const PRUnichar *title;
734 nsAString_GetData(&title_str, &title);
735 *p = *title ? SysAllocString(title) : NULL;
737 ERR("GetTitle failed: %08x\n", nsres);
744 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
746 HTMLElement *This = impl_from_IHTMLElement(iface);
747 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
751 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
753 HTMLElement *This = impl_from_IHTMLElement(iface);
754 FIXME("(%p)->(%p)\n", This, p);
758 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
760 HTMLElement *This = impl_from_IHTMLElement(iface);
762 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
764 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
767 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
769 HTMLElement *This = impl_from_IHTMLElement(iface);
771 TRACE("(%p)->(%p)\n", This, p);
773 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
776 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
778 HTMLElement *This = impl_from_IHTMLElement(iface);
779 FIXME("(%p)->()\n", This);
783 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
784 VARIANT_BOOL *pfResult)
786 HTMLElement *This = impl_from_IHTMLElement(iface);
787 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
791 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
793 HTMLElement *This = impl_from_IHTMLElement(iface);
794 FIXME("(%p)->(%p)\n", This, p);
798 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
800 HTMLElement *This = impl_from_IHTMLElement(iface);
801 FIXME("(%p)->(%p)\n", This, p);
805 static HRESULT WINAPI HTMLElement_put_lang(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_lang(IHTMLElement *iface, BSTR *p)
814 HTMLElement *This = impl_from_IHTMLElement(iface);
815 FIXME("(%p)->(%p)\n", This, p);
819 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
821 HTMLElement *This = impl_from_IHTMLElement(iface);
822 nsIDOMNSHTMLElement *nselem;
823 PRInt32 off_left = 0;
826 TRACE("(%p)->(%p)\n", This, p);
828 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
829 if(NS_FAILED(nsres)) {
830 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
834 nsres = nsIDOMNSHTMLElement_GetOffsetLeft(nselem, &off_left);
835 nsIDOMNSHTMLElement_Release(nselem);
836 if(NS_FAILED(nsres)) {
837 ERR("GetOffsetLeft failed: %08x\n", nsres);
845 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
847 HTMLElement *This = impl_from_IHTMLElement(iface);
848 nsIDOMNSHTMLElement *nselem;
852 TRACE("(%p)->(%p)\n", This, p);
854 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
855 if(NS_FAILED(nsres)) {
856 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
860 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
861 nsIDOMNSHTMLElement_Release(nselem);
862 if(NS_FAILED(nsres)) {
863 ERR("GetOffsetTop failed: %08x\n", nsres);
871 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
873 HTMLElement *This = impl_from_IHTMLElement(iface);
874 nsIDOMNSHTMLElement *nselem;
878 TRACE("(%p)->(%p)\n", This, p);
880 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
881 if(NS_FAILED(nsres)) {
882 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
886 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
887 nsIDOMNSHTMLElement_Release(nselem);
888 if(NS_FAILED(nsres)) {
889 ERR("GetOffsetWidth failed: %08x\n", nsres);
897 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
899 HTMLElement *This = impl_from_IHTMLElement(iface);
900 nsIDOMNSHTMLElement *nselem;
904 TRACE("(%p)->(%p)\n", This, p);
906 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
907 if(NS_FAILED(nsres)) {
908 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
912 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
913 nsIDOMNSHTMLElement_Release(nselem);
914 if(NS_FAILED(nsres)) {
915 ERR("GetOffsetHeight failed: %08x\n", nsres);
923 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
925 HTMLElement *This = impl_from_IHTMLElement(iface);
926 nsIDOMNSHTMLElement *nselem;
927 nsIDOMElement *nsparent;
931 TRACE("(%p)->(%p)\n", This, p);
933 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
934 if(NS_FAILED(nsres)) {
935 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
939 nsres = nsIDOMNSHTMLElement_GetOffsetParent(nselem, &nsparent);
940 nsIDOMNSHTMLElement_Release(nselem);
941 if(NS_FAILED(nsres)) {
942 ERR("GetOffsetParent failed: %08x\n", nsres);
949 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
950 nsIDOMElement_Release(nsparent);
954 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
963 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
965 HTMLElement *This = impl_from_IHTMLElement(iface);
966 nsIDOMNSHTMLElement *nselem;
970 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
973 FIXME("NULL nselem\n");
977 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
978 if(NS_FAILED(nsres)) {
979 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
983 nsAString_InitDepend(&html_str, v);
984 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
985 nsAString_Finish(&html_str);
987 if(NS_FAILED(nsres)) {
988 FIXME("SetInnerHtml failed %08x\n", nsres);
995 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
997 HTMLElement *This = impl_from_IHTMLElement(iface);
998 nsIDOMNSHTMLElement *nselem;
1002 TRACE("(%p)->(%p)\n", This, p);
1005 FIXME("NULL nselem\n");
1009 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
1010 if(NS_FAILED(nsres)) {
1011 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
1015 nsAString_Init(&html_str, NULL);
1016 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
1017 if(NS_SUCCEEDED(nsres)) {
1018 const PRUnichar *html;
1020 nsAString_GetData(&html_str, &html);
1021 *p = *html ? SysAllocString(html) : NULL;
1023 FIXME("SetInnerHtml failed %08x\n", nsres);
1027 nsAString_Finish(&html_str);
1031 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1033 HTMLElement *This = impl_from_IHTMLElement(iface);
1034 nsIDOMNode *nschild, *tmp;
1035 nsIDOMText *text_node;
1039 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1042 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1043 if(NS_FAILED(nsres)) {
1044 ERR("GetLastChild failed: %08x\n", nsres);
1050 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1051 nsIDOMNode_Release(nschild);
1052 if(NS_FAILED(nsres)) {
1053 ERR("RemoveChild failed: %08x\n", nsres);
1056 nsIDOMNode_Release(tmp);
1059 nsAString_InitDepend(&text_str, v);
1060 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1061 nsAString_Finish(&text_str);
1062 if(NS_FAILED(nsres)) {
1063 ERR("CreateTextNode failed: %08x\n", nsres);
1067 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1068 if(NS_FAILED(nsres)) {
1069 ERR("AppendChild failed: %08x\n", nsres);
1073 nsIDOMNode_Release(tmp);
1077 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1079 HTMLElement *This = impl_from_IHTMLElement(iface);
1081 TRACE("(%p)->(%p)\n", This, p);
1083 return get_node_text(&This->node, p);
1086 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1088 HTMLElement *This = impl_from_IHTMLElement(iface);
1089 nsIDOMDocumentFragment *nsfragment;
1090 nsIDOMDocumentRange *nsdocrange;
1091 nsIDOMNSRange *nsrange;
1092 nsIDOMNode *nsparent;
1096 HRESULT hres = S_OK;
1098 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1100 nsres = nsIDOMHTMLDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
1101 if(NS_FAILED(nsres))
1104 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1105 nsIDOMDocumentRange_Release(nsdocrange);
1106 if(NS_FAILED(nsres)) {
1107 ERR("CreateRange failed: %08x\n", nsres);
1111 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
1112 nsIDOMRange_Release(range);
1113 if(NS_FAILED(nsres)) {
1114 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
1118 nsAString_InitDepend(&html_str, v);
1119 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
1120 nsIDOMNSRange_Release(nsrange);
1121 nsAString_Finish(&html_str);
1122 if(NS_FAILED(nsres)) {
1123 ERR("CreateContextualFragment failed: %08x\n", nsres);
1127 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsparent);
1128 if(NS_SUCCEEDED(nsres) && nsparent) {
1131 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, This->node.nsnode, &nstmp);
1132 nsIDOMNode_Release(nsparent);
1133 if(NS_FAILED(nsres)) {
1134 ERR("ReplaceChild failed: %08x\n", nsres);
1137 nsIDOMNode_Release(nstmp);
1140 ERR("GetParentNode failed: %08x\n", nsres);
1144 nsIDOMDocumentFragment_Release(nsfragment);
1148 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1150 HTMLElement *This = impl_from_IHTMLElement(iface);
1154 WARN("(%p)->(%p) semi-stub\n", This, p);
1156 nsAString_Init(&html_str, NULL);
1157 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1158 if(SUCCEEDED(hres)) {
1159 const PRUnichar *html;
1161 nsAString_GetData(&html_str, &html);
1162 *p = SysAllocString(html);
1164 hres = E_OUTOFMEMORY;
1167 nsAString_Finish(&html_str);
1169 TRACE("ret %s\n", debugstr_w(*p));
1173 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1175 HTMLElement *This = impl_from_IHTMLElement(iface);
1176 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1180 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1182 HTMLElement *This = impl_from_IHTMLElement(iface);
1183 FIXME("(%p)->(%p)\n", This, p);
1187 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1189 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1190 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1191 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1192 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1195 if (!strcmpiW(where, wszBeforeBegin))
1199 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1200 if (!parent) return E_INVALIDARG;
1201 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1202 if (unused) nsIDOMNode_Release(unused);
1203 nsIDOMNode_Release(parent);
1205 else if (!strcmpiW(where, wszAfterBegin))
1208 nsIDOMNode *first_child;
1209 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1210 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1211 if (unused) nsIDOMNode_Release(unused);
1212 if (first_child) nsIDOMNode_Release(first_child);
1214 else if (!strcmpiW(where, wszBeforeEnd))
1217 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1218 if (unused) nsIDOMNode_Release(unused);
1220 else if (!strcmpiW(where, wszAfterEnd))
1223 nsIDOMNode *next_sibling;
1225 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1226 if (!parent) return E_INVALIDARG;
1228 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1231 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1232 nsIDOMNode_Release(next_sibling);
1235 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1236 nsIDOMNode_Release(parent);
1237 if (unused) nsIDOMNode_Release(unused);
1241 ERR("invalid where: %s\n", debugstr_w(where));
1242 return E_INVALIDARG;
1245 if (NS_FAILED(nsres))
1251 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1254 HTMLElement *This = impl_from_IHTMLElement(iface);
1255 nsIDOMDocumentRange *nsdocrange;
1257 nsIDOMNSRange *nsrange;
1263 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1265 if(!This->node.doc->nsdoc) {
1266 WARN("NULL nsdoc\n");
1267 return E_UNEXPECTED;
1270 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1271 if(NS_FAILED(nsres))
1273 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1276 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1277 nsIDOMDocumentRange_Release(nsdocrange);
1278 if(NS_FAILED(nsres))
1280 ERR("CreateRange failed: %08x\n", nsres);
1284 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1286 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1287 nsIDOMRange_Release(range);
1288 if(NS_FAILED(nsres))
1290 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1294 nsAString_InitDepend(&ns_html, html);
1296 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1297 nsIDOMNSRange_Release(nsrange);
1298 nsAString_Finish(&ns_html);
1300 if(NS_FAILED(nsres) || !nsnode)
1302 ERR("CreateTextNode failed: %08x\n", nsres);
1306 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1307 nsIDOMNode_Release(nsnode);
1312 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1315 HTMLElement *This = impl_from_IHTMLElement(iface);
1321 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1323 if(!This->node.doc->nsdoc) {
1324 WARN("NULL nsdoc\n");
1325 return E_UNEXPECTED;
1329 nsAString_InitDepend(&ns_text, text);
1330 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1331 nsAString_Finish(&ns_text);
1333 if(NS_FAILED(nsres) || !nsnode)
1335 ERR("CreateTextNode failed: %08x\n", nsres);
1339 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1340 nsIDOMNode_Release(nsnode);
1345 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1347 HTMLElement *This = impl_from_IHTMLElement(iface);
1348 FIXME("(%p)->(%p)\n", This, p);
1352 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1354 HTMLElement *This = impl_from_IHTMLElement(iface);
1355 FIXME("(%p)->(%p)\n", This, p);
1359 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1361 HTMLElement *This = impl_from_IHTMLElement(iface);
1363 TRACE("(%p)\n", This);
1365 return call_event(&This->node, EVENTID_CLICK);
1368 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1369 IHTMLFiltersCollection **p)
1371 HTMLElement *This = impl_from_IHTMLElement(iface);
1372 TRACE("(%p)->(%p)\n", This, p);
1377 *p = HTMLFiltersCollection_Create();
1382 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1384 HTMLElement *This = impl_from_IHTMLElement(iface);
1385 FIXME("(%p)->()\n", This);
1389 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1391 HTMLElement *This = impl_from_IHTMLElement(iface);
1392 FIXME("(%p)->(%p)\n", This, p);
1396 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1398 HTMLElement *This = impl_from_IHTMLElement(iface);
1399 FIXME("(%p)->(%p)\n", This, String);
1403 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1405 HTMLElement *This = impl_from_IHTMLElement(iface);
1406 FIXME("(%p)->()\n", This);
1410 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1412 HTMLElement *This = impl_from_IHTMLElement(iface);
1413 FIXME("(%p)->(%p)\n", This, p);
1417 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1419 HTMLElement *This = impl_from_IHTMLElement(iface);
1420 FIXME("(%p)->()\n", This);
1424 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1426 HTMLElement *This = impl_from_IHTMLElement(iface);
1427 FIXME("(%p)->(%p)\n", This, p);
1431 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1433 HTMLElement *This = impl_from_IHTMLElement(iface);
1434 FIXME("(%p)->()\n", This);
1438 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1440 HTMLElement *This = impl_from_IHTMLElement(iface);
1441 FIXME("(%p)->(%p)\n", This, p);
1445 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1447 HTMLElement *This = impl_from_IHTMLElement(iface);
1448 FIXME("(%p)->()\n", This);
1452 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1454 HTMLElement *This = impl_from_IHTMLElement(iface);
1455 FIXME("(%p)->(%p)\n", This, p);
1459 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1461 HTMLElement *This = impl_from_IHTMLElement(iface);
1462 FIXME("(%p)->()\n", This);
1466 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1468 HTMLElement *This = impl_from_IHTMLElement(iface);
1469 FIXME("(%p)->(%p)\n", This, p);
1473 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1475 HTMLElement *This = impl_from_IHTMLElement(iface);
1476 FIXME("(%p)->()\n", This);
1480 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1482 HTMLElement *This = impl_from_IHTMLElement(iface);
1483 FIXME("(%p)->(%p)\n", This, p);
1487 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1489 HTMLElement *This = impl_from_IHTMLElement(iface);
1490 FIXME("(%p)->()\n", This);
1494 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1496 HTMLElement *This = impl_from_IHTMLElement(iface);
1497 FIXME("(%p)->(%p)\n", This, p);
1501 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1503 HTMLElement *This = impl_from_IHTMLElement(iface);
1504 FIXME("(%p)->()\n", This);
1508 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1510 HTMLElement *This = impl_from_IHTMLElement(iface);
1511 FIXME("(%p)->(%p)\n", This, p);
1515 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1517 HTMLElement *This = impl_from_IHTMLElement(iface);
1518 FIXME("(%p)->()\n", This);
1522 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1524 HTMLElement *This = impl_from_IHTMLElement(iface);
1525 FIXME("(%p)->(%p)\n", This, p);
1529 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1531 HTMLElement *This = impl_from_IHTMLElement(iface);
1532 nsIDOMNodeList *nsnode_list;
1535 TRACE("(%p)->(%p)\n", This, p);
1537 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1538 if(NS_FAILED(nsres)) {
1539 ERR("GetChildNodes failed: %08x\n", nsres);
1543 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
1544 (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
1546 nsIDOMNodeList_Release(nsnode_list);
1550 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1552 HTMLElement *This = impl_from_IHTMLElement(iface);
1554 TRACE("(%p)->(%p)\n", This, p);
1556 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1560 static const IHTMLElementVtbl HTMLElementVtbl = {
1561 HTMLElement_QueryInterface,
1563 HTMLElement_Release,
1564 HTMLElement_GetTypeInfoCount,
1565 HTMLElement_GetTypeInfo,
1566 HTMLElement_GetIDsOfNames,
1568 HTMLElement_setAttribute,
1569 HTMLElement_getAttribute,
1570 HTMLElement_removeAttribute,
1571 HTMLElement_put_className,
1572 HTMLElement_get_className,
1575 HTMLElement_get_tagName,
1576 HTMLElement_get_parentElement,
1577 HTMLElement_get_style,
1578 HTMLElement_put_onhelp,
1579 HTMLElement_get_onhelp,
1580 HTMLElement_put_onclick,
1581 HTMLElement_get_onclick,
1582 HTMLElement_put_ondblclick,
1583 HTMLElement_get_ondblclick,
1584 HTMLElement_put_onkeydown,
1585 HTMLElement_get_onkeydown,
1586 HTMLElement_put_onkeyup,
1587 HTMLElement_get_onkeyup,
1588 HTMLElement_put_onkeypress,
1589 HTMLElement_get_onkeypress,
1590 HTMLElement_put_onmouseout,
1591 HTMLElement_get_onmouseout,
1592 HTMLElement_put_onmouseover,
1593 HTMLElement_get_onmouseover,
1594 HTMLElement_put_onmousemove,
1595 HTMLElement_get_onmousemove,
1596 HTMLElement_put_onmousedown,
1597 HTMLElement_get_onmousedown,
1598 HTMLElement_put_onmouseup,
1599 HTMLElement_get_onmouseup,
1600 HTMLElement_get_document,
1601 HTMLElement_put_title,
1602 HTMLElement_get_title,
1603 HTMLElement_put_language,
1604 HTMLElement_get_language,
1605 HTMLElement_put_onselectstart,
1606 HTMLElement_get_onselectstart,
1607 HTMLElement_scrollIntoView,
1608 HTMLElement_contains,
1609 HTMLElement_get_sourceIndex,
1610 HTMLElement_get_recordNumber,
1611 HTMLElement_put_lang,
1612 HTMLElement_get_lang,
1613 HTMLElement_get_offsetLeft,
1614 HTMLElement_get_offsetTop,
1615 HTMLElement_get_offsetWidth,
1616 HTMLElement_get_offsetHeight,
1617 HTMLElement_get_offsetParent,
1618 HTMLElement_put_innerHTML,
1619 HTMLElement_get_innerHTML,
1620 HTMLElement_put_innerText,
1621 HTMLElement_get_innerText,
1622 HTMLElement_put_outerHTML,
1623 HTMLElement_get_outerHTML,
1624 HTMLElement_put_outerText,
1625 HTMLElement_get_outerText,
1626 HTMLElement_insertAdjacentHTML,
1627 HTMLElement_insertAdjacentText,
1628 HTMLElement_get_parentTextEdit,
1629 HTMLElement_get_isTextEdit,
1631 HTMLElement_get_filters,
1632 HTMLElement_put_ondragstart,
1633 HTMLElement_get_ondragstart,
1634 HTMLElement_toString,
1635 HTMLElement_put_onbeforeupdate,
1636 HTMLElement_get_onbeforeupdate,
1637 HTMLElement_put_onafterupdate,
1638 HTMLElement_get_onafterupdate,
1639 HTMLElement_put_onerrorupdate,
1640 HTMLElement_get_onerrorupdate,
1641 HTMLElement_put_onrowexit,
1642 HTMLElement_get_onrowexit,
1643 HTMLElement_put_onrowenter,
1644 HTMLElement_get_onrowenter,
1645 HTMLElement_put_ondatasetchanged,
1646 HTMLElement_get_ondatasetchanged,
1647 HTMLElement_put_ondataavailable,
1648 HTMLElement_get_ondataavailable,
1649 HTMLElement_put_ondatasetcomplete,
1650 HTMLElement_get_ondatasetcomplete,
1651 HTMLElement_put_onfilterchange,
1652 HTMLElement_get_onfilterchange,
1653 HTMLElement_get_children,
1657 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1659 return CONTAINING_RECORD(iface, HTMLElement, node);
1662 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1664 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1668 if(IsEqualGUID(&IID_IUnknown, riid)) {
1669 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1670 *ppv = &This->IHTMLElement_iface;
1671 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1672 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1673 *ppv = &This->IHTMLElement_iface;
1674 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1675 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1676 *ppv = &This->IHTMLElement_iface;
1677 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1678 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1679 *ppv = &This->IHTMLElement2_iface;
1680 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1681 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1682 *ppv = &This->IHTMLElement3_iface;
1683 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1684 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1685 *ppv = &This->IHTMLElement4_iface;
1686 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1687 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1688 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1692 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1696 return HTMLDOMNode_QI(&This->node, riid, ppv);
1699 void HTMLElement_destructor(HTMLDOMNode *iface)
1701 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1702 HTMLDOMAttribute *attr;
1704 while(!list_empty(&This->attrs)) {
1705 attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
1707 list_remove(&attr->entry);
1709 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
1712 ConnectionPointContainer_Destroy(&This->cp_container);
1715 nsIDOMHTMLElement_Release(This->nselem);
1717 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1719 HTMLDOMNode_destructor(&This->node);
1722 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1724 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1725 HTMLElement *new_elem;
1728 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1732 IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
1733 *ret = &new_elem->node;
1737 static const NodeImplVtbl HTMLElementImplVtbl = {
1739 HTMLElement_destructor,
1743 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1745 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1748 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1749 DWORD grfdex, DISPID *pid)
1751 HTMLElement *This = impl_from_DispatchEx(dispex);
1753 if(This->node.vtbl->get_dispid)
1754 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1756 return DISP_E_UNKNOWNNAME;
1759 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1760 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1761 IServiceProvider *caller)
1763 HTMLElement *This = impl_from_DispatchEx(dispex);
1765 if(This->node.vtbl->invoke)
1766 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1767 params, res, ei, caller);
1769 ERR("(%p): element has no invoke method\n", This);
1773 static const tid_t HTMLElement_iface_tids[] = {
1778 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1780 HTMLElement_get_dispid,
1784 static dispex_static_data_t HTMLElement_dispex = {
1785 &HTMLElement_dispex_vtbl,
1786 DispHTMLUnknownElement_tid,
1788 HTMLElement_iface_tids
1791 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1793 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1795 HTMLElement2_Init(This);
1796 HTMLElement3_Init(This);
1798 if(dispex_data && !dispex_data->vtbl)
1799 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1800 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1801 dispex_data ? dispex_data : &HTMLElement_dispex);
1804 nsIDOMHTMLElement_AddRef(nselem);
1805 This->nselem = nselem;
1806 list_init(&This->attrs);
1808 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1810 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1813 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1815 nsIDOMHTMLElement *nselem;
1816 nsAString class_name_str;
1817 const PRUnichar *class_name;
1818 const tag_desc_t *tag;
1823 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1824 if(NS_FAILED(nsres))
1827 nsAString_Init(&class_name_str, NULL);
1828 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1830 nsAString_GetData(&class_name_str, &class_name);
1832 tag = get_tag_desc(class_name);
1834 hres = tag->constructor(doc, nselem, &elem);
1835 }else if(use_generic) {
1836 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1838 elem = heap_alloc_zero(sizeof(HTMLElement));
1840 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1841 elem->node.vtbl = &HTMLElementImplVtbl;
1844 hres = E_OUTOFMEMORY;
1848 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1850 nsIDOMElement_Release(nselem);
1851 nsAString_Finish(&class_name_str);
1859 /* interface IHTMLFiltersCollection */
1860 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1862 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1864 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1866 if(IsEqualGUID(&IID_IUnknown, riid)) {
1867 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1868 *ppv = &This->IHTMLFiltersCollection_iface;
1869 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1870 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1871 *ppv = &This->IHTMLFiltersCollection_iface;
1872 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1873 return *ppv ? S_OK : E_NOINTERFACE;
1877 IUnknown_AddRef((IUnknown*)*ppv);
1881 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1882 return E_NOINTERFACE;
1885 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1887 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1888 LONG ref = InterlockedIncrement(&This->ref);
1890 TRACE("(%p) ref=%d\n", This, ref);
1895 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1897 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1898 LONG ref = InterlockedDecrement(&This->ref);
1900 TRACE("(%p) ref=%d\n", This, ref);
1910 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1912 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1913 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1916 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1917 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1919 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1920 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1923 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1924 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1925 LCID lcid, DISPID *rgDispId)
1927 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1928 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1932 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1933 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1934 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1936 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1937 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1938 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1941 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1943 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1948 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1954 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1956 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1957 FIXME("(%p)->(%p)\n", This, p);
1961 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1963 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1964 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1968 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1969 HTMLFiltersCollection_QueryInterface,
1970 HTMLFiltersCollection_AddRef,
1971 HTMLFiltersCollection_Release,
1972 HTMLFiltersCollection_GetTypeInfoCount,
1973 HTMLFiltersCollection_GetTypeInfo,
1974 HTMLFiltersCollection_GetIDsOfNames,
1975 HTMLFiltersCollection_Invoke,
1976 HTMLFiltersCollection_get_length,
1977 HTMLFiltersCollection_get__newEnum,
1978 HTMLFiltersCollection_item
1981 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1986 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1987 idx = idx*10 + (*ptr-'0');
1989 return DISP_E_UNKNOWNNAME;
1991 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1992 TRACE("ret %x\n", *dispid);
1996 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1997 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1999 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
2001 V_VT(res) = VT_DISPATCH;
2002 V_DISPATCH(res) = NULL;
2004 FIXME("always returning NULL\n");
2009 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
2011 HTMLFiltersCollection_get_dispid,
2012 HTMLFiltersCollection_invoke
2015 static const tid_t HTMLFiltersCollection_iface_tids[] = {
2016 IHTMLFiltersCollection_tid,
2019 static dispex_static_data_t HTMLFiltersCollection_dispex = {
2020 &HTMLFiltersCollection_dispex_vtbl,
2021 IHTMLFiltersCollection_tid,
2023 HTMLFiltersCollection_iface_tids
2026 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
2028 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
2030 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2033 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2034 &HTMLFiltersCollection_dispex);
2036 return &ret->IHTMLFiltersCollection_iface;