OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/gestures/gesture_recognizer_impl.h" | 5 #include "ui/base/gestures/gesture_recognizer_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "ui/base/events.h" | 10 #include "ui/base/events.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return gesture_sequence->ProcessTouchEventForGesture(event, status); | 190 return gesture_sequence->ProcessTouchEventForGesture(event, status); |
191 } | 191 } |
192 | 192 |
193 void GestureRecognizerImpl::QueueTouchEventForGesture(GestureConsumer* consumer, | 193 void GestureRecognizerImpl::QueueTouchEventForGesture(GestureConsumer* consumer, |
194 const TouchEvent& event) { | 194 const TouchEvent& event) { |
195 if (!event_queue_[consumer]) | 195 if (!event_queue_[consumer]) |
196 event_queue_[consumer] = new std::queue<TouchEvent*>(); | 196 event_queue_[consumer] = new std::queue<TouchEvent*>(); |
197 event_queue_[consumer]->push(event.Copy()); | 197 event_queue_[consumer]->push(event.Copy()); |
198 } | 198 } |
199 | 199 |
| 200 bool GestureRecognizerImpl::IsQueueEmpty(GestureConsumer* consumer) { |
| 201 return !event_queue_[consumer] || event_queue_[consumer]->empty(); |
| 202 } |
| 203 |
200 GestureSequence::Gestures* GestureRecognizerImpl::AdvanceTouchQueue( | 204 GestureSequence::Gestures* GestureRecognizerImpl::AdvanceTouchQueue( |
201 GestureConsumer* consumer, | 205 GestureConsumer* consumer, |
202 bool processed) { | 206 bool processed) { |
203 if (!event_queue_[consumer] || event_queue_[consumer]->empty()) { | 207 if (!event_queue_[consumer] || event_queue_[consumer]->empty()) { |
204 LOG(ERROR) << "Trying to advance an empty gesture queue for " << consumer; | 208 LOG(ERROR) << "Trying to advance an empty gesture queue for " << consumer; |
205 return NULL; | 209 return NULL; |
206 } | 210 } |
207 | 211 |
208 ScopedPop pop(event_queue_[consumer]); | 212 ScopedPop pop(event_queue_[consumer]); |
209 TouchEvent* event = event_queue_[consumer]->front(); | 213 TouchEvent* event = event_queue_[consumer]->front(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 if (touch_id_target_for_gestures_.count(touch_id)) | 258 if (touch_id_target_for_gestures_.count(touch_id)) |
255 touch_id_target_for_gestures_.erase(touch_id); | 259 touch_id_target_for_gestures_.erase(touch_id); |
256 } | 260 } |
257 | 261 |
258 // GestureRecognizer, static | 262 // GestureRecognizer, static |
259 GestureRecognizer* GestureRecognizer::Create(GestureEventHelper* helper) { | 263 GestureRecognizer* GestureRecognizer::Create(GestureEventHelper* helper) { |
260 return new GestureRecognizerImpl(helper); | 264 return new GestureRecognizerImpl(helper); |
261 } | 265 } |
262 | 266 |
263 } // namespace ui | 267 } // namespace ui |
OLD | NEW |