summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 21:48:01 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 21:48:01 +0000
commit635b0e91e682d7637c5b89398a9e76161f9b744a (patch)
tree1a08cbd5c04e31dbbd7da4e6f4ca6604f9ac0bad /ui
parent909a9d022d002e020ccdf27ba0100bfb58c393ee (diff)
downloadchromium_src-635b0e91e682d7637c5b89398a9e76161f9b744a.zip
chromium_src-635b0e91e682d7637c5b89398a9e76161f9b744a.tar.gz
chromium_src-635b0e91e682d7637c5b89398a9e76161f9b744a.tar.bz2
Revert of Revert of Early terminate flings when scrolling impossible (https://codereview.chromium.org/213743004/)
Reason for revert: The broken fling layout test has been fixed in: https://codereview.chromium.org/219243010/ Original issue's description: > Revert of Early terminate flings when scrolling impossible (https://codereview.chromium.org/136173004/) > > Reason for revert: > Broke a layout test, fast/events/touch/gesture/pad-gesture-fling.html > > http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20Blink&tests=fast%2Fevents%2Ftouch%2Fgesture%2Fpad-gesture-fling.html > > > Original issue's description: > > Early terminate flings when scrolling impossible > > > > Previously, flings were terminated early only if the root layer overscrolled. > > Now, flings will terminate if the fling target's |scrollBy()| method returns > > false, providing consistency between layer types and saving battery on > > sites with scrolling sublayers. > > > > Also move |DidOverscrollParams| into content/ in anticipation of using it > > directly in the overscroll IPC message. > > > > Corresponding Blink patch: > > https://codereview.chromium.org/139493003/ > > > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=260631 > > TBR=aelias@chromium.org,jochen@chromium.org,jdduke@chromium.org > NOTREECHECKS=true > NOTRY=true > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=260773 TBR=aelias@chromium.org,jochen@chromium.org,tkent@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/222353002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261187 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/android/scroller.cc3
-rw-r--r--ui/gfx/android/scroller_unittest.cc24
2 files changed, 27 insertions, 0 deletions
diff --git a/ui/gfx/android/scroller.cc b/ui/gfx/android/scroller.cc
index 96658b2..4a44741 100644
--- a/ui/gfx/android/scroller.cc
+++ b/ui/gfx/android/scroller.cc
@@ -276,6 +276,9 @@ bool Scroller::ComputeScrollOffset(base::TimeTicks time) {
if (finished_)
return false;
+ if (time == curr_time_)
+ return true;
+
base::TimeDelta time_passed = time - start_time_;
if (time_passed < base::TimeDelta()) {
diff --git a/ui/gfx/android/scroller_unittest.cc b/ui/gfx/android/scroller_unittest.cc
index af3c67a..9b1018d 100644
--- a/ui/gfx/android/scroller_unittest.cc
+++ b/ui/gfx/android/scroller_unittest.cc
@@ -63,6 +63,18 @@ TEST_F(ScrollerTest, Scroll) {
EXPECT_GT(0.f, scroller.GetCurrVelocityY() * kDefaultDeltaY);
EXPECT_TRUE(scroller.IsScrollingInDirection(kDefaultDeltaX, kDefaultDeltaY));
+ // Repeated offset computations at the same timestamp should yield identical
+ // results.
+ float curr_x = scroller.GetCurrX();
+ float curr_y = scroller.GetCurrY();
+ float curr_velocity_x = scroller.GetCurrVelocityX();
+ float curr_velocity_y = scroller.GetCurrVelocityY();
+ scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
+ EXPECT_EQ(curr_x, scroller.GetCurrX());
+ EXPECT_EQ(curr_y, scroller.GetCurrY());
+ EXPECT_EQ(curr_velocity_x, scroller.GetCurrVelocityX());
+ EXPECT_EQ(curr_velocity_y, scroller.GetCurrVelocityY());
+
// Advance to the end.
scroller.ComputeScrollOffset(start_time + scroll_duration);
EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());
@@ -123,6 +135,18 @@ TEST_F(ScrollerTest, Fling) {
EXPECT_TRUE(
scroller.IsScrollingInDirection(kDefaultVelocityX, kDefaultVelocityY));
+ // Repeated offset computations at the same timestamp should yield identical
+ // results.
+ float curr_x = scroller.GetCurrX();
+ float curr_y = scroller.GetCurrY();
+ float curr_velocity_x = scroller.GetCurrVelocityX();
+ float curr_velocity_y = scroller.GetCurrVelocityY();
+ scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
+ EXPECT_EQ(curr_x, scroller.GetCurrX());
+ EXPECT_EQ(curr_y, scroller.GetCurrY());
+ EXPECT_EQ(curr_velocity_x, scroller.GetCurrVelocityX());
+ EXPECT_EQ(curr_velocity_y, scroller.GetCurrVelocityY());
+
// Advance to the end.
scroller.ComputeScrollOffset(start_time + scroll_duration);
EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());