Bug 1242331 part.3 Rename TextChangeDataBase::mOccurredDuringComposition to mIncludingChangesDuringComposition r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 28 Jan 2016 13:28:53 +0900
changeset 282078 3442a539cc8b8f2a7ab504f1e3fad11541579652
parent 282077 66b71325dfbf5cf32f2eb20a724d0dfcd805ccd0
child 282079 04d8a95c6a5e19ca4debf62a052e8011cf6af478
push id17275
push usercbook@mozilla.com
push dateThu, 28 Jan 2016 11:37:27 +0000
treeherderfx-team@e2d11e2d506c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1242331
milestone47.0a1
Bug 1242331 part.3 Rename TextChangeDataBase::mOccurredDuringComposition to mIncludingChangesDuringComposition r=smaug
dom/events/IMEContentObserver.cpp
widget/IMEData.h
widget/nsBaseWidget.cpp
widget/nsGUIEventIPC.h
widget/windows/TSFTextStore.cpp
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -129,19 +129,22 @@ public:
   explicit TextChangeDataToString(
              const IMENotification::TextChangeDataBase& aData)
   {
     if (!aData.IsValid()) {
       AppendLiteral("{ IsValid()=false }");
       return;
     }
     AppendPrintf("{ mStartOffset=%u, mRemovedEndOffset=%u, mAddedEndOffset=%u, "
-                 "mCausedOnlyByComposition=%s }", aData.mStartOffset,
-                 aData.mRemovedEndOffset, aData.mAddedEndOffset,
-                 ToChar(aData.mCausedOnlyByComposition));
+                 "mCausedOnlyByComposition=%s, "
+                 "mIncludingChangesDuringComposition=%s }",
+                 aData.mStartOffset, aData.mRemovedEndOffset,
+                 aData.mAddedEndOffset,
+                 ToChar(aData.mCausedOnlyByComposition),
+                 ToChar(aData.mIncludingChangesDuringComposition));
   }
   virtual ~TextChangeDataToString() {}
 };
 
 /******************************************************************************
  * mozilla::IMEContentObserver
  ******************************************************************************/
 
--- a/widget/IMEData.h
+++ b/widget/IMEData.h
@@ -726,17 +726,21 @@ struct IMENotification final
     uint32_t mAddedEndOffset;
 
     // Note that TextChangeDataBase may be the result of merging two or more
     // changes especially in e10s mode.
 
     // mCausedOnlyByComposition is true only when *all* merged changes are
     // caused by composition.
     bool mCausedOnlyByComposition;
-    bool mOccurredDuringComposition;
+    // mIncludingChangesDuringComposition is true if at least one change which
+    // is not caused by composition occurred during the last composition.
+    // Note that if after the last composition is finished and there are some
+    // changes not caused by composition, this is set to false.
+    bool mIncludingChangesDuringComposition;
 
     uint32_t OldLength() const
     {
       MOZ_ASSERT(IsValid());
       return mRemovedEndOffset - mStartOffset;
     }
     uint32_t NewLength() const
     {
@@ -798,17 +802,18 @@ struct IMENotification final
       MOZ_ASSERT(aRemovedEndOffset >= aStartOffset,
                  "removed end offset must not be smaller than start offset");
       MOZ_ASSERT(aAddedEndOffset >= aStartOffset,
                  "added end offset must not be smaller than start offset");
       mStartOffset = aStartOffset;
       mRemovedEndOffset = aRemovedEndOffset;
       mAddedEndOffset = aAddedEndOffset;
       mCausedOnlyByComposition = aCausedByComposition;
-      mOccurredDuringComposition = aOccurredDuringComposition;
+      mIncludingChangesDuringComposition =
+        !aCausedByComposition && aOccurredDuringComposition;
     }
   };
 
   struct MouseButtonEventData
   {
     // The value of WidgetEvent::mMessage
     EventMessage mEventMessage;
     // Character offset from the start of the focused editor under the cursor
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -2164,20 +2164,33 @@ IMENotification::TextChangeDataBase::Mer
 
   const TextChangeDataBase& newData = aOther;
   const TextChangeDataBase oldData = *this;
 
   // mCausedOnlyByComposition should be true only when all changes are caused
   // by composition.
   mCausedOnlyByComposition =
     newData.mCausedOnlyByComposition && oldData.mCausedOnlyByComposition;
-  // mOccurredDuringComposition should be true only when all changes occurred
-  // during composition.
-  mOccurredDuringComposition =
-    newData.mOccurredDuringComposition && oldData.mOccurredDuringComposition;
+  // mIncludingChangesDuringComposition should be true when at least one of
+  // the merged non-composition changes occurred during the latest composition.
+
+  if (!newData.mCausedOnlyByComposition &&
+      !newData.mIncludingChangesDuringComposition) {
+    // If new change is neither caused by composition nor occurred during
+    // composition, set mIncludingChangesDuringComposition to false because
+    // IME doesn't want outdated text changes as text change during current
+    // composition.
+    mIncludingChangesDuringComposition = false;
+  } else {
+    // Otherwise, set mIncludingChangesDuringComposition to true if either
+    // oldData or newData includes changes during composition.
+    mIncludingChangesDuringComposition =
+      newData.mIncludingChangesDuringComposition ||
+        oldData.mIncludingChangesDuringComposition;
+  }
 
   if (newData.mStartOffset >= oldData.mAddedEndOffset) {
     // Case 1:
     // If new start is after old end offset of added text, it means that text
     // after the modified range is modified.  Like:
     // added range of old change:             +----------+
     // removed range of new change:                           +----------+
     // So, the old start offset is always the smaller offset.
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -781,26 +781,26 @@ struct ParamTraits<mozilla::widget::IMEN
   typedef mozilla::widget::IMENotification::TextChangeDataBase paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, aParam.mStartOffset);
     WriteParam(aMsg, aParam.mRemovedEndOffset);
     WriteParam(aMsg, aParam.mAddedEndOffset);
     WriteParam(aMsg, aParam.mCausedOnlyByComposition);
-    WriteParam(aMsg, aParam.mOccurredDuringComposition);
+    WriteParam(aMsg, aParam.mIncludingChangesDuringComposition);
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
     return ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
            ReadParam(aMsg, aIter, &aResult->mRemovedEndOffset) &&
            ReadParam(aMsg, aIter, &aResult->mAddedEndOffset) &&
            ReadParam(aMsg, aIter, &aResult->mCausedOnlyByComposition) &&
-           ReadParam(aMsg, aIter, &aResult->mOccurredDuringComposition);
+           ReadParam(aMsg, aIter, &aResult->mIncludingChangesDuringComposition);
   }
 };
 
 template<>
 struct ParamTraits<mozilla::widget::IMENotification::MouseButtonEventData>
 {
   typedef mozilla::widget::IMENotification::MouseButtonEventData paramType;
 
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -4600,24 +4600,25 @@ TSFTextStore::OnTextChangeInternal(const
 {
   const IMENotification::TextChangeDataBase& textChangeData =
     aIMENotification.mTextChangeData;
 
   MOZ_LOG(sTextStoreLog, LogLevel::Debug,
          ("TSF: 0x%p   TSFTextStore::OnTextChangeInternal(aIMENotification={ "
           "mMessage=0x%08X, mTextChangeData={ mStartOffset=%lu, "
           "mRemovedEndOffset=%lu, mAddedEndOffset=%lu, "
-          "mCausedOnlyByComposition=%s, mOccurredDuringComposition=%s }), "
+          "mCausedOnlyByComposition=%s, "
+          "mIncludingChangesDuringComposition=%s }), "
           "mSink=0x%p, mSinkMask=%s, mComposition.IsComposing()=%s",
           this, aIMENotification.mMessage,
           textChangeData.mStartOffset,
           textChangeData.mRemovedEndOffset,
           textChangeData.mAddedEndOffset,
           GetBoolName(textChangeData.mCausedOnlyByComposition),
-          GetBoolName(textChangeData.mOccurredDuringComposition),
+          GetBoolName(textChangeData.mIncludingChangesDuringComposition),
           mSink.get(),
           GetSinkMaskNameStr(mSinkMask).get(),
           GetBoolName(mComposition.IsComposing())));
 
   if (textChangeData.mCausedOnlyByComposition) {
     // Ignore text change notifications caused only by composition since it's
     // already been handled internally.
     return NS_OK;