Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // single touch-move event). The event may also be immediately forwarded to | 59 // single touch-move event). The event may also be immediately forwarded to |
| 60 // the renderer (e.g. when there are no other queued touch event). | 60 // the renderer (e.g. when there are no other queued touch event). |
| 61 void QueueEvent(const TouchEventWithLatencyInfo& event); | 61 void QueueEvent(const TouchEventWithLatencyInfo& event); |
| 62 | 62 |
| 63 // Notifies the queue that a touch-event has been processed by the renderer. | 63 // Notifies the queue that a touch-event has been processed by the renderer. |
| 64 // At this point, the queue may send one or more gesture events and/or | 64 // At this point, the queue may send one or more gesture events and/or |
| 65 // additional queued touch-events to the renderer. | 65 // additional queued touch-events to the renderer. |
| 66 void ProcessTouchAck(InputEventAckState ack_result, | 66 void ProcessTouchAck(InputEventAckState ack_result, |
| 67 const ui::LatencyInfo& latency_info); | 67 const ui::LatencyInfo& latency_info); |
| 68 | 68 |
| 69 void ProcessUncancelableTouchMoveAck(); | |
| 70 | |
| 69 // When GestureScrollBegin is received, we send a touch cancel to renderer, | 71 // When GestureScrollBegin is received, we send a touch cancel to renderer, |
| 70 // route all the following touch events directly to client, and ignore the | 72 // route all the following touch events directly to client, and ignore the |
| 71 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, | 73 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, |
| 72 // resume the normal flow of sending touch events to the renderer. | 74 // resume the normal flow of sending touch events to the renderer. |
| 73 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); | 75 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); |
| 74 | 76 |
| 75 void OnGestureEventAck( | 77 void OnGestureEventAck( |
| 76 const GestureEventWithLatencyInfo& event, | 78 const GestureEventWithLatencyInfo& event, |
| 77 InputEventAckState ack_result); | 79 InputEventAckState ack_result); |
| 78 | 80 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 95 bool empty() const WARN_UNUSED_RESULT { | 97 bool empty() const WARN_UNUSED_RESULT { |
| 96 return touch_queue_.empty(); | 98 return touch_queue_.empty(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 size_t size() const { | 101 size_t size() const { |
| 100 return touch_queue_.size(); | 102 return touch_queue_.size(); |
| 101 } | 103 } |
| 102 | 104 |
| 103 bool has_handlers() const { return has_handlers_; } | 105 bool has_handlers() const { return has_handlers_; } |
| 104 | 106 |
| 107 int SentUncancelableTouchMoveCount() const { | |
| 108 return sent_uncancelable_touch_move_count_; | |
| 109 } | |
| 110 | |
| 105 private: | 111 private: |
| 106 class TouchTimeoutHandler; | 112 class TouchTimeoutHandler; |
| 107 class TouchMoveSlopSuppressor; | 113 class TouchMoveSlopSuppressor; |
| 108 friend class TouchTimeoutHandler; | 114 friend class TouchTimeoutHandler; |
| 109 friend class TouchEventQueueTest; | 115 friend class TouchEventQueueTest; |
| 110 | 116 |
| 111 bool HasPendingAsyncTouchMoveForTesting() const; | 117 bool HasPendingAsyncTouchMoveForTesting() const; |
| 112 bool IsTimeoutRunningForTesting() const; | 118 bool IsTimeoutRunningForTesting() const; |
| 113 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const; | 119 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const; |
| 114 | 120 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 // been preventDefaulted. | 201 // been preventDefaulted. |
| 196 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; | 202 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; |
| 197 | 203 |
| 198 // Whether touch events should remain buffered and dispatched asynchronously | 204 // Whether touch events should remain buffered and dispatched asynchronously |
| 199 // while a scroll sequence is active. In this mode, touchmove's are throttled | 205 // while a scroll sequence is active. In this mode, touchmove's are throttled |
| 200 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| | 206 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| |
| 201 // until a sufficient time period has elapsed since the last sent touch event. | 207 // until a sufficient time period has elapsed since the last sent touch event. |
| 202 // For details see the design doc at http://goo.gl/lVyJAa. | 208 // For details see the design doc at http://goo.gl/lVyJAa. |
| 203 bool send_touch_events_async_; | 209 bool send_touch_events_async_; |
| 204 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; | 210 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; |
| 211 | |
| 212 // For uncancelable touch moves, not only we send a fake ack, but also a real | |
| 213 // ack from render, which we use to decide when to send the next touch move. | |
|
tdresser
2015/03/26 15:25:29
when to send the next async touch move move.
lanwei
2015/03/27 04:39:41
Done.
| |
| 214 // This can help avoid the touch event queue keep growing when render handles | |
| 215 // touchmove slow. We use sent_uncancelable_touch_move_count_ to count the | |
| 216 // number of uncancelable touch moves sent out are waiting for | |
| 217 // their acks back from render. | |
| 218 int sent_uncancelable_touch_move_count_; | |
|
tdresser
2015/03/26 15:25:29
How about uncancelable_touch_moves_pending_ack_cou
lanwei
2015/03/27 04:39:41
Done.
| |
| 205 double last_sent_touch_timestamp_sec_; | 219 double last_sent_touch_timestamp_sec_; |
| 206 | 220 |
| 207 // Event is saved to compare pointer positions for new touchmove events. | 221 // Event is saved to compare pointer positions for new touchmove events. |
| 208 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; | 222 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; |
| 209 | 223 |
| 210 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 224 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 211 }; | 225 }; |
| 212 | 226 |
| 213 } // namespace content | 227 } // namespace content |
| 214 | 228 |
| 215 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 229 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |