2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
35 #include "htmlstyle.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 static const WCHAR aW
[] = {'A',0};
40 static const WCHAR bodyW
[] = {'B','O','D','Y',0};
41 static const WCHAR buttonW
[] = {'B','U','T','T','O','N',0};
42 static const WCHAR embedW
[] = {'E','M','B','E','D',0};
43 static const WCHAR formW
[] = {'F','O','R','M',0};
44 static const WCHAR frameW
[] = {'F','R','A','M','E',0};
45 static const WCHAR headW
[] = {'H','E','A','D',0};
46 static const WCHAR iframeW
[] = {'I','F','R','A','M','E',0};
47 static const WCHAR imgW
[] = {'I','M','G',0};
48 static const WCHAR inputW
[] = {'I','N','P','U','T',0};
49 static const WCHAR labelW
[] = {'L','A','B','E','L',0};
50 static const WCHAR linkW
[] = {'L','I','N','K',0};
51 static const WCHAR metaW
[] = {'M','E','T','A',0};
52 static const WCHAR objectW
[] = {'O','B','J','E','C','T',0};
53 static const WCHAR optionW
[] = {'O','P','T','I','O','N',0};
54 static const WCHAR scriptW
[] = {'S','C','R','I','P','T',0};
55 static const WCHAR selectW
[] = {'S','E','L','E','C','T',0};
56 static const WCHAR styleW
[] = {'S','T','Y','L','E',0};
57 static const WCHAR tableW
[] = {'T','A','B','L','E',0};
58 static const WCHAR tdW
[] = {'T','D',0};
59 static const WCHAR textareaW
[] = {'T','E','X','T','A','R','E','A',0};
60 static const WCHAR title_tagW
[]= {'T','I','T','L','E',0};
61 static const WCHAR trW
[] = {'T','R',0};
65 HRESULT (*constructor
)(HTMLDocumentNode
*,nsIDOMHTMLElement
*,HTMLElement
**);
68 static const tag_desc_t tag_descs
[] = {
69 {aW
, HTMLAnchorElement_Create
},
70 {bodyW
, HTMLBodyElement_Create
},
71 {buttonW
, HTMLButtonElement_Create
},
72 {embedW
, HTMLEmbedElement_Create
},
73 {formW
, HTMLFormElement_Create
},
74 {frameW
, HTMLFrameElement_Create
},
75 {headW
, HTMLHeadElement_Create
},
76 {iframeW
, HTMLIFrame_Create
},
77 {imgW
, HTMLImgElement_Create
},
78 {inputW
, HTMLInputElement_Create
},
79 {labelW
, HTMLLabelElement_Create
},
80 {linkW
, HTMLLinkElement_Create
},
81 {metaW
, HTMLMetaElement_Create
},
82 {objectW
, HTMLObjectElement_Create
},
83 {optionW
, HTMLOptionElement_Create
},
84 {scriptW
, HTMLScriptElement_Create
},
85 {selectW
, HTMLSelectElement_Create
},
86 {styleW
, HTMLStyleElement_Create
},
87 {tableW
, HTMLTable_Create
},
88 {tdW
, HTMLTableCell_Create
},
89 {textareaW
, HTMLTextAreaElement_Create
},
90 {title_tagW
, HTMLTitleElement_Create
},
91 {trW
, HTMLTableRow_Create
}
94 static const tag_desc_t
*get_tag_desc(const WCHAR
*tag_name
)
96 DWORD min
=0, max
=sizeof(tag_descs
)/sizeof(*tag_descs
)-1, i
;
101 r
= strcmpW(tag_name
, tag_descs
[i
].name
);
114 HRESULT
replace_node_by_html(nsIDOMHTMLDocument
*nsdoc
, nsIDOMNode
*nsnode
, const WCHAR
*html
)
116 nsIDOMDocumentFragment
*nsfragment
;
117 nsIDOMNode
*nsparent
;
123 nsres
= nsIDOMHTMLDocument_CreateRange(nsdoc
, &range
);
124 if(NS_FAILED(nsres
)) {
125 ERR("CreateRange failed: %08x\n", nsres
);
129 nsAString_InitDepend(&html_str
, html
);
130 nsIDOMRange_CreateContextualFragment(range
, &html_str
, &nsfragment
);
131 nsIDOMRange_Release(range
);
132 nsAString_Finish(&html_str
);
133 if(NS_FAILED(nsres
)) {
134 ERR("CreateContextualFragment failed: %08x\n", nsres
);
138 nsres
= nsIDOMNode_GetParentNode(nsnode
, &nsparent
);
139 if(NS_SUCCEEDED(nsres
) && nsparent
) {
142 nsres
= nsIDOMNode_ReplaceChild(nsparent
, (nsIDOMNode
*)nsfragment
, nsnode
, &nstmp
);
143 nsIDOMNode_Release(nsparent
);
144 if(NS_FAILED(nsres
)) {
145 ERR("ReplaceChild failed: %08x\n", nsres
);
148 nsIDOMNode_Release(nstmp
);
151 ERR("GetParentNode failed: %08x\n", nsres
);
155 nsIDOMDocumentFragment_Release(nsfragment
);
159 nsresult
get_elem_attr_value(nsIDOMHTMLElement
*nselem
, const WCHAR
*name
, nsAString
*val_str
, const PRUnichar
**val
)
164 nsAString_InitDepend(&name_str
, name
);
165 nsAString_Init(val_str
, NULL
);
166 nsres
= nsIDOMHTMLElement_GetAttribute(nselem
, &name_str
, val_str
);
167 nsAString_Finish(&name_str
);
168 if(NS_FAILED(nsres
)) {
169 ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name
), nsres
);
170 nsAString_Finish(val_str
);
174 nsAString_GetData(val_str
, val
);
178 HRESULT
elem_string_attr_getter(HTMLElement
*elem
, const WCHAR
*name
, BOOL use_null
, BSTR
*p
)
180 const PRUnichar
*val
;
185 nsres
= get_elem_attr_value(elem
->nselem
, name
, &val_str
, &val
);
189 TRACE("%s: returning %s\n", debugstr_w(name
), debugstr_w(val
));
191 if(*val
|| !use_null
) {
192 *p
= SysAllocString(val
);
194 hres
= E_OUTOFMEMORY
;
198 nsAString_Finish(&val_str
);
202 HRESULT
elem_string_attr_setter(HTMLElement
*elem
, const WCHAR
*name
, const WCHAR
*value
)
204 nsAString name_str
, val_str
;
207 nsAString_InitDepend(&name_str
, name
);
208 nsAString_InitDepend(&val_str
, value
);
209 nsres
= nsIDOMHTMLElement_SetAttribute(elem
->nselem
, &name_str
, &val_str
);
210 nsAString_Finish(&name_str
);
211 nsAString_Finish(&val_str
);
213 if(NS_FAILED(nsres
)) {
214 WARN("SetAttribute failed: %08x\n", nsres
);
224 IHTMLFiltersCollection IHTMLFiltersCollection_iface
;
227 } HTMLFiltersCollection
;
229 static inline HTMLFiltersCollection
*impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection
*iface
)
231 return CONTAINING_RECORD(iface
, HTMLFiltersCollection
, IHTMLFiltersCollection_iface
);
234 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void);
236 static inline HTMLElement
*impl_from_IHTMLElement(IHTMLElement
*iface
)
238 return CONTAINING_RECORD(iface
, HTMLElement
, IHTMLElement_iface
);
241 HRESULT
create_nselem(HTMLDocumentNode
*doc
, const WCHAR
*tag
, nsIDOMHTMLElement
**ret
)
243 nsIDOMElement
*nselem
;
248 WARN("NULL nsdoc\n");
252 nsAString_InitDepend(&tag_str
, tag
);
253 nsres
= nsIDOMHTMLDocument_CreateElement(doc
->nsdoc
, &tag_str
, &nselem
);
254 nsAString_Finish(&tag_str
);
255 if(NS_FAILED(nsres
)) {
256 ERR("CreateElement failed: %08x\n", nsres
);
260 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLElement
, (void**)ret
);
261 nsIDOMElement_Release(nselem
);
262 if(NS_FAILED(nsres
)) {
263 ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres
);
270 HRESULT
create_element(HTMLDocumentNode
*doc
, const WCHAR
*tag
, HTMLElement
**ret
)
272 nsIDOMHTMLElement
*nselem
;
275 /* Use owner doc if called on document fragment */
279 hres
= create_nselem(doc
, tag
, &nselem
);
283 hres
= HTMLElement_Create(doc
, (nsIDOMNode
*)nselem
, TRUE
, ret
);
284 nsIDOMHTMLElement_Release(nselem
);
288 static HRESULT WINAPI
HTMLElement_QueryInterface(IHTMLElement
*iface
,
289 REFIID riid
, void **ppv
)
291 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
293 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
296 static ULONG WINAPI
HTMLElement_AddRef(IHTMLElement
*iface
)
298 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
300 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
303 static ULONG WINAPI
HTMLElement_Release(IHTMLElement
*iface
)
305 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
307 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
310 static HRESULT WINAPI
HTMLElement_GetTypeInfoCount(IHTMLElement
*iface
, UINT
*pctinfo
)
312 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
313 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
316 static HRESULT WINAPI
HTMLElement_GetTypeInfo(IHTMLElement
*iface
, UINT iTInfo
,
317 LCID lcid
, ITypeInfo
**ppTInfo
)
319 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
320 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
323 static HRESULT WINAPI
HTMLElement_GetIDsOfNames(IHTMLElement
*iface
, REFIID riid
,
324 LPOLESTR
*rgszNames
, UINT cNames
,
325 LCID lcid
, DISPID
*rgDispId
)
327 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
328 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
332 static HRESULT WINAPI
HTMLElement_Invoke(IHTMLElement
*iface
, DISPID dispIdMember
,
333 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
334 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
336 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
337 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
338 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
341 static HRESULT WINAPI
HTMLElement_setAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
342 VARIANT AttributeValue
, LONG lFlags
)
344 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
346 DISPID dispid
, dispidNamed
= DISPID_PROPERTYPUT
;
347 DISPPARAMS dispParams
;
350 TRACE("(%p)->(%s %s %08x)\n", This
, debugstr_w(strAttributeName
), debugstr_variant(&AttributeValue
), lFlags
);
352 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
353 fdexNameCaseInsensitive
| fdexNameEnsure
, &dispid
);
357 dispParams
.cArgs
= 1;
358 dispParams
.cNamedArgs
= 1;
359 dispParams
.rgdispidNamedArgs
= &dispidNamed
;
360 dispParams
.rgvarg
= &AttributeValue
;
362 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
,
363 LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYPUT
, &dispParams
, NULL
, &excep
, NULL
);
367 static HRESULT WINAPI
HTMLElement_getAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
368 LONG lFlags
, VARIANT
*AttributeValue
)
370 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
373 DISPPARAMS dispParams
= {NULL
, NULL
, 0, 0};
376 TRACE("(%p)->(%s %08x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, AttributeValue
);
378 hres
= IDispatchEx_GetDispID(&This
->node
.dispex
.IDispatchEx_iface
, strAttributeName
,
379 fdexNameCaseInsensitive
, &dispid
);
380 if(hres
== DISP_E_UNKNOWNNAME
) {
381 V_VT(AttributeValue
) = VT_NULL
;
386 V_VT(AttributeValue
) = VT_NULL
;
390 hres
= IDispatchEx_InvokeEx(&This
->node
.dispex
.IDispatchEx_iface
, dispid
, LOCALE_SYSTEM_DEFAULT
,
391 DISPATCH_PROPERTYGET
, &dispParams
, AttributeValue
, &excep
, NULL
);
396 static HRESULT WINAPI
HTMLElement_removeAttribute(IHTMLElement
*iface
, BSTR strAttributeName
,
397 LONG lFlags
, VARIANT_BOOL
*pfSuccess
)
399 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
401 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(strAttributeName
), lFlags
, pfSuccess
);
403 return remove_prop(&This
->node
.dispex
, strAttributeName
, pfSuccess
);
406 static HRESULT WINAPI
HTMLElement_put_className(IHTMLElement
*iface
, BSTR v
)
408 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
409 nsAString classname_str
;
412 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
415 FIXME("NULL nselem\n");
419 nsAString_InitDepend(&classname_str
, v
);
420 nsres
= nsIDOMHTMLElement_SetClassName(This
->nselem
, &classname_str
);
421 nsAString_Finish(&classname_str
);
423 ERR("SetClassName failed: %08x\n", nsres
);
428 static HRESULT WINAPI
HTMLElement_get_className(IHTMLElement
*iface
, BSTR
*p
)
430 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
434 TRACE("(%p)->(%p)\n", This
, p
);
437 FIXME("NULL nselem\n");
441 nsAString_Init(&class_str
, NULL
);
442 nsres
= nsIDOMHTMLElement_GetClassName(This
->nselem
, &class_str
);
443 return return_nsstr(nsres
, &class_str
, p
);
446 static HRESULT WINAPI
HTMLElement_put_id(IHTMLElement
*iface
, BSTR v
)
448 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
452 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
455 FIXME("nselem == NULL\n");
459 nsAString_InitDepend(&id_str
, v
);
460 nsres
= nsIDOMHTMLElement_SetId(This
->nselem
, &id_str
);
461 nsAString_Finish(&id_str
);
463 ERR("SetId failed: %08x\n", nsres
);
468 static HRESULT WINAPI
HTMLElement_get_id(IHTMLElement
*iface
, BSTR
*p
)
470 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
474 TRACE("(%p)->(%p)\n", This
, p
);
481 nsAString_Init(&id_str
, NULL
);
482 nsres
= nsIDOMHTMLElement_GetId(This
->nselem
, &id_str
);
483 return return_nsstr(nsres
, &id_str
, p
);
486 static HRESULT WINAPI
HTMLElement_get_tagName(IHTMLElement
*iface
, BSTR
*p
)
488 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
492 TRACE("(%p)->(%p)\n", This
, p
);
495 static const WCHAR comment_tagW
[] = {'!',0};
497 WARN("NULL nselem, assuming comment\n");
499 *p
= SysAllocString(comment_tagW
);
500 return *p
? S_OK
: E_OUTOFMEMORY
;
503 nsAString_Init(&tag_str
, NULL
);
504 nsres
= nsIDOMHTMLElement_GetTagName(This
->nselem
, &tag_str
);
505 return return_nsstr(nsres
, &tag_str
, p
);
508 static HRESULT WINAPI
HTMLElement_get_parentElement(IHTMLElement
*iface
, IHTMLElement
**p
)
510 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
514 TRACE("(%p)->(%p)\n", This
, p
);
516 hres
= IHTMLDOMNode_get_parentNode(&This
->node
.IHTMLDOMNode_iface
, &node
);
520 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement
, (void**)p
);
521 IHTMLDOMNode_Release(node
);
528 static HRESULT WINAPI
HTMLElement_get_style(IHTMLElement
*iface
, IHTMLStyle
**p
)
530 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
532 TRACE("(%p)->(%p)\n", This
, p
);
537 hres
= HTMLStyle_Create(This
, &This
->style
);
542 *p
= &This
->style
->IHTMLStyle_iface
;
543 IHTMLStyle_AddRef(*p
);
547 static HRESULT WINAPI
HTMLElement_put_onhelp(IHTMLElement
*iface
, VARIANT v
)
549 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
550 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
554 static HRESULT WINAPI
HTMLElement_get_onhelp(IHTMLElement
*iface
, VARIANT
*p
)
556 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
557 FIXME("(%p)->(%p)\n", This
, p
);
561 static HRESULT WINAPI
HTMLElement_put_onclick(IHTMLElement
*iface
, VARIANT v
)
563 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
565 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
567 return set_node_event(&This
->node
, EVENTID_CLICK
, &v
);
570 static HRESULT WINAPI
HTMLElement_get_onclick(IHTMLElement
*iface
, VARIANT
*p
)
572 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
574 TRACE("(%p)->(%p)\n", This
, p
);
576 return get_node_event(&This
->node
, EVENTID_CLICK
, p
);
579 static HRESULT WINAPI
HTMLElement_put_ondblclick(IHTMLElement
*iface
, VARIANT v
)
581 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
583 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
585 return set_node_event(&This
->node
, EVENTID_DBLCLICK
, &v
);
588 static HRESULT WINAPI
HTMLElement_get_ondblclick(IHTMLElement
*iface
, VARIANT
*p
)
590 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
592 TRACE("(%p)->(%p)\n", This
, p
);
594 return get_node_event(&This
->node
, EVENTID_DBLCLICK
, p
);
597 static HRESULT WINAPI
HTMLElement_put_onkeydown(IHTMLElement
*iface
, VARIANT v
)
599 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
601 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
603 return set_node_event(&This
->node
, EVENTID_KEYDOWN
, &v
);
606 static HRESULT WINAPI
HTMLElement_get_onkeydown(IHTMLElement
*iface
, VARIANT
*p
)
608 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
610 TRACE("(%p)->(%p)\n", This
, p
);
612 return get_node_event(&This
->node
, EVENTID_KEYDOWN
, p
);
615 static HRESULT WINAPI
HTMLElement_put_onkeyup(IHTMLElement
*iface
, VARIANT v
)
617 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
619 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
621 return set_node_event(&This
->node
, EVENTID_KEYUP
, &v
);
624 static HRESULT WINAPI
HTMLElement_get_onkeyup(IHTMLElement
*iface
, VARIANT
*p
)
626 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
627 FIXME("(%p)->(%p)\n", This
, p
);
631 static HRESULT WINAPI
HTMLElement_put_onkeypress(IHTMLElement
*iface
, VARIANT v
)
633 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
635 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
637 return set_node_event(&This
->node
, EVENTID_KEYPRESS
, &v
);
640 static HRESULT WINAPI
HTMLElement_get_onkeypress(IHTMLElement
*iface
, VARIANT
*p
)
642 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
644 TRACE("(%p)->(%p)\n", This
, p
);
646 return get_node_event(&This
->node
, EVENTID_KEYPRESS
, p
);
649 static HRESULT WINAPI
HTMLElement_put_onmouseout(IHTMLElement
*iface
, VARIANT v
)
651 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
653 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
655 return set_node_event(&This
->node
, EVENTID_MOUSEOUT
, &v
);
658 static HRESULT WINAPI
HTMLElement_get_onmouseout(IHTMLElement
*iface
, VARIANT
*p
)
660 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
662 TRACE("(%p)->(%p)\n", This
, p
);
664 return get_node_event(&This
->node
, EVENTID_MOUSEOUT
, p
);
667 static HRESULT WINAPI
HTMLElement_put_onmouseover(IHTMLElement
*iface
, VARIANT v
)
669 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
671 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
673 return set_node_event(&This
->node
, EVENTID_MOUSEOVER
, &v
);
676 static HRESULT WINAPI
HTMLElement_get_onmouseover(IHTMLElement
*iface
, VARIANT
*p
)
678 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
680 TRACE("(%p)->(%p)\n", This
, p
);
682 return get_node_event(&This
->node
, EVENTID_MOUSEOVER
, p
);
685 static HRESULT WINAPI
HTMLElement_put_onmousemove(IHTMLElement
*iface
, VARIANT v
)
687 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
689 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
691 return set_node_event(&This
->node
, EVENTID_MOUSEMOVE
, &v
);
694 static HRESULT WINAPI
HTMLElement_get_onmousemove(IHTMLElement
*iface
, VARIANT
*p
)
696 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
698 TRACE("(%p)->(%p)\n", This
, p
);
700 return get_node_event(&This
->node
, EVENTID_MOUSEMOVE
, p
);
703 static HRESULT WINAPI
HTMLElement_put_onmousedown(IHTMLElement
*iface
, VARIANT v
)
705 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
707 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
709 return set_node_event(&This
->node
, EVENTID_MOUSEDOWN
, &v
);
712 static HRESULT WINAPI
HTMLElement_get_onmousedown(IHTMLElement
*iface
, VARIANT
*p
)
714 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
716 TRACE("(%p)->(%p)\n", This
, p
);
718 return get_node_event(&This
->node
, EVENTID_MOUSEDOWN
, p
);
721 static HRESULT WINAPI
HTMLElement_put_onmouseup(IHTMLElement
*iface
, VARIANT v
)
723 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
725 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
727 return set_node_event(&This
->node
, EVENTID_MOUSEUP
, &v
);
730 static HRESULT WINAPI
HTMLElement_get_onmouseup(IHTMLElement
*iface
, VARIANT
*p
)
732 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
734 TRACE("(%p)->(%p)\n", This
, p
);
736 return get_node_event(&This
->node
, EVENTID_MOUSEUP
, p
);
739 static HRESULT WINAPI
HTMLElement_get_document(IHTMLElement
*iface
, IDispatch
**p
)
741 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
743 TRACE("(%p)->(%p)\n", This
, p
);
748 if(This
->node
.vtbl
->get_document
)
749 return This
->node
.vtbl
->get_document(&This
->node
, p
);
751 *p
= (IDispatch
*)&This
->node
.doc
->basedoc
.IHTMLDocument2_iface
;
752 IDispatch_AddRef(*p
);
756 static const WCHAR titleW
[] = {'t','i','t','l','e',0};
758 static HRESULT WINAPI
HTMLElement_put_title(IHTMLElement
*iface
, BSTR v
)
760 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
764 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
770 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, TRUE
, &var
);
776 V_BSTR(var
) = v
? SysAllocString(v
) : NULL
;
780 nsAString_InitDepend(&title_str
, v
);
781 nsres
= nsIDOMHTMLElement_SetTitle(This
->nselem
, &title_str
);
782 nsAString_Finish(&title_str
);
784 ERR("SetTitle failed: %08x\n", nsres
);
789 static HRESULT WINAPI
HTMLElement_get_title(IHTMLElement
*iface
, BSTR
*p
)
791 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
795 TRACE("(%p)->(%p)\n", This
, p
);
801 hres
= dispex_get_dprop_ref(&This
->node
.dispex
, titleW
, FALSE
, &var
);
802 if(hres
== DISP_E_UNKNOWNNAME
) {
804 }else if(V_VT(var
) != VT_BSTR
) {
805 FIXME("title = %s\n", debugstr_variant(var
));
808 *p
= V_BSTR(var
) ? SysAllocString(V_BSTR(var
)) : NULL
;
814 nsAString_Init(&title_str
, NULL
);
815 nsres
= nsIDOMHTMLElement_GetTitle(This
->nselem
, &title_str
);
816 return return_nsstr(nsres
, &title_str
, p
);
819 static HRESULT WINAPI
HTMLElement_put_language(IHTMLElement
*iface
, BSTR v
)
821 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
822 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
826 static HRESULT WINAPI
HTMLElement_get_language(IHTMLElement
*iface
, BSTR
*p
)
828 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
829 FIXME("(%p)->(%p)\n", This
, p
);
833 static HRESULT WINAPI
HTMLElement_put_onselectstart(IHTMLElement
*iface
, VARIANT v
)
835 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
837 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
839 return set_node_event(&This
->node
, EVENTID_SELECTSTART
, &v
);
842 static HRESULT WINAPI
HTMLElement_get_onselectstart(IHTMLElement
*iface
, VARIANT
*p
)
844 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
846 TRACE("(%p)->(%p)\n", This
, p
);
848 return get_node_event(&This
->node
, EVENTID_SELECTSTART
, p
);
851 static HRESULT WINAPI
HTMLElement_scrollIntoView(IHTMLElement
*iface
, VARIANT varargStart
)
853 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
854 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&varargStart
));
858 static HRESULT WINAPI
HTMLElement_contains(IHTMLElement
*iface
, IHTMLElement
*pChild
,
859 VARIANT_BOOL
*pfResult
)
861 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
866 TRACE("(%p)->(%p %p)\n", This
, pChild
, pfResult
);
868 child
= unsafe_impl_from_IHTMLElement(pChild
);
870 ERR("not our element\n");
874 nsres
= nsIDOMNode_Contains(This
->node
.nsnode
, child
->node
.nsnode
, &result
);
875 if(NS_FAILED(nsres
)) {
880 *pfResult
= result
? VARIANT_TRUE
: VARIANT_FALSE
;
884 static HRESULT WINAPI
HTMLElement_get_sourceIndex(IHTMLElement
*iface
, LONG
*p
)
886 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
887 FIXME("(%p)->(%p)\n", This
, p
);
891 static HRESULT WINAPI
HTMLElement_get_recordNumber(IHTMLElement
*iface
, VARIANT
*p
)
893 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
894 FIXME("(%p)->(%p)\n", This
, p
);
898 static HRESULT WINAPI
HTMLElement_put_lang(IHTMLElement
*iface
, BSTR v
)
900 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
901 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
905 static HRESULT WINAPI
HTMLElement_get_lang(IHTMLElement
*iface
, BSTR
*p
)
907 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
908 FIXME("(%p)->(%p)\n", This
, p
);
912 static HRESULT WINAPI
HTMLElement_get_offsetLeft(IHTMLElement
*iface
, LONG
*p
)
914 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
917 TRACE("(%p)->(%p)\n", This
, p
);
919 nsres
= nsIDOMHTMLElement_GetOffsetLeft(This
->nselem
, p
);
920 if(NS_FAILED(nsres
)) {
921 ERR("GetOffsetLeft failed: %08x\n", nsres
);
928 static HRESULT WINAPI
HTMLElement_get_offsetTop(IHTMLElement
*iface
, LONG
*p
)
930 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
933 TRACE("(%p)->(%p)\n", This
, p
);
935 nsres
= nsIDOMHTMLElement_GetOffsetTop(This
->nselem
, p
);
936 if(NS_FAILED(nsres
)) {
937 ERR("GetOffsetTop failed: %08x\n", nsres
);
944 static HRESULT WINAPI
HTMLElement_get_offsetWidth(IHTMLElement
*iface
, LONG
*p
)
946 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
949 TRACE("(%p)->(%p)\n", This
, p
);
951 nsres
= nsIDOMHTMLElement_GetOffsetWidth(This
->nselem
, p
);
952 if(NS_FAILED(nsres
)) {
953 ERR("GetOffsetWidth failed: %08x\n", nsres
);
960 static HRESULT WINAPI
HTMLElement_get_offsetHeight(IHTMLElement
*iface
, LONG
*p
)
962 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
965 TRACE("(%p)->(%p)\n", This
, p
);
967 nsres
= nsIDOMHTMLElement_GetOffsetHeight(This
->nselem
, p
);
968 if(NS_FAILED(nsres
)) {
969 ERR("GetOffsetHeight failed: %08x\n", nsres
);
976 static HRESULT WINAPI
HTMLElement_get_offsetParent(IHTMLElement
*iface
, IHTMLElement
**p
)
978 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
979 nsIDOMElement
*nsparent
;
983 TRACE("(%p)->(%p)\n", This
, p
);
985 nsres
= nsIDOMHTMLElement_GetOffsetParent(This
->nselem
, &nsparent
);
986 if(NS_FAILED(nsres
)) {
987 ERR("GetOffsetParent failed: %08x\n", nsres
);
994 hres
= get_node(This
->node
.doc
, (nsIDOMNode
*)nsparent
, TRUE
, &node
);
995 nsIDOMElement_Release(nsparent
);
999 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)p
);
1009 static HRESULT WINAPI
HTMLElement_put_innerHTML(IHTMLElement
*iface
, BSTR v
)
1011 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1015 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1018 FIXME("NULL nselem\n");
1022 nsAString_InitDepend(&html_str
, v
);
1023 nsres
= nsIDOMHTMLElement_SetInnerHTML(This
->nselem
, &html_str
);
1024 nsAString_Finish(&html_str
);
1025 if(NS_FAILED(nsres
)) {
1026 FIXME("SetInnerHtml failed %08x\n", nsres
);
1033 static HRESULT WINAPI
HTMLElement_get_innerHTML(IHTMLElement
*iface
, BSTR
*p
)
1035 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1039 TRACE("(%p)->(%p)\n", This
, p
);
1042 FIXME("NULL nselem\n");
1046 nsAString_Init(&html_str
, NULL
);
1047 nsres
= nsIDOMHTMLElement_GetInnerHTML(This
->nselem
, &html_str
);
1048 return return_nsstr(nsres
, &html_str
, p
);
1051 static HRESULT WINAPI
HTMLElement_put_innerText(IHTMLElement
*iface
, BSTR v
)
1053 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1054 nsIDOMNode
*nschild
, *tmp
;
1055 nsIDOMText
*text_node
;
1059 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1062 nsres
= nsIDOMHTMLElement_GetLastChild(This
->nselem
, &nschild
);
1063 if(NS_FAILED(nsres
)) {
1064 ERR("GetLastChild failed: %08x\n", nsres
);
1070 nsres
= nsIDOMHTMLElement_RemoveChild(This
->nselem
, nschild
, &tmp
);
1071 nsIDOMNode_Release(nschild
);
1072 if(NS_FAILED(nsres
)) {
1073 ERR("RemoveChild failed: %08x\n", nsres
);
1076 nsIDOMNode_Release(tmp
);
1079 nsAString_InitDepend(&text_str
, v
);
1080 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &text_str
, &text_node
);
1081 nsAString_Finish(&text_str
);
1082 if(NS_FAILED(nsres
)) {
1083 ERR("CreateTextNode failed: %08x\n", nsres
);
1087 nsres
= nsIDOMHTMLElement_AppendChild(This
->nselem
, (nsIDOMNode
*)text_node
, &tmp
);
1088 if(NS_FAILED(nsres
)) {
1089 ERR("AppendChild failed: %08x\n", nsres
);
1093 nsIDOMNode_Release(tmp
);
1097 static HRESULT WINAPI
HTMLElement_get_innerText(IHTMLElement
*iface
, BSTR
*p
)
1099 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1101 TRACE("(%p)->(%p)\n", This
, p
);
1103 return get_node_text(&This
->node
, p
);
1106 static HRESULT WINAPI
HTMLElement_put_outerHTML(IHTMLElement
*iface
, BSTR v
)
1108 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1110 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1112 return replace_node_by_html(This
->node
.doc
->nsdoc
, This
->node
.nsnode
, v
);
1115 static HRESULT WINAPI
HTMLElement_get_outerHTML(IHTMLElement
*iface
, BSTR
*p
)
1117 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1121 WARN("(%p)->(%p) semi-stub\n", This
, p
);
1123 nsAString_Init(&html_str
, NULL
);
1124 hres
= nsnode_to_nsstring(This
->node
.nsnode
, &html_str
);
1125 if(SUCCEEDED(hres
)) {
1126 const PRUnichar
*html
;
1128 nsAString_GetData(&html_str
, &html
);
1129 *p
= SysAllocString(html
);
1131 hres
= E_OUTOFMEMORY
;
1134 nsAString_Finish(&html_str
);
1136 TRACE("ret %s\n", debugstr_w(*p
));
1140 static HRESULT WINAPI
HTMLElement_put_outerText(IHTMLElement
*iface
, BSTR v
)
1142 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1143 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1147 static HRESULT WINAPI
HTMLElement_get_outerText(IHTMLElement
*iface
, BSTR
*p
)
1149 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1150 FIXME("(%p)->(%p)\n", This
, p
);
1154 HRESULT
insert_adjacent_node(HTMLElement
*This
, const WCHAR
*where
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret_node
)
1156 nsIDOMNode
*ret_nsnode
;
1158 HRESULT hres
= S_OK
;
1160 static const WCHAR beforebeginW
[] = {'b','e','f','o','r','e','b','e','g','i','n',0};
1161 static const WCHAR afterbeginW
[] = {'a','f','t','e','r','b','e','g','i','n',0};
1162 static const WCHAR beforeendW
[] = {'b','e','f','o','r','e','e','n','d',0};
1163 static const WCHAR afterendW
[] = {'a','f','t','e','r','e','n','d',0};
1165 if (!strcmpiW(where
, beforebeginW
)) {
1168 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1169 if(NS_FAILED(nsres
))
1173 return E_INVALIDARG
;
1175 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, This
->node
.nsnode
, &ret_nsnode
);
1176 nsIDOMNode_Release(parent
);
1177 }else if(!strcmpiW(where
, afterbeginW
)) {
1178 nsIDOMNode
*first_child
;
1180 nsres
= nsIDOMNode_GetFirstChild(This
->node
.nsnode
, &first_child
);
1181 if(NS_FAILED(nsres
))
1184 nsres
= nsIDOMNode_InsertBefore(This
->node
.nsnode
, nsnode
, first_child
, &ret_nsnode
);
1185 if(NS_FAILED(nsres
))
1189 nsIDOMNode_Release(first_child
);
1190 }else if (!strcmpiW(where
, beforeendW
)) {
1191 nsres
= nsIDOMNode_AppendChild(This
->node
.nsnode
, nsnode
, &ret_nsnode
);
1192 }else if (!strcmpiW(where
, afterendW
)) {
1193 nsIDOMNode
*next_sibling
, *parent
;
1195 nsres
= nsIDOMNode_GetParentNode(This
->node
.nsnode
, &parent
);
1196 if(NS_FAILED(nsres
))
1199 return E_INVALIDARG
;
1201 nsres
= nsIDOMNode_GetNextSibling(This
->node
.nsnode
, &next_sibling
);
1202 if(NS_SUCCEEDED(nsres
)) {
1204 nsres
= nsIDOMNode_InsertBefore(parent
, nsnode
, next_sibling
, &ret_nsnode
);
1205 nsIDOMNode_Release(next_sibling
);
1207 nsres
= nsIDOMNode_AppendChild(parent
, nsnode
, &ret_nsnode
);
1211 nsIDOMNode_Release(parent
);
1213 ERR("invalid where: %s\n", debugstr_w(where
));
1214 return E_INVALIDARG
;
1217 if (NS_FAILED(nsres
))
1221 hres
= get_node(This
->node
.doc
, ret_nsnode
, TRUE
, ret_node
);
1222 nsIDOMNode_Release(ret_nsnode
);
1226 static HRESULT WINAPI
HTMLElement_insertAdjacentHTML(IHTMLElement
*iface
, BSTR where
,
1229 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1236 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(html
));
1238 if(!This
->node
.doc
->nsdoc
) {
1239 WARN("NULL nsdoc\n");
1240 return E_UNEXPECTED
;
1243 nsres
= nsIDOMHTMLDocument_CreateRange(This
->node
.doc
->nsdoc
, &range
);
1244 if(NS_FAILED(nsres
))
1246 ERR("CreateRange failed: %08x\n", nsres
);
1250 nsIDOMRange_SetStartBefore(range
, This
->node
.nsnode
);
1252 nsAString_InitDepend(&ns_html
, html
);
1253 nsres
= nsIDOMRange_CreateContextualFragment(range
, &ns_html
, (nsIDOMDocumentFragment
**)&nsnode
);
1254 nsAString_Finish(&ns_html
);
1255 nsIDOMRange_Release(range
);
1257 if(NS_FAILED(nsres
) || !nsnode
)
1259 ERR("CreateTextNode failed: %08x\n", nsres
);
1263 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1264 nsIDOMNode_Release(nsnode
);
1268 static HRESULT WINAPI
HTMLElement_insertAdjacentText(IHTMLElement
*iface
, BSTR where
,
1271 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1277 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(where
), debugstr_w(text
));
1279 if(!This
->node
.doc
->nsdoc
) {
1280 WARN("NULL nsdoc\n");
1281 return E_UNEXPECTED
;
1285 nsAString_InitDepend(&ns_text
, text
);
1286 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->node
.doc
->nsdoc
, &ns_text
, (nsIDOMText
**)&nsnode
);
1287 nsAString_Finish(&ns_text
);
1289 if(NS_FAILED(nsres
) || !nsnode
)
1291 ERR("CreateTextNode failed: %08x\n", nsres
);
1295 hr
= insert_adjacent_node(This
, where
, nsnode
, NULL
);
1296 nsIDOMNode_Release(nsnode
);
1301 static HRESULT WINAPI
HTMLElement_get_parentTextEdit(IHTMLElement
*iface
, IHTMLElement
**p
)
1303 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1304 FIXME("(%p)->(%p)\n", This
, p
);
1308 static HRESULT WINAPI
HTMLElement_get_isTextEdit(IHTMLElement
*iface
, VARIANT_BOOL
*p
)
1310 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1311 FIXME("(%p)->(%p)\n", This
, p
);
1315 static HRESULT WINAPI
HTMLElement_click(IHTMLElement
*iface
)
1317 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1319 TRACE("(%p)\n", This
);
1321 return call_fire_event(&This
->node
, EVENTID_CLICK
);
1324 static HRESULT WINAPI
HTMLElement_get_filters(IHTMLElement
*iface
,
1325 IHTMLFiltersCollection
**p
)
1327 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1328 TRACE("(%p)->(%p)\n", This
, p
);
1333 *p
= HTMLFiltersCollection_Create();
1338 static HRESULT WINAPI
HTMLElement_put_ondragstart(IHTMLElement
*iface
, VARIANT v
)
1340 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1341 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1345 static HRESULT WINAPI
HTMLElement_get_ondragstart(IHTMLElement
*iface
, VARIANT
*p
)
1347 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1348 FIXME("(%p)->(%p)\n", This
, p
);
1352 static HRESULT WINAPI
HTMLElement_toString(IHTMLElement
*iface
, BSTR
*String
)
1354 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1355 FIXME("(%p)->(%p)\n", This
, String
);
1359 static HRESULT WINAPI
HTMLElement_put_onbeforeupdate(IHTMLElement
*iface
, VARIANT v
)
1361 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1362 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1366 static HRESULT WINAPI
HTMLElement_get_onbeforeupdate(IHTMLElement
*iface
, VARIANT
*p
)
1368 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1369 FIXME("(%p)->(%p)\n", This
, p
);
1373 static HRESULT WINAPI
HTMLElement_put_onafterupdate(IHTMLElement
*iface
, VARIANT v
)
1375 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1376 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1380 static HRESULT WINAPI
HTMLElement_get_onafterupdate(IHTMLElement
*iface
, VARIANT
*p
)
1382 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1383 FIXME("(%p)->(%p)\n", This
, p
);
1387 static HRESULT WINAPI
HTMLElement_put_onerrorupdate(IHTMLElement
*iface
, VARIANT v
)
1389 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1390 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1394 static HRESULT WINAPI
HTMLElement_get_onerrorupdate(IHTMLElement
*iface
, VARIANT
*p
)
1396 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1397 FIXME("(%p)->(%p)\n", This
, p
);
1401 static HRESULT WINAPI
HTMLElement_put_onrowexit(IHTMLElement
*iface
, VARIANT v
)
1403 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1404 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1408 static HRESULT WINAPI
HTMLElement_get_onrowexit(IHTMLElement
*iface
, VARIANT
*p
)
1410 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1411 FIXME("(%p)->(%p)\n", This
, p
);
1415 static HRESULT WINAPI
HTMLElement_put_onrowenter(IHTMLElement
*iface
, VARIANT v
)
1417 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1418 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1422 static HRESULT WINAPI
HTMLElement_get_onrowenter(IHTMLElement
*iface
, VARIANT
*p
)
1424 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1425 FIXME("(%p)->(%p)\n", This
, p
);
1429 static HRESULT WINAPI
HTMLElement_put_ondatasetchanged(IHTMLElement
*iface
, VARIANT v
)
1431 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1432 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1436 static HRESULT WINAPI
HTMLElement_get_ondatasetchanged(IHTMLElement
*iface
, VARIANT
*p
)
1438 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1439 FIXME("(%p)->(%p)\n", This
, p
);
1443 static HRESULT WINAPI
HTMLElement_put_ondataavailable(IHTMLElement
*iface
, VARIANT v
)
1445 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1447 FIXME("(%p)->(%s) semi-stub\n", This
, debugstr_variant(&v
));
1449 return set_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, &v
);
1452 static HRESULT WINAPI
HTMLElement_get_ondataavailable(IHTMLElement
*iface
, VARIANT
*p
)
1454 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1456 TRACE("(%p)->(%p)\n", This
, p
);
1458 return get_node_event(&This
->node
, EVENTID_DATAAVAILABLE
, p
);
1461 static HRESULT WINAPI
HTMLElement_put_ondatasetcomplete(IHTMLElement
*iface
, VARIANT v
)
1463 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1464 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1468 static HRESULT WINAPI
HTMLElement_get_ondatasetcomplete(IHTMLElement
*iface
, VARIANT
*p
)
1470 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1471 FIXME("(%p)->(%p)\n", This
, p
);
1475 static HRESULT WINAPI
HTMLElement_put_onfilterchange(IHTMLElement
*iface
, VARIANT v
)
1477 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1478 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1482 static HRESULT WINAPI
HTMLElement_get_onfilterchange(IHTMLElement
*iface
, VARIANT
*p
)
1484 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1485 FIXME("(%p)->(%p)\n", This
, p
);
1489 static HRESULT WINAPI
HTMLElement_get_children(IHTMLElement
*iface
, IDispatch
**p
)
1491 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1492 nsIDOMNodeList
*nsnode_list
;
1495 TRACE("(%p)->(%p)\n", This
, p
);
1497 nsres
= nsIDOMNode_GetChildNodes(This
->node
.nsnode
, &nsnode_list
);
1498 if(NS_FAILED(nsres
)) {
1499 ERR("GetChildNodes failed: %08x\n", nsres
);
1503 *p
= (IDispatch
*)create_collection_from_nodelist(This
->node
.doc
, nsnode_list
);
1505 nsIDOMNodeList_Release(nsnode_list
);
1509 static HRESULT WINAPI
HTMLElement_get_all(IHTMLElement
*iface
, IDispatch
**p
)
1511 HTMLElement
*This
= impl_from_IHTMLElement(iface
);
1513 TRACE("(%p)->(%p)\n", This
, p
);
1515 *p
= (IDispatch
*)create_all_collection(&This
->node
, FALSE
);
1519 static const IHTMLElementVtbl HTMLElementVtbl
= {
1520 HTMLElement_QueryInterface
,
1522 HTMLElement_Release
,
1523 HTMLElement_GetTypeInfoCount
,
1524 HTMLElement_GetTypeInfo
,
1525 HTMLElement_GetIDsOfNames
,
1527 HTMLElement_setAttribute
,
1528 HTMLElement_getAttribute
,
1529 HTMLElement_removeAttribute
,
1530 HTMLElement_put_className
,
1531 HTMLElement_get_className
,
1534 HTMLElement_get_tagName
,
1535 HTMLElement_get_parentElement
,
1536 HTMLElement_get_style
,
1537 HTMLElement_put_onhelp
,
1538 HTMLElement_get_onhelp
,
1539 HTMLElement_put_onclick
,
1540 HTMLElement_get_onclick
,
1541 HTMLElement_put_ondblclick
,
1542 HTMLElement_get_ondblclick
,
1543 HTMLElement_put_onkeydown
,
1544 HTMLElement_get_onkeydown
,
1545 HTMLElement_put_onkeyup
,
1546 HTMLElement_get_onkeyup
,
1547 HTMLElement_put_onkeypress
,
1548 HTMLElement_get_onkeypress
,
1549 HTMLElement_put_onmouseout
,
1550 HTMLElement_get_onmouseout
,
1551 HTMLElement_put_onmouseover
,
1552 HTMLElement_get_onmouseover
,
1553 HTMLElement_put_onmousemove
,
1554 HTMLElement_get_onmousemove
,
1555 HTMLElement_put_onmousedown
,
1556 HTMLElement_get_onmousedown
,
1557 HTMLElement_put_onmouseup
,
1558 HTMLElement_get_onmouseup
,
1559 HTMLElement_get_document
,
1560 HTMLElement_put_title
,
1561 HTMLElement_get_title
,
1562 HTMLElement_put_language
,
1563 HTMLElement_get_language
,
1564 HTMLElement_put_onselectstart
,
1565 HTMLElement_get_onselectstart
,
1566 HTMLElement_scrollIntoView
,
1567 HTMLElement_contains
,
1568 HTMLElement_get_sourceIndex
,
1569 HTMLElement_get_recordNumber
,
1570 HTMLElement_put_lang
,
1571 HTMLElement_get_lang
,
1572 HTMLElement_get_offsetLeft
,
1573 HTMLElement_get_offsetTop
,
1574 HTMLElement_get_offsetWidth
,
1575 HTMLElement_get_offsetHeight
,
1576 HTMLElement_get_offsetParent
,
1577 HTMLElement_put_innerHTML
,
1578 HTMLElement_get_innerHTML
,
1579 HTMLElement_put_innerText
,
1580 HTMLElement_get_innerText
,
1581 HTMLElement_put_outerHTML
,
1582 HTMLElement_get_outerHTML
,
1583 HTMLElement_put_outerText
,
1584 HTMLElement_get_outerText
,
1585 HTMLElement_insertAdjacentHTML
,
1586 HTMLElement_insertAdjacentText
,
1587 HTMLElement_get_parentTextEdit
,
1588 HTMLElement_get_isTextEdit
,
1590 HTMLElement_get_filters
,
1591 HTMLElement_put_ondragstart
,
1592 HTMLElement_get_ondragstart
,
1593 HTMLElement_toString
,
1594 HTMLElement_put_onbeforeupdate
,
1595 HTMLElement_get_onbeforeupdate
,
1596 HTMLElement_put_onafterupdate
,
1597 HTMLElement_get_onafterupdate
,
1598 HTMLElement_put_onerrorupdate
,
1599 HTMLElement_get_onerrorupdate
,
1600 HTMLElement_put_onrowexit
,
1601 HTMLElement_get_onrowexit
,
1602 HTMLElement_put_onrowenter
,
1603 HTMLElement_get_onrowenter
,
1604 HTMLElement_put_ondatasetchanged
,
1605 HTMLElement_get_ondatasetchanged
,
1606 HTMLElement_put_ondataavailable
,
1607 HTMLElement_get_ondataavailable
,
1608 HTMLElement_put_ondatasetcomplete
,
1609 HTMLElement_get_ondatasetcomplete
,
1610 HTMLElement_put_onfilterchange
,
1611 HTMLElement_get_onfilterchange
,
1612 HTMLElement_get_children
,
1616 HTMLElement
*unsafe_impl_from_IHTMLElement(IHTMLElement
*iface
)
1618 return iface
->lpVtbl
== &HTMLElementVtbl
? impl_from_IHTMLElement(iface
) : NULL
;
1621 static inline HTMLElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
1623 return CONTAINING_RECORD(iface
, HTMLElement
, node
);
1626 HRESULT
HTMLElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1628 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1630 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1631 *ppv
= &This
->IHTMLElement_iface
;
1632 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1633 *ppv
= &This
->IHTMLElement_iface
;
1634 }else if(IsEqualGUID(&IID_IHTMLElement
, riid
)) {
1635 *ppv
= &This
->IHTMLElement_iface
;
1636 }else if(IsEqualGUID(&IID_IHTMLElement2
, riid
)) {
1637 *ppv
= &This
->IHTMLElement2_iface
;
1638 }else if(IsEqualGUID(&IID_IHTMLElement3
, riid
)) {
1639 *ppv
= &This
->IHTMLElement3_iface
;
1640 }else if(IsEqualGUID(&IID_IHTMLElement4
, riid
)) {
1641 *ppv
= &This
->IHTMLElement4_iface
;
1642 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
1643 *ppv
= &This
->cp_container
.IConnectionPointContainer_iface
;
1645 return HTMLDOMNode_QI(&This
->node
, riid
, ppv
);
1648 IUnknown_AddRef((IUnknown
*)*ppv
);
1652 void HTMLElement_destructor(HTMLDOMNode
*iface
)
1654 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1656 ConnectionPointContainer_Destroy(&This
->cp_container
);
1659 This
->style
->elem
= NULL
;
1660 IHTMLStyle_Release(&This
->style
->IHTMLStyle_iface
);
1662 if(This
->runtime_style
) {
1663 This
->runtime_style
->elem
= NULL
;
1664 IHTMLStyle_Release(&This
->runtime_style
->IHTMLStyle_iface
);
1667 HTMLDOMAttribute
*attr
;
1669 LIST_FOR_EACH_ENTRY(attr
, &This
->attrs
->attrs
, HTMLDOMAttribute
, entry
)
1672 This
->attrs
->elem
= NULL
;
1673 IHTMLAttributeCollection_Release(&This
->attrs
->IHTMLAttributeCollection_iface
);
1676 heap_free(This
->filter
);
1678 HTMLDOMNode_destructor(&This
->node
);
1681 HRESULT
HTMLElement_clone(HTMLDOMNode
*iface
, nsIDOMNode
*nsnode
, HTMLDOMNode
**ret
)
1683 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1684 HTMLElement
*new_elem
;
1687 hres
= HTMLElement_Create(This
->node
.doc
, nsnode
, FALSE
, &new_elem
);
1692 new_elem
->filter
= heap_strdupW(This
->filter
);
1693 if(!new_elem
->filter
) {
1694 IHTMLElement_Release(&This
->IHTMLElement_iface
);
1695 return E_OUTOFMEMORY
;
1699 *ret
= &new_elem
->node
;
1703 HRESULT
HTMLElement_handle_event(HTMLDOMNode
*iface
, DWORD eid
, nsIDOMEvent
*event
, BOOL
*prevent_default
)
1705 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
1708 case EVENTID_KEYDOWN
: {
1709 nsIDOMKeyEvent
*key_event
;
1712 nsres
= nsIDOMEvent_QueryInterface(event
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
1713 if(NS_SUCCEEDED(nsres
)) {
1716 nsIDOMKeyEvent_GetKeyCode(key_event
, &code
);
1719 case VK_F1
: /* DOM_VK_F1 */
1720 TRACE("F1 pressed\n");
1721 fire_event(This
->node
.doc
, EVENTID_HELP
, TRUE
, This
->node
.nsnode
, NULL
, NULL
);
1722 *prevent_default
= TRUE
;
1725 nsIDOMKeyEvent_Release(key_event
);
1733 cp_static_data_t HTMLElementEvents2_data
= { HTMLElementEvents2_tid
, NULL
/* FIXME */, TRUE
};
1735 const cpc_entry_t HTMLElement_cpc
[] = {
1740 static const NodeImplVtbl HTMLElementImplVtbl
= {
1742 HTMLElement_destructor
,
1745 HTMLElement_handle_event
,
1746 HTMLElement_get_attr_col
1749 static inline HTMLElement
*impl_from_DispatchEx(DispatchEx
*iface
)
1751 return CONTAINING_RECORD(iface
, HTMLElement
, node
.dispex
);
1754 static HRESULT
HTMLElement_get_dispid(DispatchEx
*dispex
, BSTR name
,
1755 DWORD grfdex
, DISPID
*pid
)
1757 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1759 if(This
->node
.vtbl
->get_dispid
)
1760 return This
->node
.vtbl
->get_dispid(&This
->node
, name
, grfdex
, pid
);
1762 return DISP_E_UNKNOWNNAME
;
1765 static HRESULT
HTMLElement_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
1766 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
1767 IServiceProvider
*caller
)
1769 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1771 if(This
->node
.vtbl
->invoke
)
1772 return This
->node
.vtbl
->invoke(&This
->node
, id
, lcid
, flags
,
1773 params
, res
, ei
, caller
);
1775 ERR("(%p): element has no invoke method\n", This
);
1779 static HRESULT
HTMLElement_populate_props(DispatchEx
*dispex
)
1781 HTMLElement
*This
= impl_from_DispatchEx(dispex
);
1782 nsIDOMMozNamedAttrMap
*attrs
;
1785 const PRUnichar
*str
;
1797 nsres
= nsIDOMHTMLElement_GetAttributes(This
->nselem
, &attrs
);
1798 if(NS_FAILED(nsres
))
1801 nsres
= nsIDOMMozNamedAttrMap_GetLength(attrs
, &len
);
1802 if(NS_FAILED(nsres
)) {
1803 nsIDOMMozNamedAttrMap_Release(attrs
);
1807 nsAString_Init(&nsstr
, NULL
);
1808 for(i
=0; i
<len
; i
++) {
1809 nsres
= nsIDOMMozNamedAttrMap_Item(attrs
, i
, &attr
);
1810 if(NS_FAILED(nsres
))
1813 nsres
= nsIDOMAttr_GetNodeName(attr
, &nsstr
);
1814 if(NS_FAILED(nsres
)) {
1815 nsIDOMAttr_Release(attr
);
1819 nsAString_GetData(&nsstr
, &str
);
1820 name
= SysAllocString(str
);
1822 nsIDOMAttr_Release(attr
);
1826 hres
= IDispatchEx_GetDispID(&dispex
->IDispatchEx_iface
, name
, fdexNameCaseInsensitive
, &id
);
1827 if(hres
!= DISP_E_UNKNOWNNAME
) {
1828 nsIDOMAttr_Release(attr
);
1829 SysFreeString(name
);
1833 nsres
= nsIDOMAttr_GetNodeValue(attr
, &nsstr
);
1834 nsIDOMAttr_Release(attr
);
1835 if(NS_FAILED(nsres
)) {
1836 SysFreeString(name
);
1840 nsAString_GetData(&nsstr
, &str
);
1841 V_VT(&value
) = VT_BSTR
;
1843 V_BSTR(&value
) = SysAllocString(str
);
1844 if(!V_BSTR(&value
)) {
1845 SysFreeString(name
);
1849 V_BSTR(&value
) = NULL
;
1851 IHTMLElement_setAttribute(&This
->IHTMLElement_iface
, name
, value
, 0);
1852 SysFreeString(name
);
1853 VariantClear(&value
);
1855 nsAString_Finish(&nsstr
);
1857 nsIDOMMozNamedAttrMap_Release(attrs
);
1861 static const tid_t HTMLElement_iface_tids
[] = {
1866 static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl
= {
1868 HTMLElement_get_dispid
,
1870 HTMLElement_populate_props
1873 static dispex_static_data_t HTMLElement_dispex
= {
1874 &HTMLElement_dispex_vtbl
,
1875 DispHTMLUnknownElement_tid
,
1877 HTMLElement_iface_tids
1880 void HTMLElement_Init(HTMLElement
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, dispex_static_data_t
*dispex_data
)
1882 This
->IHTMLElement_iface
.lpVtbl
= &HTMLElementVtbl
;
1884 HTMLElement2_Init(This
);
1885 HTMLElement3_Init(This
);
1887 if(dispex_data
&& !dispex_data
->vtbl
)
1888 dispex_data
->vtbl
= &HTMLElement_dispex_vtbl
;
1889 init_dispex(&This
->node
.dispex
, (IUnknown
*)&This
->IHTMLElement_iface
,
1890 dispex_data
? dispex_data
: &HTMLElement_dispex
);
1893 HTMLDOMNode_Init(doc
, &This
->node
, (nsIDOMNode
*)nselem
);
1895 /* No AddRef, share reference with HTMLDOMNode */
1896 assert((nsIDOMNode
*)nselem
== This
->node
.nsnode
);
1897 This
->nselem
= nselem
;
1900 This
->node
.cp_container
= &This
->cp_container
;
1901 ConnectionPointContainer_Init(&This
->cp_container
, (IUnknown
*)&This
->IHTMLElement_iface
, This
->node
.vtbl
->cpc_entries
);
1904 HRESULT
HTMLElement_Create(HTMLDocumentNode
*doc
, nsIDOMNode
*nsnode
, BOOL use_generic
, HTMLElement
**ret
)
1906 nsIDOMHTMLElement
*nselem
;
1907 nsAString class_name_str
;
1908 const PRUnichar
*class_name
;
1909 const tag_desc_t
*tag
;
1914 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMHTMLElement
, (void**)&nselem
);
1915 if(NS_FAILED(nsres
))
1918 nsAString_Init(&class_name_str
, NULL
);
1919 nsIDOMHTMLElement_GetTagName(nselem
, &class_name_str
);
1921 nsAString_GetData(&class_name_str
, &class_name
);
1923 tag
= get_tag_desc(class_name
);
1925 hres
= tag
->constructor(doc
, nselem
, &elem
);
1926 }else if(use_generic
) {
1927 hres
= HTMLGenericElement_Create(doc
, nselem
, &elem
);
1929 elem
= heap_alloc_zero(sizeof(HTMLElement
));
1931 elem
->node
.vtbl
= &HTMLElementImplVtbl
;
1932 HTMLElement_Init(elem
, doc
, nselem
, &HTMLElement_dispex
);
1935 hres
= E_OUTOFMEMORY
;
1939 TRACE("%s ret %p\n", debugstr_w(class_name
), elem
);
1941 nsIDOMHTMLElement_Release(nselem
);
1942 nsAString_Finish(&class_name_str
);
1950 HRESULT
get_elem(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**ret
)
1955 hres
= get_node(doc
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1959 *ret
= impl_from_HTMLDOMNode(node
);
1963 /* interface IHTMLFiltersCollection */
1964 static HRESULT WINAPI
HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection
*iface
, REFIID riid
, void **ppv
)
1966 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1968 TRACE("%p %s %p\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1970 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1971 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1972 }else if(IsEqualGUID(&IID_IHTMLFiltersCollection
, riid
)) {
1973 TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This
, ppv
);
1974 *ppv
= &This
->IHTMLFiltersCollection_iface
;
1975 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1976 return *ppv
? S_OK
: E_NOINTERFACE
;
1979 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1980 return E_NOINTERFACE
;
1983 IUnknown_AddRef((IUnknown
*)*ppv
);
1987 static ULONG WINAPI
HTMLFiltersCollection_AddRef(IHTMLFiltersCollection
*iface
)
1989 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
1990 LONG ref
= InterlockedIncrement(&This
->ref
);
1992 TRACE("(%p) ref=%d\n", This
, ref
);
1997 static ULONG WINAPI
HTMLFiltersCollection_Release(IHTMLFiltersCollection
*iface
)
1999 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2000 LONG ref
= InterlockedDecrement(&This
->ref
);
2002 TRACE("(%p) ref=%d\n", This
, ref
);
2012 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection
*iface
, UINT
*pctinfo
)
2014 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2015 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2018 static HRESULT WINAPI
HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection
*iface
,
2019 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
2021 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2022 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2025 static HRESULT WINAPI
HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection
*iface
,
2026 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
2027 LCID lcid
, DISPID
*rgDispId
)
2029 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2030 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2034 static HRESULT WINAPI
HTMLFiltersCollection_Invoke(IHTMLFiltersCollection
*iface
, DISPID dispIdMember
, REFIID riid
,
2035 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
2036 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2038 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2039 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2040 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2043 static HRESULT WINAPI
HTMLFiltersCollection_get_length(IHTMLFiltersCollection
*iface
, LONG
*p
)
2045 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2050 FIXME("(%p)->(%p) Always returning 0\n", This
, p
);
2056 static HRESULT WINAPI
HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection
*iface
, IUnknown
**p
)
2058 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2059 FIXME("(%p)->(%p)\n", This
, p
);
2063 static HRESULT WINAPI
HTMLFiltersCollection_item(IHTMLFiltersCollection
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
2065 HTMLFiltersCollection
*This
= impl_from_IHTMLFiltersCollection(iface
);
2066 FIXME("(%p)->(%p, %p)\n", This
, pvarIndex
, pvarResult
);
2070 static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl
= {
2071 HTMLFiltersCollection_QueryInterface
,
2072 HTMLFiltersCollection_AddRef
,
2073 HTMLFiltersCollection_Release
,
2074 HTMLFiltersCollection_GetTypeInfoCount
,
2075 HTMLFiltersCollection_GetTypeInfo
,
2076 HTMLFiltersCollection_GetIDsOfNames
,
2077 HTMLFiltersCollection_Invoke
,
2078 HTMLFiltersCollection_get_length
,
2079 HTMLFiltersCollection_get__newEnum
,
2080 HTMLFiltersCollection_item
2083 static HRESULT
HTMLFiltersCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2088 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
2089 idx
= idx
*10 + (*ptr
-'0');
2091 return DISP_E_UNKNOWNNAME
;
2093 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
2094 TRACE("ret %x\n", *dispid
);
2098 static HRESULT
HTMLFiltersCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2099 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2101 TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex
, id
, lcid
, flags
, params
, res
, ei
);
2103 V_VT(res
) = VT_DISPATCH
;
2104 V_DISPATCH(res
) = NULL
;
2106 FIXME("always returning NULL\n");
2111 static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl
= {
2113 HTMLFiltersCollection_get_dispid
,
2114 HTMLFiltersCollection_invoke
,
2118 static const tid_t HTMLFiltersCollection_iface_tids
[] = {
2119 IHTMLFiltersCollection_tid
,
2122 static dispex_static_data_t HTMLFiltersCollection_dispex
= {
2123 &HTMLFiltersCollection_dispex_vtbl
,
2124 IHTMLFiltersCollection_tid
,
2126 HTMLFiltersCollection_iface_tids
2129 static IHTMLFiltersCollection
*HTMLFiltersCollection_Create(void)
2131 HTMLFiltersCollection
*ret
= heap_alloc(sizeof(HTMLFiltersCollection
));
2133 ret
->IHTMLFiltersCollection_iface
.lpVtbl
= &HTMLFiltersCollectionVtbl
;
2136 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLFiltersCollection_iface
,
2137 &HTMLFiltersCollection_dispex
);
2139 return &ret
->IHTMLFiltersCollection_iface
;
2142 /* interface IHTMLAttributeCollection */
2143 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection(IHTMLAttributeCollection
*iface
)
2145 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection_iface
);
2148 static HRESULT WINAPI
HTMLAttributeCollection_QueryInterface(IHTMLAttributeCollection
*iface
, REFIID riid
, void **ppv
)
2150 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2152 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2153 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2154 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection
, riid
)) {
2155 *ppv
= &This
->IHTMLAttributeCollection_iface
;
2156 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection2
, riid
)) {
2157 *ppv
= &This
->IHTMLAttributeCollection2_iface
;
2158 }else if(IsEqualGUID(&IID_IHTMLAttributeCollection3
, riid
)) {
2159 *ppv
= &This
->IHTMLAttributeCollection3_iface
;
2160 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
2161 return *ppv
? S_OK
: E_NOINTERFACE
;
2164 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
2165 return E_NOINTERFACE
;
2168 IUnknown_AddRef((IUnknown
*)*ppv
);
2172 static ULONG WINAPI
HTMLAttributeCollection_AddRef(IHTMLAttributeCollection
*iface
)
2174 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2175 LONG ref
= InterlockedIncrement(&This
->ref
);
2177 TRACE("(%p) ref=%d\n", This
, ref
);
2182 static ULONG WINAPI
HTMLAttributeCollection_Release(IHTMLAttributeCollection
*iface
)
2184 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2185 LONG ref
= InterlockedDecrement(&This
->ref
);
2187 TRACE("(%p) ref=%d\n", This
, ref
);
2190 while(!list_empty(&This
->attrs
)) {
2191 HTMLDOMAttribute
*attr
= LIST_ENTRY(list_head(&This
->attrs
), HTMLDOMAttribute
, entry
);
2193 list_remove(&attr
->entry
);
2195 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2204 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfoCount(IHTMLAttributeCollection
*iface
, UINT
*pctinfo
)
2206 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2207 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2210 static HRESULT WINAPI
HTMLAttributeCollection_GetTypeInfo(IHTMLAttributeCollection
*iface
, UINT iTInfo
,
2211 LCID lcid
, ITypeInfo
**ppTInfo
)
2213 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2214 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2217 static HRESULT WINAPI
HTMLAttributeCollection_GetIDsOfNames(IHTMLAttributeCollection
*iface
, REFIID riid
,
2218 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2220 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2221 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2225 static HRESULT WINAPI
HTMLAttributeCollection_Invoke(IHTMLAttributeCollection
*iface
, DISPID dispIdMember
,
2226 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2227 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2229 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2230 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2231 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2234 static HRESULT
get_attr_dispid_by_idx(HTMLAttributeCollection
*This
, LONG
*idx
, DISPID
*dispid
)
2236 IDispatchEx
*dispex
= &This
->elem
->node
.dispex
.IDispatchEx_iface
;
2237 DISPID id
= DISPID_STARTENUM
;
2241 FIXME("filter non-enumerable attributes out\n");
2244 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2247 else if(hres
== S_FALSE
)
2257 return *idx
==len
? S_OK
: DISP_E_UNKNOWNNAME
;
2264 static inline HRESULT
get_attr_dispid_by_name(HTMLAttributeCollection
*This
, BSTR name
, DISPID
*id
)
2268 if(name
[0]>='0' && name
[0]<='9') {
2272 idx
= strtoulW(name
, &end_ptr
, 10);
2274 hres
= get_attr_dispid_by_idx(This
, &idx
, id
);
2281 WARN("NULL elem\n");
2282 return E_UNEXPECTED
;
2285 hres
= IDispatchEx_GetDispID(&This
->elem
->node
.dispex
.IDispatchEx_iface
,
2286 name
, fdexNameCaseInsensitive
, id
);
2290 static inline HRESULT
get_domattr(HTMLAttributeCollection
*This
, DISPID id
, LONG
*list_pos
, HTMLDOMAttribute
**attr
)
2292 HTMLDOMAttribute
*iter
;
2297 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2298 if(iter
->dispid
== id
) {
2307 WARN("NULL elem\n");
2308 return E_UNEXPECTED
;
2311 hres
= HTMLDOMAttribute_Create(NULL
, This
->elem
, id
, attr
);
2316 IHTMLDOMAttribute_AddRef(&(*attr
)->IHTMLDOMAttribute_iface
);
2322 static HRESULT WINAPI
HTMLAttributeCollection_get_length(IHTMLAttributeCollection
*iface
, LONG
*p
)
2324 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2327 TRACE("(%p)->(%p)\n", This
, p
);
2330 hres
= get_attr_dispid_by_idx(This
, p
, NULL
);
2334 static HRESULT WINAPI
HTMLAttributeCollection__newEnum(IHTMLAttributeCollection
*iface
, IUnknown
**p
)
2336 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2337 FIXME("(%p)->(%p)\n", This
, p
);
2341 static HRESULT WINAPI
HTMLAttributeCollection_item(IHTMLAttributeCollection
*iface
, VARIANT
*name
, IDispatch
**ppItem
)
2343 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection(iface
);
2344 HTMLDOMAttribute
*attr
;
2348 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(name
), ppItem
);
2350 switch(V_VT(name
)) {
2352 hres
= get_attr_dispid_by_idx(This
, &V_I4(name
), &id
);
2355 hres
= get_attr_dispid_by_name(This
, V_BSTR(name
), &id
);
2358 FIXME("unsupported name %s\n", debugstr_variant(name
));
2361 if(hres
== DISP_E_UNKNOWNNAME
)
2362 return E_INVALIDARG
;
2366 hres
= get_domattr(This
, id
, NULL
, &attr
);
2370 *ppItem
= (IDispatch
*)&attr
->IHTMLDOMAttribute_iface
;
2374 static const IHTMLAttributeCollectionVtbl HTMLAttributeCollectionVtbl
= {
2375 HTMLAttributeCollection_QueryInterface
,
2376 HTMLAttributeCollection_AddRef
,
2377 HTMLAttributeCollection_Release
,
2378 HTMLAttributeCollection_GetTypeInfoCount
,
2379 HTMLAttributeCollection_GetTypeInfo
,
2380 HTMLAttributeCollection_GetIDsOfNames
,
2381 HTMLAttributeCollection_Invoke
,
2382 HTMLAttributeCollection_get_length
,
2383 HTMLAttributeCollection__newEnum
,
2384 HTMLAttributeCollection_item
2387 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection2(IHTMLAttributeCollection2
*iface
)
2389 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection2_iface
);
2392 static HRESULT WINAPI
HTMLAttributeCollection2_QueryInterface(IHTMLAttributeCollection2
*iface
, REFIID riid
, void **ppv
)
2394 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2395 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2398 static ULONG WINAPI
HTMLAttributeCollection2_AddRef(IHTMLAttributeCollection2
*iface
)
2400 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2401 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2404 static ULONG WINAPI
HTMLAttributeCollection2_Release(IHTMLAttributeCollection2
*iface
)
2406 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2407 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2410 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfoCount(IHTMLAttributeCollection2
*iface
, UINT
*pctinfo
)
2412 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2413 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2416 static HRESULT WINAPI
HTMLAttributeCollection2_GetTypeInfo(IHTMLAttributeCollection2
*iface
, UINT iTInfo
,
2417 LCID lcid
, ITypeInfo
**ppTInfo
)
2419 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2420 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2423 static HRESULT WINAPI
HTMLAttributeCollection2_GetIDsOfNames(IHTMLAttributeCollection2
*iface
, REFIID riid
,
2424 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2426 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2427 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2431 static HRESULT WINAPI
HTMLAttributeCollection2_Invoke(IHTMLAttributeCollection2
*iface
, DISPID dispIdMember
,
2432 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2433 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2435 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2436 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2437 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2440 static HRESULT WINAPI
HTMLAttributeCollection2_getNamedItem(IHTMLAttributeCollection2
*iface
, BSTR bstrName
,
2441 IHTMLDOMAttribute
**newretNode
)
2443 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2444 HTMLDOMAttribute
*attr
;
2448 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2450 hres
= get_attr_dispid_by_name(This
, bstrName
, &id
);
2451 if(hres
== DISP_E_UNKNOWNNAME
) {
2454 } else if(FAILED(hres
)) {
2458 hres
= get_domattr(This
, id
, NULL
, &attr
);
2462 *newretNode
= &attr
->IHTMLDOMAttribute_iface
;
2466 static HRESULT WINAPI
HTMLAttributeCollection2_setNamedItem(IHTMLAttributeCollection2
*iface
,
2467 IHTMLDOMAttribute
*ppNode
, IHTMLDOMAttribute
**newretNode
)
2469 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2470 FIXME("(%p)->(%p %p)\n", This
, ppNode
, newretNode
);
2474 static HRESULT WINAPI
HTMLAttributeCollection2_removeNamedItem(IHTMLAttributeCollection2
*iface
,
2475 BSTR bstrName
, IHTMLDOMAttribute
**newretNode
)
2477 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection2(iface
);
2478 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), newretNode
);
2482 static const IHTMLAttributeCollection2Vtbl HTMLAttributeCollection2Vtbl
= {
2483 HTMLAttributeCollection2_QueryInterface
,
2484 HTMLAttributeCollection2_AddRef
,
2485 HTMLAttributeCollection2_Release
,
2486 HTMLAttributeCollection2_GetTypeInfoCount
,
2487 HTMLAttributeCollection2_GetTypeInfo
,
2488 HTMLAttributeCollection2_GetIDsOfNames
,
2489 HTMLAttributeCollection2_Invoke
,
2490 HTMLAttributeCollection2_getNamedItem
,
2491 HTMLAttributeCollection2_setNamedItem
,
2492 HTMLAttributeCollection2_removeNamedItem
2495 static inline HTMLAttributeCollection
*impl_from_IHTMLAttributeCollection3(IHTMLAttributeCollection3
*iface
)
2497 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, IHTMLAttributeCollection3_iface
);
2500 static HRESULT WINAPI
HTMLAttributeCollection3_QueryInterface(IHTMLAttributeCollection3
*iface
, REFIID riid
, void **ppv
)
2502 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2503 return IHTMLAttributeCollection_QueryInterface(&This
->IHTMLAttributeCollection_iface
, riid
, ppv
);
2506 static ULONG WINAPI
HTMLAttributeCollection3_AddRef(IHTMLAttributeCollection3
*iface
)
2508 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2509 return IHTMLAttributeCollection_AddRef(&This
->IHTMLAttributeCollection_iface
);
2512 static ULONG WINAPI
HTMLAttributeCollection3_Release(IHTMLAttributeCollection3
*iface
)
2514 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2515 return IHTMLAttributeCollection_Release(&This
->IHTMLAttributeCollection_iface
);
2518 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfoCount(IHTMLAttributeCollection3
*iface
, UINT
*pctinfo
)
2520 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2521 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2524 static HRESULT WINAPI
HTMLAttributeCollection3_GetTypeInfo(IHTMLAttributeCollection3
*iface
, UINT iTInfo
,
2525 LCID lcid
, ITypeInfo
**ppTInfo
)
2527 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2528 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2531 static HRESULT WINAPI
HTMLAttributeCollection3_GetIDsOfNames(IHTMLAttributeCollection3
*iface
, REFIID riid
,
2532 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2534 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2535 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
2539 static HRESULT WINAPI
HTMLAttributeCollection3_Invoke(IHTMLAttributeCollection3
*iface
, DISPID dispIdMember
,
2540 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2541 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2543 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2544 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
2545 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2548 static HRESULT WINAPI
HTMLAttributeCollection3_getNamedItem(IHTMLAttributeCollection3
*iface
, BSTR bstrName
,
2549 IHTMLDOMAttribute
**ppNodeOut
)
2551 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2552 return IHTMLAttributeCollection2_getNamedItem(&This
->IHTMLAttributeCollection2_iface
, bstrName
, ppNodeOut
);
2555 static HRESULT WINAPI
HTMLAttributeCollection3_setNamedItem(IHTMLAttributeCollection3
*iface
,
2556 IHTMLDOMAttribute
*pNodeIn
, IHTMLDOMAttribute
**ppNodeOut
)
2558 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2559 FIXME("(%p)->(%p %p)\n", This
, pNodeIn
, ppNodeOut
);
2563 static HRESULT WINAPI
HTMLAttributeCollection3_removeNamedItem(IHTMLAttributeCollection3
*iface
,
2564 BSTR bstrName
, IHTMLDOMAttribute
**ppNodeOut
)
2566 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2567 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrName
), ppNodeOut
);
2571 static HRESULT WINAPI
HTMLAttributeCollection3_item(IHTMLAttributeCollection3
*iface
, LONG index
, IHTMLDOMAttribute
**ppNodeOut
)
2573 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2574 HTMLDOMAttribute
*attr
;
2578 TRACE("(%p)->(%d %p)\n", This
, index
, ppNodeOut
);
2580 hres
= get_attr_dispid_by_idx(This
, &index
, &id
);
2581 if(hres
== DISP_E_UNKNOWNNAME
)
2582 return E_INVALIDARG
;
2586 hres
= get_domattr(This
, id
, NULL
, &attr
);
2590 *ppNodeOut
= &attr
->IHTMLDOMAttribute_iface
;
2594 static HRESULT WINAPI
HTMLAttributeCollection3_get_length(IHTMLAttributeCollection3
*iface
, LONG
*p
)
2596 HTMLAttributeCollection
*This
= impl_from_IHTMLAttributeCollection3(iface
);
2597 return IHTMLAttributeCollection_get_length(&This
->IHTMLAttributeCollection_iface
, p
);
2600 static const IHTMLAttributeCollection3Vtbl HTMLAttributeCollection3Vtbl
= {
2601 HTMLAttributeCollection3_QueryInterface
,
2602 HTMLAttributeCollection3_AddRef
,
2603 HTMLAttributeCollection3_Release
,
2604 HTMLAttributeCollection3_GetTypeInfoCount
,
2605 HTMLAttributeCollection3_GetTypeInfo
,
2606 HTMLAttributeCollection3_GetIDsOfNames
,
2607 HTMLAttributeCollection3_Invoke
,
2608 HTMLAttributeCollection3_getNamedItem
,
2609 HTMLAttributeCollection3_setNamedItem
,
2610 HTMLAttributeCollection3_removeNamedItem
,
2611 HTMLAttributeCollection3_item
,
2612 HTMLAttributeCollection3_get_length
2615 static inline HTMLAttributeCollection
*HTMLAttributeCollection_from_DispatchEx(DispatchEx
*iface
)
2617 return CONTAINING_RECORD(iface
, HTMLAttributeCollection
, dispex
);
2620 static HRESULT
HTMLAttributeCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
2622 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2623 HTMLDOMAttribute
*attr
;
2627 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(name
), flags
, dispid
);
2629 hres
= get_attr_dispid_by_name(This
, name
, dispid
);
2633 hres
= get_domattr(This
, *dispid
, &pos
, &attr
);
2636 IHTMLDOMAttribute_Release(&attr
->IHTMLDOMAttribute_iface
);
2638 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+pos
;
2642 static HRESULT
HTMLAttributeCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
,
2643 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2645 HTMLAttributeCollection
*This
= HTMLAttributeCollection_from_DispatchEx(dispex
);
2647 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
2650 case DISPATCH_PROPERTYGET
: {
2651 HTMLDOMAttribute
*iter
;
2654 pos
= id
-MSHTML_DISPID_CUSTOM_MIN
;
2656 LIST_FOR_EACH_ENTRY(iter
, &This
->attrs
, HTMLDOMAttribute
, entry
) {
2658 IHTMLDOMAttribute_AddRef(&iter
->IHTMLDOMAttribute_iface
);
2659 V_VT(res
) = VT_DISPATCH
;
2660 V_DISPATCH(res
) = (IDispatch
*)&iter
->IHTMLDOMAttribute_iface
;
2666 WARN("invalid arg\n");
2667 return E_INVALIDARG
;
2671 FIXME("unimplemented flags %x\n", flags
);
2676 static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl
= {
2678 HTMLAttributeCollection_get_dispid
,
2679 HTMLAttributeCollection_invoke
,
2683 static const tid_t HTMLAttributeCollection_iface_tids
[] = {
2684 IHTMLAttributeCollection_tid
,
2685 IHTMLAttributeCollection2_tid
,
2686 IHTMLAttributeCollection3_tid
,
2690 static dispex_static_data_t HTMLAttributeCollection_dispex
= {
2691 &HTMLAttributeCollection_dispex_vtbl
,
2692 DispHTMLAttributeCollection_tid
,
2694 HTMLAttributeCollection_iface_tids
2697 HRESULT
HTMLElement_get_attr_col(HTMLDOMNode
*iface
, HTMLAttributeCollection
**ac
)
2699 HTMLElement
*This
= impl_from_HTMLDOMNode(iface
);
2702 IHTMLAttributeCollection_AddRef(&This
->attrs
->IHTMLAttributeCollection_iface
);
2707 This
->attrs
= heap_alloc_zero(sizeof(HTMLAttributeCollection
));
2709 return E_OUTOFMEMORY
;
2711 This
->attrs
->IHTMLAttributeCollection_iface
.lpVtbl
= &HTMLAttributeCollectionVtbl
;
2712 This
->attrs
->IHTMLAttributeCollection2_iface
.lpVtbl
= &HTMLAttributeCollection2Vtbl
;
2713 This
->attrs
->IHTMLAttributeCollection3_iface
.lpVtbl
= &HTMLAttributeCollection3Vtbl
;
2714 This
->attrs
->ref
= 2;
2716 This
->attrs
->elem
= This
;
2717 list_init(&This
->attrs
->attrs
);
2718 init_dispex(&This
->attrs
->dispex
, (IUnknown
*)&This
->attrs
->IHTMLAttributeCollection_iface
,
2719 &HTMLAttributeCollection_dispex
);