OLD | NEW |
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" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Returns true if |input_event| was consumed by the client. | 111 // Returns true if |input_event| was consumed by the client. |
112 bool OfferToClient(const blink::WebInputEvent& input_event, | 112 bool OfferToClient(const blink::WebInputEvent& input_event, |
113 const ui::LatencyInfo& latency_info); | 113 const ui::LatencyInfo& latency_info); |
114 | 114 |
115 // Returns true if |input_event| was successfully sent to the renderer | 115 // Returns true if |input_event| was successfully sent to the renderer |
116 // as an async IPC Message. | 116 // as an async IPC Message. |
117 bool OfferToRenderer(const blink::WebInputEvent& input_event, | 117 bool OfferToRenderer(const blink::WebInputEvent& input_event, |
118 const ui::LatencyInfo& latency_info, | 118 const ui::LatencyInfo& latency_info, |
119 bool is_keyboard_shortcut); | 119 bool is_keyboard_shortcut); |
120 | 120 |
| 121 // A data structure that attaches some metadata to a WebMouseWheelEvent |
| 122 // and its latency info. |
| 123 struct QueuedWheelEvent { |
| 124 QueuedWheelEvent(); |
| 125 QueuedWheelEvent(const MouseWheelEventWithLatencyInfo& event, |
| 126 bool synthesized_from_pinch); |
| 127 ~QueuedWheelEvent(); |
| 128 |
| 129 MouseWheelEventWithLatencyInfo event; |
| 130 bool synthesized_from_pinch; |
| 131 }; |
| 132 |
| 133 // Enqueue or send a mouse wheel event. |
| 134 void SendWheelEvent(const QueuedWheelEvent& wheel_event); |
| 135 |
| 136 // Given a Touchpad GesturePinchUpdate event, create and send a synthetic |
| 137 // wheel event for it. |
| 138 void SendSyntheticWheelEventForPinch( |
| 139 const GestureEventWithLatencyInfo& pinch_event); |
| 140 |
121 // IPC message handlers | 141 // IPC message handlers |
122 void OnInputEventAck(blink::WebInputEvent::Type event_type, | 142 void OnInputEventAck(blink::WebInputEvent::Type event_type, |
123 InputEventAckState ack_result, | 143 InputEventAckState ack_result, |
124 const ui::LatencyInfo& latency_info); | 144 const ui::LatencyInfo& latency_info); |
125 void OnMsgMoveCaretAck(); | 145 void OnMsgMoveCaretAck(); |
126 void OnSelectRangeAck(); | 146 void OnSelectRangeAck(); |
127 void OnHasTouchEventHandlers(bool has_handlers); | 147 void OnHasTouchEventHandlers(bool has_handlers); |
128 void OnSetTouchAction(TouchAction touch_action); | 148 void OnSetTouchAction(TouchAction touch_action); |
129 | 149 |
130 // Indicates the source of an ack provided to |ProcessInputEventAck()|. | 150 // Indicates the source of an ack provided to |ProcessInputEventAck()|. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // for a corresponding InputHostMsg_HandleInputEvent_ACK message. | 229 // for a corresponding InputHostMsg_HandleInputEvent_ACK message. |
210 bool mouse_move_pending_; | 230 bool mouse_move_pending_; |
211 | 231 |
212 // The next mouse move event to send (only non-null while mouse_move_pending_ | 232 // The next mouse move event to send (only non-null while mouse_move_pending_ |
213 // is true). | 233 // is true). |
214 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move_; | 234 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move_; |
215 | 235 |
216 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent | 236 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent |
217 // and we are waiting for a corresponding ack. | 237 // and we are waiting for a corresponding ack. |
218 bool mouse_wheel_pending_; | 238 bool mouse_wheel_pending_; |
219 MouseWheelEventWithLatencyInfo current_wheel_event_; | 239 QueuedWheelEvent current_wheel_event_; |
220 | 240 |
221 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send. | 241 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send. |
222 // Unlike mouse moves, mouse wheel events received while one is pending are | 242 // Unlike mouse moves, mouse wheel events received while one is pending are |
223 // coalesced (by accumulating deltas) if they match the previous event in | 243 // coalesced (by accumulating deltas) if they match the previous event in |
224 // modifiers. On the Mac, in particular, mouse wheel events are received at a | 244 // modifiers. On the Mac, in particular, mouse wheel events are received at a |
225 // high rate; not waiting for the ack results in jankiness, and using the same | 245 // high rate; not waiting for the ack results in jankiness, and using the same |
226 // mechanism as for mouse moves (just dropping old events when multiple ones | 246 // mechanism as for mouse moves (just dropping old events when multiple ones |
227 // would be queued) results in very slow scrolling. | 247 // would be queued) results in very slow scrolling. |
228 typedef std::deque<MouseWheelEventWithLatencyInfo> WheelEventQueue; | 248 typedef std::deque<QueuedWheelEvent> WheelEventQueue; |
229 WheelEventQueue coalesced_mouse_wheel_events_; | 249 WheelEventQueue coalesced_mouse_wheel_events_; |
230 | 250 |
231 // A queue of keyboard events. We can't trust data from the renderer so we | 251 // A queue of keyboard events. We can't trust data from the renderer so we |
232 // stuff key events into a queue and pop them out on ACK, feeding our copy | 252 // stuff key events into a queue and pop them out on ACK, feeding our copy |
233 // back to whatever unhandled handler instead of the returned version. | 253 // back to whatever unhandled handler instead of the returned version. |
234 typedef std::deque<NativeWebKeyboardEvent> KeyQueue; | 254 typedef std::deque<NativeWebKeyboardEvent> KeyQueue; |
235 KeyQueue key_queue_; | 255 KeyQueue key_queue_; |
236 | 256 |
237 // The time when an input event was sent to the client. | 257 // The time when an input event was sent to the client. |
238 base::TimeTicks input_event_start_time_; | 258 base::TimeTicks input_event_start_time_; |
(...skipping 17 matching lines...) Expand all Loading... |
256 GestureEventQueue gesture_event_queue_; | 276 GestureEventQueue gesture_event_queue_; |
257 TouchActionFilter touch_action_filter_; | 277 TouchActionFilter touch_action_filter_; |
258 InputEventStreamValidator event_stream_validator_; | 278 InputEventStreamValidator event_stream_validator_; |
259 | 279 |
260 DISALLOW_COPY_AND_ASSIGN(InputRouterImpl); | 280 DISALLOW_COPY_AND_ASSIGN(InputRouterImpl); |
261 }; | 281 }; |
262 | 282 |
263 } // namespace content | 283 } // namespace content |
264 | 284 |
265 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_IMPL_H_ | 285 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_IMPL_H_ |
OLD | NEW |