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 nsIDOMNode *nsparent;
117 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
118 if(NS_FAILED(nsres)) {
119 ERR("CreateRange failed: %08x\n", nsres);
123 nsAString_InitDepend(&html_str, html);
124 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
125 nsIDOMRange_Release(range);
126 nsAString_Finish(&html_str);
127 if(NS_FAILED(nsres)) {
128 ERR("CreateContextualFragment failed: %08x\n", nsres);
132 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
133 if(NS_SUCCEEDED(nsres) && nsparent) {
136 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
137 nsIDOMNode_Release(nsparent);
138 if(NS_FAILED(nsres)) {
139 ERR("ReplaceChild failed: %08x\n", nsres);
142 nsIDOMNode_Release(nstmp);
145 ERR("GetParentNode failed: %08x\n", nsres);
149 nsIDOMDocumentFragment_Release(nsfragment);
156 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
159 } HTMLFiltersCollection;
161 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
163 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
166 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
168 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
170 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
173 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
175 nsIDOMElement *nselem;
180 WARN("NULL nsdoc\n");
184 nsAString_InitDepend(&tag_str, tag);
185 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
186 nsAString_Finish(&tag_str);
187 if(NS_FAILED(nsres)) {
188 ERR("CreateElement failed: %08x\n", nsres);
192 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
193 nsIDOMElement_Release(nselem);
194 if(NS_FAILED(nsres)) {
195 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
202 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
203 REFIID riid, void **ppv)
205 HTMLElement *This = impl_from_IHTMLElement(iface);
207 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
210 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
212 HTMLElement *This = impl_from_IHTMLElement(iface);
214 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
217 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
219 HTMLElement *This = impl_from_IHTMLElement(iface);
221 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
224 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
226 HTMLElement *This = impl_from_IHTMLElement(iface);
227 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
230 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
231 LCID lcid, ITypeInfo **ppTInfo)
233 HTMLElement *This = impl_from_IHTMLElement(iface);
234 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
237 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
238 LPOLESTR *rgszNames, UINT cNames,
239 LCID lcid, DISPID *rgDispId)
241 HTMLElement *This = impl_from_IHTMLElement(iface);
242 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
246 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
247 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
248 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
250 HTMLElement *This = impl_from_IHTMLElement(iface);
251 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
252 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
255 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
256 VARIANT AttributeValue, LONG lFlags)
258 HTMLElement *This = impl_from_IHTMLElement(iface);
260 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
261 DISPPARAMS dispParams;
264 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
266 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
267 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
271 dispParams.cArgs = 1;
272 dispParams.cNamedArgs = 1;
273 dispParams.rgdispidNamedArgs = &dispidNamed;
274 dispParams.rgvarg = &AttributeValue;
276 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
277 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
281 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
282 LONG lFlags, VARIANT *AttributeValue)
284 HTMLElement *This = impl_from_IHTMLElement(iface);
287 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
290 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
292 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
293 fdexNameCaseInsensitive, &dispid);
294 if(hres == DISP_E_UNKNOWNNAME) {
295 V_VT(AttributeValue) = VT_NULL;
300 V_VT(AttributeValue) = VT_NULL;
304 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
305 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
310 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
311 LONG lFlags, VARIANT_BOOL *pfSuccess)
313 HTMLElement *This = impl_from_IHTMLElement(iface);
315 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
317 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
320 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
322 HTMLElement *This = impl_from_IHTMLElement(iface);
323 nsAString classname_str;
326 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
329 FIXME("NULL nselem\n");
333 nsAString_InitDepend(&classname_str, v);
334 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
335 nsAString_Finish(&classname_str);
337 ERR("SetClassName failed: %08x\n", nsres);
342 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
344 HTMLElement *This = impl_from_IHTMLElement(iface);
348 TRACE("(%p)->(%p)\n", This, p);
351 FIXME("NULL nselem\n");
355 nsAString_Init(&class_str, NULL);
356 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
357 return return_nsstr(nsres, &class_str, p);
360 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
362 HTMLElement *This = impl_from_IHTMLElement(iface);
366 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
369 FIXME("nselem == NULL\n");
373 nsAString_InitDepend(&id_str, v);
374 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
375 nsAString_Finish(&id_str);
377 ERR("SetId failed: %08x\n", nsres);
382 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
384 HTMLElement *This = impl_from_IHTMLElement(iface);
388 TRACE("(%p)->(%p)\n", This, p);
395 nsAString_Init(&id_str, NULL);
396 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
397 return return_nsstr(nsres, &id_str, p);
400 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
402 HTMLElement *This = impl_from_IHTMLElement(iface);
406 TRACE("(%p)->(%p)\n", This, p);
409 static const WCHAR comment_tagW[] = {'!',0};
411 WARN("NULL nselem, assuming comment\n");
413 *p = SysAllocString(comment_tagW);
414 return *p ? S_OK : E_OUTOFMEMORY;
417 nsAString_Init(&tag_str, NULL);
418 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
419 return return_nsstr(nsres, &tag_str, p);
422 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
424 HTMLElement *This = impl_from_IHTMLElement(iface);
428 TRACE("(%p)->(%p)\n", This, p);
430 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
434 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
435 IHTMLDOMNode_Release(node);
442 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
444 HTMLElement *This = impl_from_IHTMLElement(iface);
446 TRACE("(%p)->(%p)\n", This, p);
451 hres = HTMLStyle_Create(This, &This->style);
456 *p = &This->style->IHTMLStyle_iface;
457 IHTMLStyle_AddRef(*p);
461 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
463 HTMLElement *This = impl_from_IHTMLElement(iface);
464 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
468 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
470 HTMLElement *This = impl_from_IHTMLElement(iface);
471 FIXME("(%p)->(%p)\n", This, p);
475 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
477 HTMLElement *This = impl_from_IHTMLElement(iface);
479 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
481 return set_node_event(&This->node, EVENTID_CLICK, &v);
484 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
486 HTMLElement *This = impl_from_IHTMLElement(iface);
488 TRACE("(%p)->(%p)\n", This, p);
490 return get_node_event(&This->node, EVENTID_CLICK, p);
493 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
495 HTMLElement *This = impl_from_IHTMLElement(iface);
497 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
499 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
502 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
504 HTMLElement *This = impl_from_IHTMLElement(iface);
506 TRACE("(%p)->(%p)\n", This, p);
508 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
511 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
513 HTMLElement *This = impl_from_IHTMLElement(iface);
515 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
517 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
520 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
522 HTMLElement *This = impl_from_IHTMLElement(iface);
524 TRACE("(%p)->(%p)\n", This, p);
526 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
529 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
531 HTMLElement *This = impl_from_IHTMLElement(iface);
533 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
535 return set_node_event(&This->node, EVENTID_KEYUP, &v);
538 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
540 HTMLElement *This = impl_from_IHTMLElement(iface);
541 FIXME("(%p)->(%p)\n", This, p);
545 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
547 HTMLElement *This = impl_from_IHTMLElement(iface);
549 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
551 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
554 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
556 HTMLElement *This = impl_from_IHTMLElement(iface);
558 TRACE("(%p)->(%p)\n", This, p);
560 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
563 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
565 HTMLElement *This = impl_from_IHTMLElement(iface);
567 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
569 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
572 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
574 HTMLElement *This = impl_from_IHTMLElement(iface);
576 TRACE("(%p)->(%p)\n", This, p);
578 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
581 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
583 HTMLElement *This = impl_from_IHTMLElement(iface);
585 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
587 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
590 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
592 HTMLElement *This = impl_from_IHTMLElement(iface);
594 TRACE("(%p)->(%p)\n", This, p);
596 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
599 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
601 HTMLElement *This = impl_from_IHTMLElement(iface);
603 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
605 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
608 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
610 HTMLElement *This = impl_from_IHTMLElement(iface);
612 TRACE("(%p)->(%p)\n", This, p);
614 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
617 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
619 HTMLElement *This = impl_from_IHTMLElement(iface);
621 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
623 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
626 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
628 HTMLElement *This = impl_from_IHTMLElement(iface);
630 TRACE("(%p)->(%p)\n", This, p);
632 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
635 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
637 HTMLElement *This = impl_from_IHTMLElement(iface);
639 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
641 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
644 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
646 HTMLElement *This = impl_from_IHTMLElement(iface);
648 TRACE("(%p)->(%p)\n", This, p);
650 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
653 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
655 HTMLElement *This = impl_from_IHTMLElement(iface);
657 TRACE("(%p)->(%p)\n", This, p);
662 if(This->node.vtbl->get_document)
663 return This->node.vtbl->get_document(&This->node, p);
665 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
666 IDispatch_AddRef(*p);
670 static const WCHAR titleW[] = {'t','i','t','l','e',0};
672 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
674 HTMLElement *This = impl_from_IHTMLElement(iface);
678 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
684 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
690 V_BSTR(var) = v ? SysAllocString(v) : NULL;
694 nsAString_InitDepend(&title_str, v);
695 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
696 nsAString_Finish(&title_str);
698 ERR("SetTitle failed: %08x\n", nsres);
703 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
705 HTMLElement *This = impl_from_IHTMLElement(iface);
709 TRACE("(%p)->(%p)\n", This, p);
715 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
716 if(hres == DISP_E_UNKNOWNNAME) {
718 }else if(V_VT(var) != VT_BSTR) {
719 FIXME("title = %s\n", debugstr_variant(var));
722 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
728 nsAString_Init(&title_str, NULL);
729 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
730 return return_nsstr(nsres, &title_str, p);
733 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
735 HTMLElement *This = impl_from_IHTMLElement(iface);
736 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
740 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
742 HTMLElement *This = impl_from_IHTMLElement(iface);
743 FIXME("(%p)->(%p)\n", This, p);
747 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
749 HTMLElement *This = impl_from_IHTMLElement(iface);
751 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
753 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
756 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
758 HTMLElement *This = impl_from_IHTMLElement(iface);
760 TRACE("(%p)->(%p)\n", This, p);
762 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
765 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
767 HTMLElement *This = impl_from_IHTMLElement(iface);
768 FIXME("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
772 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
773 VARIANT_BOOL *pfResult)
775 HTMLElement *This = impl_from_IHTMLElement(iface);
780 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
782 child = unsafe_impl_from_IHTMLElement(pChild);
784 ERR("not our element\n");
788 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
789 if(NS_FAILED(nsres)) {
794 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
798 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
800 HTMLElement *This = impl_from_IHTMLElement(iface);
801 FIXME("(%p)->(%p)\n", This, p);
805 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
807 HTMLElement *This = impl_from_IHTMLElement(iface);
808 FIXME("(%p)->(%p)\n", This, p);
812 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
814 HTMLElement *This = impl_from_IHTMLElement(iface);
815 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
819 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
821 HTMLElement *This = impl_from_IHTMLElement(iface);
822 FIXME("(%p)->(%p)\n", This, p);
826 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
828 HTMLElement *This = impl_from_IHTMLElement(iface);
829 PRInt32 off_left = 0;
832 TRACE("(%p)->(%p)\n", This, p);
834 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, &off_left);
835 if(NS_FAILED(nsres)) {
836 ERR("GetOffsetLeft failed: %08x\n", nsres);
844 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
846 HTMLElement *This = impl_from_IHTMLElement(iface);
850 TRACE("(%p)->(%p)\n", This, p);
852 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, &top);
853 if(NS_FAILED(nsres)) {
854 ERR("GetOffsetTop failed: %08x\n", nsres);
862 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
864 HTMLElement *This = impl_from_IHTMLElement(iface);
868 TRACE("(%p)->(%p)\n", This, p);
870 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, &offset);
871 if(NS_FAILED(nsres)) {
872 ERR("GetOffsetWidth failed: %08x\n", nsres);
880 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
882 HTMLElement *This = impl_from_IHTMLElement(iface);
886 TRACE("(%p)->(%p)\n", This, p);
888 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, &offset);
889 if(NS_FAILED(nsres)) {
890 ERR("GetOffsetHeight failed: %08x\n", nsres);
898 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
900 HTMLElement *This = impl_from_IHTMLElement(iface);
901 nsIDOMElement *nsparent;
905 TRACE("(%p)->(%p)\n", This, p);
907 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
908 if(NS_FAILED(nsres)) {
909 ERR("GetOffsetParent failed: %08x\n", nsres);
916 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
917 nsIDOMElement_Release(nsparent);
921 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
931 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
933 HTMLElement *This = impl_from_IHTMLElement(iface);
937 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
940 FIXME("NULL nselem\n");
944 nsAString_InitDepend(&html_str, v);
945 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
946 nsAString_Finish(&html_str);
947 if(NS_FAILED(nsres)) {
948 FIXME("SetInnerHtml failed %08x\n", nsres);
955 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
957 HTMLElement *This = impl_from_IHTMLElement(iface);
961 TRACE("(%p)->(%p)\n", This, p);
964 FIXME("NULL nselem\n");
968 nsAString_Init(&html_str, NULL);
969 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
970 return return_nsstr(nsres, &html_str, p);
973 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
975 HTMLElement *This = impl_from_IHTMLElement(iface);
976 nsIDOMNode *nschild, *tmp;
977 nsIDOMText *text_node;
981 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
984 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
985 if(NS_FAILED(nsres)) {
986 ERR("GetLastChild failed: %08x\n", nsres);
992 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
993 nsIDOMNode_Release(nschild);
994 if(NS_FAILED(nsres)) {
995 ERR("RemoveChild failed: %08x\n", nsres);
998 nsIDOMNode_Release(tmp);
1001 nsAString_InitDepend(&text_str, v);
1002 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1003 nsAString_Finish(&text_str);
1004 if(NS_FAILED(nsres)) {
1005 ERR("CreateTextNode failed: %08x\n", nsres);
1009 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1010 if(NS_FAILED(nsres)) {
1011 ERR("AppendChild failed: %08x\n", nsres);
1015 nsIDOMNode_Release(tmp);
1019 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1021 HTMLElement *This = impl_from_IHTMLElement(iface);
1023 TRACE("(%p)->(%p)\n", This, p);
1025 return get_node_text(&This->node, p);
1028 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1030 HTMLElement *This = impl_from_IHTMLElement(iface);
1032 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1034 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1037 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1039 HTMLElement *This = impl_from_IHTMLElement(iface);
1043 WARN("(%p)->(%p) semi-stub\n", This, p);
1045 nsAString_Init(&html_str, NULL);
1046 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1047 if(SUCCEEDED(hres)) {
1048 const PRUnichar *html;
1050 nsAString_GetData(&html_str, &html);
1051 *p = SysAllocString(html);
1053 hres = E_OUTOFMEMORY;
1056 nsAString_Finish(&html_str);
1058 TRACE("ret %s\n", debugstr_w(*p));
1062 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1064 HTMLElement *This = impl_from_IHTMLElement(iface);
1065 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1069 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1071 HTMLElement *This = impl_from_IHTMLElement(iface);
1072 FIXME("(%p)->(%p)\n", This, p);
1076 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1078 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1079 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1080 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1081 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1084 if (!strcmpiW(where, wszBeforeBegin))
1088 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1089 if (!parent) return E_INVALIDARG;
1090 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1091 if (unused) nsIDOMNode_Release(unused);
1092 nsIDOMNode_Release(parent);
1094 else if (!strcmpiW(where, wszAfterBegin))
1097 nsIDOMNode *first_child;
1098 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1099 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1100 if (unused) nsIDOMNode_Release(unused);
1101 if (first_child) nsIDOMNode_Release(first_child);
1103 else if (!strcmpiW(where, wszBeforeEnd))
1106 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1107 if (unused) nsIDOMNode_Release(unused);
1109 else if (!strcmpiW(where, wszAfterEnd))
1112 nsIDOMNode *next_sibling;
1114 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1115 if (!parent) return E_INVALIDARG;
1117 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1120 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1121 nsIDOMNode_Release(next_sibling);
1124 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1125 nsIDOMNode_Release(parent);
1126 if (unused) nsIDOMNode_Release(unused);
1130 ERR("invalid where: %s\n", debugstr_w(where));
1131 return E_INVALIDARG;
1134 if (NS_FAILED(nsres))
1140 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1143 HTMLElement *This = impl_from_IHTMLElement(iface);
1150 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1152 if(!This->node.doc->nsdoc) {
1153 WARN("NULL nsdoc\n");
1154 return E_UNEXPECTED;
1157 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1158 if(NS_FAILED(nsres))
1160 ERR("CreateRange failed: %08x\n", nsres);
1164 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1166 nsAString_InitDepend(&ns_html, html);
1167 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1168 nsAString_Finish(&ns_html);
1169 nsIDOMRange_Release(range);
1171 if(NS_FAILED(nsres) || !nsnode)
1173 ERR("CreateTextNode failed: %08x\n", nsres);
1177 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1178 nsIDOMNode_Release(nsnode);
1183 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1186 HTMLElement *This = impl_from_IHTMLElement(iface);
1192 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1194 if(!This->node.doc->nsdoc) {
1195 WARN("NULL nsdoc\n");
1196 return E_UNEXPECTED;
1200 nsAString_InitDepend(&ns_text, text);
1201 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1202 nsAString_Finish(&ns_text);
1204 if(NS_FAILED(nsres) || !nsnode)
1206 ERR("CreateTextNode failed: %08x\n", nsres);
1210 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1211 nsIDOMNode_Release(nsnode);
1216 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1218 HTMLElement *This = impl_from_IHTMLElement(iface);
1219 FIXME("(%p)->(%p)\n", This, p);
1223 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1225 HTMLElement *This = impl_from_IHTMLElement(iface);
1226 FIXME("(%p)->(%p)\n", This, p);
1230 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1232 HTMLElement *This = impl_from_IHTMLElement(iface);
1234 TRACE("(%p)\n", This);
1236 return call_fire_event(&This->node, EVENTID_CLICK);
1239 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1240 IHTMLFiltersCollection **p)
1242 HTMLElement *This = impl_from_IHTMLElement(iface);
1243 TRACE("(%p)->(%p)\n", This, p);
1248 *p = HTMLFiltersCollection_Create();
1253 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1255 HTMLElement *This = impl_from_IHTMLElement(iface);
1256 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1260 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1262 HTMLElement *This = impl_from_IHTMLElement(iface);
1263 FIXME("(%p)->(%p)\n", This, p);
1267 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1269 HTMLElement *This = impl_from_IHTMLElement(iface);
1270 FIXME("(%p)->(%p)\n", This, String);
1274 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1276 HTMLElement *This = impl_from_IHTMLElement(iface);
1277 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1281 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1283 HTMLElement *This = impl_from_IHTMLElement(iface);
1284 FIXME("(%p)->(%p)\n", This, p);
1288 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1290 HTMLElement *This = impl_from_IHTMLElement(iface);
1291 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1295 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1297 HTMLElement *This = impl_from_IHTMLElement(iface);
1298 FIXME("(%p)->(%p)\n", This, p);
1302 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1304 HTMLElement *This = impl_from_IHTMLElement(iface);
1305 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1309 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1311 HTMLElement *This = impl_from_IHTMLElement(iface);
1312 FIXME("(%p)->(%p)\n", This, p);
1316 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1318 HTMLElement *This = impl_from_IHTMLElement(iface);
1319 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1323 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1325 HTMLElement *This = impl_from_IHTMLElement(iface);
1326 FIXME("(%p)->(%p)\n", This, p);
1330 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1332 HTMLElement *This = impl_from_IHTMLElement(iface);
1333 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1337 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1339 HTMLElement *This = impl_from_IHTMLElement(iface);
1340 FIXME("(%p)->(%p)\n", This, p);
1344 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1346 HTMLElement *This = impl_from_IHTMLElement(iface);
1347 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1351 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1353 HTMLElement *This = impl_from_IHTMLElement(iface);
1354 FIXME("(%p)->(%p)\n", This, p);
1358 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1360 HTMLElement *This = impl_from_IHTMLElement(iface);
1361 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1365 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1367 HTMLElement *This = impl_from_IHTMLElement(iface);
1368 FIXME("(%p)->(%p)\n", This, p);
1372 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1374 HTMLElement *This = impl_from_IHTMLElement(iface);
1375 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1379 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1381 HTMLElement *This = impl_from_IHTMLElement(iface);
1382 FIXME("(%p)->(%p)\n", This, p);
1386 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1388 HTMLElement *This = impl_from_IHTMLElement(iface);
1389 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1393 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1395 HTMLElement *This = impl_from_IHTMLElement(iface);
1396 FIXME("(%p)->(%p)\n", This, p);
1400 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1402 HTMLElement *This = impl_from_IHTMLElement(iface);
1403 nsIDOMNodeList *nsnode_list;
1406 TRACE("(%p)->(%p)\n", This, p);
1408 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1409 if(NS_FAILED(nsres)) {
1410 ERR("GetChildNodes failed: %08x\n", nsres);
1414 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1416 nsIDOMNodeList_Release(nsnode_list);
1420 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1422 HTMLElement *This = impl_from_IHTMLElement(iface);
1424 TRACE("(%p)->(%p)\n", This, p);
1426 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1430 static const IHTMLElementVtbl HTMLElementVtbl = {
1431 HTMLElement_QueryInterface,
1433 HTMLElement_Release,
1434 HTMLElement_GetTypeInfoCount,
1435 HTMLElement_GetTypeInfo,
1436 HTMLElement_GetIDsOfNames,
1438 HTMLElement_setAttribute,
1439 HTMLElement_getAttribute,
1440 HTMLElement_removeAttribute,
1441 HTMLElement_put_className,
1442 HTMLElement_get_className,
1445 HTMLElement_get_tagName,
1446 HTMLElement_get_parentElement,
1447 HTMLElement_get_style,
1448 HTMLElement_put_onhelp,
1449 HTMLElement_get_onhelp,
1450 HTMLElement_put_onclick,
1451 HTMLElement_get_onclick,
1452 HTMLElement_put_ondblclick,
1453 HTMLElement_get_ondblclick,
1454 HTMLElement_put_onkeydown,
1455 HTMLElement_get_onkeydown,
1456 HTMLElement_put_onkeyup,
1457 HTMLElement_get_onkeyup,
1458 HTMLElement_put_onkeypress,
1459 HTMLElement_get_onkeypress,
1460 HTMLElement_put_onmouseout,
1461 HTMLElement_get_onmouseout,
1462 HTMLElement_put_onmouseover,
1463 HTMLElement_get_onmouseover,
1464 HTMLElement_put_onmousemove,
1465 HTMLElement_get_onmousemove,
1466 HTMLElement_put_onmousedown,
1467 HTMLElement_get_onmousedown,
1468 HTMLElement_put_onmouseup,
1469 HTMLElement_get_onmouseup,
1470 HTMLElement_get_document,
1471 HTMLElement_put_title,
1472 HTMLElement_get_title,
1473 HTMLElement_put_language,
1474 HTMLElement_get_language,
1475 HTMLElement_put_onselectstart,
1476 HTMLElement_get_onselectstart,
1477 HTMLElement_scrollIntoView,
1478 HTMLElement_contains,
1479 HTMLElement_get_sourceIndex,
1480 HTMLElement_get_recordNumber,
1481 HTMLElement_put_lang,
1482 HTMLElement_get_lang,
1483 HTMLElement_get_offsetLeft,
1484 HTMLElement_get_offsetTop,
1485 HTMLElement_get_offsetWidth,
1486 HTMLElement_get_offsetHeight,
1487 HTMLElement_get_offsetParent,
1488 HTMLElement_put_innerHTML,
1489 HTMLElement_get_innerHTML,
1490 HTMLElement_put_innerText,
1491 HTMLElement_get_innerText,
1492 HTMLElement_put_outerHTML,
1493 HTMLElement_get_outerHTML,
1494 HTMLElement_put_outerText,
1495 HTMLElement_get_outerText,
1496 HTMLElement_insertAdjacentHTML,
1497 HTMLElement_insertAdjacentText,
1498 HTMLElement_get_parentTextEdit,
1499 HTMLElement_get_isTextEdit,
1501 HTMLElement_get_filters,
1502 HTMLElement_put_ondragstart,
1503 HTMLElement_get_ondragstart,
1504 HTMLElement_toString,
1505 HTMLElement_put_onbeforeupdate,
1506 HTMLElement_get_onbeforeupdate,
1507 HTMLElement_put_onafterupdate,
1508 HTMLElement_get_onafterupdate,
1509 HTMLElement_put_onerrorupdate,
1510 HTMLElement_get_onerrorupdate,
1511 HTMLElement_put_onrowexit,
1512 HTMLElement_get_onrowexit,
1513 HTMLElement_put_onrowenter,
1514 HTMLElement_get_onrowenter,
1515 HTMLElement_put_ondatasetchanged,
1516 HTMLElement_get_ondatasetchanged,
1517 HTMLElement_put_ondataavailable,
1518 HTMLElement_get_ondataavailable,
1519 HTMLElement_put_ondatasetcomplete,
1520 HTMLElement_get_ondatasetcomplete,
1521 HTMLElement_put_onfilterchange,
1522 HTMLElement_get_onfilterchange,
1523 HTMLElement_get_children,
1527 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1529 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1532 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1534 return CONTAINING_RECORD(iface, HTMLElement, node);
1537 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1539 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1543 if(IsEqualGUID(&IID_IUnknown, riid)) {
1544 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1545 *ppv = &This->IHTMLElement_iface;
1546 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1547 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1548 *ppv = &This->IHTMLElement_iface;
1549 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1550 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1551 *ppv = &This->IHTMLElement_iface;
1552 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1553 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1554 *ppv = &This->IHTMLElement2_iface;
1555 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1556 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1557 *ppv = &This->IHTMLElement3_iface;
1558 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1559 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1560 *ppv = &This->IHTMLElement4_iface;
1561 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1562 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1563 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1567 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1571 return HTMLDOMNode_QI(&This->node, riid, ppv);
1574 void HTMLElement_destructor(HTMLDOMNode *iface)
1576 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1578 ConnectionPointContainer_Destroy(&This->cp_container);
1581 This->style->elem = NULL;
1582 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1584 if(This->runtime_style) {
1585 This->runtime_style->elem = NULL;
1586 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
1589 HTMLDOMAttribute *attr;
1591 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
1594 This->attrs->elem = NULL;
1595 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
1598 heap_free(This->filter);
1600 HTMLDOMNode_destructor(&This->node);
1603 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1605 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1606 HTMLElement *new_elem;
1609 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1614 new_elem->filter = heap_strdupW(This->filter);
1615 if(!new_elem->filter) {
1616 IHTMLElement_Release(&This->IHTMLElement_iface);
1617 return E_OUTOFMEMORY;
1621 *ret = &new_elem->node;
1625 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
1627 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1630 case EVENTID_KEYDOWN: {
1631 nsIDOMKeyEvent *key_event;
1634 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
1635 if(NS_SUCCEEDED(nsres)) {
1638 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
1641 case VK_F1: /* DOM_VK_F1 */
1642 TRACE("F1 pressed\n");
1643 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL);
1644 *prevent_default = TRUE;
1647 nsIDOMKeyEvent_Release(key_event);
1655 static const NodeImplVtbl HTMLElementImplVtbl = {
1657 HTMLElement_destructor,
1659 HTMLElement_handle_event,
1660 HTMLElement_get_attr_col
1663 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1665 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1668 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1669 DWORD grfdex, DISPID *pid)
1671 HTMLElement *This = impl_from_DispatchEx(dispex);
1673 if(This->node.vtbl->get_dispid)
1674 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1676 return DISP_E_UNKNOWNNAME;
1679 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1680 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1681 IServiceProvider *caller)
1683 HTMLElement *This = impl_from_DispatchEx(dispex);
1685 if(This->node.vtbl->invoke)
1686 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1687 params, res, ei, caller);
1689 ERR("(%p): element has no invoke method\n", This);
1693 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
1695 HTMLElement *This = impl_from_DispatchEx(dispex);
1696 nsIDOMNamedNodeMap *attrs;
1699 const PRUnichar *str;
1711 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
1712 if(NS_FAILED(nsres))
1715 nsres = nsIDOMNamedNodeMap_GetLength(attrs, &len);
1716 if(NS_FAILED(nsres)) {
1717 nsIDOMNamedNodeMap_Release(attrs);
1721 nsAString_Init(&nsstr, NULL);
1722 for(i=0; i<len; i++) {
1723 nsres = nsIDOMNamedNodeMap_Item(attrs, i, &node);
1724 if(NS_FAILED(nsres))
1727 nsres = nsIDOMNode_GetNodeName(node, &nsstr);
1728 if(NS_FAILED(nsres)) {
1729 nsIDOMNode_Release(node);
1733 nsAString_GetData(&nsstr, &str);
1734 name = SysAllocString(str);
1736 nsIDOMNode_Release(node);
1740 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
1741 if(hres != DISP_E_UNKNOWNNAME) {
1742 nsIDOMNode_Release(node);
1743 SysFreeString(name);
1747 nsres = nsIDOMNode_GetNodeValue(node, &nsstr);
1748 nsIDOMNode_Release(node);
1749 if(NS_FAILED(nsres)) {
1750 SysFreeString(name);
1754 nsAString_GetData(&nsstr, &str);
1755 V_VT(&value) = VT_BSTR;
1757 V_BSTR(&value) = SysAllocString(str);
1758 if(!V_BSTR(&value)) {
1759 SysFreeString(name);
1763 V_BSTR(&value) = NULL;
1765 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
1766 SysFreeString(name);
1767 VariantClear(&value);
1769 nsAString_Finish(&nsstr);
1771 nsIDOMNamedNodeMap_Release(attrs);
1775 static const tid_t HTMLElement_iface_tids[] = {
1780 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1782 HTMLElement_get_dispid,
1784 HTMLElement_populate_props
1787 static dispex_static_data_t HTMLElement_dispex = {
1788 &HTMLElement_dispex_vtbl,
1789 DispHTMLUnknownElement_tid,
1791 HTMLElement_iface_tids
1794 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1796 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1798 HTMLElement2_Init(This);
1799 HTMLElement3_Init(This);
1801 if(dispex_data && !dispex_data->vtbl)
1802 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1803 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1804 dispex_data ? dispex_data : &HTMLElement_dispex);
1807 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1809 /* No AddRef, share reference with HTMLDOMNode */
1810 assert((nsIDOMNode*)nselem == This->node.nsnode);
1811 This->nselem = nselem;
1814 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1817 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1819 nsIDOMHTMLElement *nselem;
1820 nsAString class_name_str;
1821 const PRUnichar *class_name;
1822 const tag_desc_t *tag;
1827 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1828 if(NS_FAILED(nsres))
1831 nsAString_Init(&class_name_str, NULL);
1832 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1834 nsAString_GetData(&class_name_str, &class_name);
1836 tag = get_tag_desc(class_name);
1838 hres = tag->constructor(doc, nselem, &elem);
1839 }else if(use_generic) {
1840 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1842 elem = heap_alloc_zero(sizeof(HTMLElement));
1844 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1845 elem->node.vtbl = &HTMLElementImplVtbl;
1848 hres = E_OUTOFMEMORY;
1852 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1854 nsIDOMHTMLElement_Release(nselem);
1855 nsAString_Finish(&class_name_str);
1863 /* interface IHTMLFiltersCollection */
1864 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1866 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1868 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1870 if(IsEqualGUID(&IID_IUnknown, riid)) {
1871 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1872 *ppv = &This->IHTMLFiltersCollection_iface;
1873 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1874 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1875 *ppv = &This->IHTMLFiltersCollection_iface;
1876 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1877 return *ppv ? S_OK : E_NOINTERFACE;
1881 IUnknown_AddRef((IUnknown*)*ppv);
1885 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1886 return E_NOINTERFACE;
1889 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1891 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1892 LONG ref = InterlockedIncrement(&This->ref);
1894 TRACE("(%p) ref=%d\n", This, ref);
1899 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1901 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1902 LONG ref = InterlockedDecrement(&This->ref);
1904 TRACE("(%p) ref=%d\n", This, ref);
1914 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1916 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1917 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1920 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1921 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1923 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1924 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1927 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1928 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1929 LCID lcid, DISPID *rgDispId)
1931 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1932 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1936 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1937 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1938 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1940 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1941 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1942 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1945 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1947 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1952 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1958 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1960 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1961 FIXME("(%p)->(%p)\n", This, p);
1965 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
1967 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1968 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
1972 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
1973 HTMLFiltersCollection_QueryInterface,
1974 HTMLFiltersCollection_AddRef,
1975 HTMLFiltersCollection_Release,
1976 HTMLFiltersCollection_GetTypeInfoCount,
1977 HTMLFiltersCollection_GetTypeInfo,
1978 HTMLFiltersCollection_GetIDsOfNames,
1979 HTMLFiltersCollection_Invoke,
1980 HTMLFiltersCollection_get_length,
1981 HTMLFiltersCollection_get__newEnum,
1982 HTMLFiltersCollection_item
1985 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1990 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
1991 idx = idx*10 + (*ptr-'0');
1993 return DISP_E_UNKNOWNNAME;
1995 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
1996 TRACE("ret %x\n", *dispid);
2000 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2001 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2003 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
2005 V_VT(res) = VT_DISPATCH;
2006 V_DISPATCH(res) = NULL;
2008 FIXME("always returning NULL\n");
2013 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
2015 HTMLFiltersCollection_get_dispid,
2016 HTMLFiltersCollection_invoke,
2020 static const tid_t HTMLFiltersCollection_iface_tids[] = {
2021 IHTMLFiltersCollection_tid,
2024 static dispex_static_data_t HTMLFiltersCollection_dispex = {
2025 &HTMLFiltersCollection_dispex_vtbl,
2026 IHTMLFiltersCollection_tid,
2028 HTMLFiltersCollection_iface_tids
2031 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
2033 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
2035 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2038 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2039 &HTMLFiltersCollection_dispex);
2041 return &ret->IHTMLFiltersCollection_iface;
2044 /* interface IHTMLAttributeCollection */
2045 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
2047 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
2050 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
2052 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2056 if(IsEqualGUID(&IID_IUnknown, riid)) {
2057 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
2058 *ppv = &This->IHTMLAttributeCollection_iface;
2059 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
2060 TRACE("(%p)->(IID_IHTMLAttributeCollection %p)\n", This, ppv);
2061 *ppv = &This->IHTMLAttributeCollection_iface;
2062 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
2063 TRACE("(%p)->(IID_IHTMLAttributeCollection2 %p)\n", This, ppv);
2064 *ppv = &This->IHTMLAttributeCollection2_iface;
2065 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
2066 TRACE("(%p)->(IID_IHTMLAttributeCollection3 %p)\n", This, ppv);
2067 *ppv = &This->IHTMLAttributeCollection3_iface;
2068 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2069 return *ppv ? S_OK : E_NOINTERFACE;
2073 IUnknown_AddRef((IUnknown*)*ppv);
2077 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2078 return E_NOINTERFACE;
2081 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
2083 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2084 LONG ref = InterlockedIncrement(&This->ref);
2086 TRACE("(%p) ref=%d\n", This, ref);
2091 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
2093 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2094 LONG ref = InterlockedDecrement(&This->ref);
2096 TRACE("(%p) ref=%d\n", This, ref);
2099 while(!list_empty(&This->attrs)) {
2100 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
2102 list_remove(&attr->entry);
2104 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2113 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
2115 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2116 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2119 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
2120 LCID lcid, ITypeInfo **ppTInfo)
2122 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2123 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2126 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
2127 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2129 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2130 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2134 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
2135 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2136 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2138 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2139 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2140 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2143 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
2145 IDispatchEx *dispex = &This->elem->node.dispex.IDispatchEx_iface;
2146 DISPID id = DISPID_STARTENUM;
2150 FIXME("filter non-enumerable attributes out\n");
2153 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
2156 else if(hres == S_FALSE)
2166 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
2173 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
2177 if(name[0]>='0' && name[0]<='9') {
2181 idx = strtoulW(name, &end_ptr, 10);
2183 hres = get_attr_dispid_by_idx(This, &idx, id);
2190 WARN("NULL elem\n");
2191 return E_UNEXPECTED;
2194 hres = IDispatchEx_GetDispID(&This->elem->node.dispex.IDispatchEx_iface,
2195 name, fdexNameCaseInsensitive, id);
2199 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
2201 HTMLDOMAttribute *iter;
2206 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2207 if(iter->dispid == id) {
2216 WARN("NULL elem\n");
2217 return E_UNEXPECTED;
2221 hres = HTMLDOMAttribute_Create(This->elem, id, attr);
2226 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
2232 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
2234 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2237 TRACE("(%p)->(%p)\n", This, p);
2240 hres = get_attr_dispid_by_idx(This, p, NULL);
2244 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
2246 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2247 FIXME("(%p)->(%p)\n", This, p);
2251 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
2253 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2254 HTMLDOMAttribute *attr;
2258 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
2260 switch(V_VT(name)) {
2262 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
2265 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
2268 FIXME("unsupported name %s\n", debugstr_variant(name));
2271 if(hres == DISP_E_UNKNOWNNAME)
2272 return E_INVALIDARG;
2276 hres = get_domattr(This, id, NULL, &attr);
2280 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
2284 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
2285 HTMLAttributeCollection_QueryInterface,
2286 HTMLAttributeCollection_AddRef,
2287 HTMLAttributeCollection_Release,
2288 HTMLAttributeCollection_GetTypeInfoCount,
2289 HTMLAttributeCollection_GetTypeInfo,
2290 HTMLAttributeCollection_GetIDsOfNames,
2291 HTMLAttributeCollection_Invoke,
2292 HTMLAttributeCollection_get_length,
2293 HTMLAttributeCollection__newEnum,
2294 HTMLAttributeCollection_item
2297 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
2299 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
2302 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
2304 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2305 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2308 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
2310 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2311 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2314 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
2316 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2317 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2320 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
2322 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2323 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2326 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
2327 LCID lcid, ITypeInfo **ppTInfo)
2329 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2330 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2333 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
2334 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2336 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2337 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2341 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
2342 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2343 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2345 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2346 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2347 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2350 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
2351 IHTMLDOMAttribute **newretNode)
2353 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2354 HTMLDOMAttribute *attr;
2358 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2360 hres = get_attr_dispid_by_name(This, bstrName, &id);
2361 if(hres == DISP_E_UNKNOWNNAME) {
2364 } else if(FAILED(hres)) {
2368 hres = get_domattr(This, id, NULL, &attr);
2372 *newretNode = &attr->IHTMLDOMAttribute_iface;
2376 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
2377 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
2379 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2380 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
2384 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
2385 BSTR bstrName, IHTMLDOMAttribute **newretNode)
2387 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2388 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2392 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
2393 HTMLAttributeCollection2_QueryInterface,
2394 HTMLAttributeCollection2_AddRef,
2395 HTMLAttributeCollection2_Release,
2396 HTMLAttributeCollection2_GetTypeInfoCount,
2397 HTMLAttributeCollection2_GetTypeInfo,
2398 HTMLAttributeCollection2_GetIDsOfNames,
2399 HTMLAttributeCollection2_Invoke,
2400 HTMLAttributeCollection2_getNamedItem,
2401 HTMLAttributeCollection2_setNamedItem,
2402 HTMLAttributeCollection2_removeNamedItem
2405 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
2407 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
2410 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
2412 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2413 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2416 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
2418 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2419 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2422 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
2424 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2425 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2428 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
2430 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2431 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2434 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
2435 LCID lcid, ITypeInfo **ppTInfo)
2437 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2438 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2441 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
2442 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2444 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2445 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2449 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
2450 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2451 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2453 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2454 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2455 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2458 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
2459 IHTMLDOMAttribute **ppNodeOut)
2461 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2462 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
2465 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
2466 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
2468 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2469 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
2473 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
2474 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
2476 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2477 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
2481 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
2483 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2484 HTMLDOMAttribute *attr;
2488 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
2490 hres = get_attr_dispid_by_idx(This, &index, &id);
2491 if(hres == DISP_E_UNKNOWNNAME)
2492 return E_INVALIDARG;
2496 hres = get_domattr(This, id, NULL, &attr);
2500 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
2504 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
2506 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2507 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
2510 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
2511 HTMLAttributeCollection3_QueryInterface,
2512 HTMLAttributeCollection3_AddRef,
2513 HTMLAttributeCollection3_Release,
2514 HTMLAttributeCollection3_GetTypeInfoCount,
2515 HTMLAttributeCollection3_GetTypeInfo,
2516 HTMLAttributeCollection3_GetIDsOfNames,
2517 HTMLAttributeCollection3_Invoke,
2518 HTMLAttributeCollection3_getNamedItem,
2519 HTMLAttributeCollection3_setNamedItem,
2520 HTMLAttributeCollection3_removeNamedItem,
2521 HTMLAttributeCollection3_item,
2522 HTMLAttributeCollection3_get_length
2525 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
2527 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
2530 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
2532 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2533 HTMLDOMAttribute *attr;
2537 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
2539 hres = get_attr_dispid_by_name(This, name, dispid);
2543 hres = get_domattr(This, *dispid, &pos, &attr);
2546 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2548 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
2552 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
2553 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2555 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2557 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
2560 case DISPATCH_PROPERTYGET: {
2561 HTMLDOMAttribute *iter;
2563 id = id-MSHTML_DISPID_CUSTOM_MIN+1;
2565 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2570 return E_INVALIDARG;
2572 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
2573 V_VT(res) = VT_DISPATCH;
2574 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
2579 FIXME("unimplemented flags %x\n", flags);
2584 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
2586 HTMLAttributeCollection_get_dispid,
2587 HTMLAttributeCollection_invoke,
2591 static const tid_t HTMLAttributeCollection_iface_tids[] = {
2592 IHTMLAttributeCollection_tid,
2593 IHTMLAttributeCollection2_tid,
2594 IHTMLAttributeCollection3_tid,
2598 static dispex_static_data_t HTMLAttributeCollection_dispex = {
2599 &HTMLAttributeCollection_dispex_vtbl,
2600 DispHTMLAttributeCollection_tid,
2602 HTMLAttributeCollection_iface_tids
2605 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
2607 HTMLElement *This = impl_from_HTMLDOMNode(iface);
2610 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
2615 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
2617 return E_OUTOFMEMORY;
2619 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
2620 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
2621 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
2622 This->attrs->ref = 2;
2624 This->attrs->elem = This;
2625 list_init(&This->attrs->attrs);
2626 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
2627 &HTMLAttributeCollection_dispex);