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 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // using the disposition to determine whether a scroll update should be | 48 // using the disposition to determine whether a scroll update should be |
49 // sent. Mobile Safari's default overflow scroll behavior. | 49 // sent. Mobile Safari's default overflow scroll behavior. |
50 TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE, | 50 TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE, |
51 // Send touchmove events throughout a scroll, but throttle sending and | 51 // Send touchmove events throughout a scroll, but throttle sending and |
52 // ignore the ACK as long as scrolling remains possible. Unconsumed scroll | 52 // ignore the ACK as long as scrolling remains possible. Unconsumed scroll |
53 // events return touchmove events to being dispatched synchronously. | 53 // events return touchmove events to being dispatched synchronously. |
54 TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE, | 54 TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE, |
55 TOUCH_SCROLLING_MODE_DEFAULT = TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE | 55 TOUCH_SCROLLING_MODE_DEFAULT = TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE |
56 }; | 56 }; |
57 | 57 |
58 // The |client| must outlive the TouchEventQueue. If | 58 struct CONTENT_EXPORT Config { |
59 // |touchmove_suppression_length_dips| <= 0, touch move suppression is | 59 Config(); |
60 // disabled. | 60 |
61 TouchEventQueue(TouchEventQueueClient* client, | 61 // Determines the bounds of the (square) touchmove slop suppression region. |
62 TouchScrollingMode mode, | 62 // Defaults to 0 (disabled). |
63 double touchmove_suppression_length_dips); | 63 double touchmove_slop_suppression_length_dips; |
| 64 |
| 65 // Determines the type of touch scrolling. |
| 66 // Defaults to TouchEventQueue:::TOUCH_SCROLLING_MODE_DEFAULT. |
| 67 TouchEventQueue::TouchScrollingMode touch_scrolling_mode; |
| 68 |
| 69 // Controls whether touch ack timeouts will trigger touch cancellation. |
| 70 // Defaults to 200ms. |
| 71 base::TimeDelta touch_ack_timeout_delay; |
| 72 |
| 73 // Whether the platform supports touch ack timeout behavior. |
| 74 // Defaults to false (disabled). |
| 75 bool touch_ack_timeout_supported; |
| 76 }; |
| 77 |
| 78 // The |client| must outlive the TouchEventQueue. |
| 79 TouchEventQueue(TouchEventQueueClient* client, const Config& config); |
| 80 |
64 ~TouchEventQueue(); | 81 ~TouchEventQueue(); |
65 | 82 |
66 // Adds an event to the queue. The event may be coalesced with previously | 83 // Adds an event to the queue. The event may be coalesced with previously |
67 // queued events (e.g. consecutive touch-move events can be coalesced into a | 84 // queued events (e.g. consecutive touch-move events can be coalesced into a |
68 // single touch-move event). The event may also be immediately forwarded to | 85 // single touch-move event). The event may also be immediately forwarded to |
69 // the renderer (e.g. when there are no other queued touch event). | 86 // the renderer (e.g. when there are no other queued touch event). |
70 void QueueEvent(const TouchEventWithLatencyInfo& event); | 87 void QueueEvent(const TouchEventWithLatencyInfo& event); |
71 | 88 |
72 // Notifies the queue that a touch-event has been processed by the renderer. | 89 // Notifies the queue that a touch-event has been processed by the renderer. |
73 // At this point, the queue may send one or more gesture events and/or | 90 // At this point, the queue may send one or more gesture events and/or |
(...skipping 14 matching lines...) Expand all Loading... |
88 // Notifies the queue whether the renderer has at least one touch handler. | 105 // Notifies the queue whether the renderer has at least one touch handler. |
89 void OnHasTouchEventHandlers(bool has_handlers); | 106 void OnHasTouchEventHandlers(bool has_handlers); |
90 | 107 |
91 // Returns whether the currently pending touch event (waiting ACK) is for | 108 // Returns whether the currently pending touch event (waiting ACK) is for |
92 // a touch start event. | 109 // a touch start event. |
93 bool IsPendingAckTouchStart() const; | 110 bool IsPendingAckTouchStart() const; |
94 | 111 |
95 // Sets whether a delayed touch ack will cancel and flush the current | 112 // Sets whether a delayed touch ack will cancel and flush the current |
96 // touch sequence. Note that, if the timeout was previously disabled, enabling | 113 // touch sequence. Note that, if the timeout was previously disabled, enabling |
97 // it will take effect only for the following touch sequence. | 114 // it will take effect only for the following touch sequence. |
98 void SetAckTimeoutEnabled(bool enabled, base::TimeDelta ack_timeout_delay); | 115 void SetAckTimeoutEnabled(bool enabled); |
99 | 116 |
100 bool empty() const WARN_UNUSED_RESULT { | 117 bool empty() const WARN_UNUSED_RESULT { |
101 return touch_queue_.empty(); | 118 return touch_queue_.empty(); |
102 } | 119 } |
103 | 120 |
104 size_t size() const { | 121 size_t size() const { |
105 return touch_queue_.size(); | 122 return touch_queue_.size(); |
106 } | 123 } |
107 | 124 |
108 bool ack_timeout_enabled() const { | 125 bool ack_timeout_enabled() const { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 enum TouchFilteringState { | 210 enum TouchFilteringState { |
194 FORWARD_ALL_TOUCHES, // Don't filter at all - the default. | 211 FORWARD_ALL_TOUCHES, // Don't filter at all - the default. |
195 FORWARD_TOUCHES_UNTIL_TIMEOUT, // Don't filter unless we get an ACK timeout. | 212 FORWARD_TOUCHES_UNTIL_TIMEOUT, // Don't filter unless we get an ACK timeout. |
196 DROP_TOUCHES_IN_SEQUENCE, // Filter all events until a new touch | 213 DROP_TOUCHES_IN_SEQUENCE, // Filter all events until a new touch |
197 // sequence is received. | 214 // sequence is received. |
198 DROP_ALL_TOUCHES, // Filter all events, e.g., no touch handler. | 215 DROP_ALL_TOUCHES, // Filter all events, e.g., no touch handler. |
199 TOUCH_FILTERING_STATE_DEFAULT = FORWARD_ALL_TOUCHES, | 216 TOUCH_FILTERING_STATE_DEFAULT = FORWARD_ALL_TOUCHES, |
200 }; | 217 }; |
201 TouchFilteringState touch_filtering_state_; | 218 TouchFilteringState touch_filtering_state_; |
202 | 219 |
203 // Optional handler for timed-out touch event acks, disabled by default. | 220 // Optional handler for timed-out touch event acks. |
204 bool ack_timeout_enabled_; | 221 bool ack_timeout_enabled_; |
205 scoped_ptr<TouchTimeoutHandler> timeout_handler_; | 222 scoped_ptr<TouchTimeoutHandler> timeout_handler_; |
206 | 223 |
207 // Suppression of TouchMove's within a slop region when a sequence has not yet | 224 // Suppression of TouchMove's within a slop region when a sequence has not yet |
208 // been preventDefaulted. | 225 // been preventDefaulted. |
209 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; | 226 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; |
210 | 227 |
211 // Whether touch events should remain buffered and dispatched asynchronously | 228 // Whether touch events should remain buffered and dispatched asynchronously |
212 // while a scroll sequence is active. In this mode, touchmove's are throttled | 229 // while a scroll sequence is active. In this mode, touchmove's are throttled |
213 // and ack'ed immediately, but remain buffered in |pending_async_touch_move_| | 230 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| |
214 // until a sufficient time period has elapsed since the last sent touch event. | 231 // until a sufficient time period has elapsed since the last sent touch event. |
215 // For details see the design doc at http://goo.gl/lVyJAa. | 232 // For details see the design doc at http://goo.gl/lVyJAa. |
216 bool send_touch_events_async_; | 233 bool send_touch_events_async_; |
217 bool needs_async_touch_move_for_outer_slop_region_; | 234 bool needs_async_touchmove_for_outer_slop_region_; |
218 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touch_move_; | 235 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; |
219 double last_sent_touch_timestamp_sec_; | 236 double last_sent_touch_timestamp_sec_; |
220 | 237 |
221 // How touch events are handled during scrolling. For now this is a global | 238 // How touch events are handled during scrolling. For now this is a global |
222 // setting for experimentation, but we may evolve it into an app-controlled | 239 // setting for experimentation, but we may evolve it into an app-controlled |
223 // mode. | 240 // mode. |
224 const TouchScrollingMode touch_scrolling_mode_; | 241 const TouchScrollingMode touch_scrolling_mode_; |
225 | 242 |
226 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 243 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
227 }; | 244 }; |
228 | 245 |
229 } // namespace content | 246 } // namespace content |
230 | 247 |
231 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 248 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
OLD | NEW |