| 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 "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 Loading... |
| 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 |
| 42 | 46 |
| 43 // All child frames must be detached first. | 47 // If the frame has been detached during detaching by any JS code, we should |
| 44 oldFrame->detachChildren(); | 48 // cancel the swap. |
| 45 | |
| 46 // If the frame has been detached during detaching its children, return | |
| 47 // immediately. | |
| 48 // FIXME: There is no unit test for this condition, so one needs to be | 49 // FIXME: There is no unit test for this condition, so one needs to be |
| 49 // written. | 50 // written. |
| 50 if (!oldFrame->host()) | 51 if (!oldFrame->prepareForCommit()) |
| 51 return false; | 52 return false; |
| 52 | 53 |
| 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 |
| 53 if (m_parent) { | 63 if (m_parent) { |
| 54 if (m_parent->m_firstChild == this) | 64 if (m_parent->m_firstChild == this) |
| 55 m_parent->m_firstChild = frame; | 65 m_parent->m_firstChild = frame; |
| 56 if (m_parent->m_lastChild == this) | 66 if (m_parent->m_lastChild == this) |
| 57 m_parent->m_lastChild = frame; | 67 m_parent->m_lastChild = frame; |
| 58 // FIXME: This is due to the fact that the |frame| may be a provisional | 68 // FIXME: This is due to the fact that the |frame| may be a provisional |
| 59 // local frame, because we don't know if the navigation will result in | 69 // local frame, because we don't know if the navigation will result in |
| 60 // an actual page or something else, like a download. The PlzNavigate | 70 // an actual page or something else, like a download. The PlzNavigate |
| 61 // project will remove the need for provisional local frames. | 71 // project will remove the need for provisional local frames. |
| 62 frame->m_parent = m_parent; | 72 frame->m_parent = m_parent; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 79 } | 89 } |
| 80 if (!m_openedFrameTracker->isEmpty()) { | 90 if (!m_openedFrameTracker->isEmpty()) { |
| 81 m_openedFrameTracker->updateOpener(frame); | 91 m_openedFrameTracker->updateOpener(frame); |
| 82 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); | 92 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); |
| 83 } | 93 } |
| 84 | 94 |
| 85 // Finally, clone the state of the current Frame into one matching | 95 // Finally, clone the state of the current Frame into one matching |
| 86 // the type of the passed in WebFrame. | 96 // the type of the passed in WebFrame. |
| 87 // FIXME: This is a bit clunky; this results in pointless decrements and | 97 // FIXME: This is a bit clunky; this results in pointless decrements and |
| 88 // increments of connected subframes. | 98 // increments of connected subframes. |
| 89 FrameOwner* owner = oldFrame->owner(); | |
| 90 oldFrame->disconnectOwnerElement(); | |
| 91 if (frame->isWebLocalFrame()) { | 99 if (frame->isWebLocalFrame()) { |
| 92 LocalFrame& localFrame = *toWebLocalFrameImpl(frame)->frame(); | 100 LocalFrame& localFrame = *toWebLocalFrameImpl(frame)->frame(); |
| 93 ASSERT(owner == localFrame.owner()); | 101 ASSERT(owner == localFrame.owner()); |
| 94 if (owner) { | 102 if (owner) { |
| 95 if (owner->isLocal()) { | 103 if (owner->isLocal()) { |
| 96 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(ow
ner); | 104 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(ow
ner); |
| 97 ownerElement->setContentFrame(localFrame); | 105 ownerElement->setContentFrame(localFrame); |
| 98 ownerElement->setWidget(localFrame.view()); | 106 ownerElement->setWidget(localFrame.view()); |
| 99 } else { | 107 } else { |
| 100 toRemoteBridgeFrameOwner(owner)->setContentFrame(toWebLocalFrame
Impl(frame)); | 108 toRemoteBridgeFrameOwner(owner)->setContentFrame(toWebLocalFrame
Impl(frame)); |
| 101 } | 109 } |
| 102 } else { | 110 } else { |
| 103 localFrame.page()->setMainFrame(&localFrame); | 111 localFrame.page()->setMainFrame(&localFrame); |
| 104 } | 112 } |
| 105 } else { | 113 } else { |
| 106 toWebRemoteFrameImpl(frame)->initializeCoreFrame(oldFrame->host(), owner
, oldFrame->tree().name()); | 114 toWebRemoteFrameImpl(frame)->initializeCoreFrame(host, owner, oldFrame->
tree().name()); |
| 107 } | 115 } |
| 108 toCoreFrame(frame)->finishSwapFrom(oldFrame.get()); | 116 toCoreFrame(frame)->finishSwapFrom(oldFrame.get()); |
| 109 | 117 |
| 110 return true; | 118 return true; |
| 111 } | 119 } |
| 112 | 120 |
| 113 void WebFrame::detach() | 121 void WebFrame::detach() |
| 114 { | 122 { |
| 115 toCoreFrame(this)->detach(); | 123 toCoreFrame(this)->detach(FrameDetachType::Remove); |
| 116 } | 124 } |
| 117 | 125 |
| 118 WebSecurityOrigin WebFrame::securityOrigin() const | 126 WebSecurityOrigin WebFrame::securityOrigin() const |
| 119 { | 127 { |
| 120 return WebSecurityOrigin(toCoreFrame(this)->securityContext()->securityOrigi
n()); | 128 return WebSecurityOrigin(toCoreFrame(this)->securityContext()->securityOrigi
n()); |
| 121 } | 129 } |
| 122 | 130 |
| 123 | 131 |
| 124 void WebFrame::setFrameOwnerSandboxFlags(WebSandboxFlags flags) | 132 void WebFrame::setFrameOwnerSandboxFlags(WebSandboxFlags flags) |
| 125 { | 133 { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 void WebFrame::traceFrames(VisitorDispatcher visitor, WebFrame* frame) { tra
ceFramesImpl(visitor, frame); } \ | 351 void WebFrame::traceFrames(VisitorDispatcher visitor, WebFrame* frame) { tra
ceFramesImpl(visitor, frame); } \ |
| 344 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI
mpl(visitor); } | 352 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI
mpl(visitor); } |
| 345 | 353 |
| 346 DEFINE_VISITOR_METHOD(Visitor*) | 354 DEFINE_VISITOR_METHOD(Visitor*) |
| 347 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) | 355 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) |
| 348 | 356 |
| 349 #undef DEFINE_VISITOR_METHOD | 357 #undef DEFINE_VISITOR_METHOD |
| 350 #endif | 358 #endif |
| 351 | 359 |
| 352 } // namespace blink | 360 } // namespace blink |
| OLD | NEW |