Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1309)

Unified Diff: Source/web/WebFrame.cpp

Issue 1187483004: Simplify WindowProxy handoff in WebFrame::swap(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Moo Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/Frame.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebFrame.cpp
diff --git a/Source/web/WebFrame.cpp b/Source/web/WebFrame.cpp
index 8bea271892dbd369fdb1b4bc8e2cf73815ff9ce1..98042f6431e1ae83107a2ba1ef6af0f1cef8498a 100644
--- a/Source/web/WebFrame.cpp
+++ b/Source/web/WebFrame.cpp
@@ -44,22 +44,14 @@ bool WebFrame::swap(WebFrame* frame)
RefPtrWillBeRawPtr<WebRemoteFrameImpl> protectWebRemoteFrame = isWebRemoteFrame() ? toWebRemoteFrameImpl(this) : nullptr;
#endif
- // If the frame has been detached during detaching by any JS code, we should
- // cancel the swap.
+ // Unload the current Document in this frame: this calls unload handlers,
+ // detaches child frames, etc. Since this runs script, make sure this frame
+ // wasn't detached before continuing with the swap.
// FIXME: There is no unit test for this condition, so one needs to be
// written.
if (!oldFrame->prepareForCommit())
return false;
- FrameOwner* owner = oldFrame->owner();
- FrameHost* host = oldFrame->host();
-
- // Frame::detach will call clearForClose(), we need to call
- // clearForNavigate() before detaching.
- oldFrame->prepareSwapFrom(oldFrame.get());
-
- oldFrame->detach(FrameDetachType::Swap);
-
if (m_parent) {
if (m_parent->m_firstChild == this)
m_parent->m_firstChild = frame;
@@ -70,7 +62,6 @@ bool WebFrame::swap(WebFrame* frame)
// an actual page or something else, like a download. The PlzNavigate
// project will remove the need for provisional local frames.
frame->m_parent = m_parent;
- m_parent = nullptr;
}
if (m_previousSibling) {
@@ -96,6 +87,8 @@ bool WebFrame::swap(WebFrame* frame)
// the type of the passed in WebFrame.
// FIXME: This is a bit clunky; this results in pointless decrements and
// increments of connected subframes.
+ FrameOwner* owner = oldFrame->owner();
+ oldFrame->disconnectOwnerElement();
if (frame->isWebLocalFrame()) {
LocalFrame& localFrame = *toWebLocalFrameImpl(frame)->frame();
ASSERT(owner == localFrame.owner());
@@ -111,10 +104,15 @@ bool WebFrame::swap(WebFrame* frame)
localFrame.page()->setMainFrame(&localFrame);
}
} else {
- toWebRemoteFrameImpl(frame)->initializeCoreFrame(host, owner, oldFrame->tree().name());
+ toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner, oldFrame->tree().name());
}
toCoreFrame(frame)->finishSwapFrom(oldFrame.get());
+ // Although the Document in this frame is now unloaded, many resources
+ // associated with the frame itself have not yet been freed yet.
+ oldFrame->detach(FrameDetachType::Swap);
+ m_parent = nullptr;
+
return true;
}
« no previous file with comments | « Source/core/frame/Frame.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698