| 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 #include "content/browser/renderer_host/input/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (controller) | 210 if (controller) |
| 211 controller->DiscardingGestureEvent(gesture_event.event); | 211 controller->DiscardingGestureEvent(gesture_event.event); |
| 212 return; | 212 return; |
| 213 } | 213 } |
| 214 | 214 |
| 215 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); | 215 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void InputRouterImpl::SendTouchEvent( | 218 void InputRouterImpl::SendTouchEvent( |
| 219 const TouchEventWithLatencyInfo& touch_event) { | 219 const TouchEventWithLatencyInfo& touch_event) { |
| 220 LOG(ERROR) << "Queueing touch event"; |
| 220 touch_event_queue_->QueueEvent(touch_event); | 221 touch_event_queue_->QueueEvent(touch_event); |
| 221 } | 222 } |
| 222 | 223 |
| 223 // Forwards MouseEvent without passing it through | 224 // Forwards MouseEvent without passing it through |
| 224 // TouchpadTapSuppressionController. | 225 // TouchpadTapSuppressionController. |
| 225 void InputRouterImpl::SendMouseEventImmediately( | 226 void InputRouterImpl::SendMouseEventImmediately( |
| 226 const MouseEventWithLatencyInfo& mouse_event) { | 227 const MouseEventWithLatencyInfo& mouse_event) { |
| 227 // Avoid spamming the renderer with mouse move events. It is important | 228 // Avoid spamming the renderer with mouse move events. It is important |
| 228 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our | 229 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our |
| 229 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way | 230 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way |
| 230 // more WM_MOUSEMOVE events than we wish to send to the renderer. | 231 // more WM_MOUSEMOVE events than we wish to send to the renderer. |
| 231 if (mouse_event.event.type == WebInputEvent::MouseMove) { | 232 if (mouse_event.event.type == WebInputEvent::MouseMove) { |
| 232 if (mouse_move_pending_) { | 233 if (mouse_move_pending_) { |
| 233 if (!next_mouse_move_) | 234 if (!next_mouse_move_) |
| 234 next_mouse_move_.reset(new MouseEventWithLatencyInfo(mouse_event)); | 235 next_mouse_move_.reset(new MouseEventWithLatencyInfo(mouse_event)); |
| 235 else | 236 else |
| 236 next_mouse_move_->CoalesceWith(mouse_event); | 237 next_mouse_move_->CoalesceWith(mouse_event); |
| 237 return; | 238 return; |
| 238 } | 239 } |
| 239 mouse_move_pending_ = true; | 240 mouse_move_pending_ = true; |
| 240 } | 241 } |
| 241 | 242 |
| 242 FilterAndSendWebInputEvent(mouse_event.event, mouse_event.latency, false); | 243 FilterAndSendWebInputEvent(mouse_event.event, mouse_event.latency, false); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void InputRouterImpl::SendTouchEventImmediately( | 246 void InputRouterImpl::SendTouchEventImmediately( |
| 246 const TouchEventWithLatencyInfo& touch_event) { | 247 const TouchEventWithLatencyInfo& touch_event) { |
| 248 LOG(ERROR) << "Skipping Queue"; |
| 247 FilterAndSendWebInputEvent(touch_event.event, touch_event.latency, false); | 249 FilterAndSendWebInputEvent(touch_event.event, touch_event.latency, false); |
| 248 } | 250 } |
| 249 | 251 |
| 250 void InputRouterImpl::SendGestureEventImmediately( | 252 void InputRouterImpl::SendGestureEventImmediately( |
| 251 const GestureEventWithLatencyInfo& gesture_event) { | 253 const GestureEventWithLatencyInfo& gesture_event) { |
| 252 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); | 254 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); |
| 253 } | 255 } |
| 254 | 256 |
| 255 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const { | 257 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const { |
| 256 if (key_queue_.empty()) | 258 if (key_queue_.empty()) |
| 257 return NULL; | 259 return NULL; |
| 258 return &key_queue_.front(); | 260 return &key_queue_.front(); |
| 259 } | 261 } |
| 260 | 262 |
| 261 bool InputRouterImpl::ShouldForwardTouchEvent() const { | 263 bool InputRouterImpl::ShouldForwardTouchEvent() const { |
| 264 if (!has_touch_handler_) |
| 265 LOG(ERROR) << "No touch handler"; |
| 262 // Always send a touch event if the renderer has a touch-event handler. It is | 266 // Always send a touch event if the renderer has a touch-event handler. It is |
| 263 // possible that a renderer stops listening to touch-events while there are | 267 // possible that a renderer stops listening to touch-events while there are |
| 264 // still events in the touch-queue. In such cases, the new events should still | 268 // still events in the touch-queue. In such cases, the new events should still |
| 265 // get into the queue. | 269 // get into the queue. |
| 266 return has_touch_handler_ || !touch_event_queue_->empty(); | 270 return has_touch_handler_ || !touch_event_queue_->empty(); |
| 267 } | 271 } |
| 268 | 272 |
| 269 void InputRouterImpl::OnViewUpdated(int view_flags) { | 273 void InputRouterImpl::OnViewUpdated(int view_flags) { |
| 270 bool fixed_page_scale = (view_flags & FIXED_PAGE_SCALE) != 0; | 274 bool fixed_page_scale = (view_flags & FIXED_PAGE_SCALE) != 0; |
| 271 bool mobile_viewport = (view_flags & MOBILE_VIEWPORT) != 0; | 275 bool mobile_viewport = (view_flags & MOBILE_VIEWPORT) != 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 289 IPC_END_MESSAGE_MAP() | 293 IPC_END_MESSAGE_MAP() |
| 290 | 294 |
| 291 if (!message_is_ok) | 295 if (!message_is_ok) |
| 292 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); | 296 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); |
| 293 | 297 |
| 294 return handled; | 298 return handled; |
| 295 } | 299 } |
| 296 | 300 |
| 297 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event, | 301 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event, |
| 298 InputEventAckState ack_result) { | 302 InputEventAckState ack_result) { |
| 303 LOG(ERROR) << "Touch Event Ack"; |
| 299 ack_handler_->OnTouchEventAck(event, ack_result); | 304 ack_handler_->OnTouchEventAck(event, ack_result); |
| 300 } | 305 } |
| 301 | 306 |
| 302 void InputRouterImpl::OnGestureEventAck( | 307 void InputRouterImpl::OnGestureEventAck( |
| 303 const GestureEventWithLatencyInfo& event, | 308 const GestureEventWithLatencyInfo& event, |
| 304 InputEventAckState ack_result) { | 309 InputEventAckState ack_result) { |
| 305 ProcessAckForOverscroll(event.event, ack_result); | 310 ProcessAckForOverscroll(event.event, ack_result); |
| 306 ack_handler_->OnGestureEventAck(event, ack_result); | 311 ack_handler_->OnGestureEventAck(event, ack_result); |
| 307 } | 312 } |
| 308 | 313 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 break; | 729 break; |
| 725 } | 730 } |
| 726 } | 731 } |
| 727 | 732 |
| 728 bool InputRouterImpl::IsInOverscrollGesture() const { | 733 bool InputRouterImpl::IsInOverscrollGesture() const { |
| 729 OverscrollController* controller = client_->GetOverscrollController(); | 734 OverscrollController* controller = client_->GetOverscrollController(); |
| 730 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 735 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
| 731 } | 736 } |
| 732 | 737 |
| 733 } // namespace content | 738 } // namespace content |
| OLD | NEW |