Fix issues with browser focus assignment (fixes issue #3306, fixes issue #3116, see issue #3040)

DesktopWindowTreeHostWin ("Chrome_WidgetWin_0") focus needs to be set
synchronously in response to the parent window WM_SETFOCUS message and
before the associated call to WebContents::Focus. See updated comments in
CefBrowserPlatformDelegateNativeWin::SetFocus.
This commit is contained in:
Marshall Greenblatt
2022-08-05 14:58:31 -04:00
parent 9f7a59536c
commit 21d714ab6e
3 changed files with 28 additions and 19 deletions

View File

@@ -233,13 +233,12 @@ bool CefBrowserHostBase::HasView() {
}
void CefBrowserHostBase::SetFocus(bool focus) {
// Always execute asynchronously to work around issue #3040.
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SetFocusInternal,
this, focus));
}
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostBase::SetFocus, this, focus));
return;
}
void CefBrowserHostBase::SetFocusInternal(bool focus) {
CEF_REQUIRE_UIT();
if (focus)
OnSetFocus(FOCUS_SOURCE_SYSTEM);
else if (platform_delegate_)