diff options
Diffstat (limited to 'Source/WebCore/bindings/js/ScriptController.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/ScriptController.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/Source/WebCore/bindings/js/ScriptController.cpp b/Source/WebCore/bindings/js/ScriptController.cpp index 1bd6efcac..93bbd3cc4 100644 --- a/Source/WebCore/bindings/js/ScriptController.cpp +++ b/Source/WebCore/bindings/js/ScriptController.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006-2008, 2016 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -197,7 +197,7 @@ void ScriptController::getAllWorlds(Vector<Ref<DOMWrapperWorld>>& worlds) static_cast<JSVMClientData*>(JSDOMWindow::commonVM().clientData)->getAllWorlds(worlds); } -void ScriptController::clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoPageCache) +void ScriptController::clearWindowShellsNotMatchingDOMWindow(DOMWindow* newDOMWindow, bool goingIntoPageCache) { if (m_windowShells.isEmpty()) return; @@ -205,16 +205,13 @@ void ScriptController::clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoP JSLockHolder lock(JSDOMWindowBase::commonVM()); Vector<JSC::Strong<JSDOMWindowShell>> windowShells = this->windowShells(); - for (size_t i = 0; i < windowShells.size(); ++i) { - JSDOMWindowShell* windowShell = windowShells[i].get(); - + for (auto& windowShell : windowShells) { if (&windowShell->window()->wrapped() == newDOMWindow) continue; // Clear the debugger and console from the current window before setting the new window. - attachDebugger(windowShell, nullptr); + attachDebugger(windowShell.get(), nullptr); windowShell->window()->setConsoleClient(nullptr); - // FIXME: We should clear console profiles for each frame as soon as the frame is destroyed. // Instead of clearing all of them when the main frame is destroyed. if (m_frame.isMainFrame()) { @@ -223,24 +220,39 @@ void ScriptController::clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoP } windowShell->window()->willRemoveFromWindowShell(); - windowShell->setWindow(newDOMWindow); + } + + // It's likely that resetting our windows created a lot of garbage, unless + // it went in a back/forward cache. + if (!goingIntoPageCache) + collectGarbageAfterWindowShellDestruction(); +} +void ScriptController::setDOMWindowForWindowShell(DOMWindow* newDOMWindow) +{ + if (m_windowShells.isEmpty()) + return; + + JSLockHolder lock(JSDOMWindowBase::commonVM()); + + Vector<JSC::Strong<JSDOMWindowShell>> windowShells = this->windowShells(); + for (auto& windowShell : windowShells) { + if (&windowShell->window()->wrapped() == newDOMWindow) + continue; + + windowShell->setWindow(newDOMWindow); + // An m_cacheableBindingRootObject persists between page navigations // so needs to know about the new JSDOMWindow. if (m_cacheableBindingRootObject) m_cacheableBindingRootObject->updateGlobalObject(windowShell->window()); - + if (Page* page = m_frame.page()) { - attachDebugger(windowShell, page->debugger()); + attachDebugger(windowShell.get(), page->debugger()); windowShell->window()->setProfileGroup(page->group().identifier()); windowShell->window()->setConsoleClient(&page->console()); } } - - // It's likely that resetting our windows created a lot of garbage, unless - // it went in a back/forward cache. - if (!goingIntoPageCache) - collectGarbageAfterWindowShellDestruction(); } JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld& world) |