Reland "Use property isKeyWindow for key window condition check"

提交: 20ea6a57 | 2025-11-21 17:15:24+00:00

← 返回列表

Reland "Use property isKeyWindow for key window condition check"

Moderate
提交哈希: 20ea6a5784da7b5d9d21a3a7083ea1932643635c
提交时间: 2025-11-21 17:15:24+00:00
影响等级: Moderate
生成工具: webview2-upstream-sentry
上游审核链接: 查看上游审核 🔗

📋 摘要

This commit relands a previously reverted fix that changes the key window status check in the windowDidResignKey method from [NSApp keyWindow] == [self window] to [self window].isKeyWindow. This fix addresses a focus state synchronization issue in multi-window applications: when a user clicks a notification, at the moment the window receives the windowDidResignKey notification, [NSApp keyWindow] may still temporarily point to that window, causing an incorrect early return and leaving WebContents and Blink layers thinking they still have focus, making JavaScript document.hasFocus() incorrectly return true. Using the window.isKeyWindow property correctly detects when the window has actually resigned key status, as this property is updated before windowDidResignKey is called. This fix was previously reverted for breaking