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

Side by Side Diff: ui/events/gesture_detection/touch_disposition_gesture_filter.cc

Issue 1989623002: Suppressed MEs for gestures from cancelled PEs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a comment. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" 5 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 15 matching lines...) Expand all
26 return GestureEventData(GestureEventDetails(type), 26 return GestureEventData(GestureEventDetails(type),
27 motion_event_id, 27 motion_event_id,
28 primary_tool_type, 28 primary_tool_type,
29 packet.timestamp(), 29 packet.timestamp(),
30 packet.touch_location().x(), 30 packet.touch_location().x(),
31 packet.touch_location().y(), 31 packet.touch_location().y(),
32 packet.raw_touch_location().x(), 32 packet.raw_touch_location().x(),
33 packet.raw_touch_location().y(), 33 packet.raw_touch_location().y(),
34 1, 34 1,
35 gfx::RectF(packet.touch_location(), gfx::SizeF()), 35 gfx::RectF(packet.touch_location(), gfx::SizeF()),
36 flags); 36 flags,
37 0U);
37 } 38 }
38 39
39 enum RequiredTouches { 40 enum RequiredTouches {
40 RT_NONE = 0, 41 RT_NONE = 0,
41 RT_START = 1 << 0, 42 RT_START = 1 << 0,
42 RT_CURRENT = 1 << 1, 43 RT_CURRENT = 1 << 1,
43 }; 44 };
44 45
45 struct DispositionHandlingInfo { 46 struct DispositionHandlingInfo {
46 // A bitwise-OR of |RequiredTouches|. 47 // A bitwise-OR of |RequiredTouches|.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (!Head().empty()) { 181 if (!Head().empty()) {
181 DCHECK_NE(packet.unique_touch_event_id(), 182 DCHECK_NE(packet.unique_touch_event_id(),
182 Head().front().unique_touch_event_id()); 183 Head().front().unique_touch_event_id());
183 184
184 } 185 }
185 186
186 Tail().push(packet); 187 Tail().push(packet);
187 return SUCCESS; 188 return SUCCESS;
188 } 189 }
189 190
190 void TouchDispositionGestureFilter::OnTouchEventAck(uint32_t unique_event_id, 191 void TouchDispositionGestureFilter::OnTouchEventAck(
191 bool event_consumed) { 192 uint32_t unique_touch_event_id, bool event_consumed) {
192 // Spurious asynchronous acks should not trigger a crash. 193 // Spurious asynchronous acks should not trigger a crash.
193 if (IsEmpty() || (Head().empty() && sequences_.size() == 1)) 194 if (IsEmpty() || (Head().empty() && sequences_.size() == 1))
194 return; 195 return;
195 196
196 if (Head().empty()) 197 if (Head().empty())
197 PopGestureSequence(); 198 PopGestureSequence();
198 199
199 if (!Tail().empty() && 200 if (!Tail().empty() &&
200 Tail().back().unique_touch_event_id() == unique_event_id) { 201 Tail().back().unique_touch_event_id() == unique_touch_event_id) {
201 Tail().back().Ack(event_consumed); 202 Tail().back().Ack(event_consumed);
202 if (sequences_.size() == 1 && Tail().size() == 1) 203 if (sequences_.size() == 1 && Tail().size() == 1)
203 SendAckedEvents(); 204 SendAckedEvents();
204 } else { 205 } else {
205 DCHECK(!Head().empty()); 206 DCHECK(!Head().empty());
206 DCHECK_EQ(Head().front().unique_touch_event_id(), unique_event_id); 207 DCHECK_EQ(Head().front().unique_touch_event_id(), unique_touch_event_id);
207 Head().front().Ack(event_consumed); 208 Head().front().Ack(event_consumed);
208 SendAckedEvents(); 209 SendAckedEvents();
209 } 210 }
210 } 211 }
211 212
212 void TouchDispositionGestureFilter::SendAckedEvents() { 213 void TouchDispositionGestureFilter::SendAckedEvents() {
213 // Dispatch all packets corresponding to ack'ed touches, as well as 214 // Dispatch all packets corresponding to ack'ed touches, as well as
214 // any pending timeout-based packets. 215 // any pending timeout-based packets.
215 bool touch_packet_for_current_ack_handled = false; 216 bool touch_packet_for_current_ack_handled = false;
216 while (!IsEmpty() && (!Head().empty() || sequences_.size() != 1)) { 217 while (!IsEmpty() && (!Head().empty() || sequences_.size() != 1)) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } else if (packet.gesture_source() == 298 } else if (packet.gesture_source() ==
298 GestureEventDataPacket::TOUCH_SEQUENCE_END) { 299 GestureEventDataPacket::TOUCH_SEQUENCE_END) {
299 EndScrollIfNecessary(packet); 300 EndScrollIfNecessary(packet);
300 } 301 }
301 // Always send the ET_GESTURE_END event as the last one for every touch event. 302 // Always send the ET_GESTURE_END event as the last one for every touch event.
302 if (gesture_end_index >= 0) 303 if (gesture_end_index >= 0)
303 SendGesture(packet.gesture(gesture_end_index), packet); 304 SendGesture(packet.gesture(gesture_end_index), packet);
304 } 305 }
305 306
306 void TouchDispositionGestureFilter::SendGesture( 307 void TouchDispositionGestureFilter::SendGesture(
307 const GestureEventData& event, 308 const GestureEventData& original_event,
308 const GestureEventDataPacket& packet_being_sent) { 309 const GestureEventDataPacket& packet_being_sent) {
310 GestureEventData event(original_event);
dtapuska 2016/06/03 15:02:11 Wouldn't it make more sense to set the touch_event
mustaq 2016/06/03 20:34:45 Good catch, thanks. I originally got confused with
311 event.unique_touch_event_id = packet_being_sent.unique_touch_event_id();
312
309 // TODO(jdduke): Factor out gesture stream reparation code into a standalone 313 // TODO(jdduke): Factor out gesture stream reparation code into a standalone
310 // utility class. 314 // utility class.
311 switch (event.type()) { 315 switch (event.type()) {
312 case ET_GESTURE_LONG_TAP: 316 case ET_GESTURE_LONG_TAP:
313 if (!needs_tap_ending_event_) 317 if (!needs_tap_ending_event_)
314 return; 318 return;
315 CancelTapIfNecessary(packet_being_sent); 319 CancelTapIfNecessary(packet_being_sent);
316 CancelFlingIfNecessary(packet_being_sent); 320 CancelFlingIfNecessary(packet_being_sent);
317 break; 321 break;
318 case ET_GESTURE_TAP_DOWN: 322 case ET_GESTURE_TAP_DOWN:
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return false; 476 return false;
473 } 477 }
474 478
475 bool TouchDispositionGestureFilter::GestureHandlingState:: 479 bool TouchDispositionGestureFilter::GestureHandlingState::
476 HasFilteredGestureType(EventType gesture_type) const { 480 HasFilteredGestureType(EventType gesture_type) const {
477 return any_gesture_of_type_dropped_.has_bit( 481 return any_gesture_of_type_dropped_.has_bit(
478 GetGestureTypeIndex(gesture_type)); 482 GetGestureTypeIndex(gesture_type));
479 } 483 }
480 484
481 } // namespace content 485 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698