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 "ui/events/blink/input_handler_proxy.h" | 5 #include "ui/events/blink/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 scroll_status = | 613 scroll_status = |
| 614 input_handler_->ScrollBegin(&scroll_state, cc::InputHandler::GESTURE); | 614 input_handler_->ScrollBegin(&scroll_state, cc::InputHandler::GESTURE); |
| 615 } | 615 } |
| 616 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", | 616 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", |
| 617 scroll_status.thread, | 617 scroll_status.thread, |
| 618 cc::InputHandler::LAST_SCROLL_STATUS + 1); | 618 cc::InputHandler::LAST_SCROLL_STATUS + 1); |
| 619 | 619 |
| 620 RecordMainThreadScrollingReasons(gesture_event.type, | 620 RecordMainThreadScrollingReasons(gesture_event.type, |
| 621 scroll_status.main_thread_scrolling_reasons); | 621 scroll_status.main_thread_scrolling_reasons); |
| 622 | 622 |
| 623 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE; | |
| 623 switch (scroll_status.thread) { | 624 switch (scroll_status.thread) { |
| 624 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: | 625 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: |
| 625 TRACE_EVENT_INSTANT0("input", | 626 TRACE_EVENT_INSTANT0("input", |
| 626 "InputHandlerProxy::handle_input gesture scroll", | 627 "InputHandlerProxy::handle_input gesture scroll", |
| 627 TRACE_EVENT_SCOPE_THREAD); | 628 TRACE_EVENT_SCOPE_THREAD); |
| 628 gesture_scroll_on_impl_thread_ = true; | 629 gesture_scroll_on_impl_thread_ = true; |
| 629 return DID_HANDLE; | 630 result = DID_HANDLE; |
| 631 break; | |
| 630 case cc::InputHandler::SCROLL_UNKNOWN: | 632 case cc::InputHandler::SCROLL_UNKNOWN: |
| 631 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: | 633 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: |
| 632 return DID_NOT_HANDLE; | 634 result = DID_NOT_HANDLE; |
| 635 break; | |
| 633 case cc::InputHandler::SCROLL_IGNORED: | 636 case cc::InputHandler::SCROLL_IGNORED: |
| 634 return DROP_EVENT; | 637 result = DROP_EVENT; |
| 638 break; | |
| 635 } | 639 } |
| 636 return DID_NOT_HANDLE; | 640 // Send the event and its disposition to the elasticity controller to update |
| 641 // the over-scroll animation. If the event is to be handled on the main | |
| 642 // thread, the event and its disposition will be sent to the elasticity | |
| 643 // controller after being handled on the main thread. | |
| 644 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) { | |
| 645 // Note that the call to the elasticity controller is made asynchronously, | |
| 646 // to minimize divergence between main thread and impl thread event | |
| 647 // handling paths. | |
| 648 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 649 FROM_HERE, | |
| 650 base::Bind( | |
| 651 &InputScrollElasticityController::ObserveGestureEventAndResult, | |
| 652 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | |
| 653 cc::InputHandlerScrollResult())); | |
| 654 } | |
| 655 | |
| 656 return result; | |
| 637 } | 657 } |
| 638 | 658 |
| 639 InputHandlerProxy::EventDisposition | 659 InputHandlerProxy::EventDisposition |
| 640 InputHandlerProxy::HandleGestureScrollUpdate( | 660 InputHandlerProxy::HandleGestureScrollUpdate( |
| 641 const WebGestureEvent& gesture_event) { | 661 const WebGestureEvent& gesture_event) { |
| 642 #ifndef NDEBUG | 662 #ifndef NDEBUG |
| 643 DCHECK(expect_scroll_update_end_); | 663 DCHECK(expect_scroll_update_end_); |
| 644 #endif | 664 #endif |
| 645 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 665 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
| 646 return DID_NOT_HANDLE; | 666 return DID_NOT_HANDLE; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 658 return DID_HANDLE; | 678 return DID_HANDLE; |
| 659 case cc::InputHandler::SCROLL_IGNORED: | 679 case cc::InputHandler::SCROLL_IGNORED: |
| 660 return DROP_EVENT; | 680 return DROP_EVENT; |
| 661 default: | 681 default: |
| 662 return DID_NOT_HANDLE; | 682 return DID_NOT_HANDLE; |
| 663 } | 683 } |
| 664 } | 684 } |
| 665 cc::InputHandlerScrollResult scroll_result = | 685 cc::InputHandlerScrollResult scroll_result = |
| 666 input_handler_->ScrollBy(&scroll_state); | 686 input_handler_->ScrollBy(&scroll_state); |
| 667 HandleOverscroll(scroll_point, scroll_result); | 687 HandleOverscroll(scroll_point, scroll_result); |
| 688 | |
| 689 // Send the event and its disposition to the elasticity controller to update | |
| 690 // the over-scroll animation. | |
| 691 if (scroll_elasticity_controller_) { | |
| 692 // Note that the call to the elasticity controller is made asynchronously, | |
| 693 // to minimize divergence between main thread and impl thread event | |
| 694 // handling paths. | |
| 695 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
|
tdresser
2016/03/02 18:26:53
Can we share this logic with HandleGestureScrollBe
dtapuska
2016/03/07 18:03:59
Done.
| |
| 696 FROM_HERE, | |
| 697 base::Bind( | |
| 698 &InputScrollElasticityController::ObserveGestureEventAndResult, | |
| 699 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | |
| 700 scroll_result)); | |
| 701 } | |
| 702 | |
| 668 return scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; | 703 return scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; |
| 669 } | 704 } |
| 670 | 705 |
| 671 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd( | 706 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd( |
| 672 const WebGestureEvent& gesture_event) { | 707 const WebGestureEvent& gesture_event) { |
| 673 #ifndef NDEBUG | 708 #ifndef NDEBUG |
| 674 DCHECK(expect_scroll_update_end_); | 709 DCHECK(expect_scroll_update_end_); |
| 675 expect_scroll_update_end_ = false; | 710 expect_scroll_update_end_ = false; |
| 676 #endif | 711 #endif |
| 677 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); | 712 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); |
| 678 input_handler_->ScrollEnd(&scroll_state); | 713 input_handler_->ScrollEnd(&scroll_state); |
| 679 if (!gesture_scroll_on_impl_thread_) | 714 if (!gesture_scroll_on_impl_thread_) |
| 680 return DID_NOT_HANDLE; | 715 return DID_NOT_HANDLE; |
| 716 | |
| 717 // Send the event and its disposition to the elasticity controller to update | |
| 718 // the over-scroll animation. If the event is to be handled on the main | |
| 719 // thread, the event and its disposition will be sent to the elasticity | |
| 720 // controller after being handled on the main thread. | |
| 721 if (scroll_elasticity_controller_) { | |
| 722 // Note that the call to the elasticity controller is made asynchronously, | |
| 723 // to minimize divergence between main thread and impl thread event | |
| 724 // handling paths. | |
| 725 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 726 FROM_HERE, | |
| 727 base::Bind( | |
| 728 &InputScrollElasticityController::ObserveGestureEventAndResult, | |
| 729 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | |
| 730 cc::InputHandlerScrollResult())); | |
| 731 } | |
| 732 | |
| 681 gesture_scroll_on_impl_thread_ = false; | 733 gesture_scroll_on_impl_thread_ = false; |
| 682 return DID_HANDLE; | 734 return DID_HANDLE; |
| 683 } | 735 } |
| 684 | 736 |
| 685 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart( | 737 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart( |
| 686 const WebGestureEvent& gesture_event) { | 738 const WebGestureEvent& gesture_event) { |
| 687 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); | 739 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); |
| 688 cc::InputHandler::ScrollStatus scroll_status; | 740 cc::InputHandler::ScrollStatus scroll_status; |
| 689 scroll_status.main_thread_scrolling_reasons = | 741 scroll_status.main_thread_scrolling_reasons = |
| 690 cc::MainThreadScrollingReason::kNotScrollingOnMain; | 742 cc::MainThreadScrollingReason::kNotScrollingOnMain; |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1304 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 1356 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 1305 // Return true in this case to prevent early fling termination. | 1357 // Return true in this case to prevent early fling termination. |
| 1306 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 1358 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 1307 std::abs(clipped_increment.height) < kScrollEpsilon) | 1359 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 1308 return true; | 1360 return true; |
| 1309 | 1361 |
| 1310 return did_scroll; | 1362 return did_scroll; |
| 1311 } | 1363 } |
| 1312 | 1364 |
| 1313 } // namespace ui | 1365 } // namespace ui |
| OLD | NEW |