Remove the is_headless_mode member flag variable in Mac headless mode

Commit: cd41e985 | 2025-09-22 18:11:22+00:00

← Back to List

Remove the is_headless_mode member flag variable in Mac headless mode

Moderate
Commit Hash: cd41e9851a3ac039dda54f6597b9e6f93dc162a3
Commit Time: 2025-09-22 18:11:22+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission removes the is_headless_mode member flag variable in Mac headless mode. The main changes include: 1) In native_widget_ns_window_bridge.mm, the check for params->is_headless_mode_window is replaced with a call to display::Screen::Get()->IsHeadless(); 2) The is_headless_mode_window field is removed from native_widget_ns_window.mojom; 3) The is_headless_mode_window_ member variable is removed from native_widget_mac_ns_window_host.h/mm, and replaced with a direct call to display::Screen::Get()->IsHeadless(). This change leverages the newly introduced display::Screen::IsHeadless() method, eliminating the complexity of propagating the headless flag throughout the system.

🎯 Impact Analysis

This change has a moderate impact on WebView2Mac. As a core dependency component of WebView2Mac, interface changes related to headless mode in remote_cocoa will directly affect the implementation of WebView2Mac. The specific impacts include: 1) **Mojo Interface Changes**: The is_headless_mode_window field has been removed from the NativeWidgetNSWindowInitParams structure, which means that if WebView2Mac’s HostingNSWindowBridge or other classes inheriting from remote_cocoa components directly use this field, corresponding code updates are required; 2) **Header File Dependency Changes**: WebView2Mac may need to ensure that the display/screen.h header file is included in order to use the new IsHeadless() method; 3) **Implementation Logic Adaptation**: If WebView2Mac also maintains a similar headless state variable in its own implementation, it is recommended to update it to use the unified display::Screen::Get()->IsHeadless() interface; 4) **Impact on Test Scenarios**: Testing and integration in headless mode may need to verify whether the new implementation is consistent with previous behavior. However, since the changes are mainly refactoring in nature and the actual functional logic remains unchanged, there will be no destructive impact on the core functionality of WebView2Mac.

Impacted Classes:

remote_cocoa::mojom::NativeWidgetNSWindowInitParams remote_cocoa::NativeWidgetNSWindowBridge views::NativeWidgetMacNSWindowHost display::Screen