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

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

Issue 1177333002: Revert of Detach old frame on WebFrame::swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « Source/web/RemoteFrameClientImpl.cpp ('k') | Source/web/tests/FrameTestHelpers.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 "bindings/core/v8/WindowProxyManager.h" 8 #include "bindings/core/v8/WindowProxyManager.h"
9 #include "core/frame/FrameHost.h" 9 #include "core/frame/FrameHost.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
(...skipping 21 matching lines...) Expand all
32 32
33 return frame->isWebLocalFrame() 33 return frame->isWebLocalFrame()
34 ? static_cast<Frame*>(toWebLocalFrameImpl(frame)->frame()) 34 ? static_cast<Frame*>(toWebLocalFrameImpl(frame)->frame())
35 : toWebRemoteFrameImpl(frame)->frame(); 35 : toWebRemoteFrameImpl(frame)->frame();
36 } 36 }
37 37
38 bool WebFrame::swap(WebFrame* frame) 38 bool WebFrame::swap(WebFrame* frame)
39 { 39 {
40 using std::swap; 40 using std::swap;
41 RefPtrWillBeRawPtr<Frame> oldFrame = toCoreFrame(this); 41 RefPtrWillBeRawPtr<Frame> oldFrame = toCoreFrame(this);
42 #if !ENABLE(OILPAN)
43 RefPtrWillBeRawPtr<WebLocalFrameImpl> protectWebLocalFrame = isWebLocalFrame () ? toWebLocalFrameImpl(this) : nullptr;
44 RefPtrWillBeRawPtr<WebRemoteFrameImpl> protectWebRemoteFrame = isWebRemoteFr ame() ? toWebRemoteFrameImpl(this) : nullptr;
45 #endif
46 42
47 // If the frame has been detached during detaching by any JS code, we should 43 // All child frames must be detached first.
48 // cancel the swap. 44 oldFrame->detachChildren();
45
46 // If the frame has been detached during detaching its children, return
47 // immediately.
49 // FIXME: There is no unit test for this condition, so one needs to be 48 // FIXME: There is no unit test for this condition, so one needs to be
50 // written. 49 // written.
51 if (!oldFrame->prepareForCommit()) 50 if (!oldFrame->host())
52 return false; 51 return false;
53 52
54 FrameOwner* owner = oldFrame->owner();
55 FrameHost* host = oldFrame->host();
56
57 // Frame::detach will call clearForClose(), we need to call
58 // clearForNavigate() before detaching.
59 oldFrame->prepareSwapFrom(oldFrame.get());
60
61 oldFrame->detach(FrameDetachType::Swap);
62
63 if (m_parent) { 53 if (m_parent) {
64 if (m_parent->m_firstChild == this) 54 if (m_parent->m_firstChild == this)
65 m_parent->m_firstChild = frame; 55 m_parent->m_firstChild = frame;
66 if (m_parent->m_lastChild == this) 56 if (m_parent->m_lastChild == this)
67 m_parent->m_lastChild = frame; 57 m_parent->m_lastChild = frame;
68 // FIXME: This is due to the fact that the |frame| may be a provisional 58 // FIXME: This is due to the fact that the |frame| may be a provisional
69 // local frame, because we don't know if the navigation will result in 59 // local frame, because we don't know if the navigation will result in
70 // an actual page or something else, like a download. The PlzNavigate 60 // an actual page or something else, like a download. The PlzNavigate
71 // project will remove the need for provisional local frames. 61 // project will remove the need for provisional local frames.
72 frame->m_parent = m_parent; 62 frame->m_parent = m_parent;
(...skipping 16 matching lines...) Expand all
89 } 79 }
90 if (!m_openedFrameTracker->isEmpty()) { 80 if (!m_openedFrameTracker->isEmpty()) {
91 m_openedFrameTracker->updateOpener(frame); 81 m_openedFrameTracker->updateOpener(frame);
92 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); 82 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release());
93 } 83 }
94 84
95 // Finally, clone the state of the current Frame into one matching 85 // Finally, clone the state of the current Frame into one matching
96 // the type of the passed in WebFrame. 86 // the type of the passed in WebFrame.
97 // FIXME: This is a bit clunky; this results in pointless decrements and 87 // FIXME: This is a bit clunky; this results in pointless decrements and
98 // increments of connected subframes. 88 // increments of connected subframes.
89 FrameOwner* owner = oldFrame->owner();
90 oldFrame->disconnectOwnerElement();
99 if (frame->isWebLocalFrame()) { 91 if (frame->isWebLocalFrame()) {
100 LocalFrame& localFrame = *toWebLocalFrameImpl(frame)->frame(); 92 LocalFrame& localFrame = *toWebLocalFrameImpl(frame)->frame();
101 ASSERT(owner == localFrame.owner()); 93 ASSERT(owner == localFrame.owner());
102 if (owner) { 94 if (owner) {
103 if (owner->isLocal()) { 95 if (owner->isLocal()) {
104 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(ow ner); 96 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(ow ner);
105 ownerElement->setContentFrame(localFrame); 97 ownerElement->setContentFrame(localFrame);
106 ownerElement->setWidget(localFrame.view()); 98 ownerElement->setWidget(localFrame.view());
107 } else { 99 } else {
108 toRemoteBridgeFrameOwner(owner)->setContentFrame(toWebLocalFrame Impl(frame)); 100 toRemoteBridgeFrameOwner(owner)->setContentFrame(toWebLocalFrame Impl(frame));
109 } 101 }
110 } else { 102 } else {
111 localFrame.page()->setMainFrame(&localFrame); 103 localFrame.page()->setMainFrame(&localFrame);
112 } 104 }
113 } else { 105 } else {
114 toWebRemoteFrameImpl(frame)->initializeCoreFrame(host, owner, oldFrame-> tree().name()); 106 toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner , oldFrame->tree().name());
115 } 107 }
116 toCoreFrame(frame)->finishSwapFrom(oldFrame.get()); 108 toCoreFrame(frame)->finishSwapFrom(oldFrame.get());
117 109
118 return true; 110 return true;
119 } 111 }
120 112
121 void WebFrame::detach() 113 void WebFrame::detach()
122 { 114 {
123 toCoreFrame(this)->detach(FrameDetachType::Remove); 115 toCoreFrame(this)->detach();
124 } 116 }
125 117
126 WebSecurityOrigin WebFrame::securityOrigin() const 118 WebSecurityOrigin WebFrame::securityOrigin() const
127 { 119 {
128 return WebSecurityOrigin(toCoreFrame(this)->securityContext()->securityOrigi n()); 120 return WebSecurityOrigin(toCoreFrame(this)->securityContext()->securityOrigi n());
129 } 121 }
130 122
131 123
132 void WebFrame::setFrameOwnerSandboxFlags(WebSandboxFlags flags) 124 void WebFrame::setFrameOwnerSandboxFlags(WebSandboxFlags flags)
133 { 125 {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 void WebFrame::traceFrames(VisitorDispatcher visitor, WebFrame* frame) { tra ceFramesImpl(visitor, frame); } \ 343 void WebFrame::traceFrames(VisitorDispatcher visitor, WebFrame* frame) { tra ceFramesImpl(visitor, frame); } \
352 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI mpl(visitor); } 344 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI mpl(visitor); }
353 345
354 DEFINE_VISITOR_METHOD(Visitor*) 346 DEFINE_VISITOR_METHOD(Visitor*)
355 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) 347 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor)
356 348
357 #undef DEFINE_VISITOR_METHOD 349 #undef DEFINE_VISITOR_METHOD
358 #endif 350 #endif
359 351
360 } // namespace blink 352 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/RemoteFrameClientImpl.cpp ('k') | Source/web/tests/FrameTestHelpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698