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

Unified Diff: Source/web/WebFrame.cpp

Issue 1041473002: Detach old frame on WebFrame::swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/web/RemoteFrameClientImpl.cpp ('k') | Source/web/tests/FrameTestHelpers.h » ('j') | 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 b7504104a33a316fa96046dccffa5a74da7d4b35..8bea271892dbd369fdb1b4bc8e2cf73815ff9ce1 100644
--- a/Source/web/WebFrame.cpp
+++ b/Source/web/WebFrame.cpp
@@ -39,17 +39,27 @@ bool WebFrame::swap(WebFrame* frame)
{
using std::swap;
RefPtrWillBeRawPtr<Frame> oldFrame = toCoreFrame(this);
+#if !ENABLE(OILPAN)
+ RefPtrWillBeRawPtr<WebLocalFrameImpl> protectWebLocalFrame = isWebLocalFrame() ? toWebLocalFrameImpl(this) : nullptr;
+ RefPtrWillBeRawPtr<WebRemoteFrameImpl> protectWebRemoteFrame = isWebRemoteFrame() ? toWebRemoteFrameImpl(this) : nullptr;
+#endif
- // All child frames must be detached first.
- oldFrame->detachChildren();
-
- // If the frame has been detached during detaching its children, return
- // immediately.
+ // If the frame has been detached during detaching by any JS code, we should
+ // cancel the swap.
// FIXME: There is no unit test for this condition, so one needs to be
// written.
- if (!oldFrame->host())
+ 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;
@@ -86,8 +96,6 @@ 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());
@@ -103,7 +111,7 @@ bool WebFrame::swap(WebFrame* frame)
localFrame.page()->setMainFrame(&localFrame);
}
} else {
- toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner, oldFrame->tree().name());
+ toWebRemoteFrameImpl(frame)->initializeCoreFrame(host, owner, oldFrame->tree().name());
}
toCoreFrame(frame)->finishSwapFrom(oldFrame.get());
@@ -112,7 +120,7 @@ bool WebFrame::swap(WebFrame* frame)
void WebFrame::detach()
{
- toCoreFrame(this)->detach();
+ toCoreFrame(this)->detach(FrameDetachType::Remove);
}
WebSecurityOrigin WebFrame::securityOrigin() const
« no previous file with comments | « Source/web/RemoteFrameClientImpl.cpp ('k') | Source/web/tests/FrameTestHelpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698