Bug 849573 - Handle interrupted tabs tray animation. r=sriram
authorChris Lord <chrislord.net@gmail.com>
Wed, 20 Mar 2013 23:43:47 +0000
changeset 125730 13efcaa536a7f9c7ae9af8fb351976d54749daa3
parent 125729 57d5c140a8f1ebed1069ebd57d97f9aeabe4e4eb
child 125731 d16237d9bdb39aeb4329688528e467ee873e463e
push id24461
push useremorley@mozilla.com
push dateThu, 21 Mar 2013 11:51:51 +0000
treeherdermozilla-central@a73a2b5c423b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs849573
milestone22.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 849573 - Handle interrupted tabs tray animation. r=sriram If the tabs tray animation is interrupted to run in the opposite direction, run the animation from the point the tray currently is, rather than snapping it to the open or closed position first.
mobile/android/base/BrowserApp.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -60,16 +60,18 @@ import java.util.Vector;
 abstract public class BrowserApp extends GeckoApp
                                  implements TabsPanel.TabsLayoutChangeListener,
                                             PropertyAnimator.PropertyAnimationListener,
                                             View.OnKeyListener {
     private static final String LOGTAG = "GeckoBrowserApp";
 
     private static final String PREF_CHROME_DYNAMICTOOLBAR = "browser.chrome.dynamictoolbar";
 
+    private static final int TABS_ANIMATION_DURATION = 450;
+
     public static BrowserToolbar mBrowserToolbar;
     private AboutHomeContent mAboutHomeContent;
     private Boolean mAboutHomeShowing = null;
     protected Telemetry.Timer mAboutHomeStartupTimer = null;
 
     private static final int ADDON_MENU_OFFSET = 1000;
     private class MenuItemInfo {
         public int id;
@@ -953,23 +955,27 @@ abstract public class BrowserApp extends
 
     @Override
     public boolean areTabsShown() {
         return mTabsPanel.isShown();
     }
 
     @Override
     public void onTabsLayoutChange(int width, int height) {
-        if (mMainLayoutAnimator != null)
-            mMainLayoutAnimator.stop();
+        int animationLength = TABS_ANIMATION_DURATION;
+
+        if (mMainLayoutAnimator != null) {
+            animationLength = Math.max(1, animationLength - (int)mMainLayoutAnimator.getRemainingTime());
+            mMainLayoutAnimator.stop(false);
+        }
 
         if (mTabsPanel.isShown())
             mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
 
-        mMainLayoutAnimator = new PropertyAnimator(450, sTabsInterpolator);
+        mMainLayoutAnimator = new PropertyAnimator(animationLength, sTabsInterpolator);
         mMainLayoutAnimator.setPropertyAnimationListener(this);
 
         boolean usingTextureView = mLayerView.shouldUseTextureView();
         mMainLayoutAnimator.setUseHardwareLayer(usingTextureView);
 
         if (hasTabsSideBar()) {
             mBrowserToolbar.prepareTabsAnimation(mMainLayoutAnimator, width);
 
@@ -1035,16 +1041,18 @@ abstract public class BrowserApp extends
             mBrowserToolbar.finishTabsAnimation();
             mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
         }
 
         mBrowserToolbar.refreshBackground();
 
         if (hasTabsSideBar())
             mBrowserToolbar.adjustTabsAnimation(true);
+
+        mMainLayoutAnimator = null;
     }
 
     /* Favicon methods */
     private void loadFavicon(final Tab tab) {
         maybeCancelFaviconLoad(tab);
 
         long id = Favicons.getInstance().loadFavicon(tab.getURL(), tab.getFaviconURL(), !tab.isPrivate(),
                         new Favicons.OnFaviconLoadedListener() {