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

Side by Side Diff: content/renderer/input/input_handler_proxy.cc

Issue 1063853005: Unify Android Webview and Chrome's fling (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: add a todo Created 5 years, 6 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 "content/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 FROM_HERE, 413 FROM_HERE,
414 base::Bind(&InputScrollElasticityController::ObserveWheelEventAndResult, 414 base::Bind(&InputScrollElasticityController::ObserveWheelEventAndResult,
415 scroll_elasticity_controller_->GetWeakPtr(), wheel_event, 415 scroll_elasticity_controller_->GetWeakPtr(), wheel_event,
416 scroll_result)); 416 scroll_result));
417 } 417 }
418 return result; 418 return result;
419 } 419 }
420 420
421 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin( 421 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin(
422 const WebGestureEvent& gesture_event) { 422 const WebGestureEvent& gesture_event) {
423 DCHECK(!gesture_scroll_on_impl_thread_); 423 if (gesture_scroll_on_impl_thread_)
424 CancelCurrentFling();
425
424 #ifndef NDEBUG 426 #ifndef NDEBUG
425 DCHECK(!expect_scroll_update_end_); 427 DCHECK(!expect_scroll_update_end_);
426 expect_scroll_update_end_ = true; 428 expect_scroll_update_end_ = true;
427 #endif 429 #endif
428 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( 430 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin(
429 gfx::Point(gesture_event.x, gesture_event.y), cc::InputHandler::GESTURE); 431 gfx::Point(gesture_event.x, gesture_event.y), cc::InputHandler::GESTURE);
430 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", 432 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult",
431 scroll_status, 433 scroll_status,
432 cc::InputHandler::ScrollStatusCount); 434 cc::InputHandler::ScrollStatusCount);
433 switch (scroll_status) { 435 switch (scroll_status) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // Note that the timestamp will only be used to kickstart the animation if 527 // Note that the timestamp will only be used to kickstart the animation if
526 // its sufficiently close to the timestamp of the first call |Animate()|. 528 // its sufficiently close to the timestamp of the first call |Animate()|.
527 has_fling_animation_started_ = false; 529 has_fling_animation_started_ = false;
528 fling_parameters_.startTime = gesture_event.timeStampSeconds; 530 fling_parameters_.startTime = gesture_event.timeStampSeconds;
529 fling_parameters_.delta = WebFloatPoint(vx, vy); 531 fling_parameters_.delta = WebFloatPoint(vx, vy);
530 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); 532 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y);
531 fling_parameters_.globalPoint = 533 fling_parameters_.globalPoint =
532 WebPoint(gesture_event.globalX, gesture_event.globalY); 534 WebPoint(gesture_event.globalX, gesture_event.globalY);
533 fling_parameters_.modifiers = gesture_event.modifiers; 535 fling_parameters_.modifiers = gesture_event.modifiers;
534 fling_parameters_.sourceDevice = gesture_event.sourceDevice; 536 fling_parameters_.sourceDevice = gesture_event.sourceDevice;
535 input_handler_->SetNeedsAnimate(); 537 input_handler_->SetNeedsAnimateInput();
536 return DID_HANDLE; 538 return DID_HANDLE;
537 } 539 }
538 case cc::InputHandler::SCROLL_UNKNOWN: 540 case cc::InputHandler::SCROLL_UNKNOWN:
539 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: { 541 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: {
540 TRACE_EVENT_INSTANT0("input", 542 TRACE_EVENT_INSTANT0("input",
541 "InputHandlerProxy::HandleGestureFling::" 543 "InputHandlerProxy::HandleGestureFling::"
542 "scroll_on_main_thread", 544 "scroll_on_main_thread",
543 TRACE_EVENT_SCOPE_THREAD); 545 TRACE_EVENT_SCOPE_THREAD);
544 gesture_scroll_on_impl_thread_ = false; 546 gesture_scroll_on_impl_thread_ = false;
545 fling_may_be_active_on_main_thread_ = true; 547 fling_may_be_active_on_main_thread_ = true;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 749
748 if (!has_fling_animation_started_) { 750 if (!has_fling_animation_started_) {
749 has_fling_animation_started_ = true; 751 has_fling_animation_started_ = true;
750 // Guard against invalid, future or sufficiently stale start times, as there 752 // Guard against invalid, future or sufficiently stale start times, as there
751 // are no guarantees fling event and animation timestamps are compatible. 753 // are no guarantees fling event and animation timestamps are compatible.
752 if (!fling_parameters_.startTime || 754 if (!fling_parameters_.startTime ||
753 monotonic_time_sec <= fling_parameters_.startTime || 755 monotonic_time_sec <= fling_parameters_.startTime ||
754 monotonic_time_sec >= fling_parameters_.startTime + 756 monotonic_time_sec >= fling_parameters_.startTime +
755 kMaxSecondsFromFlingTimestampToFirstAnimate) { 757 kMaxSecondsFromFlingTimestampToFirstAnimate) {
756 fling_parameters_.startTime = monotonic_time_sec; 758 fling_parameters_.startTime = monotonic_time_sec;
757 input_handler_->SetNeedsAnimate(); 759 input_handler_->SetNeedsAnimateInput();
758 return; 760 return;
759 } 761 }
760 } 762 }
761 763
762 bool fling_is_active = 764 bool fling_is_active =
763 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, 765 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime,
764 this); 766 this);
765 767
766 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_) 768 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_)
767 fling_is_active = false; 769 fling_is_active = false;
768 770
769 if (fling_is_active) { 771 if (fling_is_active) {
770 input_handler_->SetNeedsAnimate(); 772 input_handler_->SetNeedsAnimateInput();
771 } else { 773 } else {
772 TRACE_EVENT_INSTANT0("input", 774 TRACE_EVENT_INSTANT0("input",
773 "InputHandlerProxy::animate::flingOver", 775 "InputHandlerProxy::animate::flingOver",
774 TRACE_EVENT_SCOPE_THREAD); 776 TRACE_EVENT_SCOPE_THREAD);
775 CancelCurrentFling(); 777 CancelCurrentFling();
776 } 778 }
777 } 779 }
778 780
779 void InputHandlerProxy::MainThreadHasStoppedFlinging() { 781 void InputHandlerProxy::MainThreadHasStoppedFlinging() {
780 fling_may_be_active_on_main_thread_ = false; 782 fling_may_be_active_on_main_thread_ = false;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 // trigger a scroll, e.g., with a trivial time delta between fling updates. 957 // trigger a scroll, e.g., with a trivial time delta between fling updates.
956 // Return true in this case to prevent early fling termination. 958 // Return true in this case to prevent early fling termination.
957 if (std::abs(clipped_increment.width) < kScrollEpsilon && 959 if (std::abs(clipped_increment.width) < kScrollEpsilon &&
958 std::abs(clipped_increment.height) < kScrollEpsilon) 960 std::abs(clipped_increment.height) < kScrollEpsilon)
959 return true; 961 return true;
960 962
961 return did_scroll; 963 return did_scroll;
962 } 964 }
963 965
964 } // namespace content 966 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698