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( | |
jdduke (slow)
2014/07/08 21:26:20
Apologies for the drive-by, but why do we need a f
jdduke (slow)
2014/07/08 21:28:34
Hmm, disregard that, it looks like you're re-using
| |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 if (wheel_event.scrollByPage) { | 205 if (wheel_event.scrollByPage) { |
202 // TODO(jamesr): We don't properly handle scroll by page in the compositor | 206 // TODO(jamesr): We don't properly handle scroll by page in the compositor |
203 // thread, so punt it to the main thread. http://crbug.com/236639 | 207 // thread, so punt it to the main thread. http://crbug.com/236639 |
204 return DID_NOT_HANDLE; | 208 return DID_NOT_HANDLE; |
205 } | 209 } |
206 if (wheel_event.modifiers & WebInputEvent::ControlKey) { | 210 if (wheel_event.modifiers & WebInputEvent::ControlKey) { |
207 // Wheel events involving the control key never trigger scrolling, only | 211 // Wheel events involving the control key never trigger scrolling, only |
208 // event handlers. Forward to the main thread. | 212 // event handlers. Forward to the main thread. |
209 return DID_NOT_HANDLE; | 213 return DID_NOT_HANDLE; |
210 } | 214 } |
215 if (smooth_scroll_enabled_) { | |
216 cc::InputHandler::ScrollStatus scroll_status = | |
217 input_handler_->ScrollAnimated( | |
218 gfx::Point(wheel_event.x, wheel_event.y), | |
219 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY)); | |
220 switch (scroll_status) { | |
221 case cc::InputHandler::ScrollStarted: | |
222 return DID_HANDLE; | |
223 case cc::InputHandler::ScrollIgnored: | |
224 return DROP_EVENT; | |
225 default: | |
226 return DID_NOT_HANDLE; | |
227 } | |
228 } | |
211 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 229 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
212 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::Wheel); | 230 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::Wheel); |
213 switch (scroll_status) { | 231 switch (scroll_status) { |
214 case cc::InputHandler::ScrollStarted: { | 232 case cc::InputHandler::ScrollStarted: { |
215 TRACE_EVENT_INSTANT2( | 233 TRACE_EVENT_INSTANT2( |
216 "input", | 234 "input", |
217 "InputHandlerProxy::handle_input wheel scroll", | 235 "InputHandlerProxy::handle_input wheel scroll", |
218 TRACE_EVENT_SCOPE_THREAD, | 236 TRACE_EVENT_SCOPE_THREAD, |
219 "deltaX", | 237 "deltaX", |
220 -wheel_event.deltaX, | 238 -wheel_event.deltaX, |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 803 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
786 // Return true in this case to prevent early fling termination. | 804 // Return true in this case to prevent early fling termination. |
787 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 805 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
788 std::abs(clipped_increment.height) < kScrollEpsilon) | 806 std::abs(clipped_increment.height) < kScrollEpsilon) |
789 return true; | 807 return true; |
790 | 808 |
791 return did_scroll; | 809 return did_scroll; |
792 } | 810 } |
793 | 811 |
794 } // namespace content | 812 } // namespace content |
OLD | NEW |