Simplify constrainFrameRect to always return original frame rect
Minor
Commit Hash:
ecca6d0cd3491aa8befe65d980848aa390874997
Commit Time: 2025-11-19 19:39:52+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This commit modifies the -constrainFrameRect:toScreen: method implementation in NativeWidgetMacNSWindow. The previous implementation included conditional logic to avoid AppKit's menu bar collision handling only for headless windows and macOS 26+. The new code maintains special handling for headless windows but removes the macOS 26+ specific conditional branch, allowing the parent class method to handle it uniformly. Additionally, the commit fixes a related views unit test by removing the views_test_base_mac.mm file and updating test code to directly use the anchor_rect_in_screen parameter instead of relying on the GetSystemReservedHeightAtTopOfScreen() method for coordinate adjustment.
🎯 Impact Analysis
This change has a minor to moderate impact on WebView2Mac. The main impact points are:
1. **Window Positioning Behavior Change**: The constrainFrameRect method is used to constrain the window frame rectangle to fit within screen boundaries. Previously, the code directly returned the original frameRect on macOS 26+, but now it calls the parent class implementation. This may affect the positioning behavior of child windows (such as Omnibox, find bar, date picker, etc.) in fullscreen or maximized states.
2. **Potential Impact on WebView2Mac**: WebView2Mac manages windows by inheriting from NativeWidgetNSWindowBridge. If there are child windows with large shadows in WebView2Mac (similar to Omnibox), the positioning of these windows in fullscreen or maximized states may be affected. Since the host window of WebView2Mac is not controlled by Chromium, this change may affect the positioning behavior of child windows relative to the host window.
3. **Headless Windows Remain Unchanged**: For headless windows, the behavior remains unchanged - they still directly return the original frameRect without AppKit constraints.
4. **Test Framework Impact**: The removal of the GetSystemReservedHeightAtTopOfScreen() method indicates that the test framework no longer needs to account for the system-reserved height at the top of the screen. This simplifies test logic, but also means that test assumptions related to screen coordinates may need to be re-verified.
Overall, this change aims to fix unexpected shifting of the Omnibox in maximized windows with Vertical Tabs on older macOS versions. For WebView2Mac, it's necessary to verify that child window positioning still behaves as expected in various window states (fullscreen, maximized), especially for child windows with shadow effects.
1. **Window Positioning Behavior Change**: The constrainFrameRect method is used to constrain the window frame rectangle to fit within screen boundaries. Previously, the code directly returned the original frameRect on macOS 26+, but now it calls the parent class implementation. This may affect the positioning behavior of child windows (such as Omnibox, find bar, date picker, etc.) in fullscreen or maximized states.
2. **Potential Impact on WebView2Mac**: WebView2Mac manages windows by inheriting from NativeWidgetNSWindowBridge. If there are child windows with large shadows in WebView2Mac (similar to Omnibox), the positioning of these windows in fullscreen or maximized states may be affected. Since the host window of WebView2Mac is not controlled by Chromium, this change may affect the positioning behavior of child windows relative to the host window.
3. **Headless Windows Remain Unchanged**: For headless windows, the behavior remains unchanged - they still directly return the original frameRect without AppKit constraints.
4. **Test Framework Impact**: The removal of the GetSystemReservedHeightAtTopOfScreen() method indicates that the test framework no longer needs to account for the system-reserved height at the top of the screen. This simplifies test logic, but also means that test assumptions related to screen coordinates may need to be re-verified.
Overall, this change aims to fix unexpected shifting of the Omnibox in maximized windows with Vertical Tabs on older macOS versions. For WebView2Mac, it's necessary to verify that child window positioning still behaves as expected in various window states (fullscreen, maximized), especially for child windows with shadow effects.
Impacted Classes:
NativeWidgetMacNSWindow
remote_cocoa::NativeWidgetNSWindowBridge
ViewsTestBase