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

Unified Diff: Source/web/WebFrame.cpp

Issue 348833005: [DO NOT COMMIT] Random hacks to unblock work on replication. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More random hacks, including also dcheng's https://codereview.chromium.org/346403002 Created 6 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/ChromeClientImpl.cpp ('k') | Source/web/WebLocalFrameImpl.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 01e08be5bacdd953808188c5e25fbc3baf235c2e..f86da7d2dde61fae82188a974c84e443dea57c7b 100644
--- a/Source/web/WebFrame.cpp
+++ b/Source/web/WebFrame.cpp
@@ -6,6 +6,7 @@
#include "public/web/WebFrame.h"
#include "core/frame/RemoteFrame.h"
+#include "core/html/HTMLFrameOwnerElement.h"
#include "web/OpenedFrameTracker.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebRemoteFrameImpl.h"
@@ -28,6 +29,12 @@ void WebFrame::swap(WebFrame* frame)
{
using std::swap;
+ // All child frames must have been detached first.
+ ASSERT(!m_firstChild && !m_lastChild);
+ // The frame being swapped in should not have a WebCore::Frame associated
+ // with it yet.
+ ASSERT(!toWebCoreFrame(frame));
+
if (m_parent) {
if (m_parent->m_firstChild == this)
m_parent->m_firstChild = frame;
@@ -35,6 +42,7 @@ void WebFrame::swap(WebFrame* frame)
m_parent->m_lastChild = frame;
swap(m_parent, frame->m_parent);
}
+
if (m_previousSibling) {
m_previousSibling->m_nextSibling = frame;
swap(m_previousSibling, frame->m_previousSibling);
@@ -43,6 +51,7 @@ void WebFrame::swap(WebFrame* frame)
m_nextSibling->m_previousSibling = frame;
swap(m_nextSibling, frame->m_nextSibling);
}
+
if (m_opener) {
m_opener->m_openedFrameTracker->remove(this);
m_opener->m_openedFrameTracker->add(frame);
@@ -52,6 +61,19 @@ void WebFrame::swap(WebFrame* frame)
m_openedFrameTracker->updateOpener(frame);
frame->m_openedFrameTracker.reset(m_openedFrameTracker.release());
}
+
+ // Finally, clone the state of the current WebCore::Frame into one matching
+ // the type of the passed in WebFrame.
+ // FIXME: This is a bit clunky; this results in pointless decrements and
+ // increments of connected subframes.
+ WebCore::Frame* oldFrame = toWebCoreFrame(this);
+ WebCore::FrameOwner* owner = oldFrame->owner();
+ oldFrame->disconnectOwnerElement();
+ if (frame->isWebLocalFrame()) {
+ toWebLocalFrameImpl(frame)->initializeWebCoreFrame(oldFrame->host(), owner, oldFrame->tree().name(), nullAtom);
+ } else {
+ toWebRemoteFrameImpl(frame)->initializeWebCoreFrame(oldFrame->host(), owner, oldFrame->tree().name());
+ }
}
WebFrame* WebFrame::opener() const
« no previous file with comments | « Source/web/ChromeClientImpl.cpp ('k') | Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698