Revert "Don't allow NSWindow to steal focus from modal window on scrim click"

提交: 75c644e7 | 2026-04-03 21:38:56

← 返回列表

Revert "Don't allow NSWindow to steal focus from modal window on scrim click"

Minor
提交哈希: 75c644e76257e7934c05e25befaf19aee6d78a38
提交时间: 2026-04-03 21:38:56
影响等级: Minor
生成工具: webview2-upstream-sentry
上游审核链接: 查看上游审核 🔗

📋 摘要

This commit reverts commit c197df3fe6ac (Don't allow NSWindow to steal focus from modal window on scrim click) because it caused a compile failure. The reverted code includes:
1. Removed topmostVisibleChildModalWindow method from NativeWidgetMacNSWindow, which iterated child windows to find the topmost visible modal window.
2. Removed NSEventTypeLeftMouseDown handling logic from sendEvent:, which intercepted mouse events when clicks landed on the web contents area with a child modal window present, redirecting focus to the modal window.
3. Removed modal_type() public accessor from NativeWidgetNSWindowBridge header.

🎯 影响分析

The impact of this change on WebView2Mac is minimal. Key analysis:

1. **Reverted code was never in Edge**: Edge repo's NativeWidgetMacNSWindow and NativeWidgetNSWindowBridge do not contain the reverted code (topmostVisibleChildModalWindow method, modal window focus logic in sendEvent:, modal_type() accessor). Therefore this revert has no direct impact on the Edge repo.

2. **Revert restores state consistent with Edge**: The post-revert upstream code is more consistent with the Edge repo's version, reducing differences for future integration.

3. **Modal window focus management relevant to WebView2Mac**: While the reverted fix targeted browser tab-modal dialog focus issues, WebView2Mac also creates modal child windows (e.g., JavaScript alert/confirm dialogs). If this fix is re-submitted in corrected form in the future, it may positively affect WebView2Mac's modal dialog focus behavior.

4. **No integration risk**: This revert introduces no new code and only removes code not yet in Edge, posing no merge conflict risk.

受影响的类:

remote_cocoa::NativeWidgetMacNSWindow remote_cocoa::NativeWidgetNSWindowBridge