Add WidgetObserver notifications for macOS sheet modal window show/close

Commit: 3940dc26 | 2025-10-20 18:47:39+00:00

← Back to List

Add WidgetObserver notifications for macOS sheet modal window show/close

Moderate
Commit Hash: 3940dc26e01e5414bbd44b17a356c22bb9efae28
Commit Time: 2025-10-20 18:47:39+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit adds a notification mechanism for the display and closure of sheet modal windows (such as file pickers) on macOS. The main changes include: adding windowWillBeginSheet and windowDidEndSheet listener methods in ViewsNSWindowDelegate; introducing OnSheetModalShown and OnSheetModalClosed methods in the remote_cocoa Mojo interface; implementing the OnWindowModalVisibilityChanged method at the Widget level to trigger the corresponding WidgetObserver callback. This enables non-Views sheet modal windows (such as file pickers), which previously could not trigger the WidgetObserver::OnWidgetWindowModalVisibilityChanged notification, to now correctly trigger this notification.

🎯 Impact Analysis

This change has a significant positive impact on WebView2Mac. WebView2Mac relies heavily on the remote_cocoa component, particularly by inheriting NativeWidgetNSWindowBridge and implementing the NativeWidgetNSWindowHost interface. The newly added sheet modal window notification mechanism provides WebView2Mac with more comprehensive window state management capabilities. Specific impacts include: 1) The host application of WebView2Mac can now receive notifications of the display/closure of sheet modal windows (such as file pickers) via WidgetObserver, improving the completeness of event handling; 2) Since WebView2Mac inherits the relevant interfaces, it automatically gains these new features without requiring additional code modifications; 3) This enhances the integration of WebView2Mac with the native macOS window system, especially in terms of consistency when handling system-level modal windows such as file selection and print dialogs. This change does not break existing functionality, but rather expands the feature set.

Impacted Classes:

NativeWidgetNSWindowHost NativeWidgetNSWindowBridge ViewsNSWindowDelegate Widget WidgetObserver