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

Commit: 75c644e7 | 2026-04-03 21:38:56

← Back to List

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

Minor
Commit Hash: 75c644e76257e7934c05e25befaf19aee6d78a38
Commit Time: 2026-04-03 21:38:56
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

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.

🎯 Impact Analysis

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.

Impacted Classes:

remote_cocoa::NativeWidgetMacNSWindow remote_cocoa::NativeWidgetNSWindowBridge