| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 case INPUT_EVENT_ACK_STATE_UNKNOWN: return "UNKNOWN"; | 79 case INPUT_EVENT_ACK_STATE_UNKNOWN: return "UNKNOWN"; |
| 80 case INPUT_EVENT_ACK_STATE_CONSUMED: return "CONSUMED"; | 80 case INPUT_EVENT_ACK_STATE_CONSUMED: return "CONSUMED"; |
| 81 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED: return "NOT_CONSUMED"; | 81 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED: return "NOT_CONSUMED"; |
| 82 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: return "NO_CONSUMER_EXISTS"; | 82 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: return "NO_CONSUMER_EXISTS"; |
| 83 case INPUT_EVENT_ACK_STATE_IGNORED: return "IGNORED"; | 83 case INPUT_EVENT_ACK_STATE_IGNORED: return "IGNORED"; |
| 84 } | 84 } |
| 85 DLOG(WARNING) << "Unhandled InputEventAckState in GetEventAckName."; | 85 DLOG(WARNING) << "Unhandled InputEventAckState in GetEventAckName."; |
| 86 return ""; | 86 return ""; |
| 87 } | 87 } |
| 88 | 88 |
| 89 TouchEventQueue::TouchScrollingMode GetTouchScrollingMode() |
| 90 { |
| 91 std::string modeString = CommandLine::ForCurrentProcess()-> |
| 92 GetSwitchValueASCII(switches::kTouchScrollingMode); |
| 93 if (modeString == switches::kTouchScrollingModeSyncTouchmove) |
| 94 return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE; |
| 95 if (modeString == switches::kTouchScrollingModeAbsorbTouchmove) |
| 96 return TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE; |
| 97 if (modeString != "" && |
| 98 modeString != switches::kTouchScrollingModeTouchcancel) |
| 99 LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString; |
| 100 return TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL; |
| 101 } |
| 102 |
| 89 } // namespace | 103 } // namespace |
| 90 | 104 |
| 91 InputRouterImpl::InputRouterImpl(IPC::Sender* sender, | 105 InputRouterImpl::InputRouterImpl(IPC::Sender* sender, |
| 92 InputRouterClient* client, | 106 InputRouterClient* client, |
| 93 InputAckHandler* ack_handler, | 107 InputAckHandler* ack_handler, |
| 94 int routing_id) | 108 int routing_id) |
| 95 : sender_(sender), | 109 : sender_(sender), |
| 96 client_(client), | 110 client_(client), |
| 97 ack_handler_(ack_handler), | 111 ack_handler_(ack_handler), |
| 98 routing_id_(routing_id), | 112 routing_id_(routing_id), |
| 99 select_range_pending_(false), | 113 select_range_pending_(false), |
| 100 move_caret_pending_(false), | 114 move_caret_pending_(false), |
| 101 mouse_move_pending_(false), | 115 mouse_move_pending_(false), |
| 102 mouse_wheel_pending_(false), | 116 mouse_wheel_pending_(false), |
| 103 touch_ack_timeout_enabled_(false), | 117 touch_ack_timeout_enabled_(false), |
| 104 touch_ack_timeout_delay_ms_(std::numeric_limits<size_t>::max()), | 118 touch_ack_timeout_delay_ms_(std::numeric_limits<size_t>::max()), |
| 105 current_ack_source_(ACK_SOURCE_NONE), | 119 current_ack_source_(ACK_SOURCE_NONE), |
| 106 gesture_event_filter_(new GestureEventFilter(this, this)) { | 120 gesture_event_filter_(new GestureEventFilter(this, this)) { |
| 107 DCHECK(sender); | 121 DCHECK(sender); |
| 108 DCHECK(client); | 122 DCHECK(client); |
| 109 DCHECK(ack_handler); | 123 DCHECK(ack_handler); |
| 110 touch_event_queue_.reset(new TouchEventQueue(this)); | 124 touch_event_queue_.reset(new TouchEventQueue(this, GetTouchScrollingMode())); |
| 111 touch_ack_timeout_enabled_ = | 125 touch_ack_timeout_enabled_ = |
| 112 GetTouchAckTimeoutDelayMs(&touch_ack_timeout_delay_ms_); | 126 GetTouchAckTimeoutDelayMs(&touch_ack_timeout_delay_ms_); |
| 113 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled_, | 127 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled_, |
| 114 touch_ack_timeout_delay_ms_); | 128 touch_ack_timeout_delay_ms_); |
| 115 } | 129 } |
| 116 | 130 |
| 117 InputRouterImpl::~InputRouterImpl() {} | 131 InputRouterImpl::~InputRouterImpl() {} |
| 118 | 132 |
| 119 void InputRouterImpl::Flush() {} | 133 void InputRouterImpl::Flush() {} |
| 120 | 134 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 305 } |
| 292 | 306 |
| 293 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event, | 307 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event, |
| 294 InputEventAckState ack_result) { | 308 InputEventAckState ack_result) { |
| 295 ack_handler_->OnTouchEventAck(event, ack_result); | 309 ack_handler_->OnTouchEventAck(event, ack_result); |
| 296 } | 310 } |
| 297 | 311 |
| 298 void InputRouterImpl::OnGestureEventAck( | 312 void InputRouterImpl::OnGestureEventAck( |
| 299 const GestureEventWithLatencyInfo& event, | 313 const GestureEventWithLatencyInfo& event, |
| 300 InputEventAckState ack_result) { | 314 InputEventAckState ack_result) { |
| 315 touch_event_queue_->OnGestureEventAck(event, ack_result); |
| 301 ProcessAckForOverscroll(event.event, ack_result); | 316 ProcessAckForOverscroll(event.event, ack_result); |
| 302 ack_handler_->OnGestureEventAck(event, ack_result); | 317 ack_handler_->OnGestureEventAck(event, ack_result); |
| 303 } | 318 } |
| 304 | 319 |
| 305 bool InputRouterImpl::SendSelectRange(scoped_ptr<IPC::Message> message) { | 320 bool InputRouterImpl::SendSelectRange(scoped_ptr<IPC::Message> message) { |
| 306 DCHECK(message->type() == InputMsg_SelectRange::ID); | 321 DCHECK(message->type() == InputMsg_SelectRange::ID); |
| 307 if (select_range_pending_) { | 322 if (select_range_pending_) { |
| 308 next_selection_range_ = message.Pass(); | 323 next_selection_range_ = message.Pass(); |
| 309 return true; | 324 return true; |
| 310 } | 325 } |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 break; | 734 break; |
| 720 } | 735 } |
| 721 } | 736 } |
| 722 | 737 |
| 723 bool InputRouterImpl::IsInOverscrollGesture() const { | 738 bool InputRouterImpl::IsInOverscrollGesture() const { |
| 724 OverscrollController* controller = client_->GetOverscrollController(); | 739 OverscrollController* controller = client_->GetOverscrollController(); |
| 725 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 740 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
| 726 } | 741 } |
| 727 | 742 |
| 728 } // namespace content | 743 } // namespace content |
| OLD | NEW |