From a7fe94d7d54f5c0d6b84e3f3e077406c092a9ad3 Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Tue, 27 Oct 2015 14:22:05 -0400 Subject: [PATCH] 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 | 30 +++++--------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/mobile/android/base/GeckoEditable.java b/mobile/android/base/GeckoEditable.java index c9ca9b68dc2..fecff502a3c 100644 --- a/mobile/android/base/GeckoEditable.java +++ b/mobile/android/base/GeckoEditable.java @@ -854,34 +854,14 @@ final class GeckoEditable extends JNIObject } 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);