diff --git a/widget/gtk/IMContextWrapper.cpp b/widget/gtk/IMContextWrapper.cpp index aa2f6cddb26d7..e14c2b37c4436 100644 --- a/widget/gtk/IMContextWrapper.cpp +++ b/widget/gtk/IMContextWrapper.cpp @@ -1559,10 +1559,18 @@ IMContextWrapper::DispatchCompositionCommitEvent( RefPtr lastFocusedWindow(mLastFocusedWindow); + // Emulate selection until receiving actual selection range. + mSelection.CollapseTo( + mCompositionStart + + (aCommitString ? aCommitString->Length() : + mDispatchedCompositionString.Length()), + mSelection.mWritingMode); + mCompositionState = eCompositionState_NotComposing; mCompositionStart = UINT32_MAX; mCompositionTargetRange.Clear(); mDispatchedCompositionString.Truncate(); + mSelectedStringRemovedByComposition.Truncate(); nsEventStatus status; rv = dispatcher->CommitComposition(status, aCommitString); diff --git a/widget/gtk/IMContextWrapper.h b/widget/gtk/IMContextWrapper.h index c18ff9fdbf1b3..adcc02854d998 100644 --- a/widget/gtk/IMContextWrapper.h +++ b/widget/gtk/IMContextWrapper.h @@ -231,6 +231,13 @@ class IMContextWrapper final : public TextEventDispatcherListener mOffset = UINT32_MAX; mWritingMode = WritingMode(); } + void CollapseTo(uint32_t aOffset, + const WritingMode& aWritingMode) + { + mWritingMode = aWritingMode; + mOffset = aOffset; + mString.Truncate(); + } void Assign(const IMENotification& aIMENotification); void Assign(const WidgetQueryContentEvent& aSelectedTextEvent);