| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 ? -wheel_event.deltaY | 496 ? -wheel_event.deltaY |
| 497 : 0); | 497 : 0); |
| 498 | 498 |
| 499 if (wheel_event.scrollByPage) { | 499 if (wheel_event.scrollByPage) { |
| 500 // TODO(jamesr): We don't properly handle scroll by page in the compositor | 500 // TODO(jamesr): We don't properly handle scroll by page in the compositor |
| 501 // thread, so punt it to the main thread. http://crbug.com/236639 | 501 // thread, so punt it to the main thread. http://crbug.com/236639 |
| 502 result = DID_NOT_HANDLE; | 502 result = DID_NOT_HANDLE; |
| 503 RecordMainThreadScrollingReasons( | 503 RecordMainThreadScrollingReasons( |
| 504 blink::WebGestureDeviceTouchpad, | 504 blink::WebGestureDeviceTouchpad, |
| 505 cc::MainThreadScrollingReason::kPageBasedScrolling); | 505 cc::MainThreadScrollingReason::kPageBasedScrolling); |
| 506 | |
| 507 } else { | 506 } else { |
| 508 DCHECK(!ShouldAnimate(wheel_event.hasPreciseScrollingDeltas)); | 507 DCHECK(!ShouldAnimate(wheel_event.hasPreciseScrollingDeltas)); |
| 509 cc::ScrollStateData scroll_state_begin_data; | 508 cc::ScrollStateData scroll_state_begin_data; |
| 510 scroll_state_begin_data.position_x = wheel_event.x; | 509 scroll_state_begin_data.position_x = wheel_event.x; |
| 511 scroll_state_begin_data.position_y = wheel_event.y; | 510 scroll_state_begin_data.position_y = wheel_event.y; |
| 512 scroll_state_begin_data.is_beginning = true; | 511 scroll_state_begin_data.is_beginning = true; |
| 513 cc::ScrollState scroll_state_begin(scroll_state_begin_data); | 512 cc::ScrollState scroll_state_begin(scroll_state_begin_data); |
| 514 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 513 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
| 515 &scroll_state_begin, cc::InputHandler::WHEEL); | 514 &scroll_state_begin, cc::InputHandler::WHEEL); |
| 516 | 515 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } | 613 } |
| 615 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) | 614 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) |
| 616 HandleScrollElasticityOverscroll(gesture_event, | 615 HandleScrollElasticityOverscroll(gesture_event, |
| 617 cc::InputHandlerScrollResult()); | 616 cc::InputHandlerScrollResult()); |
| 618 | 617 |
| 619 return result; | 618 return result; |
| 620 } | 619 } |
| 621 | 620 |
| 622 InputHandlerProxy::EventDisposition | 621 InputHandlerProxy::EventDisposition |
| 623 InputHandlerProxy::HandleGestureScrollUpdate( | 622 InputHandlerProxy::HandleGestureScrollUpdate( |
| 624 const WebGestureEvent& gesture_event) { | 623 const WebGestureEvent& gesture_event) { |
| 625 #ifndef NDEBUG | 624 #ifndef NDEBUG |
| 626 DCHECK(expect_scroll_update_end_); | 625 DCHECK(expect_scroll_update_end_); |
| 627 #endif | 626 #endif |
| 628 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 627 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
| 629 return DID_NOT_HANDLE; | 628 return DID_NOT_HANDLE; |
| 630 | 629 |
| 631 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); | 630 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); |
| 632 gfx::Point scroll_point(gesture_event.x, gesture_event.y); | 631 gfx::Point scroll_point(gesture_event.x, gesture_event.y); |
| 633 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, | 632 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, |
| 634 -gesture_event.data.scrollUpdate.deltaY); | 633 -gesture_event.data.scrollUpdate.deltaY); |
| 635 | 634 |
| 636 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits != | 635 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits != |
| 637 blink::WebGestureEvent::ScrollUnits::Pixels)) { | 636 blink::WebGestureEvent::ScrollUnits::Pixels)) { |
| 638 DCHECK(!scroll_state.is_in_inertial_phase()); | 637 DCHECK(!scroll_state.is_in_inertial_phase()); |
| 639 switch (input_handler_->ScrollAnimated(scroll_point, scroll_delta).thread) { | 638 base::TimeTicks event_time = |
| 639 base::TimeTicks() + |
| 640 base::TimeDelta::FromSecondsD(gesture_event.timeStampSeconds); |
| 641 base::TimeDelta delay = base::TimeTicks::Now() - event_time; |
| 642 switch (input_handler_->ScrollAnimated(scroll_point, scroll_delta, delay) |
| 643 .thread) { |
| 640 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: | 644 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: |
| 641 return DID_HANDLE; | 645 return DID_HANDLE; |
| 642 case cc::InputHandler::SCROLL_IGNORED: | 646 case cc::InputHandler::SCROLL_IGNORED: |
| 643 return DROP_EVENT; | 647 return DROP_EVENT; |
| 644 default: | 648 default: |
| 645 return DID_NOT_HANDLE; | 649 return DID_NOT_HANDLE; |
| 646 } | 650 } |
| 647 } | 651 } |
| 648 cc::InputHandlerScrollResult scroll_result = | 652 cc::InputHandlerScrollResult scroll_result = |
| 649 input_handler_->ScrollBy(&scroll_state); | 653 input_handler_->ScrollBy(&scroll_state); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 // is made asynchronously, to minimize divergence between main thread and | 1342 // is made asynchronously, to minimize divergence between main thread and |
| 1339 // impl thread event handling paths. | 1343 // impl thread event handling paths. |
| 1340 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1344 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1341 FROM_HERE, | 1345 FROM_HERE, |
| 1342 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, | 1346 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, |
| 1343 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | 1347 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, |
| 1344 scroll_result)); | 1348 scroll_result)); |
| 1345 } | 1349 } |
| 1346 | 1350 |
| 1347 } // namespace ui | 1351 } // namespace ui |
| OLD | NEW |