| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 cc::InputHandler::ScrollInputType GestureScrollInputType( | 229 cc::InputHandler::ScrollInputType GestureScrollInputType( |
| 230 blink::WebGestureDevice device) { | 230 blink::WebGestureDevice device) { |
| 231 return device == blink::WebGestureDeviceTouchpad | 231 return device == blink::WebGestureDeviceTouchpad |
| 232 ? cc::InputHandler::WHEEL | 232 ? cc::InputHandler::WHEEL |
| 233 : cc::InputHandler::TOUCHSCREEN; | 233 : cc::InputHandler::TOUCHSCREEN; |
| 234 } | 234 } |
| 235 | 235 |
| 236 enum ScrollingThreadStatus { | |
| 237 SCROLLING_ON_COMPOSITOR, | |
| 238 SCROLLING_ON_COMPOSITOR_BLOCKED_ON_MAIN, | |
| 239 SCROLLING_ON_MAIN, | |
| 240 LAST_SCROLLING_THREAD_STATUS_VALUE = SCROLLING_ON_MAIN, | |
| 241 }; | |
| 242 | |
| 243 } // namespace | 236 } // namespace |
| 244 | 237 |
| 245 namespace ui { | 238 namespace ui { |
| 246 | 239 |
| 247 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler, | 240 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler, |
| 248 InputHandlerProxyClient* client) | 241 InputHandlerProxyClient* client) |
| 249 : client_(client), | 242 : client_(client), |
| 250 input_handler_(input_handler), | 243 input_handler_(input_handler), |
| 251 deferred_fling_cancel_time_seconds_(0), | 244 deferred_fling_cancel_time_seconds_(0), |
| 252 synchronous_input_handler_(nullptr), | 245 synchronous_input_handler_(nullptr), |
| 253 allow_root_animate_(true), | 246 allow_root_animate_(true), |
| 254 #ifndef NDEBUG | 247 #ifndef NDEBUG |
| 255 expect_scroll_update_end_(false), | 248 expect_scroll_update_end_(false), |
| 256 #endif | 249 #endif |
| 257 gesture_scroll_on_impl_thread_(false), | 250 gesture_scroll_on_impl_thread_(false), |
| 258 gesture_pinch_on_impl_thread_(false), | 251 gesture_pinch_on_impl_thread_(false), |
| 259 fling_may_be_active_on_main_thread_(false), | 252 fling_may_be_active_on_main_thread_(false), |
| 260 disallow_horizontal_fling_scroll_(false), | 253 disallow_horizontal_fling_scroll_(false), |
| 261 disallow_vertical_fling_scroll_(false), | 254 disallow_vertical_fling_scroll_(false), |
| 262 has_fling_animation_started_(false), | 255 has_fling_animation_started_(false), |
| 263 smooth_scroll_enabled_(false), | 256 smooth_scroll_enabled_(false), |
| 264 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()), | 257 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()), |
| 265 touchpad_and_wheel_scroll_latching_enabled_(false), | 258 touchpad_and_wheel_scroll_latching_enabled_(false), |
| 266 touch_start_result_(kEventDispositionUndefined), | 259 touch_start_result_(kEventDispositionUndefined), |
| 267 mouse_wheel_result_(kEventDispositionUndefined), | |
| 268 current_overscroll_params_(nullptr), | 260 current_overscroll_params_(nullptr), |
| 269 has_ongoing_compositor_scroll_pinch_(false), | 261 has_ongoing_compositor_scroll_pinch_(false), |
| 270 tick_clock_(base::MakeUnique<base::DefaultTickClock>()) { | 262 tick_clock_(base::MakeUnique<base::DefaultTickClock>()) { |
| 271 DCHECK(client); | 263 DCHECK(client); |
| 272 input_handler_->BindToClient(this); | 264 input_handler_->BindToClient(this); |
| 273 cc::ScrollElasticityHelper* scroll_elasticity_helper = | 265 cc::ScrollElasticityHelper* scroll_elasticity_helper = |
| 274 input_handler_->CreateScrollElasticityHelper(); | 266 input_handler_->CreateScrollElasticityHelper(); |
| 275 if (scroll_elasticity_helper) { | 267 if (scroll_elasticity_helper) { |
| 276 scroll_elasticity_controller_.reset( | 268 scroll_elasticity_controller_.reset( |
| 277 new InputScrollElasticityController(scroll_elasticity_helper)); | 269 new InputScrollElasticityController(scroll_elasticity_helper)); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 UMA_HISTOGRAM_ENUMERATION(kGestureHistogramName, i + 1, | 579 UMA_HISTOGRAM_ENUMERATION(kGestureHistogramName, i + 1, |
| 588 mainThreadScrollingReasonEnumMax); | 580 mainThreadScrollingReasonEnumMax); |
| 589 } else { | 581 } else { |
| 590 UMA_HISTOGRAM_ENUMERATION(kWheelHistogramName, i + 1, | 582 UMA_HISTOGRAM_ENUMERATION(kWheelHistogramName, i + 1, |
| 591 mainThreadScrollingReasonEnumMax); | 583 mainThreadScrollingReasonEnumMax); |
| 592 } | 584 } |
| 593 } | 585 } |
| 594 } | 586 } |
| 595 } | 587 } |
| 596 | 588 |
| 597 void InputHandlerProxy::RecordScrollingThreadStatus( | |
| 598 blink::WebGestureDevice device, | |
| 599 uint32_t reasons) { | |
| 600 DCHECK(device == blink::WebGestureDeviceTouchpad || | |
| 601 device == blink::WebGestureDeviceTouchscreen); | |
| 602 | |
| 603 if (device != blink::WebGestureDeviceTouchpad && | |
| 604 device != blink::WebGestureDeviceTouchscreen) { | |
| 605 return; | |
| 606 } | |
| 607 | |
| 608 ScrollingThreadStatus scrolling_thread_status = SCROLLING_ON_MAIN; | |
| 609 if (reasons == cc::MainThreadScrollingReason::kNotScrollingOnMain) { | |
| 610 int32_t event_disposition_result = | |
| 611 (device == blink::WebGestureDeviceTouchpad ? mouse_wheel_result_ | |
| 612 : touch_start_result_); | |
| 613 switch (event_disposition_result) { | |
| 614 case kEventDispositionUndefined: | |
| 615 case DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING: | |
| 616 case DID_HANDLE_NON_BLOCKING: | |
| 617 case DROP_EVENT: | |
| 618 scrolling_thread_status = SCROLLING_ON_COMPOSITOR; | |
| 619 break; | |
| 620 case DID_NOT_HANDLE: | |
| 621 scrolling_thread_status = SCROLLING_ON_COMPOSITOR_BLOCKED_ON_MAIN; | |
| 622 break; | |
| 623 default: | |
| 624 NOTREACHED(); | |
| 625 scrolling_thread_status = SCROLLING_ON_COMPOSITOR; | |
| 626 } | |
| 627 } | |
| 628 | |
| 629 // UMA_HISTOGRAM_ENUMERATION requires that the enum_max must be strictly | |
| 630 // greater than the sample value. | |
| 631 const uint32_t kScrolingThreadStatusEnumMax = | |
| 632 ScrollingThreadStatus::LAST_SCROLLING_THREAD_STATUS_VALUE + 1; | |
| 633 | |
| 634 if (device == blink::WebGestureDeviceTouchscreen) { | |
| 635 UMA_HISTOGRAM_ENUMERATION("Renderer4.GestureScrollingThreadStatus", | |
| 636 scrolling_thread_status, | |
| 637 kScrolingThreadStatusEnumMax); | |
| 638 } else { | |
| 639 UMA_HISTOGRAM_ENUMERATION("Renderer4.WheelScrollingThreadStatus", | |
| 640 scrolling_thread_status, | |
| 641 kScrolingThreadStatusEnumMax); | |
| 642 } | |
| 643 } | |
| 644 | |
| 645 bool InputHandlerProxy::ShouldAnimate(bool has_precise_scroll_deltas) const { | 589 bool InputHandlerProxy::ShouldAnimate(bool has_precise_scroll_deltas) const { |
| 646 #if defined(OS_MACOSX) | 590 #if defined(OS_MACOSX) |
| 647 // Mac does not smooth scroll wheel events (crbug.com/574283). | 591 // Mac does not smooth scroll wheel events (crbug.com/574283). |
| 648 return false; | 592 return false; |
| 649 #else | 593 #else |
| 650 return smooth_scroll_enabled_ && !has_precise_scroll_deltas; | 594 return smooth_scroll_enabled_ && !has_precise_scroll_deltas; |
| 651 #endif | 595 #endif |
| 652 } | 596 } |
| 653 | 597 |
| 654 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( | 598 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( |
| 655 const WebMouseWheelEvent& wheel_event) { | 599 const WebMouseWheelEvent& wheel_event) { |
| 656 // Only call |CancelCurrentFling()| if a fling was active, as it will | 600 // Only call |CancelCurrentFling()| if a fling was active, as it will |
| 657 // otherwise disrupt an in-progress touch scroll. | 601 // otherwise disrupt an in-progress touch scroll. |
| 658 if (!wheel_event.hasPreciseScrollingDeltas && fling_curve_) | 602 if (!wheel_event.hasPreciseScrollingDeltas && fling_curve_) |
| 659 CancelCurrentFling(); | 603 CancelCurrentFling(); |
| 660 | 604 |
| 661 InputHandlerProxy::EventDisposition result = DROP_EVENT; | |
| 662 cc::EventListenerProperties properties = | 605 cc::EventListenerProperties properties = |
| 663 input_handler_->GetEventListenerProperties( | 606 input_handler_->GetEventListenerProperties( |
| 664 cc::EventListenerClass::kMouseWheel); | 607 cc::EventListenerClass::kMouseWheel); |
| 665 switch (properties) { | 608 switch (properties) { |
| 666 case cc::EventListenerProperties::kPassive: | 609 case cc::EventListenerProperties::kPassive: |
| 667 result = DID_HANDLE_NON_BLOCKING; | 610 return DID_HANDLE_NON_BLOCKING; |
| 668 break; | |
| 669 case cc::EventListenerProperties::kBlockingAndPassive: | 611 case cc::EventListenerProperties::kBlockingAndPassive: |
| 670 case cc::EventListenerProperties::kBlocking: | 612 case cc::EventListenerProperties::kBlocking: |
| 671 result = DID_NOT_HANDLE; | 613 return DID_NOT_HANDLE; |
| 672 break; | |
| 673 case cc::EventListenerProperties::kNone: | 614 case cc::EventListenerProperties::kNone: |
| 674 result = DROP_EVENT; | 615 return DROP_EVENT; |
| 675 break; | |
| 676 default: | 616 default: |
| 677 NOTREACHED(); | 617 NOTREACHED(); |
| 678 result = DROP_EVENT; | 618 return DROP_EVENT; |
| 679 } | 619 } |
| 680 | |
| 681 mouse_wheel_result_ = result; | |
| 682 return result; | |
| 683 } | 620 } |
| 684 | 621 |
| 685 InputHandlerProxy::EventDisposition InputHandlerProxy::FlingScrollByMouseWheel( | 622 InputHandlerProxy::EventDisposition InputHandlerProxy::FlingScrollByMouseWheel( |
| 686 const WebMouseWheelEvent& wheel_event, | 623 const WebMouseWheelEvent& wheel_event, |
| 687 cc::EventListenerProperties listener_properties) { | 624 cc::EventListenerProperties listener_properties) { |
| 688 DCHECK(listener_properties == cc::EventListenerProperties::kPassive || | 625 DCHECK(listener_properties == cc::EventListenerProperties::kPassive || |
| 689 listener_properties == cc::EventListenerProperties::kNone); | 626 listener_properties == cc::EventListenerProperties::kNone); |
| 690 | 627 |
| 691 DCHECK(!wheel_event.railsMode); | 628 DCHECK(!wheel_event.railsMode); |
| 692 gfx::Vector2dF scroll_delta(-wheel_event.deltaX, -wheel_event.deltaY); | 629 gfx::Vector2dF scroll_delta(-wheel_event.deltaX, -wheel_event.deltaY); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 scroll_state_begin_data.position_y = wheel_event.y; | 664 scroll_state_begin_data.position_y = wheel_event.y; |
| 728 scroll_state_begin_data.is_beginning = true; | 665 scroll_state_begin_data.is_beginning = true; |
| 729 cc::ScrollState scroll_state_begin(scroll_state_begin_data); | 666 cc::ScrollState scroll_state_begin(scroll_state_begin_data); |
| 730 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 667 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
| 731 &scroll_state_begin, cc::InputHandler::WHEEL); | 668 &scroll_state_begin, cc::InputHandler::WHEEL); |
| 732 | 669 |
| 733 RecordMainThreadScrollingReasons( | 670 RecordMainThreadScrollingReasons( |
| 734 blink::WebGestureDeviceTouchpad, | 671 blink::WebGestureDeviceTouchpad, |
| 735 scroll_status.main_thread_scrolling_reasons); | 672 scroll_status.main_thread_scrolling_reasons); |
| 736 | 673 |
| 737 mouse_wheel_result_ = | |
| 738 (listener_properties == cc::EventListenerProperties::kPassive) | |
| 739 ? DID_HANDLE_NON_BLOCKING | |
| 740 : DROP_EVENT; | |
| 741 RecordScrollingThreadStatus(blink::WebGestureDeviceTouchpad, | |
| 742 scroll_status.main_thread_scrolling_reasons); | |
| 743 | |
| 744 switch (scroll_status.thread) { | 674 switch (scroll_status.thread) { |
| 745 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: { | 675 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: { |
| 746 TRACE_EVENT_INSTANT2("input", | 676 TRACE_EVENT_INSTANT2("input", |
| 747 "InputHandlerProxy::handle_input wheel scroll", | 677 "InputHandlerProxy::handle_input wheel scroll", |
| 748 TRACE_EVENT_SCOPE_THREAD, "deltaX", | 678 TRACE_EVENT_SCOPE_THREAD, "deltaX", |
| 749 scroll_delta.x(), "deltaY", scroll_delta.y()); | 679 scroll_delta.x(), "deltaY", scroll_delta.y()); |
| 750 | 680 |
| 751 cc::ScrollStateData scroll_state_update_data; | 681 cc::ScrollStateData scroll_state_update_data; |
| 752 scroll_state_update_data.delta_x = scroll_delta.x(); | 682 scroll_state_update_data.delta_x = scroll_delta.x(); |
| 753 scroll_state_update_data.delta_y = scroll_delta.y(); | 683 scroll_state_update_data.delta_y = scroll_delta.y(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 } else { | 745 } else { |
| 816 scroll_status = input_handler_->ScrollBegin( | 746 scroll_status = input_handler_->ScrollBegin( |
| 817 &scroll_state, GestureScrollInputType(gesture_event.sourceDevice)); | 747 &scroll_state, GestureScrollInputType(gesture_event.sourceDevice)); |
| 818 } | 748 } |
| 819 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", | 749 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", |
| 820 scroll_status.thread, | 750 scroll_status.thread, |
| 821 cc::InputHandler::LAST_SCROLL_STATUS + 1); | 751 cc::InputHandler::LAST_SCROLL_STATUS + 1); |
| 822 | 752 |
| 823 RecordMainThreadScrollingReasons(gesture_event.sourceDevice, | 753 RecordMainThreadScrollingReasons(gesture_event.sourceDevice, |
| 824 scroll_status.main_thread_scrolling_reasons); | 754 scroll_status.main_thread_scrolling_reasons); |
| 825 RecordScrollingThreadStatus(gesture_event.sourceDevice, | |
| 826 scroll_status.main_thread_scrolling_reasons); | |
| 827 | 755 |
| 828 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE; | 756 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE; |
| 829 switch (scroll_status.thread) { | 757 switch (scroll_status.thread) { |
| 830 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: | 758 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: |
| 831 TRACE_EVENT_INSTANT0("input", | 759 TRACE_EVENT_INSTANT0("input", |
| 832 "InputHandlerProxy::handle_input gesture scroll", | 760 "InputHandlerProxy::handle_input gesture scroll", |
| 833 TRACE_EVENT_SCOPE_THREAD); | 761 TRACE_EVENT_SCOPE_THREAD); |
| 834 gesture_scroll_on_impl_thread_ = true; | 762 gesture_scroll_on_impl_thread_ = true; |
| 835 result = DID_HANDLE; | 763 result = DID_HANDLE; |
| 836 break; | 764 break; |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | 1541 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, |
| 1614 scroll_result)); | 1542 scroll_result)); |
| 1615 } | 1543 } |
| 1616 | 1544 |
| 1617 void InputHandlerProxy::SetTickClockForTesting( | 1545 void InputHandlerProxy::SetTickClockForTesting( |
| 1618 std::unique_ptr<base::TickClock> tick_clock) { | 1546 std::unique_ptr<base::TickClock> tick_clock) { |
| 1619 tick_clock_ = std::move(tick_clock); | 1547 tick_clock_ = std::move(tick_clock); |
| 1620 } | 1548 } |
| 1621 | 1549 |
| 1622 } // namespace ui | 1550 } // namespace ui |
| OLD | NEW |