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"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
35 #include "htmlstyle.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 static const WCHAR aW[] = {'A',0};
40 static const WCHAR bodyW[] = {'B','O','D','Y',0};
41 static const WCHAR embedW[] = {'E','M','B','E','D',0};
42 static const WCHAR formW[] = {'F','O','R','M',0};
43 static const WCHAR frameW[] = {'F','R','A','M','E',0};
44 static const WCHAR headW[] = {'H','E','A','D',0};
45 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
46 static const WCHAR imgW[] = {'I','M','G',0};
47 static const WCHAR inputW[] = {'I','N','P','U','T',0};
48 static const WCHAR metaW[] = {'M','E','T','A',0};
49 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
50 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
51 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
52 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
53 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
54 static const WCHAR tableW[] = {'T','A','B','L','E',0};
55 static const WCHAR tdW[] = {'T','D',0};
56 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
57 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
58 static const WCHAR trW[] = {'T','R',0};
62 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
65 static const tag_desc_t tag_descs[] = {
66 {aW, HTMLAnchorElement_Create},
67 {bodyW, HTMLBodyElement_Create},
68 {embedW, HTMLEmbedElement_Create},
69 {formW, HTMLFormElement_Create},
70 {frameW, HTMLFrameElement_Create},
71 {headW, HTMLHeadElement_Create},
72 {iframeW, HTMLIFrame_Create},
73 {imgW, HTMLImgElement_Create},
74 {inputW, HTMLInputElement_Create},
75 {metaW, HTMLMetaElement_Create},
76 {objectW, HTMLObjectElement_Create},
77 {optionW, HTMLOptionElement_Create},
78 {scriptW, HTMLScriptElement_Create},
79 {selectW, HTMLSelectElement_Create},
80 {styleW, HTMLStyleElement_Create},
81 {tableW, HTMLTable_Create},
82 {tdW, HTMLTableCell_Create},
83 {textareaW, HTMLTextAreaElement_Create},
84 {title_tagW, HTMLTitleElement_Create},
85 {trW, HTMLTableRow_Create}
88 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
90 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
95 r = strcmpW(tag_name, tag_descs[i].name);
108 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
110 nsIDOMDocumentFragment *nsfragment;
111 nsIDOMNSRange *nsrange;
112 nsIDOMNode *nsparent;
118 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
119 if(NS_FAILED(nsres)) {
120 ERR("CreateRange failed: %08x\n", nsres);
124 nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
125 nsIDOMRange_Release(range);
126 if(NS_FAILED(nsres)) {
127 ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
131 nsAString_InitDepend(&html_str, html);
132 nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
133 nsIDOMNSRange_Release(nsrange);
134 nsAString_Finish(&html_str);
135 if(NS_FAILED(nsres)) {
136 ERR("CreateContextualFragment failed: %08x\n", nsres);
140 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
141 if(NS_SUCCEEDED(nsres) && nsparent) {
144 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
145 nsIDOMNode_Release(nsparent);
146 if(NS_FAILED(nsres)) {
147 ERR("ReplaceChild failed: %08x\n", nsres);
150 nsIDOMNode_Release(nstmp);
153 ERR("GetParentNode failed: %08x\n", nsres);
157 nsIDOMDocumentFragment_Release(nsfragment);
164 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
167 } HTMLFiltersCollection;
169 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
171 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
174 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
176 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
178 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
181 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
183 nsIDOMElement *nselem;
188 WARN("NULL nsdoc\n");
192 nsAString_InitDepend(&tag_str, tag);
193 nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
194 nsAString_Finish(&tag_str);
195 if(NS_FAILED(nsres)) {
196 ERR("CreateElement failed: %08x\n", nsres);
200 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
201 nsIDOMElement_Release(nselem);
202 if(NS_FAILED(nsres)) {
203 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
210 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
211 REFIID riid, void **ppv)
213 HTMLElement *This = impl_from_IHTMLElement(iface);
215 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
218 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
220 HTMLElement *This = impl_from_IHTMLElement(iface);
222 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
225 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
227 HTMLElement *This = impl_from_IHTMLElement(iface);
229 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
232 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
234 HTMLElement *This = impl_from_IHTMLElement(iface);
235 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
238 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
239 LCID lcid, ITypeInfo **ppTInfo)
241 HTMLElement *This = impl_from_IHTMLElement(iface);
242 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
245 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
246 LPOLESTR *rgszNames, UINT cNames,
247 LCID lcid, DISPID *rgDispId)
249 HTMLElement *This = impl_from_IHTMLElement(iface);
250 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
254 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
255 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
256 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
258 HTMLElement *This = impl_from_IHTMLElement(iface);
259 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
260 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
263 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
264 VARIANT AttributeValue, LONG lFlags)
266 HTMLElement *This = impl_from_IHTMLElement(iface);
268 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
269 DISPPARAMS dispParams;
272 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
274 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
275 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
279 dispParams.cArgs = 1;
280 dispParams.cNamedArgs = 1;
281 dispParams.rgdispidNamedArgs = &dispidNamed;
282 dispParams.rgvarg = &AttributeValue;
284 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
285 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
289 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
290 LONG lFlags, VARIANT *AttributeValue)
292 HTMLElement *This = impl_from_IHTMLElement(iface);
295 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
298 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
300 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
301 fdexNameCaseInsensitive, &dispid);
302 if(hres == DISP_E_UNKNOWNNAME) {
303 V_VT(AttributeValue) = VT_NULL;
308 V_VT(AttributeValue) = VT_NULL;
312 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
313 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
318 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
319 LONG lFlags, VARIANT_BOOL *pfSuccess)
321 HTMLElement *This = impl_from_IHTMLElement(iface);
323 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
325 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
328 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
330 HTMLElement *This = impl_from_IHTMLElement(iface);
331 nsAString classname_str;
334 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
337 FIXME("NULL nselem\n");
341 nsAString_InitDepend(&classname_str, v);
342 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
343 nsAString_Finish(&classname_str);
345 ERR("SetClassName failed: %08x\n", nsres);
350 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
352 HTMLElement *This = impl_from_IHTMLElement(iface);
356 TRACE("(%p)->(%p)\n", This, p);
359 FIXME("NULL nselem\n");
363 nsAString_Init(&class_str, NULL);
364 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
365 return return_nsstr(nsres, &class_str, p);
368 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
370 HTMLElement *This = impl_from_IHTMLElement(iface);
374 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
377 FIXME("nselem == NULL\n");
381 nsAString_InitDepend(&id_str, v);
382 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
383 nsAString_Finish(&id_str);
385 ERR("SetId failed: %08x\n", nsres);
390 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
392 HTMLElement *This = impl_from_IHTMLElement(iface);
396 TRACE("(%p)->(%p)\n", This, p);
403 nsAString_Init(&id_str, NULL);
404 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
405 return return_nsstr(nsres, &id_str, p);
408 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
410 HTMLElement *This = impl_from_IHTMLElement(iface);
414 TRACE("(%p)->(%p)\n", This, p);
417 static const WCHAR comment_tagW[] = {'!',0};
419 WARN("NULL nselem, assuming comment\n");
421 *p = SysAllocString(comment_tagW);
422 return *p ? S_OK : E_OUTOFMEMORY;
425 nsAString_Init(&tag_str, NULL);
426 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
427 return return_nsstr(nsres, &tag_str, p);
430 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
432 HTMLElement *This = impl_from_IHTMLElement(iface);
436 TRACE("(%p)->(%p)\n", This, p);
438 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
442 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
443 IHTMLDOMNode_Release(node);
450 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
452 HTMLElement *This = impl_from_IHTMLElement(iface);
454 TRACE("(%p)->(%p)\n", This, p);
457 nsIDOMElementCSSInlineStyle *nselemstyle;
458 nsIDOMCSSStyleDeclaration *nsstyle;
463 FIXME("NULL nselem\n");
467 nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
468 (void**)&nselemstyle);
469 if(NS_FAILED(nsres)) {
470 ERR("Could not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres);
474 nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle);
475 nsIDOMElementCSSInlineStyle_Release(nselemstyle);
476 if(NS_FAILED(nsres)) {
477 ERR("GetStyle failed: %08x\n", nsres);
481 hres = HTMLStyle_Create(This, nsstyle, &This->style);
482 nsIDOMCSSStyleDeclaration_Release(nsstyle);
487 *p = &This->style->IHTMLStyle_iface;
488 IHTMLStyle_AddRef(*p);
492 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
494 HTMLElement *This = impl_from_IHTMLElement(iface);
495 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
499 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
501 HTMLElement *This = impl_from_IHTMLElement(iface);
502 FIXME("(%p)->(%p)\n", This, p);
506 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
508 HTMLElement *This = impl_from_IHTMLElement(iface);
510 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
512 return set_node_event(&This->node, EVENTID_CLICK, &v);
515 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
517 HTMLElement *This = impl_from_IHTMLElement(iface);
519 TRACE("(%p)->(%p)\n", This, p);
521 return get_node_event(&This->node, EVENTID_CLICK, p);
524 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
526 HTMLElement *This = impl_from_IHTMLElement(iface);
528 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
530 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
533 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
535 HTMLElement *This = impl_from_IHTMLElement(iface);
537 TRACE("(%p)->(%p)\n", This, p);
539 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
542 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
544 HTMLElement *This = impl_from_IHTMLElement(iface);
546 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
548 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
551 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
553 HTMLElement *This = impl_from_IHTMLElement(iface);
555 TRACE("(%p)->(%p)\n", This, p);
557 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
560 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
562 HTMLElement *This = impl_from_IHTMLElement(iface);
564 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
566 return set_node_event(&This->node, EVENTID_KEYUP, &v);
569 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
571 HTMLElement *This = impl_from_IHTMLElement(iface);
572 FIXME("(%p)->(%p)\n", This, p);
576 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
578 HTMLElement *This = impl_from_IHTMLElement(iface);
579 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
583 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
585 HTMLElement *This = impl_from_IHTMLElement(iface);
586 FIXME("(%p)->(%p)\n", This, p);
590 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
592 HTMLElement *This = impl_from_IHTMLElement(iface);
594 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
596 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
599 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
601 HTMLElement *This = impl_from_IHTMLElement(iface);
603 TRACE("(%p)->(%p)\n", This, p);
605 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
608 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
610 HTMLElement *This = impl_from_IHTMLElement(iface);
612 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
614 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
617 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
619 HTMLElement *This = impl_from_IHTMLElement(iface);
621 TRACE("(%p)->(%p)\n", This, p);
623 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
626 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
628 HTMLElement *This = impl_from_IHTMLElement(iface);
630 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
632 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
635 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
637 HTMLElement *This = impl_from_IHTMLElement(iface);
639 TRACE("(%p)->(%p)\n", This, p);
641 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
644 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
646 HTMLElement *This = impl_from_IHTMLElement(iface);
648 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
650 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
653 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
655 HTMLElement *This = impl_from_IHTMLElement(iface);
657 TRACE("(%p)->(%p)\n", This, p);
659 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
662 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
664 HTMLElement *This = impl_from_IHTMLElement(iface);
666 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
668 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
671 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
673 HTMLElement *This = impl_from_IHTMLElement(iface);
675 TRACE("(%p)->(%p)\n", This, p);
677 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
680 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
682 HTMLElement *This = impl_from_IHTMLElement(iface);
684 TRACE("(%p)->(%p)\n", This, p);
689 if(This->node.vtbl->get_document)
690 return This->node.vtbl->get_document(&This->node, p);
692 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
693 IDispatch_AddRef(*p);
697 static const WCHAR titleW[] = {'t','i','t','l','e',0};
699 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
701 HTMLElement *This = impl_from_IHTMLElement(iface);
705 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
711 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
717 V_BSTR(var) = v ? SysAllocString(v) : NULL;
721 nsAString_InitDepend(&title_str, v);
722 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
723 nsAString_Finish(&title_str);
725 ERR("SetTitle failed: %08x\n", nsres);
730 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
732 HTMLElement *This = impl_from_IHTMLElement(iface);
736 TRACE("(%p)->(%p)\n", This, p);
742 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
743 if(hres == DISP_E_UNKNOWNNAME) {
745 }else if(V_VT(var) != VT_BSTR) {
746 FIXME("title = %s\n", debugstr_variant(var));
749 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
755 nsAString_Init(&title_str, NULL);
756 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
757 return return_nsstr(nsres, &title_str, p);
760 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
762 HTMLElement *This = impl_from_IHTMLElement(iface);
763 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
767 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
769 HTMLElement *This = impl_from_IHTMLElement(iface);
770 FIXME("(%p)->(%p)\n", This, p);
774 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
776 HTMLElement *This = impl_from_IHTMLElement(iface);
778 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
780 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
783 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
785 HTMLElement *This = impl_from_IHTMLElement(iface);
787 TRACE("(%p)->(%p)\n", This, p);
789 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
792 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
794 HTMLElement *This = impl_from_IHTMLElement(iface);
795 FIXME("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
799 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
800 VARIANT_BOOL *pfResult)
802 HTMLElement *This = impl_from_IHTMLElement(iface);
803 FIXME("(%p)->(%p %p)\n", This, pChild, pfResult);
807 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
809 HTMLElement *This = impl_from_IHTMLElement(iface);
810 FIXME("(%p)->(%p)\n", This, p);
814 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
816 HTMLElement *This = impl_from_IHTMLElement(iface);
817 FIXME("(%p)->(%p)\n", This, p);
821 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
823 HTMLElement *This = impl_from_IHTMLElement(iface);
824 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
828 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
830 HTMLElement *This = impl_from_IHTMLElement(iface);
831 FIXME("(%p)->(%p)\n", This, p);
835 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
837 HTMLElement *This = impl_from_IHTMLElement(iface);
838 PRInt32 off_left = 0;
841 TRACE("(%p)->(%p)\n", This, p);
843 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, &off_left);
844 if(NS_FAILED(nsres)) {
845 ERR("GetOffsetLeft failed: %08x\n", nsres);
853 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
855 HTMLElement *This = impl_from_IHTMLElement(iface);
859 TRACE("(%p)->(%p)\n", This, p);
861 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, &top);
862 if(NS_FAILED(nsres)) {
863 ERR("GetOffsetTop failed: %08x\n", nsres);
871 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
873 HTMLElement *This = impl_from_IHTMLElement(iface);
877 TRACE("(%p)->(%p)\n", This, p);
879 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, &offset);
880 if(NS_FAILED(nsres)) {
881 ERR("GetOffsetWidth failed: %08x\n", nsres);
889 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
891 HTMLElement *This = impl_from_IHTMLElement(iface);
895 TRACE("(%p)->(%p)\n", This, p);
897 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, &offset);
898 if(NS_FAILED(nsres)) {
899 ERR("GetOffsetHeight failed: %08x\n", nsres);
907 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
909 HTMLElement *This = impl_from_IHTMLElement(iface);
910 nsIDOMElement *nsparent;
914 TRACE("(%p)->(%p)\n", This, p);
916 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
917 if(NS_FAILED(nsres)) {
918 ERR("GetOffsetParent failed: %08x\n", nsres);
925 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
926 nsIDOMElement_Release(nsparent);
930 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
939 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
941 HTMLElement *This = impl_from_IHTMLElement(iface);
945 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
948 FIXME("NULL nselem\n");
952 nsAString_InitDepend(&html_str, v);
953 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
954 nsAString_Finish(&html_str);
955 if(NS_FAILED(nsres)) {
956 FIXME("SetInnerHtml failed %08x\n", nsres);
963 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
965 HTMLElement *This = impl_from_IHTMLElement(iface);
969 TRACE("(%p)->(%p)\n", This, p);
972 FIXME("NULL nselem\n");
976 nsAString_Init(&html_str, NULL);
977 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
978 return return_nsstr(nsres, &html_str, p);
981 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
983 HTMLElement *This = impl_from_IHTMLElement(iface);
984 nsIDOMNode *nschild, *tmp;
985 nsIDOMText *text_node;
989 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
992 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
993 if(NS_FAILED(nsres)) {
994 ERR("GetLastChild failed: %08x\n", nsres);
1000 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1001 nsIDOMNode_Release(nschild);
1002 if(NS_FAILED(nsres)) {
1003 ERR("RemoveChild failed: %08x\n", nsres);
1006 nsIDOMNode_Release(tmp);
1009 nsAString_InitDepend(&text_str, v);
1010 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1011 nsAString_Finish(&text_str);
1012 if(NS_FAILED(nsres)) {
1013 ERR("CreateTextNode failed: %08x\n", nsres);
1017 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1018 if(NS_FAILED(nsres)) {
1019 ERR("AppendChild failed: %08x\n", nsres);
1023 nsIDOMNode_Release(tmp);
1027 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1029 HTMLElement *This = impl_from_IHTMLElement(iface);
1031 TRACE("(%p)->(%p)\n", This, p);
1033 return get_node_text(&This->node, p);
1036 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1038 HTMLElement *This = impl_from_IHTMLElement(iface);
1040 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1042 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1045 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1047 HTMLElement *This = impl_from_IHTMLElement(iface);
1051 WARN("(%p)->(%p) semi-stub\n", This, p);
1053 nsAString_Init(&html_str, NULL);
1054 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1055 if(SUCCEEDED(hres)) {
1056 const PRUnichar *html;
1058 nsAString_GetData(&html_str, &html);
1059 *p = SysAllocString(html);
1061 hres = E_OUTOFMEMORY;
1064 nsAString_Finish(&html_str);
1066 TRACE("ret %s\n", debugstr_w(*p));
1070 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1072 HTMLElement *This = impl_from_IHTMLElement(iface);
1073 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1077 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1079 HTMLElement *This = impl_from_IHTMLElement(iface);
1080 FIXME("(%p)->(%p)\n", This, p);
1084 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1086 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1087 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1088 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1089 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1092 if (!strcmpiW(where, wszBeforeBegin))
1096 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1097 if (!parent) return E_INVALIDARG;
1098 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1099 if (unused) nsIDOMNode_Release(unused);
1100 nsIDOMNode_Release(parent);
1102 else if (!strcmpiW(where, wszAfterBegin))
1105 nsIDOMNode *first_child;
1106 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1107 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1108 if (unused) nsIDOMNode_Release(unused);
1109 if (first_child) nsIDOMNode_Release(first_child);
1111 else if (!strcmpiW(where, wszBeforeEnd))
1114 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1115 if (unused) nsIDOMNode_Release(unused);
1117 else if (!strcmpiW(where, wszAfterEnd))
1120 nsIDOMNode *next_sibling;
1122 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1123 if (!parent) return E_INVALIDARG;
1125 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1128 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1129 nsIDOMNode_Release(next_sibling);
1132 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1133 nsIDOMNode_Release(parent);
1134 if (unused) nsIDOMNode_Release(unused);
1138 ERR("invalid where: %s\n", debugstr_w(where));
1139 return E_INVALIDARG;
1142 if (NS_FAILED(nsres))
1148 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1151 HTMLElement *This = impl_from_IHTMLElement(iface);
1153 nsIDOMNSRange *nsrange;
1159 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1161 if(!This->node.doc->nsdoc) {
1162 WARN("NULL nsdoc\n");
1163 return E_UNEXPECTED;
1166 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1167 if(NS_FAILED(nsres))
1169 ERR("CreateRange failed: %08x\n", nsres);
1173 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1175 nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
1176 nsIDOMRange_Release(range);
1177 if(NS_FAILED(nsres))
1179 ERR("getting nsIDOMNSRange failed: %08x\n", nsres);
1183 nsAString_InitDepend(&ns_html, html);
1185 nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1186 nsIDOMNSRange_Release(nsrange);
1187 nsAString_Finish(&ns_html);
1189 if(NS_FAILED(nsres) || !nsnode)
1191 ERR("CreateTextNode failed: %08x\n", nsres);
1195 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1196 nsIDOMNode_Release(nsnode);
1201 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1204 HTMLElement *This = impl_from_IHTMLElement(iface);
1210 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1212 if(!This->node.doc->nsdoc) {
1213 WARN("NULL nsdoc\n");
1214 return E_UNEXPECTED;
1218 nsAString_InitDepend(&ns_text, text);
1219 nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1220 nsAString_Finish(&ns_text);
1222 if(NS_FAILED(nsres) || !nsnode)
1224 ERR("CreateTextNode failed: %08x\n", nsres);
1228 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1229 nsIDOMNode_Release(nsnode);
1234 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1236 HTMLElement *This = impl_from_IHTMLElement(iface);
1237 FIXME("(%p)->(%p)\n", This, p);
1241 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1243 HTMLElement *This = impl_from_IHTMLElement(iface);
1244 FIXME("(%p)->(%p)\n", This, p);
1248 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1250 HTMLElement *This = impl_from_IHTMLElement(iface);
1252 TRACE("(%p)\n", This);
1254 return call_fire_event(&This->node, EVENTID_CLICK);
1257 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1258 IHTMLFiltersCollection **p)
1260 HTMLElement *This = impl_from_IHTMLElement(iface);
1261 TRACE("(%p)->(%p)\n", This, p);
1266 *p = HTMLFiltersCollection_Create();
1271 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1273 HTMLElement *This = impl_from_IHTMLElement(iface);
1274 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1278 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1280 HTMLElement *This = impl_from_IHTMLElement(iface);
1281 FIXME("(%p)->(%p)\n", This, p);
1285 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1287 HTMLElement *This = impl_from_IHTMLElement(iface);
1288 FIXME("(%p)->(%p)\n", This, String);
1292 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1294 HTMLElement *This = impl_from_IHTMLElement(iface);
1295 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1299 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1301 HTMLElement *This = impl_from_IHTMLElement(iface);
1302 FIXME("(%p)->(%p)\n", This, p);
1306 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1308 HTMLElement *This = impl_from_IHTMLElement(iface);
1309 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1313 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1315 HTMLElement *This = impl_from_IHTMLElement(iface);
1316 FIXME("(%p)->(%p)\n", This, p);
1320 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1322 HTMLElement *This = impl_from_IHTMLElement(iface);
1323 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1327 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1329 HTMLElement *This = impl_from_IHTMLElement(iface);
1330 FIXME("(%p)->(%p)\n", This, p);
1334 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1336 HTMLElement *This = impl_from_IHTMLElement(iface);
1337 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1341 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1343 HTMLElement *This = impl_from_IHTMLElement(iface);
1344 FIXME("(%p)->(%p)\n", This, p);
1348 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1350 HTMLElement *This = impl_from_IHTMLElement(iface);
1351 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1355 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1357 HTMLElement *This = impl_from_IHTMLElement(iface);
1358 FIXME("(%p)->(%p)\n", This, p);
1362 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1364 HTMLElement *This = impl_from_IHTMLElement(iface);
1365 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1369 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1371 HTMLElement *This = impl_from_IHTMLElement(iface);
1372 FIXME("(%p)->(%p)\n", This, p);
1376 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1378 HTMLElement *This = impl_from_IHTMLElement(iface);
1379 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1383 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1385 HTMLElement *This = impl_from_IHTMLElement(iface);
1386 FIXME("(%p)->(%p)\n", This, p);
1390 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1392 HTMLElement *This = impl_from_IHTMLElement(iface);
1393 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1397 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1399 HTMLElement *This = impl_from_IHTMLElement(iface);
1400 FIXME("(%p)->(%p)\n", This, p);
1404 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1406 HTMLElement *This = impl_from_IHTMLElement(iface);
1407 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1411 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1413 HTMLElement *This = impl_from_IHTMLElement(iface);
1414 FIXME("(%p)->(%p)\n", This, p);
1418 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1420 HTMLElement *This = impl_from_IHTMLElement(iface);
1421 nsIDOMNodeList *nsnode_list;
1424 TRACE("(%p)->(%p)\n", This, p);
1426 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1427 if(NS_FAILED(nsres)) {
1428 ERR("GetChildNodes failed: %08x\n", nsres);
1432 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
1433 (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
1435 nsIDOMNodeList_Release(nsnode_list);
1439 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1441 HTMLElement *This = impl_from_IHTMLElement(iface);
1443 TRACE("(%p)->(%p)\n", This, p);
1445 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1449 static const IHTMLElementVtbl HTMLElementVtbl = {
1450 HTMLElement_QueryInterface,
1452 HTMLElement_Release,
1453 HTMLElement_GetTypeInfoCount,
1454 HTMLElement_GetTypeInfo,
1455 HTMLElement_GetIDsOfNames,
1457 HTMLElement_setAttribute,
1458 HTMLElement_getAttribute,
1459 HTMLElement_removeAttribute,
1460 HTMLElement_put_className,
1461 HTMLElement_get_className,
1464 HTMLElement_get_tagName,
1465 HTMLElement_get_parentElement,
1466 HTMLElement_get_style,
1467 HTMLElement_put_onhelp,
1468 HTMLElement_get_onhelp,
1469 HTMLElement_put_onclick,
1470 HTMLElement_get_onclick,
1471 HTMLElement_put_ondblclick,
1472 HTMLElement_get_ondblclick,
1473 HTMLElement_put_onkeydown,
1474 HTMLElement_get_onkeydown,
1475 HTMLElement_put_onkeyup,
1476 HTMLElement_get_onkeyup,
1477 HTMLElement_put_onkeypress,
1478 HTMLElement_get_onkeypress,
1479 HTMLElement_put_onmouseout,
1480 HTMLElement_get_onmouseout,
1481 HTMLElement_put_onmouseover,
1482 HTMLElement_get_onmouseover,
1483 HTMLElement_put_onmousemove,
1484 HTMLElement_get_onmousemove,
1485 HTMLElement_put_onmousedown,
1486 HTMLElement_get_onmousedown,
1487 HTMLElement_put_onmouseup,
1488 HTMLElement_get_onmouseup,
1489 HTMLElement_get_document,
1490 HTMLElement_put_title,
1491 HTMLElement_get_title,
1492 HTMLElement_put_language,
1493 HTMLElement_get_language,
1494 HTMLElement_put_onselectstart,
1495 HTMLElement_get_onselectstart,
1496 HTMLElement_scrollIntoView,
1497 HTMLElement_contains,
1498 HTMLElement_get_sourceIndex,
1499 HTMLElement_get_recordNumber,
1500 HTMLElement_put_lang,
1501 HTMLElement_get_lang,
1502 HTMLElement_get_offsetLeft,
1503 HTMLElement_get_offsetTop,
1504 HTMLElement_get_offsetWidth,
1505 HTMLElement_get_offsetHeight,
1506 HTMLElement_get_offsetParent,
1507 HTMLElement_put_innerHTML,
1508 HTMLElement_get_innerHTML,
1509 HTMLElement_put_innerText,
1510 HTMLElement_get_innerText,
1511 HTMLElement_put_outerHTML,
1512 HTMLElement_get_outerHTML,
1513 HTMLElement_put_outerText,
1514 HTMLElement_get_outerText,
1515 HTMLElement_insertAdjacentHTML,
1516 HTMLElement_insertAdjacentText,
1517 HTMLElement_get_parentTextEdit,
1518 HTMLElement_get_isTextEdit,
1520 HTMLElement_get_filters,
1521 HTMLElement_put_ondragstart,
1522 HTMLElement_get_ondragstart,
1523 HTMLElement_toString,
1524 HTMLElement_put_onbeforeupdate,
1525 HTMLElement_get_onbeforeupdate,
1526 HTMLElement_put_onafterupdate,
1527 HTMLElement_get_onafterupdate,
1528 HTMLElement_put_onerrorupdate,
1529 HTMLElement_get_onerrorupdate,
1530 HTMLElement_put_onrowexit,
1531 HTMLElement_get_onrowexit,
1532 HTMLElement_put_onrowenter,
1533 HTMLElement_get_onrowenter,
1534 HTMLElement_put_ondatasetchanged,
1535 HTMLElement_get_ondatasetchanged,
1536 HTMLElement_put_ondataavailable,
1537 HTMLElement_get_ondataavailable,
1538 HTMLElement_put_ondatasetcomplete,
1539 HTMLElement_get_ondatasetcomplete,
1540 HTMLElement_put_onfilterchange,
1541 HTMLElement_get_onfilterchange,
1542 HTMLElement_get_children,
1546 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1548 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1551 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1553 return CONTAINING_RECORD(iface, HTMLElement, node);
1556 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1558 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1562 if(IsEqualGUID(&IID_IUnknown, riid)) {
1563 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1564 *ppv = &This->IHTMLElement_iface;
1565 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1566 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1567 *ppv = &This->IHTMLElement_iface;
1568 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1569 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1570 *ppv = &This->IHTMLElement_iface;
1571 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1572 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1573 *ppv = &This->IHTMLElement2_iface;
1574 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1575 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1576 *ppv = &This->IHTMLElement3_iface;
1577 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1578 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1579 *ppv = &This->IHTMLElement4_iface;
1580 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1581 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1582 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1586 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1590 return HTMLDOMNode_QI(&This->node, riid, ppv);
1593 void HTMLElement_destructor(HTMLDOMNode *iface)
1595 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1597 ConnectionPointContainer_Destroy(&This->cp_container);
1600 nsIDOMHTMLElement_Release(This->nselem);
1602 This->style->elem = NULL;
1603 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1606 HTMLDOMAttribute *attr;
1608 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
1611 This->attrs->elem = NULL;
1612 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
1615 heap_free(This->filter);
1617 HTMLDOMNode_destructor(&This->node);
1620 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1622 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1623 HTMLElement *new_elem;
1626 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1631 new_elem->filter = heap_strdupW(This->filter);
1632 if(!new_elem->filter) {
1633 IHTMLElement_Release(&This->IHTMLElement_iface);
1634 return E_OUTOFMEMORY;
1638 IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
1639 *ret = &new_elem->node;
1643 static const NodeImplVtbl HTMLElementImplVtbl = {
1645 HTMLElement_destructor,
1647 HTMLElement_get_attr_col
1650 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1652 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1655 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1656 DWORD grfdex, DISPID *pid)
1658 HTMLElement *This = impl_from_DispatchEx(dispex);
1660 if(This->node.vtbl->get_dispid)
1661 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1663 return DISP_E_UNKNOWNNAME;
1666 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1667 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1668 IServiceProvider *caller)
1670 HTMLElement *This = impl_from_DispatchEx(dispex);
1672 if(This->node.vtbl->invoke)
1673 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1674 params, res, ei, caller);
1676 ERR("(%p): element has no invoke method\n", This);
1680 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
1682 HTMLElement *This = impl_from_DispatchEx(dispex);
1683 nsIDOMNamedNodeMap *attrs;
1686 const PRUnichar *str;
1698 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
1699 if(NS_FAILED(nsres))
1702 nsres = nsIDOMNamedNodeMap_GetLength(attrs, &len);
1703 if(NS_FAILED(nsres)) {
1704 nsIDOMNamedNodeMap_Release(attrs);
1708 nsAString_Init(&nsstr, NULL);
1709 for(i=0; i<len; i++) {
1710 nsres = nsIDOMNamedNodeMap_Item(attrs, i, &node);
1711 if(NS_FAILED(nsres))
1714 nsres = nsIDOMNode_GetNodeName(node, &nsstr);
1715 if(NS_FAILED(nsres)) {
1716 nsIDOMNode_Release(node);
1720 nsAString_GetData(&nsstr, &str);
1721 name = SysAllocString(str);
1723 nsIDOMNode_Release(node);
1727 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
1728 if(hres != DISP_E_UNKNOWNNAME) {
1729 nsIDOMNode_Release(node);
1730 SysFreeString(name);
1734 nsres = nsIDOMNode_GetNodeValue(node, &nsstr);
1735 nsIDOMNode_Release(node);
1736 if(NS_FAILED(nsres)) {
1737 SysFreeString(name);
1741 nsAString_GetData(&nsstr, &str);
1742 V_VT(&value) = VT_BSTR;
1744 V_BSTR(&value) = SysAllocString(str);
1745 if(!V_BSTR(&value)) {
1746 SysFreeString(name);
1750 V_BSTR(&value) = NULL;
1752 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
1753 SysFreeString(name);
1754 VariantClear(&value);
1756 nsAString_Finish(&nsstr);
1758 nsIDOMNamedNodeMap_Release(attrs);
1762 static const tid_t HTMLElement_iface_tids[] = {
1767 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1769 HTMLElement_get_dispid,
1771 HTMLElement_populate_props
1774 static dispex_static_data_t HTMLElement_dispex = {
1775 &HTMLElement_dispex_vtbl,
1776 DispHTMLUnknownElement_tid,
1778 HTMLElement_iface_tids
1781 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1783 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1785 HTMLElement2_Init(This);
1786 HTMLElement3_Init(This);
1788 if(dispex_data && !dispex_data->vtbl)
1789 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1790 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1791 dispex_data ? dispex_data : &HTMLElement_dispex);
1794 nsIDOMHTMLElement_AddRef(nselem);
1795 This->nselem = nselem;
1797 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1799 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1802 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1804 nsIDOMHTMLElement *nselem;
1805 nsAString class_name_str;
1806 const PRUnichar *class_name;
1807 const tag_desc_t *tag;
1812 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1813 if(NS_FAILED(nsres))
1816 nsAString_Init(&class_name_str, NULL);
1817 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1819 nsAString_GetData(&class_name_str, &class_name);
1821 tag = get_tag_desc(class_name);
1823 hres = tag->constructor(doc, nselem, &elem);
1824 }else if(use_generic) {
1825 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1827 elem = heap_alloc_zero(sizeof(HTMLElement));
1829 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1830 elem->node.vtbl = &HTMLElementImplVtbl;
1833 hres = E_OUTOFMEMORY;
1837 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1839 nsIDOMElement_Release(nselem);
1840 nsAString_Finish(&class_name_str);
1848 /* interface IHTMLFiltersCollection */
1849 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1851 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1853 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1855 if(IsEqualGUID(&IID_IUnknown, riid)) {
1856 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1857 *ppv = &This->IHTMLFiltersCollection_iface;
1858 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1859 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1860 *ppv = &This->IHTMLFiltersCollection_iface;
1861 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1862 return *ppv ? S_OK : E_NOINTERFACE;
1866 IUnknown_AddRef((IUnknown*)*ppv);
1870 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1871 return E_NOINTERFACE;
1874 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1876 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1877 LONG ref = InterlockedIncrement(&This->ref);
1879 TRACE("(%p) ref=%d\n", This, ref);
1884 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1886 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1887 LONG ref = InterlockedDecrement(&This->ref);
1889 TRACE("(%p) ref=%d\n", This, ref);
1899 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1901 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1902 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1905 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1906 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1908 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1909 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1912 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1913 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1914 LCID lcid, DISPID *rgDispId)
1916 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1917 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1921 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1922 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1923 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1925 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1926 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1927 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1930 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1932 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1937 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1943 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1945 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1946 FIXME("(%p)->(%p)\n", This, p);
1950 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1952 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1953 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1957 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1958 HTMLFiltersCollection_QueryInterface,
1959 HTMLFiltersCollection_AddRef,
1960 HTMLFiltersCollection_Release,
1961 HTMLFiltersCollection_GetTypeInfoCount,
1962 HTMLFiltersCollection_GetTypeInfo,
1963 HTMLFiltersCollection_GetIDsOfNames,
1964 HTMLFiltersCollection_Invoke,
1965 HTMLFiltersCollection_get_length,
1966 HTMLFiltersCollection_get__newEnum,
1967 HTMLFiltersCollection_item
1970 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1975 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1976 idx = idx*10 + (*ptr-'0');
1978 return DISP_E_UNKNOWNNAME;
1980 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1981 TRACE("ret %x\n", *dispid);
1985 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1986 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1988 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
1990 V_VT(res) = VT_DISPATCH;
1991 V_DISPATCH(res) = NULL;
1993 FIXME("always returning NULL\n");
1998 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
2000 HTMLFiltersCollection_get_dispid,
2001 HTMLFiltersCollection_invoke,
2005 static const tid_t HTMLFiltersCollection_iface_tids[] = {
2006 IHTMLFiltersCollection_tid,
2009 static dispex_static_data_t HTMLFiltersCollection_dispex = {
2010 &HTMLFiltersCollection_dispex_vtbl,
2011 IHTMLFiltersCollection_tid,
2013 HTMLFiltersCollection_iface_tids
2016 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
2018 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
2020 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2023 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2024 &HTMLFiltersCollection_dispex);
2026 return &ret->IHTMLFiltersCollection_iface;
2029 /* interface IHTMLAttributeCollection */
2030 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
2032 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
2035 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
2037 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2041 if(IsEqualGUID(&IID_IUnknown, riid)) {
2042 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
2043 *ppv = &This->IHTMLAttributeCollection_iface;
2044 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
2045 TRACE("(%p)->(IID_IHTMLAttributeCollection %p)\n", This, ppv);
2046 *ppv = &This->IHTMLAttributeCollection_iface;
2047 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
2048 TRACE("(%p)->(IID_IHTMLAttributeCollection2 %p)\n", This, ppv);
2049 *ppv = &This->IHTMLAttributeCollection2_iface;
2050 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
2051 TRACE("(%p)->(IID_IHTMLAttributeCollection3 %p)\n", This, ppv);
2052 *ppv = &This->IHTMLAttributeCollection3_iface;
2053 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2054 return *ppv ? S_OK : E_NOINTERFACE;
2058 IUnknown_AddRef((IUnknown*)*ppv);
2062 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2063 return E_NOINTERFACE;
2066 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
2068 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2069 LONG ref = InterlockedIncrement(&This->ref);
2071 TRACE("(%p) ref=%d\n", This, ref);
2076 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
2078 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2079 LONG ref = InterlockedDecrement(&This->ref);
2081 TRACE("(%p) ref=%d\n", This, ref);
2084 while(!list_empty(&This->attrs)) {
2085 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
2087 list_remove(&attr->entry);
2089 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2098 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
2100 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2101 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2104 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
2105 LCID lcid, ITypeInfo **ppTInfo)
2107 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2108 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2111 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
2112 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2114 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2115 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2119 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
2120 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2121 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2123 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2124 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2125 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2128 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
2130 IDispatchEx *dispex = &This->elem->node.dispex.IDispatchEx_iface;
2131 DISPID id = DISPID_STARTENUM;
2135 FIXME("filter non-enumerable attributes out\n");
2138 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
2141 else if(hres == S_FALSE)
2151 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
2158 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
2162 if(name[0]>='0' && name[0]<='9') {
2166 idx = strtoulW(name, &end_ptr, 10);
2168 hres = get_attr_dispid_by_idx(This, &idx, id);
2175 WARN("NULL elem\n");
2176 return E_UNEXPECTED;
2179 hres = IDispatchEx_GetDispID(&This->elem->node.dispex.IDispatchEx_iface,
2180 name, fdexNameCaseInsensitive, id);
2184 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
2186 HTMLDOMAttribute *iter;
2191 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2192 if(iter->dispid == id) {
2201 WARN("NULL elem\n");
2202 return E_UNEXPECTED;
2206 hres = HTMLDOMAttribute_Create(This->elem, id, attr);
2211 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
2217 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
2219 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2222 TRACE("(%p)->(%p)\n", This, p);
2225 hres = get_attr_dispid_by_idx(This, p, NULL);
2229 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
2231 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2232 FIXME("(%p)->(%p)\n", This, p);
2236 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
2238 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2239 HTMLDOMAttribute *attr;
2243 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
2245 switch(V_VT(name)) {
2247 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
2250 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
2253 FIXME("unsupported name %s\n", debugstr_variant(name));
2256 if(hres == DISP_E_UNKNOWNNAME)
2257 return E_INVALIDARG;
2261 hres = get_domattr(This, id, NULL, &attr);
2265 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
2269 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
2270 HTMLAttributeCollection_QueryInterface,
2271 HTMLAttributeCollection_AddRef,
2272 HTMLAttributeCollection_Release,
2273 HTMLAttributeCollection_GetTypeInfoCount,
2274 HTMLAttributeCollection_GetTypeInfo,
2275 HTMLAttributeCollection_GetIDsOfNames,
2276 HTMLAttributeCollection_Invoke,
2277 HTMLAttributeCollection_get_length,
2278 HTMLAttributeCollection__newEnum,
2279 HTMLAttributeCollection_item
2282 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
2284 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
2287 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
2289 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2290 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2293 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
2295 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2296 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2299 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
2301 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2302 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2305 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
2307 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2308 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2311 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
2312 LCID lcid, ITypeInfo **ppTInfo)
2314 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2315 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2318 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
2319 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2321 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2322 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2326 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
2327 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2328 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2330 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2331 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2332 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2335 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
2336 IHTMLDOMAttribute **newretNode)
2338 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2339 HTMLDOMAttribute *attr;
2343 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2345 hres = get_attr_dispid_by_name(This, bstrName, &id);
2346 if(hres == DISP_E_UNKNOWNNAME) {
2349 } else if(FAILED(hres)) {
2353 hres = get_domattr(This, id, NULL, &attr);
2357 *newretNode = &attr->IHTMLDOMAttribute_iface;
2361 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
2362 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
2364 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2365 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
2369 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
2370 BSTR bstrName, IHTMLDOMAttribute **newretNode)
2372 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2373 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2377 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
2378 HTMLAttributeCollection2_QueryInterface,
2379 HTMLAttributeCollection2_AddRef,
2380 HTMLAttributeCollection2_Release,
2381 HTMLAttributeCollection2_GetTypeInfoCount,
2382 HTMLAttributeCollection2_GetTypeInfo,
2383 HTMLAttributeCollection2_GetIDsOfNames,
2384 HTMLAttributeCollection2_Invoke,
2385 HTMLAttributeCollection2_getNamedItem,
2386 HTMLAttributeCollection2_setNamedItem,
2387 HTMLAttributeCollection2_removeNamedItem
2390 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
2392 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
2395 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
2397 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2398 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2401 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
2403 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2404 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2407 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
2409 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2410 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2413 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
2415 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2416 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2419 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
2420 LCID lcid, ITypeInfo **ppTInfo)
2422 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2423 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2426 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
2427 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2429 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2430 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2434 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
2435 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2436 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2438 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2439 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2440 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2443 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
2444 IHTMLDOMAttribute **ppNodeOut)
2446 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2447 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
2450 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
2451 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
2453 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2454 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
2458 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
2459 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
2461 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2462 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
2466 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
2468 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2469 HTMLDOMAttribute *attr;
2473 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
2475 hres = get_attr_dispid_by_idx(This, &index, &id);
2476 if(hres == DISP_E_UNKNOWNNAME)
2477 return E_INVALIDARG;
2481 hres = get_domattr(This, id, NULL, &attr);
2485 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
2489 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
2491 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2492 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
2495 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
2496 HTMLAttributeCollection3_QueryInterface,
2497 HTMLAttributeCollection3_AddRef,
2498 HTMLAttributeCollection3_Release,
2499 HTMLAttributeCollection3_GetTypeInfoCount,
2500 HTMLAttributeCollection3_GetTypeInfo,
2501 HTMLAttributeCollection3_GetIDsOfNames,
2502 HTMLAttributeCollection3_Invoke,
2503 HTMLAttributeCollection3_getNamedItem,
2504 HTMLAttributeCollection3_setNamedItem,
2505 HTMLAttributeCollection3_removeNamedItem,
2506 HTMLAttributeCollection3_item,
2507 HTMLAttributeCollection3_get_length
2510 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
2512 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
2515 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
2517 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2518 HTMLDOMAttribute *attr;
2522 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
2524 hres = get_attr_dispid_by_name(This, name, dispid);
2528 hres = get_domattr(This, *dispid, &pos, &attr);
2531 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2533 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
2537 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
2538 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2540 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2542 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
2545 case DISPATCH_PROPERTYGET: {
2546 HTMLDOMAttribute *iter;
2548 id = id-MSHTML_DISPID_CUSTOM_MIN+1;
2550 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2555 return E_INVALIDARG;
2557 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
2558 V_VT(res) = VT_DISPATCH;
2559 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
2564 FIXME("unimplemented flags %x\n", flags);
2569 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
2571 HTMLAttributeCollection_get_dispid,
2572 HTMLAttributeCollection_invoke,
2576 static const tid_t HTMLAttributeCollection_iface_tids[] = {
2577 IHTMLAttributeCollection_tid,
2578 IHTMLAttributeCollection2_tid,
2579 IHTMLAttributeCollection3_tid,
2583 static dispex_static_data_t HTMLAttributeCollection_dispex = {
2584 &HTMLAttributeCollection_dispex_vtbl,
2585 DispHTMLAttributeCollection_tid,
2587 HTMLAttributeCollection_iface_tids
2590 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
2592 HTMLElement *This = impl_from_HTMLDOMNode(iface);
2595 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
2600 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
2602 return E_OUTOFMEMORY;
2604 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
2605 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
2606 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
2607 This->attrs->ref = 2;
2609 This->attrs->elem = This;
2610 list_init(&This->attrs->attrs);
2611 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
2612 &HTMLAttributeCollection_dispex);