Bug 1256147 - Post to UI thread for all showSoftInput calls; r=esawin
authorJim Chen <nchen@mozilla.com>
Mon, 25 Apr 2016 12:51:12 -0400
changeset 294792 9ee4cd959c9616c11054557c9cc81f6e63712235
parent 294791 3ef32a2ed627d81db3eceeab8edfc7722096862a
child 294793 7db5ba8edcfb376d838776505464ef0f58d37bd5
push id75678
push usernchen@mozilla.com
push dateMon, 25 Apr 2016 16:52:15 +0000
treeherdermozilla-inbound@7db5ba8edcfb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1256147
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 1256147 - Post to UI thread for all showSoftInput calls; r=esawin Make showSoftInput always post to the UI thread for consistency.
mobile/android/base/java/org/mozilla/gecko/GeckoInputConnection.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoInputConnection.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoInputConnection.java
@@ -229,36 +229,31 @@ class GeckoInputConnection
         if (view == null) {
             return null;
         }
         Context context = view.getContext();
         return InputMethods.getInputMethodManager(context);
     }
 
     private void showSoftInput() {
+        final View v = getView();
         final InputMethodManager imm = getInputMethodManager();
-        if (imm != null) {
-            final View v = getView();
+        if (v == null || imm == null) {
+            return;
+        }
 
-            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() {
+        v.post(new Runnable() {
             @Override
             public void run() {
-                v.clearFocus();
-                v.requestFocus();
-
+                if (v.hasFocus() && !imm.isActive(v)) {
+                    // Marshmallow workaround: The view has focus but it is not the active
+                    // view for the input method. (Bug 1211848)
+                    v.clearFocus();
+                    v.requestFocus();
+                }
                 imm.showSoftInput(v, 0);
             }
         });
     }
 
     private void hideSoftInput() {
         final InputMethodManager imm = getInputMethodManager();
         if (imm != null) {