Fix C++23 compilation errors on Mac platform

Commit: ef7df6d1 | 2025-10-13 21:04:54+00:00

โ† Back to List

Fix C++23 compilation errors on Mac platform

Minor
Commit Hash: ef7df6d19a66a07556c117447aa02bc5a4ceb575
Commit Time: 2025-10-13 21:04:54+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review ๐Ÿ”—

๐Ÿ“‹ Summary

This submission primarily fixes C++23 compilation errors on the Mac platform. Specifically, it includes two modifications: 1) In chrome/updater/net/network_fetcher_mac.mm, the std::string constructor parameter is replaced from nullptr to std::nullopt, because in C++23 std::string can no longer be constructed from nullptr; 2) In components/remote_cocoa/app_shim/select_file_dialog_bridge.mm, the definition of the SelectFileDialogBridge::ScopedPreventKeyWindow class is moved from the end of the file to before its usage, ensuring that the type is complete when destructing unique_ptr. This is to meet the stricter requirements for incomplete types in C++23.

๐ŸŽฏ Impact Analysis

This change has minimal impact on WebView2Mac. The main impact analysis is as follows: 1) The adjustment of the ScopedPreventKeyWindow class definition location does not alter the functionality or interface of the class, but merely addresses the C++23 compilerโ€™s requirements for type completeness. This class is used to prevent the parent window of the file dialog from becoming the key window, and its functionality remains unchanged; 2) This class is a private inner class of SelectFileDialogBridge, and SelectFileDialogBridge is one of the core remote_cocoa components relied upon by WebView2Mac for handling file selection dialogs; 3) Although the change involves the file selection functionality depended on by WebView2Mac, it is purely a code structure adjustment and does not involve any business logic, interface signatures, or behavioral changes; 4) For downstream WebView2Mac code built with the C++23 compiler, this change will improve build compatibility and avoid potential compilation errors. Overall, this is a positive forward compatibility improvement and will not have any negative impact on existing functionality.

Impacted Classes:

SelectFileDialogBridge SelectFileDialogBridge::ScopedPreventKeyWindow