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

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

Powered by Google App Engine
This is Rietveld 408576698