mshtml: Use stored nsdoc in IHTMDocument2::get_all.

This commit is contained in:
Jacek Caban 2008-10-08 13:29:32 -05:00 committed by Alexandre Julliard
parent 502532ee23
commit 5629945cb7
1 changed files with 15 additions and 21 deletions

View File

@ -265,35 +265,29 @@ static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch *
static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p) static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
{ {
HTMLDocument *This = HTMLDOC_THIS(iface); HTMLDocument *This = HTMLDOC_THIS(iface);
nsIDOMDocument *nsdoc = NULL;
nsIDOMElement *nselem = NULL; nsIDOMElement *nselem = NULL;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(!This->nscontainer) { if(!This->nsdoc) {
*p = NULL; WARN("NULL nsdoc\n");
return S_OK; return E_UNEXPECTED;
} }
nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc); nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres)) {
ERR("GetDocument failed: %08x\n", nsres);
if(nsdoc) {
nsres = nsIDOMHTMLDocument_GetDocumentElement(nsdoc, &nselem);
if(NS_FAILED(nsres))
ERR("GetDocumentElement failed: %08x\n", nsres); ERR("GetDocumentElement failed: %08x\n", nsres);
return E_FAIL;
} }
if(!nselem) { if(nselem) {
*p = NULL;
return S_OK;
}
*p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE); *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE);
nsIDOMElement_Release(nselem); nsIDOMElement_Release(nselem);
}else {
*p = NULL;
}
return S_OK; return S_OK;
} }