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

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

Issue 2873213003: Move WebFrame to use WebLocalFrameBase instead of WebLocalFrameImpl. (Closed)
Patch Set: rebase Created 3 years, 7 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
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 "public/web/WebFrame.h" 5 #include "public/web/WebFrame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "bindings/core/v8/WindowProxyManager.h" 8 #include "bindings/core/v8/WindowProxyManager.h"
9 #include "core/HTMLNames.h" 9 #include "core/HTMLNames.h"
10 #include "core/dom/IncrementLoadEventDelayCount.h" 10 #include "core/dom/IncrementLoadEventDelayCount.h"
11 #include "core/frame/FrameView.h" 11 #include "core/frame/FrameView.h"
12 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
13 #include "core/frame/RemoteFrame.h" 13 #include "core/frame/RemoteFrame.h"
14 #include "core/frame/WebLocalFrameBase.h"
14 #include "core/html/HTMLFrameElementBase.h" 15 #include "core/html/HTMLFrameElementBase.h"
15 #include "core/html/HTMLFrameOwnerElement.h" 16 #include "core/html/HTMLFrameOwnerElement.h"
16 #include "core/page/Page.h" 17 #include "core/page/Page.h"
17 #include "platform/UserGestureIndicator.h" 18 #include "platform/UserGestureIndicator.h"
18 #include "platform/heap/Handle.h" 19 #include "platform/heap/Handle.h"
19 #include "platform/instrumentation/tracing/TraceEvent.h" 20 #include "platform/instrumentation/tracing/TraceEvent.h"
20 #include "public/web/WebElement.h" 21 #include "public/web/WebElement.h"
21 #include "public/web/WebFrameOwnerProperties.h" 22 #include "public/web/WebFrameOwnerProperties.h"
22 #include "public/web/WebSandboxFlags.h" 23 #include "public/web/WebSandboxFlags.h"
23 #include "web/OpenedFrameTracker.h" 24 #include "web/OpenedFrameTracker.h"
24 #include "web/RemoteFrameOwner.h" 25 #include "web/RemoteFrameOwner.h"
25 #include "web/WebLocalFrameImpl.h"
26 #include "web/WebRemoteFrameImpl.h" 26 #include "web/WebRemoteFrameImpl.h"
27 27
28 namespace blink { 28 namespace blink {
29 29
30 bool WebFrame::Swap(WebFrame* frame) { 30 bool WebFrame::Swap(WebFrame* frame) {
31 using std::swap; 31 using std::swap;
32 Frame* old_frame = ToCoreFrame(*this); 32 Frame* old_frame = ToCoreFrame(*this);
33 if (!old_frame->IsAttached()) 33 if (!old_frame->IsAttached())
34 return false; 34 return false;
35 35
36 // Unload the current Document in this frame: this calls unload handlers, 36 // Unload the current Document in this frame: this calls unload handlers,
37 // 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
38 // wasn't detached before continuing with the swap. 38 // wasn't detached before continuing with the swap.
39 // 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
40 // written. 40 // written.
41 if (!old_frame->PrepareForCommit()) 41 if (!old_frame->PrepareForCommit())
42 return false; 42 return false;
43 43
44 // If there is a local parent, it might incorrectly declare itself complete 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 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 46 // over, at which point its completion will be correctly dependent on its
47 // newly swapped-in child. 47 // newly swapped-in child.
48 std::unique_ptr<IncrementLoadEventDelayCount> delay_parent_load = 48 std::unique_ptr<IncrementLoadEventDelayCount> delay_parent_load =
49 parent_ && parent_->IsWebLocalFrame() 49 parent_ && parent_->IsWebLocalFrame()
50 ? IncrementLoadEventDelayCount::Create( 50 ? IncrementLoadEventDelayCount::Create(
51 *ToWebLocalFrameImpl(parent_)->GetFrame()->GetDocument()) 51 *ToWebLocalFrameBase(parent_)->GetFrame()->GetDocument())
52 : nullptr; 52 : nullptr;
53 53
54 if (parent_) { 54 if (parent_) {
55 if (parent_->first_child_ == this) 55 if (parent_->first_child_ == this)
56 parent_->first_child_ = frame; 56 parent_->first_child_ = frame;
57 if (parent_->last_child_ == this) 57 if (parent_->last_child_ == this)
58 parent_->last_child_ = frame; 58 parent_->last_child_ = frame;
59 // 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
60 // 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
61 // an actual page or something else, like a download. The PlzNavigate 61 // an actual page or something else, like a download. The PlzNavigate
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Clone the state of the current Frame into the one being swapped in. 94 // Clone the state of the current Frame into the one being swapped in.
95 // FIXME: This is a bit clunky; this results in pointless decrements and 95 // FIXME: This is a bit clunky; this results in pointless decrements and
96 // increments of connected subframes. 96 // increments of connected subframes.
97 if (frame->IsWebLocalFrame()) { 97 if (frame->IsWebLocalFrame()) {
98 // TODO(dcheng): in an ideal world, both branches would just use 98 // TODO(dcheng): in an ideal world, both branches would just use
99 // WebFrame's initializeCoreFrame() helper. However, Blink 99 // WebFrame's initializeCoreFrame() helper. However, Blink
100 // currently requires a 'provisional' local frame to serve as a 100 // currently requires a 'provisional' local frame to serve as a
101 // placeholder for loading state when swapping to a local frame. 101 // placeholder for loading state when swapping to a local frame.
102 // In this case, the core LocalFrame is already initialized, so just 102 // In this case, the core LocalFrame is already initialized, so just
103 // update a bit of state. 103 // update a bit of state.
104 LocalFrame& local_frame = *ToWebLocalFrameImpl(frame)->GetFrame(); 104 LocalFrame& local_frame = *ToWebLocalFrameBase(frame)->GetFrame();
105 DCHECK_EQ(owner, local_frame.Owner()); 105 DCHECK_EQ(owner, local_frame.Owner());
106 if (owner) { 106 if (owner) {
107 owner->SetContentFrame(local_frame); 107 owner->SetContentFrame(local_frame);
108 if (owner->IsLocal()) 108 if (owner->IsLocal())
109 ToHTMLFrameOwnerElement(owner)->SetWidget(local_frame.View()); 109 ToHTMLFrameOwnerElement(owner)->SetWidget(local_frame.View());
110 } else { 110 } else {
111 local_frame.GetPage()->SetMainFrame(&local_frame); 111 local_frame.GetPage()->SetMainFrame(&local_frame);
112 // This trace event is needed to detect the main frame of the 112 // This trace event is needed to detect the main frame of the
113 // renderer in telemetry metrics. See crbug.com/692112#c11. 113 // renderer in telemetry metrics. See crbug.com/692112#c11.
114 TRACE_EVENT_INSTANT1("loading", "markAsMainFrame", 114 TRACE_EVENT_INSTANT1("loading", "markAsMainFrame",
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (Frame* frame = ToCoreFrame(*this)) 285 if (Frame* frame = ToCoreFrame(*this))
286 return frame->IsLoading(); 286 return frame->IsLoading();
287 return false; 287 return false;
288 } 288 }
289 289
290 WebFrame* WebFrame::FromFrame(Frame* frame) { 290 WebFrame* WebFrame::FromFrame(Frame* frame) {
291 if (!frame) 291 if (!frame)
292 return 0; 292 return 0;
293 293
294 if (frame->IsLocalFrame()) 294 if (frame->IsLocalFrame())
295 return WebLocalFrameImpl::FromFrame(ToLocalFrame(*frame)); 295 return WebLocalFrameBase::FromFrame(ToLocalFrame(*frame));
296 return WebRemoteFrameImpl::FromFrame(ToRemoteFrame(*frame)); 296 return WebRemoteFrameImpl::FromFrame(ToRemoteFrame(*frame));
297 } 297 }
298 298
299 WebFrame::WebFrame(WebTreeScopeType scope) 299 WebFrame::WebFrame(WebTreeScopeType scope)
300 : scope_(scope), 300 : scope_(scope),
301 parent_(0), 301 parent_(0),
302 previous_sibling_(0), 302 previous_sibling_(0),
303 next_sibling_(0), 303 next_sibling_(0),
304 first_child_(0), 304 first_child_(0),
305 last_child_(0), 305 last_child_(0),
306 opener_(0), 306 opener_(0),
307 opened_frame_tracker_(new OpenedFrameTracker) {} 307 opened_frame_tracker_(new OpenedFrameTracker) {}
308 308
309 WebFrame::~WebFrame() { 309 WebFrame::~WebFrame() {
310 opened_frame_tracker_.reset(0); 310 opened_frame_tracker_.reset(0);
311 } 311 }
312 312
313 void WebFrame::TraceFrame(Visitor* visitor, WebFrame* frame) { 313 void WebFrame::TraceFrame(Visitor* visitor, WebFrame* frame) {
314 if (!frame) 314 if (!frame)
315 return; 315 return;
316 316
317 if (frame->IsWebLocalFrame()) 317 if (frame->IsWebLocalFrame())
318 visitor->Trace(ToWebLocalFrameImpl(frame)); 318 visitor->Trace(ToWebLocalFrameBase(frame));
319 else 319 else
320 visitor->Trace(ToWebRemoteFrameImpl(frame)); 320 visitor->Trace(ToWebRemoteFrameImpl(frame));
321 } 321 }
322 322
323 void WebFrame::TraceFrames(Visitor* visitor, WebFrame* frame) { 323 void WebFrame::TraceFrames(Visitor* visitor, WebFrame* frame) {
324 DCHECK(frame); 324 DCHECK(frame);
325 TraceFrame(visitor, frame->parent_); 325 TraceFrame(visitor, frame->parent_);
326 for (WebFrame* child = frame->FirstChild(); child; 326 for (WebFrame* child = frame->FirstChild(); child;
327 child = child->NextSibling()) 327 child = child->NextSibling())
328 TraceFrame(visitor, child); 328 TraceFrame(visitor, child);
329 } 329 }
330 330
331 void WebFrame::Close() { 331 void WebFrame::Close() {
332 opened_frame_tracker_->Dispose(); 332 opened_frame_tracker_->Dispose();
333 } 333 }
334 334
335 void WebFrame::InitializeCoreFrame(WebFrame& frame, Page& page) { 335 void WebFrame::InitializeCoreFrame(WebFrame& frame, Page& page) {
336 if (frame.IsWebLocalFrame()) 336 if (frame.IsWebLocalFrame())
337 ToWebLocalFrameImpl(frame).InitializeCoreFrame(page, 0, g_null_atom); 337 ToWebLocalFrameBase(frame).InitializeCoreFrame(page, 0, g_null_atom);
338 else if (frame.IsWebRemoteFrame()) 338 else if (frame.IsWebRemoteFrame())
339 ToWebRemoteFrameImpl(frame).InitializeCoreFrame(page, 0, g_null_atom); 339 ToWebRemoteFrameImpl(frame).InitializeCoreFrame(page, 0, g_null_atom);
340 else 340 else
341 NOTREACHED(); 341 NOTREACHED();
342 } 342 }
343 343
344 Frame* WebFrame::ToCoreFrame(const WebFrame& frame) { 344 Frame* WebFrame::ToCoreFrame(const WebFrame& frame) {
345 if (frame.IsWebLocalFrame()) 345 if (frame.IsWebLocalFrame())
346 return ToWebLocalFrameImpl(frame).GetFrame(); 346 return ToWebLocalFrameBase(frame).GetFrame();
347 if (frame.IsWebRemoteFrame()) 347 if (frame.IsWebRemoteFrame())
348 return ToWebRemoteFrameImpl(frame).GetFrame(); 348 return ToWebRemoteFrameImpl(frame).GetFrame();
349 NOTREACHED(); 349 NOTREACHED();
350 return nullptr; 350 return nullptr;
351 } 351 }
352 352
353 } // namespace blink 353 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/WebLocalFrameBase.h ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698