Bug 1215950 - GeckoInputConnection: Run re-focus workaround on the UI thread. r=jchen, a=sylvestre
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 22 Oct 2015 20:14:40 +0200
changeset 291290 233ab8d5b962
parent 291289 f25c880e125d
child 291291 8bd8a35e4434
push id934
push userraliiev@mozilla.com
push date2015-10-26 12:58 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, sylvestre
bugs1215950
milestone42.0
Bug 1215950 - GeckoInputConnection: Run re-focus workaround on the UI thread. r=jchen, a=sylvestre
mobile/android/base/GeckoInputConnection.java
--- a/mobile/android/base/GeckoInputConnection.java
+++ b/mobile/android/base/GeckoInputConnection.java
@@ -367,22 +367,33 @@ class GeckoInputConnection
 
     private static void showSoftInput() {
         final InputMethodManager imm = getInputMethodManager();
         if (imm != null) {
             final View v = getView();
 
             if (v.hasFocus() && !imm.isActive(v)) {
                 // Workaround: The view has focus but it is not the active view for the input method. (Bug 1211848)
+                refocusAndShowSoftInput(imm, v);
+            } else {
+                imm.showSoftInput(v, 0);
+            }
+        }
+    }
+
+    private static void refocusAndShowSoftInput(final InputMethodManager imm, final View v) {
+        ThreadUtils.postToUiThread(new Runnable() {
+            @Override
+            public void run() {
                 v.clearFocus();
                 v.requestFocus();
+
+                imm.showSoftInput(v, 0);
             }
-
-            imm.showSoftInput(v, 0);
-        }
+        });
     }
 
     private static void hideSoftInput() {
         final InputMethodManager imm = getInputMethodManager();
         if (imm != null) {
             final View v = getView();
             imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
         }