Bug 1072529 - Only create GeckoEditable once. r=esawin, a=sledru
authorJim Chen <nchen@mozilla.com>
Wed, 15 Apr 2015 15:21:32 -0400
changeset 265651 ae4189b7a0429ac40575c87c1f8367f40d2a450c
parent 265650 fb10a430555d03019ce9dd9c203183e9f18080d0
child 265652 12506f523a2855ce52b44edcebe5f6f27f6a69ec
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, sledru
bugs1072529
milestone39.0a2
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) {