--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -1179,17 +1179,17 @@ bool TSFTextStore::sHackQueryInsertForMS
#define TEXTSTORE_DEFAULT_VIEW (1)
TSFTextStore::TSFTextStore()
: mEditCookie(0)
, mSinkMask(0)
, mLock(0)
, mLockQueued(0)
, mHandlingKeyMessage(0)
- , mLockedContent(mComposition, mSelection)
+ , mContentForTSF(mComposition, mSelection)
, mRequestedAttrValues(false)
, mIsRecordingActionsWithoutLock(false)
, mPendingOnSelectionChange(false)
, mHasReturnedNoLayoutError(false)
, mWaitingQueryLayout(false)
, mPendingDestroy(false)
, mDeferClearingLockedContent(false)
, mNativeCaretIsCreated(false)
@@ -1490,17 +1490,17 @@ TSFTextStore::RequestLock(DWORD dwLockFl
if (!mSink) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::RequestLock() FAILED due to "
"any sink not stored", this));
return E_FAIL;
}
if (mDestroyed &&
- (!mLockedContent.IsInitialized() || mSelection.IsDirty())) {
+ (!mContentForTSF.IsInitialized() || mSelection.IsDirty())) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::RequestLock() FAILED due to "
"being destroyed and no information of the contents", this));
return E_FAIL;
}
if (!phrSession) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::RequestLock() FAILED due to "
@@ -1832,21 +1832,21 @@ TSFTextStore::MaybeFlushPendingNotificat
// If it's already been destroyed completely, this shouldn't notify TSF of
// anything anymore.
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::MaybeFlushPendingNotifications(), "
"does nothing because this has already destroyed completely...", this));
return;
}
- if (!mDeferClearingLockedContent && mLockedContent.IsInitialized()) {
- mLockedContent.Clear();
+ if (!mDeferClearingLockedContent && mContentForTSF.IsInitialized()) {
+ mContentForTSF.Clear();
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::MaybeFlushPendingNotifications(), "
- "mLockedContent is cleared", this));
+ "mContentForTSF is cleared", this));
}
if (mHasReturnedNoLayoutError) {
MOZ_LOG(sTextStoreLog, LogLevel::Info,
("TSF: 0x%p TSFTextStore::MaybeFlushPendingNotifications(), "
"calling TSFTextStore::NotifyTSFOfLayoutChange()...", this));
NotifyTSFOfLayoutChange();
}
@@ -1977,74 +1977,74 @@ TSFTextStore::GetSelection(ULONG ulIndex
return S_OK;
}
TSFTextStore::Content&
TSFTextStore::LockedContent()
{
// This should be called when the document is locked or the content hasn't
// been abandoned yet.
- if (NS_WARN_IF(!IsReadLocked() && !mLockedContent.IsInitialized())) {
+ if (NS_WARN_IF(!IsReadLocked() && !mContentForTSF.IsInitialized())) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::LockedContent(), FAILED, due to "
"called wrong timing, IsReadLocked()=%s, "
- "mLockedContent.IsInitialized()=%s",
+ "mContentForTSF.IsInitialized()=%s",
this, GetBoolName(IsReadLocked()),
- GetBoolName(mLockedContent.IsInitialized())));
- mLockedContent.Clear();
- return mLockedContent;
+ GetBoolName(mContentForTSF.IsInitialized())));
+ mContentForTSF.Clear();
+ return mContentForTSF;
}
Selection& currentSel = CurrentSelection();
if (currentSel.IsDirty()) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::LockedContent(), FAILED, due to "
"CurrentSelection() failure", this));
- mLockedContent.Clear();
- return mLockedContent;
- }
-
- if (!mLockedContent.IsInitialized()) {
+ mContentForTSF.Clear();
+ return mContentForTSF;
+ }
+
+ if (!mContentForTSF.IsInitialized()) {
nsAutoString text;
if (NS_WARN_IF(!GetCurrentText(text))) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::LockedContent(), FAILED, due to "
"GetCurrentText() failure", this));
- mLockedContent.Clear();
- return mLockedContent;
+ mContentForTSF.Clear();
+ return mContentForTSF;
}
- mLockedContent.Init(text);
+ mContentForTSF.Init(text);
// Basically, the locked content should be cleared after the document is
// unlocked. However, in e10s mode, content will be modified
// asynchronously. In such case, mDeferClearingLockedContent may be
// true even after the document is unlocked.
mDeferClearingLockedContent = false;
}
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::LockedContent(): "
- "mLockedContent={ mText=\"%s\" (Length()=%u), "
+ "mContentForTSF={ mText=\"%s\" (Length()=%u), "
"mLastCompositionString=\"%s\" (Length()=%u), "
"mMinTextModifiedOffset=%u }",
- this, mLockedContent.Text().Length() <= 20 ?
- NS_ConvertUTF16toUTF8(mLockedContent.Text()).get() : "<omitted>",
- mLockedContent.Text().Length(),
- NS_ConvertUTF16toUTF8(mLockedContent.LastCompositionString()).get(),
- mLockedContent.LastCompositionString().Length(),
- mLockedContent.MinTextModifiedOffset()));
-
- return mLockedContent;
+ this, mContentForTSF.Text().Length() <= 20 ?
+ NS_ConvertUTF16toUTF8(mContentForTSF.Text()).get() : "<omitted>",
+ mContentForTSF.Text().Length(),
+ NS_ConvertUTF16toUTF8(mContentForTSF.LastCompositionString()).get(),
+ mContentForTSF.LastCompositionString().Length(),
+ mContentForTSF.MinTextModifiedOffset()));
+
+ return mContentForTSF;
}
bool
TSFTextStore::GetCurrentText(nsAString& aTextContent)
{
- if (mLockedContent.IsInitialized()) {
- aTextContent = mLockedContent.Text();
+ if (mContentForTSF.IsInitialized()) {
+ aTextContent = mContentForTSF.Text();
return true;
}
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(mWidget && !mWidget->Destroyed());
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::GetCurrentText(): "
@@ -3320,17 +3320,17 @@ TSFTextStore::GetACPFromPoint(TsViewCook
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::GetACPFromPoint() FAILED due to "
"null pacp", this));
return E_INVALIDARG;
}
mWaitingQueryLayout = false;
- if (mDestroyed || mLockedContent.IsLayoutChanged()) {
+ if (mDestroyed || mContentForTSF.IsLayoutChanged()) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::GetACPFromPoint() returned "
"TS_E_NOLAYOUT", this));
mHasReturnedNoLayoutError = true;
return TS_E_NOLAYOUT;
}
LayoutDeviceIntPoint ourPt(pt->x, pt->y);
@@ -3480,17 +3480,17 @@ TSFTextStore::GetTextExt(TsViewCookie vc
mWaitingQueryLayout = false;
// NOTE: TSF (at least on Win 8.1) doesn't return TS_E_NOLAYOUT to the
// caller even if we return it. It's converted to just E_FAIL.
// However, this is fixed on Win 10.
const TSFStaticSink* kSink = TSFStaticSink::GetInstance();
if (mComposition.IsComposing() && mComposition.mStart < acpEnd &&
- mLockedContent.IsLayoutChangedAfter(acpEnd)) {
+ mContentForTSF.IsLayoutChangedAfter(acpEnd)) {
const Selection& currentSel = CurrentSelection();
// The bug of Microsoft Office IME 2010 for Japanese is similar to
// MS-IME for Win 8.1 and Win 10. Newer version of MS Office IME is not
// released yet. So, we can hack it without prefs because there must be
// no developers who want to disable this hack for tests.
const bool kIsMSOfficeJapaneseIME2010 =
kSink->IsMSOfficeJapaneseIME2010Active();
// MS IME for Japanese doesn't support asynchronous handling at deciding
@@ -3504,34 +3504,34 @@ TSFTextStore::GetTextExt(TsViewCookie vc
kSink->IsMSJapaneseIMEActive())) {
// Basically, MS-IME tries to retrieve whole composition string rect
// at deciding suggest window immediately after unlocking the document.
// However, in e10s mode, the content hasn't updated yet in most cases.
// Therefore, if the first character at the retrieving range rect is
// available, we should use it as the result.
if ((kIsMSOfficeJapaneseIME2010 ||
sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar) &&
- !mLockedContent.IsLayoutChangedAfter(acpStart) &&
+ !mContentForTSF.IsLayoutChangedAfter(acpStart) &&
acpStart < acpEnd) {
acpEnd = acpStart;
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::GetTextExt() hacked the offsets "
"of the first character of changing range of the composition "
"string for TIP acpStart=%d, acpEnd=%d",
this, acpStart, acpEnd));
}
// Although, the condition is not clear, MS-IME sometimes retrieves the
// caret rect immediately after modifying the composition string but
// before unlocking the document. In such case, we should return the
// nearest character rect.
else if ((kIsMSOfficeJapaneseIME2010 ||
sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret) &&
acpStart == acpEnd &&
currentSel.IsCollapsed() && currentSel.EndOffset() == acpEnd) {
- acpEnd = acpStart = mLockedContent.MinOffsetOfLayoutChanged();
+ acpEnd = acpStart = mContentForTSF.MinOffsetOfLayoutChanged();
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::GetTextExt() hacked the offsets "
"of the caret of the composition string for TIP acpStart=%d, "
"acpEnd=%d", this, acpStart, acpEnd));
}
}
// Free ChangJie 2010 and Easy Changjei 1.0.12.0 doesn't handle
// ITfContextView::GetTextExt() properly. Prehaps, it's due to the bug of
@@ -3559,17 +3559,17 @@ TSFTextStore::GetTextExt(TsViewCookie vc
acpEnd = mComposition.mStart;
acpStart = std::min(acpStart, acpEnd);
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::GetTextExt() hacked the offsets for "
"TIP acpStart=%d, acpEnd=%d", this, acpStart, acpEnd));
}
}
- if (mLockedContent.IsLayoutChangedAfter(acpEnd)) {
+ if (mContentForTSF.IsLayoutChangedAfter(acpEnd)) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
("TSF: 0x%p TSFTextStore::GetTextExt() returned TS_E_NOLAYOUT "
"(acpEnd=%d)", this, acpEnd));
mHasReturnedNoLayoutError = true;
return TS_E_NOLAYOUT;
}
if (mDestroyed) {
@@ -4842,20 +4842,20 @@ TSFTextStore::NotifyTSFOfLayoutChange()
// If we returned TS_E_NOLAYOUT, TIP should query the computed layout again.
mWaitingQueryLayout = returnedNoLayoutError;
// For avoiding to call this method again at unlocking the document during
// calls of OnLayoutChange(), reset mHasReturnedNoLayoutError.
mHasReturnedNoLayoutError = false;
- // Now, layout has been computed. We should notify mLockedContent for
+ // Now, layout has been computed. We should notify mContentForTSF for
// making GetTextExt() and GetACPFromPoint() not return TS_E_NOLAYOUT.
- if (mLockedContent.IsInitialized()) {
- mLockedContent.OnLayoutChanged();
+ if (mContentForTSF.IsInitialized()) {
+ mContentForTSF.OnLayoutChanged();
}
// Now, the caret position is different from ours. Destroy the native caret
// if there is.
MaybeDestroyNativeCaret();
// This method should return true if either way succeeds.
bool ret = true;
--- a/widget/windows/TSFTextStore.h
+++ b/widget/windows/TSFTextStore.h
@@ -780,28 +780,29 @@ protected:
enum : uint32_t
{
NOT_MODIFIED = UINT32_MAX
};
uint32_t mMinTextModifiedOffset;
bool mInitialized;
};
- // mLockedContent starts to cache content of the document at first query of
- // the content during a document lock. This is abandoned after document is
- // unlocked and dispatched events are handled. This is initialized by
- // LockedContent() automatically. So, don't access this member directly
- // except at calling Clear(), IsInitialized(), IsLayoutChangedAfter() or
- // IsLayoutChanged().
- Content mLockedContent;
+ // mContentForTSF starts to cache content of the document at first query of
+ // the content during a document lock. The information is expected by TSF
+ // and TIP. Therefore, this is useful for answering the query from TSF or
+ // TIP. This is abandoned after document is unlocked and dispatched events
+ // are handled. This is initialized by LockedContent() automatically.
+ // So, don't access this member directly except at calling Clear(),
+ // IsInitialized(), IsLayoutChangedAfter() or IsLayoutChanged().
+ Content mContentForTSF;
Content& LockedContent();
// While the documet is locked, this returns the text stored by
- // mLockedContent. Otherwise, return the current text content.
+ // mContentForTSF. Otherwise, return the current text content.
bool GetCurrentText(nsAString& aTextContent);
class MouseTracker final
{
public:
static const DWORD kInvalidCookie = static_cast<DWORD>(-1);
MouseTracker();
@@ -879,17 +880,17 @@ protected:
// ITfContextOwnerServices::OnLayoutChange(), mWaitingQueryLayout is set to
// true. This is set to false when GetTextExt() or GetACPFromPoint() is
// called.
bool mWaitingQueryLayout;
// During the documet is locked, we shouldn't destroy the instance.
// If this is true, the instance will be destroyed after unlocked.
bool mPendingDestroy;
// If this is false, MaybeFlushPendingNotifications() will clear the
- // mLockedContent.
+ // mContentForTSF.
bool mDeferClearingLockedContent;
// While there is native caret, this is true. Otherwise, false.
bool mNativeCaretIsCreated;
// While the instance is dispatching events, the event may not be handled
// synchronously in e10s mode. So, in such case, in strictly speaking,
// we shouldn't query layout information. However, TS_E_NOLAYOUT bugs of
// ITextStoreAPC::GetTextExt() blocks us to behave ideally.
// For preventing it to be called, we should put off notifying TSF of