2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
35 #include "htmlstyle.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 static const WCHAR aW
[] = {'A',0};
40 static const WCHAR bodyW
[] = {'B','O','D','Y',0};
41 static const WCHAR embedW
[] = {'E','M','B','E','D',0};
42 static const WCHAR formW
[] = {'F','O','R','M',0};
43 static const WCHAR frameW
[] = {'F','R','A','M','E',0};
44 static const WCHAR headW
[] = {'H','E','A','D',0};
45 static const WCHAR iframeW
[] = {'I','F','R','A','M','E',0};
46 static const WCHAR imgW
[] = {'I','M','G',0};
47 static const WCHAR inputW
[] = {'I','N','P','U','T',0};
48 static const WCHAR metaW
[] = {'M','E','T','A',0};
49 static const WCHAR objectW
[] = {'O','B','J','E','C','T',0};
50 static const WCHAR optionW
[] = {'O','P','T','I','O','N',0};
51 static const WCHAR scriptW
[] = {'S','C','R','I','P','T',0};
52 static const WCHAR selectW
[] = {'S','E','L','E','C','T',0};
53 static const WCHAR styleW
[] = {'S','T','Y','L','E',0};
54 static const WCHAR tableW
[] = {'T','A','B','L','E',0};
55 static const WCHAR tdW
[] = {'T','D',0};
56 static const WCHAR textareaW
[] = {'T','E','X','T','A','R','E','A',0};
57 static const WCHAR title_tagW
[]= {'T','I','T','L','E',0};
58 static const WCHAR trW
[] = {'T','R',0};
62 HRESULT (*constructor
)(HTMLDocumentNode
*,nsIDOMHTMLElement
*,HTMLElement
**);
65 static const tag_desc_t tag_descs
[] = {
66 {aW
, HTMLAnchorElement_Create
},
67 {bodyW
, HTMLBodyElement_Create
},
68 {embedW
, HTMLEmbedElement_Create
},
69 {formW
, HTMLFormElement_Create
},
70 {frameW
, HTMLFrameElement_Create
},
71 {headW
, HTMLHeadElement_Create
},
72 {iframeW
, HTMLIFrame_Create
},
73 {imgW
, HTMLImgElement_Create
},
74 {inputW
, HTMLInputElement_Create
},
75 {metaW
, HTMLMetaElement_Create
},
76 {objectW
, HTMLObjectElement_Create
},
77 {optionW
, HTMLOptionElement_Create
},
78 {scriptW
, HTMLScriptElement_Create
},
79 {selectW
, HTMLSelectElement_Create
},
80 {styleW
, HTMLStyleElement_Create
},
81 {tableW
, HTMLTable_Create
},
82 {tdW
, HTMLTableCell_Create
},
83 {textareaW
, HTMLTextAreaElement_Create
},
84 {title_tagW
, HTMLTitleElement_Create
},
85 {trW
, HTMLTableRow_Create
}
88 static const tag_desc_t
*get_tag_desc(const WCHAR
*tag_name
)
90 DWORD min
=0, max
=sizeof(tag_descs
)/sizeof(*tag_descs
)-1, i
;
95 r
= strcmpW(tag_name
, tag_descs
[i
].name
);
108 HRESULT
replace_node_by_html(nsIDOMHTMLDocument
*nsdoc
, nsIDOMNode
*nsnode
, const WCHAR
*html
)
110 nsIDOMDocumentFragment
*nsfragment
;
111 nsIDOMNSRange
*nsrange
;
112 nsIDOMNode
*nsparent
;
118 nsres
= nsIDOMHTMLDocument_CreateRange(nsdoc
, &range
);
119 if(NS_FAILED(nsres
)) {
120 ERR("CreateRange failed: %08x\n", nsres
);
124 nsres
= nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void**)&nsrange
);
125 nsIDOMRange_Release(range
);
126 if(NS_FAILED(nsres
)) {
127 ERR("Could not get nsIDOMNSRange: %08x\n", nsres
);
131 nsAString_InitDepend(&html_str
, html
);
132 nsIDOMNSRange_CreateContextualFragment(nsrange
, &html_str
, &nsfragment
);
133 nsIDOMNSRange_Release(nsrange
);
134 nsAString_Finish(&html_str
);
135 if(NS_FAILED(nsres
)) {
136 ERR("CreateContextualFragment failed: %08x\n", nsres
);
140 nsres
= nsIDOMNode_GetParentNode(nsnode
, &nsparent
);
141 if(NS_SUCCEEDED(nsres
) && nsparent
) {
144 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, nsnode
, &nstmp
);
145 nsIDOMNode_Release(nsparent
);
146 if(NS_FAILED(nsres
)) {
147 ERR("ReplaceChild failed: %08x\n", nsres
);
150 nsIDOMNode_Release(nstmp
);
153 ERR("GetParentNode failed: %08x\n", nsres
);
157 nsIDOMDocumentFragment_Release(nsfragment
);
164 IHTMLFiltersCollection IHTMLFiltersCollection_iface
;
167 } HTMLFiltersCollection
;
169 static inline HTMLFiltersCollection
*impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection
*iface
)
171 return CONTAINING_RECORD(iface
, HTMLFiltersCollection
, IHTMLFiltersCollection_iface
);
174 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void);
176 static inline HTMLElement
*impl_from_IHTMLElement(IHTMLElement
*iface
)
178 return CONTAINING_RECORD(iface
, HTMLElement
, IHTMLElement_iface
);
181 HRESULT
create_nselem(HTMLDocumentNode
*doc
, const WCHAR
*tag
, nsIDOMHTMLElement
**ret
)
183 nsIDOMElement
*nselem
;
188 WARN("NULL nsdoc\n");
192 nsAString_InitDepend(&tag_str
, tag
);
193 nsres
= nsIDOMDocument_CreateElement(doc
->nsdoc
, &tag_str
, &nselem
);
194 nsAString_Finish(&tag_str
);
195 if(NS_FAILED(nsres
)) {
196 ERR("CreateElement failed: %08x\n", nsres
);
200 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLElement
, (void**)ret
);
201 nsIDOMElement_Release(nselem
);
202 if(NS_FAILED(nsres
)) {
203 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres
);
210 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
211 REFIID riid
, void **ppv
)
213 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
215 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
218 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
220 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
222 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
225 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
227 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
229 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
232 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
234 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
235 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
238 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
239 LCID lcid
, ITypeInfo
**ppTInfo
)
241 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
242 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
245 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
246 LPOLESTR
*rgszNames
, UINT cNames
,
247 LCID lcid
, DISPID
*rgDispId
)
249 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
250 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
254 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
255 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
256 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
258 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
259 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
260 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
263 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
264 VARIANT AttributeValue
, LONG lFlags
)
266 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
268 DISPID dispid
, dispidNamed
= DISPID_PROPERTYPUT
;
269 DISPPARAMS dispParams
;
272 TRACE("(%p)->(%s . %08x)\n", This
, debugstr_w(strAttributeName
), lFlags
);
274 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
275 fdexNameCaseInsensitive
| fdexNameEnsure
, &dispid
);
279 dispParams
.cArgs
= 1;
280 dispParams
.cNamedArgs
= 1;
281 dispParams
.rgdispidNamedArgs
= &dispidNamed
;
282 dispParams
.rgvarg
= &AttributeValue
;
284 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
,
285 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYPUT
, &dispParams
, NULL
, &excep
, NULL
);
289 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
290 LONG lFlags
, VARIANT
*AttributeValue
)
292 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
295 DISPPARAMS dispParams
= {NULL
, NULL
, 0, 0};
298 TRACE("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
300 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
301 fdexNameCaseInsensitive
, &dispid
);
302 if(hres
== DISP_E_UNKNOWNNAME
) {
303 V_VT(AttributeValue
) = VT_NULL
;
308 V_VT(AttributeValue
) = VT_NULL
;
312 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
, LOCALE_SYSTEM_DEFAULT
,
313 DISPATCH_PROPERTYGET
, &dispParams
, AttributeValue
, &excep
, NULL
);
318 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
319 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
321 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
323 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, pfSuccess
);
325 return remove_prop(&This
->node
.dispex
, strAttributeName
, pfSuccess
);
328 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
330 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
331 nsAString classname_str
;
334 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
337 FIXME("NULL nselem\n");
341 nsAString_InitDepend(&classname_str
, v
);
342 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
343 nsAString_Finish(&classname_str
);
345 ERR("SetClassName failed: %08x\n", nsres
);
350 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
352 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
357 TRACE("(%p)->(%p)\n", This
, p
);
360 FIXME("NULL nselem\n");
364 nsAString_Init(&class_str
, NULL
);
365 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
367 if(NS_SUCCEEDED(nsres
)) {
368 const PRUnichar
*class;
369 nsAString_GetData(&class_str
, &class);
370 *p
= *class ? SysAllocString(class) : NULL
;
372 ERR("GetClassName failed: %08x\n", nsres
);
376 nsAString_Finish(&class_str
);
378 TRACE("className=%s\n", debugstr_w(*p
));
382 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
384 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
388 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
391 FIXME("nselem == NULL\n");
395 nsAString_InitDepend(&id_str
, v
);
396 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
397 nsAString_Finish(&id_str
);
399 ERR("SetId failed: %08x\n", nsres
);
404 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
406 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
411 TRACE("(%p)->(%p)\n", This
, p
);
418 nsAString_Init(&id_str
, NULL
);
419 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
420 nsAString_GetData(&id_str
, &id
);
423 ERR("GetId failed: %08x\n", nsres
);
425 *p
= SysAllocString(id
);
427 nsAString_Finish(&id_str
);
431 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
433 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
434 const PRUnichar
*tag
;
438 TRACE("(%p)->(%p)\n", This
, p
);
441 static const WCHAR comment_tagW
[] = {'!',0};
443 WARN("NULL nselem, assuming comment\n");
445 *p
= SysAllocString(comment_tagW
);
449 nsAString_Init(&tag_str
, NULL
);
450 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
451 if(NS_SUCCEEDED(nsres
)) {
452 nsAString_GetData(&tag_str
, &tag
);
453 *p
= SysAllocString(tag
);
455 ERR("GetTagName failed: %08x\n", nsres
);
458 nsAString_Finish(&tag_str
);
463 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
465 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
469 TRACE("(%p)->(%p)\n", This
, p
);
471 hres
= IHTMLDOMNode_get_parentNode(&This
->node
.IHTMLDOMNode_iface
, &node
);
475 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
476 IHTMLDOMNode_Release(node
);
483 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
485 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
487 TRACE("(%p)->(%p)\n", This
, p
);
490 nsIDOMElementCSSInlineStyle
*nselemstyle
;
491 nsIDOMCSSStyleDeclaration
*nsstyle
;
496 FIXME("NULL nselem\n");
500 nsres
= nsIDOMHTMLElement_QueryInterface(This
->nselem
, &IID_nsIDOMElementCSSInlineStyle
,
501 (void**)&nselemstyle
);
502 if(NS_FAILED(nsres
)) {
503 ERR("Could not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres
);
507 nsres
= nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle
, &nsstyle
);
508 nsIDOMElementCSSInlineStyle_Release(nselemstyle
);
509 if(NS_FAILED(nsres
)) {
510 ERR("GetStyle failed: %08x\n", nsres
);
514 hres
= HTMLStyle_Create(This
, nsstyle
, &This
->style
);
515 nsIDOMCSSStyleDeclaration_Release(nsstyle
);
520 *p
= &This
->style
->IHTMLStyle_iface
;
521 IHTMLStyle_AddRef(*p
);
525 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
527 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
528 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
532 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
534 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
535 FIXME("(%p)->(%p)\n", This
, p
);
539 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
541 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
543 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
545 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
548 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
550 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
552 TRACE("(%p)->(%p)\n", This
, p
);
554 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
557 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
559 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
561 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
563 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
566 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
568 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
570 TRACE("(%p)->(%p)\n", This
, p
);
572 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
575 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
577 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
579 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
581 return set_node_event(&This
->node
, EVENTID_KEYDOWN
, &v
);
584 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
586 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
588 TRACE("(%p)->(%p)\n", This
, p
);
590 return get_node_event(&This
->node
, EVENTID_KEYDOWN
, p
);
593 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
595 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
597 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
599 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
602 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
604 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
605 FIXME("(%p)->(%p)\n", This
, p
);
609 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
611 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
612 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
616 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
618 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
619 FIXME("(%p)->(%p)\n", This
, p
);
623 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
625 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
627 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
629 return set_node_event(&This
->node
, EVENTID_MOUSEOUT
, &v
);
632 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
634 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
636 TRACE("(%p)->(%p)\n", This
, p
);
638 return get_node_event(&This
->node
, EVENTID_MOUSEOUT
, p
);
641 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
643 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
645 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
647 return set_node_event(&This
->node
, EVENTID_MOUSEOVER
, &v
);
650 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
652 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
654 TRACE("(%p)->(%p)\n", This
, p
);
656 return get_node_event(&This
->node
, EVENTID_MOUSEOVER
, p
);
659 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
661 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
663 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
665 return set_node_event(&This
->node
, EVENTID_MOUSEMOVE
, &v
);
668 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
670 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
672 TRACE("(%p)->(%p)\n", This
, p
);
674 return get_node_event(&This
->node
, EVENTID_MOUSEMOVE
, p
);
677 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
679 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
681 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
683 return set_node_event(&This
->node
, EVENTID_MOUSEDOWN
, &v
);
686 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
688 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
690 TRACE("(%p)->(%p)\n", This
, p
);
692 return get_node_event(&This
->node
, EVENTID_MOUSEDOWN
, p
);
695 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
697 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
699 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
701 return set_node_event(&This
->node
, EVENTID_MOUSEUP
, &v
);
704 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
706 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
708 TRACE("(%p)->(%p)\n", This
, p
);
710 return get_node_event(&This
->node
, EVENTID_MOUSEUP
, p
);
713 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
715 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
717 TRACE("(%p)->(%p)\n", This
, p
);
722 if(This
->node
.vtbl
->get_document
)
723 return This
->node
.vtbl
->get_document(&This
->node
, p
);
725 *p
= (IDispatch
*)&This
->node
.doc
->basedoc
.IHTMLDocument2_iface
;
726 IDispatch_AddRef(*p
);
730 static const WCHAR titleW
[] = {'t','i','t','l','e',0};
732 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
734 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
738 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
744 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, TRUE
, &var
);
750 V_BSTR(var
) = v
? SysAllocString(v
) : NULL
;
754 nsAString_InitDepend(&title_str
, v
);
755 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
756 nsAString_Finish(&title_str
);
758 ERR("SetTitle failed: %08x\n", nsres
);
763 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
765 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
769 TRACE("(%p)->(%p)\n", This
, p
);
775 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, FALSE
, &var
);
776 if(hres
== DISP_E_UNKNOWNNAME
) {
778 }else if(V_VT(var
) != VT_BSTR
) {
779 FIXME("title = %s\n", debugstr_variant(var
));
782 *p
= V_BSTR(var
) ? SysAllocString(V_BSTR(var
)) : NULL
;
788 nsAString_Init(&title_str
, NULL
);
789 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
790 if(NS_SUCCEEDED(nsres
)) {
791 const PRUnichar
*title
;
793 nsAString_GetData(&title_str
, &title
);
794 *p
= *title
? SysAllocString(title
) : NULL
;
796 ERR("GetTitle failed: %08x\n", nsres
);
803 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
805 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
806 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
810 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
812 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
813 FIXME("(%p)->(%p)\n", This
, p
);
817 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
819 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
821 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
823 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
826 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
828 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
830 TRACE("(%p)->(%p)\n", This
, p
);
832 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
835 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
837 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
838 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&varargStart
));
842 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
843 VARIANT_BOOL
*pfResult
)
845 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
846 FIXME("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
850 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
852 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
853 FIXME("(%p)->(%p)\n", This
, p
);
857 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
859 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
860 FIXME("(%p)->(%p)\n", This
, p
);
864 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
866 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
867 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
871 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
873 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
874 FIXME("(%p)->(%p)\n", This
, p
);
878 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
880 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
881 PRInt32 off_left
= 0;
884 TRACE("(%p)->(%p)\n", This
, p
);
886 nsres
= nsIDOMHTMLElement_GetOffsetLeft(This
->nselem
, &off_left
);
887 if(NS_FAILED(nsres
)) {
888 ERR("GetOffsetLeft failed: %08x\n", nsres
);
896 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
898 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
902 TRACE("(%p)->(%p)\n", This
, p
);
904 nsres
= nsIDOMHTMLElement_GetOffsetTop(This
->nselem
, &top
);
905 if(NS_FAILED(nsres
)) {
906 ERR("GetOffsetTop failed: %08x\n", nsres
);
914 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
916 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
920 TRACE("(%p)->(%p)\n", This
, p
);
922 nsres
= nsIDOMHTMLElement_GetOffsetWidth(This
->nselem
, &offset
);
923 if(NS_FAILED(nsres
)) {
924 ERR("GetOffsetWidth failed: %08x\n", nsres
);
932 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
934 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
938 TRACE("(%p)->(%p)\n", This
, p
);
940 nsres
= nsIDOMHTMLElement_GetOffsetHeight(This
->nselem
, &offset
);
941 if(NS_FAILED(nsres
)) {
942 ERR("GetOffsetHeight failed: %08x\n", nsres
);
950 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
952 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
953 nsIDOMElement
*nsparent
;
957 TRACE("(%p)->(%p)\n", This
, p
);
959 nsres
= nsIDOMHTMLElement_GetOffsetParent(This
->nselem
, &nsparent
);
960 if(NS_FAILED(nsres
)) {
961 ERR("GetOffsetParent failed: %08x\n", nsres
);
968 hres
= get_node(This
->node
.doc
, (nsIDOMNode
*)nsparent
, TRUE
, &node
);
969 nsIDOMElement_Release(nsparent
);
973 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)p
);
982 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
984 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
988 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
991 FIXME("NULL nselem\n");
995 nsAString_InitDepend(&html_str
, v
);
996 nsres
= nsIDOMHTMLElement_SetInnerHTML(This
->nselem
, &html_str
);
997 nsAString_Finish(&html_str
);
998 if(NS_FAILED(nsres
)) {
999 FIXME("SetInnerHtml failed %08x\n", nsres
);
1006 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
1008 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1012 TRACE("(%p)->(%p)\n", This
, p
);
1015 FIXME("NULL nselem\n");
1019 nsAString_Init(&html_str
, NULL
);
1020 nsres
= nsIDOMHTMLElement_GetInnerHTML(This
->nselem
, &html_str
);
1021 if(NS_SUCCEEDED(nsres
)) {
1022 const PRUnichar
*html
;
1024 nsAString_GetData(&html_str
, &html
);
1025 *p
= *html
? SysAllocString(html
) : NULL
;
1027 FIXME("SetInnerHtml failed %08x\n", nsres
);
1031 nsAString_Finish(&html_str
);
1035 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
1037 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1038 nsIDOMNode
*nschild
, *tmp
;
1039 nsIDOMText
*text_node
;
1043 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1046 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
1047 if(NS_FAILED(nsres
)) {
1048 ERR("GetLastChild failed: %08x\n", nsres
);
1054 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
1055 nsIDOMNode_Release(nschild
);
1056 if(NS_FAILED(nsres
)) {
1057 ERR("RemoveChild failed: %08x\n", nsres
);
1060 nsIDOMNode_Release(tmp
);
1063 nsAString_InitDepend(&text_str
, v
);
1064 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
1065 nsAString_Finish(&text_str
);
1066 if(NS_FAILED(nsres
)) {
1067 ERR("CreateTextNode failed: %08x\n", nsres
);
1071 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
1072 if(NS_FAILED(nsres
)) {
1073 ERR("AppendChild failed: %08x\n", nsres
);
1077 nsIDOMNode_Release(tmp
);
1081 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
1083 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1085 TRACE("(%p)->(%p)\n", This
, p
);
1087 return get_node_text(&This
->node
, p
);
1090 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
1092 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1094 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1096 return replace_node_by_html(This
->node
.doc
->nsdoc
, This
->node
.nsnode
, v
);
1099 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
1101 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1105 WARN("(%p)->(%p) semi-stub\n", This
, p
);
1107 nsAString_Init(&html_str
, NULL
);
1108 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
1109 if(SUCCEEDED(hres
)) {
1110 const PRUnichar
*html
;
1112 nsAString_GetData(&html_str
, &html
);
1113 *p
= SysAllocString(html
);
1115 hres
= E_OUTOFMEMORY
;
1118 nsAString_Finish(&html_str
);
1120 TRACE("ret %s\n", debugstr_w(*p
));
1124 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1126 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1127 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1131 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1133 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1134 FIXME("(%p)->(%p)\n", This
, p
);
1138 static HRESULT
HTMLElement_InsertAdjacentNode(HTMLElement
*This
, BSTR where
, nsIDOMNode
*nsnode
)
1140 static const WCHAR wszBeforeBegin
[] = {'b','e','f','o','r','e','B','e','g','i','n',0};
1141 static const WCHAR wszAfterBegin
[] = {'a','f','t','e','r','B','e','g','i','n',0};
1142 static const WCHAR wszBeforeEnd
[] = {'b','e','f','o','r','e','E','n','d',0};
1143 static const WCHAR wszAfterEnd
[] = {'a','f','t','e','r','E','n','d',0};
1146 if (!strcmpiW(where
, wszBeforeBegin
))
1150 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1151 if (!parent
) return E_INVALIDARG
;
1152 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &unused
);
1153 if (unused
) nsIDOMNode_Release(unused
);
1154 nsIDOMNode_Release(parent
);
1156 else if (!strcmpiW(where
, wszAfterBegin
))
1159 nsIDOMNode
*first_child
;
1160 nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1161 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &unused
);
1162 if (unused
) nsIDOMNode_Release(unused
);
1163 if (first_child
) nsIDOMNode_Release(first_child
);
1165 else if (!strcmpiW(where
, wszBeforeEnd
))
1168 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &unused
);
1169 if (unused
) nsIDOMNode_Release(unused
);
1171 else if (!strcmpiW(where
, wszAfterEnd
))
1174 nsIDOMNode
*next_sibling
;
1176 nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1177 if (!parent
) return E_INVALIDARG
;
1179 nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1182 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &unused
);
1183 nsIDOMNode_Release(next_sibling
);
1186 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &unused
);
1187 nsIDOMNode_Release(parent
);
1188 if (unused
) nsIDOMNode_Release(unused
);
1192 ERR("invalid where: %s\n", debugstr_w(where
));
1193 return E_INVALIDARG
;
1196 if (NS_FAILED(nsres
))
1202 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1205 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1207 nsIDOMNSRange
*nsrange
;
1213 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1215 if(!This
->node
.doc
->nsdoc
) {
1216 WARN("NULL nsdoc\n");
1217 return E_UNEXPECTED
;
1220 nsres
= nsIDOMHTMLDocument_CreateRange(This
->node
.doc
->nsdoc
, &range
);
1221 if(NS_FAILED(nsres
))
1223 ERR("CreateRange failed: %08x\n", nsres
);
1227 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1229 nsIDOMRange_QueryInterface(range
, &IID_nsIDOMNSRange
, (void **)&nsrange
);
1230 nsIDOMRange_Release(range
);
1231 if(NS_FAILED(nsres
))
1233 ERR("getting nsIDOMNSRange failed: %08x\n", nsres
);
1237 nsAString_InitDepend(&ns_html
, html
);
1239 nsres
= nsIDOMNSRange_CreateContextualFragment(nsrange
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1240 nsIDOMNSRange_Release(nsrange
);
1241 nsAString_Finish(&ns_html
);
1243 if(NS_FAILED(nsres
) || !nsnode
)
1245 ERR("CreateTextNode failed: %08x\n", nsres
);
1249 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1250 nsIDOMNode_Release(nsnode
);
1255 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1258 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1264 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1266 if(!This
->node
.doc
->nsdoc
) {
1267 WARN("NULL nsdoc\n");
1268 return E_UNEXPECTED
;
1272 nsAString_InitDepend(&ns_text
, text
);
1273 nsres
= nsIDOMDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1274 nsAString_Finish(&ns_text
);
1276 if(NS_FAILED(nsres
) || !nsnode
)
1278 ERR("CreateTextNode failed: %08x\n", nsres
);
1282 hr
= HTMLElement_InsertAdjacentNode(This
, where
, nsnode
);
1283 nsIDOMNode_Release(nsnode
);
1288 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1290 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1291 FIXME("(%p)->(%p)\n", This
, p
);
1295 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1297 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1298 FIXME("(%p)->(%p)\n", This
, p
);
1302 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1304 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1306 TRACE("(%p)\n", This
);
1308 return call_fire_event(&This
->node
, EVENTID_CLICK
);
1311 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1312 IHTMLFiltersCollection
**p
)
1314 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1315 TRACE("(%p)->(%p)\n", This
, p
);
1320 *p
= HTMLFiltersCollection_Create();
1325 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1327 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1328 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1332 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1334 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1335 FIXME("(%p)->(%p)\n", This
, p
);
1339 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1341 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1342 FIXME("(%p)->(%p)\n", This
, String
);
1346 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1348 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1349 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1353 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1355 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1356 FIXME("(%p)->(%p)\n", This
, p
);
1360 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1362 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1363 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1367 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1369 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1370 FIXME("(%p)->(%p)\n", This
, p
);
1374 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1376 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1377 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1381 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1383 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1384 FIXME("(%p)->(%p)\n", This
, p
);
1388 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1390 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1391 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1395 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1397 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1398 FIXME("(%p)->(%p)\n", This
, p
);
1402 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1404 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1405 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1409 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1411 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1412 FIXME("(%p)->(%p)\n", This
, p
);
1416 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1418 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1419 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1423 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1425 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1426 FIXME("(%p)->(%p)\n", This
, p
);
1430 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1432 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1433 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1437 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1439 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1440 FIXME("(%p)->(%p)\n", This
, p
);
1444 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1446 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1447 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1451 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1453 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1454 FIXME("(%p)->(%p)\n", This
, p
);
1458 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1460 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1461 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1465 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1467 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1468 FIXME("(%p)->(%p)\n", This
, p
);
1472 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1474 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1475 nsIDOMNodeList
*nsnode_list
;
1478 TRACE("(%p)->(%p)\n", This
, p
);
1480 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1481 if(NS_FAILED(nsres
)) {
1482 ERR("GetChildNodes failed: %08x\n", nsres
);
1486 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
,
1487 (IUnknown
*)&This
->IHTMLElement_iface
, nsnode_list
);
1489 nsIDOMNodeList_Release(nsnode_list
);
1493 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1495 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1497 TRACE("(%p)->(%p)\n", This
, p
);
1499 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1503 static const IHTMLElementVtbl HTMLElementVtbl
= {
1504 HTMLElement_QueryInterface
,
1506 HTMLElement_Release
,
1507 HTMLElement_GetTypeInfoCount
,
1508 HTMLElement_GetTypeInfo
,
1509 HTMLElement_GetIDsOfNames
,
1511 HTMLElement_setAttribute
,
1512 HTMLElement_getAttribute
,
1513 HTMLElement_removeAttribute
,
1514 HTMLElement_put_className
,
1515 HTMLElement_get_className
,
1518 HTMLElement_get_tagName
,
1519 HTMLElement_get_parentElement
,
1520 HTMLElement_get_style
,
1521 HTMLElement_put_onhelp
,
1522 HTMLElement_get_onhelp
,
1523 HTMLElement_put_onclick
,
1524 HTMLElement_get_onclick
,
1525 HTMLElement_put_ondblclick
,
1526 HTMLElement_get_ondblclick
,
1527 HTMLElement_put_onkeydown
,
1528 HTMLElement_get_onkeydown
,
1529 HTMLElement_put_onkeyup
,
1530 HTMLElement_get_onkeyup
,
1531 HTMLElement_put_onkeypress
,
1532 HTMLElement_get_onkeypress
,
1533 HTMLElement_put_onmouseout
,
1534 HTMLElement_get_onmouseout
,
1535 HTMLElement_put_onmouseover
,
1536 HTMLElement_get_onmouseover
,
1537 HTMLElement_put_onmousemove
,
1538 HTMLElement_get_onmousemove
,
1539 HTMLElement_put_onmousedown
,
1540 HTMLElement_get_onmousedown
,
1541 HTMLElement_put_onmouseup
,
1542 HTMLElement_get_onmouseup
,
1543 HTMLElement_get_document
,
1544 HTMLElement_put_title
,
1545 HTMLElement_get_title
,
1546 HTMLElement_put_language
,
1547 HTMLElement_get_language
,
1548 HTMLElement_put_onselectstart
,
1549 HTMLElement_get_onselectstart
,
1550 HTMLElement_scrollIntoView
,
1551 HTMLElement_contains
,
1552 HTMLElement_get_sourceIndex
,
1553 HTMLElement_get_recordNumber
,
1554 HTMLElement_put_lang
,
1555 HTMLElement_get_lang
,
1556 HTMLElement_get_offsetLeft
,
1557 HTMLElement_get_offsetTop
,
1558 HTMLElement_get_offsetWidth
,
1559 HTMLElement_get_offsetHeight
,
1560 HTMLElement_get_offsetParent
,
1561 HTMLElement_put_innerHTML
,
1562 HTMLElement_get_innerHTML
,
1563 HTMLElement_put_innerText
,
1564 HTMLElement_get_innerText
,
1565 HTMLElement_put_outerHTML
,
1566 HTMLElement_get_outerHTML
,
1567 HTMLElement_put_outerText
,
1568 HTMLElement_get_outerText
,
1569 HTMLElement_insertAdjacentHTML
,
1570 HTMLElement_insertAdjacentText
,
1571 HTMLElement_get_parentTextEdit
,
1572 HTMLElement_get_isTextEdit
,
1574 HTMLElement_get_filters
,
1575 HTMLElement_put_ondragstart
,
1576 HTMLElement_get_ondragstart
,
1577 HTMLElement_toString
,
1578 HTMLElement_put_onbeforeupdate
,
1579 HTMLElement_get_onbeforeupdate
,
1580 HTMLElement_put_onafterupdate
,
1581 HTMLElement_get_onafterupdate
,
1582 HTMLElement_put_onerrorupdate
,
1583 HTMLElement_get_onerrorupdate
,
1584 HTMLElement_put_onrowexit
,
1585 HTMLElement_get_onrowexit
,
1586 HTMLElement_put_onrowenter
,
1587 HTMLElement_get_onrowenter
,
1588 HTMLElement_put_ondatasetchanged
,
1589 HTMLElement_get_ondatasetchanged
,
1590 HTMLElement_put_ondataavailable
,
1591 HTMLElement_get_ondataavailable
,
1592 HTMLElement_put_ondatasetcomplete
,
1593 HTMLElement_get_ondatasetcomplete
,
1594 HTMLElement_put_onfilterchange
,
1595 HTMLElement_get_onfilterchange
,
1596 HTMLElement_get_children
,
1600 HTMLElement
*unsafe_impl_from_IHTMLElement(IHTMLElement
*iface
)
1602 return iface
->lpVtbl
== &HTMLElementVtbl
? impl_from_IHTMLElement(iface
) : NULL
;
1605 static inline HTMLElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
1607 return CONTAINING_RECORD(iface
, HTMLElement
, node
);
1610 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1612 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1616 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1617 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1618 *ppv
= &This
->IHTMLElement_iface
;
1619 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1620 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1621 *ppv
= &This
->IHTMLElement_iface
;
1622 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1623 TRACE("(%p)->(IID_IHTMLElement %p)\n", This
, ppv
);
1624 *ppv
= &This
->IHTMLElement_iface
;
1625 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1626 TRACE("(%p)->(IID_IHTMLElement2 %p)\n", This
, ppv
);
1627 *ppv
= &This
->IHTMLElement2_iface
;
1628 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1629 TRACE("(%p)->(IID_IHTMLElement3 %p)\n", This
, ppv
);
1630 *ppv
= &This
->IHTMLElement3_iface
;
1631 }else if(IsEqualGUID(&IID_IHTMLElement4
, riid
)) {
1632 TRACE("(%p)->(IID_IHTMLElement4 %p)\n", This
, ppv
);
1633 *ppv
= &This
->IHTMLElement4_iface
;
1634 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1635 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
1636 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1640 IHTMLElement_AddRef(&This
->IHTMLElement_iface
);
1644 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1647 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1649 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1651 ConnectionPointContainer_Destroy(&This
->cp_container
);
1654 nsIDOMHTMLElement_Release(This
->nselem
);
1656 This
->style
->elem
= NULL
;
1657 IHTMLStyle_Release(&This
->style
->IHTMLStyle_iface
);
1660 HTMLDOMAttribute
*attr
;
1662 LIST_FOR_EACH_ENTRY(attr
, &This
->attrs
->attrs
, HTMLDOMAttribute
, entry
)
1665 This
->attrs
->elem
= NULL
;
1666 IHTMLAttributeCollection_Release(&This
->attrs
->IHTMLAttributeCollection_iface
);
1669 heap_free(This
->filter
);
1671 HTMLDOMNode_destructor(&This
->node
);
1674 HRESULT
HTMLElement_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
1676 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1677 HTMLElement
*new_elem
;
1680 hres
= HTMLElement_Create(This
->node
.doc
, nsnode
, FALSE
, &new_elem
);
1684 IHTMLElement_AddRef(&new_elem
->IHTMLElement_iface
);
1685 *ret
= &new_elem
->node
;
1689 static const NodeImplVtbl HTMLElementImplVtbl
= {
1691 HTMLElement_destructor
,
1693 HTMLElement_get_attr_col
1696 static inline HTMLElement
*impl_from_DispatchEx(DispatchEx
*iface
)
1698 return CONTAINING_RECORD(iface
, HTMLElement
, node
.dispex
);
1701 static HRESULT
HTMLElement_get_dispid(DispatchEx
*dispex
, BSTR name
,
1702 DWORD grfdex
, DISPID
*pid
)
1704 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1706 if(This
->node
.vtbl
->get_dispid
)
1707 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1709 return DISP_E_UNKNOWNNAME
;
1712 static HRESULT
HTMLElement_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
1713 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1714 IServiceProvider
*caller
)
1716 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1718 if(This
->node
.vtbl
->invoke
)
1719 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1720 params
, res
, ei
, caller
);
1722 ERR("(%p): element has no invoke method\n", This
);
1726 static HRESULT
HTMLElement_populate_props(DispatchEx
*dispex
)
1728 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1729 nsIDOMNamedNodeMap
*attrs
;
1732 const PRUnichar
*str
;
1744 nsres
= nsIDOMHTMLElement_GetAttributes(This
->nselem
, &attrs
);
1745 if(NS_FAILED(nsres
))
1748 nsres
= nsIDOMNamedNodeMap_GetLength(attrs
, &len
);
1749 if(NS_FAILED(nsres
)) {
1750 nsIDOMNamedNodeMap_Release(attrs
);
1754 nsAString_Init(&nsstr
, NULL
);
1755 for(i
=0; i
<len
; i
++) {
1756 nsres
= nsIDOMNamedNodeMap_Item(attrs
, i
, &node
);
1757 if(NS_FAILED(nsres
))
1760 nsres
= nsIDOMNode_GetNodeName(node
, &nsstr
);
1761 if(NS_FAILED(nsres
)) {
1762 nsIDOMNode_Release(node
);
1766 nsAString_GetData(&nsstr
, &str
);
1767 name
= SysAllocString(str
);
1769 nsIDOMNode_Release(node
);
1773 hres
= IDispatchEx_GetDispID(&dispex
->IDispatchEx_iface
, name
, fdexNameCaseInsensitive
, &id
);
1774 if(hres
!= DISP_E_UNKNOWNNAME
) {
1775 nsIDOMNode_Release(node
);
1776 SysFreeString(name
);
1780 nsres
= nsIDOMNode_GetNodeValue(node
, &nsstr
);
1781 nsIDOMNode_Release(node
);
1782 if(NS_FAILED(nsres
)) {
1783 SysFreeString(name
);
1787 nsAString_GetData(&nsstr
, &str
);
1788 V_VT(&value
) = VT_BSTR
;
1790 V_BSTR(&value
) = SysAllocString(str
);
1791 if(!V_BSTR(&value
)) {
1792 SysFreeString(name
);
1796 V_BSTR(&value
) = NULL
;
1798 IHTMLElement_setAttribute(&This
->IHTMLElement_iface
, name
, value
, 0);
1799 SysFreeString(name
);
1800 VariantClear(&value
);
1802 nsAString_Finish(&nsstr
);
1804 nsIDOMNamedNodeMap_Release(attrs
);
1808 static const tid_t HTMLElement_iface_tids
[] = {
1813 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1815 HTMLElement_get_dispid
,
1817 HTMLElement_populate_props
1820 static dispex_static_data_t HTMLElement_dispex
= {
1821 &HTMLElement_dispex_vtbl
,
1822 DispHTMLUnknownElement_tid
,
1824 HTMLElement_iface_tids
1827 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1829 This
->IHTMLElement_iface
.lpVtbl
= &HTMLElementVtbl
;
1831 HTMLElement2_Init(This
);
1832 HTMLElement3_Init(This
);
1834 if(dispex_data
&& !dispex_data
->vtbl
)
1835 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1836 init_dispex(&This
->node
.dispex
, (IUnknown
*)&This
->IHTMLElement_iface
,
1837 dispex_data
? dispex_data
: &HTMLElement_dispex
);
1840 nsIDOMHTMLElement_AddRef(nselem
);
1841 This
->nselem
= nselem
;
1843 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1845 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)&This
->IHTMLElement_iface
);
1848 HRESULT
HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
, HTMLElement
**ret
)
1850 nsIDOMHTMLElement
*nselem
;
1851 nsAString class_name_str
;
1852 const PRUnichar
*class_name
;
1853 const tag_desc_t
*tag
;
1858 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1859 if(NS_FAILED(nsres
))
1862 nsAString_Init(&class_name_str
, NULL
);
1863 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1865 nsAString_GetData(&class_name_str
, &class_name
);
1867 tag
= get_tag_desc(class_name
);
1869 hres
= tag
->constructor(doc
, nselem
, &elem
);
1870 }else if(use_generic
) {
1871 hres
= HTMLGenericElement_Create(doc
, nselem
, &elem
);
1873 elem
= heap_alloc_zero(sizeof(HTMLElement
));
1875 HTMLElement_Init(elem
, doc
, nselem
, &HTMLElement_dispex
);
1876 elem
->node
.vtbl
= &HTMLElementImplVtbl
;
1879 hres
= E_OUTOFMEMORY
;
1883 TRACE("%s ret %p\n", debugstr_w(class_name
), elem
);
1885 nsIDOMElement_Release(nselem
);
1886 nsAString_Finish(&class_name_str
);
1894 /* interface IHTMLFiltersCollection */
1895 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1897 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1899 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
1901 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1902 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1903 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1904 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1905 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1906 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1907 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1908 return *ppv
? S_OK
: E_NOINTERFACE
;
1912 IUnknown_AddRef((IUnknown
*)*ppv
);
1916 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1917 return E_NOINTERFACE
;
1920 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
1922 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1923 LONG ref
= InterlockedIncrement(&This
->ref
);
1925 TRACE("(%p) ref=%d\n", This
, ref
);
1930 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
1932 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1933 LONG ref
= InterlockedDecrement(&This
->ref
);
1935 TRACE("(%p) ref=%d\n", This
, ref
);
1945 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
1947 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1948 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1951 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
1952 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1954 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1955 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1958 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
1959 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
1960 LCID lcid
, DISPID
*rgDispId
)
1962 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1963 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
1967 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
1968 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
1969 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1971 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1972 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
1973 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1976 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
1978 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1983 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
1989 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
1991 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1992 FIXME("(%p)->(%p)\n", This
, p
);
1996 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
1998 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1999 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
2003 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
2004 HTMLFiltersCollection_QueryInterface
,
2005 HTMLFiltersCollection_AddRef
,
2006 HTMLFiltersCollection_Release
,
2007 HTMLFiltersCollection_GetTypeInfoCount
,
2008 HTMLFiltersCollection_GetTypeInfo
,
2009 HTMLFiltersCollection_GetIDsOfNames
,
2010 HTMLFiltersCollection_Invoke
,
2011 HTMLFiltersCollection_get_length
,
2012 HTMLFiltersCollection_get__newEnum
,
2013 HTMLFiltersCollection_item
2016 static HRESULT
HTMLFiltersCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2021 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
2022 idx
= idx
*10 + (*ptr
-'0');
2024 return DISP_E_UNKNOWNNAME
;
2026 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
2027 TRACE("ret %x\n", *dispid
);
2031 static HRESULT
HTMLFiltersCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2032 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2034 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex
, id
, lcid
, flags
, params
, res
, ei
);
2036 V_VT(res
) = VT_DISPATCH
;
2037 V_DISPATCH(res
) = NULL
;
2039 FIXME("always returning NULL\n");
2044 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
2046 HTMLFiltersCollection_get_dispid
,
2047 HTMLFiltersCollection_invoke
,
2051 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
2052 IHTMLFiltersCollection_tid
,
2055 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
2056 &HTMLFiltersCollection_dispex_vtbl
,
2057 IHTMLFiltersCollection_tid
,
2059 HTMLFiltersCollection_iface_tids
2062 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void)
2064 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
2066 ret
->IHTMLFiltersCollection_iface
.lpVtbl
= &HTMLFiltersCollectionVtbl
;
2069 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLFiltersCollection_iface
,
2070 &HTMLFiltersCollection_dispex
);
2072 return &ret
->IHTMLFiltersCollection_iface
;
2075 /* interface IHTMLAttributeCollection */
2076 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection
*iface
)
2078 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection_iface
);
2081 static HRESULT WINAPI
HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection
*iface
, REFIID riid
, void **ppv
)
2083 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2087 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2088 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
2089 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2090 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection
, riid
)) {
2091 TRACE("(%p)->(IID_IHTMLAttributeCollection %p)\n", This
, ppv
);
2092 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2093 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2
, riid
)) {
2094 TRACE("(%p)->(IID_IHTMLAttributeCollection2 %p)\n", This
, ppv
);
2095 *ppv
= &This
->IHTMLAttributeCollection2_iface
;
2096 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3
, riid
)) {
2097 TRACE("(%p)->(IID_IHTMLAttributeCollection3 %p)\n", This
, ppv
);
2098 *ppv
= &This
->IHTMLAttributeCollection3_iface
;
2099 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2100 return *ppv
? S_OK
: E_NOINTERFACE
;
2104 IUnknown_AddRef((IUnknown
*)*ppv
);
2108 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
2109 return E_NOINTERFACE
;
2112 static ULONG WINAPI
HTMLAttributeCollection_AddRef(IHTMLAttributeCollection
*iface
)
2114 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2115 LONG ref
= InterlockedIncrement(&This
->ref
);
2117 TRACE("(%p) ref=%d\n", This
, ref
);
2122 static ULONG WINAPI
HTMLAttributeCollection_Release(IHTMLAttributeCollection
*iface
)
2124 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2125 LONG ref
= InterlockedDecrement(&This
->ref
);
2127 TRACE("(%p) ref=%d\n", This
, ref
);
2130 while(!list_empty(&This
->attrs
)) {
2131 HTMLDOMAttribute
*attr
= LIST_ENTRY(list_head(&This
->attrs
), HTMLDOMAttribute
, entry
);
2133 list_remove(&attr
->entry
);
2135 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2144 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection
*iface
, UINT
*pctinfo
)
2146 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2147 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2150 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection
*iface
, UINT iTInfo
,
2151 LCID lcid
, ITypeInfo
**ppTInfo
)
2153 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2154 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2157 static HRESULT WINAPI
HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection
*iface
, REFIID riid
,
2158 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2160 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2161 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2165 static HRESULT WINAPI
HTMLAttributeCollection_Invoke(IHTMLAttributeCollection
*iface
, DISPID dispIdMember
,
2166 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2167 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2169 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2170 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2171 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2174 static HRESULT
get_attr_dispid_by_idx(HTMLAttributeCollection
*This
, LONG
*idx
, DISPID
*dispid
)
2176 IDispatchEx
*dispex
= &This
->elem
->node
.dispex
.IDispatchEx_iface
;
2177 DISPID id
= DISPID_STARTENUM
;
2181 FIXME("filter non-enumerable attributes out\n");
2184 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2187 else if(hres
== S_FALSE
)
2197 return *idx
==len
? S_OK
: DISP_E_UNKNOWNNAME
;
2204 static inline HRESULT
get_attr_dispid_by_name(HTMLAttributeCollection
*This
, BSTR name
, DISPID
*id
)
2208 if(name
[0]>='0' && name
[0]<='9') {
2212 idx
= strtoulW(name
, &end_ptr
, 10);
2214 hres
= get_attr_dispid_by_idx(This
, &idx
, id
);
2221 WARN("NULL elem\n");
2222 return E_UNEXPECTED
;
2225 hres
= IDispatchEx_GetDispID(&This
->elem
->node
.dispex
.IDispatchEx_iface
,
2226 name
, fdexNameCaseInsensitive
, id
);
2230 static inline HRESULT
get_domattr(HTMLAttributeCollection
*This
, DISPID id
, LONG
*list_pos
, HTMLDOMAttribute
**attr
)
2232 HTMLDOMAttribute
*iter
;
2237 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2238 if(iter
->dispid
== id
) {
2247 WARN("NULL elem\n");
2248 return E_UNEXPECTED
;
2252 hres
= HTMLDOMAttribute_Create(This
->elem
, id
, attr
);
2257 IHTMLDOMAttribute_AddRef(&(*attr
)->IHTMLDOMAttribute_iface
);
2263 static HRESULT WINAPI
HTMLAttributeCollection_get_length(IHTMLAttributeCollection
*iface
, LONG
*p
)
2265 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2268 TRACE("(%p)->(%p)\n", This
, p
);
2271 hres
= get_attr_dispid_by_idx(This
, p
, NULL
);
2275 static HRESULT WINAPI
HTMLAttributeCollection__newEnum(IHTMLAttributeCollection
*iface
, IUnknown
**p
)
2277 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2278 FIXME("(%p)->(%p)\n", This
, p
);
2282 static HRESULT WINAPI
HTMLAttributeCollection_item(IHTMLAttributeCollection
*iface
, VARIANT
*name
, IDispatch
**ppItem
)
2284 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2285 HTMLDOMAttribute
*attr
;
2289 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(name
), ppItem
);
2291 switch(V_VT(name
)) {
2293 hres
= get_attr_dispid_by_idx(This
, &V_I4(name
), &id
);
2296 hres
= get_attr_dispid_by_name(This
, V_BSTR(name
), &id
);
2299 FIXME("unsupported name %s\n", debugstr_variant(name
));
2302 if(hres
== DISP_E_UNKNOWNNAME
)
2303 return E_INVALIDARG
;
2307 hres
= get_domattr(This
, id
, NULL
, &attr
);
2311 *ppItem
= (IDispatch
*)&attr
->IHTMLDOMAttribute_iface
;
2315 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl
= {
2316 HTMLAttributeCollection_QueryInterface
,
2317 HTMLAttributeCollection_AddRef
,
2318 HTMLAttributeCollection_Release
,
2319 HTMLAttributeCollection_GetTypeInfoCount
,
2320 HTMLAttributeCollection_GetTypeInfo
,
2321 HTMLAttributeCollection_GetIDsOfNames
,
2322 HTMLAttributeCollection_Invoke
,
2323 HTMLAttributeCollection_get_length
,
2324 HTMLAttributeCollection__newEnum
,
2325 HTMLAttributeCollection_item
2328 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2
*iface
)
2330 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection2_iface
);
2333 static HRESULT WINAPI
HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2
*iface
, REFIID riid
, void **ppv
)
2335 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2336 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2339 static ULONG WINAPI
HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2
*iface
)
2341 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2342 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2345 static ULONG WINAPI
HTMLAttributeCollection2_Release(IHTMLAttributeCollection2
*iface
)
2347 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2348 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2351 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2
*iface
, UINT
*pctinfo
)
2353 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2354 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2357 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2
*iface
, UINT iTInfo
,
2358 LCID lcid
, ITypeInfo
**ppTInfo
)
2360 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2361 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2364 static HRESULT WINAPI
HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2
*iface
, REFIID riid
,
2365 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2367 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2368 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2372 static HRESULT WINAPI
HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2
*iface
, DISPID dispIdMember
,
2373 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2374 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2376 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2377 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2378 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2381 static HRESULT WINAPI
HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2
*iface
, BSTR bstrName
,
2382 IHTMLDOMAttribute
**newretNode
)
2384 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2385 HTMLDOMAttribute
*attr
;
2389 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2391 hres
= get_attr_dispid_by_name(This
, bstrName
, &id
);
2392 if(hres
== DISP_E_UNKNOWNNAME
) {
2395 } else if(FAILED(hres
)) {
2399 hres
= get_domattr(This
, id
, NULL
, &attr
);
2403 *newretNode
= &attr
->IHTMLDOMAttribute_iface
;
2407 static HRESULT WINAPI
HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2
*iface
,
2408 IHTMLDOMAttribute
*ppNode
, IHTMLDOMAttribute
**newretNode
)
2410 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2411 FIXME("(%p)->(%p %p)\n", This
, ppNode
, newretNode
);
2415 static HRESULT WINAPI
HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2
*iface
,
2416 BSTR bstrName
, IHTMLDOMAttribute
**newretNode
)
2418 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2419 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2423 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl
= {
2424 HTMLAttributeCollection2_QueryInterface
,
2425 HTMLAttributeCollection2_AddRef
,
2426 HTMLAttributeCollection2_Release
,
2427 HTMLAttributeCollection2_GetTypeInfoCount
,
2428 HTMLAttributeCollection2_GetTypeInfo
,
2429 HTMLAttributeCollection2_GetIDsOfNames
,
2430 HTMLAttributeCollection2_Invoke
,
2431 HTMLAttributeCollection2_getNamedItem
,
2432 HTMLAttributeCollection2_setNamedItem
,
2433 HTMLAttributeCollection2_removeNamedItem
2436 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3
*iface
)
2438 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection3_iface
);
2441 static HRESULT WINAPI
HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3
*iface
, REFIID riid
, void **ppv
)
2443 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2444 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2447 static ULONG WINAPI
HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3
*iface
)
2449 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2450 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2453 static ULONG WINAPI
HTMLAttributeCollection3_Release(IHTMLAttributeCollection3
*iface
)
2455 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2456 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2459 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3
*iface
, UINT
*pctinfo
)
2461 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2462 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2465 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3
*iface
, UINT iTInfo
,
2466 LCID lcid
, ITypeInfo
**ppTInfo
)
2468 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2469 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2472 static HRESULT WINAPI
HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3
*iface
, REFIID riid
,
2473 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2475 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2476 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2480 static HRESULT WINAPI
HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3
*iface
, DISPID dispIdMember
,
2481 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2482 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2484 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2485 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2486 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2489 static HRESULT WINAPI
HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3
*iface
, BSTR bstrName
,
2490 IHTMLDOMAttribute
**ppNodeOut
)
2492 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2493 return IHTMLAttributeCollection2_getNamedItem(&This
->IHTMLAttributeCollection2_iface
, bstrName
, ppNodeOut
);
2496 static HRESULT WINAPI
HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3
*iface
,
2497 IHTMLDOMAttribute
*pNodeIn
, IHTMLDOMAttribute
**ppNodeOut
)
2499 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2500 FIXME("(%p)->(%p %p)\n", This
, pNodeIn
, ppNodeOut
);
2504 static HRESULT WINAPI
HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3
*iface
,
2505 BSTR bstrName
, IHTMLDOMAttribute
**ppNodeOut
)
2507 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2508 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), ppNodeOut
);
2512 static HRESULT WINAPI
HTMLAttributeCollection3_item(IHTMLAttributeCollection3
*iface
, LONG index
, IHTMLDOMAttribute
**ppNodeOut
)
2514 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2515 HTMLDOMAttribute
*attr
;
2519 TRACE("(%p)->(%d %p)\n", This
, index
, ppNodeOut
);
2521 hres
= get_attr_dispid_by_idx(This
, &index
, &id
);
2522 if(hres
== DISP_E_UNKNOWNNAME
)
2523 return E_INVALIDARG
;
2527 hres
= get_domattr(This
, id
, NULL
, &attr
);
2531 *ppNodeOut
= &attr
->IHTMLDOMAttribute_iface
;
2535 static HRESULT WINAPI
HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3
*iface
, LONG
*p
)
2537 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2538 return IHTMLAttributeCollection_get_length(&This
->IHTMLAttributeCollection_iface
, p
);
2541 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl
= {
2542 HTMLAttributeCollection3_QueryInterface
,
2543 HTMLAttributeCollection3_AddRef
,
2544 HTMLAttributeCollection3_Release
,
2545 HTMLAttributeCollection3_GetTypeInfoCount
,
2546 HTMLAttributeCollection3_GetTypeInfo
,
2547 HTMLAttributeCollection3_GetIDsOfNames
,
2548 HTMLAttributeCollection3_Invoke
,
2549 HTMLAttributeCollection3_getNamedItem
,
2550 HTMLAttributeCollection3_setNamedItem
,
2551 HTMLAttributeCollection3_removeNamedItem
,
2552 HTMLAttributeCollection3_item
,
2553 HTMLAttributeCollection3_get_length
2556 static inline HTMLAttributeCollection
*HTMLAttributeCollection_from_DispatchEx(DispatchEx
*iface
)
2558 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, dispex
);
2561 static HRESULT
HTMLAttributeCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2563 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2564 HTMLDOMAttribute
*attr
;
2568 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(name
), flags
, dispid
);
2570 hres
= get_attr_dispid_by_name(This
, name
, dispid
);
2574 hres
= get_domattr(This
, *dispid
, &pos
, &attr
);
2577 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2579 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+pos
;
2583 static HRESULT
HTMLAttributeCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
2584 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2586 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2588 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
2591 case DISPATCH_PROPERTYGET
: {
2592 HTMLDOMAttribute
*iter
;
2594 id
= id
-MSHTML_DISPID_CUSTOM_MIN
+1;
2596 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2601 return E_INVALIDARG
;
2603 IHTMLDOMAttribute_AddRef(&iter
->IHTMLDOMAttribute_iface
);
2604 V_VT(res
) = VT_DISPATCH
;
2605 V_DISPATCH(res
) = (IDispatch
*)&iter
->IHTMLDOMAttribute_iface
;
2610 FIXME("unimplemented flags %x\n", flags
);
2615 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl
= {
2617 HTMLAttributeCollection_get_dispid
,
2618 HTMLAttributeCollection_invoke
,
2622 static const tid_t HTMLAttributeCollection_iface_tids
[] = {
2623 IHTMLAttributeCollection_tid
,
2624 IHTMLAttributeCollection2_tid
,
2625 IHTMLAttributeCollection3_tid
,
2629 static dispex_static_data_t HTMLAttributeCollection_dispex
= {
2630 &HTMLAttributeCollection_dispex_vtbl
,
2631 DispHTMLAttributeCollection_tid
,
2633 HTMLAttributeCollection_iface_tids
2636 HRESULT
HTMLElement_get_attr_col(HTMLDOMNode
*iface
, HTMLAttributeCollection
**ac
)
2638 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
2641 IHTMLAttributeCollection_AddRef(&This
->attrs
->IHTMLAttributeCollection_iface
);
2646 This
->attrs
= heap_alloc_zero(sizeof(HTMLAttributeCollection
));
2648 return E_OUTOFMEMORY
;
2650 This
->attrs
->IHTMLAttributeCollection_iface
.lpVtbl
= &HTMLAttributeCollectionVtbl
;
2651 This
->attrs
->IHTMLAttributeCollection2_iface
.lpVtbl
= &HTMLAttributeCollection2Vtbl
;
2652 This
->attrs
->IHTMLAttributeCollection3_iface
.lpVtbl
= &HTMLAttributeCollection3Vtbl
;
2653 This
->attrs
->ref
= 2;
2655 This
->attrs
->elem
= This
;
2656 list_init(&This
->attrs
->attrs
);
2657 init_dispex(&This
->attrs
->dispex
, (IUnknown
*)&This
->attrs
->IHTMLAttributeCollection_iface
,
2658 &HTMLAttributeCollection_dispex
);