[EditContext] Prevent redundant selection synchronization to avoid conflicts

Commit: b28ae82f | 2025-08-12 05:56:59+00:00

← Back to List

[EditContext] Prevent redundant selection synchronization to avoid conflicts

Minor
Commit Hash: b28ae82f1b2db7bde36267098fd5236a097efb91
Commit Time: 2025-08-12 05:56:59+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission primarily addresses the issue of text replacement suggestion conflicts caused by redundant selection synchronization in EditContext. The core changes include: 1) At the remote_cocoa layer, replacing the hardcoded NSSpellChecker.sharedSpellChecker with the self.spellChecker property for the spell checker; 2) At the Blink engine layer, avoiding selection synchronization from Editor when EditContext is active, as selection synchronization is handled by EditContext itself; 3) Adding a sync_selection parameter to the EditContext::SetSelection method to prevent unnecessary synchronization during temporary selection adjustments in deletion operations. These changes are mainly intended to fix the issue where suggestions are incorrectly accepted during text input.

🎯 Impact Analysis

The impact on WebView2Mac is minimal. Among the main changes, only the render_widget_host_view_cocoa.mm file is directly related to WebView2Mac’s remote_cocoa dependency. The modification in this file simply replaces the hardcoded NSSpellChecker.sharedSpellChecker call with the use of the self.spellChecker property, which is a minor refactoring that improves code testability and flexibility. Other changes mainly involve the implementation of EditContext in the Blink engine and selection synchronization logic, which do not directly affect the remote_cocoa bridging functionality of WebView2Mac. The remote_cocoa interfaces and behaviors inherited and used by WebView2Mac remain unchanged, so there is no impact on the core functionality of WebView2Mac.

Impacted Classes:

RenderWidgetHostViewCocoa