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

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

Issue 643333002: Prepare for remote->local frame swap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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/core/frame/Frame.h ('k') | Source/web/WebLocalFrameImpl.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 "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/RemoteFrame.h" 9 #include "core/frame/RemoteFrame.h"
10 #include "core/html/HTMLFrameOwnerElement.h" 10 #include "core/html/HTMLFrameOwnerElement.h"
(...skipping 24 matching lines...) Expand all
35 // All child frames must be detached first. 35 // All child frames must be detached first.
36 oldFrame->detachChildren(); 36 oldFrame->detachChildren();
37 37
38 // If the frame has been detached during detaching its children, return 38 // If the frame has been detached during detaching its children, return
39 // immediately. 39 // immediately.
40 // FIXME: There is no unit test for this condition, so one needs to be 40 // FIXME: There is no unit test for this condition, so one needs to be
41 // written. 41 // written.
42 if (!oldFrame->host()) 42 if (!oldFrame->host())
43 return false; 43 return false;
44 44
45 // The frame being swapped in should not have a Frame associated
46 // with it yet.
47 ASSERT(!toCoreFrame(frame));
48
49 if (m_parent) { 45 if (m_parent) {
50 if (m_parent->m_firstChild == this) 46 if (m_parent->m_firstChild == this)
51 m_parent->m_firstChild = frame; 47 m_parent->m_firstChild = frame;
52 if (m_parent->m_lastChild == this) 48 if (m_parent->m_lastChild == this)
53 m_parent->m_lastChild = frame; 49 m_parent->m_lastChild = frame;
54 swap(m_parent, frame->m_parent); 50 swap(m_parent, frame->m_parent);
55 } 51 }
56 52
57 if (m_previousSibling) { 53 if (m_previousSibling) {
58 m_previousSibling->m_nextSibling = frame; 54 m_previousSibling->m_nextSibling = frame;
(...skipping 13 matching lines...) Expand all
72 m_openedFrameTracker->updateOpener(frame); 68 m_openedFrameTracker->updateOpener(frame);
73 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); 69 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release());
74 } 70 }
75 71
76 // Finally, clone the state of the current Frame into one matching 72 // Finally, clone the state of the current Frame into one matching
77 // the type of the passed in WebFrame. 73 // the type of the passed in WebFrame.
78 // FIXME: This is a bit clunky; this results in pointless decrements and 74 // FIXME: This is a bit clunky; this results in pointless decrements and
79 // increments of connected subframes. 75 // increments of connected subframes.
80 FrameOwner* owner = oldFrame->owner(); 76 FrameOwner* owner = oldFrame->owner();
81 oldFrame->disconnectOwnerElement(); 77 oldFrame->disconnectOwnerElement();
82 if (frame->isWebLocalFrame()) { 78 if (toCoreFrame(frame)) {
79 ASSERT(owner == toCoreFrame(frame)->owner());
80 if (owner->isLocal())
81 toHTMLFrameOwnerElement(owner)->setContentFrame(*toCoreFrame(frame)) ;
82 } else if (frame->isWebLocalFrame()) {
83 toWebLocalFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner, oldFrame->tree().name(), nullAtom); 83 toWebLocalFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner, oldFrame->tree().name(), nullAtom);
84 } else { 84 } else {
85 toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner , oldFrame->tree().name()); 85 toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner , oldFrame->tree().name());
86 } 86 }
87 87
88 return true; 88 return true;
89 } 89 }
90 90
91 void WebFrame::detach() 91 void WebFrame::detach()
92 { 92 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 m_lastChild = child->m_previousSibling; 139 m_lastChild = child->m_previousSibling;
140 else 140 else
141 child->m_nextSibling->m_previousSibling = child->m_previousSibling; 141 child->m_nextSibling->m_previousSibling = child->m_previousSibling;
142 142
143 child->m_previousSibling = child->m_nextSibling = 0; 143 child->m_previousSibling = child->m_nextSibling = 0;
144 144
145 toCoreFrame(this)->tree().invalidateScopedChildCount(); 145 toCoreFrame(this)->tree().invalidateScopedChildCount();
146 toCoreFrame(this)->host()->decrementSubframeCount(); 146 toCoreFrame(this)->host()->decrementSubframeCount();
147 } 147 }
148 148
149 void WebFrame::setParent(WebFrame* parent)
150 {
151 m_parent = parent;
152 }
153
149 WebFrame* WebFrame::parent() const 154 WebFrame* WebFrame::parent() const
150 { 155 {
151 return m_parent; 156 return m_parent;
152 } 157 }
153 158
154 WebFrame* WebFrame::top() const 159 WebFrame* WebFrame::top() const
155 { 160 {
156 WebFrame* frame = const_cast<WebFrame*>(this); 161 WebFrame* frame = const_cast<WebFrame*>(this);
157 for (WebFrame* parent = frame; parent; parent = parent->m_parent) 162 for (WebFrame* parent = frame; parent; parent = parent->m_parent)
158 frame = parent; 163 frame = parent;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 268 }
264 269
265 void WebFrame::clearWeakFrames(Visitor* visitor) 270 void WebFrame::clearWeakFrames(Visitor* visitor)
266 { 271 {
267 if (!isFrameAlive(visitor, m_opener)) 272 if (!isFrameAlive(visitor, m_opener))
268 m_opener = nullptr; 273 m_opener = nullptr;
269 } 274 }
270 #endif 275 #endif
271 276
272 } // namespace blink 277 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/Frame.h ('k') | Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698