diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index dd989ffe897..ebb6538fd14 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -289,7 +289,7 @@ static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCo return S_OK; } - *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE)); + *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE); nsIDOMElement_Release(nselem); return S_OK; diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index fb3cccdc66b..d3c063370cd 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -35,43 +35,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); -typedef struct { - HTMLElement **buf; - DWORD len; - DWORD size; -} elem_vector; - -static void elem_vector_add(elem_vector *buf, HTMLElement *elem) -{ - if(buf->len == buf->size) { - buf->size <<= 1; - buf->buf = heap_realloc(buf->buf, buf->size*sizeof(HTMLElement**)); - } - - buf->buf[buf->len++] = elem; -} - -static void elem_vector_normalize(elem_vector *buf) -{ - if(!buf->len) { - heap_free(buf->buf); - buf->buf = NULL; - }else if(buf->size > buf->len) { - buf->buf = heap_realloc(buf->buf, buf->len*sizeof(HTMLElement**)); - } - - buf->size = buf->len; -} - -static BOOL is_elem_node(nsIDOMNode *node) -{ - PRUint16 type=0; - - nsIDOMNode_GetNodeType(node, &type); - - return type == ELEMENT_NODE || type == COMMENT_NODE; -} - #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface) #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface) @@ -1230,52 +1193,13 @@ static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch ** return S_OK; } -static void create_all_list(HTMLDocument *doc, HTMLDOMNode *elem, elem_vector *buf) -{ - nsIDOMNodeList *nsnode_list; - nsIDOMNode *iter; - PRUint32 list_len = 0, i; - nsresult nsres; - - nsres = nsIDOMNode_GetChildNodes(elem->nsnode, &nsnode_list); - if(NS_FAILED(nsres)) { - ERR("GetChildNodes failed: %08x\n", nsres); - return; - } - - nsIDOMNodeList_GetLength(nsnode_list, &list_len); - if(!list_len) - return; - - for(i=0; i(%p)\n", This, p); - buf.buf = heap_alloc(buf.size*sizeof(HTMLElement**)); - - create_all_list(This->node.doc, &This->node, &buf); - elem_vector_normalize(&buf); - - *p = (IDispatch*)HTMLElementCollection_Create((IUnknown*)HTMLELEM(This), buf.buf, buf.len); + *p = (IDispatch*)create_all_collection(&This->node, FALSE); return S_OK; } diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index 9a2c71084b1..768dbeecbca 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -463,13 +463,14 @@ static void create_all_list(HTMLDocument *doc, HTMLDOMNode *elem, elem_vector_t } } -IHTMLElementCollection *create_all_collection(HTMLDOMNode *node) +IHTMLElementCollection *create_all_collection(HTMLDOMNode *node, BOOL include_root) { elem_vector_t buf = {NULL, 0, 8}; buf.buf = heap_alloc(buf.size*sizeof(HTMLElement**)); - elem_vector_add(&buf, HTMLELEM_NODE_THIS(node)); + if(include_root) + elem_vector_add(&buf, HTMLELEM_NODE_THIS(node)); create_all_list(node->doc, node, &buf); elem_vector_normalize(&buf); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 80dc5ff3e5a..b14ad0283ce 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -585,7 +585,7 @@ IDispatch *script_parse_event(HTMLDocument*,LPCWSTR); void set_script_mode(HTMLDocument*,SCRIPTMODE); IHTMLElementCollection *HTMLElementCollection_Create(IUnknown*,HTMLElement**,DWORD); -IHTMLElementCollection *create_all_collection(HTMLDOMNode*); +IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL); IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*); /* commands */