Mac: Fix IME predictive completions in content
Issue: Predictive completions in some IMEs are not working properly when typing in a webpage. Cause: Appkit <-(sync)-> RWHVCocoa <-(async)-> Blink In an IME composition commit, RWHV commits the text to Blink through an async mojo call. Later when Blink finishes commit, it updates the text in RWHV through a separate mojo call. For predictive completions to work, IMEs calls RWHV's |attributedSubstringForProposedRange:| to retrieve some text as the context for prediction. Oftentimes the call happens before Blink's async update to RWHV, resulting in a wrong predictive context. This issue troubles both Chromium and Firefox but not Safari/Webkit. Webkit is using an undocumented async IME API. Also after macOS 10.12+, IMEs expect |selectedRange:| to return a empty range positioned at the end of the committed text. If not respected the predictive completions won't work. Solution: - Temporarily insert the committed text to RWHV's available text - Follow the |selectedRange:| requirement Bug: 710101 Change-Id: I3e4267362ea3e0a6b9f7cebce23fe59d1a6ece6a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2606140Reviewed-by:Avi Drissman <avi@chromium.org> Commit-Queue: Keren Zhu <kerenzhu@chromium.org> Cr-Commit-Position: refs/heads/master@{#845832}
Showing
Please register or sign in to comment