Implement popup menus using modern APIs, remove legacy usage related to NSPopUpButtonCell
Moderate
Commit Hash:
1786625b694f9848f877ee58bac73df7afd78d3e
Commit Time: 2025-01-22 16:56:38+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission primarily switches the implementation of popup menus from using NSPopUpButtonCell (an older macOS API with some SPI features) to supported modern APIs, and performs cleanup and refactoring of related code. Specifically: parameters and logic related to PopUpButtonCell have been removed from menu controllers such as MenuControllerCocoa, and the menu popup method has been unified; menu positioning logic has been improved to enhance the display effect of popup menus; implementations related to HTML select control popup menus, such as WebMenuRunner, have been rewritten to use a more standard Cocoa menu popup approach; corresponding test code and interface definitions have been adjusted in sync, and special handling related to the old API has been removed.
🎯 Impact Analysis
The impact of this change on WebView2Mac is mainly reflected in the behavior of the HTML select control’s popup menu and the menu-related Remote Cocoa bridging layer. Since WebView2Mac relies on the upstream remote_cocoa menu popup implementation (such as WebMenuRunner, ContextMenuRunner, etc.), switching to the modern API will make the popup menu behavior more consistent with macOS platform standards, improving compatibility and future maintainability. For downstream code such as edge_embedded_browser/client/mac/remote_cocoa/hosting_web_contents_ns_view_bridge that inherits from or calls WebMenuRunner, theoretically no major adaptation is required, but attention should be paid to:
1. The popup menu position and style may have subtle changes; UI consistency should be monitored.
2. If downstream code directly depends on NSPopUpButtonCell-related SPI or hacks, these should be removed or adapted accordingly.
3. Since interface parameters and some method names have been adjusted (such as the menuOpen property, constructor parameters, etc.), downstream custom menu controllers or test code should check for compatibility.
4. This change does not involve signature changes to Mojo interfaces or core bridging classes; overall risk is controllable, but it is recommended to focus regression testing on select popup menu-related functionality.
1. The popup menu position and style may have subtle changes; UI consistency should be monitored.
2. If downstream code directly depends on NSPopUpButtonCell-related SPI or hacks, these should be removed or adapted accordingly.
3. Since interface parameters and some method names have been adjusted (such as the menuOpen property, constructor parameters, etc.), downstream custom menu controllers or test code should check for compatibility.
4. This change does not involve signature changes to Mojo interfaces or core bridging classes; overall risk is controllable, but it is recommended to focus regression testing on select popup menu-related functionality.
Impacted Classes:
WebMenuRunner
ContextMenuRunner
MenuControllerCocoa
MenuControllerCocoaDelegateImpl
remote_cocoa::mojom::MenuHost(间接影响)
remote_cocoa::mojom::Menu(间接影响)