Bug 1510527 - Active composition count may be mismatched when updating composition. r=esawin

To avoid FlushIMEChanges per updating IME composition, we calculate composition count in DoReplaceText. But when using GV+e10s, this calculation is sometimes invalid since NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED event isn't received per PendingComposition.  Because, IMEStateManager will merge this completed events due to optimization of IME event.

Also, DoUpdateComposition calls SetPendingComposition, but it doesn't touch mIMEActiveCompositionCount,

So when using some IME, this value is minus or forever non-zero on some IMEs.

So we shouldn't use atomic count. When receiving NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED, we should reset it and allow IMEFlushChanges since Gecko has already handled all IME composition events in event queues.

Differential Revision: https://phabricator.services.mozilla.com/D14668

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Makoto Kato 2018-12-18 16:22:21 +00:00
Родитель 23994168d5
Коммит 9235079616
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -1051,6 +1051,9 @@ void GeckoEditableSupport::OnImeReplaceText(int32_t aStart, int32_t aEnd,
bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd,
jni::String::Param aText) {
ALOGIME("IME: IME_REPLACE_TEXT: text=\"%s\"",
NS_ConvertUTF16toUTF8(aText->ToString()).get());
// Return true if processed and we should reply to the OnImeReplaceText
// event later. Return false if _not_ processed and we should reply to the
// OnImeReplaceText event now.
@ -1297,6 +1300,7 @@ bool GeckoEditableSupport::DoUpdateComposition(int32_t aStart, int32_t aEnd,
}
mDispatcher->SetPendingComposition(string, mIMERanges);
mDispatcher->FlushPendingComposition(status);
mIMEActiveCompositionCount++;
mIMERanges->Clear();
return true;
}
@ -1434,11 +1438,11 @@ nsresult GeckoEditableSupport::NotifyIME(
case NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED: {
ALOGIME("IME: NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED");
// We often only get one event-handled notification after a pair of
// update-composition then replace-text calls. Therefore, only count
// the number of composition events for replace-text calls to reduce
// the chance of mismatch.
if (!(--mIMEActiveCompositionCount) && mIMEDelaySynchronizeReply) {
// NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED isn't sent per IME call.
// Receiving this event means that Gecko has already handled all IME
// composing events in queue.
mIMEActiveCompositionCount = 0;
if (mIMEDelaySynchronizeReply) {
FlushIMEChanges();
}