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 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 return frame->isWebLocalFrame() | 23 return frame->isWebLocalFrame() |
24 ? static_cast<Frame*>(toWebLocalFrameImpl(frame)->frame()) | 24 ? static_cast<Frame*>(toWebLocalFrameImpl(frame)->frame()) |
25 : toWebRemoteFrameImpl(frame)->frame(); | 25 : toWebRemoteFrameImpl(frame)->frame(); |
26 } | 26 } |
27 | 27 |
28 void WebFrame::swap(WebFrame* frame) | 28 void WebFrame::swap(WebFrame* frame) |
29 { | 29 { |
30 using std::swap; | 30 using std::swap; |
31 | 31 |
32 // All child frames must have been detached first. | 32 Frame* oldFrame = toCoreFrame(this); |
33 ASSERT(!m_firstChild && !m_lastChild); | 33 |
34 // All child frames must be detached first. | |
35 oldFrame->detachChildren(); | |
kenrb
2014/09/04 19:04:50
I haven't spent time thinking about the right sequ
dcheng
2014/09/04 19:18:11
Ken makes some good points. This reminds me of why
nasko
2014/09/04 23:46:28
I've implemented an idea based on our discussion.
| |
36 | |
34 // The frame being swapped in should not have a Frame associated | 37 // The frame being swapped in should not have a Frame associated |
35 // with it yet. | 38 // with it yet. |
36 ASSERT(!toCoreFrame(frame)); | 39 ASSERT(!toCoreFrame(frame)); |
37 | 40 |
38 if (m_parent) { | 41 if (m_parent) { |
39 if (m_parent->m_firstChild == this) | 42 if (m_parent->m_firstChild == this) |
40 m_parent->m_firstChild = frame; | 43 m_parent->m_firstChild = frame; |
41 if (m_parent->m_lastChild == this) | 44 if (m_parent->m_lastChild == this) |
42 m_parent->m_lastChild = frame; | 45 m_parent->m_lastChild = frame; |
43 swap(m_parent, frame->m_parent); | 46 swap(m_parent, frame->m_parent); |
(...skipping 15 matching lines...) Expand all Loading... | |
59 } | 62 } |
60 if (!m_openedFrameTracker->isEmpty()) { | 63 if (!m_openedFrameTracker->isEmpty()) { |
61 m_openedFrameTracker->updateOpener(frame); | 64 m_openedFrameTracker->updateOpener(frame); |
62 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); | 65 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); |
63 } | 66 } |
64 | 67 |
65 // Finally, clone the state of the current Frame into one matching | 68 // Finally, clone the state of the current Frame into one matching |
66 // the type of the passed in WebFrame. | 69 // the type of the passed in WebFrame. |
67 // FIXME: This is a bit clunky; this results in pointless decrements and | 70 // FIXME: This is a bit clunky; this results in pointless decrements and |
68 // increments of connected subframes. | 71 // increments of connected subframes. |
69 Frame* oldFrame = toCoreFrame(this); | |
70 FrameOwner* owner = oldFrame->owner(); | 72 FrameOwner* owner = oldFrame->owner(); |
71 oldFrame->disconnectOwnerElement(); | 73 oldFrame->disconnectOwnerElement(); |
72 if (frame->isWebLocalFrame()) { | 74 if (frame->isWebLocalFrame()) { |
73 toWebLocalFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner, oldFrame->tree().name(), nullAtom); | 75 toWebLocalFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner, oldFrame->tree().name(), nullAtom); |
74 } else { | 76 } else { |
75 toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner , oldFrame->tree().name()); | 77 toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner , oldFrame->tree().name()); |
76 } | 78 } |
77 } | 79 } |
78 | 80 |
79 v8::Handle<v8::Value> WebFrame::executeScriptAndReturnValueForTests(const WebScr iptSource& source) | 81 v8::Handle<v8::Value> WebFrame::executeScriptAndReturnValueForTests(const WebScr iptSource& source) |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 , m_openedFrameTracker(new OpenedFrameTracker) | 216 , m_openedFrameTracker(new OpenedFrameTracker) |
215 { | 217 { |
216 } | 218 } |
217 | 219 |
218 WebFrame::~WebFrame() | 220 WebFrame::~WebFrame() |
219 { | 221 { |
220 m_openedFrameTracker.reset(0); | 222 m_openedFrameTracker.reset(0); |
221 } | 223 } |
222 | 224 |
223 } // namespace blink | 225 } // namespace blink |
OLD | NEW |