Bug 935628 - Animate toolbar with translation instead of scroll (r=sriram)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 22 Nov 2013 13:33:15 +0000
changeset 156951 e224bc414b8dd5e4d9b9381b17ba255cbebeeee8
parent 156950 a7d59b702986a7d3bae09bcf4ded68ecb765681c
child 156952 0f9ebc032d4d8f64adcebbd6b7d59889a56a978d
push id3611
push userlrocha@mozilla.com
push dateFri, 22 Nov 2013 13:33:40 +0000
treeherderfx-team@2bd9d2e52dc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs935628
milestone28.0a1
Bug 935628 - Animate toolbar with translation instead of scroll (r=sriram)
mobile/android/base/BrowserApp.java
mobile/android/base/toolbar/BrowserToolbar.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.animation.PropertyAnimator;
+import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.favicons.Favicons;
 import org.mozilla.gecko.favicons.OnFaviconLoadedListener;
 import org.mozilla.gecko.favicons.LoadFaviconTask;
 import org.mozilla.gecko.gfx.BitmapUtils;
 import org.mozilla.gecko.gfx.GeckoLayerClient;
 import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
@@ -662,17 +663,17 @@ abstract public class BrowserApp extends
         } else {
             // Immediately show the toolbar when disabling the dynamic
             // toolbar.
             if (mLayerView != null) {
                 mLayerView.getLayerClient().setOnMetricsChangedListener(null);
             }
             mHomePagerContainer.setPadding(0, 0, 0, 0);
             if (mBrowserToolbar != null) {
-                mBrowserToolbar.scrollTo(0, 0);
+                ViewHelper.setTranslationY(mBrowserToolbar, 0);
             }
         }
 
         refreshToolbarHeight();
     }
 
     private boolean isDynamicToolbarEnabled() {
         return mDynamicToolbarEnabled && !mAccessibilityEnabled;
@@ -923,17 +924,18 @@ abstract public class BrowserApp extends
         } else {
             mDynamicToolbarCanScroll = true;
         }
 
         final View toolbarLayout = mBrowserToolbar;
         final int marginTop = Math.round(aMetrics.marginTop);
         ThreadUtils.postToUiThread(new Runnable() {
             public void run() {
-                toolbarLayout.scrollTo(0, toolbarLayout.getHeight() - marginTop);
+                ViewHelper.setTranslationY(toolbarLayout, marginTop - toolbarLayout.getHeight());
+
                 if (mDoorHangerPopup.isShowing()) {
                     mDoorHangerPopup.updatePopup();
                 }
             }
         });
 
         if (mFormAssistPopup != null)
             mFormAssistPopup.onMetricsChanged(aMetrics);
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -643,17 +643,17 @@ public class BrowserToolbar extends Geck
 
         return false;
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         // If the motion event has occured below the toolbar (due to the scroll
         // offset), let it pass through to the page.
-        if (event != null && event.getY() > getHeight() - getScrollY()) {
+        if (event != null && event.getY() > getHeight() + ViewHelper.getTranslationY(this)) {
             return false;
         }
 
         return super.onTouchEvent(event);
     }
 
     @Override
     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
@@ -819,17 +819,17 @@ public class BrowserToolbar extends Geck
 
     @Override
     public void onTextChanged(CharSequence s, int start, int before,
                               int count) {
         // do nothing
     }
 
     public boolean isVisible() {
-        return getScrollY() == 0;
+        return ViewHelper.getTranslationY(this) == 0;
     }
 
     public void setNextFocusDownId(int nextId) {
         super.setNextFocusDownId(nextId);
         mTabs.setNextFocusDownId(nextId);
         mBack.setNextFocusDownId(nextId);
         mForward.setNextFocusDownId(nextId);
         mFavicon.setNextFocusDownId(nextId);