NativeWidgetNSWindowBridge: Remove window_visible_ member, replace with NSWindow.visible
Moderate
提交哈希:
91a1300a7013ce73936747d5a7ff2ee38cbf2bf8
提交时间: 2026-05-02 16:23:55
影响等级: Moderate
生成工具: chromium-watcher
上游审核链接:
查看上游审核 🔗
📋 摘要
This commit removes the window_visible_ member variable and its window_visible() accessor from NativeWidgetNSWindowBridge,
replacing all references with direct queries to window_.visible (i.e., -[NSWindow isVisible]). It also removes dead code in
OnVisibilityChanged() where the branch (parent_ && !window_visible_) could never be true since window_visible_ was just set
to true. Additionally, it simplifies NotifyVisibilityChangeDown() by removing the visibility check before calling
-[NSWindow orderOut:], since child windows cannot be visible when the parent is not visible, and orderOut: is a no-op on
non-visible windows.
replacing all references with direct queries to window_.visible (i.e., -[NSWindow isVisible]). It also removes dead code in
OnVisibilityChanged() where the branch (parent_ && !window_visible_) could never be true since window_visible_ was just set
to true. Additionally, it simplifies NotifyVisibilityChangeDown() by removing the visibility check before calling
-[NSWindow orderOut:], since child windows cannot be visible when the parent is not visible, and orderOut: is a no-op on
non-visible windows.
🎯 影响分析
This commit has moderate impact on WebView2Mac. Details:
1. **Compilation conflicts**: The Edge downstream still references window_visible_ in ~20 locations across
native_widget_ns_window_bridge.h/.mm, including the member declaration, accessor, and numerous usage sites.
The upstream removal of this member will cause compilation errors during merge, requiring replacement of all
window_visible_ references with window_.visible.
2. **Downstream-specific code conflict**: Edge's ShowAsModalSheet() contains code not present upstream:
This "pretends" the window is visible before the sheet animation begins. Upstream had already removed this
behavior in a prior commit, but downstream still retains it. After window_visible_ is removed, this will
fail to compile and cannot be trivially replaced with window_.visible (which is a read-only NSWindow property
query). The team must evaluate whether to drop this pretend-visible logic (as upstream did) or find an alternative.
3. **Semantic change**: Switching from a cached bool to live NSWindow property queries means visibility checks
always reflect AppKit's real-time state rather than a snapshot from the last OnVisibilityChanged() callback.
For WebView2Mac's cross-process window management, this should be more correct behavior, but timing
dependencies on cached values should be verified in the WebView2 host process model.
4. **Edge-specific patch areas**: The file contains multiple BUILDFLAG(MICROSOFT_EDGE_BRANDING) and
BUILDFLAG(ENABLE_EMBEDDED_BROWSER_WEBVIEW) guarded code blocks, but none of them directly reference
window_visible_, so they are not directly affected.
1. **Compilation conflicts**: The Edge downstream still references window_visible_ in ~20 locations across
native_widget_ns_window_bridge.h/.mm, including the member declaration, accessor, and numerous usage sites.
The upstream removal of this member will cause compilation errors during merge, requiring replacement of all
window_visible_ references with window_.visible.
2. **Downstream-specific code conflict**: Edge's ShowAsModalSheet() contains code not present upstream:
window_visible_ = true; host_->OnVisibilityChanged(window_visible_);This "pretends" the window is visible before the sheet animation begins. Upstream had already removed this
behavior in a prior commit, but downstream still retains it. After window_visible_ is removed, this will
fail to compile and cannot be trivially replaced with window_.visible (which is a read-only NSWindow property
query). The team must evaluate whether to drop this pretend-visible logic (as upstream did) or find an alternative.
3. **Semantic change**: Switching from a cached bool to live NSWindow property queries means visibility checks
always reflect AppKit's real-time state rather than a snapshot from the last OnVisibilityChanged() callback.
For WebView2Mac's cross-process window management, this should be more correct behavior, but timing
dependencies on cached values should be verified in the WebView2 host process model.
4. **Edge-specific patch areas**: The file contains multiple BUILDFLAG(MICROSOFT_EDGE_BRANDING) and
BUILDFLAG(ENABLE_EMBEDDED_BROWSER_WEBVIEW) guarded code blocks, but none of them directly reference
window_visible_, so they are not directly affected.
受影响的类:
remote_cocoa::NativeWidgetNSWindowBridge