Fix event routing issues in windows with title bars

Commit: 5299d367 | 2025-06-04 18:20:09+00:00

← Back to List

Fix event routing issues in windows with title bars

Moderate
Commit Hash: 5299d367114de65d4c10718060ea4e0f63fa9806
Commit Time: 2025-06-04 18:20:09+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review πŸ”—

πŸ“‹ Summary

This commit fixes a bug in event routing for windows with a title bar. Previously, the bottom area of the window stopped receiving mouse events because the code incorrectly used window or parent view coordinates as view-local coordinates for hit testing. The fix involves two components: BridgedContentView (which hosts the toolkit-views tree) and RenderWidgetHostViewCocoa (which hosts the content area). In the hitTest method of BridgedContentView, logic was added to convert points from parent view coordinates to local coordinates. In RenderWidgetHostViewCocoa, the coordinate conversion issue in the shouldIgnoreMouseEvent method was fixed to ensure hitTest uses the correct coordinate system. This fix is particularly important for windows with a native title bar, as the parent view is taller than the content view in this case.

🎯 Impact Analysis

This fix has a significant positive impact on WebView2Mac. As a control for embedding web content, WebView2Mac relies on Remote Cocoa for window and view management. The issue addressed by this fix directly affects user interaction, especially the handling of mouse events. In windows with a title bar, if the bottom area of the window cannot receive mouse events, certain regions within the WebView2Mac control may not respond to user clicks, severely impacting user experience. This fix ensures that the entire WebView2Mac control area can correctly respond to mouse interactions, improving the control’s usability and reliability. In particular, for scenarios where WebView2Mac needs to handle complex user interfaces or requires precise mouse positioning, this fix prevents potential functional defects. Additionally, since the fix involves underlying coordinate conversion logic, it may also affect the handling of other types of input events, overall enhancing the event processing quality of WebView2Mac.

Impacted Classes:

BridgedContentView RenderWidgetHostViewCocoa