Bug 1258464 - Part 1: Remove vestigial GeckoView attrs and initialization. r=snorp
authorNick Alexander <nalexander@mozilla.com>
Wed, 30 Mar 2016 10:21:29 -0700
changeset 291284 d8cc2430bf0b6e6c10aa3c5e264af8ce3721ae4e
parent 291283 6bc6f4e79300e05c8c3288411fb54c50bd24fb6d
child 291285 4b8075ea02463c44f5d6c08584ac81c5dc0d62fd
push id74545
push userkwierso@gmail.com
push dateFri, 01 Apr 2016 23:05:42 +0000
treeherdermozilla-inbound@c410d4e20586 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1258464
milestone48.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 1258464 - Part 1: Remove vestigial GeckoView attrs and initialization. r=snorp These have no consumer and deserve to be properly reworked. MozReview-Commit-ID: KmjE44nmLXx
mobile/android/base/java/org/mozilla/gecko/GeckoView.java
mobile/android/base/resources/layout/gecko_app.xml
mobile/android/base/resources/values/attrs.xml
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoView.java
@@ -11,31 +11,26 @@ import java.util.List;
 import java.util.Set;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.annotation.ReflectionTarget;
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.gfx.GLController;
 import org.mozilla.gecko.gfx.LayerView;
-import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.mozglue.JNIObject;
-import org.mozilla.gecko.util.Clipboard;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoEventListener;
-import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.NativeEventListener;
 import org.mozilla.gecko.util.NativeJSObject;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.app.Activity;
 import android.content.Context;
-import android.content.Intent;
 import android.content.SharedPreferences;
-import android.content.res.TypedArray;
 import android.os.Binder;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
@@ -175,103 +170,40 @@ public class GeckoView extends LayerView
             };
     }
 
     private Window window;
     private boolean stateSaved;
 
     public GeckoView(Context context) {
         super(context);
-        init(context, null, true);
+        init(context);
     }
 
     public GeckoView(Context context, AttributeSet attrs) {
         super(context, attrs);
-        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GeckoView);
-        String url = a.getString(R.styleable.GeckoView_url);
-        boolean doInit = a.getBoolean(R.styleable.GeckoView_doinit, true);
-        a.recycle();
-        init(context, url, doInit);
+        init(context);
     }
 
-    private void init(Context context, String url, boolean doInit) {
-
+    private void init(Context context) {
         if (GeckoAppShell.getApplicationContext() == null) {
             GeckoAppShell.setApplicationContext(context.getApplicationContext());
         }
 
         // Set the GeckoInterface if the context is an activity and the GeckoInterface
         // has not already been set
         if (context instanceof Activity && getGeckoInterface() == null) {
             setGeckoInterface(new BaseGeckoInterface(context));
             GeckoAppShell.setContextGetter(this);
         }
 
         // Perform common initialization for Fennec/GeckoView.
         GeckoAppShell.setLayerView(this);
 
         initializeView(EventDispatcher.getInstance());
-
-        // 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),
-        // load the native code and disable content providers
-        boolean isGeckoActivity = false;
-        try {
-            isGeckoActivity = context instanceof GeckoActivity;
-        } catch (NoClassDefFoundError ex) {}
-
-        if (!isGeckoActivity) {
-            Clipboard.init(context);
-            HardwareUtils.init(context);
-
-            // If you want to use GeckoNetworkManager, start it.
-
-            final GeckoProfile profile = GeckoProfile.get(context);
-         }
-
-        GeckoThread.ensureInit(null, null);
-        if (url != null) {
-            GeckoAppShell.sendEventToGecko(GeckoEvent.createURILoadEvent(url));
-        }
-
-        if (context instanceof Activity) {
-            Tabs tabs = Tabs.getInstance();
-            tabs.attachToContext(context);
-        }
-
-        EventDispatcher.getInstance().registerGeckoThreadListener(mGeckoEventListener,
-            "Gecko:Ready",
-            "Accessibility:Event",
-            "Content:StateChange",
-            "Content:LoadError",
-            "Content:PageShow",
-            "DOMTitleChanged",
-            "Link:Favicon",
-            "Prompt:Show",
-            "Prompt:ShowTop");
-
-        EventDispatcher.getInstance().registerGeckoThreadListener(mNativeEventListener,
-            "Accessibility:Ready",
-            "GeckoView:Message");
-
-        if (GeckoThread.launch()) {
-            // This is the first launch, so finish initialization and go.
-            GeckoProfile profile = GeckoProfile.get(context).forceCreate();
-
-        } else if (GeckoThread.isRunning()) {
-            // If Gecko is already running, that means the Activity was
-            // destroyed, so we need to re-attach Gecko to this GeckoView.
-            connectToGecko();
-        }
     }
 
     @Override
     protected Parcelable onSaveInstanceState()
     {
         final Parcelable superState = super.onSaveInstanceState();
         stateSaved = true;
         return new StateBinder(superState, this.window);
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -22,17 +22,16 @@
 
         <RelativeLayout android:id="@+id/gecko_layout"
                         android:layout_width="match_parent"
                         android:layout_height="match_parent"
                         android:layout_below="@+id/tablet_tab_strip"
                         android:layout_above="@+id/find_in_page">
 
             <org.mozilla.gecko.GeckoView android:id="@+id/layer_view"
-                                         gecko:doinit="false"
                                          android:layout_width="match_parent"
                                          android:layout_height="match_parent"
                                          android:scrollbars="none"/>
 
             <AbsoluteLayout android:id="@+id/plugin_container"
                             android:background="@android:color/transparent"
                             android:layout_width="match_parent"
                             android:layout_height="match_parent"/>
--- a/mobile/android/base/resources/values/attrs.xml
+++ b/mobile/android/base/resources/values/attrs.xml
@@ -135,21 +135,16 @@
              background is full alpha and we need to copy the background underneath. -->
         <attr name="fadeBackgroundColor" format="dimension"/>
     </declare-styleable>
 
     <declare-styleable name="BookmarkFolderView">
         <attr name="state_open" format="boolean"/>
     </declare-styleable>
 
-    <declare-styleable name="GeckoView">
-        <attr name="url" format="string"/>
-        <attr name="doinit" format="boolean"/>
-    </declare-styleable>
-
     <declare-styleable name="IconTabWidget">
         <attr name="android:layout"/>
 
         <!-- Sets the tab's content type. Defaults to icon. -->
         <attr name="display">
             <enum name="icon" value="0x00" />
             <enum name="text" value="0x01" />
         </attr>