MacViews Add CATransaction V2 live resize mechanism

提交: 43f25553 | 2026-05-04 16:17:33

← 返回列表

MacViews Add CATransaction V2 live resize mechanism

Moderate
提交哈希: 43f255534bdde25ea5ff3c3f6c9a9d3848e37c39
提交时间: 2026-05-04 16:17:33
影响等级: Moderate
生成工具: chromium-watcher
上游审核链接: 查看上游审核 🔗

📋 摘要

This commit introduces a new CATransaction V2 mechanism for macOS live window resizing (drag-to-resize), controlled by the kCATransactionV2 feature flag (disabled by default). The core idea: reject automatic window resizing in NSWindowDelegate's windowWillResize, instead notify the compositor to produce a frame at the new size, then atomically call [NSWindow setFrame:] once the compositor frame arrives — eliminating flicker where window content and frame are out of sync. Key changes: NativeWidgetNSWindowBridge gains a public OnLiveResizeToFrame() method, private SendWindowFrameChangeToHost() method, and LiveResizeState struct; SetCALayerParams() adds logic to atomically apply the window frame when the matching compositor frame arrives; UpdateWindowGeometry() skips reading the window frame during live resize; ViewsNSWindowDelegate uses NSWindow private SPI liveResizeEdges to determine drag direction.

🎯 影响分析

The impact on WebView2Mac is moderate. While the feature flag is disabled by default and won't activate the new behavior immediately, the changes touch critical base class methods in NativeWidgetNSWindowBridge that are central to WebView2's rendering pipeline:

1. SetCALayerParams() is the core rendering method for WebView2 (GPU → Host → Bridge → CALayer). The new live_resize_ state check and [window_ setFrame:] call will activate when the flag is enabled. WebView2's HostingNSWindowBridge does NOT own the NSWindow (it belongs to the hosting app), so directly calling [window_ setFrame:] could conflict with the host app's window management.

2. UpdateWindowGeometry() adds an early return when live_resize_ is active, which could affect the timing of host_->OnWindowGeometryChanged() — a critical Mojo callback for Bridge-Host communication.

3. SendWindowFrameChangeToHost() refactors the Host notification logic previously in UpdateWindowGeometry(), changing how content_dip_size_ is updated.

4. ViewsNSWindowDelegate's windowWillResize:toSize: now uses private SPI [NSWindow liveResizeEdges]. In WebView2 embedded mode, whether the host app's window supports this SPI needs verification.

When kCATransactionV2 is eventually enabled, WebView2Mac's HostingNSWindowBridge may need to override OnLiveResizeToFrame() or the live-resize portions of SetCALayerParams() to avoid calling setFrame: on a window it doesn't own. Recommend proactive evaluation and adding WebView2-mode guard logic before the flag is enabled.

受影响的类:

remote_cocoa::NativeWidgetNSWindowBridge ViewsNSWindowDelegate remote_cocoa::NativeWidgetNSWindowBridge::LiveResizeState