mshtml: Include document element in collection returned by IHTMLDocument2::get_all.
This commit is contained in:
parent
e9cb14646c
commit
6437becb5b
|
@ -234,25 +234,36 @@ static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch *
|
|||
static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
|
||||
{
|
||||
HTMLDocument *This = HTMLDOC_THIS(iface);
|
||||
IHTMLElement *doc;
|
||||
IDispatch *disp;
|
||||
HRESULT hres;
|
||||
nsIDOMDocument *nsdoc = NULL;
|
||||
nsIDOMElement *nselem = NULL;
|
||||
nsresult nsres;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, p);
|
||||
|
||||
hres = IHTMLDocument3_get_documentElement(HTMLDOC3(This), &doc);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
if(!This->nscontainer) {
|
||||
*p = NULL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
hres = IHTMLElement_get_all(doc, &disp);
|
||||
IHTMLElement_Release(doc);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("GetDocument failed: %08x\n", nsres);
|
||||
|
||||
hres = IDispatch_QueryInterface(disp, &IID_IHTMLElementCollection, (void**)p);
|
||||
IDispatch_Release(disp);
|
||||
if(nsdoc) {
|
||||
nsres = nsIDOMHTMLDocument_GetDocumentElement(nsdoc, &nselem);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("GetDocumentElement failed: %08x\n", nsres);
|
||||
}
|
||||
|
||||
return hres;
|
||||
if(!nselem) {
|
||||
*p = NULL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*p = create_all_collection(get_node(This, (nsIDOMNode*)nselem));
|
||||
|
||||
nsIDOMElement_Release(nselem);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
|
||||
|
|
|
@ -1087,7 +1087,7 @@ static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static void create_all_list(HTMLDocument *doc, HTMLElement *elem, elem_vector *buf)
|
||||
static void create_all_list(HTMLDocument *doc, HTMLDOMNode *elem, elem_vector *buf)
|
||||
{
|
||||
nsIDOMNodeList *nsnode_list;
|
||||
nsIDOMNode *iter;
|
||||
|
@ -1095,7 +1095,7 @@ static void create_all_list(HTMLDocument *doc, HTMLElement *elem, elem_vector *b
|
|||
PRUint16 node_type;
|
||||
nsresult nsres;
|
||||
|
||||
nsres = nsIDOMNode_GetChildNodes(elem->node.nsnode, &nsnode_list);
|
||||
nsres = nsIDOMNode_GetChildNodes(elem->nsnode, &nsnode_list);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("GetChildNodes failed: %08x\n", nsres);
|
||||
return;
|
||||
|
@ -1117,7 +1117,7 @@ static void create_all_list(HTMLDocument *doc, HTMLElement *elem, elem_vector *b
|
|||
HTMLDOMNode *node = get_node(doc, iter);
|
||||
|
||||
elem_vector_add(buf, HTMLELEM_NODE_THIS(node));
|
||||
create_all_list(doc, HTMLELEM_NODE_THIS(node), buf);
|
||||
create_all_list(doc, node, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1131,7 +1131,7 @@ static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
|
|||
|
||||
buf.buf = mshtml_alloc(buf.size*sizeof(HTMLElement**));
|
||||
|
||||
create_all_list(This->node.doc, This, &buf);
|
||||
create_all_list(This->node.doc, &This->node, &buf);
|
||||
elem_vector_normalize(&buf);
|
||||
|
||||
*p = (IDispatch*)HTMLElementCollection_Create((IUnknown*)HTMLELEM(This), buf.buf, buf.len);
|
||||
|
@ -1595,6 +1595,19 @@ static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = {
|
|||
HTMLElementCollection_tags
|
||||
};
|
||||
|
||||
IHTMLElementCollection *create_all_collection(HTMLDOMNode *node)
|
||||
{
|
||||
elem_vector buf = {NULL, 0, 8};
|
||||
|
||||
buf.buf = mshtml_alloc(buf.size*sizeof(HTMLElement**));
|
||||
|
||||
elem_vector_add(&buf, HTMLELEM_NODE_THIS(node));
|
||||
create_all_list(node->doc, node, &buf);
|
||||
elem_vector_normalize(&buf);
|
||||
|
||||
return HTMLElementCollection_Create((IUnknown*)HTMLDOMNODE(node), buf.buf, buf.len);
|
||||
}
|
||||
|
||||
static IHTMLElementCollection *HTMLElementCollection_Create(IUnknown *ref_unk,
|
||||
HTMLElement **elems, DWORD len)
|
||||
{
|
||||
|
|
|
@ -430,6 +430,8 @@ void HTMLElement_destructor(HTMLDOMNode*);
|
|||
HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
|
||||
void release_nodes(HTMLDocument*);
|
||||
|
||||
IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
|
||||
|
||||
BOOL install_wine_gecko(void);
|
||||
|
||||
/* commands */
|
||||
|
|
Loading…
Reference in New Issue