Jacek Caban : mshtml: Create top content window in init_browser.

Alexandre Julliard julliard at winehq.org
Mon Mar 11 16:29:53 CDT 2019


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Mar 11 14:26:39 2019 +0100

mshtml: Create top content window in init_browser.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmldoc.c        | 13 +++----------
 dlls/mshtml/mshtml_private.h |  2 ++
 dlls/mshtml/nsembed.c        | 17 ++++++++++++++++-
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 5731d36..56a8617 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -5443,9 +5443,7 @@ static dispex_static_data_t HTMLDocumentObj_dispex = {
 
 static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID riid, void **ppv)
 {
-    mozIDOMWindowProxy *mozwindow;
     HTMLDocumentObj *doc;
-    nsresult nsres;
     HRESULT hres;
 
     if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
@@ -5492,15 +5490,10 @@ static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID rii
             return hres;
     }
 
-    nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &mozwindow);
-    if(NS_FAILED(nsres))
-        ERR("GetContentDOMWindow failed: %08x\n", nsres);
+    doc->basedoc.window = doc->nscontainer->content_window;
+    IHTMLWindow2_AddRef(&doc->basedoc.window->base.IHTMLWindow2_iface);
 
-    hres = create_outer_window(doc->nscontainer, mozwindow, NULL, &doc->basedoc.window);
-    if(FAILED(hres)) {
-        htmldoc_release(&doc->basedoc);
-        return hres;
-    }
+    doc->basedoc.window->doc_obj = doc;
 
     if(!doc->basedoc.doc_node && doc->basedoc.window->base.inner_window->doc) {
         doc->basedoc.doc_node = doc->basedoc.window->base.inner_window->doc;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 922ac02..1fdedce 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -713,6 +713,8 @@ struct GeckoBrowser {
     nsIBaseWindow *window;
     nsIWebBrowserFocus *focus;
 
+    HTMLOuterWindow *content_window;
+
     nsIEditor *editor;
     nsIController *editor_controller;
 
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index cab41c3..c05c83a 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -2029,9 +2029,11 @@ static const nsISupportsWeakReferenceVtbl nsSupportsWeakReferenceVtbl = {
 
 static HRESULT init_browser(GeckoBrowser *browser)
 {
+    mozIDOMWindowProxy *mozwindow;
     nsIWebBrowserSetup *wbsetup;
     nsIScrollable *scrollable;
     nsresult nsres;
+    HRESULT hres;
 
     nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_WEBBROWSER_CONTRACTID,
             NULL, &IID_nsIWebBrowser, (void**)&browser->webbrowser);
@@ -2132,7 +2134,15 @@ static HRESULT init_browser(GeckoBrowser *browser)
         ERR("Could not get nsIScrollable: %08x\n", nsres);
     }
 
-    return S_OK;
+    nsres = nsIWebBrowser_GetContentDOMWindow(browser->webbrowser, &mozwindow);
+    if(NS_FAILED(nsres)) {
+        ERR("GetContentDOMWindow failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    hres = create_outer_window(browser, mozwindow, NULL, &browser->content_window);
+    mozIDOMWindowProxy_Release(mozwindow);
+    return hres;
 }
 
 HRESULT create_gecko_browser(HTMLDocumentObj *doc, GeckoBrowser **_ret)
@@ -2174,6 +2184,11 @@ void detach_gecko_browser(GeckoBrowser *This)
 
     This->doc = NULL;
 
+    if(This->content_window) {
+        IHTMLWindow2_Release(&This->content_window->base.IHTMLWindow2_iface);
+        This->content_window = NULL;
+    }
+
     while(!list_empty(&This->document_nodes)) {
         HTMLDocumentNode *doc = LIST_ENTRY(list_head(&This->document_nodes), HTMLDocumentNode, browser_entry);
         list_remove(&doc->browser_entry);




More information about the wine-cvs mailing list