diff options
author | ccameron <ccameron@chromium.org> | 2014-11-06 19:18:50 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-07 03:19:02 +0000 |
commit | 36d091feca1a3621430a61091ff2a527972a8e79 (patch) | |
tree | 3286e93b1b78c07b05b8031166fdad02f0c7993e /cc/input | |
parent | a4a32af218cf03ac89db4a27d12681f8a1ba9108 (diff) | |
download | chromium_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/input')
-rw-r--r-- | cc/input/input_handler.cc | 13 | ||||
-rw-r--r-- | cc/input/input_handler.h | 36 |
2 files changed, 36 insertions, 13 deletions
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; |