Prevent key view status for specific TopChrome WebUIs
Minor
Commit Hash:
3cc01c9b6a22aee1fee457f29b612c63a7b41dd6
Commit Time: 2026-01-13 00:50:12+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This commit addresses an issue where the Reload WebUI's RenderWidget incorrectly becomes the first key view when entering fullscreen on macOS, causing an unwanted focus ring and stealing focus. The fix delegates the decision of
Specific changes include:
1. Added a new optional method
2. Modified the
3. Implemented this delegate method in the Chrome browser to return YES for specific TopChrome WebUIs (such as Toolbar WebUI)
4. Added the
canBecomeKeyView to the RenderWidgetHost by adding a new delegate method shouldRefuseBecomingKeyView, allowing specific WebUIs to opt out of key view status. This modification does not prevent items from receiving focus via the Views framework (e.g., tabbing), but strictly prevents macOS from automatically assigning key view status to the RenderWidget container.Specific changes include:
1. Added a new optional method
shouldRefuseBecomingKeyView to the RenderWidgetHostViewMacDelegate protocol2. Modified the
canBecomeKeyView method in render_widget_host_view_cocoa.mm to call this delegate method3. Implemented this delegate method in the Chrome browser to return YES for specific TopChrome WebUIs (such as Toolbar WebUI)
4. Added the
ShouldRefuseBecomingKeyViewForTopChromeWebUI helper function to determine if a specific URL should refuse to become the key view
🎯 Impact Analysis
The impact of this change on WebView2Mac is Minor.
**Impact Analysis:**
1. **Interface Extension**: A new optional method
2. **Behavior Change**: The
3. **WebView2Mac Impact**:
- WebView2Mac uses Remote Cocoa's
- WebView2Mac integrates with Remote Cocoa through
- If WebView2Mac's delegate (the
- Since this change primarily targets Chrome browser's TopChrome WebUIs (specifically Toolbar WebUI), and WebView2Mac does not use these specific WebUI components, it will not be directly affected
4. **Potential Opportunity**: If WebView2Mac needs to control whether RenderWidgets become key views in certain scenarios (e.g., to prevent automatic focus stealing), it can optionally implement this new delegate method.
**Conclusion**: This change is a backward-compatible interface extension that will not break WebView2Mac's existing functionality. WebView2Mac can continue to operate normally without requiring immediate action.
**Impact Analysis:**
1. **Interface Extension**: A new optional method
shouldRefuseBecomingKeyView has been added to the RenderWidgetHostViewMacDelegate protocol. Since this is an optional method (marked as @optional), WebView2Mac does not need to implement it immediately and will not encounter compilation errors.2. **Behavior Change**: The
canBecomeKeyView method in render_widget_host_view_cocoa.mm now checks whether the delegate implements the shouldRefuseBecomingKeyView method. If the delegate does not implement this method, the behavior remains unchanged and returns the original value of _canBeKeyView.3. **WebView2Mac Impact**:
- WebView2Mac uses Remote Cocoa's
RenderWidgetHostViewCocoa to manage the NSView for web content- WebView2Mac integrates with Remote Cocoa through
HostingNSWindowBridge and related components- If WebView2Mac's delegate (the
RenderWidgetHostViewMacDelegate implementation) does not implement the new method, behavior remains completely unchanged- Since this change primarily targets Chrome browser's TopChrome WebUIs (specifically Toolbar WebUI), and WebView2Mac does not use these specific WebUI components, it will not be directly affected
4. **Potential Opportunity**: If WebView2Mac needs to control whether RenderWidgets become key views in certain scenarios (e.g., to prevent automatic focus stealing), it can optionally implement this new delegate method.
**Conclusion**: This change is a backward-compatible interface extension that will not break WebView2Mac's existing functionality. WebView2Mac can continue to operate normally without requiring immediate action.
Impacted Classes:
RenderWidgetHostViewMacDelegate
RenderWidgetHostViewCocoa
ChromeRenderWidgetHostViewMacDelegate