| 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 <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 13 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
| 14 #include "content/browser/renderer_host/input/input_ack_handler.h" | 14 #include "content/browser/renderer_host/input/input_ack_handler.h" |
| 15 #include "content/browser/renderer_host/input/input_router_client.h" | 15 #include "content/browser/renderer_host/input/input_router_client.h" |
| 16 #include "content/browser/renderer_host/input/touch_event_queue.h" | 16 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 17 #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/web_input_event_util.h" |
| 18 #include "content/common/content_constants_internal.h" | 19 #include "content/common/content_constants_internal.h" |
| 19 #include "content/common/edit_command.h" | 20 #include "content/common/edit_command.h" |
| 20 #include "content/common/input/input_event_ack_state.h" | 21 #include "content/common/input/input_event_ack_state.h" |
| 21 #include "content/common/input/touch_action.h" | 22 #include "content/common/input/touch_action.h" |
| 22 #include "content/common/input/web_touch_event_traits.h" | 23 #include "content/common/input/web_touch_event_traits.h" |
| 23 #include "content/common/input_messages.h" | 24 #include "content/common/input_messages.h" |
| 24 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
| 25 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/browser/notification_types.h" | 27 #include "content/public/browser/notification_types.h" |
| 27 #include "content/public/browser/user_metrics.h" | 28 #include "content/public/browser/user_metrics.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return !touch_event_queue_.empty() || | 252 return !touch_event_queue_.empty() || |
| 252 !gesture_event_queue_.empty() || | 253 !gesture_event_queue_.empty() || |
| 253 !key_queue_.empty() || | 254 !key_queue_.empty() || |
| 254 mouse_move_pending_ || | 255 mouse_move_pending_ || |
| 255 mouse_wheel_pending_ || | 256 mouse_wheel_pending_ || |
| 256 select_message_pending_ || | 257 select_message_pending_ || |
| 257 move_caret_pending_ || | 258 move_caret_pending_ || |
| 258 active_renderer_fling_count_ > 0; | 259 active_renderer_fling_count_ > 0; |
| 259 } | 260 } |
| 260 | 261 |
| 262 void InputRouterImpl::SetDeviceScaleFactor(float device_scale_factor) { |
| 263 device_scale_factor_ = device_scale_factor; |
| 264 } |
| 265 |
| 261 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { | 266 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { |
| 262 bool handled = true; | 267 bool handled = true; |
| 263 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) | 268 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) |
| 264 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) | 269 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) |
| 265 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) | 270 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) |
| 266 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) | 271 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) |
| 267 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) | 272 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) |
| 268 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, | 273 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, |
| 269 OnSelectMessageAck) | 274 OnSelectMessageAck) |
| 270 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 275 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 break; | 410 break; |
| 406 default: | 411 default: |
| 407 break; | 412 break; |
| 408 } | 413 } |
| 409 | 414 |
| 410 return consumed; | 415 return consumed; |
| 411 } | 416 } |
| 412 | 417 |
| 413 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, | 418 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, |
| 414 const ui::LatencyInfo& latency_info) { | 419 const ui::LatencyInfo& latency_info) { |
| 415 if (Send(new InputMsg_HandleInputEvent(routing_id(), &input_event, | 420 scoped_ptr<blink::WebInputEvent> event_in_viewport = |
| 421 ConvertWebInputEventToViewport(input_event, device_scale_factor_); |
| 422 |
| 423 const WebInputEvent* event_to_send = |
| 424 event_in_viewport ? event_in_viewport.get() : &input_event; |
| 425 if (Send(new InputMsg_HandleInputEvent(routing_id(), event_to_send, |
| 416 latency_info))) { | 426 latency_info))) { |
| 417 // Ack messages for ignored ack event types should never be sent by the | 427 // Ack messages for ignored ack event types should never be sent by the |
| 418 // renderer. Consequently, such event types should not affect event time | 428 // renderer. Consequently, such event types should not affect event time |
| 419 // or in-flight event count metrics. | 429 // or in-flight event count metrics. |
| 420 if (WebInputEventTraits::WillReceiveAckFromRenderer(input_event)) { | 430 if (WebInputEventTraits::WillReceiveAckFromRenderer(input_event)) { |
| 421 input_event_start_time_ = TimeTicks::Now(); | 431 input_event_start_time_ = TimeTicks::Now(); |
| 422 client_->IncrementInFlightEventCount(); | 432 client_->IncrementInFlightEventCount(); |
| 423 } | 433 } |
| 424 return true; | 434 return true; |
| 425 } | 435 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 return; | 649 return; |
| 640 | 650 |
| 641 if (HasPendingEvents()) | 651 if (HasPendingEvents()) |
| 642 return; | 652 return; |
| 643 | 653 |
| 644 flush_requested_ = false; | 654 flush_requested_ = false; |
| 645 client_->DidFlush(); | 655 client_->DidFlush(); |
| 646 } | 656 } |
| 647 | 657 |
| 648 } // namespace content | 658 } // namespace content |
| OLD | NEW |