Bug 1242331 part.4 Add TextChangeDataBase::mIncludingChangesWithoutComposition r=smaug

This commit is contained in:
Masayuki Nakano 2016-01-28 13:28:54 +09:00
parent 76237b47a0
commit 3f46e23f14
5 changed files with 26 additions and 5 deletions

View File

@ -135,11 +135,13 @@ public:
} }
AppendPrintf("{ mStartOffset=%u, mRemovedEndOffset=%u, mAddedEndOffset=%u, " AppendPrintf("{ mStartOffset=%u, mRemovedEndOffset=%u, mAddedEndOffset=%u, "
"mCausedOnlyByComposition=%s, " "mCausedOnlyByComposition=%s, "
"mIncludingChangesDuringComposition=%s }", "mIncludingChangesDuringComposition=%s, "
"mIncludingChangesWithoutComposition=%s }",
aData.mStartOffset, aData.mRemovedEndOffset, aData.mStartOffset, aData.mRemovedEndOffset,
aData.mAddedEndOffset, aData.mAddedEndOffset,
ToChar(aData.mCausedOnlyByComposition), ToChar(aData.mCausedOnlyByComposition),
ToChar(aData.mIncludingChangesDuringComposition)); ToChar(aData.mIncludingChangesDuringComposition),
ToChar(aData.mIncludingChangesWithoutComposition));
} }
virtual ~TextChangeDataToString() {} virtual ~TextChangeDataToString() {}
}; };

View File

@ -736,6 +736,9 @@ struct IMENotification final
// Note that if after the last composition is finished and there are some // Note that if after the last composition is finished and there are some
// changes not caused by composition, this is set to false. // changes not caused by composition, this is set to false.
bool mIncludingChangesDuringComposition; bool mIncludingChangesDuringComposition;
// mIncludingChangesWithoutComposition is true if there is at least one
// change which did occur when there wasn't a composition ongoing.
bool mIncludingChangesWithoutComposition;
uint32_t OldLength() const uint32_t OldLength() const
{ {
@ -809,6 +812,8 @@ struct IMENotification final
mCausedOnlyByComposition = aCausedByComposition; mCausedOnlyByComposition = aCausedByComposition;
mIncludingChangesDuringComposition = mIncludingChangesDuringComposition =
!aCausedByComposition && aOccurredDuringComposition; !aCausedByComposition && aOccurredDuringComposition;
mIncludingChangesWithoutComposition =
!aCausedByComposition && !aOccurredDuringComposition;
} }
}; };

View File

@ -2169,11 +2169,19 @@ IMENotification::TextChangeDataBase::MergeWith(
// by composition. // by composition.
mCausedOnlyByComposition = mCausedOnlyByComposition =
newData.mCausedOnlyByComposition && oldData.mCausedOnlyByComposition; newData.mCausedOnlyByComposition && oldData.mCausedOnlyByComposition;
// mIncludingChangesWithoutComposition should be true if at least one of
// merged changes occurred without composition.
mIncludingChangesWithoutComposition =
newData.mIncludingChangesWithoutComposition ||
oldData.mIncludingChangesWithoutComposition;
// mIncludingChangesDuringComposition should be true when at least one of // mIncludingChangesDuringComposition should be true when at least one of
// the merged non-composition changes occurred during the latest composition. // the merged non-composition changes occurred during the latest composition.
if (!newData.mCausedOnlyByComposition && if (!newData.mCausedOnlyByComposition &&
!newData.mIncludingChangesDuringComposition) { !newData.mIncludingChangesDuringComposition) {
MOZ_ASSERT(newData.mIncludingChangesWithoutComposition);
MOZ_ASSERT(mIncludingChangesWithoutComposition);
// If new change is neither caused by composition nor occurred during // If new change is neither caused by composition nor occurred during
// composition, set mIncludingChangesDuringComposition to false because // composition, set mIncludingChangesDuringComposition to false because
// IME doesn't want outdated text changes as text change during current // IME doesn't want outdated text changes as text change during current

View File

@ -787,6 +787,7 @@ struct ParamTraits<mozilla::widget::IMENotification::TextChangeDataBase>
WriteParam(aMsg, aParam.mAddedEndOffset); WriteParam(aMsg, aParam.mAddedEndOffset);
WriteParam(aMsg, aParam.mCausedOnlyByComposition); WriteParam(aMsg, aParam.mCausedOnlyByComposition);
WriteParam(aMsg, aParam.mIncludingChangesDuringComposition); WriteParam(aMsg, aParam.mIncludingChangesDuringComposition);
WriteParam(aMsg, aParam.mIncludingChangesWithoutComposition);
} }
static bool Read(const Message* aMsg, void** aIter, paramType* aResult) static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
@ -795,7 +796,10 @@ struct ParamTraits<mozilla::widget::IMENotification::TextChangeDataBase>
ReadParam(aMsg, aIter, &aResult->mRemovedEndOffset) && ReadParam(aMsg, aIter, &aResult->mRemovedEndOffset) &&
ReadParam(aMsg, aIter, &aResult->mAddedEndOffset) && ReadParam(aMsg, aIter, &aResult->mAddedEndOffset) &&
ReadParam(aMsg, aIter, &aResult->mCausedOnlyByComposition) && ReadParam(aMsg, aIter, &aResult->mCausedOnlyByComposition) &&
ReadParam(aMsg, aIter, &aResult->mIncludingChangesDuringComposition); ReadParam(aMsg, aIter,
&aResult->mIncludingChangesDuringComposition) &&
ReadParam(aMsg, aIter,
&aResult->mIncludingChangesWithoutComposition);
} }
}; };

View File

@ -4606,7 +4606,8 @@ TSFTextStore::OnTextChangeInternal(const IMENotification& aIMENotification)
"mMessage=0x%08X, mTextChangeData={ mStartOffset=%lu, " "mMessage=0x%08X, mTextChangeData={ mStartOffset=%lu, "
"mRemovedEndOffset=%lu, mAddedEndOffset=%lu, " "mRemovedEndOffset=%lu, mAddedEndOffset=%lu, "
"mCausedOnlyByComposition=%s, " "mCausedOnlyByComposition=%s, "
"mIncludingChangesDuringComposition=%s }), " "mIncludingChangesDuringComposition=%s, "
"mIncludingChangesWithoutComposition=%s }), "
"mSink=0x%p, mSinkMask=%s, mComposition.IsComposing()=%s", "mSink=0x%p, mSinkMask=%s, mComposition.IsComposing()=%s",
this, aIMENotification.mMessage, this, aIMENotification.mMessage,
textChangeData.mStartOffset, textChangeData.mStartOffset,
@ -4614,6 +4615,7 @@ TSFTextStore::OnTextChangeInternal(const IMENotification& aIMENotification)
textChangeData.mAddedEndOffset, textChangeData.mAddedEndOffset,
GetBoolName(textChangeData.mCausedOnlyByComposition), GetBoolName(textChangeData.mCausedOnlyByComposition),
GetBoolName(textChangeData.mIncludingChangesDuringComposition), GetBoolName(textChangeData.mIncludingChangesDuringComposition),
GetBoolName(textChangeData.mIncludingChangesWithoutComposition),
mSink.get(), mSink.get(),
GetSinkMaskNameStr(mSinkMask).get(), GetSinkMaskNameStr(mSinkMask).get(),
GetBoolName(mComposition.IsComposing()))); GetBoolName(mComposition.IsComposing())));