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(&This->node.IHTMLDOMNode_iface, riid, ppv);
158 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
160 HTMLElement *This = impl_from_IHTMLElement(iface);
162 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
165 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
167 HTMLElement *This = impl_from_IHTMLElement(iface);
169 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
172 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
174 HTMLElement *This = impl_from_IHTMLElement(iface);
175 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, 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(&This->node.dispex.IDispatchEx_iface, 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(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
194 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
195 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
196 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
198 HTMLElement *This = impl_from_IHTMLElement(iface);
199 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
200 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
203 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
204 VARIANT AttributeValue, LONG lFlags)
206 HTMLElement *This = impl_from_IHTMLElement(iface);
208 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
209 DISPPARAMS dispParams;
212 TRACE("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
214 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
215 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
219 dispParams.cArgs = 1;
220 dispParams.cNamedArgs = 1;
221 dispParams.rgdispidNamedArgs = &dispidNamed;
222 dispParams.rgvarg = &AttributeValue;
224 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
225 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
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(&This->node.dispex.IDispatchEx_iface, 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(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
253 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
258 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
259 LONG lFlags, VARIANT_BOOL *pfSuccess)
261 HTMLElement *This = impl_from_IHTMLElement(iface);
263 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
265 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
268 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
270 HTMLElement *This = impl_from_IHTMLElement(iface);
271 nsAString classname_str;
274 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
277 FIXME("NULL nselem\n");
281 nsAString_InitDepend(&classname_str, v);
282 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
283 nsAString_Finish(&classname_str);
285 ERR("SetClassName failed: %08x\n", nsres);
290 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
292 HTMLElement *This = impl_from_IHTMLElement(iface);
297 TRACE("(%p)->(%p)\n", This, p);
300 FIXME("NULL nselem\n");
304 nsAString_Init(&class_str, NULL);
305 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
307 if(NS_SUCCEEDED(nsres)) {
308 const PRUnichar *class;
309 nsAString_GetData(&class_str, &class);
310 *p = *class ? SysAllocString(class) : NULL;
312 ERR("GetClassName failed: %08x\n", nsres);
316 nsAString_Finish(&class_str);
318 TRACE("className=%s\n", debugstr_w(*p));
322 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
324 HTMLElement *This = impl_from_IHTMLElement(iface);
328 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
331 FIXME("nselem == NULL\n");
335 nsAString_InitDepend(&id_str, v);
336 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
337 nsAString_Finish(&id_str);
339 ERR("SetId failed: %08x\n", nsres);
344 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
346 HTMLElement *This = impl_from_IHTMLElement(iface);
351 TRACE("(%p)->(%p)\n", This, p);
358 nsAString_Init(&id_str, NULL);
359 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
360 nsAString_GetData(&id_str, &id);
363 ERR("GetId failed: %08x\n", nsres);
365 *p = SysAllocString(id);
367 nsAString_Finish(&id_str);
371 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
373 HTMLElement *This = impl_from_IHTMLElement(iface);
374 const PRUnichar *tag;
378 TRACE("(%p)->(%p)\n", This, p);
381 static const WCHAR comment_tagW[] = {'!',0};
383 WARN("NULL nselem, assuming comment\n");
385 *p = SysAllocString(comment_tagW);
389 nsAString_Init(&tag_str, NULL);
390 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
391 if(NS_SUCCEEDED(nsres)) {
392 nsAString_GetData(&tag_str, &tag);
393 *p = SysAllocString(tag);
395 ERR("GetTagName failed: %08x\n", nsres);
398 nsAString_Finish(&tag_str);
403 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
405 HTMLElement *This = impl_from_IHTMLElement(iface);
409 TRACE("(%p)->(%p)\n", This, p);
411 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
415 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
416 IHTMLDOMNode_Release(node);
423 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
425 HTMLElement *This = impl_from_IHTMLElement(iface);
426 nsIDOMElementCSSInlineStyle *nselemstyle;
427 nsIDOMCSSStyleDeclaration *nsstyle;
430 TRACE("(%p)->(%p)\n", This, p);
433 FIXME("NULL nselem\n");
437 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
438 (void**)&nselemstyle);
439 if(NS_FAILED(nsres)) {
440 ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
444 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
445 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
446 if(NS_FAILED(nsres)) {
447 ERR("GetStyle failed: %08x\n", nsres);
451 /* FIXME: Store style instead of creating a new instance in each call */
452 *p = HTMLStyle_Create(nsstyle);
454 nsIDOMCSSStyleDeclaration_Release(nsstyle);
458 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
460 HTMLElement *This = impl_from_IHTMLElement(iface);
461 FIXME("(%p)->()\n", This);
465 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
467 HTMLElement *This = impl_from_IHTMLElement(iface);
468 FIXME("(%p)->(%p)\n", This, p);
472 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
474 HTMLElement *This = impl_from_IHTMLElement(iface);
476 TRACE("(%p)->()\n", This);
478 return set_node_event(&This->node, EVENTID_CLICK, &v);
481 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
483 HTMLElement *This = impl_from_IHTMLElement(iface);
485 TRACE("(%p)->(%p)\n", This, p);
487 return get_node_event(&This->node, EVENTID_CLICK, p);
490 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
492 HTMLElement *This = impl_from_IHTMLElement(iface);
494 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
496 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
499 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
501 HTMLElement *This = impl_from_IHTMLElement(iface);
503 TRACE("(%p)->(%p)\n", This, p);
505 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
508 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
510 HTMLElement *This = impl_from_IHTMLElement(iface);
512 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
514 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
517 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
519 HTMLElement *This = impl_from_IHTMLElement(iface);
521 TRACE("(%p)->(%p)\n", This, p);
523 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
526 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
528 HTMLElement *This = impl_from_IHTMLElement(iface);
530 TRACE("(%p)->()\n", This);
532 return set_node_event(&This->node, EVENTID_KEYUP, &v);
535 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
537 HTMLElement *This = impl_from_IHTMLElement(iface);
538 FIXME("(%p)->(%p)\n", This, p);
542 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
544 HTMLElement *This = impl_from_IHTMLElement(iface);
545 FIXME("(%p)->()\n", This);
549 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
551 HTMLElement *This = impl_from_IHTMLElement(iface);
552 FIXME("(%p)->(%p)\n", This, p);
556 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
558 HTMLElement *This = impl_from_IHTMLElement(iface);
560 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
562 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
565 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
567 HTMLElement *This = impl_from_IHTMLElement(iface);
569 TRACE("(%p)->(%p)\n", This, p);
571 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
574 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
576 HTMLElement *This = impl_from_IHTMLElement(iface);
578 TRACE("(%p)->()\n", This);
580 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
583 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
585 HTMLElement *This = impl_from_IHTMLElement(iface);
587 TRACE("(%p)->(%p)\n", This, p);
589 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
592 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
594 HTMLElement *This = impl_from_IHTMLElement(iface);
596 TRACE("(%p)->()\n", This);
598 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
601 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
603 HTMLElement *This = impl_from_IHTMLElement(iface);
605 TRACE("(%p)->(%p)\n", This, p);
607 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
610 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
612 HTMLElement *This = impl_from_IHTMLElement(iface);
614 TRACE("(%p)->()\n", This);
616 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
619 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
621 HTMLElement *This = impl_from_IHTMLElement(iface);
623 TRACE("(%p)->(%p)\n", This, p);
625 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
628 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
630 HTMLElement *This = impl_from_IHTMLElement(iface);
632 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
634 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
637 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
639 HTMLElement *This = impl_from_IHTMLElement(iface);
641 TRACE("(%p)->(%p)\n", This, p);
643 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
646 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
648 HTMLElement *This = impl_from_IHTMLElement(iface);
650 TRACE("(%p)->(%p)\n", This, p);
655 if(This->node.vtbl->get_document)
656 return This->node.vtbl->get_document(&This->node, p);
658 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
659 IDispatch_AddRef(*p);
663 static const WCHAR titleW[] = {'t','i','t','l','e',0};
665 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
667 HTMLElement *This = impl_from_IHTMLElement(iface);
671 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
677 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
683 V_BSTR(var) = v ? SysAllocString(v) : NULL;
687 nsAString_InitDepend(&title_str, v);
688 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
689 nsAString_Finish(&title_str);
691 ERR("SetTitle failed: %08x\n", nsres);
696 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
698 HTMLElement *This = impl_from_IHTMLElement(iface);
702 TRACE("(%p)->(%p)\n", This, p);
708 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
709 if(hres == DISP_E_UNKNOWNNAME) {
711 }else if(V_VT(var) != VT_BSTR) {
712 FIXME("title = %s\n", debugstr_variant(var));
715 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
721 nsAString_Init(&title_str, NULL);
722 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
723 if(NS_SUCCEEDED(nsres)) {
724 const PRUnichar *title;
726 nsAString_GetData(&title_str, &title);
727 *p = *title ? SysAllocString(title) : NULL;
729 ERR("GetTitle failed: %08x\n", nsres);
736 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
738 HTMLElement *This = impl_from_IHTMLElement(iface);
739 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
743 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
745 HTMLElement *This = impl_from_IHTMLElement(iface);
746 FIXME("(%p)->(%p)\n", This, p);
750 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
752 HTMLElement *This = impl_from_IHTMLElement(iface);
754 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
756 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
759 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
761 HTMLElement *This = impl_from_IHTMLElement(iface);
763 TRACE("(%p)->(%p)\n", This, p);
765 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
768 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
770 HTMLElement *This = impl_from_IHTMLElement(iface);
771 FIXME("(%p)->()\n", This);
775 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
776 VARIANT_BOOL *pfResult)
778 HTMLElement *This = impl_from_IHTMLElement(iface);
779 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
783 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
785 HTMLElement *This = impl_from_IHTMLElement(iface);
786 FIXME("(%p)->(%p)\n", This, p);
790 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
792 HTMLElement *This = impl_from_IHTMLElement(iface);
793 FIXME("(%p)->(%p)\n", This, p);
797 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
799 HTMLElement *This = impl_from_IHTMLElement(iface);
800 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
804 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
806 HTMLElement *This = impl_from_IHTMLElement(iface);
807 FIXME("(%p)->(%p)\n", This, p);
811 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
813 HTMLElement *This = impl_from_IHTMLElement(iface);
814 FIXME("(%p)->(%p)\n", This, p);
818 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
820 HTMLElement *This = impl_from_IHTMLElement(iface);
821 nsIDOMNSHTMLElement *nselem;
825 TRACE("(%p)->(%p)\n", This, p);
827 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
828 if(NS_FAILED(nsres)) {
829 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
833 nsres = nsIDOMNSHTMLElement_GetOffsetTop(nselem, &top);
834 nsIDOMNSHTMLElement_Release(nselem);
835 if(NS_FAILED(nsres)) {
836 ERR("GetOffsetTop failed: %08x\n", nsres);
844 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
846 HTMLElement *This = impl_from_IHTMLElement(iface);
847 nsIDOMNSHTMLElement *nselem;
851 TRACE("(%p)->(%p)\n", This, p);
853 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
854 if(NS_FAILED(nsres)) {
855 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
859 nsres = nsIDOMNSHTMLElement_GetOffsetWidth(nselem, &offset);
860 nsIDOMNSHTMLElement_Release(nselem);
861 if(NS_FAILED(nsres)) {
862 ERR("GetOffsetWidth failed: %08x\n", nsres);
870 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
872 HTMLElement *This = impl_from_IHTMLElement(iface);
873 nsIDOMNSHTMLElement *nselem;
877 TRACE("(%p)->(%p)\n", This, p);
879 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
880 if(NS_FAILED(nsres)) {
881 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
885 nsres = nsIDOMNSHTMLElement_GetOffsetHeight(nselem, &offset);
886 nsIDOMNSHTMLElement_Release(nselem);
887 if(NS_FAILED(nsres)) {
888 ERR("GetOffsetHeight failed: %08x\n", nsres);
896 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
898 HTMLElement *This = impl_from_IHTMLElement(iface);
899 FIXME("(%p)->(%p)\n", This, p);
903 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
905 HTMLElement *This = impl_from_IHTMLElement(iface);
906 nsIDOMNSHTMLElement *nselem;
910 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
913 FIXME("NULL nselem\n");
917 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
918 if(NS_FAILED(nsres)) {
919 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
923 nsAString_InitDepend(&html_str, v);
924 nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str);
925 nsAString_Finish(&html_str);
927 if(NS_FAILED(nsres)) {
928 FIXME("SetInnerHtml failed %08x\n", nsres);
935 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
937 HTMLElement *This = impl_from_IHTMLElement(iface);
938 nsIDOMNSHTMLElement *nselem;
942 TRACE("(%p)->(%p)\n", This, p);
945 FIXME("NULL nselem\n");
949 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
950 if(NS_FAILED(nsres)) {
951 ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
955 nsAString_Init(&html_str, NULL);
956 nsres = nsIDOMNSHTMLElement_GetInnerHTML(nselem, &html_str);
957 if(NS_SUCCEEDED(nsres)) {
958 const PRUnichar *html;
960 nsAString_GetData(&html_str, &html);
961 *p = *html ? SysAllocString(html) : NULL;
963 FIXME("SetInnerHtml failed %08x\n", nsres);
967 nsAString_Finish(&html_str);
971 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
973 HTMLElement *This = impl_from_IHTMLElement(iface);
974 nsIDOMNode *nschild, *tmp;
975 nsIDOMText *text_node;
979 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
982 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
983 if(NS_FAILED(nsres)) {
984 ERR("GetLastChild failed: %08x\n", nsres);
990 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
991 nsIDOMNode_Release(nschild);
992 if(NS_FAILED(nsres)) {
993 ERR("RemoveChild failed: %08x\n", nsres);
996 nsIDOMNode_Release(tmp);
999 nsAString_InitDepend(&text_str, v);
1000 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1001 nsAString_Finish(&text_str);
1002 if(NS_FAILED(nsres)) {
1003 ERR("CreateTextNode failed: %08x\n", nsres);
1007 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1008 if(NS_FAILED(nsres)) {
1009 ERR("AppendChild failed: %08x\n", nsres);
1013 nsIDOMNode_Release(tmp);
1017 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1019 HTMLElement *This = impl_from_IHTMLElement(iface);
1021 TRACE("(%p)->(%p)\n", This, p);
1023 return get_node_text(&This->node, p);
1026 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1028 HTMLElement *This = impl_from_IHTMLElement(iface);
1029 nsIDOMDocumentFragment *nsfragment;
1030 nsIDOMDocumentRange *nsdocrange;
1031 nsIDOMNSRange *nsrange;
1032 nsIDOMNode *nsparent;
1036 HRESULT hres = S_OK;
1038 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1040 nsres = nsIDOMHTMLDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
1041 if(NS_FAILED(nsres))
1044 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1045 nsIDOMDocumentRange_Release(nsdocrange);
1046 if(NS_FAILED(nsres)) {
1047 ERR("CreateRange failed: %08x\n", nsres);
1051 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
1052 nsIDOMRange_Release(range);
1053 if(NS_FAILED(nsres)) {
1054 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
1058 nsAString_InitDepend(&html_str, v);
1059 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
1060 nsIDOMNSRange_Release(nsrange);
1061 nsAString_Finish(&html_str);
1062 if(NS_FAILED(nsres)) {
1063 ERR("CreateContextualFragment failed: %08x\n", nsres);
1067 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsparent);
1068 if(NS_SUCCEEDED(nsres) && nsparent) {
1071 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, This->node.nsnode, &nstmp);
1072 nsIDOMNode_Release(nsparent);
1073 if(NS_FAILED(nsres)) {
1074 ERR("ReplaceChild failed: %08x\n", nsres);
1077 nsIDOMNode_Release(nstmp);
1080 ERR("GetParentNode failed: %08x\n", nsres);
1084 nsIDOMDocumentFragment_Release(nsfragment);
1088 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1090 HTMLElement *This = impl_from_IHTMLElement(iface);
1094 WARN("(%p)->(%p) semi-stub\n", This, p);
1096 nsAString_Init(&html_str, NULL);
1097 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1098 if(SUCCEEDED(hres)) {
1099 const PRUnichar *html;
1101 nsAString_GetData(&html_str, &html);
1102 *p = SysAllocString(html);
1104 hres = E_OUTOFMEMORY;
1107 nsAString_Finish(&html_str);
1109 TRACE("ret %s\n", debugstr_w(*p));
1113 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1115 HTMLElement *This = impl_from_IHTMLElement(iface);
1116 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1120 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1122 HTMLElement *This = impl_from_IHTMLElement(iface);
1123 FIXME("(%p)->(%p)\n", This, p);
1127 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1129 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1130 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1131 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1132 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1135 if (!strcmpiW(where, wszBeforeBegin))
1139 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1140 if (!parent) return E_INVALIDARG;
1141 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1142 if (unused) nsIDOMNode_Release(unused);
1143 nsIDOMNode_Release(parent);
1145 else if (!strcmpiW(where, wszAfterBegin))
1148 nsIDOMNode *first_child;
1149 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1150 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1151 if (unused) nsIDOMNode_Release(unused);
1152 if (first_child) nsIDOMNode_Release(first_child);
1154 else if (!strcmpiW(where, wszBeforeEnd))
1157 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1158 if (unused) nsIDOMNode_Release(unused);
1160 else if (!strcmpiW(where, wszAfterEnd))
1163 nsIDOMNode *next_sibling;
1165 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1166 if (!parent) return E_INVALIDARG;
1168 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1171 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1172 nsIDOMNode_Release(next_sibling);
1175 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1176 nsIDOMNode_Release(parent);
1177 if (unused) nsIDOMNode_Release(unused);
1181 ERR("invalid where: %s\n", debugstr_w(where));
1182 return E_INVALIDARG;
1185 if (NS_FAILED(nsres))
1191 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1194 HTMLElement *This = impl_from_IHTMLElement(iface);
1195 nsIDOMDocumentRange *nsdocrange;
1197 nsIDOMNSRange *nsrange;
1203 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1205 if(!This->node.doc->nsdoc) {
1206 WARN("NULL nsdoc\n");
1207 return E_UNEXPECTED;
1210 nsres = nsIDOMDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void **)&nsdocrange);
1211 if(NS_FAILED(nsres))
1213 ERR("getting nsIDOMDocumentRange failed: %08x\n", nsres);
1216 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
1217 nsIDOMDocumentRange_Release(nsdocrange);
1218 if(NS_FAILED(nsres))
1220 ERR("CreateRange failed: %08x\n", nsres);
1224 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1226 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1227 nsIDOMRange_Release(range);
1228 if(NS_FAILED(nsres))
1230 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1234 nsAString_InitDepend(&ns_html, html);
1236 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1237 nsIDOMNSRange_Release(nsrange);
1238 nsAString_Finish(&ns_html);
1240 if(NS_FAILED(nsres) || !nsnode)
1242 ERR("CreateTextNode failed: %08x\n", nsres);
1246 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1247 nsIDOMNode_Release(nsnode);
1252 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1255 HTMLElement *This = impl_from_IHTMLElement(iface);
1261 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1263 if(!This->node.doc->nsdoc) {
1264 WARN("NULL nsdoc\n");
1265 return E_UNEXPECTED;
1269 nsAString_InitDepend(&ns_text, text);
1270 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1271 nsAString_Finish(&ns_text);
1273 if(NS_FAILED(nsres) || !nsnode)
1275 ERR("CreateTextNode failed: %08x\n", nsres);
1279 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1280 nsIDOMNode_Release(nsnode);
1285 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1287 HTMLElement *This = impl_from_IHTMLElement(iface);
1288 FIXME("(%p)->(%p)\n", This, p);
1292 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1294 HTMLElement *This = impl_from_IHTMLElement(iface);
1295 FIXME("(%p)->(%p)\n", This, p);
1299 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1301 HTMLElement *This = impl_from_IHTMLElement(iface);
1303 TRACE("(%p)\n", This);
1305 return call_event(&This->node, EVENTID_CLICK);
1308 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1309 IHTMLFiltersCollection **p)
1311 HTMLElement *This = impl_from_IHTMLElement(iface);
1312 TRACE("(%p)->(%p)\n", This, p);
1317 *p = HTMLFiltersCollection_Create();
1322 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1324 HTMLElement *This = impl_from_IHTMLElement(iface);
1325 FIXME("(%p)->()\n", This);
1329 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1331 HTMLElement *This = impl_from_IHTMLElement(iface);
1332 FIXME("(%p)->(%p)\n", This, p);
1336 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1338 HTMLElement *This = impl_from_IHTMLElement(iface);
1339 FIXME("(%p)->(%p)\n", This, String);
1343 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1345 HTMLElement *This = impl_from_IHTMLElement(iface);
1346 FIXME("(%p)->()\n", This);
1350 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1352 HTMLElement *This = impl_from_IHTMLElement(iface);
1353 FIXME("(%p)->(%p)\n", This, p);
1357 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1359 HTMLElement *This = impl_from_IHTMLElement(iface);
1360 FIXME("(%p)->()\n", This);
1364 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1366 HTMLElement *This = impl_from_IHTMLElement(iface);
1367 FIXME("(%p)->(%p)\n", This, p);
1371 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1373 HTMLElement *This = impl_from_IHTMLElement(iface);
1374 FIXME("(%p)->()\n", This);
1378 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1380 HTMLElement *This = impl_from_IHTMLElement(iface);
1381 FIXME("(%p)->(%p)\n", This, p);
1385 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1387 HTMLElement *This = impl_from_IHTMLElement(iface);
1388 FIXME("(%p)->()\n", This);
1392 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1394 HTMLElement *This = impl_from_IHTMLElement(iface);
1395 FIXME("(%p)->(%p)\n", This, p);
1399 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1401 HTMLElement *This = impl_from_IHTMLElement(iface);
1402 FIXME("(%p)->()\n", This);
1406 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1408 HTMLElement *This = impl_from_IHTMLElement(iface);
1409 FIXME("(%p)->(%p)\n", This, p);
1413 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1415 HTMLElement *This = impl_from_IHTMLElement(iface);
1416 FIXME("(%p)->()\n", This);
1420 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1422 HTMLElement *This = impl_from_IHTMLElement(iface);
1423 FIXME("(%p)->(%p)\n", This, p);
1427 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1429 HTMLElement *This = impl_from_IHTMLElement(iface);
1430 FIXME("(%p)->()\n", This);
1434 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1436 HTMLElement *This = impl_from_IHTMLElement(iface);
1437 FIXME("(%p)->(%p)\n", This, p);
1441 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1443 HTMLElement *This = impl_from_IHTMLElement(iface);
1444 FIXME("(%p)->()\n", This);
1448 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1450 HTMLElement *This = impl_from_IHTMLElement(iface);
1451 FIXME("(%p)->(%p)\n", This, p);
1455 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1457 HTMLElement *This = impl_from_IHTMLElement(iface);
1458 FIXME("(%p)->()\n", This);
1462 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1464 HTMLElement *This = impl_from_IHTMLElement(iface);
1465 FIXME("(%p)->(%p)\n", This, p);
1469 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1471 HTMLElement *This = impl_from_IHTMLElement(iface);
1472 nsIDOMNodeList *nsnode_list;
1475 TRACE("(%p)->(%p)\n", This, p);
1477 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1478 if(NS_FAILED(nsres)) {
1479 ERR("GetChildNodes failed: %08x\n", nsres);
1483 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
1484 (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
1486 nsIDOMNodeList_Release(nsnode_list);
1490 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1492 HTMLElement *This = impl_from_IHTMLElement(iface);
1494 TRACE("(%p)->(%p)\n", This, p);
1496 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1500 static const IHTMLElementVtbl HTMLElementVtbl = {
1501 HTMLElement_QueryInterface,
1503 HTMLElement_Release,
1504 HTMLElement_GetTypeInfoCount,
1505 HTMLElement_GetTypeInfo,
1506 HTMLElement_GetIDsOfNames,
1508 HTMLElement_setAttribute,
1509 HTMLElement_getAttribute,
1510 HTMLElement_removeAttribute,
1511 HTMLElement_put_className,
1512 HTMLElement_get_className,
1515 HTMLElement_get_tagName,
1516 HTMLElement_get_parentElement,
1517 HTMLElement_get_style,
1518 HTMLElement_put_onhelp,
1519 HTMLElement_get_onhelp,
1520 HTMLElement_put_onclick,
1521 HTMLElement_get_onclick,
1522 HTMLElement_put_ondblclick,
1523 HTMLElement_get_ondblclick,
1524 HTMLElement_put_onkeydown,
1525 HTMLElement_get_onkeydown,
1526 HTMLElement_put_onkeyup,
1527 HTMLElement_get_onkeyup,
1528 HTMLElement_put_onkeypress,
1529 HTMLElement_get_onkeypress,
1530 HTMLElement_put_onmouseout,
1531 HTMLElement_get_onmouseout,
1532 HTMLElement_put_onmouseover,
1533 HTMLElement_get_onmouseover,
1534 HTMLElement_put_onmousemove,
1535 HTMLElement_get_onmousemove,
1536 HTMLElement_put_onmousedown,
1537 HTMLElement_get_onmousedown,
1538 HTMLElement_put_onmouseup,
1539 HTMLElement_get_onmouseup,
1540 HTMLElement_get_document,
1541 HTMLElement_put_title,
1542 HTMLElement_get_title,
1543 HTMLElement_put_language,
1544 HTMLElement_get_language,
1545 HTMLElement_put_onselectstart,
1546 HTMLElement_get_onselectstart,
1547 HTMLElement_scrollIntoView,
1548 HTMLElement_contains,
1549 HTMLElement_get_sourceIndex,
1550 HTMLElement_get_recordNumber,
1551 HTMLElement_put_lang,
1552 HTMLElement_get_lang,
1553 HTMLElement_get_offsetLeft,
1554 HTMLElement_get_offsetTop,
1555 HTMLElement_get_offsetWidth,
1556 HTMLElement_get_offsetHeight,
1557 HTMLElement_get_offsetParent,
1558 HTMLElement_put_innerHTML,
1559 HTMLElement_get_innerHTML,
1560 HTMLElement_put_innerText,
1561 HTMLElement_get_innerText,
1562 HTMLElement_put_outerHTML,
1563 HTMLElement_get_outerHTML,
1564 HTMLElement_put_outerText,
1565 HTMLElement_get_outerText,
1566 HTMLElement_insertAdjacentHTML,
1567 HTMLElement_insertAdjacentText,
1568 HTMLElement_get_parentTextEdit,
1569 HTMLElement_get_isTextEdit,
1571 HTMLElement_get_filters,
1572 HTMLElement_put_ondragstart,
1573 HTMLElement_get_ondragstart,
1574 HTMLElement_toString,
1575 HTMLElement_put_onbeforeupdate,
1576 HTMLElement_get_onbeforeupdate,
1577 HTMLElement_put_onafterupdate,
1578 HTMLElement_get_onafterupdate,
1579 HTMLElement_put_onerrorupdate,
1580 HTMLElement_get_onerrorupdate,
1581 HTMLElement_put_onrowexit,
1582 HTMLElement_get_onrowexit,
1583 HTMLElement_put_onrowenter,
1584 HTMLElement_get_onrowenter,
1585 HTMLElement_put_ondatasetchanged,
1586 HTMLElement_get_ondatasetchanged,
1587 HTMLElement_put_ondataavailable,
1588 HTMLElement_get_ondataavailable,
1589 HTMLElement_put_ondatasetcomplete,
1590 HTMLElement_get_ondatasetcomplete,
1591 HTMLElement_put_onfilterchange,
1592 HTMLElement_get_onfilterchange,
1593 HTMLElement_get_children,
1597 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1599 return CONTAINING_RECORD(iface, HTMLElement, node);
1602 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1604 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1608 if(IsEqualGUID(&IID_IUnknown, riid)) {
1609 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1610 *ppv = &This->IHTMLElement_iface;
1611 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1612 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1613 *ppv = &This->IHTMLElement_iface;
1614 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1615 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1616 *ppv = &This->IHTMLElement_iface;
1617 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1618 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1619 *ppv = &This->IHTMLElement2_iface;
1620 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1621 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1622 *ppv = &This->IHTMLElement3_iface;
1623 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1624 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1625 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1629 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1633 return HTMLDOMNode_QI(&This->node, riid, ppv);
1636 void HTMLElement_destructor(HTMLDOMNode *iface)
1638 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1640 ConnectionPointContainer_Destroy(&This->cp_container);
1643 nsIDOMHTMLElement_Release(This->nselem);
1645 HTMLDOMNode_destructor(&This->node);
1648 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1650 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1651 HTMLElement *new_elem;
1654 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1658 IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
1659 *ret = &new_elem->node;
1663 static const NodeImplVtbl HTMLElementImplVtbl = {
1665 HTMLElement_destructor,
1669 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1671 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1674 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1675 DWORD grfdex, DISPID *pid)
1677 HTMLElement *This = impl_from_DispatchEx(dispex);
1679 if(This->node.vtbl->get_dispid)
1680 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1682 return DISP_E_UNKNOWNNAME;
1685 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1686 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1687 IServiceProvider *caller)
1689 HTMLElement *This = impl_from_DispatchEx(dispex);
1691 if(This->node.vtbl->invoke)
1692 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1693 params, res, ei, caller);
1695 ERR("(%p): element has no invoke method\n", This);
1699 static const tid_t HTMLElement_iface_tids[] = {
1704 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1706 HTMLElement_get_dispid,
1710 static dispex_static_data_t HTMLElement_dispex = {
1711 &HTMLElement_dispex_vtbl,
1712 DispHTMLUnknownElement_tid,
1714 HTMLElement_iface_tids
1717 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1719 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1721 HTMLElement2_Init(This);
1722 HTMLElement3_Init(This);
1724 if(dispex_data && !dispex_data->vtbl)
1725 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1726 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1727 dispex_data ? dispex_data : &HTMLElement_dispex);
1730 nsIDOMHTMLElement_AddRef(nselem);
1731 This->nselem = nselem;
1733 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1735 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1738 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1740 nsIDOMHTMLElement *nselem;
1741 nsAString class_name_str;
1742 const PRUnichar *class_name;
1743 const tag_desc_t *tag;
1748 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1749 if(NS_FAILED(nsres))
1752 nsAString_Init(&class_name_str, NULL);
1753 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1755 nsAString_GetData(&class_name_str, &class_name);
1757 tag = get_tag_desc(class_name);
1759 hres = tag->constructor(doc, nselem, &elem);
1760 }else if(use_generic) {
1761 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1763 elem = heap_alloc_zero(sizeof(HTMLElement));
1765 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1766 elem->node.vtbl = &HTMLElementImplVtbl;
1769 hres = E_OUTOFMEMORY;
1773 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1775 nsIDOMElement_Release(nselem);
1776 nsAString_Finish(&class_name_str);
1784 /* interface IHTMLFiltersCollection */
1785 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1787 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1789 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1791 if(IsEqualGUID(&IID_IUnknown, riid)) {
1792 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1793 *ppv = &This->IHTMLFiltersCollection_iface;
1794 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1795 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1796 *ppv = &This->IHTMLFiltersCollection_iface;
1797 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1798 return *ppv ? S_OK : E_NOINTERFACE;
1802 IUnknown_AddRef((IUnknown*)*ppv);
1806 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1807 return E_NOINTERFACE;
1810 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1812 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1813 LONG ref = InterlockedIncrement(&This->ref);
1815 TRACE("(%p) ref=%d\n", This, ref);
1820 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1822 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1823 LONG ref = InterlockedDecrement(&This->ref);
1825 TRACE("(%p) ref=%d\n", This, ref);
1835 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1837 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1838 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1841 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1842 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1844 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1845 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1848 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1849 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1850 LCID lcid, DISPID *rgDispId)
1852 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1853 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1857 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1858 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1859 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1861 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1862 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1863 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1866 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1868 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1873 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1879 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1881 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1882 FIXME("(%p)->(%p)\n", This, p);
1886 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1888 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1889 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1893 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1894 HTMLFiltersCollection_QueryInterface,
1895 HTMLFiltersCollection_AddRef,
1896 HTMLFiltersCollection_Release,
1897 HTMLFiltersCollection_GetTypeInfoCount,
1898 HTMLFiltersCollection_GetTypeInfo,
1899 HTMLFiltersCollection_GetIDsOfNames,
1900 HTMLFiltersCollection_Invoke,
1901 HTMLFiltersCollection_get_length,
1902 HTMLFiltersCollection_get__newEnum,
1903 HTMLFiltersCollection_item
1906 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1911 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1912 idx = idx*10 + (*ptr-'0');
1914 return DISP_E_UNKNOWNNAME;
1916 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1917 TRACE("ret %x\n", *dispid);
1921 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1922 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1924 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
1926 V_VT(res) = VT_DISPATCH;
1927 V_DISPATCH(res) = NULL;
1929 FIXME("always returning NULL\n");
1934 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
1936 HTMLFiltersCollection_get_dispid,
1937 HTMLFiltersCollection_invoke
1940 static const tid_t HTMLFiltersCollection_iface_tids[] = {
1941 IHTMLFiltersCollection_tid,
1944 static dispex_static_data_t HTMLFiltersCollection_dispex = {
1945 &HTMLFiltersCollection_dispex_vtbl,
1946 IHTMLFiltersCollection_tid,
1948 HTMLFiltersCollection_iface_tids
1951 IHTMLFiltersCollection *HTMLFiltersCollection_Create()
1953 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
1955 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
1958 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
1959 &HTMLFiltersCollection_dispex);
1961 return &ret->IHTMLFiltersCollection_iface;