| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" | 5 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 9 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 return false; | 37 return false; |
| 38 stashed_tap_down_.reset(new GestureEventWithLatencyInfo(event)); | 38 stashed_tap_down_.reset(new GestureEventWithLatencyInfo(event)); |
| 39 return true; | 39 return true; |
| 40 | 40 |
| 41 case WebInputEvent::GestureShowPress: | 41 case WebInputEvent::GestureShowPress: |
| 42 if (!stashed_tap_down_) | 42 if (!stashed_tap_down_) |
| 43 return false; | 43 return false; |
| 44 stashed_show_press_.reset(new GestureEventWithLatencyInfo(event)); | 44 stashed_show_press_.reset(new GestureEventWithLatencyInfo(event)); |
| 45 return true; | 45 return true; |
| 46 | 46 |
| 47 case WebInputEvent::GestureLongPress: |
| 48 // It is possible that a GestureLongPress arrives after tapDownTimer |
| 49 // expiration, in this case it should still get filtered if the |
| 50 // controller suppresses the tap end events. |
| 51 if (!stashed_tap_down_) |
| 52 return controller_.ShouldSuppressTapEnd(); |
| 53 |
| 54 stashed_long_press_.reset(new GestureEventWithLatencyInfo(event)); |
| 55 return true; |
| 56 |
| 47 case WebInputEvent::GestureTapUnconfirmed: | 57 case WebInputEvent::GestureTapUnconfirmed: |
| 48 return !!stashed_tap_down_; | 58 return !!stashed_tap_down_; |
| 49 | 59 |
| 50 case WebInputEvent::GestureTapCancel: | 60 case WebInputEvent::GestureTapCancel: |
| 51 case WebInputEvent::GestureTap: | 61 case WebInputEvent::GestureTap: |
| 52 case WebInputEvent::GestureDoubleTap: | 62 case WebInputEvent::GestureDoubleTap: |
| 63 case WebInputEvent::GestureLongTap: |
| 64 case WebInputEvent::GestureTwoFingerTap: |
| 53 return controller_.ShouldSuppressTapEnd(); | 65 return controller_.ShouldSuppressTapEnd(); |
| 54 | 66 |
| 55 default: | 67 default: |
| 56 break; | 68 break; |
| 57 } | 69 } |
| 58 return false; | 70 return false; |
| 59 } | 71 } |
| 60 | 72 |
| 61 void TouchscreenTapSuppressionController::DropStashedTapDown() { | 73 void TouchscreenTapSuppressionController::DropStashedTapDown() { |
| 62 stashed_tap_down_.reset(); | 74 stashed_tap_down_.reset(); |
| 63 stashed_show_press_.reset(); | 75 stashed_show_press_.reset(); |
| 76 stashed_long_press_.reset(); |
| 77 } |
| 78 |
| 79 void TouchscreenTapSuppressionController::ForwardStashedGestureEvents() { |
| 80 DCHECK(stashed_tap_down_); |
| 81 ScopedGestureEvent tap_down = std::move(stashed_tap_down_); |
| 82 ScopedGestureEvent show_press = std::move(stashed_show_press_); |
| 83 ScopedGestureEvent long_press = std::move(stashed_long_press_); |
| 84 gesture_event_queue_->ForwardGestureEvent(*tap_down); |
| 85 if (show_press) |
| 86 gesture_event_queue_->ForwardGestureEvent(*show_press); |
| 87 if (long_press) |
| 88 gesture_event_queue_->ForwardGestureEvent(*long_press); |
| 64 } | 89 } |
| 65 | 90 |
| 66 void TouchscreenTapSuppressionController::ForwardStashedTapDown() { | 91 void TouchscreenTapSuppressionController::ForwardStashedTapDown() { |
| 67 DCHECK(stashed_tap_down_); | 92 DCHECK(stashed_tap_down_); |
| 68 ScopedGestureEvent tap_down = std::move(stashed_tap_down_); | 93 ScopedGestureEvent tap_down = std::move(stashed_tap_down_); |
| 69 ScopedGestureEvent show_press = std::move(stashed_show_press_); | |
| 70 gesture_event_queue_->ForwardGestureEvent(*tap_down); | 94 gesture_event_queue_->ForwardGestureEvent(*tap_down); |
| 71 if (show_press) | 95 stashed_show_press_.reset(); |
| 72 gesture_event_queue_->ForwardGestureEvent(*show_press); | 96 stashed_long_press_.reset(); |
| 73 } | 97 } |
| 74 | 98 |
| 75 } // namespace content | 99 } // namespace content |
| OLD | NEW |