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 6a0b1216e1a5297fcb5d05843a93068cb00cfe73
parent 296648 eae5e25b18b509d88a45d0f0fc2b86453a87450c
child 296650 e728e4f632e5a81b69f1675dca99c30df6b94b7b
push id5275
push usercbook@mozilla.com
push dateMon, 09 Nov 2015 10:21:04 +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");
                 }
             }