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:
parent
9f7a59536c
commit
21d714ab6e
|
@ -233,13 +233,12 @@ bool CefBrowserHostBase::HasView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::SetFocus(bool focus) {
|
void CefBrowserHostBase::SetFocus(bool focus) {
|
||||||
// Always execute asynchronously to work around issue #3040.
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SetFocusInternal,
|
CEF_POST_TASK(CEF_UIT,
|
||||||
this, focus));
|
base::BindOnce(&CefBrowserHostBase::SetFocus, this, focus));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::SetFocusInternal(bool focus) {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
if (focus)
|
if (focus)
|
||||||
OnSetFocus(FOCUS_SOURCE_SYSTEM);
|
OnSetFocus(FOCUS_SOURCE_SYSTEM);
|
||||||
else if (platform_delegate_)
|
else if (platform_delegate_)
|
||||||
|
|
|
@ -337,8 +337,6 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||||
// Called from LoadMainFrameURL to perform the actual navigation.
|
// Called from LoadMainFrameURL to perform the actual navigation.
|
||||||
virtual bool Navigate(const content::OpenURLParams& params);
|
virtual bool Navigate(const content::OpenURLParams& params);
|
||||||
|
|
||||||
void SetFocusInternal(bool focus);
|
|
||||||
|
|
||||||
// Create the CefFileDialogManager if it doesn't already exist.
|
// Create the CefFileDialogManager if it doesn't already exist.
|
||||||
bool EnsureFileDialogManager();
|
bool EnsureFileDialogManager();
|
||||||
|
|
||||||
|
|
|
@ -350,15 +350,12 @@ void CefBrowserPlatformDelegateNativeWin::SetFocus(bool setFocus) {
|
||||||
if (!setFocus)
|
if (!setFocus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (web_contents_) {
|
|
||||||
// Give logical focus to the RenderWidgetHostViewAura in the views
|
|
||||||
// hierarchy. This does not change the native keyboard focus.
|
|
||||||
web_contents_->Focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window_widget_) {
|
if (window_widget_) {
|
||||||
// Give native focus to the DesktopWindowTreeHostWin associated with the
|
// Give native focus to the DesktopWindowTreeHostWin ("Chrome_WidgetWin_0")
|
||||||
// root window.
|
// associated with the root window. The currently focused HWND may be
|
||||||
|
// "CefBrowserWindow" if we're called in response to our WndProc receiving
|
||||||
|
// the WM_SETFOCUS event, or some other HWND if the client calls
|
||||||
|
// CefBrowserHost::SetFocus(true) directly.
|
||||||
//
|
//
|
||||||
// The DesktopWindowTreeHostWin HandleNativeFocus/HandleNativeBlur methods
|
// The DesktopWindowTreeHostWin HandleNativeFocus/HandleNativeBlur methods
|
||||||
// are called in response to WM_SETFOCUS/WM_KILLFOCUS respectively. The
|
// are called in response to WM_SETFOCUS/WM_KILLFOCUS respectively. The
|
||||||
|
@ -369,9 +366,17 @@ void CefBrowserPlatformDelegateNativeWin::SetFocus(bool setFocus) {
|
||||||
// rings, flashing caret, onFocus/onBlur JS events, etc.) to work as
|
// rings, flashing caret, onFocus/onBlur JS events, etc.) to work as
|
||||||
// expected (see issue #1677).
|
// expected (see issue #1677).
|
||||||
// 2. Update focus state of the ui::InputMethod. If this does not occur
|
// 2. Update focus state of the ui::InputMethod. If this does not occur
|
||||||
// then InputMethodBase::GetTextInputClient will return NULL and
|
// then:
|
||||||
// InputMethodWin::OnChar will fail to sent character events to the
|
// (a) InputMethodBase::GetTextInputClient will return NULL and
|
||||||
// renderer (see issue #1700).
|
// InputMethodWin::OnChar will fail to send character events to the
|
||||||
|
// renderer (see issue #1700); and
|
||||||
|
// (b) InputMethodWinBase::IsWindowFocused will return false due to
|
||||||
|
// ::GetFocus() returning the currently focused HWND (e.g.
|
||||||
|
// "CefBrowserWindow") instead of the expected "Chrome_WidgetWin_0" HWND,
|
||||||
|
// causing TSF not to handle IME events (see issue #3306). For this same
|
||||||
|
// reason, ::SetFocus needs to be called before WebContents::Focus which
|
||||||
|
// sends the InputMethod OnWillChangeFocusedClient notification that then
|
||||||
|
// calls IsWindowFocused.
|
||||||
//
|
//
|
||||||
// This differs from activation in Chrome which is handled via
|
// This differs from activation in Chrome which is handled via
|
||||||
// HWNDMessageHandler::PostProcessActivateMessage (Widget::Show indirectly
|
// HWNDMessageHandler::PostProcessActivateMessage (Widget::Show indirectly
|
||||||
|
@ -387,6 +392,13 @@ void CefBrowserPlatformDelegateNativeWin::SetFocus(bool setFocus) {
|
||||||
// discovered.
|
// discovered.
|
||||||
::SetFocus(HWNDForWidget(window_widget_));
|
::SetFocus(HWNDForWidget(window_widget_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (web_contents_) {
|
||||||
|
// Give logical focus to the RenderWidgetHostViewAura in the views
|
||||||
|
// hierarchy. This does not change the native keyboard focus. See above
|
||||||
|
// comments about InputMethod notifications.
|
||||||
|
web_contents_->Focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() {
|
void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() {
|
||||||
|
|
Loading…
Reference in New Issue