Commit 53f00d02 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use create_collection_from_nodelist in IHTMLElement::get_children implementation.

parent c584effc
......@@ -1210,48 +1210,23 @@ static HRESULT WINAPI HTMLElement_get_onfilterchange(IHTMLElement *iface, VARIAN
return E_NOTIMPL;
}
static void create_child_list(HTMLDocument *doc, HTMLElement *elem, elem_vector *buf)
static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
{
HTMLElement *This = HTMLELEM_THIS(iface);
nsIDOMNodeList *nsnode_list;
nsIDOMNode *iter;
PRUint32 list_len = 0, i;
nsresult nsres;
nsres = nsIDOMNode_GetChildNodes(elem->node.nsnode, &nsnode_list);
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMNode_GetChildNodes(This->node.nsnode, &nsnode_list);
if(NS_FAILED(nsres)) {
ERR("GetChildNodes failed: %08x\n", nsres);
return;
}
nsIDOMNodeList_GetLength(nsnode_list, &list_len);
if(!list_len)
return;
buf->size = list_len;
buf->buf = heap_alloc(buf->size*sizeof(HTMLElement**));
for(i=0; i<list_len; i++) {
nsres = nsIDOMNodeList_Item(nsnode_list, i, &iter);
if(NS_FAILED(nsres)) {
ERR("Item failed: %08x\n", nsres);
continue;
}
if(is_elem_node(iter))
elem_vector_add(buf, HTMLELEM_NODE_THIS(get_node(doc, iter, TRUE)));
return E_FAIL;
}
}
static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **p)
{
HTMLElement *This = HTMLELEM_THIS(iface);
elem_vector buf = {NULL, 0, 0};
*p = (IDispatch*)create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nsnode_list);
TRACE("(%p)->(%p)\n", This, p);
create_child_list(This->node.doc, This, &buf);
*p = (IDispatch*)HTMLElementCollection_Create((IUnknown*)HTMLELEM(This), buf.buf, buf.len);
nsIDOMNodeList_Release(nsnode_list);
return S_OK;
}
......
......@@ -491,7 +491,8 @@ IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument *doc, IUnkn
for(i=0; i<length; i++) {
nsIDOMNodeList_Item(nslist, i, &nsnode);
buf.buf[i] = HTMLELEM_NODE_THIS(get_node(doc, nsnode, TRUE));
if(is_elem_node(nsnode))
buf.buf[i] = HTMLELEM_NODE_THIS(get_node(doc, nsnode, TRUE));
nsIDOMNode_Release(nsnode);
}
}else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment