Fix right-click issue in macOS 26 fullscreen mode
Moderate
Commit Hash:
43525428111510ed162ae729a99e46fec8e7cb16
Commit Time: 2025-08-25 15:01:27+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission adds an experimental fix for macOS 26 to address the issue where right-clicking the tabstrip in fullscreen mode fails to trigger the context menu. The main changes include: 1) Adding swizzle_ns_toolbar_view_hit_test.h/.mm files, which use swizzling of the private NSToolbarView method _hitTestForEvent: to bypass AppKit’s interception of right-click events in fullscreen mode; 2) Invoking the SwizzleNSToolbarViewHitTest() function in the ImmersiveModeTabbedControllerCocoa constructor; 3) The fix is only activated on macOS 26+ and includes logging for failures to aid debugging. This is a partial reimplementation of previous fix attempts, with improvements targeting the DCHECK issue on macOS 13 and compatibility problems with Canary builds.
🎯 Impact Analysis
This change has a moderate potential impact on WebView2Mac. Positive impacts include: 1) If WebView2Mac also uses a similar tabstrip or toolbar layout in fullscreen mode, this fix may improve the responsiveness of its context menus; 2) The fix addresses a system-level issue where NSToolbarView incorrectly intercepts right-click events in fullscreen mode, which may indirectly improve the right-click interaction experience for embedded web content in WebView2Mac. Potential risks include: 1) Swizzling AppKit private methods carries compatibility risks, as future macOS versions may change the internal implementation of NSToolbarView; 2) Although this fix targets only macOS 26+, if WebView2Mac relies on the same Remote Cocoa infrastructure, it may be indirectly affected by this underlying event handling change; 3) Since WebView2Mac requires precise event routing to handle web content interactions, any system-level event handling modifications need to be carefully verified for their impact on embedded web context menu functionality.
Impacted Classes:
ImmersiveModeTabbedControllerCocoa
SwizzleNSToolbarViewHitTest (新增函数)
NSToolbarView (系统类,通过 swizzling 修改)