Add WidgetObserver notifications for macOS sheet modal window show/close
Moderate
提交哈希:
3940dc26e01e5414bbd44b17a356c22bb9efae28
提交时间: 2025-10-20 18:47:39+00:00
影响等级: Moderate
生成工具: webview2-upstream-sentry
上游审核链接:
查看上游审核 🔗
📋 摘要
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.
🎯 影响分析
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.
受影响的类:
NativeWidgetNSWindowHost
NativeWidgetNSWindowBridge
ViewsNSWindowDelegate
Widget
WidgetObserver