| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // ack after forwarding a touch event to the client. | 183 // ack after forwarding a touch event to the client. |
| 206 bool dispatching_touch_; | 184 bool dispatching_touch_; |
| 207 | 185 |
| 208 // Whether the renderer has at least one touch handler. | 186 // Whether the renderer has at least one touch handler. |
| 209 bool has_handlers_; | 187 bool has_handlers_; |
| 210 | 188 |
| 211 // Whether to allow any remaining touches for the current sequence. Note that | 189 // Whether to allow any remaining touches for the current sequence. Note that |
| 212 // this is a stricter condition than an empty |touch_consumer_states_|, as it | 190 // this is a stricter condition than an empty |touch_consumer_states_|, as it |
| 213 // also prevents forwarding of touchstart events for new pointers in the | 191 // also prevents forwarding of touchstart events for new pointers in the |
| 214 // current sequence. This is only used when the event is synthetically | 192 // current sequence. This is only used when the event is synthetically |
| 215 // cancelled after a touch timeout, or after a scroll event when the | 193 // cancelled after a touch timeout. |
| 216 // mode is TOUCH_SCROLLING_MODE_TOUCHCANCEL. | |
| 217 bool drop_remaining_touches_in_sequence_; | 194 bool drop_remaining_touches_in_sequence_; |
| 218 | 195 |
| 219 // Optional handler for timed-out touch event acks. | 196 // Optional handler for timed-out touch event acks. |
| 220 scoped_ptr<TouchTimeoutHandler> timeout_handler_; | 197 scoped_ptr<TouchTimeoutHandler> timeout_handler_; |
| 221 | 198 |
| 222 // Suppression of TouchMove's within a slop region when a sequence has not yet | 199 // Suppression of TouchMove's within a slop region when a sequence has not yet |
| 223 // been preventDefaulted. | 200 // been preventDefaulted. |
| 224 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; | 201 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; |
| 225 | 202 |
| 226 // Whether touch events should remain buffered and dispatched asynchronously | 203 // Whether touch events should remain buffered and dispatched asynchronously |
| 227 // while a scroll sequence is active. In this mode, touchmove's are throttled | 204 // while a scroll sequence is active. In this mode, touchmove's are throttled |
| 228 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| | 205 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| |
| 229 // until a sufficient time period has elapsed since the last sent touch event. | 206 // until a sufficient time period has elapsed since the last sent touch event. |
| 230 // For details see the design doc at http://goo.gl/lVyJAa. | 207 // For details see the design doc at http://goo.gl/lVyJAa. |
| 231 bool send_touch_events_async_; | 208 bool send_touch_events_async_; |
| 232 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; | 209 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; |
| 233 double last_sent_touch_timestamp_sec_; | 210 double last_sent_touch_timestamp_sec_; |
| 234 | 211 |
| 235 // How touch events are handled during scrolling. For now this is a global | |
| 236 // setting for experimentation, but we may evolve it into an app-controlled | |
| 237 // mode. | |
| 238 const TouchScrollingMode touch_scrolling_mode_; | |
| 239 | |
| 240 // Event is saved to compare pointer positions for new touchmove events. | 212 // Event is saved to compare pointer positions for new touchmove events. |
| 241 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; | 213 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; |
| 242 | 214 |
| 243 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 215 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 244 }; | 216 }; |
| 245 | 217 |
| 246 } // namespace content | 218 } // namespace content |
| 247 | 219 |
| 248 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 220 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |