Bug 1072529 - Only create GeckoEditable once. r=esawin, a=sledru
authorJim Chen <nchen@mozilla.com>
Wed, 15 Apr 2015 15:21:32 -0400
changeset 258520 69e54b268783
parent 258519 55837b9aa111
child 258521 fff936b47a9f
push id4686
push userryanvm@gmail.com
push date2015-04-17 16:50 +0000
treeherdermozilla-beta@6a5c3aa5b912 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, sledru
bugs1072529
milestone38.0
Bug 1072529 - Only create GeckoEditable once. r=esawin, a=sledru
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1404,19 +1404,16 @@ public abstract class GeckoApp
         }
 
         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()));
-
-            // bind the GeckoEditable instance to the new LayerView
-            GeckoAppShell.notifyIMEContext(GeckoEditableListener.IME_STATE_DISABLED, "", "", "");
         }
     }
 
     /**
      * 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
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -311,18 +311,27 @@ public class GeckoAppShell
 
     private static LayerView sLayerView;
 
     public static void setLayerView(LayerView lv) {
         if (sLayerView == lv) {
             return;
         }
         sLayerView = lv;
-        // Install new Gecko-to-Java editable listener.
-        editableListener = new GeckoEditable();
+
+        // We should have a unique GeckoEditable instance per nsWindow instance,
+        // so even though we have a new view here, the underlying nsWindow is the same,
+        // and we don't create a new GeckoEditable.
+        if (editableListener == null) {
+            // Starting up; istall new Gecko-to-Java editable listener.
+            editableListener = new GeckoEditable();
+        } else {
+            // Bind the existing GeckoEditable instance to the new LayerView
+            GeckoAppShell.notifyIMEContext(GeckoEditableListener.IME_STATE_DISABLED, "", "", "");
+        }
     }
 
     @RobocopTarget
     public static LayerView getLayerView() {
         return sLayerView;
     }
 
     public static void runGecko(String apkPath, String args, String url, String type) {