mac: Route mouse up/down events to the view of the overlay content area

提交: 420b0efb | 2025-05-28 17:07:37+00:00

← 返回列表

mac: Route mouse up/down events to the view of the overlay content area

Moderate
提交哈希: 420b0efb4a166e8de71f818cbee3e43c7edf797d
提交时间: 2025-05-28 17:07:37+00:00
影响等级: Moderate
生成工具: webview2-upstream-sentry
上游审核链接: 查看上游审核 🔗

📋 摘要

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.

🎯 影响分析

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.

受影响的类:

BridgedContentView NativeWidgetMacNSWindowHost remote_cocoa::mojom::NativeWidgetNSWindowHost NativeViewHost