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

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

Issue 223673006: Support GestureBegin and GestureEnd in ui::GestureProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address jdduke's comments. Created 6 years, 9 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
Index: ui/events/gesture_detection/gesture_provider.cc
diff --git a/ui/events/gesture_detection/gesture_provider.cc b/ui/events/gesture_detection/gesture_provider.cc
index eb1794d32dfcf1c927b86fb6443a6ca8c301e76b..6245522dda40069421347ea87a793ecea4e5ea2e 100644
--- a/ui/events/gesture_detection/gesture_provider.cc
+++ b/ui/events/gesture_detection/gesture_provider.cc
@@ -72,7 +72,8 @@ GestureEventDetails CreateTapGestureDetails(EventType type,
// GestureProvider:::Config
-GestureProvider::Config::Config() : disable_click_delay(false) {}
+GestureProvider::Config::Config()
+ : disable_click_delay(false), gesture_begin_end_types_enabled(false) {}
GestureProvider::Config::~Config() {}
@@ -520,7 +521,8 @@ GestureProvider::GestureProvider(const Config& config,
touch_scroll_in_progress_(false),
pinch_in_progress_(false),
double_tap_support_for_page_(true),
- double_tap_support_for_platform_(true) {
+ double_tap_support_for_platform_(true),
+ gesture_begin_end_types_enabled_(config.gesture_begin_end_types_enabled) {
DCHECK(client);
InitGestureDetectors(config);
}
@@ -536,32 +538,12 @@ bool GestureProvider::OnTouchEvent(const MotionEvent& event) {
const bool in_scale_gesture =
scale_gesture_listener_->IsScaleGestureDetectionInProgress();
- if (event.GetAction() == MotionEvent::ACTION_DOWN) {
- current_down_event_ = event.Clone();
- touch_scroll_in_progress_ = false;
- needs_show_press_event_ = true;
- current_longpress_time_ = base::TimeTicks();
- SendTapCancelIfNecessary(event);
- }
-
- bool handled = gesture_listener_->OnTouchEvent(event, in_scale_gesture);
- handled |= scale_gesture_listener_->OnTouchEvent(event);
-
- if (event.GetAction() == MotionEvent::ACTION_UP ||
- event.GetAction() == MotionEvent::ACTION_CANCEL) {
- // Note: This call will have no effect if a fling was just generated, as
- // |Fling()| will have already signalled an end to touch-scrolling.
- EndTouchScrollIfNecessary(event.GetEventTime(), true);
-
- // We shouldn't necessarily cancel a tap on ACTION_UP, as the double-tap
- // timeout may yet trigger a SINGLE_TAP.
- if (event.GetAction() == MotionEvent::ACTION_CANCEL)
- SendTapCancelIfNecessary(event);
+ OnTouchEventHandlingBegin(event);
- UpdateDoubleTapDetectionSupport();
+ gesture_listener_->OnTouchEvent(event, in_scale_gesture);
+ scale_gesture_listener_->OnTouchEvent(event);
- current_down_event_.reset();
- }
+ OnTouchEventHandlingEnd(event);
return true;
}
@@ -666,6 +648,7 @@ void GestureProvider::Send(const GestureEventData& gesture) {
switch (gesture.type) {
case ET_GESTURE_TAP_DOWN:
needs_tap_ending_event_ = true;
+ needs_show_press_event_ = true;
break;
case ET_GESTURE_TAP_UNCONFIRMED:
needs_show_press_event_ = false;
@@ -757,4 +740,56 @@ void GestureProvider::UpdateDoubleTapDetectionSupport() {
scale_gesture_listener_->SetDoubleTapEnabled(supports_double_tap);
}
+void GestureProvider::OnTouchEventHandlingBegin(const MotionEvent& event) {
+ switch (event.GetAction()) {
+ case MotionEvent::ACTION_DOWN:
+ current_down_event_ = event.Clone();
+ touch_scroll_in_progress_ = false;
+ needs_show_press_event_ = false;
+ current_longpress_time_ = base::TimeTicks();
+ SendTapCancelIfNecessary(event);
+ if (gesture_begin_end_types_enabled_)
+ Send(CreateGesture(ET_GESTURE_BEGIN, event));
+ break;
+ case MotionEvent::ACTION_POINTER_DOWN:
+ if (gesture_begin_end_types_enabled_)
+ Send(CreateGesture(ET_GESTURE_BEGIN, event));
+ break;
+ case MotionEvent::ACTION_POINTER_UP:
+ case MotionEvent::ACTION_UP:
+ case MotionEvent::ACTION_CANCEL:
+ case MotionEvent::ACTION_MOVE:
+ break;
+ }
+}
+
+void GestureProvider::OnTouchEventHandlingEnd(const MotionEvent& event) {
+ switch (event.GetAction()) {
+ case MotionEvent::ACTION_UP:
+ case MotionEvent::ACTION_CANCEL:
+ // Note: This call will have no effect if a fling was just generated, as
+ // |Fling()| will have already signalled an end to touch-scrolling.
+ EndTouchScrollIfNecessary(event.GetEventTime(), true);
+ // We shouldn't necessarily cancel a tap on ACTION_UP, as the double-tap
jdduke (slow) 2014/04/04 19:08:36 Let's add a line break before "// We shouldn't".
tdresser 2014/04/07 13:42:55 Done.
+ // timeout may yet trigger a SINGLE_TAP.
+ if (event.GetAction() == MotionEvent::ACTION_CANCEL)
+ SendTapCancelIfNecessary(event);
+ UpdateDoubleTapDetectionSupport();
jdduke (slow) 2014/04/04 19:08:36 Also line break before |UpdateDouble...|.
tdresser 2014/04/07 13:42:55 Done.
+
+ if (gesture_begin_end_types_enabled_)
+ Send(CreateGesture(ET_GESTURE_END, event));
+
+ current_down_event_.reset();
+ break;
+ case MotionEvent::ACTION_POINTER_UP:
+ if (gesture_begin_end_types_enabled_)
+ Send(CreateGesture(ET_GESTURE_END, event));
+ break;
+ case MotionEvent::ACTION_DOWN:
+ case MotionEvent::ACTION_POINTER_DOWN:
+ case MotionEvent::ACTION_MOVE:
+ break;
+ }
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698