diff --git a/widget/android/GeckoEditableSupport.cpp b/widget/android/GeckoEditableSupport.cpp index 46bf17beed6f..25432e41e4f6 100644 --- a/widget/android/GeckoEditableSupport.cpp +++ b/widget/android/GeckoEditableSupport.cpp @@ -1071,6 +1071,7 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, const bool composing = !mIMERanges->IsEmpty(); nsEventStatus status = nsEventStatus_eIgnore; bool textChanged = composing; + bool performDeletion = true; if (!mIMEKeyEvents.IsEmpty() || !composition || !mDispatcher->IsComposing() || uint32_t(aStart) != composition->NativeOffsetOfStartComposition() || @@ -1119,13 +1120,7 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, if (aStart != aEnd) { // Perform a deletion first. - WidgetContentCommandEvent event(true, eContentCommandDelete, widget); - event.mTime = PR_Now() / 1000; - widget->DispatchEvent(&event, status); - if (!mDispatcher || widget->Destroyed()) { - return false; - } - textChanged = true; + performDeletion = true; } } else if (composition->String().Equals(string)) { /* If the new text is the same as the existing composition text, @@ -1150,6 +1145,16 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, } } + if (performDeletion) { + WidgetContentCommandEvent event(true, eContentCommandDelete, widget); + event.mTime = PR_Now() / 1000; + widget->DispatchEvent(&event, status); + if (!mDispatcher || widget->Destroyed()) { + return false; + } + textChanged = true; + } + if (composing) { mDispatcher->SetPendingComposition(string, mIMERanges); mDispatcher->FlushPendingComposition(status);