mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1171814 ContentCache should store first character rect because Yosemite's Japanese IME sometimes tries to query it r=m_kato
This commit is contained in:
parent
0bae50af4b
commit
6fcde0fcbd
@ -138,6 +138,7 @@ ContentCache::AssignContent(const ContentCache& aOther,
|
||||
|
||||
mText = aOther.mText;
|
||||
mSelection = aOther.mSelection;
|
||||
mFirstCharRect = aOther.mFirstCharRect;
|
||||
mCaret = aOther.mCaret;
|
||||
mTextRectArray = aOther.mTextRectArray;
|
||||
mEditorRect = aOther.mEditorRect;
|
||||
@ -146,15 +147,15 @@ ContentCache::AssignContent(const ContentCache& aOther,
|
||||
("ContentCache: 0x%p (mIsChrome=%s) AssignContent(aNotification=%s), "
|
||||
"Succeeded, mText.Length()=%u, mSelection={ mAnchor=%u, mFocus=%u, "
|
||||
"mWritingMode=%s, mAnchorCharRect=%s, mFocusCharRect=%s, mRect=%s }, "
|
||||
"mCaret={ mOffset=%u, mRect=%s }, mTextRectArray={ mStart=%u, "
|
||||
"mRects.Length()=%u }, mEditorRect=%s",
|
||||
"mFirstCharRect=%s, mCaret={ mOffset=%u, mRect=%s }, mTextRectArray={ "
|
||||
"mStart=%u, mRects.Length()=%u }, mEditorRect=%s",
|
||||
this, GetBoolName(mIsChrome), GetNotificationName(aNotification),
|
||||
mText.Length(), mSelection.mAnchor, mSelection.mFocus,
|
||||
GetWritingModeName(mSelection.mWritingMode).get(),
|
||||
GetRectText(mSelection.mAnchorCharRect).get(),
|
||||
GetRectText(mSelection.mFocusCharRect).get(),
|
||||
GetRectText(mSelection.mRect).get(), mCaret.mOffset,
|
||||
GetRectText(mCaret.mRect).get(), mTextRectArray.mStart,
|
||||
GetRectText(mSelection.mRect).get(), GetRectText(mFirstCharRect).get(),
|
||||
mCaret.mOffset, GetRectText(mCaret.mRect).get(), mTextRectArray.mStart,
|
||||
mTextRectArray.mRects.Length(), GetRectText(mEditorRect).get()));
|
||||
}
|
||||
|
||||
@ -171,6 +172,7 @@ ContentCache::Clear()
|
||||
|
||||
mText.Truncate();
|
||||
mSelection.Clear();
|
||||
mFirstCharRect.SetEmpty();
|
||||
mCaret.Clear();
|
||||
mTextRectArray.Clear();
|
||||
mEditorRect.SetEmpty();
|
||||
@ -597,6 +599,7 @@ ContentCache::CacheTextRects(nsIWidget* aWidget,
|
||||
mSelection.mAnchorCharRect.SetEmpty();
|
||||
mSelection.mFocusCharRect.SetEmpty();
|
||||
mSelection.mRect.SetEmpty();
|
||||
mFirstCharRect.SetEmpty();
|
||||
|
||||
if (NS_WARN_IF(!mSelection.IsValid())) {
|
||||
return false;
|
||||
@ -671,16 +674,34 @@ ContentCache::CacheTextRects(nsIWidget* aWidget,
|
||||
}
|
||||
}
|
||||
|
||||
if (!mSelection.mFocus) {
|
||||
mFirstCharRect = mSelection.mFocusCharRect;
|
||||
} else if (!mSelection.mAnchor) {
|
||||
mFirstCharRect = mSelection.mAnchorCharRect;
|
||||
} else if (mTextRectArray.InRange(0)) {
|
||||
mFirstCharRect = mTextRectArray.GetRect(0);
|
||||
} else {
|
||||
LayoutDeviceIntRect charRect;
|
||||
if (NS_WARN_IF(!QueryCharRect(aWidget, 0, charRect))) {
|
||||
MOZ_LOG(sContentCacheLog, LogLevel::Error,
|
||||
("ContentCache: 0x%p (mIsChrome=%s) CacheTextRects(), FAILED, "
|
||||
"couldn't retrieve first char rect",
|
||||
this, GetBoolName(mIsChrome)));
|
||||
} else {
|
||||
mFirstCharRect = charRect;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_LOG(sContentCacheLog, LogLevel::Info,
|
||||
("ContentCache: 0x%p (mIsChrome=%s) CacheTextRects(), Succeeded, "
|
||||
"mText.Length()=%u, mTextRectArray={ mStart=%u, mRects.Length()=%u }, "
|
||||
"mSelection={ mAnchor=%u, mAnchorCharRect=%s, mFocus=%u, "
|
||||
"mFocusCharRect=%s, mRect=%s }",
|
||||
"mFocusCharRect=%s, mRect=%s }, mFirstCharRect=%s",
|
||||
this, GetBoolName(mIsChrome), mText.Length(), mTextRectArray.mStart,
|
||||
mTextRectArray.mRects.Length(), mSelection.mAnchor,
|
||||
GetRectText(mSelection.mAnchorCharRect).get(), mSelection.mFocus,
|
||||
GetRectText(mSelection.mFocusCharRect).get(),
|
||||
GetRectText(mSelection.mRect).get()));
|
||||
GetRectText(mSelection.mRect).get(), GetRectText(mFirstCharRect).get()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -728,6 +749,11 @@ ContentCache::GetTextRect(uint32_t aOffset,
|
||||
this, GetBoolName(mIsChrome), aOffset, mTextRectArray.mStart,
|
||||
mTextRectArray.mRects.Length(), mSelection.mAnchor, mSelection.mFocus));
|
||||
|
||||
if (!aOffset) {
|
||||
NS_WARN_IF(mFirstCharRect.IsEmpty());
|
||||
aTextRect = mFirstCharRect;
|
||||
return !aTextRect.IsEmpty();
|
||||
}
|
||||
if (aOffset == mSelection.mAnchor) {
|
||||
NS_WARN_IF(mSelection.mAnchorCharRect.IsEmpty());
|
||||
aTextRect = mSelection.mAnchorCharRect;
|
||||
@ -768,6 +794,11 @@ ContentCache::GetUnionTextRects(uint32_t aOffset,
|
||||
}
|
||||
|
||||
if (aLength == 1) {
|
||||
if (!aOffset) {
|
||||
NS_WARN_IF(mFirstCharRect.IsEmpty());
|
||||
aUnionTextRect = mFirstCharRect;
|
||||
return !aUnionTextRect.IsEmpty();
|
||||
}
|
||||
if (aOffset == mSelection.mAnchor) {
|
||||
NS_WARN_IF(mSelection.mAnchorCharRect.IsEmpty());
|
||||
aUnionTextRect = mSelection.mAnchorCharRect;
|
||||
@ -796,14 +827,16 @@ ContentCache::GetCaretRect(uint32_t aOffset,
|
||||
("ContentCache: 0x%p (mIsChrome=%s) GetCaretRect(aOffset=%u), "
|
||||
"mCaret={ mOffset=%u, mRect=%s, IsValid()=%s }, mTextRectArray={ "
|
||||
"mStart=%u, mRects.Length()=%u }, mSelection={ mAnchor=%u, mFocus=%u, "
|
||||
"mWritingMode=%s, mAnchorCharRect=%s, mFocusCharRect=%s }",
|
||||
"mWritingMode=%s, mAnchorCharRect=%s, mFocusCharRect=%s }, "
|
||||
"mFirstCharRect=%s",
|
||||
this, GetBoolName(mIsChrome), aOffset, mCaret.mOffset,
|
||||
GetRectText(mCaret.mRect).get(), GetBoolName(mCaret.IsValid()),
|
||||
mTextRectArray.mStart, mTextRectArray.mRects.Length(),
|
||||
mSelection.mAnchor, mSelection.mFocus,
|
||||
GetWritingModeName(mSelection.mWritingMode).get(),
|
||||
GetRectText(mSelection.mAnchorCharRect).get(),
|
||||
GetRectText(mSelection.mFocusCharRect).get()));
|
||||
GetRectText(mSelection.mFocusCharRect).get(),
|
||||
GetRectText(mFirstCharRect).get()));
|
||||
|
||||
if (mCaret.IsValid() && mCaret.mOffset == aOffset) {
|
||||
aCaretRect = mCaret.mRect;
|
||||
|
@ -229,6 +229,10 @@ private:
|
||||
return mSelection.IsValid() && mSelection.EndOffset() <= mText.Length();
|
||||
}
|
||||
|
||||
// Stores first char rect because Yosemite's Japanese IME sometimes tries
|
||||
// to query it. If there is no text, this is caret rect.
|
||||
LayoutDeviceIntRect mFirstCharRect;
|
||||
|
||||
struct Caret final
|
||||
{
|
||||
uint32_t mOffset;
|
||||
|
@ -808,6 +808,7 @@ struct ParamTraits<mozilla::ContentCache>
|
||||
WriteParam(aMsg, aParam.mSelection.mAnchorCharRect);
|
||||
WriteParam(aMsg, aParam.mSelection.mFocusCharRect);
|
||||
WriteParam(aMsg, aParam.mSelection.mRect);
|
||||
WriteParam(aMsg, aParam.mFirstCharRect);
|
||||
WriteParam(aMsg, aParam.mCaret.mOffset);
|
||||
WriteParam(aMsg, aParam.mCaret.mRect);
|
||||
WriteParam(aMsg, aParam.mTextRectArray.mStart);
|
||||
@ -824,6 +825,7 @@ struct ParamTraits<mozilla::ContentCache>
|
||||
ReadParam(aMsg, aIter, &aResult->mSelection.mAnchorCharRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mSelection.mFocusCharRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mSelection.mRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mFirstCharRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mCaret.mOffset) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mCaret.mRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mTextRectArray.mStart) &&
|
||||
|
Loading…
Reference in New Issue
Block a user