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

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

Issue 1405613002: Support vsync-aligned wheel event dispatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_cleanup_todo
Patch Set: Rebase Created 5 years, 1 month 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_INPUT_ROUTER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_IMPL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_IMPL_H_
7 7
8 #include <queue> 8 #include <queue>
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/memory/scoped_vector.h"
13 #include "base/time/time.h" 12 #include "base/time/time.h"
14 #include "content/browser/renderer_host/input/gesture_event_queue.h" 13 #include "content/browser/renderer_host/input/gesture_event_queue.h"
15 #include "content/browser/renderer_host/input/input_router.h" 14 #include "content/browser/renderer_host/input/input_router.h"
16 #include "content/browser/renderer_host/input/touch_action_filter.h" 15 #include "content/browser/renderer_host/input/touch_action_filter.h"
17 #include "content/browser/renderer_host/input/touch_event_queue.h" 16 #include "content/browser/renderer_host/input/touch_event_queue.h"
18 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle r.h" 17 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle r.h"
18 #include "content/browser/renderer_host/input/wheel_event_queue.h"
19 #include "content/common/input/input_event_stream_validator.h" 19 #include "content/common/input/input_event_stream_validator.h"
20 #include "content/public/browser/native_web_keyboard_event.h" 20 #include "content/public/browser/native_web_keyboard_event.h"
21 21
22 namespace IPC { 22 namespace IPC {
23 class Sender; 23 class Sender;
24 } 24 }
25 25
26 namespace ui { 26 namespace ui {
27 class LatencyInfo; 27 class LatencyInfo;
28 } 28 }
29 29
30 namespace content { 30 namespace content {
31 31
32 class InputAckHandler; 32 class InputAckHandler;
33 class InputRouterClient; 33 class InputRouterClient;
34 class OverscrollController; 34 class OverscrollController;
35 struct DidOverscrollParams; 35 struct DidOverscrollParams;
36 struct InputEventAck; 36 struct InputEventAck;
37 37
38 // A default implementation for browser input event routing. 38 // A default implementation for browser input event routing.
39 class CONTENT_EXPORT InputRouterImpl 39 class CONTENT_EXPORT InputRouterImpl
40 : public NON_EXPORTED_BASE(InputRouter), 40 : public NON_EXPORTED_BASE(InputRouter),
41 public NON_EXPORTED_BASE(GestureEventQueueClient), 41 public NON_EXPORTED_BASE(GestureEventQueueClient),
42 public NON_EXPORTED_BASE(TouchEventQueueClient), 42 public NON_EXPORTED_BASE(TouchEventQueueClient),
43 public NON_EXPORTED_BASE(TouchpadTapSuppressionControllerClient) { 43 public NON_EXPORTED_BASE(TouchpadTapSuppressionControllerClient),
44 public NON_EXPORTED_BASE(WheelEventQueueClient) {
44 public: 45 public:
45 struct CONTENT_EXPORT Config { 46 struct CONTENT_EXPORT Config {
46 Config(); 47 Config();
47 GestureEventQueue::Config gesture_config; 48 GestureEventQueue::Config gesture_config;
48 TouchEventQueue::Config touch_config; 49 TouchEventQueue::Config touch_config;
50 bool buffer_wheel_events_until_flush;
49 }; 51 };
50 52
51 InputRouterImpl(IPC::Sender* sender, 53 InputRouterImpl(IPC::Sender* sender,
52 InputRouterClient* client, 54 InputRouterClient* client,
53 InputAckHandler* ack_handler, 55 InputAckHandler* ack_handler,
54 int routing_id, 56 int routing_id,
55 const Config& config); 57 const Config& config);
56 ~InputRouterImpl() override; 58 ~InputRouterImpl() override;
57 59
58 // InputRouter 60 // InputRouter
(...skipping 20 matching lines...) Expand all
79 // TouchpadTapSuppressionControllerClient 81 // TouchpadTapSuppressionControllerClient
80 void SendMouseEventImmediately( 82 void SendMouseEventImmediately(
81 const MouseEventWithLatencyInfo& mouse_event) override; 83 const MouseEventWithLatencyInfo& mouse_event) override;
82 84
83 // TouchEventQueueClient 85 // TouchEventQueueClient
84 void SendTouchEventImmediately( 86 void SendTouchEventImmediately(
85 const TouchEventWithLatencyInfo& touch_event) override; 87 const TouchEventWithLatencyInfo& touch_event) override;
86 void OnTouchEventAck(const TouchEventWithLatencyInfo& event, 88 void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
87 InputEventAckState ack_result) override; 89 InputEventAckState ack_result) override;
88 90
89 // GetureEventFilterClient 91 // GestureEventQueueClient
90 void SendGestureEventImmediately( 92 void SendGestureEventImmediately(
91 const GestureEventWithLatencyInfo& gesture_event) override; 93 const GestureEventWithLatencyInfo& gesture_event) override;
92 void OnGestureEventAck(const GestureEventWithLatencyInfo& event, 94 void OnGestureEventAck(const GestureEventWithLatencyInfo& event,
93 InputEventAckState ack_result) override; 95 InputEventAckState ack_result) override;
94 96
97 // WheelEventQueueClient
98 void SendWheelEventImmediately(
99 const MouseWheelEventWithLatencyInfo& wheel_event) override;
100 void OnWheelEventAck(const MouseWheelEventWithLatencyInfo& event,
101 InputEventAckState ack_result) override;
102 void SetNeedsFlush() override;
103
104 bool SendSelectMessage(scoped_ptr<IPC::Message> message);
95 bool SendMoveCaret(scoped_ptr<IPC::Message> message); 105 bool SendMoveCaret(scoped_ptr<IPC::Message> message);
96 bool SendSelectMessage(scoped_ptr<IPC::Message> message);
97 bool Send(IPC::Message* message); 106 bool Send(IPC::Message* message);
98 107
99 // Filters and forwards |input_event| to the appropriate handler. 108 // Filters and forwards |input_event| to the appropriate handler.
100 void FilterAndSendWebInputEvent(const blink::WebInputEvent& input_event, 109 void FilterAndSendWebInputEvent(const blink::WebInputEvent& input_event,
101 const ui::LatencyInfo& latency_info); 110 const ui::LatencyInfo& latency_info);
102 111
103 // Utility routine for filtering and forwarding |input_event| to the 112 // Utility routine for filtering and forwarding |input_event| to the
104 // appropriate handler. |input_event| will be offered to the overscroll 113 // appropriate handler. |input_event| will be offered to the overscroll
105 // controller, client and renderer, in that order. 114 // controller, client and renderer, in that order.
106 void OfferToHandlers(const blink::WebInputEvent& input_event, 115 void OfferToHandlers(const blink::WebInputEvent& input_event,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 211
203 // True if a mouse move event was sent to the render view and we are waiting 212 // True if a mouse move event was sent to the render view and we are waiting
204 // for a corresponding InputHostMsg_HandleInputEvent_ACK message. 213 // for a corresponding InputHostMsg_HandleInputEvent_ACK message.
205 bool mouse_move_pending_; 214 bool mouse_move_pending_;
206 215
207 // The next mouse move event to send (only non-null while mouse_move_pending_ 216 // The next mouse move event to send (only non-null while mouse_move_pending_
208 // is true). 217 // is true).
209 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move_; 218 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move_;
210 MouseEventWithLatencyInfo current_mouse_move_; 219 MouseEventWithLatencyInfo current_mouse_move_;
211 220
212 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent
213 // and we are waiting for a corresponding ack.
214 bool mouse_wheel_pending_;
215 MouseWheelEventWithLatencyInfo current_wheel_event_;
216
217 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send.
218 // Unlike mouse moves, mouse wheel events received while one is pending are
219 // coalesced (by accumulating deltas) if they match the previous event in
220 // modifiers. On the Mac, in particular, mouse wheel events are received at a
221 // high rate; not waiting for the ack results in jankiness, and using the same
222 // mechanism as for mouse moves (just dropping old events when multiple ones
223 // would be queued) results in very slow scrolling.
224 typedef std::deque<MouseWheelEventWithLatencyInfo> WheelEventQueue;
225 WheelEventQueue coalesced_mouse_wheel_events_;
226
227 // A queue of keyboard events. We can't trust data from the renderer so we 221 // A queue of keyboard events. We can't trust data from the renderer so we
228 // stuff key events into a queue and pop them out on ACK, feeding our copy 222 // stuff key events into a queue and pop them out on ACK, feeding our copy
229 // back to whatever unhandled handler instead of the returned version. 223 // back to whatever unhandled handler instead of the returned version.
230 typedef std::deque<NativeWebKeyboardEventWithLatencyInfo> KeyQueue; 224 typedef std::deque<NativeWebKeyboardEventWithLatencyInfo> KeyQueue;
231 KeyQueue key_queue_; 225 KeyQueue key_queue_;
232 226
233 // The time when an input event was sent to the client. 227 // The time when an input event was sent to the client.
234 base::TimeTicks input_event_start_time_; 228 base::TimeTicks input_event_start_time_;
235 229
236 // The source of the ack within the scope of |ProcessInputEventAck()|. 230 // The source of the ack within the scope of |ProcessInputEventAck()|.
237 // Defaults to ACK_SOURCE_NONE. 231 // Defaults to ACK_SOURCE_NONE.
238 AckSource current_ack_source_; 232 AckSource current_ack_source_;
239 233
240 // Whether a |FlushInput()| call has yet been accompanied by a 234 // Whether a |FlushInput()| call has yet been accompanied by a
241 // |DidFlushAllInput()| call to the client. 235 // |DidFlushAllInput()| call to the client.
242 bool flush_requested_; 236 bool flush_requested_;
243 237
244 // Whether there are any active flings in the renderer. As the fling 238 // Whether there are any active flings in the renderer. As the fling
245 // end notification is asynchronous, we use a count rather than a boolean 239 // end notification is asynchronous, we use a count rather than a boolean
246 // to avoid races in bookkeeping when starting a new fling. 240 // to avoid races in bookkeeping when starting a new fling.
247 int active_renderer_fling_count_; 241 int active_renderer_fling_count_;
248 242
249 TouchEventQueue touch_event_queue_; 243 TouchEventQueue touch_event_queue_;
250 GestureEventQueue gesture_event_queue_; 244 GestureEventQueue gesture_event_queue_;
245 WheelEventQueue wheel_event_queue_;
251 TouchActionFilter touch_action_filter_; 246 TouchActionFilter touch_action_filter_;
252 InputEventStreamValidator input_stream_validator_; 247 InputEventStreamValidator input_stream_validator_;
253 InputEventStreamValidator output_stream_validator_; 248 InputEventStreamValidator output_stream_validator_;
254 249
255 DISALLOW_COPY_AND_ASSIGN(InputRouterImpl); 250 DISALLOW_COPY_AND_ASSIGN(InputRouterImpl);
256 }; 251 };
257 252
258 } // namespace content 253 } // namespace content
259 254
260 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_IMPL_H_ 255 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698