Fix download bubble closure issue in macOS fullscreen windows and enhance event monitoring functionality
Moderate
Commit Hash:
bdd2c586f7ff4b0d5f5e9f25dc4dc8477904c69b
Commit Time: 2025-09-29 17:00:23+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission addresses the issue where the download bubble could not be properly closed in the macOS fullscreen window environment. The main changes include: 1) Modifying the download toolbar UI controller to monitor the top-level window instead of the direct parent window, ensuring that the entire browser window can be monitored in immersive fullscreen mode; 2) Unifying the macOS EventMonitor implementation to keep it consistent with the Aura implementation, supporting event monitoring for the target window as well as all its child and descendant windows, rather than only events directly targeting the window itself; 3) Updating the relevant Mojo interface and event handling method parameter naming, changing target_is_this_window to target_is_this_window_or_descendant to more accurately reflect the functionality; 4) Adding logic to traverse the parent window hierarchy in event monitoring, checking through the NSWindow.parentWindow chain whether the event originates from the target window or its descendant windows.
🎯 Impact Analysis
This change has a significant positive impact on WebView2Mac. Since WebView2Mac inherits from the remote_cocoa::NativeWidgetNSWindowBridge class and utilizes the DispatchMonitorEvent method from the remote_cocoa::mojom::NativeWidgetNSWindowHost interface, this update enhances WebView2Mac’s event handling capabilities. Specific impacts include: 1) Improved event monitoring scope: WebView2Mac can now more accurately monitor events from its window and subwindows, which is especially useful for complex window hierarchies such as WebView2 controls containing multiple NSViews; 2) Better fullscreen mode support: In macOS fullscreen or immersive modes, WebView2Mac’s event handling will be more reliable, particularly in scenarios that require monitoring user input events; 3) Enhanced interface consistency: The renaming of Mojo interface parameters makes the code clearer, aiding in the understanding and maintenance of WebView2Mac’s event handling logic; 4) Potential compatibility improvements: As WebView2Mac relies on upstream event monitoring mechanisms, these enhancements may reduce issues of event loss or misprocessing under certain macOS window configurations. Overall, this is a backward-compatible improvement that does not break existing functionality, while enhancing the accuracy and reliability of event handling.
Impacted Classes:
remote_cocoa::NativeWidgetNSWindowBridge
remote_cocoa::mojom::NativeWidgetNSWindowHost
views::NativeWidgetMacEventMonitor::Client
ui::views::EventMonitor
views::NativeWidgetMacNSWindowHost