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 FIXME("(%p)->(%p)\n", This, p);
930 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
932 HTMLElement *This = impl_from_IHTMLElement(iface);
933 nsIDOMNSHTMLElement *nselem;
937 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
940 FIXME("NULL nselem\n");
944 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
945 if(NS_FAILED(nsres)) {
946 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
950 nsAString_InitDepend(&html_str, v);
951 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
952 nsAString_Finish(&html_str);
954 if(NS_FAILED(nsres)) {
955 FIXME("SetInnerHtml failed %08x\n", nsres);
962 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
964 HTMLElement *This = impl_from_IHTMLElement(iface);
965 nsIDOMNSHTMLElement *nselem;
969 TRACE("(%p)->(%p)\n", This, p);
972 FIXME("NULL nselem\n");
976 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
977 if(NS_FAILED(nsres)) {
978 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
982 nsAString_Init(&html_str, NULL);
983 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
984 if(NS_SUCCEEDED(nsres)) {
985 const PRUnichar *html;
987 nsAString_GetData(&html_str, &html);
988 *p = *html ? SysAllocString(html) : NULL;
990 FIXME("SetInnerHtml failed %08x\n", nsres);
994 nsAString_Finish(&html_str);
998 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
1000 HTMLElement *This = impl_from_IHTMLElement(iface);
1001 nsIDOMNode *nschild, *tmp;
1002 nsIDOMText *text_node;
1006 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1009 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1010 if(NS_FAILED(nsres)) {
1011 ERR("GetLastChild failed: %08x\n", nsres);
1017 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1018 nsIDOMNode_Release(nschild);
1019 if(NS_FAILED(nsres)) {
1020 ERR("RemoveChild failed: %08x\n", nsres);
1023 nsIDOMNode_Release(tmp);
1026 nsAString_InitDepend(&text_str, v);
1027 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1028 nsAString_Finish(&text_str);
1029 if(NS_FAILED(nsres)) {
1030 ERR("CreateTextNode failed: %08x\n", nsres);
1034 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1035 if(NS_FAILED(nsres)) {
1036 ERR("AppendChild failed: %08x\n", nsres);
1040 nsIDOMNode_Release(tmp);
1044 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1046 HTMLElement *This = impl_from_IHTMLElement(iface);
1048 TRACE("(%p)->(%p)\n", This, p);
1050 return get_node_text(&This->node, p);
1053 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1055 HTMLElement *This = impl_from_IHTMLElement(iface);
1056 nsIDOMDocumentFragment *nsfragment;
1057 nsIDOMDocumentRange *nsdocrange;
1058 nsIDOMNSRange *nsrange;
1059 nsIDOMNode *nsparent;
1063 HRESULT hres = S_OK;
1065 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1067 nsres = nsIDOMHTMLDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
1068 if(NS_FAILED(nsres))
1071 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1072 nsIDOMDocumentRange_Release(nsdocrange);
1073 if(NS_FAILED(nsres)) {
1074 ERR("CreateRange failed: %08x\n", nsres);
1078 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
1079 nsIDOMRange_Release(range);
1080 if(NS_FAILED(nsres)) {
1081 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
1085 nsAString_InitDepend(&html_str, v);
1086 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
1087 nsIDOMNSRange_Release(nsrange);
1088 nsAString_Finish(&html_str);
1089 if(NS_FAILED(nsres)) {
1090 ERR("CreateContextualFragment failed: %08x\n", nsres);
1094 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsparent);
1095 if(NS_SUCCEEDED(nsres) && nsparent) {
1098 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, This->node.nsnode, &nstmp);
1099 nsIDOMNode_Release(nsparent);
1100 if(NS_FAILED(nsres)) {
1101 ERR("ReplaceChild failed: %08x\n", nsres);
1104 nsIDOMNode_Release(nstmp);
1107 ERR("GetParentNode failed: %08x\n", nsres);
1111 nsIDOMDocumentFragment_Release(nsfragment);
1115 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1117 HTMLElement *This = impl_from_IHTMLElement(iface);
1121 WARN("(%p)->(%p) semi-stub\n", This, p);
1123 nsAString_Init(&html_str, NULL);
1124 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1125 if(SUCCEEDED(hres)) {
1126 const PRUnichar *html;
1128 nsAString_GetData(&html_str, &html);
1129 *p = SysAllocString(html);
1131 hres = E_OUTOFMEMORY;
1134 nsAString_Finish(&html_str);
1136 TRACE("ret %s\n", debugstr_w(*p));
1140 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1142 HTMLElement *This = impl_from_IHTMLElement(iface);
1143 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1147 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1149 HTMLElement *This = impl_from_IHTMLElement(iface);
1150 FIXME("(%p)->(%p)\n", This, p);
1154 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1156 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1157 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1158 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1159 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1162 if (!strcmpiW(where, wszBeforeBegin))
1166 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1167 if (!parent) return E_INVALIDARG;
1168 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1169 if (unused) nsIDOMNode_Release(unused);
1170 nsIDOMNode_Release(parent);
1172 else if (!strcmpiW(where, wszAfterBegin))
1175 nsIDOMNode *first_child;
1176 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1177 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1178 if (unused) nsIDOMNode_Release(unused);
1179 if (first_child) nsIDOMNode_Release(first_child);
1181 else if (!strcmpiW(where, wszBeforeEnd))
1184 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1185 if (unused) nsIDOMNode_Release(unused);
1187 else if (!strcmpiW(where, wszAfterEnd))
1190 nsIDOMNode *next_sibling;
1192 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1193 if (!parent) return E_INVALIDARG;
1195 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1198 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1199 nsIDOMNode_Release(next_sibling);
1202 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1203 nsIDOMNode_Release(parent);
1204 if (unused) nsIDOMNode_Release(unused);
1208 ERR("invalid where: %s\n", debugstr_w(where));
1209 return E_INVALIDARG;
1212 if (NS_FAILED(nsres))
1218 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1221 HTMLElement *This = impl_from_IHTMLElement(iface);
1222 nsIDOMDocumentRange *nsdocrange;
1224 nsIDOMNSRange *nsrange;
1230 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1232 if(!This->node.doc->nsdoc) {
1233 WARN("NULL nsdoc\n");
1234 return E_UNEXPECTED;
1237 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1238 if(NS_FAILED(nsres))
1240 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1243 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1244 nsIDOMDocumentRange_Release(nsdocrange);
1245 if(NS_FAILED(nsres))
1247 ERR("CreateRange failed: %08x\n", nsres);
1251 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1253 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1254 nsIDOMRange_Release(range);
1255 if(NS_FAILED(nsres))
1257 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1261 nsAString_InitDepend(&ns_html, html);
1263 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1264 nsIDOMNSRange_Release(nsrange);
1265 nsAString_Finish(&ns_html);
1267 if(NS_FAILED(nsres) || !nsnode)
1269 ERR("CreateTextNode failed: %08x\n", nsres);
1273 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1274 nsIDOMNode_Release(nsnode);
1279 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1282 HTMLElement *This = impl_from_IHTMLElement(iface);
1288 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1290 if(!This->node.doc->nsdoc) {
1291 WARN("NULL nsdoc\n");
1292 return E_UNEXPECTED;
1296 nsAString_InitDepend(&ns_text, text);
1297 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1298 nsAString_Finish(&ns_text);
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_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1314 HTMLElement *This = impl_from_IHTMLElement(iface);
1315 FIXME("(%p)->(%p)\n", This, p);
1319 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1321 HTMLElement *This = impl_from_IHTMLElement(iface);
1322 FIXME("(%p)->(%p)\n", This, p);
1326 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1328 HTMLElement *This = impl_from_IHTMLElement(iface);
1330 TRACE("(%p)\n", This);
1332 return call_event(&This->node, EVENTID_CLICK);
1335 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1336 IHTMLFiltersCollection **p)
1338 HTMLElement *This = impl_from_IHTMLElement(iface);
1339 TRACE("(%p)->(%p)\n", This, p);
1344 *p = HTMLFiltersCollection_Create();
1349 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1351 HTMLElement *This = impl_from_IHTMLElement(iface);
1352 FIXME("(%p)->()\n", This);
1356 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1358 HTMLElement *This = impl_from_IHTMLElement(iface);
1359 FIXME("(%p)->(%p)\n", This, p);
1363 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1365 HTMLElement *This = impl_from_IHTMLElement(iface);
1366 FIXME("(%p)->(%p)\n", This, String);
1370 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1372 HTMLElement *This = impl_from_IHTMLElement(iface);
1373 FIXME("(%p)->()\n", This);
1377 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1379 HTMLElement *This = impl_from_IHTMLElement(iface);
1380 FIXME("(%p)->(%p)\n", This, p);
1384 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1386 HTMLElement *This = impl_from_IHTMLElement(iface);
1387 FIXME("(%p)->()\n", This);
1391 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1393 HTMLElement *This = impl_from_IHTMLElement(iface);
1394 FIXME("(%p)->(%p)\n", This, p);
1398 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1400 HTMLElement *This = impl_from_IHTMLElement(iface);
1401 FIXME("(%p)->()\n", This);
1405 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1407 HTMLElement *This = impl_from_IHTMLElement(iface);
1408 FIXME("(%p)->(%p)\n", This, p);
1412 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1414 HTMLElement *This = impl_from_IHTMLElement(iface);
1415 FIXME("(%p)->()\n", This);
1419 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1421 HTMLElement *This = impl_from_IHTMLElement(iface);
1422 FIXME("(%p)->(%p)\n", This, p);
1426 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1428 HTMLElement *This = impl_from_IHTMLElement(iface);
1429 FIXME("(%p)->()\n", This);
1433 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1435 HTMLElement *This = impl_from_IHTMLElement(iface);
1436 FIXME("(%p)->(%p)\n", This, p);
1440 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1442 HTMLElement *This = impl_from_IHTMLElement(iface);
1443 FIXME("(%p)->()\n", This);
1447 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1449 HTMLElement *This = impl_from_IHTMLElement(iface);
1450 FIXME("(%p)->(%p)\n", This, p);
1454 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1456 HTMLElement *This = impl_from_IHTMLElement(iface);
1457 FIXME("(%p)->()\n", This);
1461 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1463 HTMLElement *This = impl_from_IHTMLElement(iface);
1464 FIXME("(%p)->(%p)\n", This, p);
1468 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1470 HTMLElement *This = impl_from_IHTMLElement(iface);
1471 FIXME("(%p)->()\n", This);
1475 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1477 HTMLElement *This = impl_from_IHTMLElement(iface);
1478 FIXME("(%p)->(%p)\n", This, p);
1482 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1484 HTMLElement *This = impl_from_IHTMLElement(iface);
1485 FIXME("(%p)->()\n", This);
1489 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1491 HTMLElement *This = impl_from_IHTMLElement(iface);
1492 FIXME("(%p)->(%p)\n", This, p);
1496 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1498 HTMLElement *This = impl_from_IHTMLElement(iface);
1499 nsIDOMNodeList *nsnode_list;
1502 TRACE("(%p)->(%p)\n", This, p);
1504 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1505 if(NS_FAILED(nsres)) {
1506 ERR("GetChildNodes failed: %08x\n", nsres);
1510 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
1511 (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
1513 nsIDOMNodeList_Release(nsnode_list);
1517 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1519 HTMLElement *This = impl_from_IHTMLElement(iface);
1521 TRACE("(%p)->(%p)\n", This, p);
1523 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1527 static const IHTMLElementVtbl HTMLElementVtbl = {
1528 HTMLElement_QueryInterface,
1530 HTMLElement_Release,
1531 HTMLElement_GetTypeInfoCount,
1532 HTMLElement_GetTypeInfo,
1533 HTMLElement_GetIDsOfNames,
1535 HTMLElement_setAttribute,
1536 HTMLElement_getAttribute,
1537 HTMLElement_removeAttribute,
1538 HTMLElement_put_className,
1539 HTMLElement_get_className,
1542 HTMLElement_get_tagName,
1543 HTMLElement_get_parentElement,
1544 HTMLElement_get_style,
1545 HTMLElement_put_onhelp,
1546 HTMLElement_get_onhelp,
1547 HTMLElement_put_onclick,
1548 HTMLElement_get_onclick,
1549 HTMLElement_put_ondblclick,
1550 HTMLElement_get_ondblclick,
1551 HTMLElement_put_onkeydown,
1552 HTMLElement_get_onkeydown,
1553 HTMLElement_put_onkeyup,
1554 HTMLElement_get_onkeyup,
1555 HTMLElement_put_onkeypress,
1556 HTMLElement_get_onkeypress,
1557 HTMLElement_put_onmouseout,
1558 HTMLElement_get_onmouseout,
1559 HTMLElement_put_onmouseover,
1560 HTMLElement_get_onmouseover,
1561 HTMLElement_put_onmousemove,
1562 HTMLElement_get_onmousemove,
1563 HTMLElement_put_onmousedown,
1564 HTMLElement_get_onmousedown,
1565 HTMLElement_put_onmouseup,
1566 HTMLElement_get_onmouseup,
1567 HTMLElement_get_document,
1568 HTMLElement_put_title,
1569 HTMLElement_get_title,
1570 HTMLElement_put_language,
1571 HTMLElement_get_language,
1572 HTMLElement_put_onselectstart,
1573 HTMLElement_get_onselectstart,
1574 HTMLElement_scrollIntoView,
1575 HTMLElement_contains,
1576 HTMLElement_get_sourceIndex,
1577 HTMLElement_get_recordNumber,
1578 HTMLElement_put_lang,
1579 HTMLElement_get_lang,
1580 HTMLElement_get_offsetLeft,
1581 HTMLElement_get_offsetTop,
1582 HTMLElement_get_offsetWidth,
1583 HTMLElement_get_offsetHeight,
1584 HTMLElement_get_offsetParent,
1585 HTMLElement_put_innerHTML,
1586 HTMLElement_get_innerHTML,
1587 HTMLElement_put_innerText,
1588 HTMLElement_get_innerText,
1589 HTMLElement_put_outerHTML,
1590 HTMLElement_get_outerHTML,
1591 HTMLElement_put_outerText,
1592 HTMLElement_get_outerText,
1593 HTMLElement_insertAdjacentHTML,
1594 HTMLElement_insertAdjacentText,
1595 HTMLElement_get_parentTextEdit,
1596 HTMLElement_get_isTextEdit,
1598 HTMLElement_get_filters,
1599 HTMLElement_put_ondragstart,
1600 HTMLElement_get_ondragstart,
1601 HTMLElement_toString,
1602 HTMLElement_put_onbeforeupdate,
1603 HTMLElement_get_onbeforeupdate,
1604 HTMLElement_put_onafterupdate,
1605 HTMLElement_get_onafterupdate,
1606 HTMLElement_put_onerrorupdate,
1607 HTMLElement_get_onerrorupdate,
1608 HTMLElement_put_onrowexit,
1609 HTMLElement_get_onrowexit,
1610 HTMLElement_put_onrowenter,
1611 HTMLElement_get_onrowenter,
1612 HTMLElement_put_ondatasetchanged,
1613 HTMLElement_get_ondatasetchanged,
1614 HTMLElement_put_ondataavailable,
1615 HTMLElement_get_ondataavailable,
1616 HTMLElement_put_ondatasetcomplete,
1617 HTMLElement_get_ondatasetcomplete,
1618 HTMLElement_put_onfilterchange,
1619 HTMLElement_get_onfilterchange,
1620 HTMLElement_get_children,
1624 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1626 return CONTAINING_RECORD(iface, HTMLElement, node);
1629 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1631 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1635 if(IsEqualGUID(&IID_IUnknown, riid)) {
1636 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1637 *ppv = &This->IHTMLElement_iface;
1638 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1639 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1640 *ppv = &This->IHTMLElement_iface;
1641 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1642 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1643 *ppv = &This->IHTMLElement_iface;
1644 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1645 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1646 *ppv = &This->IHTMLElement2_iface;
1647 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1648 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1649 *ppv = &This->IHTMLElement3_iface;
1650 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1651 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1652 *ppv = &This->IHTMLElement4_iface;
1653 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1654 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1655 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1659 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1663 return HTMLDOMNode_QI(&This->node, riid, ppv);
1666 void HTMLElement_destructor(HTMLDOMNode *iface)
1668 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1669 HTMLDOMAttribute *attr;
1671 while(!list_empty(&This->attrs)) {
1672 attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
1674 list_remove(&attr->entry);
1676 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
1679 ConnectionPointContainer_Destroy(&This->cp_container);
1682 nsIDOMHTMLElement_Release(This->nselem);
1684 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1686 HTMLDOMNode_destructor(&This->node);
1689 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1691 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1692 HTMLElement *new_elem;
1695 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1699 IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
1700 *ret = &new_elem->node;
1704 static const NodeImplVtbl HTMLElementImplVtbl = {
1706 HTMLElement_destructor,
1710 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1712 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1715 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1716 DWORD grfdex, DISPID *pid)
1718 HTMLElement *This = impl_from_DispatchEx(dispex);
1720 if(This->node.vtbl->get_dispid)
1721 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1723 return DISP_E_UNKNOWNNAME;
1726 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1727 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1728 IServiceProvider *caller)
1730 HTMLElement *This = impl_from_DispatchEx(dispex);
1732 if(This->node.vtbl->invoke)
1733 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1734 params, res, ei, caller);
1736 ERR("(%p): element has no invoke method\n", This);
1740 static const tid_t HTMLElement_iface_tids[] = {
1745 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1747 HTMLElement_get_dispid,
1751 static dispex_static_data_t HTMLElement_dispex = {
1752 &HTMLElement_dispex_vtbl,
1753 DispHTMLUnknownElement_tid,
1755 HTMLElement_iface_tids
1758 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1760 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1762 HTMLElement2_Init(This);
1763 HTMLElement3_Init(This);
1765 if(dispex_data && !dispex_data->vtbl)
1766 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1767 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1768 dispex_data ? dispex_data : &HTMLElement_dispex);
1771 nsIDOMHTMLElement_AddRef(nselem);
1772 This->nselem = nselem;
1773 list_init(&This->attrs);
1775 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1777 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1780 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1782 nsIDOMHTMLElement *nselem;
1783 nsAString class_name_str;
1784 const PRUnichar *class_name;
1785 const tag_desc_t *tag;
1790 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1791 if(NS_FAILED(nsres))
1794 nsAString_Init(&class_name_str, NULL);
1795 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1797 nsAString_GetData(&class_name_str, &class_name);
1799 tag = get_tag_desc(class_name);
1801 hres = tag->constructor(doc, nselem, &elem);
1802 }else if(use_generic) {
1803 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1805 elem = heap_alloc_zero(sizeof(HTMLElement));
1807 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1808 elem->node.vtbl = &HTMLElementImplVtbl;
1811 hres = E_OUTOFMEMORY;
1815 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1817 nsIDOMElement_Release(nselem);
1818 nsAString_Finish(&class_name_str);
1826 /* interface IHTMLFiltersCollection */
1827 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1829 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1831 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1833 if(IsEqualGUID(&IID_IUnknown, riid)) {
1834 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1835 *ppv = &This->IHTMLFiltersCollection_iface;
1836 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1837 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1838 *ppv = &This->IHTMLFiltersCollection_iface;
1839 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1840 return *ppv ? S_OK : E_NOINTERFACE;
1844 IUnknown_AddRef((IUnknown*)*ppv);
1848 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1849 return E_NOINTERFACE;
1852 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1854 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1855 LONG ref = InterlockedIncrement(&This->ref);
1857 TRACE("(%p) ref=%d\n", This, ref);
1862 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1864 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1865 LONG ref = InterlockedDecrement(&This->ref);
1867 TRACE("(%p) ref=%d\n", This, ref);
1877 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1879 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1880 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1883 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1884 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1886 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1887 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1890 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1891 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1892 LCID lcid, DISPID *rgDispId)
1894 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1895 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1899 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1900 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1901 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1903 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1904 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1905 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1908 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1910 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1915 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1921 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1923 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1924 FIXME("(%p)->(%p)\n", This, p);
1928 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1930 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1931 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1935 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1936 HTMLFiltersCollection_QueryInterface,
1937 HTMLFiltersCollection_AddRef,
1938 HTMLFiltersCollection_Release,
1939 HTMLFiltersCollection_GetTypeInfoCount,
1940 HTMLFiltersCollection_GetTypeInfo,
1941 HTMLFiltersCollection_GetIDsOfNames,
1942 HTMLFiltersCollection_Invoke,
1943 HTMLFiltersCollection_get_length,
1944 HTMLFiltersCollection_get__newEnum,
1945 HTMLFiltersCollection_item
1948 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1953 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1954 idx = idx*10 + (*ptr-'0');
1956 return DISP_E_UNKNOWNNAME;
1958 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1959 TRACE("ret %x\n", *dispid);
1963 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1964 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1966 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
1968 V_VT(res) = VT_DISPATCH;
1969 V_DISPATCH(res) = NULL;
1971 FIXME("always returning NULL\n");
1976 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
1978 HTMLFiltersCollection_get_dispid,
1979 HTMLFiltersCollection_invoke
1982 static const tid_t HTMLFiltersCollection_iface_tids[] = {
1983 IHTMLFiltersCollection_tid,
1986 static dispex_static_data_t HTMLFiltersCollection_dispex = {
1987 &HTMLFiltersCollection_dispex_vtbl,
1988 IHTMLFiltersCollection_tid,
1990 HTMLFiltersCollection_iface_tids
1993 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
1995 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
1997 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2000 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2001 &HTMLFiltersCollection_dispex);
2003 return &ret->IHTMLFiltersCollection_iface;