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_sequence.h" | 5 #include "ui/base/gestures/gesture_sequence.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 | 304 |
305 GestureSequence::~GestureSequence() { | 305 GestureSequence::~GestureSequence() { |
306 } | 306 } |
307 | 307 |
308 GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture( | 308 GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture( |
309 const TouchEvent& event, | 309 const TouchEvent& event, |
310 EventResult result) { | 310 EventResult result) { |
311 StopLongPressTimerIfRequired(event); | 311 StopLongPressTimerIfRequired(event); |
312 last_touch_location_ = event.location(); | 312 last_touch_location_ = event.location(); |
313 if (result & ER_ASYNC) | 313 if (result & ER_CONSUMED) |
314 return NULL; | 314 return NULL; |
315 | 315 |
316 // Set a limit on the number of simultaneous touches in a gesture. | 316 // Set a limit on the number of simultaneous touches in a gesture. |
317 if (event.touch_id() >= kMaxGesturePoints) | 317 if (event.touch_id() >= kMaxGesturePoints) |
318 return NULL; | 318 return NULL; |
319 | 319 |
320 if (event.type() == ui::ET_TOUCH_PRESSED) { | 320 if (event.type() == ui::ET_TOUCH_PRESSED) { |
321 if (point_count_ == kMaxGesturePoints) | 321 if (point_count_ == kMaxGesturePoints) |
322 return NULL; | 322 return NULL; |
323 GesturePoint* new_point = &points_[event.touch_id()]; | 323 GesturePoint* new_point = &points_[event.touch_id()]; |
(...skipping 19 matching lines...) Expand all Loading... |
343 RecreateBoundingBox(); | 343 RecreateBoundingBox(); |
344 flags_ = event.flags(); | 344 flags_ = event.flags(); |
345 const int point_id = point.point_id(); | 345 const int point_id = point.point_id(); |
346 if (point_id < 0) | 346 if (point_id < 0) |
347 return NULL; | 347 return NULL; |
348 | 348 |
349 // Send GESTURE_BEGIN for any touch pressed. | 349 // Send GESTURE_BEGIN for any touch pressed. |
350 if (event.type() == ui::ET_TOUCH_PRESSED) | 350 if (event.type() == ui::ET_TOUCH_PRESSED) |
351 AppendBeginGestureEvent(point, gestures.get()); | 351 AppendBeginGestureEvent(point, gestures.get()); |
352 | 352 |
353 CHECK_NE(ER_ASYNC, result); | |
354 TouchStatusInternal status_internal = (result == ER_UNHANDLED) ? | 353 TouchStatusInternal status_internal = (result == ER_UNHANDLED) ? |
355 TSI_NOT_PROCESSED : TSI_PROCESSED; | 354 TSI_NOT_PROCESSED : TSI_PROCESSED; |
356 | 355 |
357 EdgeStateSignatureType signature = Signature(state_, point_id, | 356 EdgeStateSignatureType signature = Signature(state_, point_id, |
358 event.type(), status_internal); | 357 event.type(), status_internal); |
359 | 358 |
360 if (signature == GST_INVALID) | 359 if (signature == GST_INVALID) |
361 signature = Signature(state_, point_id, event.type(), TSI_ALWAYS); | 360 signature = Signature(state_, point_id, event.type(), TSI_ALWAYS); |
362 | 361 |
363 switch (signature) { | 362 switch (signature) { |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 return; | 1080 return; |
1082 | 1081 |
1083 // Since long press timer has been started, there should be a non-NULL point. | 1082 // Since long press timer has been started, there should be a non-NULL point. |
1084 const GesturePoint* point = GetPointByPointId(0); | 1083 const GesturePoint* point = GetPointByPointId(0); |
1085 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), | 1084 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), |
1086 event.location())) | 1085 event.location())) |
1087 long_press_timer_->Stop(); | 1086 long_press_timer_->Stop(); |
1088 } | 1087 } |
1089 | 1088 |
1090 } // namespace ui | 1089 } // namespace ui |
OLD | NEW |