diff options
author | bokan <bokan@chromium.org> | 2015-08-12 15:25:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-12 22:26:16 +0000 |
commit | 32f1b905215018af4860fe4ef64977a6dd4dc911 (patch) | |
tree | c9e56392b282c7e75624f1b20c0c906b78681099 | |
parent | 362032da2cc497fcbfe18373a867ff2494e5da87 (diff) | |
download | chromium_src-32f1b905215018af4860fe4ef64977a6dd4dc911.zip chromium_src-32f1b905215018af4860fe4ef64977a6dd4dc911.tar.gz chromium_src-32f1b905215018af4860fe4ef64977a6dd4dc911.tar.bz2 |
Use regular bubbling scroll for scrolling during pinch gesture.
Scrolls occuring during a pinch gesture, that is, moving the center of pinch
during the gesture, are treated as regular scrolls that bubble from one viewport
layer to the next.
Note, scrolls during a pinch made in order to keep the pinch point centered
remain unchanged: under the --invert-viewport-scroll-order flag, these scrolls
will "pan" the viewport, scrolling *only* the inner viewport.
BUG=433724
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1288773002
Cr-Commit-Position: refs/heads/master@{#343112}
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 7 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 32 |
2 files changed, 28 insertions, 11 deletions
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 0d44c41..1ebc60f 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -2696,13 +2696,6 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( if (!CurrentlyScrollingLayer()) return InputHandlerScrollResult(); - if (pinch_gesture_active_ && settings().invert_viewport_scroll_order) { - // Scrolls during a pinch gesture should pan the visual viewport, rather - // than a typical bubbling scroll. - viewport()->Pan(scroll_delta); - return InputHandlerScrollResult(); - } - float initial_top_controls_offset = top_controls_manager_->ControlsTopOffset(); ScrollState scroll_state( diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index b8dbc1e..55b2607 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -1193,7 +1193,10 @@ TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { outer_scroll_layer->CurrentScrollOffset()); } -TEST_F(LayerTreeHostImplTest, ScrollDuringPinchScrollsInnerViewport) { +// 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. +TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { LayerTreeSettings settings = DefaultSettings(); settings.invert_viewport_scroll_order = true; CreateHostImpl(settings, @@ -1213,17 +1216,38 @@ TEST_F(LayerTreeHostImplTest, ScrollDuringPinchScrollsInnerViewport) { host_impl_->ScrollBegin(gfx::Point(250, 250), InputHandler::GESTURE); host_impl_->PinchGestureBegin(); + host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); - host_impl_->ScrollBy(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)); - host_impl_->PinchGestureEnd(); - host_impl_->ScrollEnd(); + EXPECT_VECTOR_EQ( + gfx::Vector2dF(0, 0), + outer_scroll_layer->CurrentScrollOffset()); + EXPECT_VECTOR_EQ( + gfx::Vector2dF(125, 125), + inner_scroll_layer->CurrentScrollOffset()); + // Needed so that the pinch is accounted for in draw properties. + DrawFrame(); + + host_impl_->ScrollBy(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)); EXPECT_VECTOR_EQ( gfx::Vector2dF(0, 0), outer_scroll_layer->CurrentScrollOffset()); EXPECT_VECTOR_EQ( gfx::Vector2dF(130, 130), inner_scroll_layer->CurrentScrollOffset()); + + DrawFrame(); + + host_impl_->ScrollBy(gfx::Point(250, 250), gfx::Vector2dF(400.f, 400.f)); + EXPECT_VECTOR_EQ( + gfx::Vector2dF(80, 80), + outer_scroll_layer->CurrentScrollOffset()); + EXPECT_VECTOR_EQ( + gfx::Vector2dF(250, 250), + inner_scroll_layer->CurrentScrollOffset()); + + host_impl_->PinchGestureEnd(); + host_impl_->ScrollEnd(); } // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when |