From 08257acea2ce942692822d8b6849ba3d44c46906 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 8 Oct 2008 13:29:47 -0500 Subject: [PATCH] mshtml: Use stored nselem in get_documentElement. --- dlls/mshtml/htmldoc3.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/dlls/mshtml/htmldoc3.c b/dlls/mshtml/htmldoc3.c index 2dc5a582caf..d636834a3ec 100644 --- a/dlls/mshtml/htmldoc3.c +++ b/dlls/mshtml/htmldoc3.c @@ -134,31 +134,26 @@ static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR t static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p) { HTMLDocument *This = HTMLDOC3_THIS(iface); - nsIDOMDocument *nsdoc; - HTMLDOMNode *node; nsIDOMElement *nselem = NULL; + HTMLDOMNode *node; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); - if(!This->nscontainer) { - *p = NULL; - return S_OK; + if(!This->nsdoc) { + WARN("NULL nsdoc\n"); + return E_UNEXPECTED; } - nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc); - 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); + nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem); + if(NS_FAILED(nsres)) { + ERR("GetDocumentElement failed: %08x\n", nsres); + return E_FAIL; } + if(nselem) { node = get_node(This, (nsIDOMNode *)nselem, TRUE); - nsIDOMDocument_Release(nsdoc); - + nsIDOMElement_Release(nselem); IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p); }else { *p = NULL; -- 2.11.4.GIT