Chromium Code Reviews| 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 "public/web/WebFrame.h" | 5 #include "public/web/WebFrame.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 7 #include "bindings/core/v8/WindowProxyManager.h" | 8 #include "bindings/core/v8/WindowProxyManager.h" |
| 8 #include "core/HTMLNames.h" | 9 #include "core/HTMLNames.h" |
| 10 #include "core/dom/IncrementLoadEventDelayCount.h" | |
| 9 #include "core/frame/FrameView.h" | 11 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
| 11 #include "core/frame/RemoteFrame.h" | 13 #include "core/frame/RemoteFrame.h" |
| 12 #include "core/html/HTMLFrameElementBase.h" | 14 #include "core/html/HTMLFrameElementBase.h" |
| 13 #include "core/html/HTMLFrameOwnerElement.h" | 15 #include "core/html/HTMLFrameOwnerElement.h" |
| 14 #include "core/page/Page.h" | 16 #include "core/page/Page.h" |
| 15 #include "platform/UserGestureIndicator.h" | 17 #include "platform/UserGestureIndicator.h" |
| 16 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
| 17 #include "platform/instrumentation/tracing/TraceEvent.h" | 19 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 18 #include "public/web/WebElement.h" | 20 #include "public/web/WebElement.h" |
| 19 #include "public/web/WebFrameOwnerProperties.h" | 21 #include "public/web/WebFrameOwnerProperties.h" |
| 20 #include "public/web/WebSandboxFlags.h" | 22 #include "public/web/WebSandboxFlags.h" |
| 21 #include "web/OpenedFrameTracker.h" | 23 #include "web/OpenedFrameTracker.h" |
| 22 #include "web/RemoteFrameOwner.h" | 24 #include "web/RemoteFrameOwner.h" |
| 23 #include "web/WebLocalFrameImpl.h" | 25 #include "web/WebLocalFrameImpl.h" |
| 24 #include "web/WebRemoteFrameImpl.h" | 26 #include "web/WebRemoteFrameImpl.h" |
| 25 #include <algorithm> | |
| 26 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 | 29 |
| 29 bool WebFrame::Swap(WebFrame* frame) { | 30 bool WebFrame::Swap(WebFrame* frame) { |
| 30 using std::swap; | 31 using std::swap; |
| 31 Frame* old_frame = ToImplBase()->GetFrame(); | 32 Frame* old_frame = ToImplBase()->GetFrame(); |
| 32 if (!old_frame->IsAttached()) | 33 if (!old_frame->IsAttached()) |
| 33 return false; | 34 return false; |
| 34 | 35 |
| 35 // Unload the current Document in this frame: this calls unload handlers, | 36 // Unload the current Document in this frame: this calls unload handlers, |
| 36 // detaches child frames, etc. Since this runs script, make sure this frame | 37 // detaches child frames, etc. Since this runs script, make sure this frame |
| 37 // wasn't detached before continuing with the swap. | 38 // wasn't detached before continuing with the swap. |
| 38 // 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 |
| 39 // written. | 40 // written. |
| 40 if (!old_frame->PrepareForCommit()) | 41 if (!old_frame->PrepareForCommit()) |
| 41 return false; | 42 return false; |
| 42 | 43 |
| 44 // If there is a local parent, it might incorrectly declare itself complete | |
| 45 // during the detach phase of this swap. Suppress its completion until swap is | |
| 46 // over, at which point its completion will be correctly dependent on its | |
| 47 // newly swapped-in child. | |
| 48 std::unique_ptr<IncrementLoadEventDelayCount> delay_parent_load = | |
|
lfg
2017/04/27 17:08:25
This looks good, but do you mind explaining why th
| |
| 49 parent_ && parent_->IsWebLocalFrame() | |
| 50 ? IncrementLoadEventDelayCount::Create( | |
| 51 *ToWebLocalFrameImpl(parent_)->GetFrame()->GetDocument()) | |
| 52 : nullptr; | |
| 53 | |
| 43 if (parent_) { | 54 if (parent_) { |
| 44 if (parent_->first_child_ == this) | 55 if (parent_->first_child_ == this) |
| 45 parent_->first_child_ = frame; | 56 parent_->first_child_ = frame; |
| 46 if (parent_->last_child_ == this) | 57 if (parent_->last_child_ == this) |
| 47 parent_->last_child_ = frame; | 58 parent_->last_child_ = frame; |
| 48 // FIXME: This is due to the fact that the |frame| may be a provisional | 59 // FIXME: This is due to the fact that the |frame| may be a provisional |
| 49 // local frame, because we don't know if the navigation will result in | 60 // local frame, because we don't know if the navigation will result in |
| 50 // an actual page or something else, like a download. The PlzNavigate | 61 // an actual page or something else, like a download. The PlzNavigate |
| 51 // project will remove the need for provisional local frames. | 62 // project will remove the need for provisional local frames. |
| 52 frame->parent_ = parent_; | 63 frame->parent_ = parent_; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 for (WebFrame* child = frame->FirstChild(); child; | 331 for (WebFrame* child = frame->FirstChild(); child; |
| 321 child = child->NextSibling()) | 332 child = child->NextSibling()) |
| 322 TraceFrame(visitor, child); | 333 TraceFrame(visitor, child); |
| 323 } | 334 } |
| 324 | 335 |
| 325 void WebFrame::Close() { | 336 void WebFrame::Close() { |
| 326 opened_frame_tracker_->Dispose(); | 337 opened_frame_tracker_->Dispose(); |
| 327 } | 338 } |
| 328 | 339 |
| 329 } // namespace blink | 340 } // namespace blink |
| OLD | NEW |