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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY)); | 153 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY)); |
154 input_handler_->ScrollEnd(); | 154 input_handler_->ScrollEnd(); |
155 return did_scroll ? DID_HANDLE : DROP_EVENT; | 155 return did_scroll ? DID_HANDLE : DROP_EVENT; |
156 } | 156 } |
157 case cc::InputHandler::ScrollIgnored: | 157 case cc::InputHandler::ScrollIgnored: |
158 // TODO(jamesr): This should be DROP_EVENT, but in cases where we fail | 158 // TODO(jamesr): This should be DROP_EVENT, but in cases where we fail |
159 // to properly sync scrollability it's safer to send the event to the | 159 // to properly sync scrollability it's safer to send the event to the |
160 // main thread. Change back to DROP_EVENT once we have synchronization | 160 // main thread. Change back to DROP_EVENT once we have synchronization |
161 // bugs sorted out. | 161 // bugs sorted out. |
162 return DID_NOT_HANDLE; | 162 return DID_NOT_HANDLE; |
| 163 case cc::InputHandler::ScrollUnknown: |
163 case cc::InputHandler::ScrollOnMainThread: | 164 case cc::InputHandler::ScrollOnMainThread: |
164 return DID_NOT_HANDLE; | 165 return DID_NOT_HANDLE; |
| 166 case cc::InputHandler::ScrollStatusCount: |
| 167 NOTREACHED(); |
| 168 break; |
165 } | 169 } |
166 } else if (event.type == WebInputEvent::GestureScrollBegin) { | 170 } else if (event.type == WebInputEvent::GestureScrollBegin) { |
167 DCHECK(!gesture_scroll_on_impl_thread_); | 171 DCHECK(!gesture_scroll_on_impl_thread_); |
168 #ifndef NDEBUG | 172 #ifndef NDEBUG |
169 DCHECK(!expect_scroll_update_end_); | 173 DCHECK(!expect_scroll_update_end_); |
170 expect_scroll_update_end_ = true; | 174 expect_scroll_update_end_ = true; |
171 #endif | 175 #endif |
172 const WebGestureEvent& gesture_event = | 176 const WebGestureEvent& gesture_event = |
173 *static_cast<const WebGestureEvent*>(&event); | 177 *static_cast<const WebGestureEvent*>(&event); |
174 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 178 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
175 gfx::Point(gesture_event.x, gesture_event.y), | 179 gfx::Point(gesture_event.x, gesture_event.y), |
176 cc::InputHandler::Gesture); | 180 cc::InputHandler::Gesture); |
| 181 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", |
| 182 scroll_status, |
| 183 cc::InputHandler::ScrollStatusCount); |
177 switch (scroll_status) { | 184 switch (scroll_status) { |
178 case cc::InputHandler::ScrollStarted: | 185 case cc::InputHandler::ScrollStarted: |
179 TRACE_EVENT_INSTANT0("input", | 186 TRACE_EVENT_INSTANT0("input", |
180 "InputHandlerProxy::handle_input gesture scroll", | 187 "InputHandlerProxy::handle_input gesture scroll", |
181 TRACE_EVENT_SCOPE_THREAD); | 188 TRACE_EVENT_SCOPE_THREAD); |
182 gesture_scroll_on_impl_thread_ = true; | 189 gesture_scroll_on_impl_thread_ = true; |
183 return DID_HANDLE; | 190 return DID_HANDLE; |
| 191 case cc::InputHandler::ScrollUnknown: |
184 case cc::InputHandler::ScrollOnMainThread: | 192 case cc::InputHandler::ScrollOnMainThread: |
185 return DID_NOT_HANDLE; | 193 return DID_NOT_HANDLE; |
186 case cc::InputHandler::ScrollIgnored: | 194 case cc::InputHandler::ScrollIgnored: |
187 return DROP_EVENT; | 195 return DROP_EVENT; |
| 196 case cc::InputHandler::ScrollStatusCount: |
| 197 NOTREACHED(); |
| 198 break; |
188 } | 199 } |
189 } else if (event.type == WebInputEvent::GestureScrollUpdate) { | 200 } else if (event.type == WebInputEvent::GestureScrollUpdate) { |
190 #ifndef NDEBUG | 201 #ifndef NDEBUG |
191 DCHECK(expect_scroll_update_end_); | 202 DCHECK(expect_scroll_update_end_); |
192 #endif | 203 #endif |
193 | 204 |
194 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 205 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
195 return DID_NOT_HANDLE; | 206 return DID_NOT_HANDLE; |
196 | 207 |
197 const WebGestureEvent& gesture_event = | 208 const WebGestureEvent& gesture_event = |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 WebFloatPoint(gesture_event.data.flingStart.velocityX, | 334 WebFloatPoint(gesture_event.data.flingStart.velocityX, |
324 gesture_event.data.flingStart.velocityY); | 335 gesture_event.data.flingStart.velocityY); |
325 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); | 336 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); |
326 fling_parameters_.globalPoint = | 337 fling_parameters_.globalPoint = |
327 WebPoint(gesture_event.globalX, gesture_event.globalY); | 338 WebPoint(gesture_event.globalX, gesture_event.globalY); |
328 fling_parameters_.modifiers = gesture_event.modifiers; | 339 fling_parameters_.modifiers = gesture_event.modifiers; |
329 fling_parameters_.sourceDevice = gesture_event.sourceDevice; | 340 fling_parameters_.sourceDevice = gesture_event.sourceDevice; |
330 input_handler_->ScheduleAnimation(); | 341 input_handler_->ScheduleAnimation(); |
331 return DID_HANDLE; | 342 return DID_HANDLE; |
332 } | 343 } |
| 344 case cc::InputHandler::ScrollUnknown: |
333 case cc::InputHandler::ScrollOnMainThread: { | 345 case cc::InputHandler::ScrollOnMainThread: { |
334 TRACE_EVENT_INSTANT0("input", | 346 TRACE_EVENT_INSTANT0("input", |
335 "InputHandlerProxy::HandleGestureFling::" | 347 "InputHandlerProxy::HandleGestureFling::" |
336 "scroll_on_main_thread", | 348 "scroll_on_main_thread", |
337 TRACE_EVENT_SCOPE_THREAD); | 349 TRACE_EVENT_SCOPE_THREAD); |
338 fling_may_be_active_on_main_thread_ = true; | 350 fling_may_be_active_on_main_thread_ = true; |
339 return DID_NOT_HANDLE; | 351 return DID_NOT_HANDLE; |
340 } | 352 } |
341 case cc::InputHandler::ScrollIgnored: { | 353 case cc::InputHandler::ScrollIgnored: { |
342 TRACE_EVENT_INSTANT0( | 354 TRACE_EVENT_INSTANT0( |
343 "input", | 355 "input", |
344 "InputHandlerProxy::HandleGestureFling::ignored", | 356 "InputHandlerProxy::HandleGestureFling::ignored", |
345 TRACE_EVENT_SCOPE_THREAD); | 357 TRACE_EVENT_SCOPE_THREAD); |
346 if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) { | 358 if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) { |
347 // We still pass the curve to the main thread if there's nothing | 359 // We still pass the curve to the main thread if there's nothing |
348 // scrollable, in case something | 360 // scrollable, in case something |
349 // registers a handler before the curve is over. | 361 // registers a handler before the curve is over. |
350 return DID_NOT_HANDLE; | 362 return DID_NOT_HANDLE; |
351 } | 363 } |
352 return DROP_EVENT; | 364 return DROP_EVENT; |
353 } | 365 } |
| 366 case cc::InputHandler::ScrollStatusCount: |
| 367 NOTREACHED(); |
| 368 break; |
354 } | 369 } |
355 return DID_NOT_HANDLE; | 370 return DID_NOT_HANDLE; |
356 } | 371 } |
357 | 372 |
358 void InputHandlerProxy::Animate(base::TimeTicks time) { | 373 void InputHandlerProxy::Animate(base::TimeTicks time) { |
359 if (!fling_curve_) | 374 if (!fling_curve_) |
360 return; | 375 return; |
361 | 376 |
362 double monotonic_time_sec = InSecondsF(time); | 377 double monotonic_time_sec = InSecondsF(time); |
363 if (!fling_parameters_.startTime || | 378 if (!fling_parameters_.startTime || |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 552 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
538 // Return true in this case to prevent early fling termination. | 553 // Return true in this case to prevent early fling termination. |
539 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 554 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
540 std::abs(clipped_increment.height) < kScrollEpsilon) | 555 std::abs(clipped_increment.height) < kScrollEpsilon) |
541 return true; | 556 return true; |
542 | 557 |
543 return did_scroll; | 558 return did_scroll; |
544 } | 559 } |
545 | 560 |
546 } // namespace content | 561 } // namespace content |
OLD | NEW |