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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 bool GestureEventQueue::ShouldForwardForGFCFiltering( | 102 bool GestureEventQueue::ShouldForwardForGFCFiltering( |
103 const GestureEventWithLatencyInfo& gesture_event) const { | 103 const GestureEventWithLatencyInfo& gesture_event) const { |
104 return gesture_event.event.type != WebInputEvent::GestureFlingCancel || | 104 return gesture_event.event.type != WebInputEvent::GestureFlingCancel || |
105 !ShouldDiscardFlingCancelEvent(gesture_event); | 105 !ShouldDiscardFlingCancelEvent(gesture_event); |
106 } | 106 } |
107 | 107 |
108 bool GestureEventQueue::ShouldForwardForTapSuppression( | 108 bool GestureEventQueue::ShouldForwardForTapSuppression( |
109 const GestureEventWithLatencyInfo& gesture_event) { | 109 const GestureEventWithLatencyInfo& gesture_event) { |
110 switch (gesture_event.event.type) { | 110 switch (gesture_event.event.type) { |
111 case WebInputEvent::GestureFlingCancel: | 111 case WebInputEvent::GestureFlingCancel: |
112 if (gesture_event.event.sourceDevice == WebGestureEvent::Touchscreen) | 112 if (gesture_event.event.sourceDevice == |
| 113 blink::WebGestureDeviceTouchscreen) |
113 touchscreen_tap_suppression_controller_.GestureFlingCancel(); | 114 touchscreen_tap_suppression_controller_.GestureFlingCancel(); |
114 else | 115 else |
115 touchpad_tap_suppression_controller_.GestureFlingCancel(); | 116 touchpad_tap_suppression_controller_.GestureFlingCancel(); |
116 return true; | 117 return true; |
117 case WebInputEvent::GestureTapDown: | 118 case WebInputEvent::GestureTapDown: |
118 case WebInputEvent::GestureShowPress: | 119 case WebInputEvent::GestureShowPress: |
119 case WebInputEvent::GestureTapUnconfirmed: | 120 case WebInputEvent::GestureTapUnconfirmed: |
120 case WebInputEvent::GestureTapCancel: | 121 case WebInputEvent::GestureTapCancel: |
121 case WebInputEvent::GestureTap: | 122 case WebInputEvent::GestureTap: |
122 case WebInputEvent::GestureDoubleTap: | 123 case WebInputEvent::GestureDoubleTap: |
123 if (gesture_event.event.sourceDevice == WebGestureEvent::Touchscreen) { | 124 if (gesture_event.event.sourceDevice == |
| 125 blink::WebGestureDeviceTouchscreen) { |
124 return !touchscreen_tap_suppression_controller_.FilterTapEvent( | 126 return !touchscreen_tap_suppression_controller_.FilterTapEvent( |
125 gesture_event); | 127 gesture_event); |
126 } | 128 } |
127 return true; | 129 return true; |
128 default: | 130 default: |
129 return true; | 131 return true; |
130 } | 132 } |
131 } | 133 } |
132 | 134 |
133 bool GestureEventQueue::ShouldForwardForCoalescing( | 135 bool GestureEventQueue::ShouldForwardForCoalescing( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 DCHECK_EQ(event_with_latency.event.type, type); | 177 DCHECK_EQ(event_with_latency.event.type, type); |
176 event_with_latency.latency.AddNewLatencyFrom(latency); | 178 event_with_latency.latency.AddNewLatencyFrom(latency); |
177 | 179 |
178 // Ack'ing an event may enqueue additional gesture events. By ack'ing the | 180 // Ack'ing an event may enqueue additional gesture events. By ack'ing the |
179 // event before the forwarding of queued events below, such additional events | 181 // event before the forwarding of queued events below, such additional events |
180 // can be coalesced with existing queued events prior to dispatch. | 182 // can be coalesced with existing queued events prior to dispatch. |
181 client_->OnGestureEventAck(event_with_latency, ack_result); | 183 client_->OnGestureEventAck(event_with_latency, ack_result); |
182 | 184 |
183 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); | 185 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); |
184 if (type == WebInputEvent::GestureFlingCancel) { | 186 if (type == WebInputEvent::GestureFlingCancel) { |
185 if (event_with_latency.event.sourceDevice == WebGestureEvent::Touchscreen) | 187 if (event_with_latency.event.sourceDevice == |
| 188 blink::WebGestureDeviceTouchscreen) |
186 touchscreen_tap_suppression_controller_.GestureFlingCancelAck(processed); | 189 touchscreen_tap_suppression_controller_.GestureFlingCancelAck(processed); |
187 else | 190 else |
188 touchpad_tap_suppression_controller_.GestureFlingCancelAck(processed); | 191 touchpad_tap_suppression_controller_.GestureFlingCancelAck(processed); |
189 } | 192 } |
190 DCHECK_LT(event_index, coalesced_gesture_events_.size()); | 193 DCHECK_LT(event_index, coalesced_gesture_events_.size()); |
191 coalesced_gesture_events_.erase(coalesced_gesture_events_.begin() + | 194 coalesced_gesture_events_.erase(coalesced_gesture_events_.begin() + |
192 event_index); | 195 event_index); |
193 | 196 |
194 if (ignore_next_ack_) { | 197 if (ignore_next_ack_) { |
195 ignore_next_ack_ = false; | 198 ignore_next_ack_ = false; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 return 0; | 369 return 0; |
367 | 370 |
368 if (!ignore_next_ack_) | 371 if (!ignore_next_ack_) |
369 return 1; | 372 return 1; |
370 | 373 |
371 DCHECK_GT(coalesced_gesture_events_.size(), 1U); | 374 DCHECK_GT(coalesced_gesture_events_.size(), 1U); |
372 return 2; | 375 return 2; |
373 } | 376 } |
374 | 377 |
375 } // namespace content | 378 } // namespace content |
OLD | NEW |