diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-20 02:38:35 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-20 02:38:35 +0000 |
commit | e2713728a6f7b9c5275e1b390f17309f72e7804a (patch) | |
tree | c2e43349b1c69a419c350122a4d712c8f9c16471 /ui/base/gestures/gesture_sequence.cc | |
parent | 002414c002a132b67937869d52aeb85a0547b639 (diff) | |
download | chromium_src-e2713728a6f7b9c5275e1b390f17309f72e7804a.zip chromium_src-e2713728a6f7b9c5275e1b390f17309f72e7804a.tar.gz chromium_src-e2713728a6f7b9c5275e1b390f17309f72e7804a.tar.bz2 |
Add scroll prediction as a configurable gesture parameter.
BUG=143242
TEST=Enable scroll prediction flag and set scroll prediction value in chrome://gesture, log out and log back in. Scroll with finger and verify that scroll is keeping up better with finger movements.
TEST=GestureRecognizerTest.GestureEventScrollPrediction
Review URL: https://chromiumcodereview.appspot.com/15995037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/gestures/gesture_sequence.cc')
-rw-r--r-- | ui/base/gestures/gesture_sequence.cc | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc index 0ee4114..45dd184 100644 --- a/ui/base/gestures/gesture_sequence.cc +++ b/ui/base/gestures/gesture_sequence.cc @@ -7,6 +7,7 @@ #include <cmath> #include <stdlib.h> +#include "base/command_line.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" @@ -15,6 +16,7 @@ #include "ui/base/events/event_constants.h" #include "ui/base/gestures/gesture_configuration.h" #include "ui/base/gestures/gesture_util.h" +#include "ui/base/ui_base_switches.h" #include "ui/gfx/rect.h" namespace ui { @@ -724,6 +726,8 @@ void GestureSequence::AppendScrollGestureEnd(const GesturePoint& point, float y_velocity) { float railed_x_velocity = x_velocity; float railed_y_velocity = y_velocity; + last_scroll_prediction_offset_.set_x(0); + last_scroll_prediction_offset_.set_y(0); if (scroll_type_ == ST_HORIZONTAL) railed_y_velocity = 0; @@ -752,7 +756,9 @@ void GestureSequence::AppendScrollGestureEnd(const GesturePoint& point, void GestureSequence::AppendScrollGestureUpdate(GesturePoint& point, Gestures* gestures) { - gfx::Vector2d d; + static bool use_scroll_prediction = CommandLine::ForCurrentProcess()-> + HasSwitch(switches::kEnableScrollPrediction); + gfx::Vector2dF d; gfx::Point location; if (point_count_ == 1) { d = point.ScrollDelta(); @@ -762,6 +768,20 @@ void GestureSequence::AppendScrollGestureUpdate(GesturePoint& point, d = location - latest_multi_scroll_update_location_; latest_multi_scroll_update_location_ = location; } + + if (use_scroll_prediction) { + // Remove the extra distance added by the last scroll prediction and add + // the new prediction offset. + d -= last_scroll_prediction_offset_; + last_scroll_prediction_offset_.set_x( + GestureConfiguration::scroll_prediction_seconds() * point.XVelocity()); + last_scroll_prediction_offset_.set_y( + GestureConfiguration::scroll_prediction_seconds() * point.YVelocity()); + d += last_scroll_prediction_offset_; + location += gfx::Vector2d(last_scroll_prediction_offset_.x(), + last_scroll_prediction_offset_.y()); + } + if (scroll_type_ == ST_HORIZONTAL) d.set_y(0); else if (scroll_type_ == ST_VERTICAL) |