summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorYash Malik <ymalik@google.com>2016-01-26 16:44:15 -0500
committerYash Malik <ymalik@google.com>2016-01-26 21:47:19 +0000
commit6cde6b8b133fb6cabe6bce83e90d69a770b2ae04 (patch)
treec00fe8c48487fc5f1402150dd5ab281eb2cdb3b3 /cc
parent03e16dd6b47e2b632c46c2be74fcd7d6f385c4f3 (diff)
downloadchromium_src-6cde6b8b133fb6cabe6bce83e90d69a770b2ae04.zip
chromium_src-6cde6b8b133fb6cabe6bce83e90d69a770b2ae04.tar.gz
chromium_src-6cde6b8b133fb6cabe6bce83e90d69a770b2ae04.tar.bz2
Stop non-user scrollable layers from scrolling on the compositor
BUG=579207 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1623663002 Cr-Commit-Position: refs/heads/master@{#371250} (cherry picked from commit 399b4764c4020e5a0c2e4da0f457971447f6b286) Review URL: https://codereview.chromium.org/1633253002 . Cr-Commit-Position: refs/branch-heads/2623@{#146} Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
Diffstat (limited to 'cc')
-rw-r--r--cc/trees/layer_tree_host_impl.cc16
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc82
2 files changed, 94 insertions, 4 deletions
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 057228f..96c1d68 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2632,7 +2632,12 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
const gfx::Point& viewport_point,
const gfx::Vector2dF& scroll_delta) {
if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) {
- return ScrollAnimationUpdateTarget(layer_impl, scroll_delta)
+ gfx::Vector2dF delta = scroll_delta;
+ if (!layer_impl->user_scrollable(ScrollbarOrientation::HORIZONTAL))
+ delta.set_x(0);
+ if (!layer_impl->user_scrollable(ScrollbarOrientation::VERTICAL))
+ delta.set_y(0);
+ return ScrollAnimationUpdateTarget(layer_impl, delta)
? SCROLL_STARTED
: SCROLL_IGNORED;
}
@@ -2659,6 +2664,15 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
target_offset.SetToMin(layer_impl->MaxScrollOffset());
gfx::Vector2dF actual_delta = target_offset.DeltaFrom(current_offset);
+ if (!layer_impl->user_scrollable(ScrollbarOrientation::HORIZONTAL)) {
+ actual_delta.set_x(0);
+ target_offset.set_x(current_offset.x());
+ }
+ if (!layer_impl->user_scrollable(ScrollbarOrientation::VERTICAL)) {
+ actual_delta.set_y(0);
+ target_offset.set_y(current_offset.y());
+ }
+
const float kEpsilon = 0.1f;
bool can_layer_scroll = (std::abs(actual_delta.x()) > kEpsilon ||
std::abs(actual_delta.y()) > kEpsilon);
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 814279e..e3e1f53 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -9143,7 +9143,10 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
// Test that a smooth scroll offset animation is aborted when followed by a
// non-smooth scroll offset animation.
TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
- SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
DrawFrame();
base::TimeTicks start_time =
@@ -9208,7 +9211,10 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
// Evolved from LayerTreeHostImplTest.ScrollAnimated.
TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
- SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
DrawFrame();
base::TimeTicks start_time =
@@ -9221,7 +9227,6 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
-
begin_frame_args.frame_time = start_time;
host_impl_->WillBeginImplFrame(begin_frame_args);
host_impl_->Animate();
@@ -9267,6 +9272,77 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
host_impl_->DidFinishImplFrame();
}
+// Test that smooth scroll offset animation doesn't happen for non user
+// scrollable layers.
+TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) {
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true);
+ host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false);
+
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
+ EXPECT_EQ(
+ InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)));
+
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(50);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ // Should not have scrolled horizontally.
+ EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x());
+ float y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 1 && y < 49);
+
+ // Update target.
+ EXPECT_EQ(
+ InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)));
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(200);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 50 && y < 100);
+ EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(250);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
+ scrolling_layer->CurrentScrollOffset());
+ EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
+}
+
TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) {
host_impl_->CreatePendingTree();