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

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

Issue 2843543002: Missing source pointer down events are handled. (Closed)
Patch Set: use of reference for the mandatory parameter. Created 3 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 ef0e71f6d5dcd14368a65ebbfceae64f6e354728..a3f73861fe4ec5ed69477a343ed1e4e060d4d216 100644
--- a/ui/events/gesture_detection/gesture_detector.cc
+++ b/ui/events/gesture_detection/gesture_detector.cc
@@ -246,6 +246,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) {
handled = HandleSwipeIfNeeded(ev, vx_total / count, vy_total / count);
if (two_finger_tap_allowed_for_gesture_ && ev.GetPointerCount() == 2 &&
+ secondary_pointer_down_event_ &&
(ev.GetEventTime() - secondary_pointer_down_event_->GetEventTime() <=
two_finger_tap_timeout_)) {
handled = listener_->OnTwoFingerTap(*current_down_event_, ev);
@@ -554,12 +555,9 @@ bool GestureDetector::IsWithinTouchSlop(const MotionEvent& ev) {
for (size_t i = 0; i < ev.GetPointerCount(); i++) {
const int pointer_id = ev.GetPointerId(i);
const MotionEvent* source_pointer_down_event = GetSourcePointerDownEvent(
- *current_down_event_,
- (maximum_pointer_count_ > 1 && secondary_pointer_down_event_)
- ? *secondary_pointer_down_event_
- : *current_down_event_,
+ *current_down_event_.get(), secondary_pointer_down_event_.get(),
pointer_id);
- DCHECK(source_pointer_down_event);
+
if (!source_pointer_down_event)
return false;
@@ -580,17 +578,23 @@ bool GestureDetector::IsWithinTouchSlop(const MotionEvent& ev) {
const MotionEvent* GestureDetector::GetSourcePointerDownEvent(
const MotionEvent& current_down_event,
- const MotionEvent& secondary_pointer_down_event,
+ const MotionEvent* secondary_pointer_down_event,
const int pointer_id) {
if (current_down_event.GetPointerId(0) == pointer_id)
return &current_down_event;
- for (size_t i = 0; i < secondary_pointer_down_event.GetPointerCount(); i++) {
- if (secondary_pointer_down_event.GetPointerId(i) == pointer_id)
- return &secondary_pointer_down_event;
+ // Secondary pointer down event is sometimes missing (crbug.com/704426), the
+ // source pointer down event is not found in these cases.
+ // crbug.com/704426 is the only related bug report and we don't have any
+ // reliable repro of the bug.
+ if (!secondary_pointer_down_event)
+ return nullptr;
+
+ for (size_t i = 0; i < secondary_pointer_down_event->GetPointerCount(); i++) {
+ if (secondary_pointer_down_event->GetPointerId(i) == pointer_id)
+ return secondary_pointer_down_event;
}
- NOTREACHED();
return nullptr;
}
« 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