| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 using blink::WebMouseEvent; | 48 using blink::WebMouseEvent; |
| 49 using blink::WebMouseWheelEvent; | 49 using blink::WebMouseWheelEvent; |
| 50 | 50 |
| 51 namespace content { | 51 namespace content { |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 // TODO(jdduke): Instead of relying on command line flags or conditional | 54 // TODO(jdduke): Instead of relying on command line flags or conditional |
| 55 // conditional compilation here, we should instead use an InputRouter::Settings | 55 // conditional compilation here, we should instead use an InputRouter::Settings |
| 56 // construct, supplied and customized by the RenderWidgetHostView. See | 56 // construct, supplied and customized by the RenderWidgetHostView. See |
| 57 // crbug.com/343917. | 57 // crbug.com/343917. |
| 58 bool GetTouchAckTimeoutDelayMs(size_t* touch_ack_timeout_delay_ms) { | 58 bool GetTouchAckTimeoutDelay(base::TimeDelta* touch_ack_timeout_delay) { |
| 59 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); | 59 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); |
| 60 if (!parsed_command_line->HasSwitch(switches::kTouchAckTimeoutDelayMs)) | 60 if (!parsed_command_line->HasSwitch(switches::kTouchAckTimeoutDelayMs)) |
| 61 return false; | 61 return false; |
| 62 | 62 |
| 63 std::string timeout_string = parsed_command_line->GetSwitchValueASCII( | 63 std::string timeout_string = parsed_command_line->GetSwitchValueASCII( |
| 64 switches::kTouchAckTimeoutDelayMs); | 64 switches::kTouchAckTimeoutDelayMs); |
| 65 size_t timeout_value; | 65 size_t timeout_ms; |
| 66 if (!base::StringToSizeT(timeout_string, &timeout_value)) | 66 if (!base::StringToSizeT(timeout_string, &timeout_ms)) |
| 67 return false; | 67 return false; |
| 68 | 68 |
| 69 *touch_ack_timeout_delay_ms = timeout_value; | 69 *touch_ack_timeout_delay = base::TimeDelta::FromMilliseconds(timeout_ms); |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 #if defined(OS_ANDROID) | 73 #if defined(OS_ANDROID) |
| 74 double GetTouchMoveSlopSuppressionLengthDips() { | 74 double GetTouchMoveSlopSuppressionLengthDips() { |
| 75 const double touch_slop_length_pixels = | 75 const double touch_slop_length_pixels = |
| 76 static_cast<double>(gfx::ViewConfiguration::GetTouchSlopInPixels()); | 76 static_cast<double>(gfx::ViewConfiguration::GetTouchSlopInPixels()); |
| 77 const double device_scale_factor = | 77 const double device_scale_factor = |
| 78 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor(); | 78 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor(); |
| 79 return touch_slop_length_pixels / device_scale_factor; | 79 return touch_slop_length_pixels / device_scale_factor; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 int routing_id) | 139 int routing_id) |
| 140 : sender_(sender), | 140 : sender_(sender), |
| 141 client_(client), | 141 client_(client), |
| 142 ack_handler_(ack_handler), | 142 ack_handler_(ack_handler), |
| 143 routing_id_(routing_id), | 143 routing_id_(routing_id), |
| 144 select_range_pending_(false), | 144 select_range_pending_(false), |
| 145 move_caret_pending_(false), | 145 move_caret_pending_(false), |
| 146 mouse_move_pending_(false), | 146 mouse_move_pending_(false), |
| 147 mouse_wheel_pending_(false), | 147 mouse_wheel_pending_(false), |
| 148 touch_ack_timeout_supported_(false), | 148 touch_ack_timeout_supported_(false), |
| 149 touch_ack_timeout_delay_ms_(std::numeric_limits<size_t>::max()), | |
| 150 current_view_flags_(0), | 149 current_view_flags_(0), |
| 151 current_ack_source_(ACK_SOURCE_NONE), | 150 current_ack_source_(ACK_SOURCE_NONE), |
| 152 gesture_event_queue_(new GestureEventQueue(this, this)) { | 151 gesture_event_queue_(new GestureEventQueue(this, this)) { |
| 153 DCHECK(sender); | 152 DCHECK(sender); |
| 154 DCHECK(client); | 153 DCHECK(client); |
| 155 DCHECK(ack_handler); | 154 DCHECK(ack_handler); |
| 156 touch_event_queue_.reset(new TouchEventQueue( | 155 touch_event_queue_.reset(new TouchEventQueue( |
| 157 this, GetTouchScrollingMode(), GetTouchMoveSlopSuppressionLengthDips())); | 156 this, GetTouchScrollingMode(), GetTouchMoveSlopSuppressionLengthDips())); |
| 158 touch_ack_timeout_supported_ = | 157 touch_ack_timeout_supported_ = |
| 159 GetTouchAckTimeoutDelayMs(&touch_ack_timeout_delay_ms_); | 158 GetTouchAckTimeoutDelay(&touch_ack_timeout_delay_); |
| 160 UpdateTouchAckTimeoutEnabled(); | 159 UpdateTouchAckTimeoutEnabled(); |
| 161 } | 160 } |
| 162 | 161 |
| 163 InputRouterImpl::~InputRouterImpl() {} | 162 InputRouterImpl::~InputRouterImpl() {} |
| 164 | 163 |
| 165 void InputRouterImpl::Flush() {} | 164 void InputRouterImpl::Flush() {} |
| 166 | 165 |
| 167 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { | 166 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { |
| 168 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); | 167 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); |
| 169 switch (message->type()) { | 168 switch (message->type()) { |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 x, y, 0, event.latency)); | 779 x, y, 0, event.latency)); |
| 781 } | 780 } |
| 782 break; | 781 break; |
| 783 case WebMouseEvent::ButtonNone: | 782 case WebMouseEvent::ButtonNone: |
| 784 break; | 783 break; |
| 785 } | 784 } |
| 786 } | 785 } |
| 787 | 786 |
| 788 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { | 787 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { |
| 789 if (!touch_ack_timeout_supported_) { | 788 if (!touch_ack_timeout_supported_) { |
| 790 touch_event_queue_->SetAckTimeoutEnabled(false, 0); | 789 touch_event_queue_->SetAckTimeoutEnabled(false, base::TimeDelta()); |
| 791 return; | 790 return; |
| 792 } | 791 } |
| 793 | 792 |
| 794 // Mobile sites tend to be well-behaved with respect to touch handling, so | 793 // Mobile sites tend to be well-behaved with respect to touch handling, so |
| 795 // they have less need for the touch timeout fallback. | 794 // they have less need for the touch timeout fallback. |
| 796 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; | 795 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; |
| 797 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; | 796 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; |
| 798 | 797 |
| 799 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves | 798 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves |
| 800 // little purpose. It's also a strong signal that touch handling is critical | 799 // little purpose. It's also a strong signal that touch handling is critical |
| 801 // to page functionality, so the timeout could do more harm than good. | 800 // to page functionality, so the timeout could do more harm than good. |
| 802 const bool touch_action_none = | 801 const bool touch_action_none = |
| 803 touch_action_filter_.allowed_touch_action() == TOUCH_ACTION_NONE; | 802 touch_action_filter_.allowed_touch_action() == TOUCH_ACTION_NONE; |
| 804 | 803 |
| 805 const bool touch_ack_timeout_enabled = !fixed_page_scale && | 804 const bool touch_ack_timeout_enabled = !fixed_page_scale && |
| 806 !mobile_viewport && | 805 !mobile_viewport && |
| 807 !touch_action_none; | 806 !touch_action_none; |
| 808 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled, | 807 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled, |
| 809 touch_ack_timeout_delay_ms_); | 808 touch_ack_timeout_delay_); |
| 810 } | 809 } |
| 811 | 810 |
| 812 bool InputRouterImpl::IsInOverscrollGesture() const { | 811 bool InputRouterImpl::IsInOverscrollGesture() const { |
| 813 OverscrollController* controller = client_->GetOverscrollController(); | 812 OverscrollController* controller = client_->GetOverscrollController(); |
| 814 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 813 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
| 815 } | 814 } |
| 816 | 815 |
| 817 } // namespace content | 816 } // namespace content |
| OLD | NEW |