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

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

Issue 2040543002: Take MT jank into account when animating the scroll offset on CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused plumbing Created 4 years, 3 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // TODO(jamesr): We don't properly handle scroll by page in the compositor 486 // TODO(jamesr): We don't properly handle scroll by page in the compositor
487 // thread, so punt it to the main thread. http://crbug.com/236639 487 // thread, so punt it to the main thread. http://crbug.com/236639
488 result = DID_NOT_HANDLE; 488 result = DID_NOT_HANDLE;
489 RecordMainThreadScrollingReasons( 489 RecordMainThreadScrollingReasons(
490 blink::WebGestureDeviceTouchpad, 490 blink::WebGestureDeviceTouchpad,
491 cc::MainThreadScrollingReason::kPageBasedScrolling); 491 cc::MainThreadScrollingReason::kPageBasedScrolling);
492 492
493 } else if (ShouldAnimate(wheel_event.hasPreciseScrollingDeltas)) { 493 } else if (ShouldAnimate(wheel_event.hasPreciseScrollingDeltas)) {
494 cc::InputHandler::ScrollStatus scroll_status = 494 cc::InputHandler::ScrollStatus scroll_status =
495 input_handler_->ScrollAnimated(gfx::Point(wheel_event.x, wheel_event.y), 495 input_handler_->ScrollAnimated(gfx::Point(wheel_event.x, wheel_event.y),
496 scroll_delta); 496 scroll_delta, base::TimeDelta());
497 497
498 RecordMainThreadScrollingReasons( 498 RecordMainThreadScrollingReasons(
499 blink::WebGestureDeviceTouchpad, 499 blink::WebGestureDeviceTouchpad,
500 scroll_status.main_thread_scrolling_reasons); 500 scroll_status.main_thread_scrolling_reasons);
501 501
502 switch (scroll_status.thread) { 502 switch (scroll_status.thread) {
503 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: 503 case cc::InputHandler::SCROLL_ON_IMPL_THREAD:
504 result = DID_HANDLE; 504 result = DID_HANDLE;
505 break; 505 break;
506 case cc::InputHandler::SCROLL_IGNORED: 506 case cc::InputHandler::SCROLL_IGNORED:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 618 }
619 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) 619 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE)
620 HandleScrollElasticityOverscroll(gesture_event, 620 HandleScrollElasticityOverscroll(gesture_event,
621 cc::InputHandlerScrollResult()); 621 cc::InputHandlerScrollResult());
622 622
623 return result; 623 return result;
624 } 624 }
625 625
626 InputHandlerProxy::EventDisposition 626 InputHandlerProxy::EventDisposition
627 InputHandlerProxy::HandleGestureScrollUpdate( 627 InputHandlerProxy::HandleGestureScrollUpdate(
628 const WebGestureEvent& gesture_event) { 628 const WebGestureEvent& gesture_event) {
629 #ifndef NDEBUG 629 #ifndef NDEBUG
630 DCHECK(expect_scroll_update_end_); 630 DCHECK(expect_scroll_update_end_);
631 #endif 631 #endif
632 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) 632 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_)
633 return DID_NOT_HANDLE; 633 return DID_NOT_HANDLE;
634 634
635 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); 635 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event);
636 gfx::Point scroll_point(gesture_event.x, gesture_event.y); 636 gfx::Point scroll_point(gesture_event.x, gesture_event.y);
637 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, 637 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX,
638 -gesture_event.data.scrollUpdate.deltaY); 638 -gesture_event.data.scrollUpdate.deltaY);
639 639
640 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits != 640 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits !=
641 blink::WebGestureEvent::ScrollUnits::Pixels)) { 641 blink::WebGestureEvent::ScrollUnits::Pixels)) {
642 switch (input_handler_->ScrollAnimated(scroll_point, scroll_delta).thread) { 642 base::TimeDelta delay =
643 (base::TimeTicks::Now() -
644 (base::TimeTicks() +
645 base::TimeDelta::FromSecondsD(gesture_event.timeStampSeconds)));
tdresser 2016/08/25 15:55:54 Math seems correct, though I might add a temporary
ymalik 2016/08/29 14:52:06 Good tip, looks much prettier!
646 switch (input_handler_->ScrollAnimated(scroll_point, scroll_delta, delay)
647 .thread) {
643 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: 648 case cc::InputHandler::SCROLL_ON_IMPL_THREAD:
644 return DID_HANDLE; 649 return DID_HANDLE;
645 case cc::InputHandler::SCROLL_IGNORED: 650 case cc::InputHandler::SCROLL_IGNORED:
646 return DROP_EVENT; 651 return DROP_EVENT;
647 default: 652 default:
648 return DID_NOT_HANDLE; 653 return DID_NOT_HANDLE;
649 } 654 }
650 } 655 }
651 cc::InputHandlerScrollResult scroll_result = 656 cc::InputHandlerScrollResult scroll_result =
652 input_handler_->ScrollBy(&scroll_state); 657 input_handler_->ScrollBy(&scroll_state);
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 // is made asynchronously, to minimize divergence between main thread and 1346 // is made asynchronously, to minimize divergence between main thread and
1342 // impl thread event handling paths. 1347 // impl thread event handling paths.
1343 base::ThreadTaskRunnerHandle::Get()->PostTask( 1348 base::ThreadTaskRunnerHandle::Get()->PostTask(
1344 FROM_HERE, 1349 FROM_HERE,
1345 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, 1350 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult,
1346 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, 1351 scroll_elasticity_controller_->GetWeakPtr(), gesture_event,
1347 scroll_result)); 1352 scroll_result));
1348 } 1353 }
1349 1354
1350 } // namespace ui 1355 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698