Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue.h

Issue 156783006: Consuming a touch move prevents only the next scroll update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 18 matching lines...) Expand all
29 const TouchEventWithLatencyInfo& event) = 0; 29 const TouchEventWithLatencyInfo& event) = 0;
30 30
31 virtual void OnTouchEventAck( 31 virtual void OnTouchEventAck(
32 const TouchEventWithLatencyInfo& event, 32 const TouchEventWithLatencyInfo& event,
33 InputEventAckState ack_result) = 0; 33 InputEventAckState ack_result) = 0;
34 }; 34 };
35 35
36 // A queue for throttling and coalescing touch-events. 36 // A queue for throttling and coalescing touch-events.
37 class CONTENT_EXPORT TouchEventQueue { 37 class CONTENT_EXPORT TouchEventQueue {
38 public: 38 public:
39 // Different ways of dealing with touch events during scrolling.
40 // TODO(rbyers): Remove (or otherwise update) this once results of
41 // experiments are complete. http://crbug.com/328503
42 enum TouchScrollingMode {
43 // Send a touchcancel on scroll start and no further touch events for the
44 // duration of the scroll. Chrome Android's traditional behavior.
45 TOUCH_SCROLLING_MODE_TOUCHCANCEL,
46 // Send touchmove events throughout a scroll, blocking on each ACK and
47 // using the disposition to determine whether a scroll update should be
48 // sent. Mobile Safari's default overflow scroll behavior.
49 TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE,
50 // Like sync, except that consumed scroll events cause subsequent touchmove
51 // events to be suppressed. Unconsumed scroll events return touchmove
52 // events to being dispatched synchronously (so scrolling may be hijacked
53 // when a scroll limit is reached, and later resumed).
54 TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE
55 };
39 56
40 // The |client| must outlive the TouchEventQueue. 57 // The |client| must outlive the TouchEventQueue.
41 explicit TouchEventQueue(TouchEventQueueClient* client); 58 explicit TouchEventQueue(TouchEventQueueClient* client,
59 TouchScrollingMode mode = TOUCH_SCROLLING_MODE_TOUCHCANCEL);
42 ~TouchEventQueue(); 60 ~TouchEventQueue();
43 61
44 // Adds an event to the queue. The event may be coalesced with previously 62 // Adds an event to the queue. The event may be coalesced with previously
45 // queued events (e.g. consecutive touch-move events can be coalesced into a 63 // queued events (e.g. consecutive touch-move events can be coalesced into a
46 // single touch-move event). The event may also be immediately forwarded to 64 // single touch-move event). The event may also be immediately forwarded to
47 // the renderer (e.g. when there are no other queued touch event). 65 // the renderer (e.g. when there are no other queued touch event).
48 void QueueEvent(const TouchEventWithLatencyInfo& event); 66 void QueueEvent(const TouchEventWithLatencyInfo& event);
49 67
50 // Notifies the queue that a touch-event has been processed by the renderer. 68 // Notifies the queue that a touch-event has been processed by the renderer.
51 // At this point, the queue may send one or more gesture events and/or 69 // At this point, the queue may send one or more gesture events and/or
52 // additional queued touch-events to the renderer. 70 // additional queued touch-events to the renderer.
53 void ProcessTouchAck(InputEventAckState ack_result, 71 void ProcessTouchAck(InputEventAckState ack_result,
54 const ui::LatencyInfo& latency_info); 72 const ui::LatencyInfo& latency_info);
55 73
56 // When GestureScrollBegin is received, we send a touch cancel to renderer, 74 // When GestureScrollBegin is received, we send a touch cancel to renderer,
57 // route all the following touch events directly to client, and ignore the 75 // route all the following touch events directly to client, and ignore the
58 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, 76 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received,
59 // resume the normal flow of sending touch events to the renderer. 77 // resume the normal flow of sending touch events to the renderer.
60 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); 78 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event);
61 79
80 void OnGestureEventAck(
81 const GestureEventWithLatencyInfo& event,
82 InputEventAckState ack_result);
83
62 // Notifies the queue whether the renderer has at least one touch handler. 84 // Notifies the queue whether the renderer has at least one touch handler.
63 void OnHasTouchEventHandlers(bool has_handlers); 85 void OnHasTouchEventHandlers(bool has_handlers);
64 86
65 // Returns whether the currently pending touch event (waiting ACK) is for 87 // Returns whether the currently pending touch event (waiting ACK) is for
66 // a touch start event. 88 // a touch start event.
67 bool IsPendingAckTouchStart() const; 89 bool IsPendingAckTouchStart() const;
68 90
69 // Sets whether a delayed touch ack will cancel and flush the current 91 // Sets whether a delayed touch ack will cancel and flush the current
70 // touch sequence. 92 // touch sequence.
71 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms); 93 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ACK_WITH_NOT_CONSUMED, 142 ACK_WITH_NOT_CONSUMED,
121 FORWARD_TO_RENDERER, 143 FORWARD_TO_RENDERER,
122 }; 144 };
123 // Filter touches prior to forwarding to the renderer, e.g., if the renderer 145 // Filter touches prior to forwarding to the renderer, e.g., if the renderer
124 // has no touch handler. 146 // has no touch handler.
125 PreFilterResult FilterBeforeForwarding(const blink::WebTouchEvent& event); 147 PreFilterResult FilterBeforeForwarding(const blink::WebTouchEvent& event);
126 void ForwardToRenderer(const TouchEventWithLatencyInfo& event); 148 void ForwardToRenderer(const TouchEventWithLatencyInfo& event);
127 void UpdateTouchAckStates(const blink::WebTouchEvent& event, 149 void UpdateTouchAckStates(const blink::WebTouchEvent& event,
128 InputEventAckState ack_result); 150 InputEventAckState ack_result);
129 151
130
131 // Handles touch event forwarding and ack'ed event dispatch. 152 // Handles touch event forwarding and ack'ed event dispatch.
132 TouchEventQueueClient* client_; 153 TouchEventQueueClient* client_;
133 154
134 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; 155 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue;
135 TouchQueue touch_queue_; 156 TouchQueue touch_queue_;
136 157
137 // Maintain the ACK status for each touch point. 158 // Maintain the ACK status for each touch point.
138 typedef std::map<int, InputEventAckState> TouchPointAckStates; 159 typedef std::map<int, InputEventAckState> TouchPointAckStates;
139 TouchPointAckStates touch_ack_states_; 160 TouchPointAckStates touch_ack_states_;
140 161
(...skipping 17 matching lines...) Expand all
158 TouchFilteringState touch_filtering_state_; 179 TouchFilteringState touch_filtering_state_;
159 180
160 // Optional handler for timed-out touch event acks, disabled by default. 181 // Optional handler for timed-out touch event acks, disabled by default.
161 bool ack_timeout_enabled_; 182 bool ack_timeout_enabled_;
162 scoped_ptr<TouchTimeoutHandler> timeout_handler_; 183 scoped_ptr<TouchTimeoutHandler> timeout_handler_;
163 184
164 // Optional suppression of TouchMove's within a slop region when a sequence 185 // Optional suppression of TouchMove's within a slop region when a sequence
165 // has not yet been preventDefaulted, disabled by default. 186 // has not yet been preventDefaulted, disabled by default.
166 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; 187 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_;
167 188
189 // How touch events are handled during scrolling. For now this is a global
190 // setting for experimentation, but we may evolve it into an app-controlled
191 // mode.
192 const TouchScrollingMode touch_scrolling_mode_;
193
194 // Wether touchmove events should be dropped due to the
195 // TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE mode. Note that we can't use
196 // touch_filtering_state_ for this (without adding a few new states and
197 // complicating the code significantly) because it can occur with and without
198 // timeout, and shouldn't cause touchend to be dropped.
199 bool absorbing_touch_moves_;
200
168 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); 201 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue);
169 }; 202 };
170 203
171 } // namespace content 204 } // namespace content
172 205
173 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 206 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698