Support setting corner radius for Widget on macOS

Commit: 346115be | 2025-04-01 18:47:14+00:00

← Back to List

Support setting corner radius for Widget on macOS

Moderate
Commit Hash: 346115be8dac9ca4c2185ba1a81f66a5e58a3ef8
Commit Time: 2025-04-01 18:47:14+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission primarily implements the effect of Widget::InitParams::corner_radius on the macOS platform. Specifically, a corner mask is added to the content view of NSWindow, enabling the window content to display rounded corners. At the same time, the logic for drawing rounded corners in the glic window background is removed to avoid display issues on Windows due to limited system support. Additionally, the relevant Mojo interface (NativeWidgetNSWindow.mojom) and the bridging class in remote_cocoa (NativeWidgetNSWindowBridge) have also been updated to support the corner_radius parameter, ensuring the transmission and application of rounded corner parameters across processes and platforms.

🎯 Impact Analysis

This change has a moderate impact on WebView2Mac. The reasons are as follows:
1. The signature of the CreateContentView method in the remote_cocoa::mojom::NativeWidgetNSWindow interface has changed, with the addition of an optional corner_radius parameter. If WebView2Mac downstream directly implements or calls this interface, it needs to adapt to this parameter accordingly; otherwise, compilation errors or inconsistent runtime behavior may occur.
2. The CreateContentView method in the remote_cocoa::NativeWidgetNSWindowBridge class has also added the corner_radius parameter, and the implementation applies a corner mask to the NSView’s layer. If WebView2Mac inherits or overrides this class/method, it must ensure consistency in parameters and behavior; otherwise, the display of window content corners may be affected.
3. This change improves the controllability and consistency of window corners on macOS, which benefits the visual consistency of WebView2Mac. However, if there is custom corner logic downstream, attention should be paid to conflicts or duplication with the new upstream implementation.
4. Since changes to interface and method signatures are high-risk dependencies, it is recommended that WebView2Mac promptly adapt to these changes and focus on testing the display effect of window content corners.

Impacted Classes:

remote_cocoa::mojom::NativeWidgetNSWindow remote_cocoa::NativeWidgetNSWindowBridge remote_cocoa::mojom::NativeWidgetNSWindowInitParams