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

Unified Diff: ui/events/gesture_detection/gesture_detector.cc

Issue 289373009: Support tap_count in ui::GestureProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small cleanup. Created 6 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/events/gesture_detection/gesture_detector.h ('k') | ui/events/gesture_detection/gesture_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gesture_detection/gesture_detector.cc
diff --git a/ui/events/gesture_detection/gesture_detector.cc b/ui/events/gesture_detection/gesture_detector.cc
index fdc524bef2cf8e861fde0022dcf604db9fbf354f..f3b3bed5ad8369b9738a177a773c8ad3de98ef2c 100644
--- a/ui/events/gesture_detection/gesture_detector.cc
+++ b/ui/events/gesture_detection/gesture_detector.cc
@@ -64,7 +64,7 @@ void GestureDetector::SimpleGestureListener::OnShowPress(const MotionEvent& e) {
}
bool GestureDetector::SimpleGestureListener::OnSingleTapUp(
- const MotionEvent& e) {
+ const MotionEvent& e, int tap_count) {
jdduke (slow) 2014/05/21 15:07:14 Maybe tap_repeat_count? Hmm, but that's slightly a
tdresser 2014/05/21 16:39:15 We use tap_count throughout (GestureEventDetails,
return false;
}
@@ -100,7 +100,7 @@ bool GestureDetector::SimpleGestureListener::OnTwoFingerTap(
}
bool GestureDetector::SimpleGestureListener::OnSingleTapConfirmed(
- const MotionEvent& e) {
+ const MotionEvent& e, int tap_count) {
return false;
}
@@ -187,9 +187,10 @@ GestureDetector::GestureDetector(
last_focus_y_(0),
down_focus_x_(0),
down_focus_y_(0),
- longpress_enabled_(true),
- swipe_enabled_(false),
- two_finger_tap_enabled_(false) {
+ longpress_enabled_(true),
+ swipe_enabled_(false),
+ two_finger_tap_enabled_(false),
+ tap_count_(0) {
DCHECK(listener_);
Init(config);
}
@@ -327,6 +328,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) {
down_focus_x_ = last_focus_x_ = focus_x;
down_focus_y_ = last_focus_y_ = focus_y;
+ previous_down_event_ = current_down_event_.Pass();
current_down_event_ = ev.Clone();
secondary_pointer_down_event_.reset();
@@ -416,9 +418,27 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) {
timeout_handler_->StopTimeout(TAP);
in_longpress_ = false;
} else if (always_in_tap_region_) {
- handled = listener_->OnSingleTapUp(ev);
+ if (double_tap_listener_) {
+ tap_count_ = 1;
+ } else {
+ if (previous_down_event_ && previous_up_event_ &&
+ current_down_event_ &&
+ IsConsideredDoubleTap(*previous_down_event_,
+ *previous_up_event_,
+ *current_down_event_)) {
+ ++tap_count_;
+ // We only support up to triple tap. Further taps are also treated
+ // as triple taps.
+ tap_count_ = std::min(tap_count_, 3);
jdduke (slow) 2014/05/21 15:07:14 I'd prefer the GestureDetector not have any awaren
tdresser 2014/05/21 16:39:15 Done.
+ } else {
+ // As we're outside of the double tap range, reset the
+ // |tap_count_|.
+ tap_count_ = 1;
+ }
+ }
+ handled = listener_->OnSingleTapUp(ev, tap_count_);
if (defer_confirm_single_tap_ && double_tap_listener_ != NULL) {
- double_tap_listener_->OnSingleTapConfirmed(ev);
+ double_tap_listener_->OnSingleTapConfirmed(ev, 1);
jdduke (slow) 2014/05/21 15:07:14 Might as well just use |tap_count_| here instead o
tdresser 2014/05/21 16:39:15 Done.
}
} else {
@@ -513,7 +533,7 @@ void GestureDetector::OnTapTimeout() {
if (!double_tap_listener_)
return;
if (!still_down_)
- double_tap_listener_->OnSingleTapConfirmed(*current_down_event_);
+ double_tap_listener_->OnSingleTapConfirmed(*current_down_event_, 1);
else
defer_confirm_single_tap_ = true;
}
« no previous file with comments | « ui/events/gesture_detection/gesture_detector.h ('k') | ui/events/gesture_detection/gesture_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698