Chromium Code Reviews| 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/renderer/input/input_handler_proxy.h" | 5 #include "ui/events/blink/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 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/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "content/common/input/did_overscroll_params.h" | |
| 18 #include "content/common/input/web_input_event_traits.h" | |
| 19 #include "content/public/common/content_switches.h" | |
| 20 #include "content/renderer/input/input_handler_proxy_client.h" | |
| 21 #include "content/renderer/input/input_scroll_elasticity_controller.h" | |
| 22 #include "third_party/WebKit/public/platform/Platform.h" | |
| 23 #include "third_party/WebKit/public/web/WebInputEvent.h" | 17 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 18 #include "ui/events/blink/input_handler_proxy_client.h" | |
| 19 #include "ui/events/blink/input_scroll_elasticity_controller.h" | |
| 24 #include "ui/events/latency_info.h" | 20 #include "ui/events/latency_info.h" |
| 25 #include "ui/gfx/geometry/point_conversions.h" | 21 #include "ui/gfx/geometry/point_conversions.h" |
| 26 | 22 |
| 27 using blink::WebFloatPoint; | 23 using blink::WebFloatPoint; |
| 28 using blink::WebFloatSize; | 24 using blink::WebFloatSize; |
| 29 using blink::WebGestureEvent; | 25 using blink::WebGestureEvent; |
| 30 using blink::WebInputEvent; | 26 using blink::WebInputEvent; |
| 31 using blink::WebMouseEvent; | 27 using blink::WebMouseEvent; |
| 32 using blink::WebMouseWheelEvent; | 28 using blink::WebMouseWheelEvent; |
| 33 using blink::WebPoint; | 29 using blink::WebPoint; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 break; | 167 break; |
| 172 default: | 168 default: |
| 173 NOTREACHED(); | 169 NOTREACHED(); |
| 174 break; | 170 break; |
| 175 } | 171 } |
| 176 } | 172 } |
| 177 } | 173 } |
| 178 | 174 |
| 179 } // namespace | 175 } // namespace |
| 180 | 176 |
| 181 namespace content { | 177 namespace ui { |
| 182 | 178 |
| 183 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler, | 179 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler, |
| 184 InputHandlerProxyClient* client) | 180 InputHandlerProxyClient* client) |
| 185 : client_(client), | 181 : client_(client), |
| 186 input_handler_(input_handler), | 182 input_handler_(input_handler), |
| 187 deferred_fling_cancel_time_seconds_(0), | 183 deferred_fling_cancel_time_seconds_(0), |
| 188 synchronous_input_handler_(nullptr), | 184 synchronous_input_handler_(nullptr), |
| 189 allow_root_animate_(true), | 185 allow_root_animate_(true), |
| 190 #ifndef NDEBUG | 186 #ifndef NDEBUG |
| 191 expect_scroll_update_end_(false), | 187 expect_scroll_update_end_(false), |
| 192 #endif | 188 #endif |
| 193 gesture_scroll_on_impl_thread_(false), | 189 gesture_scroll_on_impl_thread_(false), |
| 194 gesture_pinch_on_impl_thread_(false), | 190 gesture_pinch_on_impl_thread_(false), |
| 195 fling_may_be_active_on_main_thread_(false), | 191 fling_may_be_active_on_main_thread_(false), |
| 196 disallow_horizontal_fling_scroll_(false), | 192 disallow_horizontal_fling_scroll_(false), |
| 197 disallow_vertical_fling_scroll_(false), | 193 disallow_vertical_fling_scroll_(false), |
| 198 has_fling_animation_started_(false), | 194 has_fling_animation_started_(false), |
| 195 smooth_scroll_enabled_(false), | |
| 199 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()) { | 196 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()) { |
| 200 DCHECK(client); | 197 DCHECK(client); |
| 201 input_handler_->BindToClient(this); | 198 input_handler_->BindToClient(this); |
| 202 smooth_scroll_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 203 switches::kEnableSmoothScrolling); | |
| 204 cc::ScrollElasticityHelper* scroll_elasticity_helper = | 199 cc::ScrollElasticityHelper* scroll_elasticity_helper = |
| 205 input_handler_->CreateScrollElasticityHelper(); | 200 input_handler_->CreateScrollElasticityHelper(); |
| 206 if (scroll_elasticity_helper) { | 201 if (scroll_elasticity_helper) { |
| 207 scroll_elasticity_controller_.reset( | 202 scroll_elasticity_controller_.reset( |
| 208 new InputScrollElasticityController(scroll_elasticity_helper)); | 203 new InputScrollElasticityController(scroll_elasticity_helper)); |
| 209 } | 204 } |
| 210 } | 205 } |
| 211 | 206 |
| 212 InputHandlerProxy::~InputHandlerProxy() {} | 207 InputHandlerProxy::~InputHandlerProxy() {} |
| 213 | 208 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 234 | 229 |
| 235 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = | 230 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = |
| 236 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); | 231 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); |
| 237 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); | 232 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); |
| 238 return disposition; | 233 return disposition; |
| 239 } | 234 } |
| 240 | 235 |
| 241 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( | 236 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( |
| 242 const WebInputEvent& event) { | 237 const WebInputEvent& event) { |
| 243 DCHECK(input_handler_); | 238 DCHECK(input_handler_); |
| 244 TRACE_EVENT1("input,benchmark", "InputHandlerProxy::HandleInputEvent", | |
| 245 "type", WebInputEventTraits::GetName(event.type)); | |
|
tdresser
2015/11/11 05:58:24
Why did this trace disappear?
Khushal
2015/11/11 06:18:26
WebInputEventTraits lives in content.
May be we m
| |
| 246 | 239 |
| 247 if (FilterInputEventForFlingBoosting(event)) | 240 if (FilterInputEventForFlingBoosting(event)) |
| 248 return DID_HANDLE; | 241 return DID_HANDLE; |
| 249 | 242 |
| 250 switch (event.type) { | 243 switch (event.type) { |
| 251 case WebInputEvent::MouseWheel: | 244 case WebInputEvent::MouseWheel: |
| 252 return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event)); | 245 return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event)); |
| 253 | 246 |
| 254 case WebInputEvent::GestureScrollBegin: | 247 case WebInputEvent::GestureScrollBegin: |
| 255 return HandleGestureScrollBegin( | 248 return HandleGestureScrollBegin( |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 863 if (!scroll_result.did_overscroll_root) | 856 if (!scroll_result.did_overscroll_root) |
| 864 return; | 857 return; |
| 865 | 858 |
| 866 TRACE_EVENT2("input", | 859 TRACE_EVENT2("input", |
| 867 "InputHandlerProxy::DidOverscroll", | 860 "InputHandlerProxy::DidOverscroll", |
| 868 "dx", | 861 "dx", |
| 869 scroll_result.unused_scroll_delta.x(), | 862 scroll_result.unused_scroll_delta.x(), |
| 870 "dy", | 863 "dy", |
| 871 scroll_result.unused_scroll_delta.y()); | 864 scroll_result.unused_scroll_delta.y()); |
| 872 | 865 |
| 873 DidOverscrollParams params; | |
| 874 params.accumulated_overscroll = scroll_result.accumulated_root_overscroll; | |
| 875 params.latest_overscroll_delta = scroll_result.unused_scroll_delta; | |
| 876 params.current_fling_velocity = | |
| 877 ToClientScrollIncrement(current_fling_velocity_); | |
| 878 params.causal_event_viewport_point = gfx::PointF(causal_event_viewport_point); | |
| 879 | |
| 880 if (fling_curve_) { | 866 if (fling_curve_) { |
| 881 static const int kFlingOverscrollThreshold = 1; | 867 static const int kFlingOverscrollThreshold = 1; |
| 882 disallow_horizontal_fling_scroll_ |= | 868 disallow_horizontal_fling_scroll_ |= |
| 883 std::abs(params.accumulated_overscroll.x()) >= | 869 std::abs(scroll_result.accumulated_root_overscroll.x()) >= |
| 884 kFlingOverscrollThreshold; | 870 kFlingOverscrollThreshold; |
| 885 disallow_vertical_fling_scroll_ |= | 871 disallow_vertical_fling_scroll_ |= |
| 886 std::abs(params.accumulated_overscroll.y()) >= | 872 std::abs(scroll_result.accumulated_root_overscroll.y()) >= |
| 887 kFlingOverscrollThreshold; | 873 kFlingOverscrollThreshold; |
| 888 } | 874 } |
| 889 | 875 |
| 890 client_->DidOverscroll(params); | 876 client_->DidOverscroll(scroll_result.accumulated_root_overscroll, |
| 877 scroll_result.unused_scroll_delta, | |
| 878 ToClientScrollIncrement(current_fling_velocity_), | |
| 879 gfx::PointF(causal_event_viewport_point)); | |
| 891 } | 880 } |
| 892 | 881 |
| 893 bool InputHandlerProxy::CancelCurrentFling() { | 882 bool InputHandlerProxy::CancelCurrentFling() { |
| 894 if (CancelCurrentFlingWithoutNotifyingClient()) { | 883 if (CancelCurrentFlingWithoutNotifyingClient()) { |
| 895 client_->DidStopFlinging(); | 884 client_->DidStopFlinging(); |
| 896 return true; | 885 return true; |
| 897 } | 886 } |
| 898 return false; | 887 return false; |
| 899 } | 888 } |
| 900 | 889 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 // It's possible the provided |increment| is sufficiently small as to not | 1027 // It's possible the provided |increment| is sufficiently small as to not |
| 1039 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 1028 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 1040 // Return true in this case to prevent early fling termination. | 1029 // Return true in this case to prevent early fling termination. |
| 1041 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 1030 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 1042 std::abs(clipped_increment.height) < kScrollEpsilon) | 1031 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 1043 return true; | 1032 return true; |
| 1044 | 1033 |
| 1045 return did_scroll; | 1034 return did_scroll; |
| 1046 } | 1035 } |
| 1047 | 1036 |
| 1048 } // namespace content | 1037 } // namespace ui |
| OLD | NEW |