Bug 1508252 - Set temporary range when replacement range is available. r=masayuki, a=RyanVM
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 10 Dec 2018 03:17:15 +0000
changeset 509083 49a93d8ec9f9a1e9d4b3322bfbb77d86be5d71a8
parent 509082 37e58b34932fe6e1d5246412c94e31af2c3a41e6
child 509084 34be2a107bd4c664f179518ef9f11036cd00418f
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, RyanVM
bugs1508252
milestone65.0
Bug 1508252 - Set temporary range when replacement range is available. r=masayuki, a=RyanVM This issue is e10s only. Even if calling SetSelection, it doesn't reset selection cache in TextInputHandler. Since selection cache is updated by OnSelectionChange asynchronous, we should set temporary range when having replacement range. Also, even if marking dirty doesn't fix this issue. Content cache may return other range such as caret position instead of replacement range by SetSelection. Differential Revision: https://phabricator.services.mozilla.com/D14002
widget/cocoa/TextInputHandler.mm
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -4060,17 +4060,22 @@ IMEInputHandler::SetMarkedText(NSAttribu
 
   mMarkedRange.length = str.Length();
 
   if (!IsIMEComposing() && !str.IsEmpty()) {
     // If there is no selection and replacement range is specified, set the
     // range as selection.
     if (aReplacementRange && aReplacementRange->location != NSNotFound &&
         !NSEqualRanges(SelectedRange(), *aReplacementRange)) {
-      NS_ENSURE_TRUE_VOID(SetSelection(*aReplacementRange));
+      // Set temporary selection range since OnSelectionChange is async.
+      mSelectedRange = *aReplacementRange;
+      if (NS_WARN_IF(!SetSelection(*aReplacementRange))) {
+        mSelectedRange.location = NSNotFound; // Marking dirty
+        return;
+      }
     }
 
     mMarkedRange.location = SelectedRange().location;
 
     if (!DispatchCompositionStartEvent()) {
       MOZ_LOG(gLog, LogLevel::Info,
         ("%p IMEInputHandler::SetMarkedText, cannot continue handling "
          "composition after dispatching compositionstart", this));