summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-31 20:24:42 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-31 20:24:42 +0000
commitd2afa867d9f2451d2dede9b8bd5374441a79a862 (patch)
tree5cf262a443201d0b21e9f5e3cf8cf7400efbe02e /cc
parent533b464baefc2b0490ea4427a1a22658426bd73d (diff)
downloadchromium_src-d2afa867d9f2451d2dede9b8bd5374441a79a862.zip
chromium_src-d2afa867d9f2451d2dede9b8bd5374441a79a862.tar.gz
chromium_src-d2afa867d9f2451d2dede9b8bd5374441a79a862.tar.bz2
Early terminate flings when scrolling impossible
Previously, flings were terminated early only if the root layer overscrolled. Now, flings will terminate if the fling target's |scrollBy()| method returns false, providing consistency between layer types and saving battery on sites with scrolling sublayers. Also move |DidOverscrollParams| into content/ in anticipation of using it directly in the overscroll IPC message. Corresponding Blink patch: https://codereview.chromium.org/139493003/ Review URL: https://codereview.chromium.org/136173004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/input/input_handler.h11
-rw-r--r--cc/trees/layer_tree_host_impl.cc13
-rw-r--r--cc/trees/layer_tree_host_impl.h6
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc19
-rw-r--r--cc/trees/layer_tree_host_unittest_scroll.cc4
5 files changed, 8 insertions, 45 deletions
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h
index fda17cd..b269345 100644
--- a/cc/input/input_handler.h
+++ b/cc/input/input_handler.h
@@ -24,12 +24,6 @@ namespace cc {
class LayerScrollOffsetDelegate;
-struct DidOverscrollParams {
- gfx::Vector2dF accumulated_overscroll;
- gfx::Vector2dF latest_overscroll_delta;
- gfx::Vector2dF current_fling_velocity;
-};
-
class CC_EXPORT InputHandlerClient {
public:
virtual ~InputHandlerClient() {}
@@ -41,7 +35,8 @@ class CC_EXPORT InputHandlerClient {
// 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 DidOverscrollParams& params) = 0;
+ virtual void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll,
+ const gfx::Vector2dF& latest_overscroll_delta) = 0;
protected:
InputHandlerClient() {}
@@ -94,8 +89,6 @@ class CC_EXPORT InputHandler {
// ScrollIgnored if not.
virtual ScrollStatus FlingScrollBegin() = 0;
- virtual void NotifyCurrentFlingVelocity(const gfx::Vector2dF& velocity) = 0;
-
virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0;
// Stop scrolling the selected layer. Should only be called if ScrollBegin()
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 072e8e7..928f7a7 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2317,11 +2317,8 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
accumulated_root_overscroll_ += unused_root_delta;
bool did_overscroll = !unused_root_delta.IsZero();
if (did_overscroll && input_handler_client_) {
- DidOverscrollParams params;
- params.accumulated_overscroll = accumulated_root_overscroll_;
- params.latest_overscroll_delta = unused_root_delta;
- params.current_fling_velocity = current_fling_velocity_;
- input_handler_client_->DidOverscroll(params);
+ input_handler_client_->DidOverscroll(accumulated_root_overscroll_,
+ unused_root_delta);
}
return did_scroll_content || did_scroll_top_controls;
@@ -2384,7 +2381,6 @@ void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
active_tree_->ClearCurrentlyScrollingLayer();
did_lock_scrolling_layer_ = false;
accumulated_root_overscroll_ = gfx::Vector2dF();
- current_fling_velocity_ = gfx::Vector2dF();
}
void LayerTreeHostImpl::ScrollEnd() {
@@ -2415,11 +2411,6 @@ InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
return ScrollStarted;
}
-void LayerTreeHostImpl::NotifyCurrentFlingVelocity(
- const gfx::Vector2dF& velocity) {
- current_fling_velocity_ = velocity;
-}
-
float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
const gfx::PointF& device_viewport_point,
LayerImpl* layer_impl) {
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 10477dc..dc20aaf 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -123,8 +123,6 @@ class CC_EXPORT LayerTreeHostImpl
virtual void OnRootLayerDelegatedScrollOffsetChanged() OVERRIDE;
virtual void ScrollEnd() OVERRIDE;
virtual InputHandler::ScrollStatus FlingScrollBegin() OVERRIDE;
- virtual void NotifyCurrentFlingVelocity(
- const gfx::Vector2dF& velocity) OVERRIDE;
virtual void MouseMoveAt(const gfx::Point& viewport_point) OVERRIDE;
virtual void PinchGestureBegin() OVERRIDE;
virtual void PinchGestureUpdate(float magnify_delta,
@@ -380,9 +378,6 @@ class CC_EXPORT LayerTreeHostImpl
gfx::Vector2dF accumulated_root_overscroll() const {
return accumulated_root_overscroll_;
}
- gfx::Vector2dF current_fling_velocity() const {
- return current_fling_velocity_;
- }
bool pinch_gesture_active() const { return pinch_gesture_active_; }
@@ -569,7 +564,6 @@ class CC_EXPORT LayerTreeHostImpl
ManagedMemoryPolicy cached_managed_memory_policy_;
gfx::Vector2dF accumulated_root_overscroll_;
- gfx::Vector2dF current_fling_velocity_;
bool pinch_gesture_active_;
bool pinch_gesture_end_should_clear_scrolling_layer_;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 351ec35..8bf0e43 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -2986,19 +2986,16 @@ TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
DrawFrame();
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// 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));
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// Overscroll events are reflected immediately.
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50));
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// In-bounds scrolling resets accumulated overscroll for the scrolled axes.
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50));
@@ -3026,15 +3023,6 @@ TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
-
- EXPECT_EQ(InputHandler::ScrollStarted,
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
- // Fling velocity is reflected immediately.
- host_impl_->NotifyCurrentFlingVelocity(gfx::Vector2dF(10, 0));
- EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
- EXPECT_EQ(gfx::Vector2dF(0, -20), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity());
}
@@ -3087,10 +3075,8 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
host_impl_->ScrollEnd();
// After scrolling the parent, another scroll on the opposite direction
- // should scroll the child, resetting the fling velocity.
+ // should scroll the child.
scroll_delta = gfx::Vector2d(0, 70);
- host_impl_->NotifyCurrentFlingVelocity(gfx::Vector2dF(10, 0));
- EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity());
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::NonBubblingGesture));
@@ -3098,7 +3084,6 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
host_impl_->ScrollEnd();
}
}
@@ -3152,14 +3137,12 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
DrawFrame();
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// Even though the layer can't scroll the overscroll still happens.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
}
TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) {
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index adda9bd..626c67d 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -1088,7 +1088,9 @@ class ThreadCheckingInputHandlerClient : public InputHandlerClient {
*received_stop_flinging_ = true;
}
- virtual void DidOverscroll(const DidOverscrollParams& params) OVERRIDE {
+ virtual void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll,
+ const gfx::Vector2dF& latest_overscroll_delta)
+ OVERRIDE {
if (!task_runner_->BelongsToCurrentThread())
ADD_FAILURE() << "DidOverscroll called on wrong thread";
}