Jacek Caban : mshtml: Use stored nsdoc in IHTMLDocument2::get_title.

Alexandre Julliard julliard at winehq.org
Thu Oct 9 07:42:48 CDT 2008


Module: wine
Branch: master
Commit: c5adad12fefe0d50f1dd647e234b0e2095825416
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c5adad12fefe0d50f1dd647e234b0e2095825416

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Oct  8 13:28:59 2008 -0500

mshtml: Use stored nsdoc in IHTMLDocument2::get_title.

---

 dlls/mshtml/htmldoc.c |   30 ++++++++++++------------------
 1 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index d31c9ce..a3d68c6 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -391,36 +391,30 @@ static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    nsIDOMHTMLDocument *nshtmldoc;
-    nsIDOMDocument *nsdoc;
     const PRUnichar *ret;
     nsAString nsstr;
     nsresult nsres;
 
     TRACE("(%p)->(%p)\n", This, p);
 
-    if(!This->nscontainer)
-        return E_FAIL;
-
-    nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
-    if(NS_FAILED(nsres) || !nsdoc) {
-        ERR("GetDocument failed: %08x\n", nsres);
-        return E_FAIL;
+    if(!This->nsdoc) {
+        WARN("NULL nsdoc\n");
+        return E_UNEXPECTED;
     }
 
-    nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
-    nsIDOMDocument_Release(nsdoc);
 
     nsAString_Init(&nsstr, NULL);
+    nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
+    if (NS_SUCCEEDED(nsres)) {
+        nsAString_GetData(&nsstr, &ret);
+        *p = SysAllocString(ret);
+    }
+    nsAString_Finish(&nsstr);
 
-    nsres = nsIDOMHTMLDocument_GetTitle(nshtmldoc, &nsstr);
-    nsIDOMHTMLDocument_Release(nshtmldoc);
-    if (NS_FAILED(nsres))
+    if(NS_FAILED(nsres)) {
         ERR("GetTitle failed: %08x\n", nsres);
-
-    nsAString_GetData(&nsstr, &ret);
-    *p = SysAllocString(ret);
-    nsAString_Finish(&nsstr);
+        return E_FAIL;
+    }
 
     return S_OK;
 }




More information about the wine-cvs mailing list