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

Unified Diff: Source/web/WebFrame.cpp

Issue 271793002: Implement WebFrame::swap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo Created 6 years, 7 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/OpenedFrameTracker.cpp ('k') | public/web/WebFrame.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 acad3e4bc27c6bb7c8218faf64a65c3b84a487d2..accb8a8c187b7bc5aca37dc7d9e457cb7ca6e3cc 100644
--- a/Source/web/WebFrame.cpp
+++ b/Source/web/WebFrame.cpp
@@ -6,9 +6,41 @@
#include "public/web/WebFrame.h"
#include "web/OpenedFrameTracker.h"
+#include <algorithm>
+
namespace blink {
+void WebFrame::swap(WebFrame* frame)
+{
+ using std::swap;
+
+ if (m_parent) {
+ if (m_parent->m_firstChild == this)
+ m_parent->m_firstChild = frame;
+ if (m_parent->m_lastChild == this)
+ 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);
+ }
+ if (m_nextSibling) {
+ 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);
+ swap(m_opener, frame->m_opener);
+ }
+ if (!m_openedFrameTracker->isEmpty()) {
+ m_openedFrameTracker->updateOpener(frame);
+ frame->m_openedFrameTracker.reset(m_openedFrameTracker.release());
+ }
+}
+
WebFrame* WebFrame::opener() const
{
return m_opener;
« no previous file with comments | « Source/web/OpenedFrameTracker.cpp ('k') | public/web/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698