| 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 20 matching lines...) Expand all Loading... |
| 31 const TouchEventWithLatencyInfo& event) = 0; | 31 const TouchEventWithLatencyInfo& event) = 0; |
| 32 | 32 |
| 33 virtual void OnTouchEventAck( | 33 virtual void OnTouchEventAck( |
| 34 const TouchEventWithLatencyInfo& event, | 34 const TouchEventWithLatencyInfo& event, |
| 35 InputEventAckState ack_result) = 0; | 35 InputEventAckState ack_result) = 0; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // A queue for throttling and coalescing touch-events. | 38 // A queue for throttling and coalescing touch-events. |
| 39 class CONTENT_EXPORT TouchEventQueue { | 39 class CONTENT_EXPORT TouchEventQueue { |
| 40 public: | 40 public: |
| 41 // Different ways of dealing with touch events during scrolling. | |
| 42 // TODO(rbyers): Remove this once we're confident that touch move absorption | |
| 43 // is OK. http://crbug.com/350430 | |
| 44 enum TouchScrollingMode { | |
| 45 // Send a touchcancel on scroll start and no further touch events for the | |
| 46 // duration of the scroll. Chrome Android's traditional behavior. | |
| 47 TOUCH_SCROLLING_MODE_TOUCHCANCEL, | |
| 48 // Send touchmove events throughout a scroll, blocking on each ACK and | |
| 49 // using the disposition to determine whether a scroll update should be | |
| 50 // sent. Mobile Safari's default overflow scroll behavior. | |
| 51 TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE, | |
| 52 // Send touchmove events throughout a scroll, but throttle sending and | |
| 53 // ignore the ACK as long as scrolling remains possible. Unconsumed scroll | |
| 54 // events return touchmove events to being dispatched synchronously. | |
| 55 TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE, | |
| 56 TOUCH_SCROLLING_MODE_DEFAULT = TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE | |
| 57 }; | |
| 58 | |
| 59 struct CONTENT_EXPORT Config { | 41 struct CONTENT_EXPORT Config { |
| 60 Config(); | 42 Config(); |
| 61 | 43 |
| 62 // Determines the type of touch scrolling. | |
| 63 // Defaults to TouchEventQueue:::TOUCH_SCROLLING_MODE_DEFAULT. | |
| 64 TouchEventQueue::TouchScrollingMode touch_scrolling_mode; | |
| 65 | |
| 66 // Controls whether touch ack timeouts will trigger touch cancellation. | 44 // Controls whether touch ack timeouts will trigger touch cancellation. |
| 67 // Defaults to 200ms. | 45 // Defaults to 200ms. |
| 68 base::TimeDelta touch_ack_timeout_delay; | 46 base::TimeDelta touch_ack_timeout_delay; |
| 69 | 47 |
| 70 // Whether the platform supports touch ack timeout behavior. | 48 // Whether the platform supports touch ack timeout behavior. |
| 71 // Defaults to false (disabled). | 49 // Defaults to false (disabled). |
| 72 bool touch_ack_timeout_supported; | 50 bool touch_ack_timeout_supported; |
| 73 }; | 51 }; |
| 74 | 52 |
| 75 // The |client| must outlive the TouchEventQueue. | 53 // The |client| must outlive the TouchEventQueue. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // ack after forwarding a touch event to the client. | 182 // ack after forwarding a touch event to the client. |
| 205 bool dispatching_touch_; | 183 bool dispatching_touch_; |
| 206 | 184 |
| 207 // Whether the renderer has at least one touch handler. | 185 // Whether the renderer has at least one touch handler. |
| 208 bool has_handlers_; | 186 bool has_handlers_; |
| 209 | 187 |
| 210 // Whether to allow any remaining touches for the current sequence. Note that | 188 // Whether to allow any remaining touches for the current sequence. Note that |
| 211 // this is a stricter condition than an empty |touch_consumer_states_|, as it | 189 // this is a stricter condition than an empty |touch_consumer_states_|, as it |
| 212 // also prevents forwarding of touchstart events for new pointers in the | 190 // also prevents forwarding of touchstart events for new pointers in the |
| 213 // current sequence. This is only used when the event is synthetically | 191 // current sequence. This is only used when the event is synthetically |
| 214 // cancelled after a touch timeout, or after a scroll event when the | 192 // cancelled after a touch timeout. |
| 215 // mode is TOUCH_SCROLLING_MODE_TOUCHCANCEL. | |
| 216 bool drop_remaining_touches_in_sequence_; | 193 bool drop_remaining_touches_in_sequence_; |
| 217 | 194 |
| 218 // Optional handler for timed-out touch event acks. | 195 // Optional handler for timed-out touch event acks. |
| 219 scoped_ptr<TouchTimeoutHandler> timeout_handler_; | 196 scoped_ptr<TouchTimeoutHandler> timeout_handler_; |
| 220 | 197 |
| 221 // Suppression of TouchMove's within a slop region when a sequence has not yet | 198 // Suppression of TouchMove's within a slop region when a sequence has not yet |
| 222 // been preventDefaulted. | 199 // been preventDefaulted. |
| 223 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; | 200 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; |
| 224 | 201 |
| 225 // Whether touch events should remain buffered and dispatched asynchronously | 202 // Whether touch events should remain buffered and dispatched asynchronously |
| 226 // while a scroll sequence is active. In this mode, touchmove's are throttled | 203 // while a scroll sequence is active. In this mode, touchmove's are throttled |
| 227 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| | 204 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| |
| 228 // until a sufficient time period has elapsed since the last sent touch event. | 205 // until a sufficient time period has elapsed since the last sent touch event. |
| 229 // For details see the design doc at http://goo.gl/lVyJAa. | 206 // For details see the design doc at http://goo.gl/lVyJAa. |
| 230 bool send_touch_events_async_; | 207 bool send_touch_events_async_; |
| 231 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; | 208 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; |
| 232 double last_sent_touch_timestamp_sec_; | 209 double last_sent_touch_timestamp_sec_; |
| 233 | 210 |
| 234 // How touch events are handled during scrolling. For now this is a global | |
| 235 // setting for experimentation, but we may evolve it into an app-controlled | |
| 236 // mode. | |
| 237 const TouchScrollingMode touch_scrolling_mode_; | |
| 238 | |
| 239 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 211 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 240 }; | 212 }; |
| 241 | 213 |
| 242 } // namespace content | 214 } // namespace content |
| 243 | 215 |
| 244 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 216 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |