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

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

Issue 140253005: Add touch scrolling modes experimental flags (DEPRECATED) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address my own nits. 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 17 matching lines...) Expand all
28 const TouchEventWithLatencyInfo& event) = 0; 28 const TouchEventWithLatencyInfo& event) = 0;
29 29
30 virtual void OnTouchEventAck( 30 virtual void OnTouchEventAck(
31 const TouchEventWithLatencyInfo& event, 31 const TouchEventWithLatencyInfo& event,
32 InputEventAckState ack_result) = 0; 32 InputEventAckState ack_result) = 0;
33 }; 33 };
34 34
35 // A queue for throttling and coalescing touch-events. 35 // A queue for throttling and coalescing touch-events.
36 class CONTENT_EXPORT TouchEventQueue { 36 class CONTENT_EXPORT TouchEventQueue {
37 public: 37 public:
38 // Different ways of dealing with touch events during scrolling.
39 // TODO(rbyers): Remove (or otherwise update) this once results of
40 // experiments are complete. http://crbug.com/328503
41 enum TouchScrollingMode {
42 // Send a touchcancel on scroll start and no further touch events for the
43 // duration of the scroll. Chrome Android's traditional behavior.
44 TOUCH_SCROLLING_MODE_TOUCHCANCEL,
45 // Send touchmove events throughout a scroll, blocking on each ACK and
46 // using the disposition to determine whether a scroll update should be
47 // sent. Mobile Safari's default overflow scroll behavior.
48 TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE,
49 // Like sync, except that consumed scroll events cause subsequent touchmove
50 // events to be suppressed. Unconsumed scroll events return touchmove
51 // events to being dispatched synchronously (so scrolling may be hijacked
52 // when a scroll limit is reached, and later resumed).
53 TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE
54 };
38 55
39 // The |client| must outlive the TouchEventQueue. 56 // The |client| must outlive the TouchEventQueue.
40 explicit TouchEventQueue(TouchEventQueueClient* client); 57 explicit TouchEventQueue(TouchEventQueueClient* client,
58 TouchScrollingMode mode = TOUCH_SCROLLING_MODE_TOUCHCANCEL);
41 ~TouchEventQueue(); 59 ~TouchEventQueue();
42 60
43 // Adds an event to the queue. The event may be coalesced with previously 61 // Adds an event to the queue. The event may be coalesced with previously
44 // queued events (e.g. consecutive touch-move events can be coalesced into a 62 // queued events (e.g. consecutive touch-move events can be coalesced into a
45 // single touch-move event). The event may also be immediately forwarded to 63 // single touch-move event). The event may also be immediately forwarded to
46 // the renderer (e.g. when there are no other queued touch event). 64 // the renderer (e.g. when there are no other queued touch event).
47 void QueueEvent(const TouchEventWithLatencyInfo& event); 65 void QueueEvent(const TouchEventWithLatencyInfo& event);
48 66
49 // Notifies the queue that a touch-event has been processed by the renderer. 67 // Notifies the queue that a touch-event has been processed by the renderer.
50 // At this point, the queue may send one or more gesture events and/or 68 // At this point, the queue may send one or more gesture events and/or
51 // additional queued touch-events to the renderer. 69 // additional queued touch-events to the renderer.
52 void ProcessTouchAck(InputEventAckState ack_result, 70 void ProcessTouchAck(InputEventAckState ack_result,
53 const ui::LatencyInfo& latency_info); 71 const ui::LatencyInfo& latency_info);
54 72
55 // When GestureScrollBegin is received, we send a touch cancel to renderer, 73 // When GestureScrollBegin is received, we send a touch cancel to renderer,
56 // route all the following touch events directly to client, and ignore the 74 // route all the following touch events directly to client, and ignore the
57 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, 75 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received,
58 // resume the normal flow of sending touch events to the renderer. 76 // resume the normal flow of sending touch events to the renderer.
59 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); 77 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event);
60 78
79 void OnGestureEventAck(
80 const GestureEventWithLatencyInfo& event,
81 InputEventAckState ack_result);
82
61 // Notifies the queue whether the renderer has at least one touch handler. 83 // Notifies the queue whether the renderer has at least one touch handler.
62 void OnHasTouchEventHandlers(bool has_handlers); 84 void OnHasTouchEventHandlers(bool has_handlers);
63 85
64 // Returns whether the currently pending touch event (waiting ACK) is for 86 // Returns whether the currently pending touch event (waiting ACK) is for
65 // a touch start event. 87 // a touch start event.
66 bool IsPendingAckTouchStart() const; 88 bool IsPendingAckTouchStart() const;
67 89
68 // Sets whether a delayed touch ack will cancel and flush the current 90 // Sets whether a delayed touch ack will cancel and flush the current
69 // touch sequence. 91 // touch sequence.
70 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms); 92 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Pops the touch-event from the top of the queue and sends it to the 128 // 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. 129 // TouchEventQueueClient. This reduces the size of the queue by one.
108 void PopTouchEventToClient(InputEventAckState ack_result, 130 void PopTouchEventToClient(InputEventAckState ack_result,
109 const ui::LatencyInfo& renderer_latency_info); 131 const ui::LatencyInfo& renderer_latency_info);
110 132
111 bool ShouldForwardToRenderer(const blink::WebTouchEvent& event) const; 133 bool ShouldForwardToRenderer(const blink::WebTouchEvent& event) const;
112 void ForwardToRenderer(const TouchEventWithLatencyInfo& event); 134 void ForwardToRenderer(const TouchEventWithLatencyInfo& event);
113 void UpdateTouchAckStates(const blink::WebTouchEvent& event, 135 void UpdateTouchAckStates(const blink::WebTouchEvent& event,
114 InputEventAckState ack_result); 136 InputEventAckState ack_result);
115 137
116
117 // Handles touch event forwarding and ack'ed event dispatch. 138 // Handles touch event forwarding and ack'ed event dispatch.
118 TouchEventQueueClient* client_; 139 TouchEventQueueClient* client_;
119 140
120 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; 141 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue;
121 TouchQueue touch_queue_; 142 TouchQueue touch_queue_;
122 143
123 // Maintain the ACK status for each touch point. 144 // Maintain the ACK status for each touch point.
124 typedef std::map<int, InputEventAckState> TouchPointAckStates; 145 typedef std::map<int, InputEventAckState> TouchPointAckStates;
125 TouchPointAckStates touch_ack_states_; 146 TouchPointAckStates touch_ack_states_;
126 147
(...skipping 13 matching lines...) Expand all
140 // sequence is received. 161 // sequence is received.
141 DROP_ALL_TOUCHES, // Filter all events, e.g., no touch handler. 162 DROP_ALL_TOUCHES, // Filter all events, e.g., no touch handler.
142 TOUCH_FILTERING_STATE_DEFAULT = FORWARD_ALL_TOUCHES, 163 TOUCH_FILTERING_STATE_DEFAULT = FORWARD_ALL_TOUCHES,
143 }; 164 };
144 TouchFilteringState touch_filtering_state_; 165 TouchFilteringState touch_filtering_state_;
145 166
146 // Optional handler for timed-out touch event acks, disabled by default. 167 // Optional handler for timed-out touch event acks, disabled by default.
147 bool ack_timeout_enabled_; 168 bool ack_timeout_enabled_;
148 scoped_ptr<TouchTimeoutHandler> timeout_handler_; 169 scoped_ptr<TouchTimeoutHandler> timeout_handler_;
149 170
171 // How touch events are handled during scrolling. For now this is a global
172 // setting for experimentation, but we may evolve it into an app-controlled
173 // mode.
174 const TouchScrollingMode touch_scrolling_mode_;
175
176 // Wether touchmove events should be dropped due to the
177 // TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE mode. Note that we can't use
178 // touch_filtering_state_ for this (without adding a few new states and
179 // complicating the code significantly) because it can occur with and without
180 // timeout, and shouldn't cause touchend to be dropped.
181 bool absorbing_touch_moves_;
182
150 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); 183 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue);
151 }; 184 };
152 185
153 } // namespace content 186 } // namespace content
154 187
155 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 188 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/input_router_impl.cc ('k') | content/browser/renderer_host/input/touch_event_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698