Popup Menu Modernization Cleanup (Not Switched to New API)
Minor
Commit Hash:
e08093dc66512c3b822d9a3b072ca6a6bcb4cfe2
Commit Time: 2025-03-17 01:50:41+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission primarily modernizes and cleans up code related to popup menus, without switching to the new API. Specifically: 1) WebMenuRunner now supports testing via explicit test callbacks, eliminating the need for external code to intervene in the internal implementation through NSView swizzling; 2) The useWithPopUpButtonCell parameter has been removed from MenuControllerCocoa, as WebMenuRunner constructs the menu itself and the parameter was not actually used; 3) The default -init constructor of MenuControllerCocoa has been removed, now requiring the menu model to be passed in during initialization and the menu to be constructed immediately, simplifying lifecycle management; 4) Modernization of code style and structure. Related files include remote_cocoa context_menu_runner.mm, web_menu_runner_mac.h/mm, etc.
🎯 Impact Analysis
These changes are primarily code cleanup and interface simplification related to popup menus, without modifying the core interfaces of remote_cocoa, the Mojo protocol, or the NSWindow/NSView bridging mechanism. The remote_cocoa::WebMenuRunner interfaces relied upon by WebView2Mac have undergone some API adjustments (such as the method for registering test callbacks), but these changes will not affect the normal functionality or performance of WebView2Mac. The only point to note is that if downstream code directly calls the useWithPopUpButtonCell parameter of MenuControllerCocoa or relies on its default constructor, corresponding adaptations will be required. Overall, these changes improve code robustness and maintainability, with minimal impact on WebView2Mac.
Impacted Classes:
WebMenuRunner
MenuControllerCocoa
ContextMenuRunner