summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 18:14:57 +0000
committerrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 18:14:57 +0000
commit6a660e670543db8232ea24a17dd6a7720f756cf3 (patch)
treef674b574f587ddb3f9f5ae5d5e8d5af5abac3a85
parentd33f8bb636e4e878cb34bda3846b304f5ce5cb05 (diff)
downloadchromium_src-6a660e670543db8232ea24a17dd6a7720f756cf3.zip
chromium_src-6a660e670543db8232ea24a17dd6a7720f756cf3.tar.gz
chromium_src-6a660e670543db8232ea24a17dd6a7720f756cf3.tar.bz2
Bound the maximum touchscreen fling velocity.
Set a configurable cap on the maximum touchscreen fling velocity. BUG=141653 Review URL: https://chromiumcodereview.appspot.com/11299276 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170761 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/gesture_config.js5
-rw-r--r--chrome/browser/ui/gesture_prefs_observer_factory_aura.cc7
-rw-r--r--chrome/common/pref_names.cc1
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--ui/aura/test/aura_test_base.cc1
-rw-r--r--ui/base/gestures/gesture_configuration.cc6
-rw-r--r--ui/base/gestures/gesture_configuration.h7
-rw-r--r--ui/base/gestures/gesture_sequence.cc5
8 files changed, 27 insertions, 6 deletions
diff --git a/chrome/browser/resources/gesture_config.js b/chrome/browser/resources/gesture_config.js
index 25e9ce6..74607f9 100644
--- a/chrome/browser/resources/gesture_config.js
+++ b/chrome/browser/resources/gesture_config.js
@@ -244,6 +244,11 @@ function GestureConfig() {
key: 'fling_acceleration_curve_coefficient_3',
label: '+',
units: 'x<sup>0</sup>'
+ },
+ {
+ key: 'fling_velocity_cap',
+ label: 'Touchscreen Fling Velocity Cap',
+ units: 'pixels / second'
}
];
diff --git a/chrome/browser/ui/gesture_prefs_observer_factory_aura.cc b/chrome/browser/ui/gesture_prefs_observer_factory_aura.cc
index 5669fc7..d52ecc1 100644
--- a/chrome/browser/ui/gesture_prefs_observer_factory_aura.cc
+++ b/chrome/browser/ui/gesture_prefs_observer_factory_aura.cc
@@ -78,6 +78,7 @@ const char* kPrefsToObserve[] = {
prefs::kFlingAccelerationCurveCoefficient1,
prefs::kFlingAccelerationCurveCoefficient2,
prefs::kFlingAccelerationCurveCoefficient3,
+ prefs::kFlingVelocityCap,
prefs::kLongPressTimeInSeconds,
prefs::kMaxDistanceForTwoFingerTapInPixels,
prefs::kMaxSecondsBetweenDoubleClick,
@@ -136,6 +137,8 @@ void GesturePrefsObserver::Update() {
prefs_->GetDouble(prefs::kFlingAccelerationCurveCoefficient2));
GestureConfiguration::set_fling_acceleration_curve_coefficients(3,
prefs_->GetDouble(prefs::kFlingAccelerationCurveCoefficient3));
+ GestureConfiguration::set_fling_velocity_cap(
+ prefs_->GetDouble(prefs::kFlingVelocityCap));
GestureConfiguration::set_long_press_time_in_seconds(
prefs_->GetDouble(
prefs::kLongPressTimeInSeconds));
@@ -256,6 +259,10 @@ void GesturePrefsObserverFactoryAura::RegisterUserPrefs(PrefService* prefs) {
GestureConfiguration::fling_acceleration_curve_coefficients(3),
PrefService::UNSYNCABLE_PREF);
prefs->RegisterDoublePref(
+ prefs::kFlingVelocityCap,
+ GestureConfiguration::fling_velocity_cap(),
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterDoublePref(
prefs::kLongPressTimeInSeconds,
GestureConfiguration::long_press_time_in_seconds(),
PrefService::UNSYNCABLE_PREF);
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 5b232fa..ebdabfaf 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -2087,6 +2087,7 @@ const char kPinnedLauncherApps[] =
// Boolean value indicating whether to show a logout button in the ash tray.
const char kShowLogoutButtonInTray[] = "show_logout_button_in_tray";
+const char kFlingVelocityCap[] = "gesture.fling_velocity_cap";
const char kLongPressTimeInSeconds[] =
"gesture.long_press_time_in_seconds";
const char kMaxDistanceBetweenTapsForDoubleTap[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index d713440..db09c6d 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -761,6 +761,7 @@ extern const char kUseDefaultPinnedApps[];
extern const char kPinnedLauncherApps[];
extern const char kShowLogoutButtonInTray[];
+extern const char kFlingVelocityCap[];
extern const char kLongPressTimeInSeconds[];
extern const char kMaxDistanceBetweenTapsForDoubleTap[];
extern const char kMaxDistanceForTwoFingerTapInPixels[];
diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc
index 6e99dd5..9d0c96c6 100644
--- a/ui/aura/test/aura_test_base.cc
+++ b/ui/aura/test/aura_test_base.cc
@@ -54,6 +54,7 @@ void AuraTestBase::SetUp() {
2, 0.0452381f);
ui::GestureConfiguration::set_fling_acceleration_curve_coefficients(
3, 0.8f);
+ ui::GestureConfiguration::set_fling_velocity_cap(15000.0f);
helper_.reset(new AuraTestHelper(&message_loop_));
helper_->SetUp();
diff --git a/ui/base/gestures/gesture_configuration.cc b/ui/base/gestures/gesture_configuration.cc
index 8310ed8..39847830 100644
--- a/ui/base/gestures/gesture_configuration.cc
+++ b/ui/base/gestures/gesture_configuration.cc
@@ -6,12 +6,8 @@
namespace ui {
-// Ordered alphabetically ignoring underscores, to align with the
-// associated list of prefs in gesture_prefs_aura.cc.
-// NOTE: When updating values here, also update
-// browser/resources/gesture_config.js for chrome://gesture config UI.
-// TODO(rbyers) unify these - crbug.com/156392
int GestureConfiguration::default_radius_ = 15;
+float GestureConfiguration::fling_velocity_cap_ = 17000.0f;
double GestureConfiguration::long_press_time_in_seconds_ = 1.0;
double GestureConfiguration::semi_long_press_time_in_seconds_ = 0.4;
double GestureConfiguration::max_distance_for_two_finger_tap_in_pixels_ = 300;
diff --git a/ui/base/gestures/gesture_configuration.h b/ui/base/gestures/gesture_configuration.h
index 256c5d2..2fc5470 100644
--- a/ui/base/gestures/gesture_configuration.h
+++ b/ui/base/gestures/gesture_configuration.h
@@ -149,6 +149,12 @@ class UI_EXPORT GestureConfiguration {
static float fling_acceleration_curve_coefficients(int i) {
return fling_acceleration_curve_coefficients_[i];
}
+ static float fling_velocity_cap() {
+ return fling_velocity_cap_;
+ }
+ static void set_fling_velocity_cap(float val) {
+ fling_velocity_cap_ = val;
+ }
private:
// These are listed in alphabetical order ignoring underscores, to
@@ -187,6 +193,7 @@ class UI_EXPORT GestureConfiguration {
static double rail_break_proportion_;
static double rail_start_proportion_;
static float fling_acceleration_curve_coefficients_[NumAccelParams];
+ static float fling_velocity_cap_;
DISALLOW_COPY_AND_ASSIGN(GestureConfiguration);
};
diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc
index 115229a..07d42ed 100644
--- a/ui/base/gestures/gesture_sequence.cc
+++ b/ui/base/gestures/gesture_sequence.cc
@@ -296,7 +296,10 @@ float CalibrateFlingVelocity(float velocity) {
nu += x * a;
x *= normalized_velocity;
}
- return nu * velocity;
+ if (velocity < 0.f)
+ return std::max(nu * velocity, -GestureConfiguration::fling_velocity_cap());
+ else
+ return std::min(nu * velocity, GestureConfiguration::fling_velocity_cap());
}
} // namespace