OLD | NEW |
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 return INVALID_PACKET_ORDER; | 161 return INVALID_PACKET_ORDER; |
162 | 162 |
163 if (packet.gesture_source() == GestureEventDataPacket::TOUCH_TIMEOUT && | 163 if (packet.gesture_source() == GestureEventDataPacket::TOUCH_TIMEOUT && |
164 Tail().empty()) { | 164 Tail().empty()) { |
165 // Handle the timeout packet immediately if the packet preceding the timeout | 165 // Handle the timeout packet immediately if the packet preceding the timeout |
166 // has already been dispatched. | 166 // has already been dispatched. |
167 FilterAndSendPacket(packet); | 167 FilterAndSendPacket(packet); |
168 return SUCCESS; | 168 return SUCCESS; |
169 } | 169 } |
170 | 170 |
171 // Check the packet's unique_touch_event_id is valid and unique. | 171 // Check the packet's unique_touch_event_id is valid and unique with the |
| 172 // exception of TOUCH_TIMEOUT packets which have the unique_touch_event_id_ |
| 173 // of 0. |TOUCH_TIMEOUT| packets don't wait for an ack, they are dispatched |
| 174 // as soon as they reach the head of the queue, in |SendAckedEvents|. |
172 if (!Tail().empty()) { | 175 if (!Tail().empty()) { |
173 DCHECK_NE(packet.unique_touch_event_id(), | 176 DCHECK((packet.gesture_source() == GestureEventDataPacket::TOUCH_TIMEOUT) |
174 Tail().back().unique_touch_event_id()); | 177 || (packet.unique_touch_event_id() != |
| 178 Tail().back().unique_touch_event_id())); |
175 } | 179 } |
176 if (!Head().empty()) { | 180 if (!Head().empty()) { |
177 DCHECK_NE(packet.unique_touch_event_id(), | 181 DCHECK_NE(packet.unique_touch_event_id(), |
178 Head().front().unique_touch_event_id()); | 182 Head().front().unique_touch_event_id()); |
| 183 |
179 } | 184 } |
180 | 185 |
181 Tail().push(packet); | 186 Tail().push(packet); |
182 return SUCCESS; | 187 return SUCCESS; |
183 } | 188 } |
184 | 189 |
185 void TouchDispositionGestureFilter::OnTouchEventAck(uint32_t unique_event_id, | 190 void TouchDispositionGestureFilter::OnTouchEventAck(uint32_t unique_event_id, |
186 bool event_consumed) { | 191 bool event_consumed) { |
187 // Spurious asynchronous acks should not trigger a crash. | 192 // Spurious asynchronous acks should not trigger a crash. |
188 if (IsEmpty() || (Head().empty() && sequences_.size() == 1)) | 193 if (IsEmpty() || (Head().empty() && sequences_.size() == 1)) |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 return false; | 472 return false; |
468 } | 473 } |
469 | 474 |
470 bool TouchDispositionGestureFilter::GestureHandlingState:: | 475 bool TouchDispositionGestureFilter::GestureHandlingState:: |
471 HasFilteredGestureType(EventType gesture_type) const { | 476 HasFilteredGestureType(EventType gesture_type) const { |
472 return any_gesture_of_type_dropped_.has_bit( | 477 return any_gesture_of_type_dropped_.has_bit( |
473 GetGestureTypeIndex(gesture_type)); | 478 GetGestureTypeIndex(gesture_type)); |
474 } | 479 } |
475 | 480 |
476 } // namespace content | 481 } // namespace content |
OLD | NEW |