Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: ui/events/blink/input_handler_proxy.cc

Issue 2625453002: Touchpad and wheel scroll latching for ChromeOS behind flag. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 expect_scroll_update_end_(false), 247 expect_scroll_update_end_(false),
248 #endif 248 #endif
249 gesture_scroll_on_impl_thread_(false), 249 gesture_scroll_on_impl_thread_(false),
250 gesture_pinch_on_impl_thread_(false), 250 gesture_pinch_on_impl_thread_(false),
251 fling_may_be_active_on_main_thread_(false), 251 fling_may_be_active_on_main_thread_(false),
252 disallow_horizontal_fling_scroll_(false), 252 disallow_horizontal_fling_scroll_(false),
253 disallow_vertical_fling_scroll_(false), 253 disallow_vertical_fling_scroll_(false),
254 has_fling_animation_started_(false), 254 has_fling_animation_started_(false),
255 smooth_scroll_enabled_(false), 255 smooth_scroll_enabled_(false),
256 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()), 256 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()),
257 touchpad_and_wheel_scroll_latching_enabled_(false),
257 touch_start_result_(kEventDispositionUndefined), 258 touch_start_result_(kEventDispositionUndefined),
258 current_overscroll_params_(nullptr), 259 current_overscroll_params_(nullptr),
259 has_ongoing_compositor_scroll_pinch_(false), 260 has_ongoing_compositor_scroll_pinch_(false),
260 tick_clock_(base::MakeUnique<base::DefaultTickClock>()) { 261 tick_clock_(base::MakeUnique<base::DefaultTickClock>()) {
261 DCHECK(client); 262 DCHECK(client);
262 input_handler_->BindToClient(this); 263 input_handler_->BindToClient(this);
263 cc::ScrollElasticityHelper* scroll_elasticity_helper = 264 cc::ScrollElasticityHelper* scroll_elasticity_helper =
264 input_handler_->CreateScrollElasticityHelper(); 265 input_handler_->CreateScrollElasticityHelper();
265 if (scroll_elasticity_helper) { 266 if (scroll_elasticity_helper) {
266 scroll_elasticity_controller_.reset( 267 scroll_elasticity_controller_.reset(
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 case cc::EventListenerProperties::kBlocking: 607 case cc::EventListenerProperties::kBlocking:
607 return DID_NOT_HANDLE; 608 return DID_NOT_HANDLE;
608 case cc::EventListenerProperties::kNone: 609 case cc::EventListenerProperties::kNone:
609 return DROP_EVENT; 610 return DROP_EVENT;
610 default: 611 default:
611 NOTREACHED(); 612 NOTREACHED();
612 return DROP_EVENT; 613 return DROP_EVENT;
613 } 614 }
614 } 615 }
615 616
616 InputHandlerProxy::EventDisposition InputHandlerProxy::ScrollByMouseWheel( 617 InputHandlerProxy::EventDisposition InputHandlerProxy::FlingScrollByMouseWheel(
617 const WebMouseWheelEvent& wheel_event, 618 const WebMouseWheelEvent& wheel_event,
618 cc::EventListenerProperties listener_properties) { 619 cc::EventListenerProperties listener_properties) {
619 DCHECK(listener_properties == cc::EventListenerProperties::kPassive || 620 DCHECK(listener_properties == cc::EventListenerProperties::kPassive ||
620 listener_properties == cc::EventListenerProperties::kNone); 621 listener_properties == cc::EventListenerProperties::kNone);
621 622
622 // TODO(ccameron): The rail information should be pushed down into 623 DCHECK(!wheel_event.railsMode);
bokan 2017/01/10 18:53:58 Is this because the TODO was resolved?
sahel 2017/01/10 21:10:06 No it's not, it is because this function is only c
623 // InputHandler. 624 gfx::Vector2dF scroll_delta(-wheel_event.deltaX, -wheel_event.deltaY);
624 gfx::Vector2dF scroll_delta(
625 wheel_event.railsMode != WebInputEvent::RailsModeVertical
626 ? -wheel_event.deltaX
627 : 0,
628 wheel_event.railsMode != WebInputEvent::RailsModeHorizontal
629 ? -wheel_event.deltaY
630 : 0);
631 625
632 if (wheel_event.scrollByPage) { 626 DCHECK(!wheel_event.scrollByPage);
bokan 2017/01/10 18:53:58 The bug linked with the TODO(jamesr) is still open
sahel 2017/01/10 21:10:06 Similarly, this part of the code was never execute
633 // TODO(jamesr): We don't properly handle scroll by page in the compositor 627 DCHECK(wheel_event.hasPreciseScrollingDeltas);
634 // thread, so punt it to the main thread. http://crbug.com/236639 628 if (touchpad_and_wheel_scroll_latching_enabled_) {
635 RecordMainThreadScrollingReasons( 629 if (gesture_scroll_on_impl_thread_) {
bokan 2017/01/10 18:53:58 nit: if (!gesture_scroll_on_impl_thread_) ret
sahel 2017/01/10 21:10:06 Done.
636 blink::WebGestureDeviceTouchpad, 630 TRACE_EVENT_INSTANT2("input",
637 cc::MainThreadScrollingReason::kPageBasedScrolling); 631 "InputHandlerProxy::handle_input wheel scroll",
638 return DID_NOT_HANDLE; 632 TRACE_EVENT_SCOPE_THREAD, "deltaX", scroll_delta.x(),
633 "deltaY", scroll_delta.y());
639 634
640 } else if (ShouldAnimate(wheel_event.hasPreciseScrollingDeltas)) { 635 cc::ScrollStateData scroll_state_update_data;
641 base::TimeTicks event_time = 636 scroll_state_update_data.delta_x = scroll_delta.x();
642 base::TimeTicks() + 637 scroll_state_update_data.delta_y = scroll_delta.y();
643 base::TimeDelta::FromSecondsD(wheel_event.timeStampSeconds); 638 scroll_state_update_data.position_x = wheel_event.x;
644 base::TimeDelta delay = base::TimeTicks::Now() - event_time; 639 scroll_state_update_data.position_y = wheel_event.y;
bokan 2017/01/10 18:53:58 This code is duplicated from below. Instead of cop
sahel 2017/01/10 21:10:06 I initially did that in mouse_wheel_event_queue. I
bokan 2017/01/10 21:25:06 Ok, if it's going away eventually duplication is f
sahel 2017/01/12 18:53:44 Acknowledged.
645 cc::InputHandler::ScrollStatus scroll_status = 640 cc::ScrollState scroll_state_update(scroll_state_update_data);
646 input_handler_->ScrollAnimated(gfx::Point(wheel_event.x, wheel_event.y),
647 scroll_delta, delay);
648 641
649 RecordMainThreadScrollingReasons( 642 cc::InputHandlerScrollResult scroll_result =
650 blink::WebGestureDeviceTouchpad, 643 input_handler_->ScrollBy(&scroll_state_update);
651 scroll_status.main_thread_scrolling_reasons); 644 HandleOverscroll(gfx::Point(wheel_event.x, wheel_event.y), scroll_result,
645 false);
646 if (scroll_result.did_scroll) {
647 return listener_properties == cc::EventListenerProperties::kPassive
648 ? DID_HANDLE_NON_BLOCKING
649 : DID_HANDLE;
650 }
651 // End of fling.
652 cc::ScrollStateData scroll_state_end_data;
653 scroll_state_end_data.is_ending = true;
654 cc::ScrollState scroll_state_end(scroll_state_end_data);
655 input_handler_->ScrollEnd(&scroll_state_end);
652 656
653 switch (scroll_status.thread) { 657 return DROP_EVENT;
654 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: 658 } else {
655 return DID_HANDLE; 659 return DID_NOT_HANDLE;
656 case cc::InputHandler::SCROLL_IGNORED:
657 return DROP_EVENT;
658 default:
659 return DID_NOT_HANDLE;
660 } 660 }
661 661 } else { // !touchpad_and_wheel_scroll_latching_enabled_
662 } else {
663 cc::ScrollStateData scroll_state_begin_data; 662 cc::ScrollStateData scroll_state_begin_data;
664 scroll_state_begin_data.position_x = wheel_event.x; 663 scroll_state_begin_data.position_x = wheel_event.x;
665 scroll_state_begin_data.position_y = wheel_event.y; 664 scroll_state_begin_data.position_y = wheel_event.y;
666 scroll_state_begin_data.is_beginning = true; 665 scroll_state_begin_data.is_beginning = true;
667 cc::ScrollState scroll_state_begin(scroll_state_begin_data); 666 cc::ScrollState scroll_state_begin(scroll_state_begin_data);
668 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( 667 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin(
669 &scroll_state_begin, cc::InputHandler::WHEEL); 668 &scroll_state_begin, cc::InputHandler::WHEEL);
670 669
671 RecordMainThreadScrollingReasons( 670 RecordMainThreadScrollingReasons(
672 blink::WebGestureDeviceTouchpad, 671 blink::WebGestureDeviceTouchpad,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 NOTREACHED(); 872 NOTREACHED();
874 return DID_NOT_HANDLE; 873 return DID_NOT_HANDLE;
875 } 874 }
876 875
877 #ifndef NDEBUG 876 #ifndef NDEBUG
878 expect_scroll_update_end_ = false; 877 expect_scroll_update_end_ = false;
879 #endif 878 #endif
880 879
881 switch (scroll_status.thread) { 880 switch (scroll_status.thread) {
882 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: { 881 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: {
883 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { 882 if (!touchpad_and_wheel_scroll_latching_enabled_ &&
883 gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) {
884 scroll_state.set_is_ending(true); 884 scroll_state.set_is_ending(true);
885 input_handler_->ScrollEnd(&scroll_state); 885 input_handler_->ScrollEnd(&scroll_state);
886 } 886 }
887 887
888 const float vx = gesture_event.data.flingStart.velocityX; 888 const float vx = gesture_event.data.flingStart.velocityX;
889 const float vy = gesture_event.data.flingStart.velocityY; 889 const float vy = gesture_event.data.flingStart.velocityY;
890 current_fling_velocity_ = gfx::Vector2dF(vx, vy); 890 current_fling_velocity_ = gfx::Vector2dF(vx, vy);
891 DCHECK(!current_fling_velocity_.IsZero()); 891 DCHECK(!current_fling_velocity_.IsZero());
892 fling_curve_.reset(client_->CreateFlingAnimationCurve( 892 fling_curve_.reset(client_->CreateFlingAnimationCurve(
893 gesture_event.sourceDevice, 893 gesture_event.sourceDevice,
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 fling_parameters_.modifiers, 1409 fling_parameters_.modifiers,
1410 InSecondsF(base::TimeTicks::Now())); 1410 InSecondsF(base::TimeTicks::Now()));
1411 synthetic_wheel.deltaX = increment.width; 1411 synthetic_wheel.deltaX = increment.width;
1412 synthetic_wheel.deltaY = increment.height; 1412 synthetic_wheel.deltaY = increment.height;
1413 synthetic_wheel.hasPreciseScrollingDeltas = true; 1413 synthetic_wheel.hasPreciseScrollingDeltas = true;
1414 synthetic_wheel.x = fling_parameters_.point.x; 1414 synthetic_wheel.x = fling_parameters_.point.x;
1415 synthetic_wheel.y = fling_parameters_.point.y; 1415 synthetic_wheel.y = fling_parameters_.point.y;
1416 synthetic_wheel.globalX = fling_parameters_.globalPoint.x; 1416 synthetic_wheel.globalX = fling_parameters_.globalPoint.x;
1417 synthetic_wheel.globalY = fling_parameters_.globalPoint.y; 1417 synthetic_wheel.globalY = fling_parameters_.globalPoint.y;
1418 1418
1419 disposition = ScrollByMouseWheel(synthetic_wheel, properties); 1419 disposition = FlingScrollByMouseWheel(synthetic_wheel, properties);
1420 1420
1421 // Send the event over to the main thread. 1421 // Send the event over to the main thread.
1422 if (disposition == DID_HANDLE_NON_BLOCKING) { 1422 if (disposition == DID_HANDLE_NON_BLOCKING) {
1423 client_->DispatchNonBlockingEventToMainThread( 1423 client_->DispatchNonBlockingEventToMainThread(
1424 ui::WebInputEventTraits::Clone(synthetic_wheel), ui::LatencyInfo()); 1424 ui::WebInputEventTraits::Clone(synthetic_wheel), ui::LatencyInfo());
1425 } 1425 }
1426 break; 1426 break;
1427 } 1427 }
1428 default: 1428 default:
1429 NOTREACHED(); 1429 NOTREACHED();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, 1539 scroll_elasticity_controller_->GetWeakPtr(), gesture_event,
1540 scroll_result)); 1540 scroll_result));
1541 } 1541 }
1542 1542
1543 void InputHandlerProxy::SetTickClockForTesting( 1543 void InputHandlerProxy::SetTickClockForTesting(
1544 std::unique_ptr<base::TickClock> tick_clock) { 1544 std::unique_ptr<base::TickClock> tick_clock) {
1545 tick_clock_ = std::move(tick_clock); 1545 tick_clock_ = std::move(tick_clock);
1546 } 1546 }
1547 1547
1548 } // namespace ui 1548 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698