Jacek Caban : mshtml: Moved option_factory to HTMLWindow object.

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


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

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

mshtml: Moved option_factory to HTMLWindow object.

---

 dlls/mshtml/htmldoc.c        |    5 -----
 dlls/mshtml/htmloption.c     |   10 +++++-----
 dlls/mshtml/htmlwindow.c     |   11 ++++++++---
 dlls/mshtml/mshtml_private.h |   27 +++++++++++++++------------
 4 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 8b810fc..1c35b4b 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -196,11 +196,6 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
         if(This->hwnd)
             DestroyWindow(This->hwnd);
 
-        if(This->option_factory) {
-            This->option_factory->doc = NULL;
-            IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
-        }
-
         if(This->location)
             This->location->doc = NULL;
 
diff --git a/dlls/mshtml/htmloption.c b/dlls/mshtml/htmloption.c
index 49d8deb..0bc9f2c 100644
--- a/dlls/mshtml/htmloption.c
+++ b/dlls/mshtml/htmloption.c
@@ -459,7 +459,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
     TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value),
           debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem);
 
-    if(!This->doc->nsdoc) {
+    if(!This->window || !This->window->doc || !This->window->doc->nsdoc) {
         WARN("NULL nsdoc\n");
         return E_UNEXPECTED;
     }
@@ -467,14 +467,14 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
     *optelem = NULL;
 
     nsAString_Init(&option_str, optionW);
-    nsres = nsIDOMHTMLDocument_CreateElement(This->doc->nsdoc, &option_str, &nselem);
+    nsres = nsIDOMHTMLDocument_CreateElement(This->window->doc->nsdoc, &option_str, &nselem);
     nsAString_Finish(&option_str);
     if(NS_FAILED(nsres)) {
         ERR("CreateElement failed: %08x\n", nsres);
         return E_FAIL;
     }
 
-    hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(This->doc, (nsIDOMNode*)nselem, TRUE)),
+    hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(This->window->doc, (nsIDOMNode*)nselem, TRUE)),
             &IID_IHTMLOptionElement, (void**)optelem);
     nsIDOMElement_Release(nselem);
 
@@ -509,7 +509,7 @@ static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl = {
     HTMLOptionElementFactory_create
 };
 
-HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument *doc)
+HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow *window)
 {
     HTMLOptionElementFactory *ret;
 
@@ -517,7 +517,7 @@ HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument *doc)
 
     ret->lpHTMLOptionElementFactoryVtbl = &HTMLOptionElementFactoryVtbl;
     ret->ref = 1;
-    ret->doc = doc;
+    ret->window = window;
 
     return ret;
 }
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index f268a0a..60a46a1 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -95,6 +95,11 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
     if(!ref) {
         DWORD i;
 
+        if(This->option_factory) {
+            This->option_factory->window = NULL;
+            IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
+        }
+
         if(This->event_target)
             release_event_target(This->event_target);
         for(i=0; i < This->global_prop_cnt; i++)
@@ -672,10 +677,10 @@ static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionEle
 
     TRACE("(%p)->(%p)\n", This, p);
 
-    if(!This->doc->option_factory)
-        This->doc->option_factory = HTMLOptionElementFactory_Create(This->doc);
+    if(!This->option_factory)
+        This->option_factory = HTMLOptionElementFactory_Create(This);
 
-    *p = HTMLOPTFACTORY(This->doc->option_factory);
+    *p = HTMLOPTFACTORY(This->option_factory);
     IHTMLOptionElementFactory_AddRef(*p);
 
     return S_OK;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 2aedc98..f5cb291 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Jacek Caban for CodeWeavers
+ * Copyright 2005-2009 Jacek Caban for CodeWeavers
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -153,6 +153,8 @@ void release_dispex(DispatchEx*);
 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
 
+typedef struct HTMLWindow HTMLWindow;
+
 typedef enum {
     SCRIPTMODE_GECKO,
     SCRIPTMODE_ACTIVESCRIPT
@@ -167,6 +169,14 @@ typedef struct {
 } global_prop_t;
 
 typedef struct {
+    const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
+
+    LONG ref;
+
+    HTMLWindow *window;
+} HTMLOptionElementFactory;
+
+struct HTMLWindow {
     DispatchEx dispex;
     const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
     const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
@@ -183,12 +193,14 @@ typedef struct {
     SCRIPTMODE scriptmode;
     struct list script_hosts;
 
+    HTMLOptionElementFactory *option_factory;
+
     global_prop_t *global_props;
     DWORD global_prop_cnt;
     DWORD global_prop_size;
 
     struct list entry;
-} HTMLWindow;
+};
 
 typedef enum {
     UNKNOWN_USERMODE,
@@ -229,14 +241,6 @@ struct HTMLLocation {
     HTMLDocument *doc;
 };
 
-typedef struct {
-    const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
-
-    LONG ref;
-
-    HTMLDocument *doc;
-} HTMLOptionElementFactory;
-
 struct HTMLDocument {
     DispatchEx dispex;
     const IHTMLDocument2Vtbl              *lpHTMLDocument2Vtbl;
@@ -303,7 +307,6 @@ struct HTMLDocument {
     ConnectionPoint cp_htmldocevents2;
     ConnectionPoint cp_propnotif;
 
-    HTMLOptionElementFactory *option_factory;
     HTMLLocation *location;
 
     struct list selection_list;
@@ -510,7 +513,7 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocument**);
 
 HRESULT HTMLWindow_Create(HTMLDocument*,nsIDOMWindow*,HTMLWindow**);
 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
-HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
+HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
 HTMLLocation *HTMLLocation_Create(HTMLDocument*);
 IOmNavigator *OmNavigator_Create(void);
 




More information about the wine-cvs mailing list