mac: Route mouse up/down events to the view of the overlay content area
Moderate
Commit Hash:
420b0efb4a166e8de71f818cbee3e43c7edf797d
Commit Time: 2025-05-28 17:07:37+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission modifies the mouse event routing mechanism on macOS, resolving the issue where views overlaying the content area (hosted in a view::WebView) could not receive mouse up and down events. The main changes include: 1) Overriding the event routing logic in the hitTest: method of BridgedContentView; 2) Replacing the original GetIsDraggableBackgroundAt() method with a more comprehensive GetHitTestResult() method, which returns four different hit test results (draggable background, content view, subview, other); 3) Enhancing the hit test logic in NativeWidgetMacNSWindowHost, especially for handling NativeViewHost, enabling correct recognition of embedded subviews. This change ensures that mouse events are correctly routed to the appropriate target views.
🎯 Impact Analysis
This change has a significant positive impact on WebView2Mac. As WebView2Mac is a control for embedding web content, it is likely to be embedded into the toolkit-views tree as a NativeViewHost. This change substantially improves the mouse event routing mechanism, specifically: 1) It fixes the issue where overlay views could not receive mouse events, directly enhancing the interactivity of upper-layer UI controls on WebView2Mac; 2) The enhanced hit testing logic can correctly identify NativeViewHost, ensuring that the WebView2Mac control can receive mouse events that it should handle; 3) The new HitTestResult enumeration provides more precise event categorization, helping WebView2Mac better handle different types of user interactions. These improvements will enhance the user experience and functional stability of WebView2Mac, especially in scenarios involving mouse interactions.
Impacted Classes:
BridgedContentView
NativeWidgetMacNSWindowHost
remote_cocoa::mojom::NativeWidgetNSWindowHost
NativeViewHost