Bug 1267526 part.1 TSFTextStore shouldn't notify TSF of selectin change when the selection isn't actually changed r?m_kato
MozReview-Commit-ID: 8HLz30lR2TH
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -4752,21 +4752,28 @@ TSFTextStore::OnSelectionChangeInternal(
!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;
}
- mSelection.SetSelection(
- selectionChangeData.mOffset,
- selectionChangeData.Length(),
- selectionChangeData.mReversed,
- selectionChangeData.GetWritingMode());
+ // If selection range isn't actually changed, we don't need to notify TSF
+ // of this selection change.
+ if (!mSelection.SetSelection(
+ selectionChangeData.mOffset,
+ selectionChangeData.Length(),
+ selectionChangeData.mReversed,
+ selectionChangeData.GetWritingMode())) {
+ MOZ_LOG(sTextStoreLog, LogLevel::Debug,
+ ("TSF: 0x%p TSFTextStore::OnSelectionChangeInternal(), selection "
+ "isn't actually changed.", this));
+ return NS_OK;
+ }
if (!selectionChangeData.mCausedBySelectionEvent) {
// Should be notified via MaybeFlushPendingNotifications() for keeping
// the order of change notifications.
mPendingOnSelectionChange = true;
if (mIsRecordingActionsWithoutLock) {
MOZ_LOG(sTextStoreLog, LogLevel::Info,
("TSF: 0x%p TSFTextStore::OnSelectionChangeInternal(), putting "
--- a/widget/windows/TSFTextStore.h
+++ b/widget/windows/TSFTextStore.h
@@ -413,27 +413,33 @@ protected:
if (mACP.style.ase != TS_AE_START) {
mACP.style.ase = TS_AE_END;
}
// We're not support interim char selection for now.
// XXX Probably, this is necessary for supporting South Asian languages.
mACP.style.fInterimChar = FALSE;
}
- void SetSelection(uint32_t aStart,
+ bool SetSelection(uint32_t aStart,
uint32_t aLength,
bool aReversed,
WritingMode aWritingMode)
{
+ bool changed = mDirty ||
+ mACP.acpStart != static_cast<LONG>(aStart) ||
+ mACP.acpEnd != static_cast<LONG>(aStart + aLength);
+
mDirty = false;
mACP.acpStart = static_cast<LONG>(aStart);
mACP.acpEnd = static_cast<LONG>(aStart + aLength);
mACP.style.ase = aReversed ? TS_AE_START : TS_AE_END;
mACP.style.fInterimChar = FALSE;
mWritingMode = aWritingMode;
+
+ return changed;
}
bool IsCollapsed() const
{
MOZ_ASSERT(!mDirty);
return (mACP.acpStart == mACP.acpEnd);
}