Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: ui/base/gestures/gesture_point.cc

Issue 16018006: Generate tap gesture with tap_count = 3 for triple-tap (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix sky's comment Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/gestures/gesture_point.h ('k') | ui/base/gestures/gesture_sequence.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/gestures/gesture_point.cc
diff --git a/ui/base/gestures/gesture_point.cc b/ui/base/gestures/gesture_point.cc
index 765ffd98c01e58081183b595a0d065e71844377e..105779b17c272b3c4aa4a7ab9057dd76eda49d78 100644
--- a/ui/base/gestures/gesture_point.cc
+++ b/ui/base/gestures/gesture_point.cc
@@ -19,6 +19,7 @@ GesturePoint::GesturePoint()
: first_touch_time_(0.0),
second_last_touch_time_(0.0),
last_touch_time_(0.0),
+ second_last_tap_time_(0.0),
last_tap_time_(0.0),
velocity_calculator_(
GestureConfiguration::points_buffered_for_velocity()),
@@ -76,6 +77,8 @@ void GesturePoint::UpdateValues(const TouchEvent& event) {
void GesturePoint::UpdateForTap() {
// Update the tap-position and time, and reset every other state.
+ second_last_tap_position_ = last_tap_position_;
+ second_last_tap_time_ = last_tap_time_;
last_tap_time_ = last_touch_time_;
last_tap_position_ = last_touch_position_;
}
@@ -91,8 +94,16 @@ bool GesturePoint::IsInClickWindow(const TouchEvent& event) const {
}
bool GesturePoint::IsInDoubleClickWindow(const TouchEvent& event) const {
- return IsInSecondClickTimeWindow() &&
- IsSecondClickInsideManhattanSquare(event);
+ return IsInClickAggregateTimeWindow(last_tap_time_, last_touch_time_) &&
+ IsPointInsideManhattanSquare(event.location(), last_tap_position_);
+}
+
+bool GesturePoint::IsInTripleClickWindow(const TouchEvent& event) const {
+ return IsInClickAggregateTimeWindow(last_tap_time_, last_touch_time_) &&
+ IsInClickAggregateTimeWindow(second_last_tap_time_, last_tap_time_) &&
+ IsPointInsideManhattanSquare(event.location(), last_tap_position_) &&
+ IsPointInsideManhattanSquare(last_tap_position_,
+ second_last_tap_position_);
}
bool GesturePoint::IsInScrollWindow(const TouchEvent& event) const {
@@ -161,8 +172,9 @@ bool GesturePoint::IsInClickTimeWindow() const {
GestureConfiguration::max_touch_down_duration_in_seconds_for_click();
}
-bool GesturePoint::IsInSecondClickTimeWindow() const {
- double duration = last_touch_time_ - last_tap_time_;
+bool GesturePoint::IsInClickAggregateTimeWindow(double before,
+ double after) const {
+ double duration = after - before;
return duration < GestureConfiguration::max_seconds_between_double_click();
}
@@ -171,10 +183,9 @@ bool GesturePoint::IsInsideManhattanSquare(const TouchEvent& event) const {
first_touch_position_);
}
-bool GesturePoint::IsSecondClickInsideManhattanSquare(
- const TouchEvent& event) const {
- int manhattan_distance = abs(event.location().x() - last_tap_position_.x()) +
- abs(event.location().y() - last_tap_position_.y());
+bool GesturePoint::IsPointInsideManhattanSquare(gfx::Point p1,
+ gfx::Point p2) const {
+ int manhattan_distance = abs(p1.x() - p2.x()) + abs(p1.y() - p2.y());
return manhattan_distance <
GestureConfiguration::max_distance_between_taps_for_double_tap();
}
« no previous file with comments | « ui/base/gestures/gesture_point.h ('k') | ui/base/gestures/gesture_sequence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698