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

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

Issue 1800143002: Notify Blink about start of gesture scroll through a queued event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 8 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
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <list>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "content/browser/renderer_host/event_with_latency_info.h" 16 #include "content/browser/renderer_host/event_with_latency_info.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/common/input/input_event_ack_state.h" 18 #include "content/common/input/input_event_ack_state.h"
19 #include "third_party/WebKit/public/web/WebInputEvent.h" 19 #include "third_party/WebKit/public/web/WebInputEvent.h"
20 #include "ui/gfx/geometry/point_f.h" 20 #include "ui/gfx/geometry/point_f.h"
21 21
22 namespace content { 22 namespace content {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 TouchEventQueue(TouchEventQueueClient* client, const Config& config); 63 TouchEventQueue(TouchEventQueueClient* client, const Config& config);
64 64
65 ~TouchEventQueue(); 65 ~TouchEventQueue();
66 66
67 // Adds an event to the queue. The event may be coalesced with previously 67 // Adds an event to the queue. The event may be coalesced with previously
68 // queued events (e.g. consecutive touch-move events can be coalesced into a 68 // queued events (e.g. consecutive touch-move events can be coalesced into a
69 // single touch-move event). The event may also be immediately forwarded to 69 // single touch-move event). The event may also be immediately forwarded to
70 // the renderer (e.g. when there are no other queued touch event). 70 // the renderer (e.g. when there are no other queued touch event).
71 void QueueEvent(const TouchEventWithLatencyInfo& event); 71 void QueueEvent(const TouchEventWithLatencyInfo& event);
72 72
73 // Insert a TouchScrollStarted event in the queue ahead of all not-in-flight
74 // events.
75 void PrependTouchScrollNotification();
76
73 // Notifies the queue that a touch-event has been processed by the renderer. 77 // Notifies the queue that a touch-event has been processed by the renderer.
74 // At this point, if the ack is for async touchmove, remove the uncancelable 78 // At this point, if the ack is for async touchmove, remove the uncancelable
75 // touchmove from the front of the queue and decide if it should dispatch the 79 // touchmove from the front of the queue and decide if it should dispatch the
76 // next pending async touch move event, otherwise the queue may send one or 80 // next pending async touch move event, otherwise the queue may send one or
77 // more gesture events and/or additional queued touch-events to the renderer. 81 // more gesture events and/or additional queued touch-events to the renderer.
78 void ProcessTouchAck(InputEventAckState ack_result, 82 void ProcessTouchAck(InputEventAckState ack_result,
79 const ui::LatencyInfo& latency_info, 83 const ui::LatencyInfo& latency_info,
80 const uint32_t unique_touch_event_id); 84 const uint32_t unique_touch_event_id);
81 85
82 // When GestureScrollBegin is received, we send a touch cancel to renderer, 86 // When GestureScrollBegin is received, we send a touch cancel to renderer,
(...skipping 19 matching lines...) Expand all
102 void SetAckTimeoutEnabled(bool enabled); 106 void SetAckTimeoutEnabled(bool enabled);
103 107
104 // Sets whether the current site has a mobile friendly viewport. This 108 // Sets whether the current site has a mobile friendly viewport. This
105 // determines which ack timeout delay will be used for *future* touch events. 109 // determines which ack timeout delay will be used for *future* touch events.
106 // The default assumption is that the site is *not* mobile-optimized. 110 // The default assumption is that the site is *not* mobile-optimized.
107 void SetIsMobileOptimizedSite(bool mobile_optimized_site); 111 void SetIsMobileOptimizedSite(bool mobile_optimized_site);
108 112
109 // Whether ack timeout behavior is supported and enabled for the current site. 113 // Whether ack timeout behavior is supported and enabled for the current site.
110 bool IsAckTimeoutEnabled() const; 114 bool IsAckTimeoutEnabled() const;
111 115
112 bool IsForwardingTouches();
113
114 bool empty() const WARN_UNUSED_RESULT { 116 bool empty() const WARN_UNUSED_RESULT {
115 return touch_queue_.empty(); 117 return touch_queue_.empty();
116 } 118 }
117 119
118 size_t size() const { 120 size_t size() const {
119 return touch_queue_.size(); 121 return touch_queue_.size();
120 } 122 }
121 123
122 bool has_handlers() const { return has_handlers_; } 124 bool has_handlers() const { return has_handlers_; }
123 125
(...skipping 24 matching lines...) Expand all
148 void ForwardNextEventToRenderer(); 150 void ForwardNextEventToRenderer();
149 151
150 // Pops the touch-event from the head of the queue and acks it to the client. 152 // Pops the touch-event from the head of the queue and acks it to the client.
151 void PopTouchEventToClient(InputEventAckState ack_result); 153 void PopTouchEventToClient(InputEventAckState ack_result);
152 154
153 // Pops the touch-event from the top of the queue and acks it to the client, 155 // Pops the touch-event from the top of the queue and acks it to the client,
154 // updating the event with |renderer_latency_info|. 156 // updating the event with |renderer_latency_info|.
155 void PopTouchEventToClient(InputEventAckState ack_result, 157 void PopTouchEventToClient(InputEventAckState ack_result,
156 const ui::LatencyInfo& renderer_latency_info); 158 const ui::LatencyInfo& renderer_latency_info);
157 159
158 // Ack all coalesced events in |acked_event| to the client with |ack_result|, 160 // Ack all coalesced events at the head of the queue to the client with
159 // updating the acked events with |optional_latency_info| if it exists. 161 // |ack_result|, updating the acked events with |optional_latency_info| if it
160 void AckTouchEventToClient( 162 // exists, and popping the head of the queue.
161 InputEventAckState ack_result, 163 void AckTouchEventToClient(InputEventAckState ack_result,
162 std::unique_ptr<CoalescedWebTouchEvent> acked_event, 164 const ui::LatencyInfo* optional_latency_info);
163 const ui::LatencyInfo* optional_latency_info);
164
165 // Safely pop the head of the queue.
166 std::unique_ptr<CoalescedWebTouchEvent> PopTouchEvent();
167 165
168 // Dispatch |touch| to the client. Before dispatching, updates pointer 166 // Dispatch |touch| to the client. Before dispatching, updates pointer
169 // states in touchmove events for pointers that have not changed position. 167 // states in touchmove events for pointers that have not changed position.
170 void SendTouchEventImmediately(TouchEventWithLatencyInfo* touch); 168 void SendTouchEventImmediately(TouchEventWithLatencyInfo* touch);
171 169
172 enum PreFilterResult { 170 enum PreFilterResult {
173 ACK_WITH_NO_CONSUMER_EXISTS, 171 ACK_WITH_NO_CONSUMER_EXISTS,
174 ACK_WITH_NOT_CONSUMED, 172 ACK_WITH_NOT_CONSUMED,
175 FORWARD_TO_RENDERER, 173 FORWARD_TO_RENDERER,
176 }; 174 };
177 // Filter touches prior to forwarding to the renderer, e.g., if the renderer 175 // Filter touches prior to forwarding to the renderer, e.g., if the renderer
178 // has no touch handler. 176 // has no touch handler.
179 PreFilterResult FilterBeforeForwarding(const blink::WebTouchEvent& event); 177 PreFilterResult FilterBeforeForwarding(const blink::WebTouchEvent& event);
180 void ForwardToRenderer(const TouchEventWithLatencyInfo& event); 178 void ForwardToRenderer(const TouchEventWithLatencyInfo& event);
181 void UpdateTouchConsumerStates(const blink::WebTouchEvent& event, 179 void UpdateTouchConsumerStates(const blink::WebTouchEvent& event,
182 InputEventAckState ack_result); 180 InputEventAckState ack_result);
183 void FlushPendingAsyncTouchmove(); 181 void FlushPendingAsyncTouchmove();
184 182
185 // Handles touch event forwarding and ack'ed event dispatch. 183 // Handles touch event forwarding and ack'ed event dispatch.
186 TouchEventQueueClient* client_; 184 TouchEventQueueClient* client_;
187 185
188 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; 186 typedef std::list<CoalescedWebTouchEvent*> TouchQueue;
189 TouchQueue touch_queue_; 187 TouchQueue touch_queue_;
190 188
191 // Position of the first touch in the most recent sequence forwarded to the 189 // Position of the first touch in the most recent sequence forwarded to the
192 // client. 190 // client.
193 gfx::PointF touch_sequence_start_position_; 191 gfx::PointF touch_sequence_start_position_;
194 192
195 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. 193 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|.
196 // True within the scope of |AckTouchEventToClient()|. 194 // True within the scope of |AckTouchEventToClient()|.
197 bool dispatching_touch_ack_; 195 bool dispatching_touch_ack_;
198 196
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 241
244 // Event is saved to compare pointer positions for new touchmove events. 242 // Event is saved to compare pointer positions for new touchmove events.
245 std::unique_ptr<blink::WebTouchEvent> last_sent_touchevent_; 243 std::unique_ptr<blink::WebTouchEvent> last_sent_touchevent_;
246 244
247 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); 245 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue);
248 }; 246 };
249 247
250 } // namespace content 248 } // namespace content
251 249
252 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 250 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698