Module: wine Branch: master Commit: 521888958ca141129d116f5c8a97dbe7b9ede360 URL: https://source.winehq.org/git/wine.git/?a=commit;h=521888958ca141129d116f5c8...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Mar 11 14:23:13 2019 +0100
mshtml: Move child window list to inner window and detach children when detaching parent.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/htmlwindow.c | 32 +++++++++++++++----------------- dlls/mshtml/mshtml_private.h | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index ffd4424..0ab81f1 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -66,19 +66,6 @@ static inline BOOL is_outer_window(HTMLWindow *window) return &window->outer_window->base == window; }
-static void release_children(HTMLOuterWindow *This) -{ - HTMLOuterWindow *child; - - while(!list_empty(&This->children)) { - child = LIST_ENTRY(list_tail(&This->children), HTMLOuterWindow, sibling_entry); - - list_remove(&child->sibling_entry); - child->parent = NULL; - IHTMLWindow2_Release(&child->base.IHTMLWindow2_iface); - } -} - static HRESULT get_location(HTMLInnerWindow *This, HTMLLocation **ret) { if(This->location) { @@ -99,7 +86,7 @@ void get_top_window(HTMLOuterWindow *window, HTMLOuterWindow **ret) { HTMLOuterWindow *iter;
- for(iter = window; iter->parent; iter = iter->parent); + for(iter = window; iter->parent && iter->parent; iter = iter->parent); *ret = iter; }
@@ -128,6 +115,18 @@ static void detach_inner_window(HTMLInnerWindow *window) HTMLOuterWindow *outer_window = window->base.outer_window; HTMLDocumentNode *doc = window->doc;
+ while(!list_empty(&window->children)) { + HTMLOuterWindow *child = LIST_ENTRY(list_tail(&window->children), HTMLOuterWindow, sibling_entry); + + list_remove(&child->sibling_entry); + child->parent = NULL; + + if(child->base.inner_window) + detach_inner_window(child->base.inner_window); + + IHTMLWindow2_Release(&child->base.IHTMLWindow2_iface); + } + if(outer_window && outer_window->doc_obj && outer_window == outer_window->doc_obj->basedoc.window) window->doc->basedoc.cp_container.forward_container = NULL;
@@ -228,7 +227,6 @@ static void release_outer_window(HTMLOuterWindow *This) set_current_uri(This, NULL); if(This->base.inner_window) detach_inner_window(This->base.inner_window); - release_children(This);
if(This->secmgr) IInternetSecurityManager_Release(This->secmgr); @@ -3515,6 +3513,7 @@ static HRESULT create_inner_window(HTMLOuterWindow *outer_window, IMoniker *mon, if(!window) return E_OUTOFMEMORY;
+ list_init(&window->children); list_init(&window->script_hosts); list_init(&window->bindings); list_init(&window->script_queue); @@ -3565,7 +3564,6 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, 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); @@ -3586,7 +3584,7 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
window->parent = parent; - list_add_tail(&parent->children, &window->sibling_entry); + list_add_tail(&parent->base.inner_window->children, &window->sibling_entry); }
TRACE("%p inner_window %p\n", window, window->base.inner_window); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index cef745e..03a3f3d 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -501,7 +501,6 @@ struct HTMLOuterWindow {
IInternetSecurityManager *secmgr;
- struct list children; struct list sibling_entry; struct wine_rb_entry entry; }; @@ -512,6 +511,7 @@ struct HTMLInnerWindow {
HTMLDocumentNode *doc;
+ struct list children; struct list script_hosts;
IHTMLEventObj *event;