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"
37 static const WCHAR aW[] = {'A',0};
38 static const WCHAR bodyW[] = {'B','O','D','Y',0};
39 static const WCHAR embedW[] = {'E','M','B','E','D',0};
40 static const WCHAR formW[] = {'F','O','R','M',0};
41 static const WCHAR frameW[] = {'F','R','A','M','E',0};
42 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
43 static const WCHAR imgW[] = {'I','M','G',0};
44 static const WCHAR inputW[] = {'I','N','P','U','T',0};
45 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
46 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
47 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
48 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
49 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
50 static const WCHAR tableW[] = {'T','A','B','L','E',0};
51 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
52 static const WCHAR trW[] = {'T','R',0};
56 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
59 static const tag_desc_t tag_descs[] = {
60 {aW, HTMLAnchorElement_Create},
61 {bodyW, HTMLBodyElement_Create},
62 {embedW, HTMLEmbedElement_Create},
63 {formW, HTMLFormElement_Create},
64 {frameW, HTMLFrameElement_Create},
65 {iframeW, HTMLIFrame_Create},
66 {imgW, HTMLImgElement_Create},
67 {inputW, HTMLInputElement_Create},
68 {objectW, HTMLObjectElement_Create},
69 {optionW, HTMLOptionElement_Create},
70 {scriptW, HTMLScriptElement_Create},
71 {selectW, HTMLSelectElement_Create},
72 {styleW, HTMLStyleElement_Create},
73 {tableW, HTMLTable_Create},
74 {textareaW, HTMLTextAreaElement_Create},
75 {trW, HTMLTableRow_Create}
78 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
80 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
85 r = strcmpW(tag_name, tag_descs[i].name);
101 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
104 } HTMLFiltersCollection;
106 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
108 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
111 IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
114 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
116 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
118 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
121 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
123 nsIDOMElement *nselem;
128 WARN("NULL nsdoc\n");
132 nsAString_InitDepend(&tag_str, tag);
133 nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
134 nsAString_Finish(&tag_str);
135 if(NS_FAILED(nsres)) {
136 ERR("CreateElement failed: %08x\n", nsres);
140 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
141 nsIDOMElement_Release(nselem);
142 if(NS_FAILED(nsres)) {
143 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
150 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
151 REFIID riid, void **ppv)
153 HTMLElement *This = impl_from_IHTMLElement(iface);
155 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
158 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
160 HTMLElement *This = impl_from_IHTMLElement(iface);
162 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->node));
165 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
167 HTMLElement *This = impl_from_IHTMLElement(iface);
169 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->node));
172 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
174 HTMLElement *This = impl_from_IHTMLElement(iface);
175 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
178 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
179 LCID lcid, ITypeInfo **ppTInfo)
181 HTMLElement *This = impl_from_IHTMLElement(iface);
182 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
185 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
186 LPOLESTR *rgszNames, UINT cNames,
187 LCID lcid, DISPID *rgDispId)
189 HTMLElement *This = impl_from_IHTMLElement(iface);
190 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
193 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
194 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
195 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
197 HTMLElement *This = impl_from_IHTMLElement(iface);
198 return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid,
199 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
202 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
203 VARIANT AttributeValue, LONG lFlags)
205 HTMLElement *This = impl_from_IHTMLElement(iface);
207 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
208 DISPPARAMS dispParams;
211 TRACE("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
213 hres = IDispatchEx_GetDispID(DISPATCHEX(&This->node.dispex), strAttributeName,
214 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
218 dispParams.cArgs = 1;
219 dispParams.cNamedArgs = 1;
220 dispParams.rgdispidNamedArgs = &dispidNamed;
221 dispParams.rgvarg = &AttributeValue;
223 hres = IDispatchEx_InvokeEx(DISPATCHEX(&This->node.dispex), dispid,
224 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams,
229 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
230 LONG lFlags, VARIANT *AttributeValue)
232 HTMLElement *This = impl_from_IHTMLElement(iface);
235 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
238 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
240 hres = IDispatchEx_GetDispID(DISPATCHEX(&This->node.dispex), strAttributeName,
241 fdexNameCaseInsensitive, &dispid);
242 if(hres == DISP_E_UNKNOWNNAME) {
243 V_VT(AttributeValue) = VT_NULL;
248 V_VT(AttributeValue) = VT_NULL;
252 hres = IDispatchEx_InvokeEx(DISPATCHEX(&This->node.dispex), dispid,
253 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dispParams,
254 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(HTMLDOMNODE(&This->node), &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);
427 nsIDOMElementCSSInlineStyle *nselemstyle;
428 nsIDOMCSSStyleDeclaration *nsstyle;
431 TRACE("(%p)->(%p)\n", This, p);
434 FIXME("NULL nselem\n");
438 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
439 (void**)&nselemstyle);
440 if(NS_FAILED(nsres)) {
441 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
445 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
446 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
447 if(NS_FAILED(nsres)) {
448 ERR("GetStyle failed: %08x\n", nsres);
452 /* FIXME: Store style instead of creating a new instance in each call */
453 *p = HTMLStyle_Create(nsstyle);
455 nsIDOMCSSStyleDeclaration_Release(nsstyle);
459 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
461 HTMLElement *This = impl_from_IHTMLElement(iface);
462 FIXME("(%p)->()\n", This);
466 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
468 HTMLElement *This = impl_from_IHTMLElement(iface);
469 FIXME("(%p)->(%p)\n", This, p);
473 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
475 HTMLElement *This = impl_from_IHTMLElement(iface);
477 TRACE("(%p)->()\n", This);
479 return set_node_event(&This->node, EVENTID_CLICK, &v);
482 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
484 HTMLElement *This = impl_from_IHTMLElement(iface);
486 TRACE("(%p)->(%p)\n", This, p);
488 return get_node_event(&This->node, EVENTID_CLICK, p);
491 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
493 HTMLElement *This = impl_from_IHTMLElement(iface);
495 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
497 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
500 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
502 HTMLElement *This = impl_from_IHTMLElement(iface);
504 TRACE("(%p)->(%p)\n", This, p);
506 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
509 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
511 HTMLElement *This = impl_from_IHTMLElement(iface);
513 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
515 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
518 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
520 HTMLElement *This = impl_from_IHTMLElement(iface);
522 TRACE("(%p)->(%p)\n", This, p);
524 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
527 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
529 HTMLElement *This = impl_from_IHTMLElement(iface);
531 TRACE("(%p)->()\n", This);
533 return set_node_event(&This->node, EVENTID_KEYUP, &v);
536 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
538 HTMLElement *This = impl_from_IHTMLElement(iface);
539 FIXME("(%p)->(%p)\n", This, p);
543 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
545 HTMLElement *This = impl_from_IHTMLElement(iface);
546 FIXME("(%p)->()\n", This);
550 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
552 HTMLElement *This = impl_from_IHTMLElement(iface);
553 FIXME("(%p)->(%p)\n", This, p);
557 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
559 HTMLElement *This = impl_from_IHTMLElement(iface);
561 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
563 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
566 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
568 HTMLElement *This = impl_from_IHTMLElement(iface);
570 TRACE("(%p)->(%p)\n", This, p);
572 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
575 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
577 HTMLElement *This = impl_from_IHTMLElement(iface);
579 TRACE("(%p)->()\n", This);
581 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
584 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
586 HTMLElement *This = impl_from_IHTMLElement(iface);
588 TRACE("(%p)->(%p)\n", This, p);
590 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
593 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
595 HTMLElement *This = impl_from_IHTMLElement(iface);
596 FIXME("(%p)->()\n", This);
600 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
602 HTMLElement *This = impl_from_IHTMLElement(iface);
603 FIXME("(%p)->(%p)\n", This, p);
607 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
609 HTMLElement *This = impl_from_IHTMLElement(iface);
611 TRACE("(%p)->()\n", This);
613 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
616 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
618 HTMLElement *This = impl_from_IHTMLElement(iface);
620 TRACE("(%p)->(%p)\n", This, p);
622 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
625 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
627 HTMLElement *This = impl_from_IHTMLElement(iface);
629 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
631 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
634 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
636 HTMLElement *This = impl_from_IHTMLElement(iface);
638 TRACE("(%p)->(%p)\n", This, p);
640 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
643 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
645 HTMLElement *This = impl_from_IHTMLElement(iface);
647 TRACE("(%p)->(%p)\n", This, p);
652 if(This->node.vtbl->get_document)
653 return This->node.vtbl->get_document(&This->node, p);
655 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
656 IDispatch_AddRef(*p);
660 static const WCHAR titleW[] = {'t','i','t','l','e',0};
662 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
664 HTMLElement *This = impl_from_IHTMLElement(iface);
668 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
674 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
680 V_BSTR(var) = v ? SysAllocString(v) : NULL;
684 nsAString_InitDepend(&title_str, v);
685 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
686 nsAString_Finish(&title_str);
688 ERR("SetTitle failed: %08x\n", nsres);
693 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
695 HTMLElement *This = impl_from_IHTMLElement(iface);
699 TRACE("(%p)->(%p)\n", This, p);
705 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
706 if(hres == DISP_E_UNKNOWNNAME) {
708 }else if(V_VT(var) != VT_BSTR) {
709 FIXME("title = %s\n", debugstr_variant(var));
712 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
718 nsAString_Init(&title_str, NULL);
719 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
720 if(NS_SUCCEEDED(nsres)) {
721 const PRUnichar *title;
723 nsAString_GetData(&title_str, &title);
724 *p = *title ? SysAllocString(title) : NULL;
726 ERR("GetTitle failed: %08x\n", nsres);
733 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
735 HTMLElement *This = impl_from_IHTMLElement(iface);
736 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
740 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
742 HTMLElement *This = impl_from_IHTMLElement(iface);
743 FIXME("(%p)->(%p)\n", This, p);
747 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
749 HTMLElement *This = impl_from_IHTMLElement(iface);
751 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
753 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
756 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
758 HTMLElement *This = impl_from_IHTMLElement(iface);
760 TRACE("(%p)->(%p)\n", This, p);
762 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
765 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
767 HTMLElement *This = impl_from_IHTMLElement(iface);
768 FIXME("(%p)->()\n", This);
772 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
773 VARIANT_BOOL *pfResult)
775 HTMLElement *This = impl_from_IHTMLElement(iface);
776 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
780 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
782 HTMLElement *This = impl_from_IHTMLElement(iface);
783 FIXME("(%p)->(%p)\n", This, p);
787 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
789 HTMLElement *This = impl_from_IHTMLElement(iface);
790 FIXME("(%p)->(%p)\n", This, p);
794 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
796 HTMLElement *This = impl_from_IHTMLElement(iface);
797 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
801 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
803 HTMLElement *This = impl_from_IHTMLElement(iface);
804 FIXME("(%p)->(%p)\n", This, p);
808 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
810 HTMLElement *This = impl_from_IHTMLElement(iface);
811 FIXME("(%p)->(%p)\n", This, p);
815 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
817 HTMLElement *This = impl_from_IHTMLElement(iface);
818 nsIDOMNSHTMLElement *nselem;
822 TRACE("(%p)->(%p)\n", This, p);
824 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
825 if(NS_FAILED(nsres)) {
826 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
830 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
831 nsIDOMNSHTMLElement_Release(nselem);
832 if(NS_FAILED(nsres)) {
833 ERR("GetOffsetTop failed: %08x\n", nsres);
841 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
843 HTMLElement *This = impl_from_IHTMLElement(iface);
844 nsIDOMNSHTMLElement *nselem;
848 TRACE("(%p)->(%p)\n", This, p);
850 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
851 if(NS_FAILED(nsres)) {
852 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
856 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
857 nsIDOMNSHTMLElement_Release(nselem);
858 if(NS_FAILED(nsres)) {
859 ERR("GetOffsetWidth failed: %08x\n", nsres);
867 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
869 HTMLElement *This = impl_from_IHTMLElement(iface);
870 nsIDOMNSHTMLElement *nselem;
874 TRACE("(%p)->(%p)\n", This, p);
876 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
877 if(NS_FAILED(nsres)) {
878 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
882 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
883 nsIDOMNSHTMLElement_Release(nselem);
884 if(NS_FAILED(nsres)) {
885 ERR("GetOffsetHeight failed: %08x\n", nsres);
893 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
895 HTMLElement *This = impl_from_IHTMLElement(iface);
896 FIXME("(%p)->(%p)\n", This, p);
900 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
902 HTMLElement *This = impl_from_IHTMLElement(iface);
903 nsIDOMNSHTMLElement *nselem;
907 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
910 FIXME("NULL nselem\n");
914 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
915 if(NS_FAILED(nsres)) {
916 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
920 nsAString_InitDepend(&html_str, v);
921 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
922 nsAString_Finish(&html_str);
924 if(NS_FAILED(nsres)) {
925 FIXME("SetInnerHtml failed %08x\n", nsres);
932 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
934 HTMLElement *This = impl_from_IHTMLElement(iface);
935 nsIDOMNSHTMLElement *nselem;
939 TRACE("(%p)->(%p)\n", This, p);
942 FIXME("NULL nselem\n");
946 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
947 if(NS_FAILED(nsres)) {
948 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
952 nsAString_Init(&html_str, NULL);
953 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
954 if(NS_SUCCEEDED(nsres)) {
955 const PRUnichar *html;
957 nsAString_GetData(&html_str, &html);
958 *p = *html ? SysAllocString(html) : NULL;
960 FIXME("SetInnerHtml failed %08x\n", nsres);
964 nsAString_Finish(&html_str);
968 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
970 HTMLElement *This = impl_from_IHTMLElement(iface);
971 nsIDOMNode *nschild, *tmp;
972 nsIDOMText *text_node;
976 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
979 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
980 if(NS_FAILED(nsres)) {
981 ERR("GetLastChild failed: %08x\n", nsres);
987 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
988 nsIDOMNode_Release(nschild);
989 if(NS_FAILED(nsres)) {
990 ERR("RemoveChild failed: %08x\n", nsres);
993 nsIDOMNode_Release(tmp);
996 nsAString_InitDepend(&text_str, v);
997 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
998 nsAString_Finish(&text_str);
999 if(NS_FAILED(nsres)) {
1000 ERR("CreateTextNode failed: %08x\n", nsres);
1004 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1005 if(NS_FAILED(nsres)) {
1006 ERR("AppendChild failed: %08x\n", nsres);
1010 nsIDOMNode_Release(tmp);
1014 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1016 HTMLElement *This = impl_from_IHTMLElement(iface);
1018 TRACE("(%p)->(%p)\n", This, p);
1020 return get_node_text(&This->node, p);
1023 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1025 HTMLElement *This = impl_from_IHTMLElement(iface);
1026 nsIDOMDocumentFragment *nsfragment;
1027 nsIDOMDocumentRange *nsdocrange;
1028 nsIDOMNSRange *nsrange;
1029 nsIDOMNode *nsparent;
1033 HRESULT hres = S_OK;
1035 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1037 nsres = nsIDOMHTMLDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
1038 if(NS_FAILED(nsres))
1041 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1042 nsIDOMDocumentRange_Release(nsdocrange);
1043 if(NS_FAILED(nsres)) {
1044 ERR("CreateRange failed: %08x\n", nsres);
1048 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
1049 nsIDOMRange_Release(range);
1050 if(NS_FAILED(nsres)) {
1051 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
1055 nsAString_InitDepend(&html_str, v);
1056 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
1057 nsIDOMNSRange_Release(nsrange);
1058 nsAString_Finish(&html_str);
1059 if(NS_FAILED(nsres)) {
1060 ERR("CreateContextualFragment failed: %08x\n", nsres);
1064 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsparent);
1065 if(NS_SUCCEEDED(nsres) && nsparent) {
1068 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, This->node.nsnode, &nstmp);
1069 nsIDOMNode_Release(nsparent);
1070 if(NS_FAILED(nsres)) {
1071 ERR("ReplaceChild failed: %08x\n", nsres);
1074 nsIDOMNode_Release(nstmp);
1077 ERR("GetParentNode failed: %08x\n", nsres);
1081 nsIDOMDocumentFragment_Release(nsfragment);
1085 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1087 HTMLElement *This = impl_from_IHTMLElement(iface);
1091 WARN("(%p)->(%p) semi-stub\n", This, p);
1093 nsAString_Init(&html_str, NULL);
1094 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1095 if(SUCCEEDED(hres)) {
1096 const PRUnichar *html;
1098 nsAString_GetData(&html_str, &html);
1099 *p = SysAllocString(html);
1101 hres = E_OUTOFMEMORY;
1104 nsAString_Finish(&html_str);
1106 TRACE("ret %s\n", debugstr_w(*p));
1110 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1112 HTMLElement *This = impl_from_IHTMLElement(iface);
1113 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1117 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1119 HTMLElement *This = impl_from_IHTMLElement(iface);
1120 FIXME("(%p)->(%p)\n", This, p);
1124 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1126 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1127 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1128 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1129 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1132 if (!strcmpiW(where, wszBeforeBegin))
1136 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1137 if (!parent) return E_INVALIDARG;
1138 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1139 if (unused) nsIDOMNode_Release(unused);
1140 nsIDOMNode_Release(parent);
1142 else if (!strcmpiW(where, wszAfterBegin))
1145 nsIDOMNode *first_child;
1146 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1147 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1148 if (unused) nsIDOMNode_Release(unused);
1149 if (first_child) nsIDOMNode_Release(first_child);
1151 else if (!strcmpiW(where, wszBeforeEnd))
1154 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1155 if (unused) nsIDOMNode_Release(unused);
1157 else if (!strcmpiW(where, wszAfterEnd))
1160 nsIDOMNode *next_sibling;
1162 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1163 if (!parent) return E_INVALIDARG;
1165 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1168 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1169 nsIDOMNode_Release(next_sibling);
1172 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1173 nsIDOMNode_Release(parent);
1174 if (unused) nsIDOMNode_Release(unused);
1178 ERR("invalid where: %s\n", debugstr_w(where));
1179 return E_INVALIDARG;
1182 if (NS_FAILED(nsres))
1188 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1191 HTMLElement *This = impl_from_IHTMLElement(iface);
1192 nsIDOMDocumentRange *nsdocrange;
1194 nsIDOMNSRange *nsrange;
1200 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1202 if(!This->node.doc->nsdoc) {
1203 WARN("NULL nsdoc\n");
1204 return E_UNEXPECTED;
1207 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1208 if(NS_FAILED(nsres))
1210 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1213 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1214 nsIDOMDocumentRange_Release(nsdocrange);
1215 if(NS_FAILED(nsres))
1217 ERR("CreateRange failed: %08x\n", nsres);
1221 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1223 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1224 nsIDOMRange_Release(range);
1225 if(NS_FAILED(nsres))
1227 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1231 nsAString_InitDepend(&ns_html, html);
1233 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1234 nsIDOMNSRange_Release(nsrange);
1235 nsAString_Finish(&ns_html);
1237 if(NS_FAILED(nsres) || !nsnode)
1239 ERR("CreateTextNode failed: %08x\n", nsres);
1243 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1244 nsIDOMNode_Release(nsnode);
1249 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1252 HTMLElement *This = impl_from_IHTMLElement(iface);
1258 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1260 if(!This->node.doc->nsdoc) {
1261 WARN("NULL nsdoc\n");
1262 return E_UNEXPECTED;
1266 nsAString_InitDepend(&ns_text, text);
1267 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1268 nsAString_Finish(&ns_text);
1270 if(NS_FAILED(nsres) || !nsnode)
1272 ERR("CreateTextNode failed: %08x\n", nsres);
1276 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1277 nsIDOMNode_Release(nsnode);
1282 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1284 HTMLElement *This = impl_from_IHTMLElement(iface);
1285 FIXME("(%p)->(%p)\n", This, p);
1289 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1291 HTMLElement *This = impl_from_IHTMLElement(iface);
1292 FIXME("(%p)->(%p)\n", This, p);
1296 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1298 HTMLElement *This = impl_from_IHTMLElement(iface);
1300 TRACE("(%p)\n", This);
1302 return call_event(&This->node, EVENTID_CLICK);
1305 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1306 IHTMLFiltersCollection **p)
1308 HTMLElement *This = impl_from_IHTMLElement(iface);
1309 TRACE("(%p)->(%p)\n", This, p);
1314 *p = HTMLFiltersCollection_Create();
1319 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1321 HTMLElement *This = impl_from_IHTMLElement(iface);
1322 FIXME("(%p)->()\n", This);
1326 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1328 HTMLElement *This = impl_from_IHTMLElement(iface);
1329 FIXME("(%p)->(%p)\n", This, p);
1333 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1335 HTMLElement *This = impl_from_IHTMLElement(iface);
1336 FIXME("(%p)->(%p)\n", This, String);
1340 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1342 HTMLElement *This = impl_from_IHTMLElement(iface);
1343 FIXME("(%p)->()\n", This);
1347 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1349 HTMLElement *This = impl_from_IHTMLElement(iface);
1350 FIXME("(%p)->(%p)\n", This, p);
1354 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1356 HTMLElement *This = impl_from_IHTMLElement(iface);
1357 FIXME("(%p)->()\n", This);
1361 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1363 HTMLElement *This = impl_from_IHTMLElement(iface);
1364 FIXME("(%p)->(%p)\n", This, p);
1368 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1370 HTMLElement *This = impl_from_IHTMLElement(iface);
1371 FIXME("(%p)->()\n", This);
1375 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1377 HTMLElement *This = impl_from_IHTMLElement(iface);
1378 FIXME("(%p)->(%p)\n", This, p);
1382 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1384 HTMLElement *This = impl_from_IHTMLElement(iface);
1385 FIXME("(%p)->()\n", This);
1389 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1391 HTMLElement *This = impl_from_IHTMLElement(iface);
1392 FIXME("(%p)->(%p)\n", This, p);
1396 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1398 HTMLElement *This = impl_from_IHTMLElement(iface);
1399 FIXME("(%p)->()\n", This);
1403 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1405 HTMLElement *This = impl_from_IHTMLElement(iface);
1406 FIXME("(%p)->(%p)\n", This, p);
1410 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1412 HTMLElement *This = impl_from_IHTMLElement(iface);
1413 FIXME("(%p)->()\n", This);
1417 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1419 HTMLElement *This = impl_from_IHTMLElement(iface);
1420 FIXME("(%p)->(%p)\n", This, p);
1424 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1426 HTMLElement *This = impl_from_IHTMLElement(iface);
1427 FIXME("(%p)->()\n", This);
1431 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1433 HTMLElement *This = impl_from_IHTMLElement(iface);
1434 FIXME("(%p)->(%p)\n", This, p);
1438 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1440 HTMLElement *This = impl_from_IHTMLElement(iface);
1441 FIXME("(%p)->()\n", This);
1445 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1447 HTMLElement *This = impl_from_IHTMLElement(iface);
1448 FIXME("(%p)->(%p)\n", This, p);
1452 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1454 HTMLElement *This = impl_from_IHTMLElement(iface);
1455 FIXME("(%p)->()\n", This);
1459 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1461 HTMLElement *This = impl_from_IHTMLElement(iface);
1462 FIXME("(%p)->(%p)\n", This, p);
1466 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1468 HTMLElement *This = impl_from_IHTMLElement(iface);
1469 nsIDOMNodeList *nsnode_list;
1472 TRACE("(%p)->(%p)\n", This, p);
1474 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1475 if(NS_FAILED(nsres)) {
1476 ERR("GetChildNodes failed: %08x\n", nsres);
1480 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
1481 (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
1483 nsIDOMNodeList_Release(nsnode_list);
1487 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1489 HTMLElement *This = impl_from_IHTMLElement(iface);
1491 TRACE("(%p)->(%p)\n", This, p);
1493 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1497 static const IHTMLElementVtbl HTMLElementVtbl = {
1498 HTMLElement_QueryInterface,
1500 HTMLElement_Release,
1501 HTMLElement_GetTypeInfoCount,
1502 HTMLElement_GetTypeInfo,
1503 HTMLElement_GetIDsOfNames,
1505 HTMLElement_setAttribute,
1506 HTMLElement_getAttribute,
1507 HTMLElement_removeAttribute,
1508 HTMLElement_put_className,
1509 HTMLElement_get_className,
1512 HTMLElement_get_tagName,
1513 HTMLElement_get_parentElement,
1514 HTMLElement_get_style,
1515 HTMLElement_put_onhelp,
1516 HTMLElement_get_onhelp,
1517 HTMLElement_put_onclick,
1518 HTMLElement_get_onclick,
1519 HTMLElement_put_ondblclick,
1520 HTMLElement_get_ondblclick,
1521 HTMLElement_put_onkeydown,
1522 HTMLElement_get_onkeydown,
1523 HTMLElement_put_onkeyup,
1524 HTMLElement_get_onkeyup,
1525 HTMLElement_put_onkeypress,
1526 HTMLElement_get_onkeypress,
1527 HTMLElement_put_onmouseout,
1528 HTMLElement_get_onmouseout,
1529 HTMLElement_put_onmouseover,
1530 HTMLElement_get_onmouseover,
1531 HTMLElement_put_onmousemove,
1532 HTMLElement_get_onmousemove,
1533 HTMLElement_put_onmousedown,
1534 HTMLElement_get_onmousedown,
1535 HTMLElement_put_onmouseup,
1536 HTMLElement_get_onmouseup,
1537 HTMLElement_get_document,
1538 HTMLElement_put_title,
1539 HTMLElement_get_title,
1540 HTMLElement_put_language,
1541 HTMLElement_get_language,
1542 HTMLElement_put_onselectstart,
1543 HTMLElement_get_onselectstart,
1544 HTMLElement_scrollIntoView,
1545 HTMLElement_contains,
1546 HTMLElement_get_sourceIndex,
1547 HTMLElement_get_recordNumber,
1548 HTMLElement_put_lang,
1549 HTMLElement_get_lang,
1550 HTMLElement_get_offsetLeft,
1551 HTMLElement_get_offsetTop,
1552 HTMLElement_get_offsetWidth,
1553 HTMLElement_get_offsetHeight,
1554 HTMLElement_get_offsetParent,
1555 HTMLElement_put_innerHTML,
1556 HTMLElement_get_innerHTML,
1557 HTMLElement_put_innerText,
1558 HTMLElement_get_innerText,
1559 HTMLElement_put_outerHTML,
1560 HTMLElement_get_outerHTML,
1561 HTMLElement_put_outerText,
1562 HTMLElement_get_outerText,
1563 HTMLElement_insertAdjacentHTML,
1564 HTMLElement_insertAdjacentText,
1565 HTMLElement_get_parentTextEdit,
1566 HTMLElement_get_isTextEdit,
1568 HTMLElement_get_filters,
1569 HTMLElement_put_ondragstart,
1570 HTMLElement_get_ondragstart,
1571 HTMLElement_toString,
1572 HTMLElement_put_onbeforeupdate,
1573 HTMLElement_get_onbeforeupdate,
1574 HTMLElement_put_onafterupdate,
1575 HTMLElement_get_onafterupdate,
1576 HTMLElement_put_onerrorupdate,
1577 HTMLElement_get_onerrorupdate,
1578 HTMLElement_put_onrowexit,
1579 HTMLElement_get_onrowexit,
1580 HTMLElement_put_onrowenter,
1581 HTMLElement_get_onrowenter,
1582 HTMLElement_put_ondatasetchanged,
1583 HTMLElement_get_ondatasetchanged,
1584 HTMLElement_put_ondataavailable,
1585 HTMLElement_get_ondataavailable,
1586 HTMLElement_put_ondatasetcomplete,
1587 HTMLElement_get_ondatasetcomplete,
1588 HTMLElement_put_onfilterchange,
1589 HTMLElement_get_onfilterchange,
1590 HTMLElement_get_children,
1594 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1596 return CONTAINING_RECORD(iface, HTMLElement, node);
1599 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1601 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1605 if(IsEqualGUID(&IID_IUnknown, riid)) {
1606 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1607 *ppv = &This->IHTMLElement_iface;
1608 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1609 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1610 *ppv = &This->IHTMLElement_iface;
1611 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1612 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1613 *ppv = &This->IHTMLElement_iface;
1614 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1615 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1616 *ppv = &This->IHTMLElement2_iface;
1617 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1618 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1619 *ppv = &This->IHTMLElement3_iface;
1620 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1621 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1622 *ppv = CONPTCONT(&This->cp_container);
1626 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1630 return HTMLDOMNode_QI(&This->node, riid, ppv);
1633 void HTMLElement_destructor(HTMLDOMNode *iface)
1635 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1637 ConnectionPointContainer_Destroy(&This->cp_container);
1640 nsIDOMHTMLElement_Release(This->nselem);
1642 HTMLDOMNode_destructor(&This->node);
1645 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1647 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1648 HTMLElement *new_elem;
1651 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1655 IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
1656 *ret = &new_elem->node;
1660 static const NodeImplVtbl HTMLElementImplVtbl = {
1662 HTMLElement_destructor,
1666 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1668 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1671 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1672 DWORD grfdex, DISPID *pid)
1674 HTMLElement *This = impl_from_DispatchEx(dispex);
1676 if(This->node.vtbl->get_dispid)
1677 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1679 return DISP_E_UNKNOWNNAME;
1682 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1683 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1684 IServiceProvider *caller)
1686 HTMLElement *This = impl_from_DispatchEx(dispex);
1688 if(This->node.vtbl->invoke)
1689 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1690 params, res, ei, caller);
1692 ERR("(%p): element has no invoke method\n", This);
1696 static const tid_t HTMLElement_iface_tids[] = {
1701 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1703 HTMLElement_get_dispid,
1707 static dispex_static_data_t HTMLElement_dispex = {
1708 &HTMLElement_dispex_vtbl,
1709 DispHTMLUnknownElement_tid,
1711 HTMLElement_iface_tids
1714 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1716 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1718 HTMLElement2_Init(This);
1719 HTMLElement3_Init(This);
1721 if(dispex_data && !dispex_data->vtbl)
1722 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1723 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1724 dispex_data ? dispex_data : &HTMLElement_dispex);
1727 nsIDOMHTMLElement_AddRef(nselem);
1728 This->nselem = nselem;
1730 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1732 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1735 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1737 nsIDOMHTMLElement *nselem;
1738 nsAString class_name_str;
1739 const PRUnichar *class_name;
1740 const tag_desc_t *tag;
1745 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1746 if(NS_FAILED(nsres))
1749 nsAString_Init(&class_name_str, NULL);
1750 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1752 nsAString_GetData(&class_name_str, &class_name);
1754 tag = get_tag_desc(class_name);
1756 hres = tag->constructor(doc, nselem, &elem);
1757 }else if(use_generic) {
1758 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1760 elem = heap_alloc_zero(sizeof(HTMLElement));
1762 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1763 elem->node.vtbl = &HTMLElementImplVtbl;
1766 hres = E_OUTOFMEMORY;
1770 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1772 nsIDOMElement_Release(nselem);
1773 nsAString_Finish(&class_name_str);
1781 /* interface IHTMLFiltersCollection */
1782 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1784 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1786 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1788 if(IsEqualGUID(&IID_IUnknown, riid)) {
1789 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1790 *ppv = &This->IHTMLFiltersCollection_iface;
1791 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1792 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1793 *ppv = &This->IHTMLFiltersCollection_iface;
1794 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1795 return *ppv ? S_OK : E_NOINTERFACE;
1799 IUnknown_AddRef((IUnknown*)*ppv);
1803 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1804 return E_NOINTERFACE;
1807 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1809 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1810 LONG ref = InterlockedIncrement(&This->ref);
1812 TRACE("(%p) ref=%d\n", This, ref);
1817 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1819 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1820 LONG ref = InterlockedDecrement(&This->ref);
1822 TRACE("(%p) ref=%d\n", This, ref);
1832 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1834 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1835 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1838 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1839 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1841 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1842 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1845 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1846 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1847 LCID lcid, DISPID *rgDispId)
1849 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1850 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1853 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1854 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1855 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1857 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1858 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
1859 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1862 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1864 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1869 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1875 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1877 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1878 FIXME("(%p)->(%p)\n", This, p);
1882 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1884 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1885 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1889 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1890 HTMLFiltersCollection_QueryInterface,
1891 HTMLFiltersCollection_AddRef,
1892 HTMLFiltersCollection_Release,
1893 HTMLFiltersCollection_GetTypeInfoCount,
1894 HTMLFiltersCollection_GetTypeInfo,
1895 HTMLFiltersCollection_GetIDsOfNames,
1896 HTMLFiltersCollection_Invoke,
1897 HTMLFiltersCollection_get_length,
1898 HTMLFiltersCollection_get__newEnum,
1899 HTMLFiltersCollection_item
1902 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1907 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1908 idx = idx*10 + (*ptr-'0');
1910 return DISP_E_UNKNOWNNAME;
1912 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1913 TRACE("ret %x\n", *dispid);
1917 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1918 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1920 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
1922 V_VT(res) = VT_DISPATCH;
1923 V_DISPATCH(res) = NULL;
1925 FIXME("always returning NULL\n");
1930 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
1932 HTMLFiltersCollection_get_dispid,
1933 HTMLFiltersCollection_invoke
1936 static const tid_t HTMLFiltersCollection_iface_tids[] = {
1937 IHTMLFiltersCollection_tid,
1940 static dispex_static_data_t HTMLFiltersCollection_dispex = {
1941 &HTMLFiltersCollection_dispex_vtbl,
1942 IHTMLFiltersCollection_tid,
1944 HTMLFiltersCollection_iface_tids
1947 IHTMLFiltersCollection *HTMLFiltersCollection_Create()
1949 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
1951 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
1954 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
1955 &HTMLFiltersCollection_dispex);
1957 return &ret->IHTMLFiltersCollection_iface;