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..5e6c52fcd73660f1722effff7b5c5961dc3f7e4d 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_; |
} |
@@ -95,6 +98,11 @@ bool GesturePoint::IsInDoubleClickWindow(const TouchEvent& event) const { |
IsSecondClickInsideManhattanSquare(event); |
} |
+bool GesturePoint::IsInTripleClickWindow(const TouchEvent& event) const { |
+ return IsInThirdClickTimeWindow() && |
+ IsThirdClickInsideManhattanSquare(event); |
+} |
+ |
bool GesturePoint::IsInScrollWindow(const TouchEvent& event) const { |
return event.type() == ui::ET_TOUCH_MOVED && |
!IsInsideManhattanSquare(event); |
@@ -166,6 +174,13 @@ bool GesturePoint::IsInSecondClickTimeWindow() const { |
return duration < GestureConfiguration::max_seconds_between_double_click(); |
} |
+bool GesturePoint::IsInThirdClickTimeWindow() const { |
+ double duration1 = last_touch_time_ - last_tap_time_; |
+ double duration2 = last_tap_time_ - second_last_tap_time_; |
+ return duration1 < GestureConfiguration::max_seconds_between_double_click() && |
+ duration2 < GestureConfiguration::max_seconds_between_double_click(); |
+} |
+ |
sadrul
2013/05/28 17:48:46
Refactor IsInSecondClickTimeWindow and IsInThirdCl
Yufeng Shen (Slow to review)
2013/05/28 19:31:44
Done.
|
bool GesturePoint::IsInsideManhattanSquare(const TouchEvent& event) const { |
return ui::gestures::IsInsideManhattanSquare(event.location(), |
first_touch_position_); |
@@ -179,6 +194,21 @@ bool GesturePoint::IsSecondClickInsideManhattanSquare( |
GestureConfiguration::max_distance_between_taps_for_double_tap(); |
} |
+bool GesturePoint::IsThirdClickInsideManhattanSquare( |
+ const TouchEvent& event) const { |
+ int manhattan_distance1 = |
+ abs(event.location().x() - last_tap_position_.x()) + |
+ abs(event.location().y() - last_tap_position_.y()); |
+ int manhattan_distance2 = |
+ abs(last_tap_position_.x() - second_last_tap_position_.x()) + |
+ abs(last_tap_position_.y() - second_last_tap_position_.y()); |
+ |
+ return manhattan_distance1 < |
+ GestureConfiguration::max_distance_between_taps_for_double_tap() && |
+ manhattan_distance2 < |
+ GestureConfiguration::max_distance_between_taps_for_double_tap(); |
+} |
+ |
sadrul
2013/05/28 17:48:46
Similarly,
IsLocationsInsideManhattanSquare(poin
Yufeng Shen (Slow to review)
2013/05/28 19:31:44
Done.
|
bool GesturePoint::IsOverMinFlickSpeed() { |
return velocity_calculator_.VelocitySquared() > |
GestureConfiguration::min_flick_speed_squared(); |