Commit a6426e39 authored by David Bokan's avatar David Bokan Committed by Commit Bot

Add test for viewport clipping issue

In https://crrev.com/f9cbcfa426bdf0cb830cd7d1ce7cc80845184d3e I landed
a fix to https://crbug.com/898757. This fix was needed ASAP since it
needed to be merged. I landed a fix without a test at the time. This CL
adds a test.

Bug: 901083,898757
Change-Id: I0b3dc44a7e94e33f5897f7d9f19159523807dc56
Reviewed-on: https://chromium-review.googlesource.com/c/1336786Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608880}
parent a3249b80
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "cc/test/layer_tree_test.h" #include "cc/test/layer_tree_test.h"
#include "cc/test/skia_common.h" #include "cc/test/skia_common.h"
#include "cc/test/test_task_graph_runner.h" #include "cc/test/test_task_graph_runner.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/draw_property_utils.h" #include "cc/trees/draw_property_utils.h"
#include "cc/trees/effect_node.h" #include "cc/trees/effect_node.h"
#include "cc/trees/latency_info_swap_promise.h" #include "cc/trees/latency_info_swap_promise.h"
...@@ -5465,6 +5466,65 @@ TEST_F(LayerTreeHostImplBrowserControlsTest, ...@@ -5465,6 +5466,65 @@ TEST_F(LayerTreeHostImplBrowserControlsTest,
host_impl_->ScrollEnd(EndState().get()); host_impl_->ScrollEnd(EndState().get());
} }
TEST_F(LayerTreeHostImplBrowserControlsTest,
MovingBrowserControlsChangesViewportClip) {
// TODO(bokan): This test is checking pre-blink-gen-property-tree behavior
// and can be removed once that flag ships. See crbug.com/901083.
if (DefaultSettings().use_layer_lists)
return;
SetupBrowserControlsAndScrollLayerWithVirtualViewport(
gfx::Size(50, 50), gfx::Size(25, 25), gfx::Size(100, 100));
LayerTreeImpl* active_tree = host_impl_->active_tree();
// Create a content layer beneath the outer viewport scroll layer.
int id = host_impl_->OuterViewportScrollLayer()->id();
host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild(
LayerImpl::Create(host_impl_->active_tree(), id + 2));
LayerImpl* content =
active_tree->OuterViewportScrollLayer()->test_properties()->children[0];
content->SetBounds(gfx::Size(100, 100));
host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 4.f);
host_impl_->active_tree()->BuildPropertyTreesForTesting();
DrawFrame();
LayerImpl* inner_container = active_tree->InnerViewportContainerLayer();
LayerImpl* outer_container = active_tree->OuterViewportContainerLayer();
LayerImpl* outer_scroll = active_tree->OuterViewportScrollLayer();
auto* property_trees = host_impl_->active_tree()->property_trees();
ClipNode* outer_clip_node =
property_trees->clip_tree.Node(outer_scroll->clip_tree_index());
// The browser controls should start off showing so the viewport should be
// shrunk.
EXPECT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset());
ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds());
ASSERT_EQ(gfx::Size(25, 25), outer_container->bounds());
EXPECT_EQ(gfx::SizeF(100, 100), active_tree->ScrollableSize());
EXPECT_EQ(gfx::SizeF(50, 50), outer_clip_node->clip.size());
EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
host_impl_
->ScrollBegin(BeginState(gfx::Point()).get(),
InputHandler::TOUCHSCREEN)
.thread);
// Hide the browser controls by 10px. The outer clip should expand by 10px as
// well because the clip node doesn't account for the "resize to
// minimum-scale" that occurs for the outer viewport layer (hence, why the
// outer viewport layer is half the size of the inner in this test).
{
host_impl_->ScrollBy(
UpdateState(gfx::Point(0, 0), gfx::Vector2dF(0.f, 10.f)).get());
ASSERT_EQ(40, host_impl_->browser_controls_manager()->ContentTopOffset());
EXPECT_EQ(gfx::SizeF(50, 60), outer_clip_node->clip.size());
}
host_impl_->ScrollEnd(EndState().get());
}
// Tests that browser controls affect the position of horizontal scrollbars. // Tests that browser controls affect the position of horizontal scrollbars.
TEST_F(LayerTreeHostImplBrowserControlsTest, TEST_F(LayerTreeHostImplBrowserControlsTest,
HidingBrowserControlsAdjustsScrollbarPosition) { HidingBrowserControlsAdjustsScrollbarPosition) {
......
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