Commit 747b7b56 authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

content: Only drop fallback if sized changed while hidden

Instead of dropping fallback every time a tab goes hidden, only drop
fallback if size changes when the tab was hidden.

Bug: 822442
Change-Id: Ib1ac403f9c76cbb406ca5f85d47f6b789ca9b055
Reviewed-on: https://chromium-review.googlesource.com/965016Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Commit-Queue: Saman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543830}
parent 1710f5ad
......@@ -267,10 +267,18 @@ void DelegatedFrameHost::WasResized(
if (enable_surface_synchronization_) {
if (!client_->DelegatedFrameHostIsVisible()) {
if (HasFallbackSurface()) {
// If the tab is resized while hidden, reset the fallback so that the next
// time user switches back to it the page is blank. This is preferred to
// showing contents of old size. Don't call EvictDelegatedFrame to avoid
// races when dragging tabs across displays. See https://crbug.com/813157.
if (pending_surface_dip_size_ != current_frame_size_in_dip_ &&
HasFallbackSurface()) {
client_->DelegatedFrameHostGetLayer()->SetFallbackSurfaceId(
viz::SurfaceId());
}
// Don't update the SurfaceLayer when invisible to avoid blocking on
// renderers that do not submit CompositorFrames. Next time the renderer
// is visible, WasResized will be called again. See WasShown.
return;
}
......
......@@ -405,6 +405,10 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
DeviceScaleFactorChanges);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
HideThenShow);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
DropFallbackIfResizedWhileHidden);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
DontDropFallbackIfNotResizedWhileHidden);
FRIEND_TEST_ALL_PREFIXES(SitePerProcessHitTestBrowserTest, PopupMenuTest);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
NewContentRenderingTimeout);
......
......@@ -6003,6 +6003,43 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
EXPECT_NE(id1, id2);
}
// If a tab was resized while it's hidden, drop the fallback so next time it's
// visible we show blank.
TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
DropFallbackIfResizedWhileHidden) {
view_->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
gfx::Rect());
view_->Show();
viz::LocalSurfaceId id1 = view_->GetLocalSurfaceId();
view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo(
viz::SurfaceId(view_->GetFrameSinkId(), id1), 1, gfx::Size(20, 20)));
EXPECT_TRUE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid());
view_->Hide();
view_->SetSize(gfx::Size(54, 32));
view_->Show();
EXPECT_FALSE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid());
}
// If a tab is hidden and shown without being resized in the meantime, the
// fallback SurfaceId has to be preserved.
TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
DontDropFallbackIfNotResizedWhileHidden) {
view_->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
gfx::Rect());
view_->Show();
viz::LocalSurfaceId id1 = view_->GetLocalSurfaceId();
view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo(
viz::SurfaceId(view_->GetFrameSinkId(), id1), 1, gfx::Size(20, 20)));
EXPECT_TRUE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid());
view_->Hide();
view_->Show();
EXPECT_TRUE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid());
}
// This class provides functionality to test a RenderWidgetHostViewAura
// instance which has been hooked up to a test RenderViewHost instance and
// a WebContents instance.
......
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