2 * Copyright 2006-2008 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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
36 IHTMLElementCollection IHTMLElementCollection_iface
;
42 } HTMLElementCollection
;
45 IEnumVARIANT IEnumVARIANT_iface
;
50 HTMLElementCollection
*col
;
51 } HTMLElementCollectionEnum
;
59 /* FIXME: Handle it better way */
60 static inline HTMLElement
*elem_from_HTMLDOMNode(HTMLDOMNode
*iface
)
62 return CONTAINING_RECORD(iface
, HTMLElement
, node
);
65 static IHTMLElementCollection
*HTMLElementCollection_Create(HTMLElement
**elems
, DWORD len
);
67 static void elem_vector_add(elem_vector_t
*buf
, HTMLElement
*elem
)
69 if(buf
->len
== buf
->size
) {
71 buf
->buf
= heap_realloc(buf
->buf
, buf
->size
*sizeof(HTMLElement
*));
74 buf
->buf
[buf
->len
++] = elem
;
77 static void elem_vector_normalize(elem_vector_t
*buf
)
82 }else if(buf
->size
> buf
->len
) {
83 buf
->buf
= heap_realloc(buf
->buf
, buf
->len
*sizeof(HTMLElement
*));
89 static inline BOOL
is_elem_node(nsIDOMNode
*node
)
93 nsIDOMNode_GetNodeType(node
, &type
);
95 return type
== ELEMENT_NODE
|| type
== COMMENT_NODE
;
98 static inline HTMLElementCollectionEnum
*impl_from_IEnumVARIANT(IEnumVARIANT
*iface
)
100 return CONTAINING_RECORD(iface
, HTMLElementCollectionEnum
, IEnumVARIANT_iface
);
103 static HRESULT WINAPI
HTMLElementCollectionEnum_QueryInterface(IEnumVARIANT
*iface
, REFIID riid
, void **ppv
)
105 HTMLElementCollectionEnum
*This
= impl_from_IEnumVARIANT(iface
);
107 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
108 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
109 *ppv
= &This
->IEnumVARIANT_iface
;
110 }else if(IsEqualGUID(riid
, &IID_IEnumVARIANT
)) {
111 TRACE("(%p)->(IID_IEnumVARIANT %p)\n", This
, ppv
);
112 *ppv
= &This
->IEnumVARIANT_iface
;
114 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
116 return E_NOINTERFACE
;
119 IUnknown_AddRef((IUnknown
*)*ppv
);
123 static ULONG WINAPI
HTMLElementCollectionEnum_AddRef(IEnumVARIANT
*iface
)
125 HTMLElementCollectionEnum
*This
= impl_from_IEnumVARIANT(iface
);
126 LONG ref
= InterlockedIncrement(&This
->ref
);
128 TRACE("(%p) ref=%d\n", This
, ref
);
133 static ULONG WINAPI
HTMLElementCollectionEnum_Release(IEnumVARIANT
*iface
)
135 HTMLElementCollectionEnum
*This
= impl_from_IEnumVARIANT(iface
);
136 LONG ref
= InterlockedDecrement(&This
->ref
);
138 TRACE("(%p) ref=%d\n", This
, ref
);
141 IHTMLElementCollection_Release(&This
->col
->IHTMLElementCollection_iface
);
148 static HRESULT WINAPI
HTMLElementCollectionEnum_Next(IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*rgVar
, ULONG
*pCeltFetched
)
150 HTMLElementCollectionEnum
*This
= impl_from_IEnumVARIANT(iface
);
153 TRACE("(%p)->(%d %p %p)\n", This
, celt
, rgVar
, pCeltFetched
);
155 while(This
->iter
+fetched
< This
->col
->len
&& fetched
< celt
) {
156 V_VT(rgVar
+fetched
) = VT_DISPATCH
;
157 V_DISPATCH(rgVar
+fetched
) = (IDispatch
*)&This
->col
->elems
[This
->iter
+fetched
]->IHTMLElement_iface
;
158 IDispatch_AddRef(V_DISPATCH(rgVar
+fetched
));
162 This
->iter
+= fetched
;
164 *pCeltFetched
= fetched
;
165 return fetched
== celt
? S_OK
: S_FALSE
;
168 static HRESULT WINAPI
HTMLElementCollectionEnum_Skip(IEnumVARIANT
*iface
, ULONG celt
)
170 HTMLElementCollectionEnum
*This
= impl_from_IEnumVARIANT(iface
);
172 TRACE("(%p)->(%d)\n", This
, celt
);
174 if(This
->iter
+ celt
> This
->col
->len
) {
175 This
->iter
= This
->col
->len
;
183 static HRESULT WINAPI
HTMLElementCollectionEnum_Reset(IEnumVARIANT
*iface
)
185 HTMLElementCollectionEnum
*This
= impl_from_IEnumVARIANT(iface
);
187 TRACE("(%p)->()\n", This
);
193 static HRESULT WINAPI
HTMLElementCollectionEnum_Clone(IEnumVARIANT
*iface
, IEnumVARIANT
**ppEnum
)
195 HTMLElementCollectionEnum
*This
= impl_from_IEnumVARIANT(iface
);
196 FIXME("(%p)->(%p)\n", This
, ppEnum
);
200 static const IEnumVARIANTVtbl HTMLElementCollectionEnumVtbl
= {
201 HTMLElementCollectionEnum_QueryInterface
,
202 HTMLElementCollectionEnum_AddRef
,
203 HTMLElementCollectionEnum_Release
,
204 HTMLElementCollectionEnum_Next
,
205 HTMLElementCollectionEnum_Skip
,
206 HTMLElementCollectionEnum_Reset
,
207 HTMLElementCollectionEnum_Clone
210 static inline HTMLElementCollection
*impl_from_IHTMLElementCollection(IHTMLElementCollection
*iface
)
212 return CONTAINING_RECORD(iface
, HTMLElementCollection
, IHTMLElementCollection_iface
);
215 static HRESULT WINAPI
HTMLElementCollection_QueryInterface(IHTMLElementCollection
*iface
,
216 REFIID riid
, void **ppv
)
218 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
222 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
223 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
224 *ppv
= &This
->IHTMLElementCollection_iface
;
225 }else if(IsEqualGUID(&IID_IHTMLElementCollection
, riid
)) {
226 TRACE("(%p)->(IID_IHTMLElementCollection %p)\n", This
, ppv
);
227 *ppv
= &This
->IHTMLElementCollection_iface
;
228 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
229 return *ppv
? S_OK
: E_NOINTERFACE
;
233 IHTMLElementCollection_AddRef(&This
->IHTMLElementCollection_iface
);
237 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
238 return E_NOINTERFACE
;
241 static ULONG WINAPI
HTMLElementCollection_AddRef(IHTMLElementCollection
*iface
)
243 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
244 LONG ref
= InterlockedIncrement(&This
->ref
);
246 TRACE("(%p) ref=%d\n", This
, ref
);
251 static ULONG WINAPI
HTMLElementCollection_Release(IHTMLElementCollection
*iface
)
253 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
254 LONG ref
= InterlockedDecrement(&This
->ref
);
256 TRACE("(%p) ref=%d\n", This
, ref
);
261 for(i
=0; i
< This
->len
; i
++)
262 node_release(&This
->elems
[i
]->node
);
263 heap_free(This
->elems
);
265 release_dispex(&This
->dispex
);
272 static HRESULT WINAPI
HTMLElementCollection_GetTypeInfoCount(IHTMLElementCollection
*iface
,
275 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
276 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
279 static HRESULT WINAPI
HTMLElementCollection_GetTypeInfo(IHTMLElementCollection
*iface
,
280 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
282 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
283 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
286 static HRESULT WINAPI
HTMLElementCollection_GetIDsOfNames(IHTMLElementCollection
*iface
,
287 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
289 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
290 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
294 static HRESULT WINAPI
HTMLElementCollection_Invoke(IHTMLElementCollection
*iface
,
295 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
296 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
298 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
299 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
300 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
303 static HRESULT WINAPI
HTMLElementCollection_toString(IHTMLElementCollection
*iface
,
306 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
307 FIXME("(%p)->(%p)\n", This
, String
);
311 static HRESULT WINAPI
HTMLElementCollection_put_length(IHTMLElementCollection
*iface
,
314 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
315 FIXME("(%p)->(%d)\n", This
, v
);
319 static HRESULT WINAPI
HTMLElementCollection_get_length(IHTMLElementCollection
*iface
,
322 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
324 TRACE("(%p)->(%p)\n", This
, p
);
330 static HRESULT WINAPI
HTMLElementCollection_get__newEnum(IHTMLElementCollection
*iface
,
333 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
334 HTMLElementCollectionEnum
*ret
;
336 TRACE("(%p)->(%p)\n", This
, p
);
338 ret
= heap_alloc(sizeof(*ret
));
340 return E_OUTOFMEMORY
;
342 ret
->IEnumVARIANT_iface
.lpVtbl
= &HTMLElementCollectionEnumVtbl
;
346 IHTMLElementCollection_AddRef(&This
->IHTMLElementCollection_iface
);
349 *p
= (IUnknown
*)&ret
->IEnumVARIANT_iface
;
353 static BOOL
is_elem_id(HTMLElement
*elem
, LPCWSTR name
)
358 hres
= IHTMLElement_get_id(&elem
->IHTMLElement_iface
, &elem_id
);
360 WARN("IHTMLElement_get_id failed: 0x%08x\n", hres
);
364 if(elem_id
&& !strcmpW(elem_id
, name
)) {
365 SysFreeString(elem_id
);
369 SysFreeString(elem_id
);
373 static BOOL
is_elem_name(HTMLElement
*elem
, LPCWSTR name
)
375 const PRUnichar
*str
;
376 nsAString nsstr
, nsname
;
380 static const PRUnichar nameW
[] = {'n','a','m','e',0};
385 nsAString_Init(&nsstr
, NULL
);
386 nsIDOMHTMLElement_GetId(elem
->nselem
, &nsstr
);
387 nsAString_GetData(&nsstr
, &str
);
388 if(!strcmpiW(str
, name
)) {
389 nsAString_Finish(&nsstr
);
393 nsAString_InitDepend(&nsname
, nameW
);
394 nsres
= nsIDOMHTMLElement_GetAttribute(elem
->nselem
, &nsname
, &nsstr
);
395 nsAString_Finish(&nsname
);
396 if(NS_SUCCEEDED(nsres
)) {
397 nsAString_GetData(&nsstr
, &str
);
398 ret
= !strcmpiW(str
, name
);
401 nsAString_Finish(&nsstr
);
405 static HRESULT
get_item_idx(HTMLElementCollection
*This
, UINT idx
, IDispatch
**ret
)
407 if(idx
< This
->len
) {
408 *ret
= (IDispatch
*)This
->elems
[idx
];
409 IDispatch_AddRef(*ret
);
415 static HRESULT WINAPI
HTMLElementCollection_item(IHTMLElementCollection
*iface
,
416 VARIANT name
, VARIANT index
, IDispatch
**pdisp
)
418 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
421 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&name
), debugstr_variant(&index
), pdisp
);
425 switch(V_VT(&name
)) {
429 hres
= get_item_idx(This
, V_I4(&name
), pdisp
);
433 hres
= get_item_idx(This
, V_UINT(&name
), pdisp
);
439 if(V_VT(&index
) == VT_I4
) {
440 LONG idx
= V_I4(&index
);
445 for(i
=0; i
<This
->len
; i
++) {
446 if(is_elem_name(This
->elems
[i
], V_BSTR(&name
)) && !idx
--)
451 *pdisp
= (IDispatch
*)&This
->elems
[i
]->IHTMLElement_iface
;
452 IDispatch_AddRef(*pdisp
);
455 elem_vector_t buf
= {NULL
, 0, 8};
457 buf
.buf
= heap_alloc(buf
.size
*sizeof(HTMLElement
*));
459 for(i
=0; i
<This
->len
; i
++) {
460 if(is_elem_name(This
->elems
[i
], V_BSTR(&name
))) {
461 node_addref(&This
->elems
[i
]->node
);
462 elem_vector_add(&buf
, This
->elems
[i
]);
467 elem_vector_normalize(&buf
);
468 *pdisp
= (IDispatch
*)HTMLElementCollection_Create(buf
.buf
, buf
.len
);
471 /* Already AddRef-ed */
472 *pdisp
= (IDispatch
*)&buf
.buf
[0]->IHTMLElement_iface
;
482 FIXME("Unsupported name %s\n", debugstr_variant(&name
));
487 TRACE("returning %p\n", *pdisp
);
491 static HRESULT WINAPI
HTMLElementCollection_tags(IHTMLElementCollection
*iface
,
492 VARIANT tagName
, IDispatch
**pdisp
)
494 HTMLElementCollection
*This
= impl_from_IHTMLElementCollection(iface
);
497 const PRUnichar
*tag
;
498 elem_vector_t buf
= {NULL
, 0, 8};
500 if(V_VT(&tagName
) != VT_BSTR
) {
501 WARN("Invalid arg\n");
502 return DISP_E_MEMBERNOTFOUND
;
505 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(V_BSTR(&tagName
)), pdisp
);
507 buf
.buf
= heap_alloc(buf
.size
*sizeof(HTMLElement
*));
509 nsAString_Init(&tag_str
, NULL
);
511 for(i
=0; i
<This
->len
; i
++) {
512 if(!This
->elems
[i
]->nselem
)
515 nsIDOMHTMLElement_GetTagName(This
->elems
[i
]->nselem
, &tag_str
);
516 nsAString_GetData(&tag_str
, &tag
);
518 if(CompareStringW(LOCALE_SYSTEM_DEFAULT
, NORM_IGNORECASE
, tag
, -1,
519 V_BSTR(&tagName
), -1) == CSTR_EQUAL
) {
520 node_addref(&This
->elems
[i
]->node
);
521 elem_vector_add(&buf
, This
->elems
[i
]);
525 nsAString_Finish(&tag_str
);
526 elem_vector_normalize(&buf
);
528 TRACE("fount %d tags\n", buf
.len
);
530 *pdisp
= (IDispatch
*)HTMLElementCollection_Create(buf
.buf
, buf
.len
);
534 static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl
= {
535 HTMLElementCollection_QueryInterface
,
536 HTMLElementCollection_AddRef
,
537 HTMLElementCollection_Release
,
538 HTMLElementCollection_GetTypeInfoCount
,
539 HTMLElementCollection_GetTypeInfo
,
540 HTMLElementCollection_GetIDsOfNames
,
541 HTMLElementCollection_Invoke
,
542 HTMLElementCollection_toString
,
543 HTMLElementCollection_put_length
,
544 HTMLElementCollection_get_length
,
545 HTMLElementCollection_get__newEnum
,
546 HTMLElementCollection_item
,
547 HTMLElementCollection_tags
550 static inline HTMLElementCollection
*impl_from_DispatchEx(DispatchEx
*iface
)
552 return CONTAINING_RECORD(iface
, HTMLElementCollection
, dispex
);
555 #define DISPID_ELEMCOL_0 MSHTML_DISPID_CUSTOM_MIN
557 static HRESULT
HTMLElementCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
559 HTMLElementCollection
*This
= impl_from_DispatchEx(dispex
);
564 return DISP_E_UNKNOWNNAME
;
566 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
567 idx
= idx
*10 + (*ptr
-'0');
570 /* the name contains alpha characters, so search by name & id */
571 for(idx
= 0; idx
< This
->len
; ++idx
) {
572 if(is_elem_id(This
->elems
[idx
], name
) ||
573 is_elem_name(This
->elems
[idx
], name
))
579 return DISP_E_UNKNOWNNAME
;
581 *dispid
= DISPID_ELEMCOL_0
+ idx
;
582 TRACE("ret %x\n", *dispid
);
586 static HRESULT
HTMLElementCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
587 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
589 HTMLElementCollection
*This
= impl_from_DispatchEx(dispex
);
592 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
594 idx
= id
- DISPID_ELEMCOL_0
;
596 return DISP_E_UNKNOWNNAME
;
599 case DISPATCH_PROPERTYGET
:
600 V_VT(res
) = VT_DISPATCH
;
601 V_DISPATCH(res
) = (IDispatch
*)&This
->elems
[idx
]->IHTMLElement_iface
;
602 IHTMLElement_AddRef(&This
->elems
[idx
]->IHTMLElement_iface
);
605 FIXME("unimplemented flags %x\n", flags
);
612 static const dispex_static_data_vtbl_t HTMLElementColection_dispex_vtbl
= {
614 HTMLElementCollection_get_dispid
,
615 HTMLElementCollection_invoke
,
619 static const tid_t HTMLElementCollection_iface_tids
[] = {
620 IHTMLElementCollection_tid
,
624 static dispex_static_data_t HTMLElementCollection_dispex
= {
625 &HTMLElementColection_dispex_vtbl
,
626 DispHTMLElementCollection_tid
,
628 HTMLElementCollection_iface_tids
631 static void create_all_list(HTMLDocumentNode
*doc
, HTMLDOMNode
*elem
, elem_vector_t
*buf
)
633 nsIDOMNodeList
*nsnode_list
;
635 UINT32 list_len
= 0, i
;
639 nsres
= nsIDOMNode_GetChildNodes(elem
->nsnode
, &nsnode_list
);
640 if(NS_FAILED(nsres
)) {
641 ERR("GetChildNodes failed: %08x\n", nsres
);
645 nsIDOMNodeList_GetLength(nsnode_list
, &list_len
);
649 for(i
=0; i
<list_len
; i
++) {
650 nsres
= nsIDOMNodeList_Item(nsnode_list
, i
, &iter
);
651 if(NS_FAILED(nsres
)) {
652 ERR("Item failed: %08x\n", nsres
);
656 if(is_elem_node(iter
)) {
659 hres
= get_node(doc
, iter
, TRUE
, &node
);
661 FIXME("get_node failed: %08x\n", hres
);
665 elem_vector_add(buf
, elem_from_HTMLDOMNode(node
));
666 create_all_list(doc
, node
, buf
);
671 IHTMLElementCollection
*create_all_collection(HTMLDOMNode
*node
, BOOL include_root
)
673 elem_vector_t buf
= {NULL
, 0, 8};
675 buf
.buf
= heap_alloc(buf
.size
*sizeof(HTMLElement
*));
679 elem_vector_add(&buf
, elem_from_HTMLDOMNode(node
));
681 create_all_list(node
->doc
, node
, &buf
);
682 elem_vector_normalize(&buf
);
684 return HTMLElementCollection_Create(buf
.buf
, buf
.len
);
687 IHTMLElementCollection
*create_collection_from_nodelist(HTMLDocumentNode
*doc
, nsIDOMNodeList
*nslist
)
689 UINT32 length
= 0, i
;
694 nsIDOMNodeList_GetLength(nslist
, &length
);
701 buf
.buf
= heap_alloc(buf
.size
*sizeof(HTMLElement
*));
703 for(i
=0; i
<length
; i
++) {
704 nsIDOMNodeList_Item(nslist
, i
, &nsnode
);
705 if(is_elem_node(nsnode
)) {
706 hres
= get_node(doc
, nsnode
, TRUE
, &node
);
709 buf
.buf
[buf
.len
++] = elem_from_HTMLDOMNode(node
);
711 nsIDOMNode_Release(nsnode
);
714 elem_vector_normalize(&buf
);
719 return HTMLElementCollection_Create(buf
.buf
, buf
.len
);
722 IHTMLElementCollection
*create_collection_from_htmlcol(HTMLDocumentNode
*doc
, nsIDOMHTMLCollection
*nscol
)
724 UINT32 length
= 0, i
;
729 nsIDOMHTMLCollection_GetLength(nscol
, &length
);
731 buf
.len
= buf
.size
= length
;
735 buf
.buf
= heap_alloc(buf
.size
*sizeof(HTMLElement
*));
737 for(i
=0; i
<length
; i
++) {
738 nsIDOMHTMLCollection_Item(nscol
, i
, &nsnode
);
739 hres
= get_node(doc
, nsnode
, TRUE
, &node
);
740 nsIDOMNode_Release(nsnode
);
743 buf
.buf
[i
] = elem_from_HTMLDOMNode(node
);
754 return HTMLElementCollection_Create(buf
.buf
, buf
.len
);
757 static IHTMLElementCollection
*HTMLElementCollection_Create(HTMLElement
**elems
, DWORD len
)
759 HTMLElementCollection
*ret
= heap_alloc_zero(sizeof(HTMLElementCollection
));
761 ret
->IHTMLElementCollection_iface
.lpVtbl
= &HTMLElementCollectionVtbl
;
766 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLElementCollection_iface
,
767 &HTMLElementCollection_dispex
);
769 TRACE("ret=%p len=%d\n", ret
, len
);
771 return &ret
->IHTMLElementCollection_iface
;