Remove the is_headless_mode member flag variable in Mac headless mode

提交: cd41e985 | 2025-09-22 18:11:22+00:00

← 返回列表

Remove the is_headless_mode member flag variable in Mac headless mode

Moderate
提交哈希: cd41e9851a3ac039dda54f6597b9e6f93dc162a3
提交时间: 2025-09-22 18:11:22+00:00
影响等级: Moderate
生成工具: webview2-upstream-sentry
上游审核链接: 查看上游审核 🔗

📋 摘要

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.

🎯 影响分析

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.

受影响的类:

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