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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "content/browser/renderer_host/input/input_router.h" | 9 #include "content/browser/renderer_host/input/input_router.h" |
10 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" | 10 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return ShouldForwardForZeroVelocityFlingStart(gesture_event) && | 96 return ShouldForwardForZeroVelocityFlingStart(gesture_event) && |
97 ShouldForwardForBounceReduction(gesture_event) && | 97 ShouldForwardForBounceReduction(gesture_event) && |
98 ShouldForwardForGFCFiltering(gesture_event) && | 98 ShouldForwardForGFCFiltering(gesture_event) && |
99 ShouldForwardForTapSuppression(gesture_event) && | 99 ShouldForwardForTapSuppression(gesture_event) && |
100 ShouldForwardForCoalescing(gesture_event); | 100 ShouldForwardForCoalescing(gesture_event); |
101 } | 101 } |
102 | 102 |
103 bool GestureEventQueue::ShouldForwardForZeroVelocityFlingStart( | 103 bool GestureEventQueue::ShouldForwardForZeroVelocityFlingStart( |
104 const GestureEventWithLatencyInfo& gesture_event) const { | 104 const GestureEventWithLatencyInfo& gesture_event) const { |
105 return gesture_event.event.type != WebInputEvent::GestureFlingStart || | 105 return gesture_event.event.type != WebInputEvent::GestureFlingStart || |
106 gesture_event.event.sourceDevice != WebGestureEvent::Touchpad || | 106 gesture_event.event.sourceDevice != blink::WebGestureDeviceTouchpad || |
107 gesture_event.event.data.flingStart.velocityX != 0 || | 107 gesture_event.event.data.flingStart.velocityX != 0 || |
108 gesture_event.event.data.flingStart.velocityY != 0; | 108 gesture_event.event.data.flingStart.velocityY != 0; |
109 } | 109 } |
110 | 110 |
111 bool GestureEventQueue::ShouldForwardForGFCFiltering( | 111 bool GestureEventQueue::ShouldForwardForGFCFiltering( |
112 const GestureEventWithLatencyInfo& gesture_event) const { | 112 const GestureEventWithLatencyInfo& gesture_event) const { |
113 return gesture_event.event.type != WebInputEvent::GestureFlingCancel || | 113 return gesture_event.event.type != WebInputEvent::GestureFlingCancel || |
114 !ShouldDiscardFlingCancelEvent(gesture_event); | 114 !ShouldDiscardFlingCancelEvent(gesture_event); |
115 } | 115 } |
116 | 116 |
117 bool GestureEventQueue::ShouldForwardForTapSuppression( | 117 bool GestureEventQueue::ShouldForwardForTapSuppression( |
118 const GestureEventWithLatencyInfo& gesture_event) { | 118 const GestureEventWithLatencyInfo& gesture_event) { |
119 switch (gesture_event.event.type) { | 119 switch (gesture_event.event.type) { |
120 case WebInputEvent::GestureFlingCancel: | 120 case WebInputEvent::GestureFlingCancel: |
121 if (gesture_event.event.sourceDevice == WebGestureEvent::Touchscreen) | 121 if (gesture_event.event.sourceDevice == blink::WebGestureDeviceTouchpad) |
122 touchscreen_tap_suppression_controller_.GestureFlingCancel(); | 122 touchscreen_tap_suppression_controller_.GestureFlingCancel(); |
123 else | 123 else |
124 touchpad_tap_suppression_controller_.GestureFlingCancel(); | 124 touchpad_tap_suppression_controller_.GestureFlingCancel(); |
125 return true; | 125 return true; |
126 case WebInputEvent::GestureTapDown: | 126 case WebInputEvent::GestureTapDown: |
127 case WebInputEvent::GestureShowPress: | 127 case WebInputEvent::GestureShowPress: |
128 case WebInputEvent::GestureTapUnconfirmed: | 128 case WebInputEvent::GestureTapUnconfirmed: |
129 case WebInputEvent::GestureTapCancel: | 129 case WebInputEvent::GestureTapCancel: |
130 case WebInputEvent::GestureTap: | 130 case WebInputEvent::GestureTap: |
131 case WebInputEvent::GestureDoubleTap: | 131 case WebInputEvent::GestureDoubleTap: |
132 if (gesture_event.event.sourceDevice == WebGestureEvent::Touchscreen) { | 132 if (gesture_event.event.sourceDevice == blink::WebGestureDeviceTouchpad) { |
133 return !touchscreen_tap_suppression_controller_.FilterTapEvent( | 133 return !touchscreen_tap_suppression_controller_.FilterTapEvent( |
134 gesture_event); | 134 gesture_event); |
135 } | 135 } |
136 return true; | 136 return true; |
137 default: | 137 default: |
138 return true; | 138 return true; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 bool GestureEventQueue::ShouldForwardForCoalescing( | 142 bool GestureEventQueue::ShouldForwardForCoalescing( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 DCHECK_EQ(event_with_latency.event.type, type); | 184 DCHECK_EQ(event_with_latency.event.type, type); |
185 event_with_latency.latency.AddNewLatencyFrom(latency); | 185 event_with_latency.latency.AddNewLatencyFrom(latency); |
186 | 186 |
187 // Ack'ing an event may enqueue additional gesture events. By ack'ing the | 187 // Ack'ing an event may enqueue additional gesture events. By ack'ing the |
188 // event before the forwarding of queued events below, such additional events | 188 // event before the forwarding of queued events below, such additional events |
189 // can be coalesced with existing queued events prior to dispatch. | 189 // can be coalesced with existing queued events prior to dispatch. |
190 client_->OnGestureEventAck(event_with_latency, ack_result); | 190 client_->OnGestureEventAck(event_with_latency, ack_result); |
191 | 191 |
192 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); | 192 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); |
193 if (type == WebInputEvent::GestureFlingCancel) { | 193 if (type == WebInputEvent::GestureFlingCancel) { |
194 if (event_with_latency.event.sourceDevice == WebGestureEvent::Touchscreen) | 194 if (event_with_latency.event.sourceDevice == |
| 195 blink::WebGestureDeviceTouchpad) |
195 touchscreen_tap_suppression_controller_.GestureFlingCancelAck(processed); | 196 touchscreen_tap_suppression_controller_.GestureFlingCancelAck(processed); |
196 else | 197 else |
197 touchpad_tap_suppression_controller_.GestureFlingCancelAck(processed); | 198 touchpad_tap_suppression_controller_.GestureFlingCancelAck(processed); |
198 } | 199 } |
199 DCHECK_LT(event_index, coalesced_gesture_events_.size()); | 200 DCHECK_LT(event_index, coalesced_gesture_events_.size()); |
200 coalesced_gesture_events_.erase(coalesced_gesture_events_.begin() + | 201 coalesced_gesture_events_.erase(coalesced_gesture_events_.begin() + |
201 event_index); | 202 event_index); |
202 | 203 |
203 if (ignore_next_ack_) { | 204 if (ignore_next_ack_) { |
204 ignore_next_ack_ = false; | 205 ignore_next_ack_ = false; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 return 0; | 376 return 0; |
376 | 377 |
377 if (!ignore_next_ack_) | 378 if (!ignore_next_ack_) |
378 return 1; | 379 return 1; |
379 | 380 |
380 DCHECK_GT(coalesced_gesture_events_.size(), 1U); | 381 DCHECK_GT(coalesced_gesture_events_.size(), 1U); |
381 return 2; | 382 return 2; |
382 } | 383 } |
383 | 384 |
384 } // namespace content | 385 } // namespace content |
OLD | NEW |