Jacek Caban : mshtml: Move GetContentDOMWindow call from HTMLWindow_Create.

Alexandre Julliard julliard at winehq.org
Mon Oct 13 06:37:38 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Oct 10 15:48:14 2008 -0500

mshtml: Move GetContentDOMWindow call from HTMLWindow_Create.

---

 dlls/mshtml/htmldoc.c        |    8 +++++++-
 dlls/mshtml/htmlwindow.c     |   32 +++++++++++++++++---------------
 dlls/mshtml/mshtml_private.h |    2 +-
 3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 00bc68c..f39688b 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1551,6 +1551,7 @@ static dispex_static_data_t HTMLDocument_dispex = {
 
 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
 {
+    nsIDOMWindow *nswindow;
     HTMLDocument *ret;
     HRESULT hres;
 
@@ -1596,7 +1597,12 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
     ret->nscontainer = NSContainer_Create(ret, NULL);
     update_nsdocument(ret);
 
-    ret->window = HTMLWindow_Create(ret);
+    if(ret->nscontainer)
+        nsIWebBrowser_GetContentDOMWindow(ret->nscontainer->webbrowser, &nswindow);
+
+    HTMLWindow_Create(ret, nswindow, &ret->window);
+    if(nswindow)
+        nsIDOMWindow_Release(nswindow);
 
     get_thread_hwnd();
 
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 6e8a8ea..b73811a 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -1182,29 +1182,31 @@ static dispex_static_data_t HTMLWindow_dispex = {
     HTMLWindow_iface_tids
 };
 
-HTMLWindow *HTMLWindow_Create(HTMLDocument *doc)
+HRESULT HTMLWindow_Create(HTMLDocument *doc, nsIDOMWindow *nswindow, HTMLWindow **ret)
 {
-    HTMLWindow *ret = heap_alloc_zero(sizeof(HTMLWindow));
+    HTMLWindow *window;
 
-    ret->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
-    ret->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
-    ret->lpIDispatchExVtbl = &WindowDispExVtbl;
-    ret->ref = 1;
-    ret->doc = doc;
+    window = heap_alloc_zero(sizeof(HTMLWindow));
+    if(!window)
+        return E_OUTOFMEMORY;
 
-    init_dispex(&ret->dispex, (IUnknown*)HTMLWINDOW2(ret), &HTMLWindow_dispex);
+    window->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
+    window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
+    window->lpIDispatchExVtbl = &WindowDispExVtbl;
+    window->ref = 1;
+    window->doc = doc;
 
-    if(doc->nscontainer) {
-        nsresult nsres;
+    init_dispex(&window->dispex, (IUnknown*)HTMLWINDOW2(window), &HTMLWindow_dispex);
 
-        nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &ret->nswindow);
-        if(NS_FAILED(nsres))
-            ERR("GetContentDOMWindow failed: %08x\n", nsres);
+    if(nswindow) {
+        nsIDOMWindow_AddRef(nswindow);
+        window->nswindow = nswindow;
     }
 
-    list_add_head(&window_list, &ret->entry);
+    list_add_head(&window_list, &window->entry);
 
-    return ret;
+    *ret = window;
+    return S_OK;
 }
 
 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 79c954d..c39d245 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -460,7 +460,7 @@ typedef struct {
 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
 
-HTMLWindow *HTMLWindow_Create(HTMLDocument*);
+HRESULT HTMLWindow_Create(HTMLDocument*,nsIDOMWindow*,HTMLWindow**);
 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
 HTMLLocation *HTMLLocation_Create(HTMLDocument*);




More information about the wine-cvs mailing list