Bug 831862 - Force restart input during notifyIMEEnabled; r=cpeterson a=bbajaj
authorJim Chen <nchen@mozilla.com>
Fri, 18 Jan 2013 15:49:19 -0500
changeset 127337 26337130270a36239cc47d8468e1119a0d632434
parent 127336 45b35a3a46c7906992a00cb9c6e0b7fe426247ea
child 127338 7b8f0863a84464791b6ce04a7530162c9881ff8a
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson, bbajaj
bugs831862
milestone20.0a2
Bug 831862 - Force restart input during notifyIMEEnabled; r=cpeterson a=bbajaj
mobile/android/base/GeckoInputConnection.java
--- a/mobile/android/base/GeckoInputConnection.java
+++ b/mobile/android/base/GeckoInputConnection.java
@@ -196,24 +196,28 @@ class GeckoInputConnection
     private static void hideSoftInput() {
         final InputMethodManager imm = getInputMethodManager();
         if (imm != null) {
             final View v = getView();
             imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
         }
     }
 
-    private void restartInput() {
+    private void tryRestartInput() {
         // Coalesce restartInput calls because InputMethodManager.restartInput()
         // is expensive and successive calls to it can lock up the keyboard
-        long time = SystemClock.uptimeMillis();
-        if (time < mLastRestartInputTime + 200) {
+        if (SystemClock.uptimeMillis() < mLastRestartInputTime + 200) {
             return;
         }
-        mLastRestartInputTime = time;
+        restartInput();
+    }
+
+    private void restartInput() {
+
+        mLastRestartInputTime = SystemClock.uptimeMillis();
 
         final InputMethodManager imm = getInputMethodManager();
         if (imm == null) {
             return;
         }
         final View v = getView();
         // InputMethodManager has internal logic to detect if we are restarting input
         // in an already focused View, which is the case here because all content text
@@ -511,17 +515,17 @@ class GeckoInputConnection
             case NOTIFY_IME_CANCELCOMPOSITION:
                 // Set composition to empty and end composition
                 setComposingText("", 0);
                 // Fall through
 
             case NOTIFY_IME_RESETINPUTSTATE:
                 // Commit and end composition
                 finishComposingText();
-                restartInput();
+                tryRestartInput();
                 break;
 
             case NOTIFY_IME_FOCUSCHANGE:
                 // Showing/hiding vkb is done in notifyIMEEnabled
                 resetState();
                 break;
 
             default: