Fix the issue of missing mouse down and up events in the fullscreen top-chrome area

Commit: 8c004781 | 2025-06-02 17:47:44+00:00

← Back to List

Fix the issue of missing mouse down and up events in the fullscreen top-chrome area

Minor
Commit Hash: 8c004781dde7d42d9a3fed8cafcaa4929943dd69
Commit Time: 2025-06-02 17:47:44+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission primarily fixes the issue of lost mouse press and release events in the top-chrome area (top toolbar area) under fullscreen mode. The problem originated from a previous submission (https://crrev.com/c/6574464) that routed mouse press and release events to the NSWindow's contentView. However, in the fullscreen top-chrome area, the contentView is a view managed by AppKit, rather than an NSView hosting views::RootView. This submission resolves the issue through the following modifications:
1. Updated the logic and comments of the hitTest method in bridged_content_view.mm to clarify how NSWindow calls -[contentView hitTest:] to determine the target NSView for mouse events.
2. Renamed the HitTestResult enum value in the mojom interface from kContentView to kRootView to more accurately describe its purpose.
3. Correspondingly updated the usage of the new enum value in native_widget_mac_ns_window_host.mm.
These changes ensure that in immersive fullscreen mode, events are correctly routed to the NSView hosting views::RootView, rather than the AppKit-owned title bar view.

🎯 Impact Analysis

This commit has the following potential impacts on WebView2Mac:
1. **Event Routing Improvements**: Fixed mouse event routing issues in fullscreen mode, which may enhance the mouse interaction experience of WebView2Mac in fullscreen mode.
2. **Interface Changes**: The HitTestResult enumeration has been renamed from kContentView to kRootView. Although this is only a semantic improvement, downstream code in WebView2Mac that directly references this enumeration value may need to be updated accordingly.
3. **hitTest Logic Optimization**: The implementation of the hitTest method has been updated to more accurately determine event targets in different scenarios, which may affect mouse event handling for embedded web content in WebView2Mac.
4. **Immersive Fullscreen Support**: Optimizations have been made specifically for immersive fullscreen mode. If WebView2Mac supports or plans to support fullscreen mode, this fix will be beneficial.
Since WebView2Mac relies on Remote Cocoa for NSWindow and NSView management, these event routing improvements should enhance the stability and accuracy of user interactions.

Impacted Classes:

BridgedContentView NativeWidgetMacNSWindowHost HitTestResult