Bug 886576 - Fix scrolling cancelling locked dynamic toolbar animations. r=kats, a=lsblakk
authorChris Lord <chrislord.net@gmail.com>
Fri, 19 Jul 2013 17:39:44 +0100
changeset 148028 d45388fa2fe17a4d6d72bd04b5e375312524cc39
parent 148027 8ac9338cb526e78afaa212d47eaa44b6b1c0b318
child 148029 653b455a607a8b30f2191f43867faa74df047f1f
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, lsblakk
bugs886576
milestone24.0a2
Bug 886576 - Fix scrolling cancelling locked dynamic toolbar animations. r=kats, a=lsblakk Move the margin animation-cancelling call into the margins-pinned check block in LayerMarginsAnimator to make sure margin animations aren't cancelled by scrolling when margins are locked.
mobile/android/base/BrowserApp.java
mobile/android/base/gfx/LayerMarginsAnimator.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1210,18 +1210,18 @@ abstract public class BrowserApp extends
 
         mTabsPanel.prepareTabsAnimation(mMainLayoutAnimator);
         mBrowserToolbar.prepareTabsAnimation(mMainLayoutAnimator, areTabsShown());
 
         // If the tabs layout is animating onto the screen, pin the dynamic
         // toolbar.
         if (mLayerView != null && isDynamicToolbarEnabled()) {
             if (width > 0 && height > 0) {
+                mLayerView.getLayerMarginsAnimator().setMarginsPinned(true);
                 mLayerView.getLayerMarginsAnimator().showMargins(false);
-                mLayerView.getLayerMarginsAnimator().setMarginsPinned(true);
             } else {
                 mLayerView.getLayerMarginsAnimator().setMarginsPinned(false);
             }
         }
 
         mMainLayoutAnimator.start();
     }
 
--- a/mobile/android/base/gfx/LayerMarginsAnimator.java
+++ b/mobile/android/base/gfx/LayerMarginsAnimator.java
@@ -221,27 +221,27 @@ public class LayerMarginsAnimator implem
         return aDelta - (marginStart - aMargins[0]);
     }
 
     /*
      * Taking maximum margins into account, offsets the margins and then the
      * viewport origin and returns the modified metrics.
      */
     ImmutableViewportMetrics scrollBy(ImmutableViewportMetrics aMetrics, float aDx, float aDy) {
-        // Make sure to cancel any margin animations when scrolling begins
-        if (mAnimationTimer != null) {
-            mAnimationTimer.cancel();
-            mAnimationTimer = null;
-        }
-
         float[] newMarginsX = { aMetrics.marginLeft, aMetrics.marginRight };
         float[] newMarginsY = { aMetrics.marginTop, aMetrics.marginBottom };
 
         // Only alter margins if the toolbar isn't pinned
         if (!mMarginsPinned) {
+            // Make sure to cancel any margin animations when margin-scrolling begins
+            if (mAnimationTimer != null) {
+                mAnimationTimer.cancel();
+                mAnimationTimer = null;
+            }
+
             // Reset the touch travel when changing direction
             if ((aDx >= 0) != (mTouchTravelDistance.x >= 0)) {
                 mTouchTravelDistance.x = 0;
             }
             if ((aDy >= 0) != (mTouchTravelDistance.y >= 0)) {
                 mTouchTravelDistance.y = 0;
             }