Jacek Caban : mshtml: Use rb tree instead of list to map nsIDOMWindowProxy to HTMLOuterWindow.

Alexandre Julliard julliard at winehq.org
Tue Sep 13 11:33:57 CDT 2016


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Sep 12 13:44:31 2016 +0200

mshtml: Use rb tree instead of list to map nsIDOMWindowProxy to HTMLOuterWindow.

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

---

 dlls/mshtml/htmlwindow.c     | 40 +++++++++++++++++++++-------------------
 dlls/mshtml/mshtml_private.h |  3 ++-
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 407de0c..14246a6 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -44,7 +44,22 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
-static struct list window_list = LIST_INIT(window_list);
+static int window_map_compare(const void *key, const struct wine_rb_entry *entry)
+{
+    HTMLOuterWindow *window = WINE_RB_ENTRY_VALUE(entry, HTMLOuterWindow, entry);
+
+    if(window->window_proxy == key)
+        return 0;
+    return (void*)window->window_proxy > key ? -1 : 1;
+}
+
+static struct wine_rb_tree window_map = { window_map_compare };
+
+HTMLOuterWindow *mozwindow_to_window(const mozIDOMWindowProxy *mozwindow)
+{
+    struct wine_rb_entry *entry = wine_rb_get(&window_map, mozwindow);
+    return entry ? WINE_RB_ENTRY_VALUE(entry, HTMLOuterWindow, entry) : NULL;
+}
 
 static inline BOOL is_outer_window(HTMLWindow *window)
 {
@@ -220,7 +235,7 @@ static void release_outer_window(HTMLOuterWindow *This)
     if(This->window_proxy)
         mozIDOMWindowProxy_Release(This->window_proxy);
 
-    list_remove(&This->entry);
+    wine_rb_remove(&window_map, &This->entry);
     heap_free(This);
 }
 
@@ -3052,6 +3067,10 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
 
     window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
     window->readystate = READYSTATE_UNINITIALIZED;
+    window->task_magic = get_task_target_magic();
+
+    list_init(&window->children);
+    wine_rb_put(&window_map, window->window_proxy, &window->entry);
 
     hres = create_pending_window(window, NULL);
     if(SUCCEEDED(hres))
@@ -3067,11 +3086,6 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
         return hres;
     }
 
-    window->task_magic = get_task_target_magic();
-
-    list_init(&window->children);
-    list_add_head(&window_list, &window->entry);
-
     if(parent) {
         IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
 
@@ -3174,15 +3188,3 @@ HRESULT update_window_doc(HTMLInnerWindow *window)
 
     return hres;
 }
-
-HTMLOuterWindow *mozwindow_to_window(const mozIDOMWindowProxy *mozwindow)
-{
-    HTMLOuterWindow *iter;
-
-    LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLOuterWindow, entry) {
-        if(iter->window_proxy == mozwindow)
-            return iter;
-    }
-
-    return NULL;
-}
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 875d95a..1d4dcc5 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -31,6 +31,7 @@
 #include "shdeprecated.h"
 
 #include "wine/list.h"
+#include "wine/rbtree.h"
 #include "wine/unicode.h"
 
 #ifdef INIT_GUID
@@ -466,7 +467,7 @@ struct HTMLOuterWindow {
 
     struct list children;
     struct list sibling_entry;
-    struct list entry;
+    struct wine_rb_entry entry;
 };
 
 struct HTMLInnerWindow {




More information about the wine-cvs mailing list