Chromium Code Reviews| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 case GST_INVALID: | 361 case GST_INVALID: |
| 362 break; | 362 break; |
| 363 | 363 |
| 364 case GST_NO_GESTURE_FIRST_PRESSED: | 364 case GST_NO_GESTURE_FIRST_PRESSED: |
| 365 TouchDown(event, point, gestures.get()); | 365 TouchDown(event, point, gestures.get()); |
| 366 set_state(GS_PENDING_SYNTHETIC_CLICK); | 366 set_state(GS_PENDING_SYNTHETIC_CLICK); |
| 367 break; | 367 break; |
| 368 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED: | 368 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED: |
| 369 if (Click(event, point, gestures.get())) | 369 if (Click(event, point, gestures.get())) |
| 370 point.UpdateForTap(); | 370 point.UpdateForTap(); |
| 371 else | |
| 372 AppendTapCancelGestureEvent(point, gestures.get()); | |
| 371 set_state(GS_NO_GESTURE); | 373 set_state(GS_NO_GESTURE); |
| 372 break; | 374 break; |
| 373 case GST_PENDING_SYNTHETIC_CLICK_FIRST_MOVED: | 375 case GST_PENDING_SYNTHETIC_CLICK_FIRST_MOVED: |
| 374 case GST_PENDING_SYNTHETIC_CLICK_FIRST_STATIONARY: | 376 case GST_PENDING_SYNTHETIC_CLICK_FIRST_STATIONARY: |
| 375 if (ScrollStart(event, point, gestures.get())) { | 377 if (ScrollStart(event, point, gestures.get())) { |
| 378 AppendTapCancelGestureEvent(point, gestures.get()); | |
|
sadrul
2012/09/09 18:33:02
This will add TAP_CANCEL after SCROLL_START. I thi
Rick Byers
2012/09/10 00:56:26
Yep, you're right - thanks. I don't think it make
| |
| 376 set_state(GS_SCROLL); | 379 set_state(GS_SCROLL); |
| 377 if (ScrollUpdate(event, point, gestures.get())) | 380 if (ScrollUpdate(event, point, gestures.get())) |
| 378 point.UpdateForScroll(); | 381 point.UpdateForScroll(); |
| 379 } | 382 } |
| 380 break; | 383 break; |
| 381 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED_HANDLED: | 384 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED_HANDLED: |
| 382 case GST_PENDING_SYNTHETIC_CLICK_FIRST_CANCELLED: | 385 case GST_PENDING_SYNTHETIC_CLICK_FIRST_CANCELLED: |
| 386 AppendTapCancelGestureEvent(point, gestures.get()); | |
| 383 set_state(GS_NO_GESTURE); | 387 set_state(GS_NO_GESTURE); |
| 384 break; | 388 break; |
| 385 case GST_SCROLL_FIRST_MOVED: | 389 case GST_SCROLL_FIRST_MOVED: |
| 386 if (scroll_type_ == ST_VERTICAL || | 390 if (scroll_type_ == ST_VERTICAL || |
| 387 scroll_type_ == ST_HORIZONTAL) | 391 scroll_type_ == ST_HORIZONTAL) |
| 388 BreakRailScroll(event, point, gestures.get()); | 392 BreakRailScroll(event, point, gestures.get()); |
| 389 if (ScrollUpdate(event, point, gestures.get())) | 393 if (ScrollUpdate(event, point, gestures.get())) |
| 390 point.UpdateForScroll(); | 394 point.UpdateForScroll(); |
| 391 break; | 395 break; |
| 392 case GST_SCROLL_FIRST_RELEASED: | 396 case GST_SCROLL_FIRST_RELEASED: |
| 393 case GST_SCROLL_FIRST_CANCELLED: | 397 case GST_SCROLL_FIRST_CANCELLED: |
| 394 ScrollEnd(event, point, gestures.get()); | 398 ScrollEnd(event, point, gestures.get()); |
| 395 set_state(GS_NO_GESTURE); | 399 set_state(GS_NO_GESTURE); |
| 396 break; | 400 break; |
| 401 case GST_PENDING_SYNTHETIC_CLICK_SECOND_PRESSED: | |
| 402 AppendTapCancelGestureEvent(point, gestures.get()); | |
| 403 // fall through | |
| 397 case GST_SCROLL_SECOND_PRESSED: | 404 case GST_SCROLL_SECOND_PRESSED: |
| 398 case GST_PENDING_SYNTHETIC_CLICK_SECOND_PRESSED: | |
| 399 if (IsSecondTouchDownCloseEnoughForTwoFingerTap()) { | 405 if (IsSecondTouchDownCloseEnoughForTwoFingerTap()) { |
| 400 TwoFingerTouchDown(event, point, gestures.get()); | 406 TwoFingerTouchDown(event, point, gestures.get()); |
| 401 set_state(GS_PENDING_TWO_FINGER_TAP); | 407 set_state(GS_PENDING_TWO_FINGER_TAP); |
| 402 } else { | 408 } else { |
| 403 PinchStart(event, point, gestures.get()); | 409 PinchStart(event, point, gestures.get()); |
| 404 set_state(GS_PINCH); | 410 set_state(GS_PINCH); |
| 405 } | 411 } |
| 406 break; | 412 break; |
| 407 case GST_PENDING_TWO_FINGER_TAP_FIRST_RELEASED: | 413 case GST_PENDING_TWO_FINGER_TAP_FIRST_RELEASED: |
| 408 case GST_PENDING_TWO_FINGER_TAP_SECOND_RELEASED: | 414 case GST_PENDING_TWO_FINGER_TAP_SECOND_RELEASED: |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point, | 596 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point, |
| 591 Gestures* gestures) { | 597 Gestures* gestures) { |
| 592 gestures->push_back(CreateGestureEvent( | 598 gestures->push_back(CreateGestureEvent( |
| 593 GestureEventDetails(ui::ET_GESTURE_TAP_DOWN, 0, 0), | 599 GestureEventDetails(ui::ET_GESTURE_TAP_DOWN, 0, 0), |
| 594 point.first_touch_position(), | 600 point.first_touch_position(), |
| 595 flags_, | 601 flags_, |
| 596 base::Time::FromDoubleT(point.last_touch_time()), | 602 base::Time::FromDoubleT(point.last_touch_time()), |
| 597 1 << point.touch_id())); | 603 1 << point.touch_id())); |
| 598 } | 604 } |
| 599 | 605 |
| 606 void GestureSequence::AppendTapCancelGestureEvent(const GesturePoint& point, | |
| 607 Gestures* gestures) { | |
| 608 gestures->push_back(CreateGestureEvent( | |
| 609 GestureEventDetails(ui::ET_GESTURE_TAP_CANCEL, 0, 0), | |
| 610 point.first_touch_position(), | |
| 611 flags_, | |
| 612 base::Time::FromDoubleT(point.last_touch_time()), | |
| 613 1 << point.touch_id())); | |
| 614 } | |
| 615 | |
| 600 void GestureSequence::AppendBeginGestureEvent(const GesturePoint& point, | 616 void GestureSequence::AppendBeginGestureEvent(const GesturePoint& point, |
| 601 Gestures* gestures) { | 617 Gestures* gestures) { |
| 602 gestures->push_back(CreateGestureEvent( | 618 gestures->push_back(CreateGestureEvent( |
| 603 GestureEventDetails(ui::ET_GESTURE_BEGIN, 0, 0), | 619 GestureEventDetails(ui::ET_GESTURE_BEGIN, 0, 0), |
| 604 point.first_touch_position(), | 620 point.first_touch_position(), |
| 605 flags_, | 621 flags_, |
| 606 base::Time::FromDoubleT(point.last_touch_time()), | 622 base::Time::FromDoubleT(point.last_touch_time()), |
| 607 1 << point.touch_id())); | 623 1 << point.touch_id())); |
| 608 } | 624 } |
| 609 | 625 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 return; | 1069 return; |
| 1054 | 1070 |
| 1055 // Since long press timer has been started, there should be a non-NULL point. | 1071 // Since long press timer has been started, there should be a non-NULL point. |
| 1056 const GesturePoint* point = GetPointByPointId(0); | 1072 const GesturePoint* point = GetPointByPointId(0); |
| 1057 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), | 1073 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), |
| 1058 event.location())) | 1074 event.location())) |
| 1059 long_press_timer_->Stop(); | 1075 long_press_timer_->Stop(); |
| 1060 } | 1076 } |
| 1061 | 1077 |
| 1062 } // namespace ui | 1078 } // namespace ui |
| OLD | NEW |