Bug 1199658 - Don't commit Java composition when Gecko side commits its composition; r=esawin, a=lizzard
authorJim Chen <nchen@mozilla.com>
Tue, 27 Oct 2015 14:22:05 -0400
changeset 296649 6a0b1216e1a5
parent 296648 eae5e25b18b5
child 296650 e728e4f632e5
push id5275
push usercbook@mozilla.com
push date2015-11-09 10:21 +0000
treeherdermozilla-beta@a54630b3ac76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, lizzard
bugs1199658
milestone43.0
Bug 1199658 - Don't commit Java composition when Gecko side commits its composition; r=esawin, a=lizzard Right now, when the Gecko side commits its composition, we notify the Java side and the Java side commits its composition as well. However, some keyboards have trouble dealing with us manually committing the composition. To better support these keyboards, this patch makes it so that even if the Gecko composition is committed, the Java composition is still kept. Because the Gecko composition on Android is used only for display purposes, it doesn't matter too much when the Gecko composition is out-of-sync with the Java composition.
mobile/android/base/GeckoEditable.java
--- a/mobile/android/base/GeckoEditable.java
+++ b/mobile/android/base/GeckoEditable.java
@@ -725,44 +725,24 @@ final class GeckoEditable
             break;
         }
         if (action.mShouldUpdate) {
             geckoUpdateGecko(false);
         }
     }
 
     private void notifyCommitComposition() {
-        // Gecko already committed its composition, and
-        // we should remove the composition on our side as well.
-        boolean wasComposing = false;
-        final Object[] spans = mText.getSpans(0, mText.length(), Object.class);
-
-        for (Object span : spans) {
-            if ((mText.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) {
-                mText.removeSpan(span);
-                wasComposing = true;
-            }
-        }
-
-        if (!wasComposing) {
-            return;
-        }
-
-        // Generate a text change notification if we actually cleared the composition.
-        final CharSequence text = TextUtils.stringOrSpannedString(mText);
-        geckoPostToIc(new Runnable() {
-            @Override
-            public void run() {
-                mListener.onTextChange(text, 0, text.length(), text.length());
-            }
-        });
+        // Gecko already committed its composition. However, Android keyboards
+        // have trouble dealing with us removing the composition manually on
+        // the Java side. Therefore, we keep the composition intact on the Java
+        // side. The text content should still be in-sync on both sides.
     }
 
     private void notifyCancelComposition() {
-        // Composition should have been cancelled on our side
+        // Composition should have been canceled on our side
         // through text update notifications; verify that here.
         if (DEBUG) {
             final Object[] spans = mText.getSpans(0, mText.length(), Object.class);
             for (Object span : spans) {
                 if ((mText.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) {
                     throw new IllegalStateException("composition not cancelled");
                 }
             }