Bug 1158309 - Initialize LayerView sooner; r=snorp
authorJim Chen <nchen@mozilla.com>
Thu, 30 Apr 2015 13:01:01 -0400
changeset 273212 7552ffb7bd0c8e2872ce65e5519de89747b50c41
parent 273211 08958b9a714ec96660fbf7033807ccb1cc8865be
child 273213 20f5e306d6b639c7629dcceb60424ae615169115
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1158309
milestone40.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 1158309 - Initialize LayerView sooner; r=snorp
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoView.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1270,16 +1270,17 @@ public abstract class GeckoApp
         GeckoScreenOrientation.getInstance().update(getResources().getConfiguration().orientation);
 
         setContentView(getLayout());
 
         // Set up Gecko layout.
         mRootLayout = (OuterLayout) findViewById(R.id.root_layout);
         mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
         mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
+        mLayerView = (LayerView) findViewById(R.id.layer_view);
 
         // Determine whether we should restore tabs.
         mShouldRestore = getSessionRestoreState(savedInstanceState);
         if (mShouldRestore && savedInstanceState != null) {
             boolean wasInBackground =
                 savedInstanceState.getBoolean(SAVED_STATE_IN_BACKGROUND, false);
 
             // Don't log OOM-kills if only one activity was destroyed. (For example
@@ -1409,23 +1410,22 @@ public abstract class GeckoApp
         if (mCameraView == null) {
             // Pre-ICS devices need the camera surface in a visible layout.
             if (Versions.preICS) {
                 mCameraView = new SurfaceView(this);
                 ((SurfaceView)mCameraView).getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
             }
         }
 
-        if (mLayerView == null) {
-            LayerView layerView = (LayerView) findViewById(R.id.layer_view);
-            layerView.initializeView(EventDispatcher.getInstance());
-            mLayerView = layerView;
-            GeckoAppShell.sendEventToGecko(GeckoEvent.createObjectEvent(
-                GeckoEvent.ACTION_OBJECT_LAYER_CLIENT, layerView.getLayerClientObject()));
-        }
+        // XXX our editor tests require the GeckoView to have focus to pass, so we have to
+        // manually shift focus to the GeckoView. requestFocus apparently doesn't work at
+        // this stage of starting up, so we have to unset and reset the focusability.
+        mLayerView.setFocusable(false);
+        mLayerView.setFocusable(true);
+        mLayerView.setFocusableInTouchMode(true);
     }
 
     /**
      * Loads the initial tab at Fennec startup.
      *
      * If Fennec was opened with an external URL, that URL will be loaded.
      * Otherwise, unless there was a session restore, the default URL
      * (about:home) be loaded.
--- a/mobile/android/base/GeckoView.java
+++ b/mobile/android/base/GeckoView.java
@@ -117,16 +117,20 @@ public class GeckoView extends LayerView
         a.recycle();
         init(context, url, doInit);
     }
 
     private void init(Context context, String url, boolean doInit) {
         // Perform common initialization for Fennec/GeckoView.
         GeckoAppShell.setLayerView(this);
 
+        initializeView(EventDispatcher.getInstance());
+        GeckoAppShell.sendEventToGecko(GeckoEvent.createObjectEvent(
+                GeckoEvent.ACTION_OBJECT_LAYER_CLIENT, getLayerClientObject()));
+
         // TODO: Fennec currently takes care of its own initialization, so this
         // flag is a hack used in Fennec to prevent GeckoView initialization.
         // This should go away once Fennec also uses GeckoView for
         // initialization.
         if (!doInit)
             return;
 
         // If running outside of a GeckoActivity (eg, from a library project),
@@ -176,23 +180,19 @@ public class GeckoView extends LayerView
             "Link:Favicon",
             "Prompt:Show",
             "Prompt:ShowTop");
 
         EventDispatcher.getInstance().registerGeckoThreadListener(mNativeEventListener,
             "Accessibility:Ready",
             "GeckoView:Message");
 
-        initializeView(EventDispatcher.getInstance());
-
         if (GeckoThread.launch()) {
             // This is the first launch, so finish initialization and go.
             GeckoProfile profile = GeckoProfile.get(context).forceCreate();
-            GeckoAppShell.sendEventToGecko(GeckoEvent.createObjectEvent(
-                GeckoEvent.ACTION_OBJECT_LAYER_CLIENT, getLayerClientObject()));
 
         } else if (GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
             // If Gecko is already running, that means the Activity was
             // destroyed, so we need to re-attach Gecko to this GeckoView.
             connectToGecko();
         }
     }