Jacek Caban : mshtml: Don't create window in create_doc_from_nsdoc.

Alexandre Julliard julliard at winehq.org
Thu Sep 17 13:52:18 CDT 2009


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Sep 16 22:07:38 2009 +0200

mshtml: Don't create window in create_doc_from_nsdoc.

---

 dlls/mshtml/htmldoc.c        |   13 +++++--------
 dlls/mshtml/htmliframe.c     |   12 +++++++++++-
 dlls/mshtml/htmlwindow.c     |    3 +--
 dlls/mshtml/mshtml_private.h |    4 ++--
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 9eea254..04ef042 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1847,10 +1847,9 @@ static const htmldoc_vtbl_t HTMLDocumentNodeVtbl = {
     HTMLDocumentNode_Release
 };
 
-HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentNode **ret)
+HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLWindow *window, HTMLDocumentNode **ret)
 {
     HTMLDocumentNode *doc;
-    HRESULT hres;
 
     doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
     if(!doc)
@@ -1862,11 +1861,8 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentNode **ret)
     nsIDOMHTMLDocument_AddRef(nsdoc);
     doc->basedoc.nsdoc = nsdoc;
 
-    hres = HTMLWindow_Create(&doc->basedoc, NULL, &doc->basedoc.window);
-    if(FAILED(hres)) {
-        htmldoc_release(&doc->basedoc);
-        return hres;
-    }
+    IHTMLWindow2_AddRef(HTMLWINDOW2(window));
+    doc->basedoc.window = window;
 
     *ret = doc;
     return S_OK;
@@ -1946,7 +1942,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
             ERR("GetContentDOMWindow failed: %08x\n", nsres);
     }
 
-    hres = HTMLWindow_Create(&doc->basedoc, nswindow, &doc->basedoc.window);
+    hres = HTMLWindow_Create(nswindow, &doc->basedoc.window);
     if(nswindow)
         nsIDOMWindow_Release(nswindow);
     if(FAILED(hres)) {
@@ -1954,6 +1950,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
         return hres;
     }
 
+    doc->basedoc.window->doc = &doc->basedoc;
     get_thread_hwnd();
 
     return S_OK;
diff --git a/dlls/mshtml/htmliframe.c b/dlls/mshtml/htmliframe.c
index 713932f..f0c8cdd 100644
--- a/dlls/mshtml/htmliframe.c
+++ b/dlls/mshtml/htmliframe.c
@@ -107,6 +107,7 @@ static HRESULT WINAPI HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface,
     if(!This->content_doc) {
         nsIDOMHTMLDocument *nshtmldoc;
         nsIDOMDocument *nsdoc;
+        HTMLWindow *window;
         nsresult nsres;
         HRESULT hres;
 
@@ -128,7 +129,16 @@ static HRESULT WINAPI HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface,
             return E_FAIL;
         }
 
-        hres = create_doc_from_nsdoc(nshtmldoc, &This->content_doc);
+        hres = HTMLWindow_Create(NULL, &window);
+        if(FAILED(hres)) {
+            nsIDOMDocument_Release(nsdoc);
+            return hres;
+        }
+
+        hres = create_doc_from_nsdoc(nshtmldoc, window, &This->content_doc);
+        if(SUCCEEDED(hres))
+            window->doc = &This->content_doc->basedoc;
+        IHTMLWindow2_Release(HTMLWINDOW2(window));
         nsIDOMHTMLDocument_Release(nshtmldoc);
         if(FAILED(hres))
             return hres;
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 8fae282..1ce18cb 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -1413,7 +1413,7 @@ static dispex_static_data_t HTMLWindow_dispex = {
     HTMLWindow_iface_tids
 };
 
-HRESULT HTMLWindow_Create(HTMLDocument *doc, nsIDOMWindow *nswindow, HTMLWindow **ret)
+HRESULT HTMLWindow_Create(nsIDOMWindow *nswindow, HTMLWindow **ret)
 {
     HTMLWindow *window;
 
@@ -1425,7 +1425,6 @@ HRESULT HTMLWindow_Create(HTMLDocument *doc, nsIDOMWindow *nswindow, HTMLWindow
     window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
     window->lpIDispatchExVtbl = &WindowDispExVtbl;
     window->ref = 1;
-    window->doc = doc;
 
     init_dispex(&window->dispex, (IUnknown*)HTMLWINDOW2(window), &HTMLWindow_dispex);
 
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 6f65787..21e6e2a 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -540,9 +540,9 @@ typedef struct {
 
 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
-HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentNode**);
+HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLWindow*,HTMLDocumentNode**);
 
-HRESULT HTMLWindow_Create(HTMLDocument*,nsIDOMWindow*,HTMLWindow**);
+HRESULT HTMLWindow_Create(nsIDOMWindow*,HTMLWindow**);
 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);




More information about the wine-cvs mailing list