summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorccameron <ccameron@chromium.org>2014-11-06 19:18:50 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-07 03:19:02 +0000
commit36d091feca1a3621430a61091ff2a527972a8e79 (patch)
tree3286e93b1b78c07b05b8031166fdad02f0c7993e /cc
parenta4a32af218cf03ac89db4a27d12681f8a1ba9108 (diff)
downloadchromium_src-36d091feca1a3621430a61091ff2a527972a8e79.zip
chromium_src-36d091feca1a3621430a61091ff2a527972a8e79.tar.gz
chromium_src-36d091feca1a3621430a61091ff2a527972a8e79.tar.bz2
Return overscroll data from cc::InputHandler::ScrollBy
Whether or not a cc::InputHandler::ScrollBy resulted in some scrolling happening is returned as a bool from the function, but whether or not all of the input scroll delta was used is made available through a callback to the cc::InputHandlerClient::DidOverscroll function. All of this information should be made available in the return value. Make ScrollBy return a struct that contains information about if a scroll happened, if an overscroll happened, and how much of an overscroll happened. The overscroll effect on Mac will require knowledge of exactly what happened with scroll (was there any extra overscroll, etc) at the point where the scroll is attempted. BUG=133097 Review URL: https://codereview.chromium.org/701343002 Cr-Commit-Position: refs/heads/master@{#303172}
Diffstat (limited to 'cc')
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/cc.gyp1
-rw-r--r--cc/input/input_handler.cc13
-rw-r--r--cc/input/input_handler.h36
-rw-r--r--cc/trees/layer_tree_host_impl.cc20
-rw-r--r--cc/trees/layer_tree_host_impl.h5
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc166
-rw-r--r--cc/trees/layer_tree_host_unittest_scroll.cc7
8 files changed, 179 insertions, 70 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 9b417f0..e9ef9e2 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -112,6 +112,7 @@ component("cc") {
"debug/unittest_only_benchmark.h",
"debug/unittest_only_benchmark_impl.cc",
"debug/unittest_only_benchmark_impl.h",
+ "input/input_handler.cc",
"input/input_handler.h",
"input/page_scale_animation.cc",
"input/page_scale_animation.h",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index 308a61d..7ac0122 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -140,6 +140,7 @@
'debug/unittest_only_benchmark.h',
'debug/unittest_only_benchmark_impl.cc',
'debug/unittest_only_benchmark_impl.h',
+ 'input/input_handler.cc',
'input/input_handler.h',
'input/page_scale_animation.cc',
'input/page_scale_animation.h',
diff --git a/cc/input/input_handler.cc b/cc/input/input_handler.cc
new file mode 100644
index 0000000..336d0d4
--- /dev/null
+++ b/cc/input/input_handler.cc
@@ -0,0 +1,13 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/input/input_handler.h"
+
+namespace cc {
+
+InputHandlerScrollResult::InputHandlerScrollResult()
+ : did_scroll(false), did_overscroll_root(false) {
+}
+
+} // namespace cc
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h
index b3205a8..7a9c991 100644
--- a/cc/input/input_handler.h
+++ b/cc/input/input_handler.h
@@ -6,6 +6,7 @@
#define CC_INPUT_INPUT_HANDLER_H_
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "cc/base/cc_export.h"
#include "cc/base/swap_promise_monitor.h"
@@ -24,6 +25,21 @@ namespace cc {
class LayerScrollOffsetDelegate;
+struct CC_EXPORT InputHandlerScrollResult {
+ InputHandlerScrollResult();
+ // Did any layer scroll as a result this ScrollBy call?
+ bool did_scroll;
+ // Was any of the scroll delta argument to this ScrollBy call not used?
+ bool did_overscroll_root;
+ // The total overscroll that has been accumulated by all ScrollBy calls that
+ // have had overscroll since the last ScrollBegin call. This resets upon a
+ // ScrollBy with no overscroll.
+ gfx::Vector2dF accumulated_root_overscroll;
+ // The amount of the scroll delta argument to this ScrollBy call that was not
+ // used for scrolling.
+ gfx::Vector2dF unused_scroll_delta;
+};
+
class CC_EXPORT InputHandlerClient {
public:
virtual ~InputHandlerClient() {}
@@ -32,13 +48,6 @@ class CC_EXPORT InputHandlerClient {
virtual void Animate(base::TimeTicks time) = 0;
virtual void MainThreadHasStoppedFlinging() = 0;
- // Called when scroll deltas reaching the root scrolling layer go unused.
- // The accumulated overscroll is scoped by the most recent call to
- // InputHandler::ScrollBegin.
- virtual void DidOverscroll(const gfx::PointF& causal_event_viewport_point,
- const gfx::Vector2dF& accumulated_overscroll,
- const gfx::Vector2dF& latest_overscroll_delta) = 0;
-
protected:
InputHandlerClient() {}
@@ -85,15 +94,16 @@ class CC_EXPORT InputHandler {
// should be in viewport (logical pixel) coordinates. Otherwise they are in
// scrolling layer's (logical pixel) space. If there is no room to move the
// layer in the requested direction, its first ancestor layer that can be
- // scrolled will be moved instead. If no layer can be moved in the requested
- // direction at all, then false is returned. If any layer is moved, then
- // true is returned.
+ // scrolled will be moved instead. The return value's |did_scroll| field is
+ // set to false if no layer can be moved in the requested direction at all,
+ // and set to true if any layer is moved.
// If the scroll delta hits the root layer, and the layer can no longer move,
// the root overscroll accumulated within this ScrollBegin() scope is reported
- // to the client.
+ // in the return value's |accumulated_overscroll| field.
// Should only be called if ScrollBegin() returned ScrollStarted.
- virtual bool ScrollBy(const gfx::Point& viewport_point,
- const gfx::Vector2dF& scroll_delta) = 0;
+ virtual InputHandlerScrollResult ScrollBy(
+ const gfx::Point& viewport_point,
+ const gfx::Vector2dF& scroll_delta) = 0;
virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point,
ScrollDirection direction) = 0;
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index d2041ac..00be57f 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2638,11 +2638,12 @@ bool LayerTreeHostImpl::ShouldTopControlsConsumeScroll(
return false;
}
-bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
- const gfx::Vector2dF& scroll_delta) {
+InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
+ const gfx::Point& viewport_point,
+ const gfx::Vector2dF& scroll_delta) {
TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy");
if (!CurrentlyScrollingLayer())
- return false;
+ return InputHandlerScrollResult();
gfx::Vector2dF pending_delta = scroll_delta;
gfx::Vector2dF unused_root_delta;
@@ -2763,15 +2764,14 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
accumulated_root_overscroll_.set_x(0);
if (did_scroll_y)
accumulated_root_overscroll_.set_y(0);
-
accumulated_root_overscroll_ += unused_root_delta;
- bool did_overscroll = !unused_root_delta.IsZero();
- if (did_overscroll && input_handler_client_) {
- input_handler_client_->DidOverscroll(
- viewport_point, accumulated_root_overscroll_, unused_root_delta);
- }
- return did_scroll_content || did_scroll_top_controls;
+ InputHandlerScrollResult scroll_result;
+ scroll_result.did_scroll = did_scroll_content || did_scroll_top_controls;
+ scroll_result.did_overscroll_root = !unused_root_delta.IsZero();
+ scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_;
+ scroll_result.unused_scroll_delta = unused_root_delta;
+ return scroll_result;
}
// This implements scrolling by page as described here:
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 157fe00..2309ef7 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -136,8 +136,9 @@ class CC_EXPORT LayerTreeHostImpl
InputHandler::ScrollStatus ScrollAnimated(
const gfx::Point& viewport_point,
const gfx::Vector2dF& scroll_delta) override;
- bool ScrollBy(const gfx::Point& viewport_point,
- const gfx::Vector2dF& scroll_delta) override;
+ InputHandlerScrollResult ScrollBy(
+ const gfx::Point& viewport_point,
+ const gfx::Vector2dF& scroll_delta) override;
bool ScrollVerticallyByPage(const gfx::Point& viewport_point,
ScrollDirection direction) override;
void SetRootLayerScrollOffsetDelegate(
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 9395639..45d636a 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -777,27 +777,40 @@ TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) {
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
// Trying to scroll to the left/top will not succeed.
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)));
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)));
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)));
+ EXPECT_FALSE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll);
+ EXPECT_FALSE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll);
+ EXPECT_FALSE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll);
// Scrolling to the right/bottom will succeed.
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0)));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 10)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0)).did_scroll);
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll);
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 10)).did_scroll);
// Scrolling to left/top will now succeed.
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll);
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll);
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll);
// Scrolling diagonally against an edge will succeed.
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10)));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10)).did_scroll);
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll);
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10)).did_scroll);
// Trying to scroll more than the available space will also succeed.
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000)).did_scroll);
}
TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) {
@@ -3710,6 +3723,7 @@ TEST_F(LayerTreeHostImplTest,
}
TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
+ InputHandlerScrollResult scroll_result;
SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->SetViewportSize(gfx::Size(50, 50));
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
@@ -3719,38 +3733,105 @@ TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
// In-bounds scrolling does not affect overscroll.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
// Overscroll events are reflected immediately.
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
// In-bounds scrolling resets accumulated overscroll for the scrolled axes.
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10));
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10));
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0));
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-15, 0));
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-15, 0));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(-5, 0), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(-5, -10), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 60));
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 60));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(-5, 10), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -60));
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -60));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll());
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
// Overscroll accumulates within the scope of ScrollBegin/ScrollEnd as long
// as no scroll occurs.
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, -30), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
+ EXPECT_FALSE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, -50), host_impl_->accumulated_root_overscroll());
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
// Overscroll resets on valid scroll.
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_FALSE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
+ EXPECT_TRUE(scroll_result.did_scroll);
+ EXPECT_TRUE(scroll_result.did_overscroll_root);
+ EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta);
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll());
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll,
+ host_impl_->accumulated_root_overscroll());
+
host_impl_->ScrollEnd();
}
@@ -6554,7 +6635,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
gfx::Vector2d scroll_delta(0, -2);
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta));
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
// The grand child should have scrolled up to its limit.
scroll_info = host_impl_->ProcessScrollDeltas();
@@ -6564,7 +6645,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
// The child should have received the bubbled delta, but the locked
// scrolling layer should remain set as the grand child.
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta));
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(2u, scroll_info->scrolls.size());
ExpectContains(*scroll_info, grand_child->id(), scroll_delta);
@@ -6574,7 +6655,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
// The first |ScrollBy| after the fling should re-lock the scrolling
// layer to the first layer that scrolled, which is the child.
EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin());
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta));
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child);
// The child should have scrolled up to its limit.
@@ -6584,7 +6665,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
ExpectContains(*scroll_info, child->id(), scroll_delta + scroll_delta);
// As the locked layer is at it's limit, no further scrolling can occur.
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta));
+ EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child);
host_impl_->ScrollEnd();
}
@@ -6982,7 +7063,8 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) {
// Scrolling normally should not trigger any forwarding.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll);
host_impl_->ScrollEnd();
EXPECT_EQ(0, set_needs_commit_count);
@@ -6994,7 +7076,8 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) {
scroll_layer->SetHaveScrollEventHandlers(true);
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll);
host_impl_->ScrollEnd();
EXPECT_EQ(0, set_needs_commit_count);
@@ -7049,7 +7132,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
// Scroll just the top controls and verify that the scroll succeeds.
const float residue = 10;
float offset = top_controls_height_ - residue;
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset());
EXPECT_EQ(gfx::Vector2dF().ToString(),
scroll_layer->TotalScrollOffset().ToString());
@@ -7057,7 +7141,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
// Scroll across the boundary
const float content_scroll = 20;
offset = residue + content_scroll;
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
EXPECT_EQ(-top_controls_height_,
host_impl_->top_controls_manager()->ControlsTopOffset());
EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(),
@@ -7065,7 +7150,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
// Now scroll back to the top of the content
offset = -content_scroll;
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
EXPECT_EQ(-top_controls_height_,
host_impl_->top_controls_manager()->ControlsTopOffset());
EXPECT_EQ(gfx::Vector2dF().ToString(),
@@ -7073,13 +7159,15 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
// And scroll the top controls completely into view
offset = -top_controls_height_;
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
EXPECT_EQ(gfx::Vector2dF().ToString(),
scroll_layer->TotalScrollOffset().ToString());
// And attempt to scroll past the end
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_FALSE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
EXPECT_EQ(gfx::Vector2dF().ToString(),
scroll_layer->TotalScrollOffset().ToString());
@@ -7103,7 +7191,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) {
// Scroll the top controls partially.
const float residue = 35;
float offset = top_controls_height_ - residue;
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset());
EXPECT_EQ(gfx::Vector2dF().ToString(),
scroll_layer->TotalScrollOffset().ToString());
@@ -7171,7 +7260,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
// Scroll the top controls partially.
const float residue = 15;
float offset = top_controls_height_ - residue;
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_TRUE(
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset());
EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
scroll_layer->TotalScrollOffset().ToString());
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index e922f21..8e7d220 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -1091,13 +1091,6 @@ class ThreadCheckingInputHandlerClient : public InputHandlerClient {
*received_stop_flinging_ = true;
}
- void DidOverscroll(const gfx::PointF& causal_event_viewport_point,
- const gfx::Vector2dF& accumulated_overscroll,
- const gfx::Vector2dF& latest_overscroll_delta) override {
- if (!task_runner_->BelongsToCurrentThread())
- ADD_FAILURE() << "DidOverscroll called on wrong thread";
- }
-
private:
base::SingleThreadTaskRunner* task_runner_;
bool* received_stop_flinging_;