Bug 935473 - Avoid unnecessary animations in forward button (r=wesj)
authorLucas Rocha <lucasr@lucasr.org>
Thu, 05 Dec 2013 16:26:35 +0000
changeset 173674 8e6348162cc2b45f9236e4a1f3cbe83df63e8ab1
parent 173673 b3128b3dc02dc8d3efe05cb6c80ac1dcdc64d21b
child 173675 2c343bc88009383f5192c586f2bd153009bacec2
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs935473
milestone28.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 935473 - Avoid unnecessary animations in forward button (r=wesj)
mobile/android/base/toolbar/BrowserToolbar.java
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -1381,16 +1381,24 @@ public class BrowserToolbar extends Geck
 
         // Save the state on the forward button so that we can skip animations
         // when there's nothing to change
         setButtonEnabled(mForward, enabled);
 
         if (mForward.getVisibility() != View.VISIBLE)
             return;
 
+        // if the forward button's margin is non-zero, this means it has already
+        // been animated to be visible¬ł and vice-versa.
+        MarginLayoutParams fwdParams = (MarginLayoutParams) mForward.getLayoutParams();
+        if ((fwdParams.leftMargin > mDefaultForwardMargin && enabled) ||
+            (fwdParams.leftMargin == mDefaultForwardMargin && !enabled)) {
+            return;
+        }
+
         // We want the forward button to show immediately when switching tabs
         mForwardAnim = new PropertyAnimator(mSwitchingTabs ? 10 : FORWARD_ANIMATION_DURATION);
         final int width = mForward.getWidth() / 2;
 
         mForwardAnim.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
             @Override
             public void onPropertyAnimationStart() {
                 if (!enabled) {