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 linkW[] = {'L','I','N','K',0};
49 static const WCHAR metaW[] = {'M','E','T','A',0};
50 static const WCHAR objectW[] = {'O','B','J','E','C','T',0};
51 static const WCHAR optionW[] = {'O','P','T','I','O','N',0};
52 static const WCHAR scriptW[] = {'S','C','R','I','P','T',0};
53 static const WCHAR selectW[] = {'S','E','L','E','C','T',0};
54 static const WCHAR styleW[] = {'S','T','Y','L','E',0};
55 static const WCHAR tableW[] = {'T','A','B','L','E',0};
56 static const WCHAR tdW[] = {'T','D',0};
57 static const WCHAR textareaW[] = {'T','E','X','T','A','R','E','A',0};
58 static const WCHAR title_tagW[]= {'T','I','T','L','E',0};
59 static const WCHAR trW[] = {'T','R',0};
63 HRESULT (*constructor)(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
66 static const tag_desc_t tag_descs[] = {
67 {aW, HTMLAnchorElement_Create},
68 {bodyW, HTMLBodyElement_Create},
69 {embedW, HTMLEmbedElement_Create},
70 {formW, HTMLFormElement_Create},
71 {frameW, HTMLFrameElement_Create},
72 {headW, HTMLHeadElement_Create},
73 {iframeW, HTMLIFrame_Create},
74 {imgW, HTMLImgElement_Create},
75 {inputW, HTMLInputElement_Create},
76 {linkW, HTMLLinkElement_Create},
77 {metaW, HTMLMetaElement_Create},
78 {objectW, HTMLObjectElement_Create},
79 {optionW, HTMLOptionElement_Create},
80 {scriptW, HTMLScriptElement_Create},
81 {selectW, HTMLSelectElement_Create},
82 {styleW, HTMLStyleElement_Create},
83 {tableW, HTMLTable_Create},
84 {tdW, HTMLTableCell_Create},
85 {textareaW, HTMLTextAreaElement_Create},
86 {title_tagW, HTMLTitleElement_Create},
87 {trW, HTMLTableRow_Create}
90 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
92 DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
97 r = strcmpW(tag_name, tag_descs[i].name);
110 HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html)
112 nsIDOMDocumentFragment *nsfragment;
113 nsIDOMNode *nsparent;
119 nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range);
120 if(NS_FAILED(nsres)) {
121 ERR("CreateRange failed: %08x\n", nsres);
125 nsAString_InitDepend(&html_str, html);
126 nsIDOMRange_CreateContextualFragment(range, &html_str, &nsfragment);
127 nsIDOMRange_Release(range);
128 nsAString_Finish(&html_str);
129 if(NS_FAILED(nsres)) {
130 ERR("CreateContextualFragment failed: %08x\n", nsres);
134 nsres = nsIDOMNode_GetParentNode(nsnode, &nsparent);
135 if(NS_SUCCEEDED(nsres) && nsparent) {
138 nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, nsnode, &nstmp);
139 nsIDOMNode_Release(nsparent);
140 if(NS_FAILED(nsres)) {
141 ERR("ReplaceChild failed: %08x\n", nsres);
144 nsIDOMNode_Release(nstmp);
147 ERR("GetParentNode failed: %08x\n", nsres);
151 nsIDOMDocumentFragment_Release(nsfragment);
158 IHTMLFiltersCollection IHTMLFiltersCollection_iface;
161 } HTMLFiltersCollection;
163 static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface)
165 return CONTAINING_RECORD(iface, HTMLFiltersCollection, IHTMLFiltersCollection_iface);
168 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
170 static inline HTMLElement *impl_from_IHTMLElement(IHTMLElement *iface)
172 return CONTAINING_RECORD(iface, HTMLElement, IHTMLElement_iface);
175 HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
177 nsIDOMElement *nselem;
182 WARN("NULL nsdoc\n");
186 nsAString_InitDepend(&tag_str, tag);
187 nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, &nselem);
188 nsAString_Finish(&tag_str);
189 if(NS_FAILED(nsres)) {
190 ERR("CreateElement failed: %08x\n", nsres);
194 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
195 nsIDOMElement_Release(nselem);
196 if(NS_FAILED(nsres)) {
197 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
204 HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **ret)
206 nsIDOMHTMLElement *nselem;
209 /* Use owner doc if called on document fragment */
213 hres = create_nselem(doc, tag, &nselem);
217 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, TRUE, ret);
218 nsIDOMHTMLElement_Release(nselem);
222 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
223 REFIID riid, void **ppv)
225 HTMLElement *This = impl_from_IHTMLElement(iface);
227 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
230 static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
232 HTMLElement *This = impl_from_IHTMLElement(iface);
234 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
237 static ULONG WINAPI HTMLElement_Release(IHTMLElement *iface)
239 HTMLElement *This = impl_from_IHTMLElement(iface);
241 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
244 static HRESULT WINAPI HTMLElement_GetTypeInfoCount(IHTMLElement *iface, UINT *pctinfo)
246 HTMLElement *This = impl_from_IHTMLElement(iface);
247 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
250 static HRESULT WINAPI HTMLElement_GetTypeInfo(IHTMLElement *iface, UINT iTInfo,
251 LCID lcid, ITypeInfo **ppTInfo)
253 HTMLElement *This = impl_from_IHTMLElement(iface);
254 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
257 static HRESULT WINAPI HTMLElement_GetIDsOfNames(IHTMLElement *iface, REFIID riid,
258 LPOLESTR *rgszNames, UINT cNames,
259 LCID lcid, DISPID *rgDispId)
261 HTMLElement *This = impl_from_IHTMLElement(iface);
262 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
266 static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMember,
267 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
268 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
270 HTMLElement *This = impl_from_IHTMLElement(iface);
271 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
272 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
275 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
276 VARIANT AttributeValue, LONG lFlags)
278 HTMLElement *This = impl_from_IHTMLElement(iface);
280 DISPID dispid, dispidNamed = DISPID_PROPERTYPUT;
281 DISPPARAMS dispParams;
284 TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
286 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
287 fdexNameCaseInsensitive | fdexNameEnsure, &dispid);
291 dispParams.cArgs = 1;
292 dispParams.cNamedArgs = 1;
293 dispParams.rgdispidNamedArgs = &dispidNamed;
294 dispParams.rgvarg = &AttributeValue;
296 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid,
297 LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
301 static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
302 LONG lFlags, VARIANT *AttributeValue)
304 HTMLElement *This = impl_from_IHTMLElement(iface);
307 DISPPARAMS dispParams = {NULL, NULL, 0, 0};
310 TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
312 hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
313 fdexNameCaseInsensitive, &dispid);
314 if(hres == DISP_E_UNKNOWNNAME) {
315 V_VT(AttributeValue) = VT_NULL;
320 V_VT(AttributeValue) = VT_NULL;
324 hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
325 DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
330 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
331 LONG lFlags, VARIANT_BOOL *pfSuccess)
333 HTMLElement *This = impl_from_IHTMLElement(iface);
335 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
337 return remove_prop(&This->node.dispex, strAttributeName, pfSuccess);
340 static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v)
342 HTMLElement *This = impl_from_IHTMLElement(iface);
343 nsAString classname_str;
346 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
349 FIXME("NULL nselem\n");
353 nsAString_InitDepend(&classname_str, v);
354 nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str);
355 nsAString_Finish(&classname_str);
357 ERR("SetClassName failed: %08x\n", nsres);
362 static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
364 HTMLElement *This = impl_from_IHTMLElement(iface);
368 TRACE("(%p)->(%p)\n", This, p);
371 FIXME("NULL nselem\n");
375 nsAString_Init(&class_str, NULL);
376 nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
377 return return_nsstr(nsres, &class_str, p);
380 static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
382 HTMLElement *This = impl_from_IHTMLElement(iface);
386 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
389 FIXME("nselem == NULL\n");
393 nsAString_InitDepend(&id_str, v);
394 nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str);
395 nsAString_Finish(&id_str);
397 ERR("SetId failed: %08x\n", nsres);
402 static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
404 HTMLElement *This = impl_from_IHTMLElement(iface);
408 TRACE("(%p)->(%p)\n", This, p);
415 nsAString_Init(&id_str, NULL);
416 nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
417 return return_nsstr(nsres, &id_str, p);
420 static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
422 HTMLElement *This = impl_from_IHTMLElement(iface);
426 TRACE("(%p)->(%p)\n", This, p);
429 static const WCHAR comment_tagW[] = {'!',0};
431 WARN("NULL nselem, assuming comment\n");
433 *p = SysAllocString(comment_tagW);
434 return *p ? S_OK : E_OUTOFMEMORY;
437 nsAString_Init(&tag_str, NULL);
438 nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
439 return return_nsstr(nsres, &tag_str, p);
442 static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
444 HTMLElement *This = impl_from_IHTMLElement(iface);
448 TRACE("(%p)->(%p)\n", This, p);
450 hres = IHTMLDOMNode_get_parentNode(&This->node.IHTMLDOMNode_iface, &node);
454 hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p);
455 IHTMLDOMNode_Release(node);
462 static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
464 HTMLElement *This = impl_from_IHTMLElement(iface);
466 TRACE("(%p)->(%p)\n", This, p);
471 hres = HTMLStyle_Create(This, &This->style);
476 *p = &This->style->IHTMLStyle_iface;
477 IHTMLStyle_AddRef(*p);
481 static HRESULT WINAPI HTMLElement_put_onhelp(IHTMLElement *iface, VARIANT v)
483 HTMLElement *This = impl_from_IHTMLElement(iface);
484 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
488 static HRESULT WINAPI HTMLElement_get_onhelp(IHTMLElement *iface, VARIANT *p)
490 HTMLElement *This = impl_from_IHTMLElement(iface);
491 FIXME("(%p)->(%p)\n", This, p);
495 static HRESULT WINAPI HTMLElement_put_onclick(IHTMLElement *iface, VARIANT v)
497 HTMLElement *This = impl_from_IHTMLElement(iface);
499 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
501 return set_node_event(&This->node, EVENTID_CLICK, &v);
504 static HRESULT WINAPI HTMLElement_get_onclick(IHTMLElement *iface, VARIANT *p)
506 HTMLElement *This = impl_from_IHTMLElement(iface);
508 TRACE("(%p)->(%p)\n", This, p);
510 return get_node_event(&This->node, EVENTID_CLICK, p);
513 static HRESULT WINAPI HTMLElement_put_ondblclick(IHTMLElement *iface, VARIANT v)
515 HTMLElement *This = impl_from_IHTMLElement(iface);
517 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
519 return set_node_event(&This->node, EVENTID_DBLCLICK, &v);
522 static HRESULT WINAPI HTMLElement_get_ondblclick(IHTMLElement *iface, VARIANT *p)
524 HTMLElement *This = impl_from_IHTMLElement(iface);
526 TRACE("(%p)->(%p)\n", This, p);
528 return get_node_event(&This->node, EVENTID_DBLCLICK, p);
531 static HRESULT WINAPI HTMLElement_put_onkeydown(IHTMLElement *iface, VARIANT v)
533 HTMLElement *This = impl_from_IHTMLElement(iface);
535 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
537 return set_node_event(&This->node, EVENTID_KEYDOWN, &v);
540 static HRESULT WINAPI HTMLElement_get_onkeydown(IHTMLElement *iface, VARIANT *p)
542 HTMLElement *This = impl_from_IHTMLElement(iface);
544 TRACE("(%p)->(%p)\n", This, p);
546 return get_node_event(&This->node, EVENTID_KEYDOWN, p);
549 static HRESULT WINAPI HTMLElement_put_onkeyup(IHTMLElement *iface, VARIANT v)
551 HTMLElement *This = impl_from_IHTMLElement(iface);
553 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
555 return set_node_event(&This->node, EVENTID_KEYUP, &v);
558 static HRESULT WINAPI HTMLElement_get_onkeyup(IHTMLElement *iface, VARIANT *p)
560 HTMLElement *This = impl_from_IHTMLElement(iface);
561 FIXME("(%p)->(%p)\n", This, p);
565 static HRESULT WINAPI HTMLElement_put_onkeypress(IHTMLElement *iface, VARIANT v)
567 HTMLElement *This = impl_from_IHTMLElement(iface);
569 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
571 return set_node_event(&This->node, EVENTID_KEYPRESS, &v);
574 static HRESULT WINAPI HTMLElement_get_onkeypress(IHTMLElement *iface, VARIANT *p)
576 HTMLElement *This = impl_from_IHTMLElement(iface);
578 TRACE("(%p)->(%p)\n", This, p);
580 return get_node_event(&This->node, EVENTID_KEYPRESS, p);
583 static HRESULT WINAPI HTMLElement_put_onmouseout(IHTMLElement *iface, VARIANT v)
585 HTMLElement *This = impl_from_IHTMLElement(iface);
587 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
589 return set_node_event(&This->node, EVENTID_MOUSEOUT, &v);
592 static HRESULT WINAPI HTMLElement_get_onmouseout(IHTMLElement *iface, VARIANT *p)
594 HTMLElement *This = impl_from_IHTMLElement(iface);
596 TRACE("(%p)->(%p)\n", This, p);
598 return get_node_event(&This->node, EVENTID_MOUSEOUT, p);
601 static HRESULT WINAPI HTMLElement_put_onmouseover(IHTMLElement *iface, VARIANT v)
603 HTMLElement *This = impl_from_IHTMLElement(iface);
605 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
607 return set_node_event(&This->node, EVENTID_MOUSEOVER, &v);
610 static HRESULT WINAPI HTMLElement_get_onmouseover(IHTMLElement *iface, VARIANT *p)
612 HTMLElement *This = impl_from_IHTMLElement(iface);
614 TRACE("(%p)->(%p)\n", This, p);
616 return get_node_event(&This->node, EVENTID_MOUSEOVER, p);
619 static HRESULT WINAPI HTMLElement_put_onmousemove(IHTMLElement *iface, VARIANT v)
621 HTMLElement *This = impl_from_IHTMLElement(iface);
623 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
625 return set_node_event(&This->node, EVENTID_MOUSEMOVE, &v);
628 static HRESULT WINAPI HTMLElement_get_onmousemove(IHTMLElement *iface, VARIANT *p)
630 HTMLElement *This = impl_from_IHTMLElement(iface);
632 TRACE("(%p)->(%p)\n", This, p);
634 return get_node_event(&This->node, EVENTID_MOUSEMOVE, p);
637 static HRESULT WINAPI HTMLElement_put_onmousedown(IHTMLElement *iface, VARIANT v)
639 HTMLElement *This = impl_from_IHTMLElement(iface);
641 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
643 return set_node_event(&This->node, EVENTID_MOUSEDOWN, &v);
646 static HRESULT WINAPI HTMLElement_get_onmousedown(IHTMLElement *iface, VARIANT *p)
648 HTMLElement *This = impl_from_IHTMLElement(iface);
650 TRACE("(%p)->(%p)\n", This, p);
652 return get_node_event(&This->node, EVENTID_MOUSEDOWN, p);
655 static HRESULT WINAPI HTMLElement_put_onmouseup(IHTMLElement *iface, VARIANT v)
657 HTMLElement *This = impl_from_IHTMLElement(iface);
659 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
661 return set_node_event(&This->node, EVENTID_MOUSEUP, &v);
664 static HRESULT WINAPI HTMLElement_get_onmouseup(IHTMLElement *iface, VARIANT *p)
666 HTMLElement *This = impl_from_IHTMLElement(iface);
668 TRACE("(%p)->(%p)\n", This, p);
670 return get_node_event(&This->node, EVENTID_MOUSEUP, p);
673 static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **p)
675 HTMLElement *This = impl_from_IHTMLElement(iface);
677 TRACE("(%p)->(%p)\n", This, p);
682 if(This->node.vtbl->get_document)
683 return This->node.vtbl->get_document(&This->node, p);
685 *p = (IDispatch*)&This->node.doc->basedoc.IHTMLDocument2_iface;
686 IDispatch_AddRef(*p);
690 static const WCHAR titleW[] = {'t','i','t','l','e',0};
692 static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v)
694 HTMLElement *This = impl_from_IHTMLElement(iface);
698 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
704 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var);
710 V_BSTR(var) = v ? SysAllocString(v) : NULL;
714 nsAString_InitDepend(&title_str, v);
715 nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str);
716 nsAString_Finish(&title_str);
718 ERR("SetTitle failed: %08x\n", nsres);
723 static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
725 HTMLElement *This = impl_from_IHTMLElement(iface);
729 TRACE("(%p)->(%p)\n", This, p);
735 hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var);
736 if(hres == DISP_E_UNKNOWNNAME) {
738 }else if(V_VT(var) != VT_BSTR) {
739 FIXME("title = %s\n", debugstr_variant(var));
742 *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL;
748 nsAString_Init(&title_str, NULL);
749 nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
750 return return_nsstr(nsres, &title_str, p);
753 static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
755 HTMLElement *This = impl_from_IHTMLElement(iface);
756 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
760 static HRESULT WINAPI HTMLElement_get_language(IHTMLElement *iface, BSTR *p)
762 HTMLElement *This = impl_from_IHTMLElement(iface);
763 FIXME("(%p)->(%p)\n", This, p);
767 static HRESULT WINAPI HTMLElement_put_onselectstart(IHTMLElement *iface, VARIANT v)
769 HTMLElement *This = impl_from_IHTMLElement(iface);
771 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
773 return set_node_event(&This->node, EVENTID_SELECTSTART, &v);
776 static HRESULT WINAPI HTMLElement_get_onselectstart(IHTMLElement *iface, VARIANT *p)
778 HTMLElement *This = impl_from_IHTMLElement(iface);
780 TRACE("(%p)->(%p)\n", This, p);
782 return get_node_event(&This->node, EVENTID_SELECTSTART, p);
785 static HRESULT WINAPI HTMLElement_scrollIntoView(IHTMLElement *iface, VARIANT varargStart)
787 HTMLElement *This = impl_from_IHTMLElement(iface);
788 FIXME("(%p)->(%s)\n", This, debugstr_variant(&varargStart));
792 static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pChild,
793 VARIANT_BOOL *pfResult)
795 HTMLElement *This = impl_from_IHTMLElement(iface);
800 TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
802 child = unsafe_impl_from_IHTMLElement(pChild);
804 ERR("not our element\n");
808 nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
809 if(NS_FAILED(nsres)) {
814 *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
818 static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
820 HTMLElement *This = impl_from_IHTMLElement(iface);
821 FIXME("(%p)->(%p)\n", This, p);
825 static HRESULT WINAPI HTMLElement_get_recordNumber(IHTMLElement *iface, VARIANT *p)
827 HTMLElement *This = impl_from_IHTMLElement(iface);
828 FIXME("(%p)->(%p)\n", This, p);
832 static HRESULT WINAPI HTMLElement_put_lang(IHTMLElement *iface, BSTR v)
834 HTMLElement *This = impl_from_IHTMLElement(iface);
835 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
839 static HRESULT WINAPI HTMLElement_get_lang(IHTMLElement *iface, BSTR *p)
841 HTMLElement *This = impl_from_IHTMLElement(iface);
842 FIXME("(%p)->(%p)\n", This, p);
846 static HRESULT WINAPI HTMLElement_get_offsetLeft(IHTMLElement *iface, LONG *p)
848 HTMLElement *This = impl_from_IHTMLElement(iface);
849 PRInt32 off_left = 0;
852 TRACE("(%p)->(%p)\n", This, p);
854 nsres = nsIDOMHTMLElement_GetOffsetLeft(This->nselem, &off_left);
855 if(NS_FAILED(nsres)) {
856 ERR("GetOffsetLeft failed: %08x\n", nsres);
864 static HRESULT WINAPI HTMLElement_get_offsetTop(IHTMLElement *iface, LONG *p)
866 HTMLElement *This = impl_from_IHTMLElement(iface);
870 TRACE("(%p)->(%p)\n", This, p);
872 nsres = nsIDOMHTMLElement_GetOffsetTop(This->nselem, &top);
873 if(NS_FAILED(nsres)) {
874 ERR("GetOffsetTop failed: %08x\n", nsres);
882 static HRESULT WINAPI HTMLElement_get_offsetWidth(IHTMLElement *iface, LONG *p)
884 HTMLElement *This = impl_from_IHTMLElement(iface);
888 TRACE("(%p)->(%p)\n", This, p);
890 nsres = nsIDOMHTMLElement_GetOffsetWidth(This->nselem, &offset);
891 if(NS_FAILED(nsres)) {
892 ERR("GetOffsetWidth failed: %08x\n", nsres);
900 static HRESULT WINAPI HTMLElement_get_offsetHeight(IHTMLElement *iface, LONG *p)
902 HTMLElement *This = impl_from_IHTMLElement(iface);
906 TRACE("(%p)->(%p)\n", This, p);
908 nsres = nsIDOMHTMLElement_GetOffsetHeight(This->nselem, &offset);
909 if(NS_FAILED(nsres)) {
910 ERR("GetOffsetHeight failed: %08x\n", nsres);
918 static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLElement **p)
920 HTMLElement *This = impl_from_IHTMLElement(iface);
921 nsIDOMElement *nsparent;
925 TRACE("(%p)->(%p)\n", This, p);
927 nsres = nsIDOMHTMLElement_GetOffsetParent(This->nselem, &nsparent);
928 if(NS_FAILED(nsres)) {
929 ERR("GetOffsetParent failed: %08x\n", nsres);
936 hres = get_node(This->node.doc, (nsIDOMNode*)nsparent, TRUE, &node);
937 nsIDOMElement_Release(nsparent);
941 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
951 static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
953 HTMLElement *This = impl_from_IHTMLElement(iface);
957 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
960 FIXME("NULL nselem\n");
964 nsAString_InitDepend(&html_str, v);
965 nsres = nsIDOMHTMLElement_SetInnerHTML(This->nselem, &html_str);
966 nsAString_Finish(&html_str);
967 if(NS_FAILED(nsres)) {
968 FIXME("SetInnerHtml failed %08x\n", nsres);
975 static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
977 HTMLElement *This = impl_from_IHTMLElement(iface);
981 TRACE("(%p)->(%p)\n", This, p);
984 FIXME("NULL nselem\n");
988 nsAString_Init(&html_str, NULL);
989 nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
990 return return_nsstr(nsres, &html_str, p);
993 static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
995 HTMLElement *This = impl_from_IHTMLElement(iface);
996 nsIDOMNode *nschild, *tmp;
997 nsIDOMText *text_node;
1001 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1004 nsres = nsIDOMHTMLElement_GetLastChild(This->nselem, &nschild);
1005 if(NS_FAILED(nsres)) {
1006 ERR("GetLastChild failed: %08x\n", nsres);
1012 nsres = nsIDOMHTMLElement_RemoveChild(This->nselem, nschild, &tmp);
1013 nsIDOMNode_Release(nschild);
1014 if(NS_FAILED(nsres)) {
1015 ERR("RemoveChild failed: %08x\n", nsres);
1018 nsIDOMNode_Release(tmp);
1021 nsAString_InitDepend(&text_str, v);
1022 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node);
1023 nsAString_Finish(&text_str);
1024 if(NS_FAILED(nsres)) {
1025 ERR("CreateTextNode failed: %08x\n", nsres);
1029 nsres = nsIDOMHTMLElement_AppendChild(This->nselem, (nsIDOMNode*)text_node, &tmp);
1030 if(NS_FAILED(nsres)) {
1031 ERR("AppendChild failed: %08x\n", nsres);
1035 nsIDOMNode_Release(tmp);
1039 static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
1041 HTMLElement *This = impl_from_IHTMLElement(iface);
1043 TRACE("(%p)->(%p)\n", This, p);
1045 return get_node_text(&This->node, p);
1048 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
1050 HTMLElement *This = impl_from_IHTMLElement(iface);
1052 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1054 return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v);
1057 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
1059 HTMLElement *This = impl_from_IHTMLElement(iface);
1063 WARN("(%p)->(%p) semi-stub\n", This, p);
1065 nsAString_Init(&html_str, NULL);
1066 hres = nsnode_to_nsstring(This->node.nsnode, &html_str);
1067 if(SUCCEEDED(hres)) {
1068 const PRUnichar *html;
1070 nsAString_GetData(&html_str, &html);
1071 *p = SysAllocString(html);
1073 hres = E_OUTOFMEMORY;
1076 nsAString_Finish(&html_str);
1078 TRACE("ret %s\n", debugstr_w(*p));
1082 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
1084 HTMLElement *This = impl_from_IHTMLElement(iface);
1085 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1089 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
1091 HTMLElement *This = impl_from_IHTMLElement(iface);
1092 FIXME("(%p)->(%p)\n", This, p);
1096 static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsIDOMNode *nsnode)
1098 static const WCHAR wszBeforeBegin[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1099 static const WCHAR wszAfterBegin[] = {'a','f','t','e','r','B','e','g','i','n',0};
1100 static const WCHAR wszBeforeEnd[] = {'b','e','f','o','r','e','E','n','d',0};
1101 static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
1104 if (!strcmpiW(where, wszBeforeBegin))
1108 nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1109 if (!parent) return E_INVALIDARG;
1110 nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
1111 if (unused) nsIDOMNode_Release(unused);
1112 nsIDOMNode_Release(parent);
1114 else if (!strcmpiW(where, wszAfterBegin))
1117 nsIDOMNode *first_child;
1118 nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
1119 nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
1120 if (unused) nsIDOMNode_Release(unused);
1121 if (first_child) nsIDOMNode_Release(first_child);
1123 else if (!strcmpiW(where, wszBeforeEnd))
1126 nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
1127 if (unused) nsIDOMNode_Release(unused);
1129 else if (!strcmpiW(where, wszAfterEnd))
1132 nsIDOMNode *next_sibling;
1134 nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
1135 if (!parent) return E_INVALIDARG;
1137 nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
1140 nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
1141 nsIDOMNode_Release(next_sibling);
1144 nsres = nsIDOMNode_AppendChild(parent, nsnode, &unused);
1145 nsIDOMNode_Release(parent);
1146 if (unused) nsIDOMNode_Release(unused);
1150 ERR("invalid where: %s\n", debugstr_w(where));
1151 return E_INVALIDARG;
1154 if (NS_FAILED(nsres))
1160 static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR where,
1163 HTMLElement *This = impl_from_IHTMLElement(iface);
1170 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
1172 if(!This->node.doc->nsdoc) {
1173 WARN("NULL nsdoc\n");
1174 return E_UNEXPECTED;
1177 nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
1178 if(NS_FAILED(nsres))
1180 ERR("CreateRange failed: %08x\n", nsres);
1184 nsIDOMRange_SetStartBefore(range, This->node.nsnode);
1186 nsAString_InitDepend(&ns_html, html);
1187 nsres = nsIDOMRange_CreateContextualFragment(range, &ns_html, (nsIDOMDocumentFragment **)&nsnode);
1188 nsAString_Finish(&ns_html);
1189 nsIDOMRange_Release(range);
1191 if(NS_FAILED(nsres) || !nsnode)
1193 ERR("CreateTextNode failed: %08x\n", nsres);
1197 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1198 nsIDOMNode_Release(nsnode);
1203 static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR where,
1206 HTMLElement *This = impl_from_IHTMLElement(iface);
1212 TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
1214 if(!This->node.doc->nsdoc) {
1215 WARN("NULL nsdoc\n");
1216 return E_UNEXPECTED;
1220 nsAString_InitDepend(&ns_text, text);
1221 nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode);
1222 nsAString_Finish(&ns_text);
1224 if(NS_FAILED(nsres) || !nsnode)
1226 ERR("CreateTextNode failed: %08x\n", nsres);
1230 hr = HTMLElement_InsertAdjacentNode(This, where, nsnode);
1231 nsIDOMNode_Release(nsnode);
1236 static HRESULT WINAPI HTMLElement_get_parentTextEdit(IHTMLElement *iface, IHTMLElement **p)
1238 HTMLElement *This = impl_from_IHTMLElement(iface);
1239 FIXME("(%p)->(%p)\n", This, p);
1243 static HRESULT WINAPI HTMLElement_get_isTextEdit(IHTMLElement *iface, VARIANT_BOOL *p)
1245 HTMLElement *This = impl_from_IHTMLElement(iface);
1246 FIXME("(%p)->(%p)\n", This, p);
1250 static HRESULT WINAPI HTMLElement_click(IHTMLElement *iface)
1252 HTMLElement *This = impl_from_IHTMLElement(iface);
1254 TRACE("(%p)\n", This);
1256 return call_fire_event(&This->node, EVENTID_CLICK);
1259 static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
1260 IHTMLFiltersCollection **p)
1262 HTMLElement *This = impl_from_IHTMLElement(iface);
1263 TRACE("(%p)->(%p)\n", This, p);
1268 *p = HTMLFiltersCollection_Create();
1273 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
1275 HTMLElement *This = impl_from_IHTMLElement(iface);
1276 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1280 static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *p)
1282 HTMLElement *This = impl_from_IHTMLElement(iface);
1283 FIXME("(%p)->(%p)\n", This, p);
1287 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
1289 HTMLElement *This = impl_from_IHTMLElement(iface);
1290 FIXME("(%p)->(%p)\n", This, String);
1294 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
1296 HTMLElement *This = impl_from_IHTMLElement(iface);
1297 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1301 static HRESULT WINAPI HTMLElement_get_onbeforeupdate(IHTMLElement *iface, VARIANT *p)
1303 HTMLElement *This = impl_from_IHTMLElement(iface);
1304 FIXME("(%p)->(%p)\n", This, p);
1308 static HRESULT WINAPI HTMLElement_put_onafterupdate(IHTMLElement *iface, VARIANT v)
1310 HTMLElement *This = impl_from_IHTMLElement(iface);
1311 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1315 static HRESULT WINAPI HTMLElement_get_onafterupdate(IHTMLElement *iface, VARIANT *p)
1317 HTMLElement *This = impl_from_IHTMLElement(iface);
1318 FIXME("(%p)->(%p)\n", This, p);
1322 static HRESULT WINAPI HTMLElement_put_onerrorupdate(IHTMLElement *iface, VARIANT v)
1324 HTMLElement *This = impl_from_IHTMLElement(iface);
1325 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1329 static HRESULT WINAPI HTMLElement_get_onerrorupdate(IHTMLElement *iface, VARIANT *p)
1331 HTMLElement *This = impl_from_IHTMLElement(iface);
1332 FIXME("(%p)->(%p)\n", This, p);
1336 static HRESULT WINAPI HTMLElement_put_onrowexit(IHTMLElement *iface, VARIANT v)
1338 HTMLElement *This = impl_from_IHTMLElement(iface);
1339 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1343 static HRESULT WINAPI HTMLElement_get_onrowexit(IHTMLElement *iface, VARIANT *p)
1345 HTMLElement *This = impl_from_IHTMLElement(iface);
1346 FIXME("(%p)->(%p)\n", This, p);
1350 static HRESULT WINAPI HTMLElement_put_onrowenter(IHTMLElement *iface, VARIANT v)
1352 HTMLElement *This = impl_from_IHTMLElement(iface);
1353 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1357 static HRESULT WINAPI HTMLElement_get_onrowenter(IHTMLElement *iface, VARIANT *p)
1359 HTMLElement *This = impl_from_IHTMLElement(iface);
1360 FIXME("(%p)->(%p)\n", This, p);
1364 static HRESULT WINAPI HTMLElement_put_ondatasetchanged(IHTMLElement *iface, VARIANT v)
1366 HTMLElement *This = impl_from_IHTMLElement(iface);
1367 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1371 static HRESULT WINAPI HTMLElement_get_ondatasetchanged(IHTMLElement *iface, VARIANT *p)
1373 HTMLElement *This = impl_from_IHTMLElement(iface);
1374 FIXME("(%p)->(%p)\n", This, p);
1378 static HRESULT WINAPI HTMLElement_put_ondataavailable(IHTMLElement *iface, VARIANT v)
1380 HTMLElement *This = impl_from_IHTMLElement(iface);
1382 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1384 return set_node_event(&This->node, EVENTID_DATAAVAILABLE, &v);
1387 static HRESULT WINAPI HTMLElement_get_ondataavailable(IHTMLElement *iface, VARIANT *p)
1389 HTMLElement *This = impl_from_IHTMLElement(iface);
1391 TRACE("(%p)->(%p)\n", This, p);
1393 return get_node_event(&This->node, EVENTID_DATAAVAILABLE, p);
1396 static HRESULT WINAPI HTMLElement_put_ondatasetcomplete(IHTMLElement *iface, VARIANT v)
1398 HTMLElement *This = impl_from_IHTMLElement(iface);
1399 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1403 static HRESULT WINAPI HTMLElement_get_ondatasetcomplete(IHTMLElement *iface, VARIANT *p)
1405 HTMLElement *This = impl_from_IHTMLElement(iface);
1406 FIXME("(%p)->(%p)\n", This, p);
1410 static HRESULT WINAPI HTMLElement_put_onfilterchange(IHTMLElement *iface, VARIANT v)
1412 HTMLElement *This = impl_from_IHTMLElement(iface);
1413 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1417 static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIANT *p)
1419 HTMLElement *This = impl_from_IHTMLElement(iface);
1420 FIXME("(%p)->(%p)\n", This, p);
1424 static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
1426 HTMLElement *This = impl_from_IHTMLElement(iface);
1427 nsIDOMNodeList *nsnode_list;
1430 TRACE("(%p)->(%p)\n", This, p);
1432 nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
1433 if(NS_FAILED(nsres)) {
1434 ERR("GetChildNodes failed: %08x\n", nsres);
1438 *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
1440 nsIDOMNodeList_Release(nsnode_list);
1444 static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
1446 HTMLElement *This = impl_from_IHTMLElement(iface);
1448 TRACE("(%p)->(%p)\n", This, p);
1450 *p = (IDispatch*)create_all_collection(&This->node, FALSE);
1454 static const IHTMLElementVtbl HTMLElementVtbl = {
1455 HTMLElement_QueryInterface,
1457 HTMLElement_Release,
1458 HTMLElement_GetTypeInfoCount,
1459 HTMLElement_GetTypeInfo,
1460 HTMLElement_GetIDsOfNames,
1462 HTMLElement_setAttribute,
1463 HTMLElement_getAttribute,
1464 HTMLElement_removeAttribute,
1465 HTMLElement_put_className,
1466 HTMLElement_get_className,
1469 HTMLElement_get_tagName,
1470 HTMLElement_get_parentElement,
1471 HTMLElement_get_style,
1472 HTMLElement_put_onhelp,
1473 HTMLElement_get_onhelp,
1474 HTMLElement_put_onclick,
1475 HTMLElement_get_onclick,
1476 HTMLElement_put_ondblclick,
1477 HTMLElement_get_ondblclick,
1478 HTMLElement_put_onkeydown,
1479 HTMLElement_get_onkeydown,
1480 HTMLElement_put_onkeyup,
1481 HTMLElement_get_onkeyup,
1482 HTMLElement_put_onkeypress,
1483 HTMLElement_get_onkeypress,
1484 HTMLElement_put_onmouseout,
1485 HTMLElement_get_onmouseout,
1486 HTMLElement_put_onmouseover,
1487 HTMLElement_get_onmouseover,
1488 HTMLElement_put_onmousemove,
1489 HTMLElement_get_onmousemove,
1490 HTMLElement_put_onmousedown,
1491 HTMLElement_get_onmousedown,
1492 HTMLElement_put_onmouseup,
1493 HTMLElement_get_onmouseup,
1494 HTMLElement_get_document,
1495 HTMLElement_put_title,
1496 HTMLElement_get_title,
1497 HTMLElement_put_language,
1498 HTMLElement_get_language,
1499 HTMLElement_put_onselectstart,
1500 HTMLElement_get_onselectstart,
1501 HTMLElement_scrollIntoView,
1502 HTMLElement_contains,
1503 HTMLElement_get_sourceIndex,
1504 HTMLElement_get_recordNumber,
1505 HTMLElement_put_lang,
1506 HTMLElement_get_lang,
1507 HTMLElement_get_offsetLeft,
1508 HTMLElement_get_offsetTop,
1509 HTMLElement_get_offsetWidth,
1510 HTMLElement_get_offsetHeight,
1511 HTMLElement_get_offsetParent,
1512 HTMLElement_put_innerHTML,
1513 HTMLElement_get_innerHTML,
1514 HTMLElement_put_innerText,
1515 HTMLElement_get_innerText,
1516 HTMLElement_put_outerHTML,
1517 HTMLElement_get_outerHTML,
1518 HTMLElement_put_outerText,
1519 HTMLElement_get_outerText,
1520 HTMLElement_insertAdjacentHTML,
1521 HTMLElement_insertAdjacentText,
1522 HTMLElement_get_parentTextEdit,
1523 HTMLElement_get_isTextEdit,
1525 HTMLElement_get_filters,
1526 HTMLElement_put_ondragstart,
1527 HTMLElement_get_ondragstart,
1528 HTMLElement_toString,
1529 HTMLElement_put_onbeforeupdate,
1530 HTMLElement_get_onbeforeupdate,
1531 HTMLElement_put_onafterupdate,
1532 HTMLElement_get_onafterupdate,
1533 HTMLElement_put_onerrorupdate,
1534 HTMLElement_get_onerrorupdate,
1535 HTMLElement_put_onrowexit,
1536 HTMLElement_get_onrowexit,
1537 HTMLElement_put_onrowenter,
1538 HTMLElement_get_onrowenter,
1539 HTMLElement_put_ondatasetchanged,
1540 HTMLElement_get_ondatasetchanged,
1541 HTMLElement_put_ondataavailable,
1542 HTMLElement_get_ondataavailable,
1543 HTMLElement_put_ondatasetcomplete,
1544 HTMLElement_get_ondatasetcomplete,
1545 HTMLElement_put_onfilterchange,
1546 HTMLElement_get_onfilterchange,
1547 HTMLElement_get_children,
1551 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement *iface)
1553 return iface->lpVtbl == &HTMLElementVtbl ? impl_from_IHTMLElement(iface) : NULL;
1556 static inline HTMLElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1558 return CONTAINING_RECORD(iface, HTMLElement, node);
1561 HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1563 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1567 if(IsEqualGUID(&IID_IUnknown, riid)) {
1568 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1569 *ppv = &This->IHTMLElement_iface;
1570 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1571 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1572 *ppv = &This->IHTMLElement_iface;
1573 }else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
1574 TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
1575 *ppv = &This->IHTMLElement_iface;
1576 }else if(IsEqualGUID(&IID_IHTMLElement2, riid)) {
1577 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This, ppv);
1578 *ppv = &This->IHTMLElement2_iface;
1579 }else if(IsEqualGUID(&IID_IHTMLElement3, riid)) {
1580 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This, ppv);
1581 *ppv = &This->IHTMLElement3_iface;
1582 }else if(IsEqualGUID(&IID_IHTMLElement4, riid)) {
1583 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This, ppv);
1584 *ppv = &This->IHTMLElement4_iface;
1585 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
1586 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
1587 *ppv = &This->cp_container.IConnectionPointContainer_iface;
1591 IHTMLElement_AddRef(&This->IHTMLElement_iface);
1595 return HTMLDOMNode_QI(&This->node, riid, ppv);
1598 void HTMLElement_destructor(HTMLDOMNode *iface)
1600 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1602 ConnectionPointContainer_Destroy(&This->cp_container);
1605 This->style->elem = NULL;
1606 IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
1608 if(This->runtime_style) {
1609 This->runtime_style->elem = NULL;
1610 IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface);
1613 HTMLDOMAttribute *attr;
1615 LIST_FOR_EACH_ENTRY(attr, &This->attrs->attrs, HTMLDOMAttribute, entry)
1618 This->attrs->elem = NULL;
1619 IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
1622 heap_free(This->filter);
1624 HTMLDOMNode_destructor(&This->node);
1627 HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
1629 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1630 HTMLElement *new_elem;
1633 hres = HTMLElement_Create(This->node.doc, nsnode, FALSE, &new_elem);
1638 new_elem->filter = heap_strdupW(This->filter);
1639 if(!new_elem->filter) {
1640 IHTMLElement_Release(&This->IHTMLElement_iface);
1641 return E_OUTOFMEMORY;
1645 *ret = &new_elem->node;
1649 HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
1651 HTMLElement *This = impl_from_HTMLDOMNode(iface);
1654 case EVENTID_KEYDOWN: {
1655 nsIDOMKeyEvent *key_event;
1658 nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
1659 if(NS_SUCCEEDED(nsres)) {
1662 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
1665 case VK_F1: /* DOM_VK_F1 */
1666 TRACE("F1 pressed\n");
1667 fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
1668 *prevent_default = TRUE;
1671 nsIDOMKeyEvent_Release(key_event);
1679 static const NodeImplVtbl HTMLElementImplVtbl = {
1681 HTMLElement_destructor,
1683 HTMLElement_handle_event,
1684 HTMLElement_get_attr_col
1687 static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface)
1689 return CONTAINING_RECORD(iface, HTMLElement, node.dispex);
1692 static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name,
1693 DWORD grfdex, DISPID *pid)
1695 HTMLElement *This = impl_from_DispatchEx(dispex);
1697 if(This->node.vtbl->get_dispid)
1698 return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
1700 return DISP_E_UNKNOWNNAME;
1703 static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
1704 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
1705 IServiceProvider *caller)
1707 HTMLElement *This = impl_from_DispatchEx(dispex);
1709 if(This->node.vtbl->invoke)
1710 return This->node.vtbl->invoke(&This->node, id, lcid, flags,
1711 params, res, ei, caller);
1713 ERR("(%p): element has no invoke method\n", This);
1717 static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
1719 HTMLElement *This = impl_from_DispatchEx(dispex);
1720 nsIDOMNamedNodeMap *attrs;
1723 const PRUnichar *str;
1735 nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
1736 if(NS_FAILED(nsres))
1739 nsres = nsIDOMNamedNodeMap_GetLength(attrs, &len);
1740 if(NS_FAILED(nsres)) {
1741 nsIDOMNamedNodeMap_Release(attrs);
1745 nsAString_Init(&nsstr, NULL);
1746 for(i=0; i<len; i++) {
1747 nsres = nsIDOMNamedNodeMap_Item(attrs, i, &node);
1748 if(NS_FAILED(nsres))
1751 nsres = nsIDOMNode_GetNodeName(node, &nsstr);
1752 if(NS_FAILED(nsres)) {
1753 nsIDOMNode_Release(node);
1757 nsAString_GetData(&nsstr, &str);
1758 name = SysAllocString(str);
1760 nsIDOMNode_Release(node);
1764 hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
1765 if(hres != DISP_E_UNKNOWNNAME) {
1766 nsIDOMNode_Release(node);
1767 SysFreeString(name);
1771 nsres = nsIDOMNode_GetNodeValue(node, &nsstr);
1772 nsIDOMNode_Release(node);
1773 if(NS_FAILED(nsres)) {
1774 SysFreeString(name);
1778 nsAString_GetData(&nsstr, &str);
1779 V_VT(&value) = VT_BSTR;
1781 V_BSTR(&value) = SysAllocString(str);
1782 if(!V_BSTR(&value)) {
1783 SysFreeString(name);
1787 V_BSTR(&value) = NULL;
1789 IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
1790 SysFreeString(name);
1791 VariantClear(&value);
1793 nsAString_Finish(&nsstr);
1795 nsIDOMNamedNodeMap_Release(attrs);
1799 static const tid_t HTMLElement_iface_tids[] = {
1804 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
1806 HTMLElement_get_dispid,
1808 HTMLElement_populate_props
1811 static dispex_static_data_t HTMLElement_dispex = {
1812 &HTMLElement_dispex_vtbl,
1813 DispHTMLUnknownElement_tid,
1815 HTMLElement_iface_tids
1818 void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
1820 This->IHTMLElement_iface.lpVtbl = &HTMLElementVtbl;
1822 HTMLElement2_Init(This);
1823 HTMLElement3_Init(This);
1825 if(dispex_data && !dispex_data->vtbl)
1826 dispex_data->vtbl = &HTMLElement_dispex_vtbl;
1827 init_dispex(&This->node.dispex, (IUnknown*)&This->IHTMLElement_iface,
1828 dispex_data ? dispex_data : &HTMLElement_dispex);
1831 HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
1833 /* No AddRef, share reference with HTMLDOMNode */
1834 assert((nsIDOMNode*)nselem == This->node.nsnode);
1835 This->nselem = nselem;
1838 ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)&This->IHTMLElement_iface);
1841 HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
1843 nsIDOMHTMLElement *nselem;
1844 nsAString class_name_str;
1845 const PRUnichar *class_name;
1846 const tag_desc_t *tag;
1851 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem);
1852 if(NS_FAILED(nsres))
1855 nsAString_Init(&class_name_str, NULL);
1856 nsIDOMHTMLElement_GetTagName(nselem, &class_name_str);
1858 nsAString_GetData(&class_name_str, &class_name);
1860 tag = get_tag_desc(class_name);
1862 hres = tag->constructor(doc, nselem, &elem);
1863 }else if(use_generic) {
1864 hres = HTMLGenericElement_Create(doc, nselem, &elem);
1866 elem = heap_alloc_zero(sizeof(HTMLElement));
1868 HTMLElement_Init(elem, doc, nselem, &HTMLElement_dispex);
1869 elem->node.vtbl = &HTMLElementImplVtbl;
1872 hres = E_OUTOFMEMORY;
1876 TRACE("%s ret %p\n", debugstr_w(class_name), elem);
1878 nsIDOMHTMLElement_Release(nselem);
1879 nsAString_Finish(&class_name_str);
1887 HRESULT get_elem(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **ret)
1892 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
1896 *ret = impl_from_HTMLDOMNode(node);
1900 /* interface IHTMLFiltersCollection */
1901 static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
1903 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1905 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
1907 if(IsEqualGUID(&IID_IUnknown, riid)) {
1908 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1909 *ppv = &This->IHTMLFiltersCollection_iface;
1910 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
1911 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
1912 *ppv = &This->IHTMLFiltersCollection_iface;
1913 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1914 return *ppv ? S_OK : E_NOINTERFACE;
1918 IUnknown_AddRef((IUnknown*)*ppv);
1922 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1923 return E_NOINTERFACE;
1926 static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
1928 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1929 LONG ref = InterlockedIncrement(&This->ref);
1931 TRACE("(%p) ref=%d\n", This, ref);
1936 static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
1938 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1939 LONG ref = InterlockedDecrement(&This->ref);
1941 TRACE("(%p) ref=%d\n", This, ref);
1951 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
1953 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1954 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1957 static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
1958 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1960 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1961 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1964 static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
1965 REFIID riid, LPOLESTR *rgszNames, UINT cNames,
1966 LCID lcid, DISPID *rgDispId)
1968 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1969 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1973 static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
1974 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1975 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1977 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1978 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1979 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1982 static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
1984 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1989 FIXME("(%p)->(%p) Always returning 0\n", This, p);
1995 static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
1997 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
1998 FIXME("(%p)->(%p)\n", This, p);
2002 static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
2004 HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface);
2005 FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
2009 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
2010 HTMLFiltersCollection_QueryInterface,
2011 HTMLFiltersCollection_AddRef,
2012 HTMLFiltersCollection_Release,
2013 HTMLFiltersCollection_GetTypeInfoCount,
2014 HTMLFiltersCollection_GetTypeInfo,
2015 HTMLFiltersCollection_GetIDsOfNames,
2016 HTMLFiltersCollection_Invoke,
2017 HTMLFiltersCollection_get_length,
2018 HTMLFiltersCollection_get__newEnum,
2019 HTMLFiltersCollection_item
2022 static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
2027 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
2028 idx = idx*10 + (*ptr-'0');
2030 return DISP_E_UNKNOWNNAME;
2032 *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
2033 TRACE("ret %x\n", *dispid);
2037 static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2038 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2040 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei);
2042 V_VT(res) = VT_DISPATCH;
2043 V_DISPATCH(res) = NULL;
2045 FIXME("always returning NULL\n");
2050 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
2052 HTMLFiltersCollection_get_dispid,
2053 HTMLFiltersCollection_invoke,
2057 static const tid_t HTMLFiltersCollection_iface_tids[] = {
2058 IHTMLFiltersCollection_tid,
2061 static dispex_static_data_t HTMLFiltersCollection_dispex = {
2062 &HTMLFiltersCollection_dispex_vtbl,
2063 IHTMLFiltersCollection_tid,
2065 HTMLFiltersCollection_iface_tids
2068 static IHTMLFiltersCollection *HTMLFiltersCollection_Create(void)
2070 HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
2072 ret->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl;
2075 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLFiltersCollection_iface,
2076 &HTMLFiltersCollection_dispex);
2078 return &ret->IHTMLFiltersCollection_iface;
2081 /* interface IHTMLAttributeCollection */
2082 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection *iface)
2084 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection_iface);
2087 static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection *iface, REFIID riid, void **ppv)
2089 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2093 if(IsEqualGUID(&IID_IUnknown, riid)) {
2094 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
2095 *ppv = &This->IHTMLAttributeCollection_iface;
2096 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection, riid)) {
2097 TRACE("(%p)->(IID_IHTMLAttributeCollection %p)\n", This, ppv);
2098 *ppv = &This->IHTMLAttributeCollection_iface;
2099 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2, riid)) {
2100 TRACE("(%p)->(IID_IHTMLAttributeCollection2 %p)\n", This, ppv);
2101 *ppv = &This->IHTMLAttributeCollection2_iface;
2102 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3, riid)) {
2103 TRACE("(%p)->(IID_IHTMLAttributeCollection3 %p)\n", This, ppv);
2104 *ppv = &This->IHTMLAttributeCollection3_iface;
2105 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2106 return *ppv ? S_OK : E_NOINTERFACE;
2110 IUnknown_AddRef((IUnknown*)*ppv);
2114 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2115 return E_NOINTERFACE;
2118 static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface)
2120 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2121 LONG ref = InterlockedIncrement(&This->ref);
2123 TRACE("(%p) ref=%d\n", This, ref);
2128 static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface)
2130 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2131 LONG ref = InterlockedDecrement(&This->ref);
2133 TRACE("(%p) ref=%d\n", This, ref);
2136 while(!list_empty(&This->attrs)) {
2137 HTMLDOMAttribute *attr = LIST_ENTRY(list_head(&This->attrs), HTMLDOMAttribute, entry);
2139 list_remove(&attr->entry);
2141 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2150 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection *iface, UINT *pctinfo)
2152 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2153 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2156 static HRESULT WINAPI HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection *iface, UINT iTInfo,
2157 LCID lcid, ITypeInfo **ppTInfo)
2159 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2160 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2163 static HRESULT WINAPI HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection *iface, REFIID riid,
2164 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2166 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2167 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2171 static HRESULT WINAPI HTMLAttributeCollection_Invoke(IHTMLAttributeCollection *iface, DISPID dispIdMember,
2172 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2173 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2175 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2176 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2177 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2180 static HRESULT get_attr_dispid_by_idx(HTMLAttributeCollection *This, LONG *idx, DISPID *dispid)
2182 IDispatchEx *dispex = &This->elem->node.dispex.IDispatchEx_iface;
2183 DISPID id = DISPID_STARTENUM;
2187 FIXME("filter non-enumerable attributes out\n");
2190 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
2193 else if(hres == S_FALSE)
2203 return *idx==len ? S_OK : DISP_E_UNKNOWNNAME;
2210 static inline HRESULT get_attr_dispid_by_name(HTMLAttributeCollection *This, BSTR name, DISPID *id)
2214 if(name[0]>='0' && name[0]<='9') {
2218 idx = strtoulW(name, &end_ptr, 10);
2220 hres = get_attr_dispid_by_idx(This, &idx, id);
2227 WARN("NULL elem\n");
2228 return E_UNEXPECTED;
2231 hres = IDispatchEx_GetDispID(&This->elem->node.dispex.IDispatchEx_iface,
2232 name, fdexNameCaseInsensitive, id);
2236 static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG *list_pos, HTMLDOMAttribute **attr)
2238 HTMLDOMAttribute *iter;
2243 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2244 if(iter->dispid == id) {
2253 WARN("NULL elem\n");
2254 return E_UNEXPECTED;
2257 hres = HTMLDOMAttribute_Create(This->elem, id, attr);
2262 IHTMLDOMAttribute_AddRef(&(*attr)->IHTMLDOMAttribute_iface);
2268 static HRESULT WINAPI HTMLAttributeCollection_get_length(IHTMLAttributeCollection *iface, LONG *p)
2270 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2273 TRACE("(%p)->(%p)\n", This, p);
2276 hres = get_attr_dispid_by_idx(This, p, NULL);
2280 static HRESULT WINAPI HTMLAttributeCollection__newEnum(IHTMLAttributeCollection *iface, IUnknown **p)
2282 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2283 FIXME("(%p)->(%p)\n", This, p);
2287 static HRESULT WINAPI HTMLAttributeCollection_item(IHTMLAttributeCollection *iface, VARIANT *name, IDispatch **ppItem)
2289 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface);
2290 HTMLDOMAttribute *attr;
2294 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(name), ppItem);
2296 switch(V_VT(name)) {
2298 hres = get_attr_dispid_by_idx(This, &V_I4(name), &id);
2301 hres = get_attr_dispid_by_name(This, V_BSTR(name), &id);
2304 FIXME("unsupported name %s\n", debugstr_variant(name));
2307 if(hres == DISP_E_UNKNOWNNAME)
2308 return E_INVALIDARG;
2312 hres = get_domattr(This, id, NULL, &attr);
2316 *ppItem = (IDispatch*)&attr->IHTMLDOMAttribute_iface;
2320 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl = {
2321 HTMLAttributeCollection_QueryInterface,
2322 HTMLAttributeCollection_AddRef,
2323 HTMLAttributeCollection_Release,
2324 HTMLAttributeCollection_GetTypeInfoCount,
2325 HTMLAttributeCollection_GetTypeInfo,
2326 HTMLAttributeCollection_GetIDsOfNames,
2327 HTMLAttributeCollection_Invoke,
2328 HTMLAttributeCollection_get_length,
2329 HTMLAttributeCollection__newEnum,
2330 HTMLAttributeCollection_item
2333 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2 *iface)
2335 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection2_iface);
2338 static HRESULT WINAPI HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2 *iface, REFIID riid, void **ppv)
2340 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2341 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2344 static ULONG WINAPI HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2 *iface)
2346 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2347 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2350 static ULONG WINAPI HTMLAttributeCollection2_Release(IHTMLAttributeCollection2 *iface)
2352 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2353 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2356 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2 *iface, UINT *pctinfo)
2358 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2359 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2362 static HRESULT WINAPI HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2 *iface, UINT iTInfo,
2363 LCID lcid, ITypeInfo **ppTInfo)
2365 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2366 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2369 static HRESULT WINAPI HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2 *iface, REFIID riid,
2370 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2372 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2373 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2377 static HRESULT WINAPI HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2 *iface, DISPID dispIdMember,
2378 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2379 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2381 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2382 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2383 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2386 static HRESULT WINAPI HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2 *iface, BSTR bstrName,
2387 IHTMLDOMAttribute **newretNode)
2389 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2390 HTMLDOMAttribute *attr;
2394 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2396 hres = get_attr_dispid_by_name(This, bstrName, &id);
2397 if(hres == DISP_E_UNKNOWNNAME) {
2400 } else if(FAILED(hres)) {
2404 hres = get_domattr(This, id, NULL, &attr);
2408 *newretNode = &attr->IHTMLDOMAttribute_iface;
2412 static HRESULT WINAPI HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2 *iface,
2413 IHTMLDOMAttribute *ppNode, IHTMLDOMAttribute **newretNode)
2415 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2416 FIXME("(%p)->(%p %p)\n", This, ppNode, newretNode);
2420 static HRESULT WINAPI HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2 *iface,
2421 BSTR bstrName, IHTMLDOMAttribute **newretNode)
2423 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection2(iface);
2424 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), newretNode);
2428 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl = {
2429 HTMLAttributeCollection2_QueryInterface,
2430 HTMLAttributeCollection2_AddRef,
2431 HTMLAttributeCollection2_Release,
2432 HTMLAttributeCollection2_GetTypeInfoCount,
2433 HTMLAttributeCollection2_GetTypeInfo,
2434 HTMLAttributeCollection2_GetIDsOfNames,
2435 HTMLAttributeCollection2_Invoke,
2436 HTMLAttributeCollection2_getNamedItem,
2437 HTMLAttributeCollection2_setNamedItem,
2438 HTMLAttributeCollection2_removeNamedItem
2441 static inline HTMLAttributeCollection *impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3 *iface)
2443 return CONTAINING_RECORD(iface, HTMLAttributeCollection, IHTMLAttributeCollection3_iface);
2446 static HRESULT WINAPI HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3 *iface, REFIID riid, void **ppv)
2448 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2449 return IHTMLAttributeCollection_QueryInterface(&This->IHTMLAttributeCollection_iface, riid, ppv);
2452 static ULONG WINAPI HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3 *iface)
2454 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2455 return IHTMLAttributeCollection_AddRef(&This->IHTMLAttributeCollection_iface);
2458 static ULONG WINAPI HTMLAttributeCollection3_Release(IHTMLAttributeCollection3 *iface)
2460 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2461 return IHTMLAttributeCollection_Release(&This->IHTMLAttributeCollection_iface);
2464 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3 *iface, UINT *pctinfo)
2466 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2467 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2470 static HRESULT WINAPI HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3 *iface, UINT iTInfo,
2471 LCID lcid, ITypeInfo **ppTInfo)
2473 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2474 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2477 static HRESULT WINAPI HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3 *iface, REFIID riid,
2478 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2480 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2481 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2485 static HRESULT WINAPI HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3 *iface, DISPID dispIdMember,
2486 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2487 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2489 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2490 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
2491 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2494 static HRESULT WINAPI HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3 *iface, BSTR bstrName,
2495 IHTMLDOMAttribute **ppNodeOut)
2497 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2498 return IHTMLAttributeCollection2_getNamedItem(&This->IHTMLAttributeCollection2_iface, bstrName, ppNodeOut);
2501 static HRESULT WINAPI HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3 *iface,
2502 IHTMLDOMAttribute *pNodeIn, IHTMLDOMAttribute **ppNodeOut)
2504 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2505 FIXME("(%p)->(%p %p)\n", This, pNodeIn, ppNodeOut);
2509 static HRESULT WINAPI HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3 *iface,
2510 BSTR bstrName, IHTMLDOMAttribute **ppNodeOut)
2512 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2513 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrName), ppNodeOut);
2517 static HRESULT WINAPI HTMLAttributeCollection3_item(IHTMLAttributeCollection3 *iface, LONG index, IHTMLDOMAttribute **ppNodeOut)
2519 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2520 HTMLDOMAttribute *attr;
2524 TRACE("(%p)->(%d %p)\n", This, index, ppNodeOut);
2526 hres = get_attr_dispid_by_idx(This, &index, &id);
2527 if(hres == DISP_E_UNKNOWNNAME)
2528 return E_INVALIDARG;
2532 hres = get_domattr(This, id, NULL, &attr);
2536 *ppNodeOut = &attr->IHTMLDOMAttribute_iface;
2540 static HRESULT WINAPI HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3 *iface, LONG *p)
2542 HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection3(iface);
2543 return IHTMLAttributeCollection_get_length(&This->IHTMLAttributeCollection_iface, p);
2546 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl = {
2547 HTMLAttributeCollection3_QueryInterface,
2548 HTMLAttributeCollection3_AddRef,
2549 HTMLAttributeCollection3_Release,
2550 HTMLAttributeCollection3_GetTypeInfoCount,
2551 HTMLAttributeCollection3_GetTypeInfo,
2552 HTMLAttributeCollection3_GetIDsOfNames,
2553 HTMLAttributeCollection3_Invoke,
2554 HTMLAttributeCollection3_getNamedItem,
2555 HTMLAttributeCollection3_setNamedItem,
2556 HTMLAttributeCollection3_removeNamedItem,
2557 HTMLAttributeCollection3_item,
2558 HTMLAttributeCollection3_get_length
2561 static inline HTMLAttributeCollection *HTMLAttributeCollection_from_DispatchEx(DispatchEx *iface)
2563 return CONTAINING_RECORD(iface, HTMLAttributeCollection, dispex);
2566 static HRESULT HTMLAttributeCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
2568 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2569 HTMLDOMAttribute *attr;
2573 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), flags, dispid);
2575 hres = get_attr_dispid_by_name(This, name, dispid);
2579 hres = get_domattr(This, *dispid, &pos, &attr);
2582 IHTMLDOMAttribute_Release(&attr->IHTMLDOMAttribute_iface);
2584 *dispid = MSHTML_DISPID_CUSTOM_MIN+pos;
2588 static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
2589 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2591 HTMLAttributeCollection *This = HTMLAttributeCollection_from_DispatchEx(dispex);
2593 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
2596 case DISPATCH_PROPERTYGET: {
2597 HTMLDOMAttribute *iter;
2600 pos = id-MSHTML_DISPID_CUSTOM_MIN;
2602 LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
2604 IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
2605 V_VT(res) = VT_DISPATCH;
2606 V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
2612 WARN("invalid arg\n");
2613 return E_INVALIDARG;
2617 FIXME("unimplemented flags %x\n", flags);
2622 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
2624 HTMLAttributeCollection_get_dispid,
2625 HTMLAttributeCollection_invoke,
2629 static const tid_t HTMLAttributeCollection_iface_tids[] = {
2630 IHTMLAttributeCollection_tid,
2631 IHTMLAttributeCollection2_tid,
2632 IHTMLAttributeCollection3_tid,
2636 static dispex_static_data_t HTMLAttributeCollection_dispex = {
2637 &HTMLAttributeCollection_dispex_vtbl,
2638 DispHTMLAttributeCollection_tid,
2640 HTMLAttributeCollection_iface_tids
2643 HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
2645 HTMLElement *This = impl_from_HTMLDOMNode(iface);
2648 IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface);
2653 This->attrs = heap_alloc_zero(sizeof(HTMLAttributeCollection));
2655 return E_OUTOFMEMORY;
2657 This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl;
2658 This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl;
2659 This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl;
2660 This->attrs->ref = 2;
2662 This->attrs->elem = This;
2663 list_init(&This->attrs->attrs);
2664 init_dispex(&This->attrs->dispex, (IUnknown*)&This->attrs->IHTMLAttributeCollection_iface,
2665 &HTMLAttributeCollection_dispex);