Bug 853497 - Remove spacer view from gecko_app.xml (r=cwiiis)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 22 Mar 2013 10:26:26 +0000
changeset 125918 55f53541cd6cf2235e7a036496d251a88a7871f8
parent 125917 3550c269a5652b0b0081a9f9afbf8621fec30fc8
child 125919 649f6d85d61632d1b58f0b4392726bc5ec10b04e
push id25167
push userlrocha@mozilla.com
push dateFri, 22 Mar 2013 10:27:50 +0000
treeherdermozilla-inbound@649f6d85d616 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscwiiis
bugs853497
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 853497 - Remove spacer view from gecko_app.xml (r=cwiiis)
mobile/android/base/BrowserApp.java
mobile/android/base/resources/layout/gecko_app.xml
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -105,20 +105,16 @@ abstract public class BrowserApp extends
 
     // A drag has to move this amount multiplied by the height of the toolbar
     // before the toolbar will appear or disappear.
     private static final float TOOLBAR_MOVEMENT_THRESHOLD = 0.3f;
 
     // Whether the dynamic toolbar pref is enabled.
     private boolean mDynamicToolbarEnabled = false;
 
-    // The widget used to push the LayerView below the address bar when the
-    // toolbar is disabled.
-    private View mToolbarSpacer = null;
-
     // The last recorded touch event from onInterceptTouchEvent. These are
     // not updated until the movement threshold has been exceeded.
     private float mLastTouchX = 0.0f;
     private float mLastTouchY = 0.0f;
 
     // Because we can only scroll by integer amounts, we store the fractional
     // amounts to be applied here.
     private float mToolbarSubpixelAccumulation = 0.0f;
@@ -434,18 +430,16 @@ abstract public class BrowserApp extends
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         mAboutHomeStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_ABOUTHOME");
 
         super.onCreate(savedInstanceState);
 
-        mToolbarSpacer = findViewById(R.id.toolbar_spacer);
-
         LinearLayout actionBar = (LinearLayout) getActionBarLayout();
         mMainLayout.addView(actionBar, 2);
 
         ((GeckoApp.MainLayout) mMainLayout).setOnInterceptTouchListener(new HideTabsTouchListener());
 
         mBrowserToolbar = new BrowserToolbar(this);
         mBrowserToolbar.from(actionBar);
 
@@ -493,17 +487,17 @@ abstract public class BrowserApp extends
                     return;
                 }
                 mDynamicToolbarEnabled = value;
 
                 ThreadUtils.postToUiThread(new Runnable() {
                     @Override
                     public void run() {
                         if (mDynamicToolbarEnabled) {
-                            mToolbarSpacer.setPadding(0, 0, 0, 0);
+                            setToolbarMargin(0);
                         } else {
                             // Immediately show the toolbar when disabling the dynamic
                             // toolbar.
                             mAboutHomeContent.setPadding(0, 0, 0, 0);
                             mBrowserToolbar.cancelVisibilityAnimation();
                             mBrowserToolbar.getLayout().scrollTo(0, 0);
                         }
 
@@ -596,32 +590,42 @@ abstract public class BrowserApp extends
                 Tabs.getInstance().loadUrl(uri, flags);
             }
         }
 
         // Intercept key events for gamepad shortcuts
         mLayerView.setOnKeyListener(this);
     }
 
+    private void setSidebarMargin(int margin) {
+        ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).leftMargin = margin;
+        mGeckoLayout.requestLayout();
+    }
+
+    private void setToolbarMargin(int margin) {
+        ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).topMargin = margin;
+        mGeckoLayout.requestLayout();
+    }
+
     public void setToolbarHeight(int aHeight, int aVisibleHeight) {
         if (!mDynamicToolbarEnabled || Boolean.TRUE.equals(mAboutHomeShowing)) {
             // Use aVisibleHeight here so that when the dynamic toolbar is
             // enabled, the padding will animate with the toolbar becoming
             // visible.
             if (mDynamicToolbarEnabled) {
                 // When the dynamic toolbar is enabled, set the padding on the
                 // about:home widget directly - this is to avoid resizing the
                 // LayerView, which can cause visible artifacts.
                 mAboutHomeContent.setPadding(0, aVisibleHeight, 0, 0);
             } else {
-                mToolbarSpacer.setPadding(0, aVisibleHeight, 0, 0);
+                setToolbarMargin(aVisibleHeight);
             }
             aHeight = aVisibleHeight = 0;
         } else {
-            mToolbarSpacer.setPadding(0, 0, 0, 0);
+            setToolbarMargin(0);
         }
 
         // Update the Gecko-side global for fixed viewport margins.
         if (aHeight != mToolbarHeight) {
             mToolbarHeight = aHeight;
 
             // In the current UI, this is the only place we have need of
             // viewport margins (to stop the toolbar from obscuring fixed-pos
@@ -752,19 +756,17 @@ abstract public class BrowserApp extends
             if (isSideBar) {
                 width = lp.width;
                 mMainLayout.scrollTo(0, 0);
             } else {
                 width = 0;
             }
 
             mBrowserToolbar.adjustForTabsLayout(width);
-
-            ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(width, 0, 0, 0);
-            mGeckoLayout.requestLayout();
+            setSidebarMargin(width);
         }
 
         if (changed) {
             // Cancel state of previous sidebar state
             mBrowserToolbar.updateTabs(false);
 
             mTabsPanel.setIsSideBar(isSideBar);
             mBrowserToolbar.setIsSideBar(isSideBar);
@@ -982,19 +984,18 @@ abstract public class BrowserApp extends
         boolean usingTextureView = mLayerView.shouldUseTextureView();
         mMainLayoutAnimator.setUseHardwareLayer(usingTextureView);
 
         if (hasTabsSideBar()) {
             mBrowserToolbar.prepareTabsAnimation(mMainLayoutAnimator, width);
 
             // Set the gecko layout for sliding.
             if (!mTabsPanel.isShown()) {
-                ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(0, 0, 0, 0);
                 mGeckoLayout.scrollTo(mTabsPanel.getWidth() * -1, 0);
-                mGeckoLayout.requestLayout();
+                setSidebarMargin(0);
             }
 
             mMainLayoutAnimator.attach(mGeckoLayout,
                                        PropertyAnimator.Property.SCROLL_X,
                                        -width);
         } else {
             mMainLayoutAnimator.attach(mMainLayout,
                                        PropertyAnimator.Property.SCROLL_Y,
@@ -1031,17 +1032,17 @@ abstract public class BrowserApp extends
         // Destroy the hardware layer used during the animation
         if (Build.VERSION.SDK_INT >= 11)
             mTabsPanel.setLayerType(View.LAYER_TYPE_NONE, null);
         else
             mTabsPanel.setDrawingCacheEnabled(false);
 
         if (mTabsPanel.isShown()) {
             if (hasTabsSideBar()) {
-                ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(mTabsPanel.getWidth(), 0, 0, 0);
+                setSidebarMargin(mTabsPanel.getWidth());
                 mGeckoLayout.scrollTo(0, 0);
             }
 
             mGeckoLayout.requestLayout();
         } else {
             mTabsPanel.setVisibility(View.INVISIBLE);
             mBrowserToolbar.updateTabs(false);
             mBrowserToolbar.finishTabsAnimation();
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -14,20 +14,16 @@
                                  android:visibility="invisible"/>
 
    <view class="org.mozilla.gecko.GeckoApp$MainLayout"
          android:id="@+id/main_layout"
          style="@style/Screen.Transparent">
 
         <!-- BrowserToolbar will be added dynamically -->
 
-        <FrameLayout android:id="@+id/toolbar_spacer"
-                     android:layout_width="fill_parent"
-                     android:layout_height="wrap_content"/>
-
         <RelativeLayout android:id="@+id/gecko_layout"
                         android:layout_width="fill_parent"
                         android:layout_height="fill_parent"
                         android:layout_below="@+id/toolbar_spacer"
                         android:layout_above="@+id/find_in_page">
 
             <include layout="@layout/shared_ui_components"/>