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

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

Issue 260923003: Revert of Consolidate all touch/gesture related constants in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_GESTURE_EVENT_QUEUE_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "content/browser/renderer_host/input/tap_suppression_controller.h"
14 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle r.h"
15 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro ller.h"
16 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
17 #include "content/port/browser/event_with_latency_info.h" 14 #include "content/port/browser/event_with_latency_info.h"
18 #include "content/port/common/input_event_ack_state.h" 15 #include "content/port/common/input_event_ack_state.h"
19 #include "third_party/WebKit/public/web/WebInputEvent.h" 16 #include "third_party/WebKit/public/web/WebInputEvent.h"
20 #include "ui/gfx/transform.h" 17 #include "ui/gfx/transform.h"
21 18
22 namespace content { 19 namespace content {
23 class GestureEventQueueTest; 20 class GestureEventQueueTest;
24 class InputRouter; 21 class InputRouter;
25 class MockRenderWidgetHost; 22 class MockRenderWidgetHost;
23 class TouchpadTapSuppressionController;
24 class TouchpadTapSuppressionControllerClient;
25 class TouchscreenTapSuppressionController;
26 26
27 // Interface with which the GestureEventQueue can forward gesture events, and 27 // Interface with which the GestureEventQueue can forward gesture events, and
28 // dispatch gesture event responses. 28 // dispatch gesture event responses.
29 class CONTENT_EXPORT GestureEventQueueClient { 29 class CONTENT_EXPORT GestureEventQueueClient {
30 public: 30 public:
31 virtual ~GestureEventQueueClient() {} 31 virtual ~GestureEventQueueClient() {}
32 32
33 virtual void SendGestureEventImmediately( 33 virtual void SendGestureEventImmediately(
34 const GestureEventWithLatencyInfo& event) = 0; 34 const GestureEventWithLatencyInfo& event) = 0;
35 35
(...skipping 18 matching lines...) Expand all
54 // as possible and therefore maximize the chance that the event stream can be 54 // as possible and therefore maximize the chance that the event stream can be
55 // handled entirely by the compositor thread. 55 // handled entirely by the compositor thread.
56 // Events in the queue are forwarded to the renderer one by one; i.e., each 56 // Events in the queue are forwarded to the renderer one by one; i.e., each
57 // event is sent after receiving the ACK for previous one. The only exception is 57 // event is sent after receiving the ACK for previous one. The only exception is
58 // that if a GestureScrollUpdate is followed by a GesturePinchUpdate, they are 58 // that if a GestureScrollUpdate is followed by a GesturePinchUpdate, they are
59 // sent together. 59 // sent together.
60 // TODO(rjkroege): Possibly refactor into a filter chain: 60 // TODO(rjkroege): Possibly refactor into a filter chain:
61 // http://crbug.com/148443. 61 // http://crbug.com/148443.
62 class CONTENT_EXPORT GestureEventQueue { 62 class CONTENT_EXPORT GestureEventQueue {
63 public: 63 public:
64 struct CONTENT_EXPORT Config {
65 Config();
66
67 // Controls touchpad-related tap suppression, disabled by default.
68 TapSuppressionController::Config touchpad_tap_suppression_config;
69
70 // Controls touchscreen-related tap suppression, disabled by default.
71 TapSuppressionController::Config touchscreen_tap_suppression_config;
72
73 // Determines whether non-scroll gesture events are "debounced" during an
74 // active scroll sequence, suppressing brief scroll interruptions.
75 // Zero by default (disabled).
76 base::TimeDelta debounce_interval;
77 };
78
79 // Both |client| and |touchpad_client| must outlive the GestureEventQueue. 64 // Both |client| and |touchpad_client| must outlive the GestureEventQueue.
80 GestureEventQueue(GestureEventQueueClient* client, 65 GestureEventQueue(GestureEventQueueClient* client,
81 TouchpadTapSuppressionControllerClient* touchpad_client, 66 TouchpadTapSuppressionControllerClient* touchpad_client);
82 const Config& config);
83 ~GestureEventQueue(); 67 ~GestureEventQueue();
84 68
85 // Returns |true| if the caller should immediately forward the provided 69 // Returns |true| if the caller should immediately forward the provided
86 // |GestureEventWithLatencyInfo| argument to the renderer. 70 // |GestureEventWithLatencyInfo| argument to the renderer.
87 // If this function returns false, then the event may be queued and forwared 71 // If this function returns false, then the event may be queued and forwared
88 // at a later point. 72 // at a later point.
89 bool ShouldForward(const GestureEventWithLatencyInfo&); 73 bool ShouldForward(const GestureEventWithLatencyInfo&);
90 74
91 // Indicates that the caller has received an acknowledgement from the renderer 75 // Indicates that the caller has received an acknowledgement from the renderer
92 // with state |ack_result| and event |type|. May send events if the queue is 76 // with state |ack_result| and event |type|. May send events if the queue is
(...skipping 12 matching lines...) Expand all
105 void ForwardGestureEvent(const GestureEventWithLatencyInfo& gesture_event); 89 void ForwardGestureEvent(const GestureEventWithLatencyInfo& gesture_event);
106 90
107 // Whether the queue is expecting a gesture event ack. 91 // Whether the queue is expecting a gesture event ack.
108 bool ExpectingGestureAck() const; 92 bool ExpectingGestureAck() const;
109 93
110 bool empty() const { 94 bool empty() const {
111 return coalesced_gesture_events_.empty() && 95 return coalesced_gesture_events_.empty() &&
112 debouncing_deferral_queue_.empty(); 96 debouncing_deferral_queue_.empty();
113 } 97 }
114 98
115 void set_debounce_interval_time_ms_for_testing(int interval_ms) { 99 void set_debounce_enabled_for_testing(bool enabled) {
116 debounce_interval_ = base::TimeDelta::FromMilliseconds(interval_ms); 100 debounce_enabled_ = enabled;
101 }
102
103 void set_debounce_interval_time_ms_for_testing(int interval_time_ms) {
104 debounce_interval_time_ms_ = interval_time_ms;
117 } 105 }
118 106
119 private: 107 private:
120 friend class GestureEventQueueTest; 108 friend class GestureEventQueueTest;
121 friend class MockRenderWidgetHost; 109 friend class MockRenderWidgetHost;
122 110
123 // TODO(mohsen): There are a bunch of ShouldForward.../ShouldDiscard... 111 // TODO(mohsen): There are a bunch of ShouldForward.../ShouldDiscard...
124 // methods that are getting confusing. This should be somehow fixed. Maybe 112 // methods that are getting confusing. This should be somehow fixed. Maybe
125 // while refactoring GEQ: http://crbug.com/148443. 113 // while refactoring GEQ: http://crbug.com/148443.
126 114
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 181
194 // True if two related gesture events were sent before without waiting 182 // True if two related gesture events were sent before without waiting
195 // for an ACK, so the next gesture ACK should be ignored. 183 // for an ACK, so the next gesture ACK should be ignored.
196 bool ignore_next_ack_; 184 bool ignore_next_ack_;
197 185
198 // An object tracking the state of touchpad on the delivery of mouse events to 186 // An object tracking the state of touchpad on the delivery of mouse events to
199 // the renderer to filter mouse immediately after a touchpad fling canceling 187 // the renderer to filter mouse immediately after a touchpad fling canceling
200 // tap. 188 // tap.
201 // TODO(mohsen): Move touchpad tap suppression out of GestureEventQueue since 189 // TODO(mohsen): Move touchpad tap suppression out of GestureEventQueue since
202 // GEQ is meant to only be used for touchscreen gesture events. 190 // GEQ is meant to only be used for touchscreen gesture events.
203 TouchpadTapSuppressionController touchpad_tap_suppression_controller_; 191 scoped_ptr<TouchpadTapSuppressionController>
192 touchpad_tap_suppression_controller_;
204 193
205 // An object tracking the state of touchscreen on the delivery of gesture tap 194 // An object tracking the state of touchscreen on the delivery of gesture tap
206 // events to the renderer to filter taps immediately after a touchscreen fling 195 // events to the renderer to filter taps immediately after a touchscreen fling
207 // canceling tap. 196 // canceling tap.
208 TouchscreenTapSuppressionController touchscreen_tap_suppression_controller_; 197 scoped_ptr<TouchscreenTapSuppressionController>
198 touchscreen_tap_suppression_controller_;
209 199
210 typedef std::deque<GestureEventWithLatencyInfo> GestureQueue; 200 typedef std::deque<GestureEventWithLatencyInfo> GestureQueue;
211 201
212 // Queue of coalesced gesture events not yet sent to the renderer. If 202 // Queue of coalesced gesture events not yet sent to the renderer. If
213 // |ignore_next_ack_| is false, then the event at the front of the queue has 203 // |ignore_next_ack_| is false, then the event at the front of the queue has
214 // been sent and is awaiting an ACK, and all other events have yet to be sent. 204 // been sent and is awaiting an ACK, and all other events have yet to be sent.
215 // If |ignore_next_ack_| is true, then the two events at the front of the 205 // If |ignore_next_ack_| is true, then the two events at the front of the
216 // queue have been sent, and the second is awaiting an ACK. All other events 206 // queue have been sent, and the second is awaiting an ACK. All other events
217 // have yet to be sent. 207 // have yet to be sent.
218 GestureQueue coalesced_gesture_events_; 208 GestureQueue coalesced_gesture_events_;
219 209
220 // Timer to release a previously deferred gesture event. 210 // Timer to release a previously deferred gesture event.
221 base::OneShotTimer<GestureEventQueue> debounce_deferring_timer_; 211 base::OneShotTimer<GestureEventQueue> debounce_deferring_timer_;
222 212
223 // Queue of events that have been deferred for debounce. 213 // Queue of events that have been deferred for debounce.
224 GestureQueue debouncing_deferral_queue_; 214 GestureQueue debouncing_deferral_queue_;
225 215
226 // Time window in which to debounce scroll/fling ends. Note that an interval 216 // Time window in which to debounce scroll/fling ends.
227 // of zero effectively disables debouncing. 217 // TODO(rjkroege): Make this dynamically configurable.
228 base::TimeDelta debounce_interval_; 218 int debounce_interval_time_ms_;
219
220 // Whether scroll-ending events should be deferred when a scroll is active.
221 // Defaults to true.
222 bool debounce_enabled_;
229 223
230 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue); 224 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue);
231 }; 225 };
232 226
233 } // namespace content 227 } // namespace content
234 228
235 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ 229 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
OLDNEW
« no previous file with comments | « content/browser/android/content_startup_flags.cc ('k') | content/browser/renderer_host/input/gesture_event_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698