summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_view_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-03-21 11:19:09 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-03-21 11:53:14 +0000
commitc8d11a21c648e87f3560042e1c022f031a6e6519 (patch)
treed8885fb28dd423258abc4eeadbdd7157c7b5c6c5 /src/core/web_contents_view_qt.cpp
parent01c763c83d0c846164dcb5b69b9343e6ee2ac0b7 (diff)
Fixup focus implementation
Follow the other implementation and pass TakeFocus to WebContents Delegate, and hook to our UI from there. Also fixes use of Blur instead of LostFocus, which means we now render unfocused more correctly. Change-Id: I34a1882489bc68b9ff36ed5139af0ee8a3a95b79 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/core/web_contents_view_qt.cpp')
-rw-r--r--src/core/web_contents_view_qt.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index 3c4465ae3..7e0275aa0 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -51,6 +51,7 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/context_menu_params.h"
#include <ui/gfx/image/image_skia.h>
@@ -128,6 +129,22 @@ void WebContentsViewQt::SetInitialFocus()
Focus();
}
+void WebContentsViewQt::FocusThroughTabTraversal(bool reverse)
+{
+ content::WebContentsImpl *web_contents = static_cast<content::WebContentsImpl*>(m_webContents);
+ if (web_contents->ShowingInterstitialPage()) {
+ web_contents->GetInterstitialPage()->FocusThroughTabTraversal(reverse);
+ return;
+ }
+ content::RenderWidgetHostView *fullscreen_view = web_contents->GetFullscreenRenderWidgetHostView();
+ if (fullscreen_view) {
+ fullscreen_view->Focus();
+ return;
+ }
+ web_contents->GetRenderViewHost()->SetInitialFocus(reverse);
+}
+
+
ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::WebContextMenuData::kMediaTypeNone)
ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::WebContextMenuData::kMediaTypeImage)
ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::WebContextMenuData::kMediaTypeVideo)
@@ -247,25 +264,22 @@ void WebContentsViewQt::UpdateDragCursor(blink::WebDragOperation dragOperation)
#endif // QT_CONFIG(draganddrop)
}
-void WebContentsViewQt::TakeFocus(bool reverse)
+void WebContentsViewQt::GotFocus(content::RenderWidgetHostImpl* render_widget_host)
{
- m_client->passOnFocus(reverse);
+ content::WebContentsImpl *web_contents = static_cast<content::WebContentsImpl*>(m_webContents);
+ web_contents->NotifyWebContentsFocused(render_widget_host);
}
-void WebContentsViewQt::FocusThroughTabTraversal(bool reverse)
+void WebContentsViewQt::LostFocus(content::RenderWidgetHostImpl* render_widget_host)
{
content::WebContentsImpl *web_contents = static_cast<content::WebContentsImpl*>(m_webContents);
- if (web_contents->ShowingInterstitialPage()) {
- web_contents->GetInterstitialPage()->FocusThroughTabTraversal(reverse);
- return;
- }
- content::RenderWidgetHostView *fullscreen_view = web_contents->GetFullscreenRenderWidgetHostView();
- if (fullscreen_view) {
- fullscreen_view->Focus();
- return;
- }
- web_contents->GetRenderViewHost()->SetInitialFocus(reverse);
+ web_contents->NotifyWebContentsLostFocus(render_widget_host);
}
+void WebContentsViewQt::TakeFocus(bool reverse)
+{
+ if (m_webContents->GetDelegate())
+ m_webContents->GetDelegate()->TakeFocus(m_webContents, reverse);
+}
} // namespace QtWebEngineCore