| 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 "content/renderer/input/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "content/common/input/did_overscroll_params.h" | 12 #include "content/common/input/did_overscroll_params.h" |
| 12 #include "content/common/input/web_input_event_traits.h" | 13 #include "content/common/input/web_input_event_traits.h" |
| 14 #include "content/public/common/content_switches.h" |
| 13 #include "content/renderer/input/input_handler_proxy_client.h" | 15 #include "content/renderer/input/input_handler_proxy_client.h" |
| 14 #include "third_party/WebKit/public/platform/Platform.h" | 16 #include "third_party/WebKit/public/platform/Platform.h" |
| 15 #include "third_party/WebKit/public/web/WebInputEvent.h" | 17 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 16 #include "ui/events/latency_info.h" | 18 #include "ui/events/latency_info.h" |
| 17 #include "ui/gfx/frame_time.h" | 19 #include "ui/gfx/frame_time.h" |
| 18 #include "ui/gfx/geometry/point_conversions.h" | 20 #include "ui/gfx/geometry/point_conversions.h" |
| 19 | 21 |
| 20 using blink::WebFloatPoint; | 22 using blink::WebFloatPoint; |
| 21 using blink::WebFloatSize; | 23 using blink::WebFloatSize; |
| 22 using blink::WebGestureEvent; | 24 using blink::WebGestureEvent; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 expect_scroll_update_end_(false), | 152 expect_scroll_update_end_(false), |
| 151 #endif | 153 #endif |
| 152 gesture_scroll_on_impl_thread_(false), | 154 gesture_scroll_on_impl_thread_(false), |
| 153 gesture_pinch_on_impl_thread_(false), | 155 gesture_pinch_on_impl_thread_(false), |
| 154 fling_may_be_active_on_main_thread_(false), | 156 fling_may_be_active_on_main_thread_(false), |
| 155 disallow_horizontal_fling_scroll_(false), | 157 disallow_horizontal_fling_scroll_(false), |
| 156 disallow_vertical_fling_scroll_(false), | 158 disallow_vertical_fling_scroll_(false), |
| 157 has_fling_animation_started_(false) { | 159 has_fling_animation_started_(false) { |
| 158 DCHECK(client); | 160 DCHECK(client); |
| 159 input_handler_->BindToClient(this); | 161 input_handler_->BindToClient(this); |
| 162 smooth_scroll_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 163 switches::kEnableSmoothScrolling); |
| 160 } | 164 } |
| 161 | 165 |
| 162 InputHandlerProxy::~InputHandlerProxy() {} | 166 InputHandlerProxy::~InputHandlerProxy() {} |
| 163 | 167 |
| 164 void InputHandlerProxy::WillShutdown() { | 168 void InputHandlerProxy::WillShutdown() { |
| 165 input_handler_ = NULL; | 169 input_handler_ = NULL; |
| 166 client_->WillShutdown(); | 170 client_->WillShutdown(); |
| 167 } | 171 } |
| 168 | 172 |
| 169 InputHandlerProxy::EventDisposition | 173 InputHandlerProxy::EventDisposition |
| (...skipping 30 matching lines...) Expand all Loading... |
| 200 if (wheel_event.scrollByPage) { | 204 if (wheel_event.scrollByPage) { |
| 201 // TODO(jamesr): We don't properly handle scroll by page in the compositor | 205 // TODO(jamesr): We don't properly handle scroll by page in the compositor |
| 202 // thread, so punt it to the main thread. http://crbug.com/236639 | 206 // thread, so punt it to the main thread. http://crbug.com/236639 |
| 203 return DID_NOT_HANDLE; | 207 return DID_NOT_HANDLE; |
| 204 } | 208 } |
| 205 if (wheel_event.modifiers & WebInputEvent::ControlKey) { | 209 if (wheel_event.modifiers & WebInputEvent::ControlKey) { |
| 206 // Wheel events involving the control key never trigger scrolling, only | 210 // Wheel events involving the control key never trigger scrolling, only |
| 207 // event handlers. Forward to the main thread. | 211 // event handlers. Forward to the main thread. |
| 208 return DID_NOT_HANDLE; | 212 return DID_NOT_HANDLE; |
| 209 } | 213 } |
| 214 if (smooth_scroll_enabled_) { |
| 215 cc::InputHandler::ScrollStatus scroll_status = |
| 216 input_handler_->ScrollAnimated( |
| 217 gfx::Point(wheel_event.x, wheel_event.y), |
| 218 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY)); |
| 219 switch (scroll_status) { |
| 220 case cc::InputHandler::ScrollStarted: |
| 221 return DID_HANDLE; |
| 222 case cc::InputHandler::ScrollIgnored: |
| 223 return DROP_EVENT; |
| 224 default: |
| 225 return DID_NOT_HANDLE; |
| 226 } |
| 227 } |
| 210 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 228 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
| 211 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::Wheel); | 229 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::Wheel); |
| 212 switch (scroll_status) { | 230 switch (scroll_status) { |
| 213 case cc::InputHandler::ScrollStarted: { | 231 case cc::InputHandler::ScrollStarted: { |
| 214 TRACE_EVENT_INSTANT2( | 232 TRACE_EVENT_INSTANT2( |
| 215 "input", | 233 "input", |
| 216 "InputHandlerProxy::handle_input wheel scroll", | 234 "InputHandlerProxy::handle_input wheel scroll", |
| 217 TRACE_EVENT_SCOPE_THREAD, | 235 TRACE_EVENT_SCOPE_THREAD, |
| 218 "deltaX", | 236 "deltaX", |
| 219 -wheel_event.deltaX, | 237 -wheel_event.deltaX, |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 802 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 785 // Return true in this case to prevent early fling termination. | 803 // Return true in this case to prevent early fling termination. |
| 786 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 804 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 787 std::abs(clipped_increment.height) < kScrollEpsilon) | 805 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 788 return true; | 806 return true; |
| 789 | 807 |
| 790 return did_scroll; | 808 return did_scroll; |
| 791 } | 809 } |
| 792 | 810 |
| 793 } // namespace content | 811 } // namespace content |
| OLD | NEW |