summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbokan <bokan@chromium.org>2015-10-07 14:08:03 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-07 21:08:55 +0000
commit49c85a92156ec9f794f6c57c3f2d2ab2aa981f94 (patch)
tree7bd2e703f3a8962c3c5095c6a6c5b32235c7f414
parentc8f842abb4ef0b30ff792b7bf8b52d36b2cf9fc0 (diff)
downloadchromium_src-49c85a92156ec9f794f6c57c3f2d2ab2aa981f94.zip
chromium_src-49c85a92156ec9f794f6c57c3f2d2ab2aa981f94.tar.gz
chromium_src-49c85a92156ec9f794f6c57c3f2d2ab2aa981f94.tar.bz2
Remove arbitrary fractional rounding in viewport scroll.
This rounding was arbitrary but previous naive attempts to remove it resulted in top control jittering so it was left in. With the viewport scroll order change in r348988, this caused fractional scrolls to be dropped completely. Removing it now though doesn't seem to cause the top control problem. BUG=539334 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1387333003 Cr-Commit-Position: refs/heads/master@{#352945}
-rw-r--r--cc/layers/viewport.cc16
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc48
2 files changed, 53 insertions, 11 deletions
diff --git a/cc/layers/viewport.cc b/cc/layers/viewport.cc
index 80e711f..4b68de5 100644
--- a/cc/layers/viewport.cc
+++ b/cc/layers/viewport.cc
@@ -50,17 +50,11 @@ Viewport::ScrollResult Viewport::ScrollBy(const gfx::Vector2dF& delta,
ScrollResult result;
- // TODO(bokan): This shouldn't be needed but removing it causes subtle
- // viewport movement during top controls manipulation.
- if (gfx::ToRoundedVector2d(pending_content_delta).IsZero()) {
- result.consumed_delta = delta;
- } else {
- pending_content_delta -= host_impl_->ScrollLayer(OuterScrollLayer(),
- pending_content_delta,
- viewport_point,
- is_direct_manipulation);
- result.consumed_delta = delta - AdjustOverscroll(pending_content_delta);
- }
+ pending_content_delta -= host_impl_->ScrollLayer(OuterScrollLayer(),
+ pending_content_delta,
+ viewport_point,
+ is_direct_manipulation);
+ result.consumed_delta = delta - AdjustOverscroll(pending_content_delta);
result.content_scrolled_delta = content_delta - pending_content_delta;
return result;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 0de56bf..8f737ee 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -1311,6 +1311,54 @@ TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) {
outer_scroll_layer->CurrentScrollOffset());
}
+// Make sure scrolls smaller than a unit applied to the viewport don't get
+// dropped. crbug.com/539334.
+TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) {
+ LayerTreeSettings settings = DefaultSettings();
+ CreateHostImpl(settings, CreateOutputSurface());
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f);
+
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
+ LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
+
+ // Sanity checks.
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(500, 500),
+ outer_scroll_layer->MaxScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset());
+
+ RebuildPropertyTrees();
+
+ // Scroll only the layout viewport.
+ host_impl_->ScrollBegin(gfx::Point(250, 250), InputHandler::GESTURE);
+ host_impl_->ScrollBy(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f));
+ EXPECT_VECTOR2DF_EQ(
+ gfx::Vector2dF(0.125f, 0.125f),
+ outer_scroll_layer->CurrentScrollOffset());
+ EXPECT_VECTOR2DF_EQ(
+ gfx::Vector2dF(0, 0),
+ inner_scroll_layer->CurrentScrollOffset());
+ host_impl_->ScrollEnd();
+
+ host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f);
+
+ // Now that we zoomed in, the scroll should be applied to the inner viewport.
+ host_impl_->ScrollBegin(gfx::Point(250, 250), InputHandler::GESTURE);
+ host_impl_->ScrollBy(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f));
+ EXPECT_VECTOR2DF_EQ(
+ gfx::Vector2dF(0.125f, 0.125f),
+ outer_scroll_layer->CurrentScrollOffset());
+ EXPECT_VECTOR2DF_EQ(
+ gfx::Vector2dF(0.25f, 0.25f),
+ inner_scroll_layer->CurrentScrollOffset());
+ host_impl_->ScrollEnd();
+}
+
// Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work
// as expected. That is, scrolling during a pinch should bubble from the inner
// to the outer viewport.