OLD | NEW |
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 "content/browser/renderer_host/input/gesture_event_queue.h" | 5 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" | 8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" |
9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" | 9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 gesture_transform.Translate(gesture_event.event.x, gesture_event.event.y); | 47 gesture_transform.Translate(gesture_event.event.x, gesture_event.event.y); |
48 } else { | 48 } else { |
49 NOTREACHED() << "Invalid event type for transform retrieval: " | 49 NOTREACHED() << "Invalid event type for transform retrieval: " |
50 << WebInputEventTraits::GetName(gesture_event.event.type); | 50 << WebInputEventTraits::GetName(gesture_event.event.type); |
51 } | 51 } |
52 return gesture_transform; | 52 return gesture_transform; |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 GestureEventQueue::Config::Config() { | 57 GestureEventQueue::Config::Config() : enable_fling_cancel_filtering(true) { |
58 } | 58 } |
59 | 59 |
60 GestureEventQueue::GestureEventQueue( | 60 GestureEventQueue::GestureEventQueue( |
61 GestureEventQueueClient* client, | 61 GestureEventQueueClient* client, |
62 TouchpadTapSuppressionControllerClient* touchpad_client, | 62 TouchpadTapSuppressionControllerClient* touchpad_client, |
63 const Config& config) | 63 const Config& config) |
64 : client_(client), | 64 : client_(client), |
| 65 enable_fling_cancel_filtering_(config.enable_fling_cancel_filtering), |
65 active_fling_count_(0), | 66 active_fling_count_(0), |
66 scrolling_in_progress_(false), | 67 scrolling_in_progress_(false), |
67 ignore_next_ack_(false), | 68 ignore_next_ack_(false), |
68 touchpad_tap_suppression_controller_( | 69 touchpad_tap_suppression_controller_( |
69 touchpad_client, | 70 touchpad_client, |
70 config.touchpad_tap_suppression_config), | 71 config.touchpad_tap_suppression_config), |
71 touchscreen_tap_suppression_controller_( | 72 touchscreen_tap_suppression_controller_( |
72 this, | 73 this, |
73 config.touchscreen_tap_suppression_config), | 74 config.touchscreen_tap_suppression_config), |
74 debounce_interval_(config.debounce_interval) { | 75 debounce_interval_(config.debounce_interval) { |
(...skipping 10 matching lines...) Expand all Loading... |
85 !ShouldForwardForGFCFiltering(gesture_event) || | 86 !ShouldForwardForGFCFiltering(gesture_event) || |
86 !ShouldForwardForTapSuppression(gesture_event)) { | 87 !ShouldForwardForTapSuppression(gesture_event)) { |
87 return; | 88 return; |
88 } | 89 } |
89 | 90 |
90 QueueAndForwardIfNecessary(gesture_event); | 91 QueueAndForwardIfNecessary(gesture_event); |
91 } | 92 } |
92 | 93 |
93 bool GestureEventQueue::ShouldDiscardFlingCancelEvent( | 94 bool GestureEventQueue::ShouldDiscardFlingCancelEvent( |
94 const GestureEventWithLatencyInfo& gesture_event) const { | 95 const GestureEventWithLatencyInfo& gesture_event) const { |
| 96 if (!enable_fling_cancel_filtering_) |
| 97 return false; |
| 98 |
95 GestureQueue::const_reverse_iterator it = | 99 GestureQueue::const_reverse_iterator it = |
96 coalesced_gesture_events_.rbegin(); | 100 coalesced_gesture_events_.rbegin(); |
97 while (it != coalesced_gesture_events_.rend()) { | 101 while (it != coalesced_gesture_events_.rend()) { |
98 if (it->event.type == WebInputEvent::GestureFlingStart) | 102 if (it->event.type == WebInputEvent::GestureFlingStart) |
99 return false; | 103 return false; |
100 if (it->event.type == WebInputEvent::GestureFlingCancel) | 104 if (it->event.type == WebInputEvent::GestureFlingCancel) |
101 return true; | 105 return true; |
102 it++; | 106 it++; |
103 } | 107 } |
104 // If there are no fling-affecting events in the queue, and there's still an | 108 // If there are no fling-affecting events in the queue, and there's still an |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 return 0; | 393 return 0; |
390 | 394 |
391 if (!ignore_next_ack_) | 395 if (!ignore_next_ack_) |
392 return 1; | 396 return 1; |
393 | 397 |
394 DCHECK_GT(coalesced_gesture_events_.size(), 1U); | 398 DCHECK_GT(coalesced_gesture_events_.size(), 1U); |
395 return 2; | 399 return 2; |
396 } | 400 } |
397 | 401 |
398 } // namespace content | 402 } // namespace content |
OLD | NEW |