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

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: Clean up error handling and tests. 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
jdduke (slow) 2014/02/13 16:53:06 Let's add a TOUCH_SCROLLING_MODE_DEFAULT = TOUCH_S
tdresser 2014/02/13 18:14:09 Done.
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);
jdduke (slow) 2014/02/13 16:53:06 Nit: No default args, and remove explicit.
tdresser 2014/02/13 18:14:09 Done.
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 TouchFilteringState touch_filtering_state_; 180 TouchFilteringState touch_filtering_state_;
159 181
160 // Optional handler for timed-out touch event acks, disabled by default. 182 // Optional handler for timed-out touch event acks, disabled by default.
161 bool ack_timeout_enabled_; 183 bool ack_timeout_enabled_;
162 scoped_ptr<TouchTimeoutHandler> timeout_handler_; 184 scoped_ptr<TouchTimeoutHandler> timeout_handler_;
163 185
164 // Optional suppression of TouchMove's within a slop region when a sequence 186 // Optional suppression of TouchMove's within a slop region when a sequence
165 // has not yet been preventDefaulted, disabled by default. 187 // has not yet been preventDefaulted, disabled by default.
166 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; 188 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_;
167 189
190 // How touch events are handled during scrolling. For now this is a global
191 // setting for experimentation, but we may evolve it into an app-controlled
192 // mode.
193 const TouchScrollingMode touch_scrolling_mode_;
194
195 // Whether touchmove events should be dropped due to the
196 // TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE mode. Note that we can't use
197 // touch_filtering_state_ for this (without adding a few new states and
198 // complicating the code significantly) because it can occur with and without
199 // timeout, and shouldn't cause touchend to be dropped.
200 bool absorbing_touch_moves_;
201
168 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); 202 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue);
169 }; 203 };
170 204
171 } // namespace content 205 } // namespace content
172 206
173 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 207 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698