Closed Bug 1677926 Opened 4 years ago Closed 4 years ago

[TSF} GetTextExtent immediately after committing composition may return error

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

x86_64
Windows 10
defect

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

Details

(Keywords: inputmethod)

Attachments

(1 file)

STR:

  1. Type something with Japanese IME (composition must start from second or later caret position) in web content.
  2. Commit the composition

Then, GetTextExt is called with acpStart = acpEnd = 0 and it tries to query the character rect with relative offset query from the last composition start offset. However, ContentCacheInParent solves it with current selection. So, the offset is solved to "0 + last composition length". Then, if it's not cached, it returns error. Or otherwise, it returns wrong character's rect.

This might cause random odd suggest window position of some IMEs.

I found this with the following debug warnings:

[Parent 21952: Main Thread]: I/nsTextStoreWidgets 0x00000165C936B820 TSFTextStore::GetTextExt(vcView=1, acpStart=0, acpEnd=0, prc=0x0000000D8C7FC1E0, pfClipped=0x0000000D8C7FC190), IsHandlingComposition()=true, mContentForTSF={ MinOffsetOfLayoutChanged()=4294967295, LatestCompositionStartOffset()=13, LatestCompositionEndOffset()=15 }, mComposition= { IsComposing()=false, mStart=13, EndOffset()=13 }, mDeferNotifyingTSF=false, mWaitingQueryLayout=false, IMEHandler::IsA11yHandlingNativeCaret()=true
[Parent 21952: Main Thread]: I/ContentCacheWidgets 0x00000165C5D4E208 HandleQueryContentEvent(aEvent={ mMessage=eQueryTextRect, mInput={ mOffset=2, mLength=1 } }, aWidget=0x00000165B969B800), mText.Length()=15
[Parent 21952: Main Thread]: I/ContentCacheWidgets 0x00000165C5D4E208 GetUnionTextRects(aOffset=2, aLength=1, aRoundToExistingOffset=true), mTextRectArray={ mStart=4294967295, mRects.Length()=0 }, mSelection={ mAnchor=15, mFocus=15 }
[Parent 21952, Main Thread] WARNING: '!GetUnionTextRects( aEvent.mInput.mOffset, aEvent.mInput.mLength, isRelativeToInsertionPoint, aEvent.mReply.mRect)', file m:/src/widget/ContentCache.cpp:747
[Parent 21952: Main Thread]: E/ContentCacheWidgets 0x00000165C5D4E208 HandleQueryContentEvent(), FAILED to get union rect
[Parent 21952, Main Thread] WARNING: '!mContentCache.HandleQueryContentEvent( aEvent, textInputHandlingWidget)', file m:/src/dom/ipc/BrowserParent.cpp:2918
[Parent 21952, Main Thread] WARNING: '!event.mSucceeded', file m:/src/widget/windows/TSFTextStore.cpp:4498
[Parent 21952: Main Thread]: E/nsTextStoreWidgets 0x00000165C936B820   TSFTextStore::GetTextExt() FAILED due to eQueryTextRect failure

Immediately after committing composition, i.e., still remote content is
handling the commit, ContentCacheInParent does not think that it still
has composition, but TSFTextStore::GetTextExt() tries a query whose offset
is relative offset from the last composition start offset and then,
ContentCacheInParent solves it with selection start (typically, the last
composition end offset). Therefore, this may cause returning error from
GetTextExt() and some TIP may fail to do something for next typing.

This patch makes TSFTextStore::GetTextExt() consider whether it'll query
content with relative offset from last composition start or selection start,
from TextEventDispatcher::IsComposing() result rather than
TextEventDispatcher::IsHandlingComposition() since the former means whether
there is composition in the chrome process, but the latter is there is
composition in focused process, and ContentCacheInParent state matches the
former.

Depends on D97270

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/b403f89feb4c
Make `TSFTextStore::GetTextExt()` consider whether it can query content with relative offset from last composition start with `TextEventDispatcher::IsComposing()` r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: