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