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

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

Issue 660663002: Clear pending events upon main frame navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates Created 6 years, 1 month 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
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/events/gesture_event_details.h" 9 #include "ui/events/gesture_event_details.h"
10 10
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return; 176 return;
177 177
178 if (Head().empty()) 178 if (Head().empty())
179 PopGestureSequence(); 179 PopGestureSequence();
180 180
181 GestureSequence& sequence = Head(); 181 GestureSequence& sequence = Head();
182 182
183 // Dispatch the packet corresponding to the ack'ed touch, as well as any 183 // Dispatch the packet corresponding to the ack'ed touch, as well as any
184 // additional timeout-based packets queued before the ack was received. 184 // additional timeout-based packets queued before the ack was received.
185 bool touch_packet_for_current_ack_handled = false; 185 bool touch_packet_for_current_ack_handled = false;
186 bool sequence_cancelled = false;
186 while (!sequence.empty()) { 187 while (!sequence.empty()) {
187 DCHECK_NE(sequence.front().gesture_source(), 188 DCHECK_NE(sequence.front().gesture_source(),
188 GestureEventDataPacket::UNDEFINED); 189 GestureEventDataPacket::UNDEFINED);
189 DCHECK_NE(sequence.front().gesture_source(), 190 DCHECK_NE(sequence.front().gesture_source(),
190 GestureEventDataPacket::INVALID); 191 GestureEventDataPacket::INVALID);
191 192
192 GestureEventDataPacket::GestureSource source = 193 GestureEventDataPacket::GestureSource source =
193 sequence.front().gesture_source(); 194 sequence.front().gesture_source();
194 if (source != GestureEventDataPacket::TOUCH_TIMEOUT) { 195 if (source != GestureEventDataPacket::TOUCH_TIMEOUT) {
195 // We should handle at most one non-timeout based packet. 196 // We should handle at most one non-timeout based packet.
196 if (touch_packet_for_current_ack_handled) 197 if (touch_packet_for_current_ack_handled)
197 break; 198 break;
198 state_.OnTouchEventAck(event_consumed, IsTouchStartEvent(source)); 199 state_.OnTouchEventAck(event_consumed, IsTouchStartEvent(source));
199 touch_packet_for_current_ack_handled = true; 200 touch_packet_for_current_ack_handled = true;
201 sequence_cancelled =
202 source == GestureEventDataPacket::TOUCH_SEQUENCE_CANCEL;
200 } 203 }
201 // We need to pop the current sequence before sending the packet, because 204 // We need to pop the current sequence before sending the packet, because
202 // sending the packet could result in this method being re-entered (e.g. on 205 // sending the packet could result in this method being re-entered (e.g. on
203 // Aura, we could trigger a touch-cancel). As popping the sequence destroys 206 // Aura, we could trigger a touch-cancel). As popping the sequence destroys
204 // the packet, we copy the packet before popping it. 207 // the packet, we copy the packet before popping it.
205 const GestureEventDataPacket packet = sequence.front(); 208 const GestureEventDataPacket packet = sequence.front();
206 sequence.pop(); 209 sequence.pop();
207 FilterAndSendPacket(packet); 210 FilterAndSendPacket(packet);
208 } 211 }
212
213 if (sequence.empty() && sequence_cancelled)
214 PopGestureSequence();
215
209 DCHECK(touch_packet_for_current_ack_handled); 216 DCHECK(touch_packet_for_current_ack_handled);
210 } 217 }
211 218
212 bool TouchDispositionGestureFilter::IsEmpty() const { 219 bool TouchDispositionGestureFilter::IsEmpty() const {
213 return sequences_.empty(); 220 return sequences_.empty();
214 } 221 }
215 222
216 void TouchDispositionGestureFilter::FilterAndSendPacket( 223 void TouchDispositionGestureFilter::FilterAndSendPacket(
217 const GestureEventDataPacket& packet) { 224 const GestureEventDataPacket& packet) {
218 if (packet.gesture_source() == GestureEventDataPacket::TOUCH_SEQUENCE_START) { 225 if (packet.gesture_source() == GestureEventDataPacket::TOUCH_SEQUENCE_START) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 last_gesture_of_type_dropped_.has_bit( 425 last_gesture_of_type_dropped_.has_bit(
419 GetGestureTypeIndex(antecedent_event_type)))) { 426 GetGestureTypeIndex(antecedent_event_type)))) {
420 last_gesture_of_type_dropped_.mark_bit(GetGestureTypeIndex(gesture_type)); 427 last_gesture_of_type_dropped_.mark_bit(GetGestureTypeIndex(gesture_type));
421 return true; 428 return true;
422 } 429 }
423 last_gesture_of_type_dropped_.clear_bit(GetGestureTypeIndex(gesture_type)); 430 last_gesture_of_type_dropped_.clear_bit(GetGestureTypeIndex(gesture_type));
424 return false; 431 return false;
425 } 432 }
426 433
427 } // namespace content 434 } // namespace content
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698