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

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

Issue 549333002: Always send the ET_GESTURE_END event as the last one for every touch event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add cast to index Created 6 years, 3 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 | « no previous file | ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gesture_detection/touch_disposition_gesture_filter.cc
diff --git a/ui/events/gesture_detection/touch_disposition_gesture_filter.cc b/ui/events/gesture_detection/touch_disposition_gesture_filter.cc
index 323c7aafd04d98327c58b1fb4d63d5112a9163bb..33c8d4322f4ef12edeeb75a2f3f6715b0c6c3a21 100644
--- a/ui/events/gesture_detection/touch_disposition_gesture_filter.cc
+++ b/ui/events/gesture_detection/touch_disposition_gesture_filter.cc
@@ -219,7 +219,7 @@ void TouchDispositionGestureFilter::FilterAndSendPacket(
} else if (packet.gesture_source() == GestureEventDataPacket::TOUCH_START) {
CancelTapIfNecessary(packet);
}
-
+ int gesture_end_index = -1;
for (size_t i = 0; i < packet.gesture_count(); ++i) {
const GestureEventData& gesture = packet.gesture(i);
DCHECK_GE(gesture.details.type(), ET_GESTURE_TYPE_START);
@@ -232,9 +232,20 @@ void TouchDispositionGestureFilter::FilterAndSendPacket(
// Sending a timed gesture could delete |this|, so we need to return
// directly after the |SendGesture| call.
SendGesture(gesture, packet);
+ // We should not have a timeout gesture and other gestures in the same
+ // packet.
+ DCHECK_EQ(1U, packet.gesture_count());
return;
}
-
+ // Occasionally scroll or tap cancel events are synthesized when a touch
+ // sequence has been canceled or terminated, we want to make sure that
+ // ET_GESTURE_END always happens after them.
+ if (gesture.type() == ET_GESTURE_END) {
+ // Make sure there is at most one ET_GESTURE_END event in each packet.
+ DCHECK_EQ(-1, gesture_end_index);
+ gesture_end_index = static_cast<int>(i);
+ continue;
+ }
SendGesture(gesture, packet);
}
@@ -246,6 +257,9 @@ void TouchDispositionGestureFilter::FilterAndSendPacket(
GestureEventDataPacket::TOUCH_SEQUENCE_END) {
EndScrollIfNecessary(packet);
}
+ // Always send the ET_GESTURE_END event as the last one for every touch event.
+ if (gesture_end_index >= 0)
+ SendGesture(packet.gesture(gesture_end_index), packet);
}
void TouchDispositionGestureFilter::SendGesture(
« no previous file with comments | « no previous file | ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698