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

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

Issue 1187483004: Simplify WindowProxy handoff in WebFrame::swap(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Moo 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/Frame.cpp ('k') | no next file » | 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 26 matching lines...) Expand all
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) 42 #if !ENABLE(OILPAN)
43 RefPtrWillBeRawPtr<WebLocalFrameImpl> protectWebLocalFrame = isWebLocalFrame () ? toWebLocalFrameImpl(this) : nullptr; 43 RefPtrWillBeRawPtr<WebLocalFrameImpl> protectWebLocalFrame = isWebLocalFrame () ? toWebLocalFrameImpl(this) : nullptr;
44 RefPtrWillBeRawPtr<WebRemoteFrameImpl> protectWebRemoteFrame = isWebRemoteFr ame() ? toWebRemoteFrameImpl(this) : nullptr; 44 RefPtrWillBeRawPtr<WebRemoteFrameImpl> protectWebRemoteFrame = isWebRemoteFr ame() ? toWebRemoteFrameImpl(this) : nullptr;
45 #endif 45 #endif
46 46
47 // If the frame has been detached during detaching by any JS code, we should 47 // Unload the current Document in this frame: this calls unload handlers,
48 // cancel the swap. 48 // detaches child frames, etc. Since this runs script, make sure this frame
49 // wasn't detached before continuing with the swap.
49 // FIXME: There is no unit test for this condition, so one needs to be 50 // FIXME: There is no unit test for this condition, so one needs to be
50 // written. 51 // written.
51 if (!oldFrame->prepareForCommit()) 52 if (!oldFrame->prepareForCommit())
52 return false; 53 return false;
53 54
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) { 55 if (m_parent) {
64 if (m_parent->m_firstChild == this) 56 if (m_parent->m_firstChild == this)
65 m_parent->m_firstChild = frame; 57 m_parent->m_firstChild = frame;
66 if (m_parent->m_lastChild == this) 58 if (m_parent->m_lastChild == this)
67 m_parent->m_lastChild = frame; 59 m_parent->m_lastChild = frame;
68 // FIXME: This is due to the fact that the |frame| may be a provisional 60 // 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 61 // 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 62 // an actual page or something else, like a download. The PlzNavigate
71 // project will remove the need for provisional local frames. 63 // project will remove the need for provisional local frames.
72 frame->m_parent = m_parent; 64 frame->m_parent = m_parent;
73 m_parent = nullptr;
74 } 65 }
75 66
76 if (m_previousSibling) { 67 if (m_previousSibling) {
77 m_previousSibling->m_nextSibling = frame; 68 m_previousSibling->m_nextSibling = frame;
78 swap(m_previousSibling, frame->m_previousSibling); 69 swap(m_previousSibling, frame->m_previousSibling);
79 } 70 }
80 if (m_nextSibling) { 71 if (m_nextSibling) {
81 m_nextSibling->m_previousSibling = frame; 72 m_nextSibling->m_previousSibling = frame;
82 swap(m_nextSibling, frame->m_nextSibling); 73 swap(m_nextSibling, frame->m_nextSibling);
83 } 74 }
84 75
85 if (m_opener) { 76 if (m_opener) {
86 m_opener->m_openedFrameTracker->remove(this); 77 m_opener->m_openedFrameTracker->remove(this);
87 m_opener->m_openedFrameTracker->add(frame); 78 m_opener->m_openedFrameTracker->add(frame);
88 swap(m_opener, frame->m_opener); 79 swap(m_opener, frame->m_opener);
89 } 80 }
90 if (!m_openedFrameTracker->isEmpty()) { 81 if (!m_openedFrameTracker->isEmpty()) {
91 m_openedFrameTracker->updateOpener(frame); 82 m_openedFrameTracker->updateOpener(frame);
92 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); 83 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release());
93 } 84 }
94 85
95 // Finally, clone the state of the current Frame into one matching 86 // Finally, clone the state of the current Frame into one matching
96 // the type of the passed in WebFrame. 87 // the type of the passed in WebFrame.
97 // FIXME: This is a bit clunky; this results in pointless decrements and 88 // FIXME: This is a bit clunky; this results in pointless decrements and
98 // increments of connected subframes. 89 // increments of connected subframes.
90 FrameOwner* owner = oldFrame->owner();
91 oldFrame->disconnectOwnerElement();
99 if (frame->isWebLocalFrame()) { 92 if (frame->isWebLocalFrame()) {
100 LocalFrame& localFrame = *toWebLocalFrameImpl(frame)->frame(); 93 LocalFrame& localFrame = *toWebLocalFrameImpl(frame)->frame();
101 ASSERT(owner == localFrame.owner()); 94 ASSERT(owner == localFrame.owner());
102 if (owner) { 95 if (owner) {
103 if (owner->isLocal()) { 96 if (owner->isLocal()) {
104 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(ow ner); 97 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(ow ner);
105 ownerElement->setContentFrame(localFrame); 98 ownerElement->setContentFrame(localFrame);
106 ownerElement->setWidget(localFrame.view()); 99 ownerElement->setWidget(localFrame.view());
107 } else { 100 } else {
108 toRemoteBridgeFrameOwner(owner)->setContentFrame(toWebLocalFrame Impl(frame)); 101 toRemoteBridgeFrameOwner(owner)->setContentFrame(toWebLocalFrame Impl(frame));
109 } 102 }
110 } else { 103 } else {
111 localFrame.page()->setMainFrame(&localFrame); 104 localFrame.page()->setMainFrame(&localFrame);
112 } 105 }
113 } else { 106 } else {
114 toWebRemoteFrameImpl(frame)->initializeCoreFrame(host, owner, oldFrame-> tree().name()); 107 toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner , oldFrame->tree().name());
115 } 108 }
116 toCoreFrame(frame)->finishSwapFrom(oldFrame.get()); 109 toCoreFrame(frame)->finishSwapFrom(oldFrame.get());
117 110
111 // Although the Document in this frame is now unloaded, many resources
112 // associated with the frame itself have not yet been freed yet.
113 oldFrame->detach(FrameDetachType::Swap);
114 m_parent = nullptr;
115
118 return true; 116 return true;
119 } 117 }
120 118
121 void WebFrame::detach() 119 void WebFrame::detach()
122 { 120 {
123 toCoreFrame(this)->detach(FrameDetachType::Remove); 121 toCoreFrame(this)->detach(FrameDetachType::Remove);
124 } 122 }
125 123
126 WebSecurityOrigin WebFrame::securityOrigin() const 124 WebSecurityOrigin WebFrame::securityOrigin() const
127 { 125 {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 void WebFrame::traceFrames(VisitorDispatcher visitor, WebFrame* frame) { tra ceFramesImpl(visitor, frame); } \ 349 void WebFrame::traceFrames(VisitorDispatcher visitor, WebFrame* frame) { tra ceFramesImpl(visitor, frame); } \
352 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI mpl(visitor); } 350 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI mpl(visitor); }
353 351
354 DEFINE_VISITOR_METHOD(Visitor*) 352 DEFINE_VISITOR_METHOD(Visitor*)
355 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) 353 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor)
356 354
357 #undef DEFINE_VISITOR_METHOD 355 #undef DEFINE_VISITOR_METHOD
358 #endif 356 #endif
359 357
360 } // namespace blink 358 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/Frame.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698