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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // resume the normal flow of sending touch events to the renderer. | 79 // resume the normal flow of sending touch events to the renderer. |
80 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); | 80 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); |
81 | 81 |
82 void OnGestureEventAck( | 82 void OnGestureEventAck( |
83 const GestureEventWithLatencyInfo& event, | 83 const GestureEventWithLatencyInfo& event, |
84 InputEventAckState ack_result); | 84 InputEventAckState ack_result); |
85 | 85 |
86 // Notifies the queue whether the renderer has at least one touch handler. | 86 // Notifies the queue whether the renderer has at least one touch handler. |
87 void OnHasTouchEventHandlers(bool has_handlers); | 87 void OnHasTouchEventHandlers(bool has_handlers); |
88 | 88 |
| 89 // Notifies the queue whether the renderer has at least one touchmove handler. |
| 90 void OnHasTouchMoveEventHandlers(bool has_handlers); |
| 91 |
89 // Returns whether the currently pending touch event (waiting ACK) is for | 92 // Returns whether the currently pending touch event (waiting ACK) is for |
90 // a touch start event. | 93 // a touch start event. |
91 bool IsPendingAckTouchStart() const; | 94 bool IsPendingAckTouchStart() const; |
92 | 95 |
93 // Sets whether a delayed touch ack will cancel and flush the current | 96 // Sets whether a delayed touch ack will cancel and flush the current |
94 // touch sequence. Note that, if the timeout was previously disabled, enabling | 97 // touch sequence. Note that, if the timeout was previously disabled, enabling |
95 // it will take effect only for the following touch sequence. | 98 // it will take effect only for the following touch sequence. |
96 void SetAckTimeoutEnabled(bool enabled); | 99 void SetAckTimeoutEnabled(bool enabled); |
97 | 100 |
98 // Sets whether the current site has a mobile friendly viewport. This | 101 // Sets whether the current site has a mobile friendly viewport. This |
99 // determines which ack timeout delay will be used for *future* touch events. | 102 // determines which ack timeout delay will be used for *future* touch events. |
100 // The default assumption is that the site is *not* mobile-optimized. | 103 // The default assumption is that the site is *not* mobile-optimized. |
101 void SetIsMobileOptimizedSite(bool mobile_optimized_site); | 104 void SetIsMobileOptimizedSite(bool mobile_optimized_site); |
102 | 105 |
103 // Whether ack timeout behavior is supported and enabled for the current site. | 106 // Whether ack timeout behavior is supported and enabled for the current site. |
104 bool IsAckTimeoutEnabled() const; | 107 bool IsAckTimeoutEnabled() const; |
105 | 108 |
106 bool IsForwardingTouches(); | 109 bool IsForwardingTouches(); |
107 | 110 |
108 bool empty() const WARN_UNUSED_RESULT { | 111 bool empty() const WARN_UNUSED_RESULT { |
109 return touch_queue_.empty(); | 112 return touch_queue_.empty(); |
110 } | 113 } |
111 | 114 |
112 size_t size() const { | 115 size_t size() const { |
113 return touch_queue_.size(); | 116 return touch_queue_.size(); |
114 } | 117 } |
115 | 118 |
116 bool has_handlers() const { return has_handlers_; } | 119 bool has_handlers() const { return has_handlers_ || has_move_handlers_; } |
117 | 120 |
118 size_t uncancelable_touch_moves_pending_ack_count() const { | 121 size_t uncancelable_touch_moves_pending_ack_count() const { |
119 return ack_pending_async_touchmove_ids_.size(); | 122 return ack_pending_async_touchmove_ids_.size(); |
120 } | 123 } |
121 | 124 |
122 private: | 125 private: |
123 class TouchTimeoutHandler; | 126 class TouchTimeoutHandler; |
124 class TouchMoveSlopSuppressor; | 127 class TouchMoveSlopSuppressor; |
125 friend class TouchTimeoutHandler; | 128 friend class TouchTimeoutHandler; |
126 friend class TouchEventQueueTest; | 129 friend class TouchEventQueueTest; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool dispatching_touch_ack_; | 193 bool dispatching_touch_ack_; |
191 | 194 |
192 // Used to prevent touch timeout scheduling and increase the count for async | 195 // Used to prevent touch timeout scheduling and increase the count for async |
193 // touchmove if we receive a synchronous ack after forwarding a touch event | 196 // touchmove if we receive a synchronous ack after forwarding a touch event |
194 // to the client. | 197 // to the client. |
195 bool dispatching_touch_; | 198 bool dispatching_touch_; |
196 | 199 |
197 // Whether the renderer has at least one touch handler. | 200 // Whether the renderer has at least one touch handler. |
198 bool has_handlers_; | 201 bool has_handlers_; |
199 | 202 |
| 203 // Whether the renderer has at least one touchmove handler. |
| 204 bool has_move_handlers_; |
| 205 |
200 // Whether any pointer in the touch sequence reported having a consumer. | 206 // Whether any pointer in the touch sequence reported having a consumer. |
201 bool has_handler_for_current_sequence_; | 207 bool has_handler_for_current_sequence_; |
202 | 208 |
203 // Whether to allow any remaining touches for the current sequence. Note that | 209 // Whether to allow any remaining touches for the current sequence. Note that |
204 // this is a stricter condition than an empty |touch_consumer_states_|, as it | 210 // this is a stricter condition than an empty |touch_consumer_states_|, as it |
205 // also prevents forwarding of touchstart events for new pointers in the | 211 // also prevents forwarding of touchstart events for new pointers in the |
206 // current sequence. This is only used when the event is synthetically | 212 // current sequence. This is only used when the event is synthetically |
207 // cancelled after a touch timeout. | 213 // cancelled after a touch timeout. |
208 bool drop_remaining_touches_in_sequence_; | 214 bool drop_remaining_touches_in_sequence_; |
209 | 215 |
(...skipping 26 matching lines...) Expand all Loading... |
236 | 242 |
237 // Event is saved to compare pointer positions for new touchmove events. | 243 // Event is saved to compare pointer positions for new touchmove events. |
238 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; | 244 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; |
239 | 245 |
240 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 246 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
241 }; | 247 }; |
242 | 248 |
243 } // namespace content | 249 } // namespace content |
244 | 250 |
245 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 251 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
OLD | NEW |