Bug 1107636 - Replace top-level RelativeLayout with <merge>. r=sebastian
Using systrace, I took 2 traces before and after. Using the slowest
of both traces, the first three measure passes had the following
improvements in CPU time:
1) 20.583ms -> 13.149ms
2) 1.695ms -> 0.827ms (1/2)
3) 22.146ms -> 11.602ms (1/2)
This is to be expected – RelativeLayout requires two measure passes
so it makes sense to approximately half the measure times.
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -165,17 +165,17 @@ public abstract class GeckoApp
public static final String SAVED_STATE_IN_BACKGROUND = "inBackground";
public static final String SAVED_STATE_PRIVATE_SESSION = "privateSession";
// Delay before running one-time "cleanup" tasks that may be needed
// after a version upgrade.
private static final int CLEANUP_DEFERRAL_SECONDS = 15;
- protected RelativeLayout mRootLayout;
+ protected View mRootLayout;
protected RelativeLayout mMainLayout;
protected RelativeLayout mGeckoLayout;
private View mCameraView;
private OrientationEventListener mCameraOrientationEventListener;
public List<GeckoAppShell.AppStateListener> mAppStateListeners = new LinkedList<GeckoAppShell.AppStateListener>();
protected MenuPanel mMenuPanel;
protected Menu mMenu;
@@ -1380,17 +1380,17 @@ public abstract class GeckoApp
super.onCreate(savedInstanceState);
GeckoScreenOrientation.getInstance().update(getResources().getConfiguration().orientation);
setContentView(getLayout());
// Set up Gecko layout.
- mRootLayout = (RelativeLayout) findViewById(R.id.root_layout);
+ mRootLayout = findViewById(android.R.id.content);
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
mLayerView = (LayerView) findViewById(R.id.layer_view);
// Use global layout state change to kick off additional initialization
mMainLayout.getViewTreeObserver().addOnGlobalLayoutListener(this);
// Determine whether we should restore tabs.
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/root_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ViewStub android:id="@+id/tabs_panel"
android:layout="@layout/tabs_panel_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<view class="org.mozilla.gecko.GeckoApp$MainLayout"
android:id="@+id/main_layout"
@@ -145,9 +142,9 @@
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:visibility="gone" />
<ViewStub android:id="@+id/toast_stub"
android:layout="@layout/button_toast"
style="@style/Toast"/>
-</RelativeLayout>
+</merge>
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -633,18 +633,16 @@
<item name="@android:windowEnterAnimation">@anim/popup_show</item>
<item name="@android:windowExitAnimation">@anim/popup_hide</item>
</style>
<style name="ToastBase">
<item name="android:background">@drawable/toast_background</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:layout_alignParentBottom">true</item>
- <item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_gravity">bottom|center_horizontal</item>
<item name="android:layout_marginBottom">64dp</item>
<item name="android:layout_marginTop">0dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:clickable">true</item>
</style>
<style name="Toast" parent="ToastBase">