Windows: Fix focus assignment when clicking WebView with external parent (fixes issue #3031)

This commit is contained in:
Marshall Greenblatt 2020-10-27 14:43:10 -04:00
parent 6a525748c4
commit 4e6c558bf2
2 changed files with 23 additions and 2 deletions

View File

@ -103,7 +103,10 @@ patches = [
# #
# Support configuration of RWHVGuest device scale factor. # Support configuration of RWHVGuest device scale factor.
# https://bitbucket.org/chromiumembedded/cef/issues/2078 # https://bitbucket.org/chromiumembedded/cef/issues/2078
'name': 'views_widget_180_1481_1565_1677_1749', #
# Windows: Fix focus assignment when clicking WebView with external parent.
# https://bitbucket.org/chromiumembedded/cef/issues/3031
'name': 'views_widget',
}, },
{ {
# Allow specification of a custom WebContentsView. # Allow specification of a custom WebContentsView.

View File

@ -73,7 +73,7 @@ index 5b2aa87a53fa..302626b947c6 100644
FRIEND_TEST_ALL_PREFIXES( FRIEND_TEST_ALL_PREFIXES(
BrowserSideFlingBrowserTest, BrowserSideFlingBrowserTest,
diff --git content/browser/renderer_host/render_widget_host_view_event_handler.cc content/browser/renderer_host/render_widget_host_view_event_handler.cc diff --git content/browser/renderer_host/render_widget_host_view_event_handler.cc content/browser/renderer_host/render_widget_host_view_event_handler.cc
index b49d2f96efec..080a49940263 100644 index b49d2f96efec..d6308880de1b 100644
--- content/browser/renderer_host/render_widget_host_view_event_handler.cc --- content/browser/renderer_host/render_widget_host_view_event_handler.cc
+++ content/browser/renderer_host/render_widget_host_view_event_handler.cc +++ content/browser/renderer_host/render_widget_host_view_event_handler.cc
@@ -37,6 +37,10 @@ @@ -37,6 +37,10 @@
@ -102,6 +102,24 @@ index b49d2f96efec..080a49940263 100644
#endif #endif
synthetic_move_position_ = center_in_screen; synthetic_move_position_ = center_in_screen;
} }
@@ -985,6 +997,17 @@ bool RenderWidgetHostViewEventHandler::MatchesSynthesizedMovePosition(
}
void RenderWidgetHostViewEventHandler::SetKeyboardFocus() {
+#if defined(OS_WIN)
+ if (host_view_->HasExternalParent() &&
+ window_ && window_->delegate()->CanFocus()) {
+ aura::WindowTreeHost* host = window_->GetHost();
+ if (host) {
+ gfx::AcceleratedWidget hwnd = host->GetAcceleratedWidget();
+ if (!(::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE))
+ ::SetFocus(hwnd);
+ }
+ }
+#endif
// TODO(wjmaclean): can host_ ever be null?
if (host_ && set_focus_on_mouse_down_or_key_event_) {
set_focus_on_mouse_down_or_key_event_ = false;
diff --git content/public/browser/render_widget_host_view.h content/public/browser/render_widget_host_view.h diff --git content/public/browser/render_widget_host_view.h content/public/browser/render_widget_host_view.h
index beba7a3a40b8..941acdfbff8b 100644 index beba7a3a40b8..941acdfbff8b 100644
--- content/public/browser/render_widget_host_view.h --- content/public/browser/render_widget_host_view.h