Bug 1184890 part.3 TSFTextStore shouldn't commit composition when a selection change notification occurred before starting current composition r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 27 Oct 2015 07:21:37 +0900
changeset 304806 92d383d8d282e9fb35302836f9e44717c2d1d4cc
parent 304805 e23949bd2c042aa175f029112a26114c2ea6b558
child 304807 23f0dcfdcce1de9293704d6e59a679eed76eeede
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1184890
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1184890 part.3 TSFTextStore shouldn't commit composition when a selection change notification occurred before starting current composition r=m_kato
widget/windows/TSFTextStore.cpp
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -4650,16 +4650,35 @@ TSFTextStore::OnSelectionChangeInternal(
           GetBoolName(selectionChangeData.mCausedBySelectionEvent),
           GetBoolName(selectionChangeData.mOccurredDuringComposition),
           mSink.get(), GetSinkMaskNameStr(mSinkMask).get(),
           GetBoolName(mIsRecordingActionsWithoutLock),
           GetBoolName(mComposition.IsComposing())));
 
   mDeferNotifyingTSF = false;
 
+  // A compositionstart event handler can change selection before actually
+  // starting composition in the editor. This causes very complicated issue
+  // because TSF requests to lock the document but we allow to change the
+  // selection for web apps for keeping compatibility.
+  // For now, we should not send selection change notification until the
+  // active composition ends.  However, this causes TSF stores wrong selection
+  // offset.  That might cause TSF stopping working.  So, at next change,
+  // we should cache content *until* composition end.  Then, we will solve
+  // this issue.
+  if (mComposition.IsComposing() &&
+      !selectionChangeData.mOccurredDuringComposition) {
+    MOZ_LOG(sTextStoreLog, LogLevel::Warning,
+           ("TSF: 0x%p   TSFTextStore::OnSelectionChangeInternal(), WARNING, "
+            "ignoring selection change notification which occurred before "
+            "composition start.", this));
+    return NS_OK;
+  }
+
+
   if (IsReadLocked()) {
     // XXX Why don't we mark mPendingOnSelectionChange as true here?
     return NS_OK;
   }
 
   mSelection.SetSelection(
     selectionChangeData.mOffset,
     selectionChangeData.Length(),