summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorlanwei@chromium.org <lanwei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-11 20:25:26 +0000
committerlanwei@chromium.org <lanwei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-11 20:26:55 +0000
commit89d3891564cee699bfe2888396df30f2434b1799 (patch)
treeccd7f442dc2940982ec94292f65f131905151827 /ui
parent1f19f126d66a541c478b84268765d06e489f798a (diff)
downloadchromium_src-89d3891564cee699bfe2888396df30f2434b1799.zip
chromium_src-89d3891564cee699bfe2888396df30f2434b1799.tar.gz
chromium_src-89d3891564cee699bfe2888396df30f2434b1799.tar.bz2
Change the max_swipe_deviation_ratio to max_swipe_deviation_angle.
Angle makes more sense here to determine if it is a swipe gesture. R=tdresser@chromium.org BUG=366603 Review URL: https://codereview.chromium.org/452153004 Cr-Commit-Position: refs/heads/master@{#288785} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288785 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc15
-rw-r--r--ui/events/gesture_detection/gesture_config_helper_aura.cc6
-rw-r--r--ui/events/gestures/gesture_configuration.cc2
-rw-r--r--ui/events/gestures/gesture_configuration.h10
-rw-r--r--ui/events/gestures/gesture_sequence.cc9
5 files changed, 29 insertions, 13 deletions
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index b57e4cd..963b24d 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -2890,6 +2890,21 @@ TEST_P(GestureRecognizerTest, MultiFingerSwipe) {
count, points, 10, kSteps, 11 * kSteps, 0);
EXPECT_TRUE(delegate->swipe_right());
delegate->Reset();
+
+ generator.GestureMultiFingerScroll(
+ count, points, 10, kSteps, 5 * kSteps, 12 * kSteps);
+ EXPECT_FALSE(delegate->swipe_down());
+ delegate->Reset();
+
+ generator.GestureMultiFingerScroll(
+ count, points, 10, kSteps, 4 * kSteps, 12 * kSteps);
+ EXPECT_TRUE(delegate->swipe_down());
+ delegate->Reset();
+
+ generator.GestureMultiFingerScroll(
+ count, points, 10, kSteps, 3 * kSteps, 12 * kSteps);
+ EXPECT_TRUE(delegate->swipe_down());
+ delegate->Reset();
}
}
diff --git a/ui/events/gesture_detection/gesture_config_helper_aura.cc b/ui/events/gesture_detection/gesture_config_helper_aura.cc
index c6c18f7..195e891 100644
--- a/ui/events/gesture_detection/gesture_config_helper_aura.cc
+++ b/ui/events/gesture_detection/gesture_config_helper_aura.cc
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// MSVC++ requires this to be set before any other includes to get M_PI.
-#define _USE_MATH_DEFINES
-
#include "ui/events/gesture_detection/gesture_config_helper.h"
#include <cmath>
@@ -36,8 +33,7 @@ GestureDetector::Config DefaultGestureDetectorConfig() {
config.swipe_enabled = true;
config.minimum_swipe_velocity = GestureConfiguration::min_swipe_speed();
config.maximum_swipe_deviation_angle =
- atan2(1.f, GestureConfiguration::max_swipe_deviation_ratio()) * 180.0f /
- static_cast<float>(M_PI);
+ GestureConfiguration::max_swipe_deviation_angle();
config.two_finger_tap_enabled = true;
config.two_finger_tap_max_separation =
GestureConfiguration::max_distance_for_two_finger_tap_in_pixels();
diff --git a/ui/events/gestures/gesture_configuration.cc b/ui/events/gestures/gesture_configuration.cc
index 8623e99..5b22639 100644
--- a/ui/events/gestures/gesture_configuration.cc
+++ b/ui/events/gestures/gesture_configuration.cc
@@ -18,7 +18,7 @@ int GestureConfiguration::max_radius_ = 100;
double GestureConfiguration::max_seconds_between_double_click_ = 0.7;
double
GestureConfiguration::max_separation_for_gesture_touches_in_pixels_ = 150;
-double GestureConfiguration::max_swipe_deviation_ratio_ = 3;
+float GestureConfiguration::max_swipe_deviation_angle_ = 20;
double
GestureConfiguration::max_touch_down_duration_in_seconds_for_click_ = 0.8;
double GestureConfiguration::max_touch_move_in_pixels_for_click_ = 15;
diff --git a/ui/events/gestures/gesture_configuration.h b/ui/events/gestures/gesture_configuration.h
index 1e3ea68..81f3ae0 100644
--- a/ui/events/gestures/gesture_configuration.h
+++ b/ui/events/gestures/gesture_configuration.h
@@ -71,11 +71,11 @@ class EVENTS_BASE_EXPORT GestureConfiguration {
static void set_max_separation_for_gesture_touches_in_pixels(int val) {
max_separation_for_gesture_touches_in_pixels_ = val;
}
- static double max_swipe_deviation_ratio() {
- return max_swipe_deviation_ratio_;
+ static float max_swipe_deviation_angle() {
+ return max_swipe_deviation_angle_;
}
- static void set_max_swipe_deviation_ratio(double val) {
- max_swipe_deviation_ratio_ = val;
+ static void set_max_swipe_deviation_angle(float val) {
+ max_swipe_deviation_angle_ = val;
}
static double max_touch_down_duration_in_seconds_for_click() {
return max_touch_down_duration_in_seconds_for_click_;
@@ -238,7 +238,7 @@ class EVENTS_BASE_EXPORT GestureConfiguration {
static double semi_long_press_time_in_seconds_;
static double max_seconds_between_double_click_;
static double max_separation_for_gesture_touches_in_pixels_;
- static double max_swipe_deviation_ratio_;
+ static float max_swipe_deviation_angle_;
static double max_touch_down_duration_in_seconds_for_click_;
static double max_touch_move_in_pixels_for_click_;
static double max_distance_between_taps_for_double_tap_;
diff --git a/ui/events/gestures/gesture_sequence.cc b/ui/events/gestures/gesture_sequence.cc
index e20e702..838a6a1 100644
--- a/ui/events/gestures/gesture_sequence.cc
+++ b/ui/events/gestures/gesture_sequence.cc
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// MSVC++ requires this to be set before any other includes to get M_PI.
+#define _USE_MATH_DEFINES
+
#include "ui/events/gestures/gesture_sequence.h"
#include <stdlib.h>
@@ -1412,9 +1415,11 @@ bool GestureSequence::MaybeSwipe(const TouchEvent& event,
if (!swipe_y)
velocity_y = 0.001f;
- float ratio = velocity_x > velocity_y ? velocity_x / velocity_y :
+ float ratio = velocity_x < velocity_y ? velocity_x / velocity_y :
velocity_y / velocity_x;
- if (ratio < GestureConfiguration::max_swipe_deviation_ratio())
+ float angle = atan(ratio) * 180.0f / static_cast<float>(M_PI);
+
+ if (angle > GestureConfiguration::max_swipe_deviation_angle())
return false;
if (velocity_x > velocity_y)