Bug 1199658 - Don't commit Java composition when Gecko side commits its composition; r=esawin
authorJim Chen <nchen@mozilla.com>
Tue, 27 Oct 2015 14:22:05 -0400
changeset 305026 90ca2ac0a32f5df01d6e3e07b93f6f2c46d39328
parent 305025 71bd7be01147f01a5072f929475d26babd556469
child 305027 0395c8b2846bba2e3115403e7eb26e046efee259
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1199658
milestone44.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 1199658 - Don't commit Java composition when Gecko side commits its composition; r=esawin 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
@@ -849,44 +849,24 @@ final class GeckoEditable extends JNIObj
             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");
                 }
             }