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