mshtml: Moved detaching inner window to separated function.

This commit is contained in:
Jacek Caban 2012-07-11 13:51:39 +02:00 committed by Alexandre Julliard
parent 8bb4a6b3ea
commit 2c1fe7f0c8
1 changed files with 24 additions and 26 deletions

View File

@ -43,8 +43,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
static struct list window_list = LIST_INIT(window_list);
static HRESULT window_set_docnode(HTMLOuterWindow*,HTMLDocumentNode*);
static inline BOOL is_outer_window(HTMLWindow *window)
{
return &window->outer_window->base == window;
@ -107,6 +105,25 @@ static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIAN
return get_event_handler(&window->inner_window->doc->body_event_target, eid, var);
}
static void detach_inner_window(HTMLOuterWindow *outer_window)
{
HTMLInnerWindow *window = outer_window->base.inner_window;
if(!window)
return;
if(outer_window->doc_obj && outer_window == outer_window->doc_obj->basedoc.window)
window->doc->basedoc.cp_container.forward_container = NULL;
detach_events(window->doc);
abort_window_bindings(window);
release_script_hosts(window);
window->doc->basedoc.window = NULL;
window->base.outer_window = NULL;
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
}
static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
{
return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow2_iface);
@ -183,7 +200,7 @@ static void release_outer_window(HTMLOuterWindow *This)
remove_target_tasks(This->task_magic);
set_window_bscallback(This, NULL);
set_current_mon(This, NULL);
window_set_docnode(This, NULL);
detach_inner_window(This);
release_children(This);
if(This->secmgr)
@ -2667,32 +2684,13 @@ static HRESULT window_set_docnode(HTMLOuterWindow *window, HTMLDocumentNode *doc
HTMLInnerWindow *inner_window;
HRESULT hres;
if(window->base.inner_window) {
if(window->doc_obj && window == window->doc_obj->basedoc.window)
window->base.inner_window->doc->basedoc.cp_container.forward_container = NULL;
detach_events(window->base.inner_window->doc);
abort_window_bindings(window->base.inner_window);
release_script_hosts(window->base.inner_window);
}
hres = create_inner_window(window, doc_node, &inner_window);
if(FAILED(hres))
return hres;
if(doc_node) {
hres = create_inner_window(window, doc_node, &inner_window);
if(FAILED(hres))
return hres;
}else {
inner_window = NULL;
}
if(window->base.inner_window) {
window->base.inner_window->doc->basedoc.window = NULL;
window->base.inner_window->base.outer_window = NULL;
IHTMLWindow2_Release(&window->base.inner_window->base.IHTMLWindow2_iface);
}
detach_inner_window(window);
window->base.inner_window = inner_window;
if(!doc_node)
return S_OK;
if(window->doc_obj && window->doc_obj->basedoc.window == window) {
if(window->doc_obj->basedoc.doc_node)
htmldoc_release(&window->doc_obj->basedoc.doc_node->basedoc);