Fix misplaced omnibox popup due to macOS 26 window rect constraints

Commit: 45af5838 | 2025-11-12 05:11:07+00:00

← Back to List

Fix misplaced omnibox popup due to macOS 26 window rect constraints

Moderate
Commit Hash: 45af583888facfc9bf95ca1cbd6d6169bf5ac3e5
Commit Time: 2025-11-12 05:11:07+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit fixes the misplaced Omnibox popup issue caused by new child NSWindow positioning restrictions in macOS 26. macOS 26 adds new constraints to child window positioning: in fullscreen mode, it prevents child windows from entering the titlebar and menubar areas; in non-fullscreen mode, it prevents child windows from overlapping the window border. This becomes problematic for the Omnibox popup, which has a shadow area that enters these restricted zones. The fix overrides -constrainFrameRect:toScreen: in the NativeWidgetMacNSWindow base class to remove these restrictions. Previously, this fix was only applied to the overlay widget used in fullscreen mode, but now it has been extended to all child windows (including the Omnibox popup). The change moves the constrainFrameRect override from the NativeWidgetMacOverlayNSWindow subclass to the NativeWidgetMacNSWindow base class and removes the duplicate code from the overlay window.

🎯 Impact Analysis

This change has a moderate impact on WebView2Mac. WebView2Mac's HostingNSWindowBridge inherits from remote_cocoa::NativeWidgetNSWindowBridge and uses NativeWidgetMacNSWindow as its window implementation. This change modifies the constrainFrameRect:toScreen: method of NativeWidgetMacNSWindow, which controls window positioning constraints on screen.

Specific impacts include:
1. **Window Positioning Behavior Changes**: On macOS 26, all child windows created by WebView2Mac (such as popups, dropdown menus, tooltips, etc.) will bypass system window position restrictions. This may change the positioning behavior of these windows in both fullscreen and non-fullscreen modes.
2. **Compatibility with Host Applications**: WebView2Mac windows can now be positioned more freely and may overlap with the host application window's borders or macOS system UI elements. This could affect visual presentation or user experience.
3. **Headless Mode Protection**: The code preserves special handling for headless windows (not constrained to screen), which is important for WebView2Mac's headless testing scenarios.
4. **Potential Layout Issues**: If WebView2Mac relies on the system's default window constraints to ensure child windows don't exceed visible areas, this change may cause some child windows to be positioned incorrectly.

Recommendation: The WebView2Mac team should test all types of child windows (popup menus, autocomplete dropdowns, tooltips, dialogs, etc.) on macOS 26 to ensure they are correctly positioned in both fullscreen and non-fullscreen modes, without unexpected overlapping or positioning issues. Special attention should be paid to windows with shadow effects, as these windows occupy more area than their visible content.

Impacted Classes:

NativeWidgetMacNSWindow NativeWidgetMacOverlayNSWindow remote_cocoa::NativeWidgetNSWindowBridge