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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // additional queued touch-events to the renderer. | 51 // additional queued touch-events to the renderer. |
52 void ProcessTouchAck(InputEventAckState ack_result, | 52 void ProcessTouchAck(InputEventAckState ack_result, |
53 const ui::LatencyInfo& latency_info); | 53 const ui::LatencyInfo& latency_info); |
54 | 54 |
55 // When GestureScrollBegin is received, we send a touch cancel to renderer, | 55 // When GestureScrollBegin is received, we send a touch cancel to renderer, |
56 // route all the following touch events directly to client, and ignore the | 56 // route all the following touch events directly to client, and ignore the |
57 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, | 57 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, |
58 // resume the normal flow of sending touch events to the renderer. | 58 // resume the normal flow of sending touch events to the renderer. |
59 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); | 59 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); |
60 | 60 |
| 61 void OnGestureEventAck( |
| 62 const GestureEventWithLatencyInfo& event, |
| 63 InputEventAckState ack_result); |
| 64 |
61 // Notifies the queue whether the renderer has at least one touch handler. | 65 // Notifies the queue whether the renderer has at least one touch handler. |
62 void OnHasTouchEventHandlers(bool has_handlers); | 66 void OnHasTouchEventHandlers(bool has_handlers); |
63 | 67 |
64 // Returns whether the currently pending touch event (waiting ACK) is for | 68 // Returns whether the currently pending touch event (waiting ACK) is for |
65 // a touch start event. | 69 // a touch start event. |
66 bool IsPendingAckTouchStart() const; | 70 bool IsPendingAckTouchStart() const; |
67 | 71 |
68 // Sets whether a delayed touch ack will cancel and flush the current | 72 // Sets whether a delayed touch ack will cancel and flush the current |
69 // touch sequence. | 73 // touch sequence. |
70 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms); | 74 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Pops the touch-event from the top of the queue and sends it to the | 110 // Pops the touch-event from the top of the queue and sends it to the |
107 // TouchEventQueueClient. This reduces the size of the queue by one. | 111 // TouchEventQueueClient. This reduces the size of the queue by one. |
108 void PopTouchEventToClient(InputEventAckState ack_result, | 112 void PopTouchEventToClient(InputEventAckState ack_result, |
109 const ui::LatencyInfo& renderer_latency_info); | 113 const ui::LatencyInfo& renderer_latency_info); |
110 | 114 |
111 bool ShouldForwardToRenderer(const blink::WebTouchEvent& event) const; | 115 bool ShouldForwardToRenderer(const blink::WebTouchEvent& event) const; |
112 void ForwardToRenderer(const TouchEventWithLatencyInfo& event); | 116 void ForwardToRenderer(const TouchEventWithLatencyInfo& event); |
113 void UpdateTouchAckStates(const blink::WebTouchEvent& event, | 117 void UpdateTouchAckStates(const blink::WebTouchEvent& event, |
114 InputEventAckState ack_result); | 118 InputEventAckState ack_result); |
115 | 119 |
| 120 // Different ways of dealing with touch events during scrolling. |
| 121 // TODO(rbyers): Remove (or otherwise update) this once results of |
| 122 // experiments are complete. http://crbug.com/328503 |
| 123 enum TouchScrollingMode { |
| 124 // Send a touchcancel on scroll start and no further touch events for the |
| 125 // duration of the scroll. Chrome Android's traditional behavior. |
| 126 TOUCH_SCROLLING_MODE_TOUCHCANCEL, |
| 127 // Send touchmove events throughout a scroll, blocking on each ACK and |
| 128 // using the disposition to determine whether a scroll update should be |
| 129 // sent. Mobile Safari's default overflow scroll behavior. |
| 130 TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE, |
| 131 // Like sync, except that consumed scroll events cause subsequent touchmove |
| 132 // events to be suppressed. Unconsumed scroll events return touchmove |
| 133 // events to being dispatched synchronously (so scrolling may be hijacked |
| 134 // when a scroll limit is reached, and later resumed). |
| 135 TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE |
| 136 }; |
| 137 static TouchScrollingMode GetTouchScrollingMode(); |
116 | 138 |
117 // Handles touch event forwarding and ack'ed event dispatch. | 139 // Handles touch event forwarding and ack'ed event dispatch. |
118 TouchEventQueueClient* client_; | 140 TouchEventQueueClient* client_; |
119 | 141 |
120 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 142 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; |
121 TouchQueue touch_queue_; | 143 TouchQueue touch_queue_; |
122 | 144 |
123 // Maintain the ACK status for each touch point. | 145 // Maintain the ACK status for each touch point. |
124 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 146 typedef std::map<int, InputEventAckState> TouchPointAckStates; |
125 TouchPointAckStates touch_ack_states_; | 147 TouchPointAckStates touch_ack_states_; |
(...skipping 14 matching lines...) Expand all Loading... |
140 // sequence is received. | 162 // sequence is received. |
141 DROP_ALL_TOUCHES, // Filter all events, e.g., no touch handler. | 163 DROP_ALL_TOUCHES, // Filter all events, e.g., no touch handler. |
142 TOUCH_FILTERING_STATE_DEFAULT = FORWARD_ALL_TOUCHES, | 164 TOUCH_FILTERING_STATE_DEFAULT = FORWARD_ALL_TOUCHES, |
143 }; | 165 }; |
144 TouchFilteringState touch_filtering_state_; | 166 TouchFilteringState touch_filtering_state_; |
145 | 167 |
146 // Optional handler for timed-out touch event acks, disabled by default. | 168 // Optional handler for timed-out touch event acks, disabled by default. |
147 bool ack_timeout_enabled_; | 169 bool ack_timeout_enabled_; |
148 scoped_ptr<TouchTimeoutHandler> timeout_handler_; | 170 scoped_ptr<TouchTimeoutHandler> timeout_handler_; |
149 | 171 |
| 172 // How touch events are handled during scrolling. For now this is a global |
| 173 // setting for experimentation, but we may evolve it into an app-controlled |
| 174 // mode. |
| 175 const TouchScrollingMode touch_scrolling_mode_; |
| 176 |
| 177 // Wether touchmove events should be dropped due to the |
| 178 // TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE mode. Note that we can't use |
| 179 // touch_filtering_state_ for this (without adding a few new states and |
| 180 // complicating the code significantly) because it can occur with and without |
| 181 // timeout, and shouldn't cause touchend to be dropped. |
| 182 bool absorbing_touch_moves_; |
| 183 |
150 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 184 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
151 }; | 185 }; |
152 | 186 |
153 } // namespace content | 187 } // namespace content |
154 | 188 |
155 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 189 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
OLD | NEW |