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 buttonW[] = {'B','U','T','T','O','N',0};
42 static const WCHAR embedW[] = {'E','M','B','E','D',0};
43 static const WCHAR formW[] = {'F','O','R','M',0};
44 static const WCHAR frameW[] = {'F','R','A','M','E',0};
45 static const WCHAR headW[] = {'H','E','A','D',0};
46 static const WCHAR iframeW[] = {'I','F','R','A','M','E',0};
47 static const WCHAR imgW[] = {'I','M','G',0};
48 static const WCHAR inputW[] = {'I','N','P','U','T',0};
49 static const WCHAR labelW[] = {'L','A','B','E','L',0};
50 static const WCHAR linkW[] = {'L','I','N','K',0};
51 static const WCHAR metaW[] = {'M','E','T','A',0};
52 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
53 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
54 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
55 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
56 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
57 static const WCHAR tableW[] = {'T','A','B','L','E',0};
58 static const WCHAR tdW[] = {'T','D',0};
59 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
60 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
61 static const WCHAR trW[] = {'T','R',0};
65 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
68 static const tag_desc_t tag_descs[] = {
69 {aW, HTMLAnchorElement_Create},
70 {bodyW, HTMLBodyElement_Create},
71 {buttonW, HTMLButtonElement_Create},
72 {embedW, HTMLEmbedElement_Create},
73 {formW, HTMLFormElement_Create},
74 {frameW, HTMLFrameElement_Create},
75 {headW, HTMLHeadElement_Create},
76 {iframeW, HTMLIFrame_Create},
77 {imgW, HTMLImgElement_Create},
78 {inputW, HTMLInputElement_Create},
79 {labelW, HTMLLabelElement_Create},
80 {linkW, HTMLLinkElement_Create},
81 {metaW, HTMLMetaElement_Create},
82 {objectW, HTMLObjectElement_Create},
83 {optionW, HTMLOptionElement_Create},
84 {scriptW, HTMLScriptElement_Create},
85 {selectW, HTMLSelectElement_Create},
86 {styleW, HTMLStyleElement_Create},
87 {tableW, HTMLTable_Create},
88 {tdW, HTMLTableCell_Create},
89 {textareaW, HTMLTextAreaElement_Create},
90 {title_tagW, HTMLTitleElement_Create},
91 {trW, HTMLTableRow_Create}
94 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
96 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
101 r = strcmpW(tag_name, tag_descs[i].name);
114 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
116 nsIDOMDocumentFragment *nsfragment;
117 nsIDOMNode *nsparent;
123 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
124 if(NS_FAILED(nsres)) {
125 ERR("CreateRange failed: %08x\n", nsres);
129 nsAString_InitDepend(&html_str, html);
130 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
131 nsIDOMRange_Release(range);
132 nsAString_Finish(&html_str);
133 if(NS_FAILED(nsres)) {
134 ERR("CreateContextualFragment failed: %08x\n", nsres);
138 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
139 if(NS_SUCCEEDED(nsres) && nsparent) {
142 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
143 nsIDOMNode_Release(nsparent);
144 if(NS_FAILED(nsres)) {
145 ERR("ReplaceChild failed: %08x\n", nsres);
148 nsIDOMNode_Release(nstmp);
151 ERR("GetParentNode failed: %08x\n", nsres);
155 nsIDOMDocumentFragment_Release(nsfragment);
162 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
165 } HTMLFiltersCollection;
167 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
169 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
172 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
174 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
176 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
179 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
181 nsIDOMElement *nselem;
186 WARN("NULL nsdoc\n");
190 nsAString_InitDepend(&tag_str, tag);
191 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
192 nsAString_Finish(&tag_str);
193 if(NS_FAILED(nsres)) {
194 ERR("CreateElement failed: %08x\n", nsres);
198 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
199 nsIDOMElement_Release(nselem);
200 if(NS_FAILED(nsres)) {
201 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
208 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
210 nsIDOMHTMLElement *nselem;
213 /* Use owner doc if called on document fragment */
217 hres = create_nselem(doc, tag, &nselem);
221 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
222 nsIDOMHTMLElement_Release(nselem);
226 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
227 REFIID riid, void **ppv)
229 HTMLElement *This = impl_from_IHTMLElement(iface);
231 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
234 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
236 HTMLElement *This = impl_from_IHTMLElement(iface);
238 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
241 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
243 HTMLElement *This = impl_from_IHTMLElement(iface);
245 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
248 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
250 HTMLElement *This = impl_from_IHTMLElement(iface);
251 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
254 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
255 LCID lcid, ITypeInfo **ppTInfo)
257 HTMLElement *This = impl_from_IHTMLElement(iface);
258 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
261 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
262 LPOLESTR *rgszNames, UINT cNames,
263 LCID lcid, DISPID *rgDispId)
265 HTMLElement *This = impl_from_IHTMLElement(iface);
266 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
270 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
271 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
272 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
274 HTMLElement *This = impl_from_IHTMLElement(iface);
275 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
276 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
279 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
280 VARIANT AttributeValue, LONG lFlags)
282 HTMLElement *This = impl_from_IHTMLElement(iface);
284 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
285 DISPPARAMS dispParams;
288 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
290 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
291 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
295 dispParams.cArgs = 1;
296 dispParams.cNamedArgs = 1;
297 dispParams.rgdispidNamedArgs = &dispidNamed;
298 dispParams.rgvarg = &AttributeValue;
300 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
301 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
305 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
306 LONG lFlags, VARIANT *AttributeValue)
308 HTMLElement *This = impl_from_IHTMLElement(iface);
311 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
314 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
316 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
317 fdexNameCaseInsensitive, &dispid);
318 if(hres == DISP_E_UNKNOWNNAME) {
319 V_VT(AttributeValue) = VT_NULL;
324 V_VT(AttributeValue) = VT_NULL;
328 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
329 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
334 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
335 LONG lFlags, VARIANT_BOOL *pfSuccess)
337 HTMLElement *This = impl_from_IHTMLElement(iface);
339 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
341 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
344 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
346 HTMLElement *This = impl_from_IHTMLElement(iface);
347 nsAString classname_str;
350 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
353 FIXME("NULL nselem\n");
357 nsAString_InitDepend(&classname_str, v);
358 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
359 nsAString_Finish(&classname_str);
361 ERR("SetClassName failed: %08x\n", nsres);
366 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
368 HTMLElement *This = impl_from_IHTMLElement(iface);
372 TRACE("(%p)->(%p)\n", This, p);
375 FIXME("NULL nselem\n");
379 nsAString_Init(&class_str, NULL);
380 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
381 return return_nsstr(nsres, &class_str, p);
384 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
386 HTMLElement *This = impl_from_IHTMLElement(iface);
390 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
393 FIXME("nselem == NULL\n");
397 nsAString_InitDepend(&id_str, v);
398 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
399 nsAString_Finish(&id_str);
401 ERR("SetId failed: %08x\n", nsres);
406 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
408 HTMLElement *This = impl_from_IHTMLElement(iface);
412 TRACE("(%p)->(%p)\n", This, p);
419 nsAString_Init(&id_str, NULL);
420 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
421 return return_nsstr(nsres, &id_str, p);
424 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
426 HTMLElement *This = impl_from_IHTMLElement(iface);
430 TRACE("(%p)->(%p)\n", This, p);
433 static const WCHAR comment_tagW[] = {'!',0};
435 WARN("NULL nselem, assuming comment\n");
437 *p = SysAllocString(comment_tagW);
438 return *p ? S_OK : E_OUTOFMEMORY;
441 nsAString_Init(&tag_str, NULL);
442 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
443 return return_nsstr(nsres, &tag_str, p);
446 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
448 HTMLElement *This = impl_from_IHTMLElement(iface);
452 TRACE("(%p)->(%p)\n", This, p);
454 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
458 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
459 IHTMLDOMNode_Release(node);
466 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
468 HTMLElement *This = impl_from_IHTMLElement(iface);
470 TRACE("(%p)->(%p)\n", This, p);
475 hres = HTMLStyle_Create(This, &This->style);
480 *p = &This->style->IHTMLStyle_iface;
481 IHTMLStyle_AddRef(*p);
485 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
487 HTMLElement *This = impl_from_IHTMLElement(iface);
488 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
492 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
494 HTMLElement *This = impl_from_IHTMLElement(iface);
495 FIXME("(%p)->(%p)\n", This, p);
499 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
501 HTMLElement *This = impl_from_IHTMLElement(iface);
503 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
505 return set_node_event(&This->node, EVENTID_CLICK, &v);
508 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
510 HTMLElement *This = impl_from_IHTMLElement(iface);
512 TRACE("(%p)->(%p)\n", This, p);
514 return get_node_event(&This->node, EVENTID_CLICK, p);
517 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
519 HTMLElement *This = impl_from_IHTMLElement(iface);
521 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
523 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
526 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
528 HTMLElement *This = impl_from_IHTMLElement(iface);
530 TRACE("(%p)->(%p)\n", This, p);
532 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
535 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
537 HTMLElement *This = impl_from_IHTMLElement(iface);
539 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
541 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
544 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
546 HTMLElement *This = impl_from_IHTMLElement(iface);
548 TRACE("(%p)->(%p)\n", This, p);
550 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
553 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
555 HTMLElement *This = impl_from_IHTMLElement(iface);
557 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
559 return set_node_event(&This->node, EVENTID_KEYUP, &v);
562 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
564 HTMLElement *This = impl_from_IHTMLElement(iface);
565 FIXME("(%p)->(%p)\n", This, p);
569 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
571 HTMLElement *This = impl_from_IHTMLElement(iface);
573 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
575 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
578 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
580 HTMLElement *This = impl_from_IHTMLElement(iface);
582 TRACE("(%p)->(%p)\n", This, p);
584 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
587 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
589 HTMLElement *This = impl_from_IHTMLElement(iface);
591 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
593 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
596 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
598 HTMLElement *This = impl_from_IHTMLElement(iface);
600 TRACE("(%p)->(%p)\n", This, p);
602 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
605 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
607 HTMLElement *This = impl_from_IHTMLElement(iface);
609 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
611 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
614 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
616 HTMLElement *This = impl_from_IHTMLElement(iface);
618 TRACE("(%p)->(%p)\n", This, p);
620 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
623 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
625 HTMLElement *This = impl_from_IHTMLElement(iface);
627 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
629 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
632 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
634 HTMLElement *This = impl_from_IHTMLElement(iface);
636 TRACE("(%p)->(%p)\n", This, p);
638 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
641 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
643 HTMLElement *This = impl_from_IHTMLElement(iface);
645 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
647 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
650 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
652 HTMLElement *This = impl_from_IHTMLElement(iface);
654 TRACE("(%p)->(%p)\n", This, p);
656 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
659 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
661 HTMLElement *This = impl_from_IHTMLElement(iface);
663 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
665 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
668 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
670 HTMLElement *This = impl_from_IHTMLElement(iface);
672 TRACE("(%p)->(%p)\n", This, p);
674 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
677 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
679 HTMLElement *This = impl_from_IHTMLElement(iface);
681 TRACE("(%p)->(%p)\n", This, p);
686 if(This->node.vtbl->get_document)
687 return This->node.vtbl->get_document(&This->node, p);
689 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
690 IDispatch_AddRef(*p);
694 static const WCHAR titleW[] = {'t','i','t','l','e',0};
696 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
698 HTMLElement *This = impl_from_IHTMLElement(iface);
702 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
708 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
714 V_BSTR(var) = v ? SysAllocString(v) : NULL;
718 nsAString_InitDepend(&title_str, v);
719 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
720 nsAString_Finish(&title_str);
722 ERR("SetTitle failed: %08x\n", nsres);
727 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
729 HTMLElement *This = impl_from_IHTMLElement(iface);
733 TRACE("(%p)->(%p)\n", This, p);
739 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
740 if(hres == DISP_E_UNKNOWNNAME) {
742 }else if(V_VT(var) != VT_BSTR) {
743 FIXME("title = %s\n", debugstr_variant(var));
746 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
752 nsAString_Init(&title_str, NULL);
753 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
754 return return_nsstr(nsres, &title_str, p);
757 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
759 HTMLElement *This = impl_from_IHTMLElement(iface);
760 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
764 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
766 HTMLElement *This = impl_from_IHTMLElement(iface);
767 FIXME("(%p)->(%p)\n", This, p);
771 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
773 HTMLElement *This = impl_from_IHTMLElement(iface);
775 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
777 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
780 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
782 HTMLElement *This = impl_from_IHTMLElement(iface);
784 TRACE("(%p)->(%p)\n", This, p);
786 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
789 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
791 HTMLElement *This = impl_from_IHTMLElement(iface);
792 FIXME("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
796 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
797 VARIANT_BOOL *pfResult)
799 HTMLElement *This = impl_from_IHTMLElement(iface);
804 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
806 child = unsafe_impl_from_IHTMLElement(pChild);
808 ERR("not our element\n");
812 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
813 if(NS_FAILED(nsres)) {
818 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
822 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
824 HTMLElement *This = impl_from_IHTMLElement(iface);
825 FIXME("(%p)->(%p)\n", This, p);
829 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
831 HTMLElement *This = impl_from_IHTMLElement(iface);
832 FIXME("(%p)->(%p)\n", This, p);
836 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
838 HTMLElement *This = impl_from_IHTMLElement(iface);
839 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
843 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
845 HTMLElement *This = impl_from_IHTMLElement(iface);
846 FIXME("(%p)->(%p)\n", This, p);
850 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
852 HTMLElement *This = impl_from_IHTMLElement(iface);
855 TRACE("(%p)->(%p)\n", This, p);
857 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, p);
858 if(NS_FAILED(nsres)) {
859 ERR("GetOffsetLeft failed: %08x\n", nsres);
866 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
868 HTMLElement *This = impl_from_IHTMLElement(iface);
871 TRACE("(%p)->(%p)\n", This, p);
873 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, p);
874 if(NS_FAILED(nsres)) {
875 ERR("GetOffsetTop failed: %08x\n", nsres);
882 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
884 HTMLElement *This = impl_from_IHTMLElement(iface);
887 TRACE("(%p)->(%p)\n", This, p);
889 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, p);
890 if(NS_FAILED(nsres)) {
891 ERR("GetOffsetWidth failed: %08x\n", nsres);
898 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
900 HTMLElement *This = impl_from_IHTMLElement(iface);
903 TRACE("(%p)->(%p)\n", This, p);
905 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, p);
906 if(NS_FAILED(nsres)) {
907 ERR("GetOffsetHeight failed: %08x\n", nsres);
914 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
916 HTMLElement *This = impl_from_IHTMLElement(iface);
917 nsIDOMElement *nsparent;
921 TRACE("(%p)->(%p)\n", This, p);
923 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
924 if(NS_FAILED(nsres)) {
925 ERR("GetOffsetParent failed: %08x\n", nsres);
932 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
933 nsIDOMElement_Release(nsparent);
937 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
947 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
949 HTMLElement *This = impl_from_IHTMLElement(iface);
953 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
956 FIXME("NULL nselem\n");
960 nsAString_InitDepend(&html_str, v);
961 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
962 nsAString_Finish(&html_str);
963 if(NS_FAILED(nsres)) {
964 FIXME("SetInnerHtml failed %08x\n", nsres);
971 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
973 HTMLElement *This = impl_from_IHTMLElement(iface);
977 TRACE("(%p)->(%p)\n", This, p);
980 FIXME("NULL nselem\n");
984 nsAString_Init(&html_str, NULL);
985 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
986 return return_nsstr(nsres, &html_str, p);
989 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
991 HTMLElement *This = impl_from_IHTMLElement(iface);
992 nsIDOMNode *nschild, *tmp;
993 nsIDOMText *text_node;
997 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1000 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1001 if(NS_FAILED(nsres)) {
1002 ERR("GetLastChild failed: %08x\n", nsres);
1008 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1009 nsIDOMNode_Release(nschild);
1010 if(NS_FAILED(nsres)) {
1011 ERR("RemoveChild failed: %08x\n", nsres);
1014 nsIDOMNode_Release(tmp);
1017 nsAString_InitDepend(&text_str, v);
1018 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1019 nsAString_Finish(&text_str);
1020 if(NS_FAILED(nsres)) {
1021 ERR("CreateTextNode failed: %08x\n", nsres);
1025 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1026 if(NS_FAILED(nsres)) {
1027 ERR("AppendChild failed: %08x\n", nsres);
1031 nsIDOMNode_Release(tmp);
1035 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1037 HTMLElement *This = impl_from_IHTMLElement(iface);
1039 TRACE("(%p)->(%p)\n", This, p);
1041 return get_node_text(&This->node, p);
1044 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1046 HTMLElement *This = impl_from_IHTMLElement(iface);
1048 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1050 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1053 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1055 HTMLElement *This = impl_from_IHTMLElement(iface);
1059 WARN("(%p)->(%p) semi-stub\n", This, p);
1061 nsAString_Init(&html_str, NULL);
1062 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1063 if(SUCCEEDED(hres)) {
1064 const PRUnichar *html;
1066 nsAString_GetData(&html_str, &html);
1067 *p = SysAllocString(html);
1069 hres = E_OUTOFMEMORY;
1072 nsAString_Finish(&html_str);
1074 TRACE("ret %s\n", debugstr_w(*p));
1078 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1080 HTMLElement *This = impl_from_IHTMLElement(iface);
1081 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1085 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1087 HTMLElement *This = impl_from_IHTMLElement(iface);
1088 FIXME("(%p)->(%p)\n", This, p);
1092 HRESULT insert_adjacent_node(HTMLElement *This, const WCHAR *where, nsIDOMNode *nsnode, HTMLDOMNode **ret_node)
1094 nsIDOMNode *ret_nsnode;
1096 HRESULT hres = S_OK;
1098 static const WCHAR beforebeginW[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1099 static const WCHAR afterbeginW[] = {'a','f','t','e','r','b','e','g','i','n',0};
1100 static const WCHAR beforeendW[] = {'b','e','f','o','r','e','e','n','d',0};
1101 static const WCHAR afterendW[] = {'a','f','t','e','r','e','n','d',0};
1103 if (!strcmpiW(where, beforebeginW)) {
1106 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1107 if(NS_FAILED(nsres))
1111 return E_INVALIDARG;
1113 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &ret_nsnode);
1114 nsIDOMNode_Release(parent);
1115 }else if(!strcmpiW(where, afterbeginW)) {
1116 nsIDOMNode *first_child;
1118 nsres = nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1119 if(NS_FAILED(nsres))
1122 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &ret_nsnode);
1123 if(NS_FAILED(nsres))
1127 nsIDOMNode_Release(first_child);
1128 }else if (!strcmpiW(where, beforeendW)) {
1129 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &ret_nsnode);
1130 }else if (!strcmpiW(where, afterendW)) {
1131 nsIDOMNode *next_sibling, *parent;
1133 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1134 if(NS_FAILED(nsres))
1137 return E_INVALIDARG;
1139 nsres = nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1140 if(NS_SUCCEEDED(nsres)) {
1142 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &ret_nsnode);
1143 nsIDOMNode_Release(next_sibling);
1145 nsres = nsIDOMNode_AppendChild(parent, nsnode, &ret_nsnode);
1149 nsIDOMNode_Release(parent);
1151 ERR("invalid where: %s\n", debugstr_w(where));
1152 return E_INVALIDARG;
1155 if (NS_FAILED(nsres))
1159 hres = get_node(This->node.doc, ret_nsnode, TRUE, ret_node);
1160 nsIDOMNode_Release(ret_nsnode);
1164 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1167 HTMLElement *This = impl_from_IHTMLElement(iface);
1174 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1176 if(!This->node.doc->nsdoc) {
1177 WARN("NULL nsdoc\n");
1178 return E_UNEXPECTED;
1181 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1182 if(NS_FAILED(nsres))
1184 ERR("CreateRange failed: %08x\n", nsres);
1188 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1190 nsAString_InitDepend(&ns_html, html);
1191 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1192 nsAString_Finish(&ns_html);
1193 nsIDOMRange_Release(range);
1195 if(NS_FAILED(nsres) || !nsnode)
1197 ERR("CreateTextNode failed: %08x\n", nsres);
1201 hr = insert_adjacent_node(This, where, nsnode, NULL);
1202 nsIDOMNode_Release(nsnode);
1206 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1209 HTMLElement *This = impl_from_IHTMLElement(iface);
1215 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1217 if(!This->node.doc->nsdoc) {
1218 WARN("NULL nsdoc\n");
1219 return E_UNEXPECTED;
1223 nsAString_InitDepend(&ns_text, text);
1224 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1225 nsAString_Finish(&ns_text);
1227 if(NS_FAILED(nsres) || !nsnode)
1229 ERR("CreateTextNode failed: %08x\n", nsres);
1233 hr = insert_adjacent_node(This, where, nsnode, NULL);
1234 nsIDOMNode_Release(nsnode);
1239 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1241 HTMLElement *This = impl_from_IHTMLElement(iface);
1242 FIXME("(%p)->(%p)\n", This, p);
1246 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1248 HTMLElement *This = impl_from_IHTMLElement(iface);
1249 FIXME("(%p)->(%p)\n", This, p);
1253 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1255 HTMLElement *This = impl_from_IHTMLElement(iface);
1257 TRACE("(%p)\n", This);
1259 return call_fire_event(&This->node, EVENTID_CLICK);
1262 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1263 IHTMLFiltersCollection **p)
1265 HTMLElement *This = impl_from_IHTMLElement(iface);
1266 TRACE("(%p)->(%p)\n", This, p);
1271 *p = HTMLFiltersCollection_Create();
1276 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1278 HTMLElement *This = impl_from_IHTMLElement(iface);
1279 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1283 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1285 HTMLElement *This = impl_from_IHTMLElement(iface);
1286 FIXME("(%p)->(%p)\n", This, p);
1290 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1292 HTMLElement *This = impl_from_IHTMLElement(iface);
1293 FIXME("(%p)->(%p)\n", This, String);
1297 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1299 HTMLElement *This = impl_from_IHTMLElement(iface);
1300 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1304 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1306 HTMLElement *This = impl_from_IHTMLElement(iface);
1307 FIXME("(%p)->(%p)\n", This, p);
1311 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1313 HTMLElement *This = impl_from_IHTMLElement(iface);
1314 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1318 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1320 HTMLElement *This = impl_from_IHTMLElement(iface);
1321 FIXME("(%p)->(%p)\n", This, p);
1325 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1327 HTMLElement *This = impl_from_IHTMLElement(iface);
1328 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1332 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1334 HTMLElement *This = impl_from_IHTMLElement(iface);
1335 FIXME("(%p)->(%p)\n", This, p);
1339 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1341 HTMLElement *This = impl_from_IHTMLElement(iface);
1342 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1346 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1348 HTMLElement *This = impl_from_IHTMLElement(iface);
1349 FIXME("(%p)->(%p)\n", This, p);
1353 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1355 HTMLElement *This = impl_from_IHTMLElement(iface);
1356 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1360 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1362 HTMLElement *This = impl_from_IHTMLElement(iface);
1363 FIXME("(%p)->(%p)\n", This, p);
1367 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1369 HTMLElement *This = impl_from_IHTMLElement(iface);
1370 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1374 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1376 HTMLElement *This = impl_from_IHTMLElement(iface);
1377 FIXME("(%p)->(%p)\n", This, p);
1381 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1383 HTMLElement *This = impl_from_IHTMLElement(iface);
1385 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1387 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1390 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1392 HTMLElement *This = impl_from_IHTMLElement(iface);
1394 TRACE("(%p)->(%p)\n", This, p);
1396 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1399 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1401 HTMLElement *This = impl_from_IHTMLElement(iface);
1402 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1406 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1408 HTMLElement *This = impl_from_IHTMLElement(iface);
1409 FIXME("(%p)->(%p)\n", This, p);
1413 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1415 HTMLElement *This = impl_from_IHTMLElement(iface);
1416 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1420 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1422 HTMLElement *This = impl_from_IHTMLElement(iface);
1423 FIXME("(%p)->(%p)\n", This, p);
1427 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1429 HTMLElement *This = impl_from_IHTMLElement(iface);
1430 nsIDOMNodeList *nsnode_list;
1433 TRACE("(%p)->(%p)\n", This, p);
1435 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1436 if(NS_FAILED(nsres)) {
1437 ERR("GetChildNodes failed: %08x\n", nsres);
1441 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1443 nsIDOMNodeList_Release(nsnode_list);
1447 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1449 HTMLElement *This = impl_from_IHTMLElement(iface);
1451 TRACE("(%p)->(%p)\n", This, p);
1453 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1457 static const IHTMLElementVtbl HTMLElementVtbl = {
1458 HTMLElement_QueryInterface,
1460 HTMLElement_Release,
1461 HTMLElement_GetTypeInfoCount,
1462 HTMLElement_GetTypeInfo,
1463 HTMLElement_GetIDsOfNames,
1465 HTMLElement_setAttribute,
1466 HTMLElement_getAttribute,
1467 HTMLElement_removeAttribute,
1468 HTMLElement_put_className,
1469 HTMLElement_get_className,
1472 HTMLElement_get_tagName,
1473 HTMLElement_get_parentElement,
1474 HTMLElement_get_style,
1475 HTMLElement_put_onhelp,
1476 HTMLElement_get_onhelp,
1477 HTMLElement_put_onclick,
1478 HTMLElement_get_onclick,
1479 HTMLElement_put_ondblclick,
1480 HTMLElement_get_ondblclick,
1481 HTMLElement_put_onkeydown,
1482 HTMLElement_get_onkeydown,
1483 HTMLElement_put_onkeyup,
1484 HTMLElement_get_onkeyup,
1485 HTMLElement_put_onkeypress,
1486 HTMLElement_get_onkeypress,
1487 HTMLElement_put_onmouseout,
1488 HTMLElement_get_onmouseout,
1489 HTMLElement_put_onmouseover,
1490 HTMLElement_get_onmouseover,
1491 HTMLElement_put_onmousemove,
1492 HTMLElement_get_onmousemove,
1493 HTMLElement_put_onmousedown,
1494 HTMLElement_get_onmousedown,
1495 HTMLElement_put_onmouseup,
1496 HTMLElement_get_onmouseup,
1497 HTMLElement_get_document,
1498 HTMLElement_put_title,
1499 HTMLElement_get_title,
1500 HTMLElement_put_language,
1501 HTMLElement_get_language,
1502 HTMLElement_put_onselectstart,
1503 HTMLElement_get_onselectstart,
1504 HTMLElement_scrollIntoView,
1505 HTMLElement_contains,
1506 HTMLElement_get_sourceIndex,
1507 HTMLElement_get_recordNumber,
1508 HTMLElement_put_lang,
1509 HTMLElement_get_lang,
1510 HTMLElement_get_offsetLeft,
1511 HTMLElement_get_offsetTop,
1512 HTMLElement_get_offsetWidth,
1513 HTMLElement_get_offsetHeight,
1514 HTMLElement_get_offsetParent,
1515 HTMLElement_put_innerHTML,
1516 HTMLElement_get_innerHTML,
1517 HTMLElement_put_innerText,
1518 HTMLElement_get_innerText,
1519 HTMLElement_put_outerHTML,
1520 HTMLElement_get_outerHTML,
1521 HTMLElement_put_outerText,
1522 HTMLElement_get_outerText,
1523 HTMLElement_insertAdjacentHTML,
1524 HTMLElement_insertAdjacentText,
1525 HTMLElement_get_parentTextEdit,
1526 HTMLElement_get_isTextEdit,
1528 HTMLElement_get_filters,
1529 HTMLElement_put_ondragstart,
1530 HTMLElement_get_ondragstart,
1531 HTMLElement_toString,
1532 HTMLElement_put_onbeforeupdate,
1533 HTMLElement_get_onbeforeupdate,
1534 HTMLElement_put_onafterupdate,
1535 HTMLElement_get_onafterupdate,
1536 HTMLElement_put_onerrorupdate,
1537 HTMLElement_get_onerrorupdate,
1538 HTMLElement_put_onrowexit,
1539 HTMLElement_get_onrowexit,
1540 HTMLElement_put_onrowenter,
1541 HTMLElement_get_onrowenter,
1542 HTMLElement_put_ondatasetchanged,
1543 HTMLElement_get_ondatasetchanged,
1544 HTMLElement_put_ondataavailable,
1545 HTMLElement_get_ondataavailable,
1546 HTMLElement_put_ondatasetcomplete,
1547 HTMLElement_get_ondatasetcomplete,
1548 HTMLElement_put_onfilterchange,
1549 HTMLElement_get_onfilterchange,
1550 HTMLElement_get_children,
1554 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1556 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1559 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1561 return CONTAINING_RECORD(iface, HTMLElement, node);
1564 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1566 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1570 if(IsEqualGUID(&IID_IUnknown, riid)) {
1571 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1572 *ppv = &This->IHTMLElement_iface;
1573 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1574 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1575 *ppv = &This->IHTMLElement_iface;
1576 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1577 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1578 *ppv = &This->IHTMLElement_iface;
1579 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1580 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1581 *ppv = &This->IHTMLElement2_iface;
1582 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1583 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1584 *ppv = &This->IHTMLElement3_iface;
1585 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1586 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1587 *ppv = &This->IHTMLElement4_iface;
1588 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1589 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1590 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1594 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1598 return HTMLDOMNode_QI(&This->node, riid, ppv);
1601 void HTMLElement_destructor(HTMLDOMNode *iface)
1603 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1605 ConnectionPointContainer_Destroy(&This->cp_container);
1608 This->style->elem = NULL;
1609 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1611 if(This->runtime_style) {
1612 This->runtime_style->elem = NULL;
1613 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
1616 HTMLDOMAttribute *attr;
1618 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
1621 This->attrs->elem = NULL;
1622 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
1625 heap_free(This->filter);
1627 HTMLDOMNode_destructor(&This->node);
1630 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1632 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1633 HTMLElement *new_elem;
1636 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1641 new_elem->filter = heap_strdupW(This->filter);
1642 if(!new_elem->filter) {
1643 IHTMLElement_Release(&This->IHTMLElement_iface);
1644 return E_OUTOFMEMORY;
1648 *ret = &new_elem->node;
1652 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
1654 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1657 case EVENTID_KEYDOWN: {
1658 nsIDOMKeyEvent *key_event;
1661 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
1662 if(NS_SUCCEEDED(nsres)) {
1665 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
1668 case VK_F1: /* DOM_VK_F1 */
1669 TRACE("F1 pressed\n");
1670 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
1671 *prevent_default = TRUE;
1674 nsIDOMKeyEvent_Release(key_event);
1682 cp_static_data_t HTMLElementEvents2_data = { HTMLElementEvents2_tid, NULL /* FIXME */, TRUE };
1684 const cpc_entry_t HTMLElement_cpc[] = {
1689 static const NodeImplVtbl HTMLElementImplVtbl = {
1691 HTMLElement_destructor,
1694 HTMLElement_handle_event,
1695 HTMLElement_get_attr_col
1698 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1700 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1703 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1704 DWORD grfdex, DISPID *pid)
1706 HTMLElement *This = impl_from_DispatchEx(dispex);
1708 if(This->node.vtbl->get_dispid)
1709 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1711 return DISP_E_UNKNOWNNAME;
1714 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1715 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1716 IServiceProvider *caller)
1718 HTMLElement *This = impl_from_DispatchEx(dispex);
1720 if(This->node.vtbl->invoke)
1721 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1722 params, res, ei, caller);
1724 ERR("(%p): element has no invoke method\n", This);
1728 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
1730 HTMLElement *This = impl_from_DispatchEx(dispex);
1731 nsIDOMNamedNodeMap *attrs;
1734 const PRUnichar *str;
1746 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
1747 if(NS_FAILED(nsres))
1750 nsres = nsIDOMNamedNodeMap_GetLength(attrs, &len);
1751 if(NS_FAILED(nsres)) {
1752 nsIDOMNamedNodeMap_Release(attrs);
1756 nsAString_Init(&nsstr, NULL);
1757 for(i=0; i<len; i++) {
1758 nsres = nsIDOMNamedNodeMap_Item(attrs, i, &node);
1759 if(NS_FAILED(nsres))
1762 nsres = nsIDOMNode_GetNodeName(node, &nsstr);
1763 if(NS_FAILED(nsres)) {
1764 nsIDOMNode_Release(node);
1768 nsAString_GetData(&nsstr, &str);
1769 name = SysAllocString(str);
1771 nsIDOMNode_Release(node);
1775 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
1776 if(hres != DISP_E_UNKNOWNNAME) {
1777 nsIDOMNode_Release(node);
1778 SysFreeString(name);
1782 nsres = nsIDOMNode_GetNodeValue(node, &nsstr);
1783 nsIDOMNode_Release(node);
1784 if(NS_FAILED(nsres)) {
1785 SysFreeString(name);
1789 nsAString_GetData(&nsstr, &str);
1790 V_VT(&value) = VT_BSTR;
1792 V_BSTR(&value) = SysAllocString(str);
1793 if(!V_BSTR(&value)) {
1794 SysFreeString(name);
1798 V_BSTR(&value) = NULL;
1800 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
1801 SysFreeString(name);
1802 VariantClear(&value);
1804 nsAString_Finish(&nsstr);
1806 nsIDOMNamedNodeMap_Release(attrs);
1810 static const tid_t HTMLElement_iface_tids[] = {
1815 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1817 HTMLElement_get_dispid,
1819 HTMLElement_populate_props
1822 static dispex_static_data_t HTMLElement_dispex = {
1823 &HTMLElement_dispex_vtbl,
1824 DispHTMLUnknownElement_tid,
1826 HTMLElement_iface_tids
1829 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1831 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1833 HTMLElement2_Init(This);
1834 HTMLElement3_Init(This);
1836 if(dispex_data && !dispex_data->vtbl)
1837 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1838 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1839 dispex_data ? dispex_data : &HTMLElement_dispex);
1842 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1844 /* No AddRef, share reference with HTMLDOMNode */
1845 assert((nsIDOMNode*)nselem == This->node.nsnode);
1846 This->nselem = nselem;
1849 This->node.cp_container = &This->cp_container;
1850 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface, This->node.vtbl->cpc_entries);
1853 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1855 nsIDOMHTMLElement *nselem;
1856 nsAString class_name_str;
1857 const PRUnichar *class_name;
1858 const tag_desc_t *tag;
1863 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1864 if(NS_FAILED(nsres))
1867 nsAString_Init(&class_name_str, NULL);
1868 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1870 nsAString_GetData(&class_name_str, &class_name);
1872 tag = get_tag_desc(class_name);
1874 hres = tag->constructor(doc, nselem, &elem);
1875 }else if(use_generic) {
1876 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1878 elem = heap_alloc_zero(sizeof(HTMLElement));
1880 elem->node.vtbl = &HTMLElementImplVtbl;
1881 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1884 hres = E_OUTOFMEMORY;
1888 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1890 nsIDOMHTMLElement_Release(nselem);
1891 nsAString_Finish(&class_name_str);
1899 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
1904 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
1908 *ret = impl_from_HTMLDOMNode(node);
1912 /* interface IHTMLFiltersCollection */
1913 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1915 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1917 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1919 if(IsEqualGUID(&IID_IUnknown, riid)) {
1920 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1921 *ppv = &This->IHTMLFiltersCollection_iface;
1922 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1923 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1924 *ppv = &This->IHTMLFiltersCollection_iface;
1925 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1926 return *ppv ? S_OK : E_NOINTERFACE;
1930 IUnknown_AddRef((IUnknown*)*ppv);
1934 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1935 return E_NOINTERFACE;
1938 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1940 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1941 LONG ref = InterlockedIncrement(&This->ref);
1943 TRACE("(%p) ref=%d\n", This, ref);
1948 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1950 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1951 LONG ref = InterlockedDecrement(&This->ref);
1953 TRACE("(%p) ref=%d\n", This, ref);
1963 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1965 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1966 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1969 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1970 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1972 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1973 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1976 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1977 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1978 LCID lcid, DISPID *rgDispId)
1980 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1981 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1985 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1986 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1987 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1989 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1990 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1991 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1994 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1996 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
2001 FIXME("(%p)->(%p) Always returning 0\n", This, p);
2007 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
2009 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
2010 FIXME("(%p)->(%p)\n", This, p);
2014 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
2016 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
2017 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
2021 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
2022 HTMLFiltersCollection_QueryInterface,
2023 HTMLFiltersCollection_AddRef,
2024 HTMLFiltersCollection_Release,
2025 HTMLFiltersCollection_GetTypeInfoCount,
2026 HTMLFiltersCollection_GetTypeInfo,
2027 HTMLFiltersCollection_GetIDsOfNames,
2028 HTMLFiltersCollection_Invoke,
2029 HTMLFiltersCollection_get_length,
2030 HTMLFiltersCollection_get__newEnum,
2031 HTMLFiltersCollection_item
2034 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
2039 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
2040 idx = idx*10 + (*ptr-'0');
2042 return DISP_E_UNKNOWNNAME;
2044 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
2045 TRACE("ret %x\n", *dispid);
2049 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2050 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2052 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
2054 V_VT(res) = VT_DISPATCH;
2055 V_DISPATCH(res) = NULL;
2057 FIXME("always returning NULL\n");
2062 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
2064 HTMLFiltersCollection_get_dispid,
2065 HTMLFiltersCollection_invoke,
2069 static const tid_t HTMLFiltersCollection_iface_tids[] = {
2070 IHTMLFiltersCollection_tid,
2073 static dispex_static_data_t HTMLFiltersCollection_dispex = {
2074 &HTMLFiltersCollection_dispex_vtbl,
2075 IHTMLFiltersCollection_tid,
2077 HTMLFiltersCollection_iface_tids
2080 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
2082 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
2084 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2087 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2088 &HTMLFiltersCollection_dispex);
2090 return &ret->IHTMLFiltersCollection_iface;
2093 /* interface IHTMLAttributeCollection */
2094 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
2096 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
2099 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
2101 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2105 if(IsEqualGUID(&IID_IUnknown, riid)) {
2106 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
2107 *ppv = &This->IHTMLAttributeCollection_iface;
2108 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
2109 TRACE("(%p)->(IID_IHTMLAttributeCollection %p)\n", This, ppv);
2110 *ppv = &This->IHTMLAttributeCollection_iface;
2111 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
2112 TRACE("(%p)->(IID_IHTMLAttributeCollection2 %p)\n", This, ppv);
2113 *ppv = &This->IHTMLAttributeCollection2_iface;
2114 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
2115 TRACE("(%p)->(IID_IHTMLAttributeCollection3 %p)\n", This, ppv);
2116 *ppv = &This->IHTMLAttributeCollection3_iface;
2117 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2118 return *ppv ? S_OK : E_NOINTERFACE;
2122 IUnknown_AddRef((IUnknown*)*ppv);
2126 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2127 return E_NOINTERFACE;
2130 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
2132 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2133 LONG ref = InterlockedIncrement(&This->ref);
2135 TRACE("(%p) ref=%d\n", This, ref);
2140 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
2142 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2143 LONG ref = InterlockedDecrement(&This->ref);
2145 TRACE("(%p) ref=%d\n", This, ref);
2148 while(!list_empty(&This->attrs)) {
2149 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
2151 list_remove(&attr->entry);
2153 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2162 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
2164 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2165 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2168 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
2169 LCID lcid, ITypeInfo **ppTInfo)
2171 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2172 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2175 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
2176 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2178 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2179 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2183 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
2184 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2185 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2187 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2188 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2189 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2192 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
2194 IDispatchEx *dispex = &This->elem->node.dispex.IDispatchEx_iface;
2195 DISPID id = DISPID_STARTENUM;
2199 FIXME("filter non-enumerable attributes out\n");
2202 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
2205 else if(hres == S_FALSE)
2215 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
2222 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
2226 if(name[0]>='0' && name[0]<='9') {
2230 idx = strtoulW(name, &end_ptr, 10);
2232 hres = get_attr_dispid_by_idx(This, &idx, id);
2239 WARN("NULL elem\n");
2240 return E_UNEXPECTED;
2243 hres = IDispatchEx_GetDispID(&This->elem->node.dispex.IDispatchEx_iface,
2244 name, fdexNameCaseInsensitive, id);
2248 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
2250 HTMLDOMAttribute *iter;
2255 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2256 if(iter->dispid == id) {
2265 WARN("NULL elem\n");
2266 return E_UNEXPECTED;
2269 hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
2274 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
2280 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
2282 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2285 TRACE("(%p)->(%p)\n", This, p);
2288 hres = get_attr_dispid_by_idx(This, p, NULL);
2292 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
2294 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2295 FIXME("(%p)->(%p)\n", This, p);
2299 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
2301 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2302 HTMLDOMAttribute *attr;
2306 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
2308 switch(V_VT(name)) {
2310 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
2313 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
2316 FIXME("unsupported name %s\n", debugstr_variant(name));
2319 if(hres == DISP_E_UNKNOWNNAME)
2320 return E_INVALIDARG;
2324 hres = get_domattr(This, id, NULL, &attr);
2328 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
2332 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
2333 HTMLAttributeCollection_QueryInterface,
2334 HTMLAttributeCollection_AddRef,
2335 HTMLAttributeCollection_Release,
2336 HTMLAttributeCollection_GetTypeInfoCount,
2337 HTMLAttributeCollection_GetTypeInfo,
2338 HTMLAttributeCollection_GetIDsOfNames,
2339 HTMLAttributeCollection_Invoke,
2340 HTMLAttributeCollection_get_length,
2341 HTMLAttributeCollection__newEnum,
2342 HTMLAttributeCollection_item
2345 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
2347 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
2350 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
2352 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2353 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2356 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
2358 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2359 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2362 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
2364 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2365 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2368 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
2370 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2371 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2374 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
2375 LCID lcid, ITypeInfo **ppTInfo)
2377 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2378 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2381 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
2382 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2384 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2385 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2389 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
2390 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2391 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2393 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2394 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2395 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2398 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
2399 IHTMLDOMAttribute **newretNode)
2401 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2402 HTMLDOMAttribute *attr;
2406 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2408 hres = get_attr_dispid_by_name(This, bstrName, &id);
2409 if(hres == DISP_E_UNKNOWNNAME) {
2412 } else if(FAILED(hres)) {
2416 hres = get_domattr(This, id, NULL, &attr);
2420 *newretNode = &attr->IHTMLDOMAttribute_iface;
2424 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
2425 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
2427 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2428 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
2432 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
2433 BSTR bstrName, IHTMLDOMAttribute **newretNode)
2435 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2436 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2440 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
2441 HTMLAttributeCollection2_QueryInterface,
2442 HTMLAttributeCollection2_AddRef,
2443 HTMLAttributeCollection2_Release,
2444 HTMLAttributeCollection2_GetTypeInfoCount,
2445 HTMLAttributeCollection2_GetTypeInfo,
2446 HTMLAttributeCollection2_GetIDsOfNames,
2447 HTMLAttributeCollection2_Invoke,
2448 HTMLAttributeCollection2_getNamedItem,
2449 HTMLAttributeCollection2_setNamedItem,
2450 HTMLAttributeCollection2_removeNamedItem
2453 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
2455 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
2458 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
2460 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2461 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2464 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
2466 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2467 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2470 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
2472 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2473 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2476 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
2478 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2479 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2482 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
2483 LCID lcid, ITypeInfo **ppTInfo)
2485 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2486 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2489 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
2490 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2492 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2493 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2497 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
2498 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2499 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2501 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2502 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2503 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2506 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
2507 IHTMLDOMAttribute **ppNodeOut)
2509 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2510 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
2513 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
2514 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
2516 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2517 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
2521 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
2522 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
2524 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2525 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
2529 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
2531 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2532 HTMLDOMAttribute *attr;
2536 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
2538 hres = get_attr_dispid_by_idx(This, &index, &id);
2539 if(hres == DISP_E_UNKNOWNNAME)
2540 return E_INVALIDARG;
2544 hres = get_domattr(This, id, NULL, &attr);
2548 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
2552 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
2554 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2555 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
2558 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
2559 HTMLAttributeCollection3_QueryInterface,
2560 HTMLAttributeCollection3_AddRef,
2561 HTMLAttributeCollection3_Release,
2562 HTMLAttributeCollection3_GetTypeInfoCount,
2563 HTMLAttributeCollection3_GetTypeInfo,
2564 HTMLAttributeCollection3_GetIDsOfNames,
2565 HTMLAttributeCollection3_Invoke,
2566 HTMLAttributeCollection3_getNamedItem,
2567 HTMLAttributeCollection3_setNamedItem,
2568 HTMLAttributeCollection3_removeNamedItem,
2569 HTMLAttributeCollection3_item,
2570 HTMLAttributeCollection3_get_length
2573 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
2575 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
2578 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
2580 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2581 HTMLDOMAttribute *attr;
2585 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
2587 hres = get_attr_dispid_by_name(This, name, dispid);
2591 hres = get_domattr(This, *dispid, &pos, &attr);
2594 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2596 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
2600 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
2601 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2603 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2605 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
2608 case DISPATCH_PROPERTYGET: {
2609 HTMLDOMAttribute *iter;
2612 pos = id-MSHTML_DISPID_CUSTOM_MIN;
2614 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2616 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
2617 V_VT(res) = VT_DISPATCH;
2618 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
2624 WARN("invalid arg\n");
2625 return E_INVALIDARG;
2629 FIXME("unimplemented flags %x\n", flags);
2634 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
2636 HTMLAttributeCollection_get_dispid,
2637 HTMLAttributeCollection_invoke,
2641 static const tid_t HTMLAttributeCollection_iface_tids[] = {
2642 IHTMLAttributeCollection_tid,
2643 IHTMLAttributeCollection2_tid,
2644 IHTMLAttributeCollection3_tid,
2648 static dispex_static_data_t HTMLAttributeCollection_dispex = {
2649 &HTMLAttributeCollection_dispex_vtbl,
2650 DispHTMLAttributeCollection_tid,
2652 HTMLAttributeCollection_iface_tids
2655 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
2657 HTMLElement *This = impl_from_HTMLDOMNode(iface);
2660 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
2665 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
2667 return E_OUTOFMEMORY;
2669 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
2670 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
2671 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
2672 This->attrs->ref = 2;
2674 This->attrs->elem = This;
2675 list_init(&This->attrs->attrs);
2676 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
2677 &HTMLAttributeCollection_dispex);