Bug 1091128 - Ensure that large negative velocities are also clamped to the velocity cap. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 29 Oct 2014 15:40:02 -0400
changeset 213078 08655880fafcd9aa67d61b0ac421c9b7e96c4409
parent 213077 2f7b39a26383401515d091f07df68e67899317ad
child 213079 d81c4d490c107b4b90d5422e51ad83fa26f09a1b
push id51143
push usercbook@mozilla.com
push dateThu, 30 Oct 2014 14:14:04 +0000
treeherdermozilla-inbound@e80345c5bf6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1091128
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1091128 - Ensure that large negative velocities are also clamped to the velocity cap. r=botond
gfx/layers/apz/src/Axis.cpp
--- a/gfx/layers/apz/src/Axis.cpp
+++ b/gfx/layers/apz/src/Axis.cpp
@@ -44,19 +44,26 @@ void Axis::UpdateWithTouchAtDevicePoint(
     // update mPos so we don't run into problems like bug 1042734, even though
     // that means the velocity will be stale. Better than doing a divide-by-zero.
     mPos = aPos;
     return;
   }
 
   float newVelocity = mAxisLocked ? 0.0f : (float)(mPos - aPos) / (float)(aTimestampMs - mPosTimeMs);
   if (gfxPrefs::APZMaxVelocity() > 0.0f) {
+    bool velocityIsNegative = (newVelocity < 0);
+    newVelocity = fabs(newVelocity);
+
     ScreenPoint maxVelocity = MakePoint(gfxPrefs::APZMaxVelocity() * APZCTreeManager::GetDPI());
     mAsyncPanZoomController->ToLocalScreenCoordinates(&maxVelocity, mAsyncPanZoomController->PanStart());
     newVelocity = std::min(newVelocity, maxVelocity.Length());
+
+    if (velocityIsNegative) {
+      newVelocity = -newVelocity;
+    }
   }
 
   mVelocity = newVelocity;
   mPos = aPos;
   mPosTimeMs = aTimestampMs;
 
   // Limit queue size pased on pref
   mVelocityQueue.AppendElement(std::make_pair(aTimestampMs, mVelocity));