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

Side by Side Diff: Source/web/WebFrame.cpp

Issue 271793002: Implement WebFrame::swap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/OpenedFrameTracker.cpp ('k') | public/web/WebFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "public/web/WebFrame.h" 6 #include "public/web/WebFrame.h"
7 7
8 #include "web/OpenedFrameTracker.h" 8 #include "web/OpenedFrameTracker.h"
9 #include <algorithm>
10
9 11
10 namespace blink { 12 namespace blink {
11 13
14 void WebFrame::swap(WebFrame* frame)
15 {
16 using std::swap;
17
18 if (m_parent) {
19 if (m_parent->m_firstChild == this)
eseidel 2014/05/08 00:13:01 I probably would have written a overrideIfSetTo(m_
dcheng 2014/05/08 01:54:18 Yeah I think it may not be worth it at the moment.
20 m_parent->m_firstChild = frame;
21 if (m_parent->m_lastChild == this)
22 m_parent->m_lastChild = frame;
23 swap(m_parent, frame->m_parent);
24 }
25 if (m_previousSibling) {
26 m_previousSibling->m_nextSibling = frame;
27 swap(m_previousSibling, frame->m_previousSibling);
28 }
29 if (m_nextSibling) {
30 m_nextSibling->m_previousSibling = frame;
31 swap(m_nextSibling, frame->m_nextSibling);
32 }
33 if (m_opener) {
34 m_opener->m_openedFrameTracker->remove(this);
35 m_opener->m_openedFrameTracker->add(frame);
36 swap(m_opener, frame->m_opener);
37 }
38 if (!m_openedFrameTracker->isEmpty()) {
39 m_openedFrameTracker->updateOpener(frame);
40 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release());
41 }
42 }
43
12 WebFrame* WebFrame::opener() const 44 WebFrame* WebFrame::opener() const
13 { 45 {
14 return m_opener; 46 return m_opener;
15 } 47 }
16 48
17 void WebFrame::setOpener(WebFrame* opener) 49 void WebFrame::setOpener(WebFrame* opener)
18 { 50 {
19 if (m_opener) 51 if (m_opener)
20 m_opener->m_openedFrameTracker->remove(this); 52 m_opener->m_openedFrameTracker->remove(this);
21 if (opener) 53 if (opener)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 , m_openedFrameTracker(new OpenedFrameTracker) 131 , m_openedFrameTracker(new OpenedFrameTracker)
100 { 132 {
101 } 133 }
102 134
103 WebFrame::~WebFrame() 135 WebFrame::~WebFrame()
104 { 136 {
105 m_openedFrameTracker.reset(0); 137 m_openedFrameTracker.reset(0);
106 } 138 }
107 139
108 } // namespace blink 140 } // namespace blink
OLDNEW
« 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