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 "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(); | |
|
jdduke (slow)
2014/04/16 17:41:54
Would it be at all useful to break here (and below
| |
| 165 } | 168 } |
| 166 } else if (event.type == WebInputEvent::GestureScrollBegin) { | 169 } else if (event.type == WebInputEvent::GestureScrollBegin) { |
| 167 DCHECK(!gesture_scroll_on_impl_thread_); | 170 DCHECK(!gesture_scroll_on_impl_thread_); |
| 168 #ifndef NDEBUG | 171 #ifndef NDEBUG |
| 169 DCHECK(!expect_scroll_update_end_); | 172 DCHECK(!expect_scroll_update_end_); |
| 170 expect_scroll_update_end_ = true; | 173 expect_scroll_update_end_ = true; |
| 171 #endif | 174 #endif |
| 172 const WebGestureEvent& gesture_event = | 175 const WebGestureEvent& gesture_event = |
| 173 *static_cast<const WebGestureEvent*>(&event); | 176 *static_cast<const WebGestureEvent*>(&event); |
| 174 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 177 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
| 175 gfx::Point(gesture_event.x, gesture_event.y), | 178 gfx::Point(gesture_event.x, gesture_event.y), |
| 176 cc::InputHandler::Gesture); | 179 cc::InputHandler::Gesture); |
| 180 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", | |
| 181 scroll_status, | |
| 182 cc::InputHandler::ScrollStatusCount); | |
| 177 switch (scroll_status) { | 183 switch (scroll_status) { |
| 178 case cc::InputHandler::ScrollStarted: | 184 case cc::InputHandler::ScrollStarted: |
| 179 TRACE_EVENT_INSTANT0("input", | 185 TRACE_EVENT_INSTANT0("input", |
| 180 "InputHandlerProxy::handle_input gesture scroll", | 186 "InputHandlerProxy::handle_input gesture scroll", |
| 181 TRACE_EVENT_SCOPE_THREAD); | 187 TRACE_EVENT_SCOPE_THREAD); |
| 182 gesture_scroll_on_impl_thread_ = true; | 188 gesture_scroll_on_impl_thread_ = true; |
| 183 return DID_HANDLE; | 189 return DID_HANDLE; |
| 190 case cc::InputHandler::ScrollUnknown: | |
| 184 case cc::InputHandler::ScrollOnMainThread: | 191 case cc::InputHandler::ScrollOnMainThread: |
| 185 return DID_NOT_HANDLE; | 192 return DID_NOT_HANDLE; |
| 186 case cc::InputHandler::ScrollIgnored: | 193 case cc::InputHandler::ScrollIgnored: |
| 187 return DROP_EVENT; | 194 return DROP_EVENT; |
| 195 case cc::InputHandler::ScrollStatusCount: | |
| 196 NOTREACHED(); | |
| 188 } | 197 } |
| 189 } else if (event.type == WebInputEvent::GestureScrollUpdate) { | 198 } else if (event.type == WebInputEvent::GestureScrollUpdate) { |
| 190 #ifndef NDEBUG | 199 #ifndef NDEBUG |
| 191 DCHECK(expect_scroll_update_end_); | 200 DCHECK(expect_scroll_update_end_); |
| 192 #endif | 201 #endif |
| 193 | 202 |
| 194 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 203 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
| 195 return DID_NOT_HANDLE; | 204 return DID_NOT_HANDLE; |
| 196 | 205 |
| 197 const WebGestureEvent& gesture_event = | 206 const WebGestureEvent& gesture_event = |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 WebFloatPoint(gesture_event.data.flingStart.velocityX, | 332 WebFloatPoint(gesture_event.data.flingStart.velocityX, |
| 324 gesture_event.data.flingStart.velocityY); | 333 gesture_event.data.flingStart.velocityY); |
| 325 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); | 334 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); |
| 326 fling_parameters_.globalPoint = | 335 fling_parameters_.globalPoint = |
| 327 WebPoint(gesture_event.globalX, gesture_event.globalY); | 336 WebPoint(gesture_event.globalX, gesture_event.globalY); |
| 328 fling_parameters_.modifiers = gesture_event.modifiers; | 337 fling_parameters_.modifiers = gesture_event.modifiers; |
| 329 fling_parameters_.sourceDevice = gesture_event.sourceDevice; | 338 fling_parameters_.sourceDevice = gesture_event.sourceDevice; |
| 330 input_handler_->ScheduleAnimation(); | 339 input_handler_->ScheduleAnimation(); |
| 331 return DID_HANDLE; | 340 return DID_HANDLE; |
| 332 } | 341 } |
| 342 case cc::InputHandler::ScrollUnknown: | |
| 333 case cc::InputHandler::ScrollOnMainThread: { | 343 case cc::InputHandler::ScrollOnMainThread: { |
| 334 TRACE_EVENT_INSTANT0("input", | 344 TRACE_EVENT_INSTANT0("input", |
| 335 "InputHandlerProxy::HandleGestureFling::" | 345 "InputHandlerProxy::HandleGestureFling::" |
| 336 "scroll_on_main_thread", | 346 "scroll_on_main_thread", |
| 337 TRACE_EVENT_SCOPE_THREAD); | 347 TRACE_EVENT_SCOPE_THREAD); |
| 338 fling_may_be_active_on_main_thread_ = true; | 348 fling_may_be_active_on_main_thread_ = true; |
| 339 return DID_NOT_HANDLE; | 349 return DID_NOT_HANDLE; |
| 340 } | 350 } |
| 341 case cc::InputHandler::ScrollIgnored: { | 351 case cc::InputHandler::ScrollIgnored: { |
| 342 TRACE_EVENT_INSTANT0( | 352 TRACE_EVENT_INSTANT0( |
| 343 "input", | 353 "input", |
| 344 "InputHandlerProxy::HandleGestureFling::ignored", | 354 "InputHandlerProxy::HandleGestureFling::ignored", |
| 345 TRACE_EVENT_SCOPE_THREAD); | 355 TRACE_EVENT_SCOPE_THREAD); |
| 346 if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) { | 356 if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) { |
| 347 // We still pass the curve to the main thread if there's nothing | 357 // We still pass the curve to the main thread if there's nothing |
| 348 // scrollable, in case something | 358 // scrollable, in case something |
| 349 // registers a handler before the curve is over. | 359 // registers a handler before the curve is over. |
| 350 return DID_NOT_HANDLE; | 360 return DID_NOT_HANDLE; |
| 351 } | 361 } |
| 352 return DROP_EVENT; | 362 return DROP_EVENT; |
| 353 } | 363 } |
| 364 case cc::InputHandler::ScrollStatusCount: | |
| 365 NOTREACHED(); | |
| 354 } | 366 } |
| 355 return DID_NOT_HANDLE; | 367 return DID_NOT_HANDLE; |
| 356 } | 368 } |
| 357 | 369 |
| 358 void InputHandlerProxy::Animate(base::TimeTicks time) { | 370 void InputHandlerProxy::Animate(base::TimeTicks time) { |
| 359 if (!fling_curve_) | 371 if (!fling_curve_) |
| 360 return; | 372 return; |
| 361 | 373 |
| 362 double monotonic_time_sec = InSecondsF(time); | 374 double monotonic_time_sec = InSecondsF(time); |
| 363 if (!fling_parameters_.startTime || | 375 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. | 549 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 538 // Return true in this case to prevent early fling termination. | 550 // Return true in this case to prevent early fling termination. |
| 539 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 551 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 540 std::abs(clipped_increment.height) < kScrollEpsilon) | 552 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 541 return true; | 553 return true; |
| 542 | 554 |
| 543 return did_scroll; | 555 return did_scroll; |
| 544 } | 556 } |
| 545 | 557 |
| 546 } // namespace content | 558 } // namespace content |
| OLD | NEW |