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

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

Issue 274323004: NOT FOR LANDING - [WebView] Allow fling animation via the LayerScrollOffsetDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 5 years, 9 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
« no previous file with comments | « content/public/browser/android/synchronous_compositor_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 // Note that the timestamp will only be used to kickstart the animation if 513 // Note that the timestamp will only be used to kickstart the animation if
514 // its sufficiently close to the timestamp of the first call |Animate()|. 514 // its sufficiently close to the timestamp of the first call |Animate()|.
515 has_fling_animation_started_ = false; 515 has_fling_animation_started_ = false;
516 fling_parameters_.startTime = gesture_event.timeStampSeconds; 516 fling_parameters_.startTime = gesture_event.timeStampSeconds;
517 fling_parameters_.delta = WebFloatPoint(vx, vy); 517 fling_parameters_.delta = WebFloatPoint(vx, vy);
518 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); 518 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y);
519 fling_parameters_.globalPoint = 519 fling_parameters_.globalPoint =
520 WebPoint(gesture_event.globalX, gesture_event.globalY); 520 WebPoint(gesture_event.globalX, gesture_event.globalY);
521 fling_parameters_.modifiers = gesture_event.modifiers; 521 fling_parameters_.modifiers = gesture_event.modifiers;
522 fling_parameters_.sourceDevice = gesture_event.sourceDevice; 522 fling_parameters_.sourceDevice = gesture_event.sourceDevice;
523 input_handler_->SetNeedsAnimate(); 523 input_handler_->SetNeedsAnimateInput();
524 return DID_HANDLE; 524 return DID_HANDLE;
525 } 525 }
526 case cc::InputHandler::SCROLL_UNKNOWN: 526 case cc::InputHandler::SCROLL_UNKNOWN:
527 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: { 527 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: {
528 TRACE_EVENT_INSTANT0("input", 528 TRACE_EVENT_INSTANT0("input",
529 "InputHandlerProxy::HandleGestureFling::" 529 "InputHandlerProxy::HandleGestureFling::"
530 "scroll_on_main_thread", 530 "scroll_on_main_thread",
531 TRACE_EVENT_SCOPE_THREAD); 531 TRACE_EVENT_SCOPE_THREAD);
532 fling_may_be_active_on_main_thread_ = true; 532 fling_may_be_active_on_main_thread_ = true;
533 return DID_NOT_HANDLE; 533 return DID_NOT_HANDLE;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 733
734 if (!has_fling_animation_started_) { 734 if (!has_fling_animation_started_) {
735 has_fling_animation_started_ = true; 735 has_fling_animation_started_ = true;
736 // Guard against invalid, future or sufficiently stale start times, as there 736 // Guard against invalid, future or sufficiently stale start times, as there
737 // are no guarantees fling event and animation timestamps are compatible. 737 // are no guarantees fling event and animation timestamps are compatible.
738 if (!fling_parameters_.startTime || 738 if (!fling_parameters_.startTime ||
739 monotonic_time_sec <= fling_parameters_.startTime || 739 monotonic_time_sec <= fling_parameters_.startTime ||
740 monotonic_time_sec >= fling_parameters_.startTime + 740 monotonic_time_sec >= fling_parameters_.startTime +
741 kMaxSecondsFromFlingTimestampToFirstAnimate) { 741 kMaxSecondsFromFlingTimestampToFirstAnimate) {
742 fling_parameters_.startTime = monotonic_time_sec; 742 fling_parameters_.startTime = monotonic_time_sec;
743 input_handler_->SetNeedsAnimate(); 743 input_handler_->SetNeedsAnimateInput();
744 return; 744 return;
745 } 745 }
746 } 746 }
747 747
748 bool fling_is_active = 748 bool fling_is_active =
749 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, 749 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime,
750 this); 750 this);
751 751
752 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_) 752 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_)
753 fling_is_active = false; 753 fling_is_active = false;
754 754
755 if (fling_is_active) { 755 if (fling_is_active) {
756 input_handler_->SetNeedsAnimate(); 756 input_handler_->SetNeedsAnimateInput();
757 } else { 757 } else {
758 TRACE_EVENT_INSTANT0("input", 758 TRACE_EVENT_INSTANT0("input",
759 "InputHandlerProxy::animate::flingOver", 759 "InputHandlerProxy::animate::flingOver",
760 TRACE_EVENT_SCOPE_THREAD); 760 TRACE_EVENT_SCOPE_THREAD);
761 CancelCurrentFling(); 761 CancelCurrentFling();
762 } 762 }
763 } 763 }
764 764
765 void InputHandlerProxy::MainThreadHasStoppedFlinging() { 765 void InputHandlerProxy::MainThreadHasStoppedFlinging() {
766 fling_may_be_active_on_main_thread_ = false; 766 fling_may_be_active_on_main_thread_ = false;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // trigger a scroll, e.g., with a trivial time delta between fling updates. 941 // trigger a scroll, e.g., with a trivial time delta between fling updates.
942 // Return true in this case to prevent early fling termination. 942 // Return true in this case to prevent early fling termination.
943 if (std::abs(clipped_increment.width) < kScrollEpsilon && 943 if (std::abs(clipped_increment.width) < kScrollEpsilon &&
944 std::abs(clipped_increment.height) < kScrollEpsilon) 944 std::abs(clipped_increment.height) < kScrollEpsilon)
945 return true; 945 return true;
946 946
947 return did_scroll; 947 return did_scroll;
948 } 948 }
949 949
950 } // namespace content 950 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/android/synchronous_compositor_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698