Fix invalid replacement range check error during Japanese IME text reconversion
Minor
Commit Hash:
4646a17d39cc696819b571f771d3e6c667bffc54
Commit Time: 2025-04-18 18:02:46+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission fixes an issue where a CHECK error occurs during text reconversion (reconversion, i.e., homophone conversion) in Google Japanese IME due to an invalid replacement range being passed in. Specifically, when the IME calls the -setMarkedText: method, the replacement range passed in may not be the standard NSNotFound (2^31-1), but rather 2^32, which causes a CHECK error during subsequent gfx::Range conversion. The fix is to use the gfx::Range::FromPossiblyInvalidNSRange() method to safely handle such invalid NSRange values and convert them to gfx::InvalidRange.
🎯 Impact Analysis
This change has a positive impact on WebView2Mac. Since WebView2Mac embeds web content on macOS via Remote Cocoa, it relies on the same input method event handling mechanism. This fix addresses a critical issue that could cause application crashes, especially when performing text reconversion using Google Japanese IME. For WebView2Mac users, this means:
1. Improved stability when using Japanese input methods, preventing crashes caused by CHECK errors
2. Ensured proper functioning of text input and conversion features
3. Enhanced user experience in multilingual input scenarios
As this is a bug fix rather than a feature change, it does not affect the API or existing functionality of WebView2Mac, but simply improves reliability.
1. Improved stability when using Japanese input methods, preventing crashes caused by CHECK errors
2. Ensured proper functioning of text input and conversion features
3. Enhanced user experience in multilingual input scenarios
As this is a bug fix rather than a feature change, it does not affect the API or existing functionality of WebView2Mac, but simply improves reliability.
Impacted Classes:
RenderWidgetHostViewCocoa