Commit 78431b8b authored by Tom McKee's avatar Tom McKee Committed by Commit Bot

[Refactor] Consolidate updates during RenderWidget::DidNavigate

During a load of the main frame, both the RenderWidget and its owned
LayerTreeHost, need to be told that there was a navigation. It used to
be that the RenderFrameImpl would notify the RenderWidget then reach
into the RenderWidget for a reference to the owned LayerTreeHost and
signal it too.

This violates the "tell, don't get" principle; it makes more sense for
the RenderWidget to forward its signal to the LayerTreeHost than to
require calling code to know to update the LayerTreeHost.

This CL changes the RenderWidget to forward the 'DidNavigate' signal to
its LayerTreeHost and simplifies the neighbouring interfaces.

Change-Id: I6050f70a194e7030041d56556ddce5f92c3e2deb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002724Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Tom McKee <tommckee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733368}
parent 059cfc4c
...@@ -1293,10 +1293,6 @@ void LayerTreeHost::SetExternalPageScaleFactor( ...@@ -1293,10 +1293,6 @@ void LayerTreeHost::SetExternalPageScaleFactor(
SetNeedsCommit(); SetNeedsCommit();
} }
void LayerTreeHost::ClearCachesOnNextCommit() {
clear_caches_on_next_commit_ = true;
}
void LayerTreeHost::SetLocalSurfaceIdAllocationFromParent( void LayerTreeHost::SetLocalSurfaceIdAllocationFromParent(
const viz::LocalSurfaceIdAllocation& const viz::LocalSurfaceIdAllocation&
local_surface_id_allocation_from_parent) { local_surface_id_allocation_from_parent) {
...@@ -1797,6 +1793,9 @@ void LayerTreeHost::RequestBeginMainFrameNotExpected(bool new_state) { ...@@ -1797,6 +1793,9 @@ void LayerTreeHost::RequestBeginMainFrameNotExpected(bool new_state) {
} }
void LayerTreeHost::SetSourceURL(ukm::SourceId source_id, const GURL& url) { void LayerTreeHost::SetSourceURL(ukm::SourceId source_id, const GURL& url) {
// Clears image caches and resets the scheduling history for the content
// produced by this host so far.
clear_caches_on_next_commit_ = true;
proxy_->SetSourceURL(source_id, url); proxy_->SetSourceURL(source_id, url);
} }
......
...@@ -424,10 +424,6 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { ...@@ -424,10 +424,6 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
return painted_device_scale_factor_; return painted_device_scale_factor_;
} }
// Clears image caches and resets the scheduling history for the content
// produced by this host so far.
void ClearCachesOnNextCommit();
// If this LayerTreeHost needs a valid viz::LocalSurfaceId then commits will // If this LayerTreeHost needs a valid viz::LocalSurfaceId then commits will
// be deferred until a valid viz::LocalSurfaceId is provided. // be deferred until a valid viz::LocalSurfaceId is provided.
void SetLocalSurfaceIdAllocationFromParent( void SetLocalSurfaceIdAllocationFromParent(
......
...@@ -4428,14 +4428,7 @@ void RenderFrameImpl::DidCommitProvisionalLoad( ...@@ -4428,14 +4428,7 @@ void RenderFrameImpl::DidCommitProvisionalLoad(
// track of that on the widget to help the browser process detect when stale // track of that on the widget to help the browser process detect when stale
// compositor frames are being shown after a commit. // compositor frames are being shown after a commit.
if (is_main_frame_) { if (is_main_frame_) {
GetLocalRootRenderWidget()->DidNavigate(); GetLocalRootRenderWidget()->DidNavigate(
// Update the URL and the document source id used to key UKM metrics in the
// compositor if the navigation is not in the same document, which
// represents a new UKM source.
// Note that this is only done for the main frame since the metrics for all
// frames are keyed to the main frame's URL.
GetLocalRootRenderWidget()->layer_tree_host()->SetSourceURL(
frame_->GetDocument().GetUkmSourceId(), GetLoadingUrl()); frame_->GetDocument().GetUkmSourceId(), GetLoadingUrl());
} }
......
...@@ -3679,7 +3679,7 @@ void RenderWidget::StartDragging(network::mojom::ReferrerPolicy policy, ...@@ -3679,7 +3679,7 @@ void RenderWidget::StartDragging(network::mojom::ReferrerPolicy policy,
image_offset, possible_drag_event_info_)); image_offset, possible_drag_event_info_));
} }
void RenderWidget::DidNavigate() { void RenderWidget::DidNavigate(ukm::SourceId source_id, const GURL& url) {
// The input handler wants to know about navigation so that it can // The input handler wants to know about navigation so that it can
// suppress input until the newly navigated page has a committed frame. // suppress input until the newly navigated page has a committed frame.
// It also resets the state for UMA reporting of input arrival with respect // It also resets the state for UMA reporting of input arrival with respect
...@@ -3687,7 +3687,10 @@ void RenderWidget::DidNavigate() { ...@@ -3687,7 +3687,10 @@ void RenderWidget::DidNavigate() {
DCHECK(widget_input_handler_manager_); DCHECK(widget_input_handler_manager_);
widget_input_handler_manager_->DidNavigate(); widget_input_handler_manager_->DidNavigate();
layer_tree_host_->ClearCachesOnNextCommit(); // Update the URL and the document source id used to key UKM metrics in the
// compositor. Note that the metrics for all frames are keyed to the main
// frame's URL.
layer_tree_host_->SetSourceURL(source_id, url);
} }
blink::WebInputMethodController* RenderWidget::GetInputMethodController() blink::WebInputMethodController* RenderWidget::GetInputMethodController()
......
...@@ -558,7 +558,7 @@ class CONTENT_EXPORT RenderWidget ...@@ -558,7 +558,7 @@ class CONTENT_EXPORT RenderWidget
// Helper to convert |point| using ConvertWindowToViewport(). // Helper to convert |point| using ConvertWindowToViewport().
gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point); gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
gfx::Point ConvertWindowPointToViewport(const gfx::Point& point); gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
void DidNavigate(); void DidNavigate(ukm::SourceId source_id, const GURL& url);
bool auto_resize_mode() const { return auto_resize_mode_; } bool auto_resize_mode() const { return auto_resize_mode_; }
......
...@@ -56,7 +56,7 @@ class RenderWidgetTest : public RenderViewTest { ...@@ -56,7 +56,7 @@ class RenderWidgetTest : public RenderViewTest {
}; };
TEST_F(RenderWidgetTest, OnSynchronizeVisualProperties) { TEST_F(RenderWidgetTest, OnSynchronizeVisualProperties) {
widget()->DidNavigate(); widget()->DidNavigate(ukm::SourceId(42), GURL(""));
// The initial bounds is empty, so setting it to the same thing should do // The initial bounds is empty, so setting it to the same thing should do
// nothing. // nothing.
VisualProperties visual_properties; VisualProperties visual_properties;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment