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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 FROM_HERE, | 411 FROM_HERE, |
| 412 base::Bind(&InputScrollElasticityController::ObserveWheelEventAndResult, | 412 base::Bind(&InputScrollElasticityController::ObserveWheelEventAndResult, |
| 413 scroll_elasticity_controller_->GetWeakPtr(), wheel_event, | 413 scroll_elasticity_controller_->GetWeakPtr(), wheel_event, |
| 414 scroll_result)); | 414 scroll_result)); |
| 415 } | 415 } |
| 416 return result; | 416 return result; |
| 417 } | 417 } |
| 418 | 418 |
| 419 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin( | 419 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin( |
| 420 const WebGestureEvent& gesture_event) { | 420 const WebGestureEvent& gesture_event) { |
| 421 DCHECK(!gesture_scroll_on_impl_thread_); | 421 if (gesture_scroll_on_impl_thread_) |
|
jdduke (slow)
2015/05/18 21:18:34
This probably deserves a small test.
hush (inactive)
2015/05/19 18:14:59
Done.
| |
| 422 CancelCurrentFling(); | |
| 423 | |
| 422 #ifndef NDEBUG | 424 #ifndef NDEBUG |
| 423 DCHECK(!expect_scroll_update_end_); | 425 DCHECK(!expect_scroll_update_end_); |
| 424 expect_scroll_update_end_ = true; | 426 expect_scroll_update_end_ = true; |
| 425 #endif | 427 #endif |
| 426 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 428 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
| 427 gfx::Point(gesture_event.x, gesture_event.y), cc::InputHandler::GESTURE); | 429 gfx::Point(gesture_event.x, gesture_event.y), cc::InputHandler::GESTURE); |
| 428 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", | 430 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", |
| 429 scroll_status, | 431 scroll_status, |
| 430 cc::InputHandler::ScrollStatusCount); | 432 cc::InputHandler::ScrollStatusCount); |
| 431 switch (scroll_status) { | 433 switch (scroll_status) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 // Note that the timestamp will only be used to kickstart the animation if | 525 // Note that the timestamp will only be used to kickstart the animation if |
| 524 // its sufficiently close to the timestamp of the first call |Animate()|. | 526 // its sufficiently close to the timestamp of the first call |Animate()|. |
| 525 has_fling_animation_started_ = false; | 527 has_fling_animation_started_ = false; |
| 526 fling_parameters_.startTime = gesture_event.timeStampSeconds; | 528 fling_parameters_.startTime = gesture_event.timeStampSeconds; |
| 527 fling_parameters_.delta = WebFloatPoint(vx, vy); | 529 fling_parameters_.delta = WebFloatPoint(vx, vy); |
| 528 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); | 530 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); |
| 529 fling_parameters_.globalPoint = | 531 fling_parameters_.globalPoint = |
| 530 WebPoint(gesture_event.globalX, gesture_event.globalY); | 532 WebPoint(gesture_event.globalX, gesture_event.globalY); |
| 531 fling_parameters_.modifiers = gesture_event.modifiers; | 533 fling_parameters_.modifiers = gesture_event.modifiers; |
| 532 fling_parameters_.sourceDevice = gesture_event.sourceDevice; | 534 fling_parameters_.sourceDevice = gesture_event.sourceDevice; |
| 533 input_handler_->SetNeedsAnimate(); | 535 input_handler_->SetNeedsAnimateInput(); |
| 534 return DID_HANDLE; | 536 return DID_HANDLE; |
| 535 } | 537 } |
| 536 case cc::InputHandler::SCROLL_UNKNOWN: | 538 case cc::InputHandler::SCROLL_UNKNOWN: |
| 537 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: { | 539 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: { |
| 538 TRACE_EVENT_INSTANT0("input", | 540 TRACE_EVENT_INSTANT0("input", |
| 539 "InputHandlerProxy::HandleGestureFling::" | 541 "InputHandlerProxy::HandleGestureFling::" |
| 540 "scroll_on_main_thread", | 542 "scroll_on_main_thread", |
| 541 TRACE_EVENT_SCOPE_THREAD); | 543 TRACE_EVENT_SCOPE_THREAD); |
| 542 gesture_scroll_on_impl_thread_ = false; | 544 gesture_scroll_on_impl_thread_ = false; |
| 543 fling_may_be_active_on_main_thread_ = true; | 545 fling_may_be_active_on_main_thread_ = true; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 | 747 |
| 746 if (!has_fling_animation_started_) { | 748 if (!has_fling_animation_started_) { |
| 747 has_fling_animation_started_ = true; | 749 has_fling_animation_started_ = true; |
| 748 // Guard against invalid, future or sufficiently stale start times, as there | 750 // Guard against invalid, future or sufficiently stale start times, as there |
| 749 // are no guarantees fling event and animation timestamps are compatible. | 751 // are no guarantees fling event and animation timestamps are compatible. |
| 750 if (!fling_parameters_.startTime || | 752 if (!fling_parameters_.startTime || |
| 751 monotonic_time_sec <= fling_parameters_.startTime || | 753 monotonic_time_sec <= fling_parameters_.startTime || |
| 752 monotonic_time_sec >= fling_parameters_.startTime + | 754 monotonic_time_sec >= fling_parameters_.startTime + |
| 753 kMaxSecondsFromFlingTimestampToFirstAnimate) { | 755 kMaxSecondsFromFlingTimestampToFirstAnimate) { |
| 754 fling_parameters_.startTime = monotonic_time_sec; | 756 fling_parameters_.startTime = monotonic_time_sec; |
| 755 input_handler_->SetNeedsAnimate(); | 757 input_handler_->SetNeedsAnimateInput(); |
| 756 return; | 758 return; |
| 757 } | 759 } |
| 758 } | 760 } |
| 759 | 761 |
| 760 bool fling_is_active = | 762 bool fling_is_active = |
| 761 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, | 763 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, |
| 762 this); | 764 this); |
| 763 | 765 |
| 764 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_) | 766 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_) |
| 765 fling_is_active = false; | 767 fling_is_active = false; |
| 766 | 768 |
| 767 if (fling_is_active) { | 769 if (fling_is_active) { |
| 768 input_handler_->SetNeedsAnimate(); | 770 input_handler_->SetNeedsAnimateInput(); |
| 769 } else { | 771 } else { |
| 770 TRACE_EVENT_INSTANT0("input", | 772 TRACE_EVENT_INSTANT0("input", |
| 771 "InputHandlerProxy::animate::flingOver", | 773 "InputHandlerProxy::animate::flingOver", |
| 772 TRACE_EVENT_SCOPE_THREAD); | 774 TRACE_EVENT_SCOPE_THREAD); |
| 773 CancelCurrentFling(); | 775 CancelCurrentFling(); |
| 774 } | 776 } |
| 775 } | 777 } |
| 776 | 778 |
| 777 void InputHandlerProxy::MainThreadHasStoppedFlinging() { | 779 void InputHandlerProxy::MainThreadHasStoppedFlinging() { |
| 778 fling_may_be_active_on_main_thread_ = false; | 780 fling_may_be_active_on_main_thread_ = false; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 953 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 955 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 954 // Return true in this case to prevent early fling termination. | 956 // Return true in this case to prevent early fling termination. |
| 955 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 957 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 956 std::abs(clipped_increment.height) < kScrollEpsilon) | 958 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 957 return true; | 959 return true; |
| 958 | 960 |
| 959 return did_scroll; | 961 return did_scroll; |
| 960 } | 962 } |
| 961 | 963 |
| 962 } // namespace content | 964 } // namespace content |
| OLD | NEW |