summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2014-01-31 17:24:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-10 21:36:04 +0100
commit331b7fa11c84107e3300b14ece5fc5991cfc35e9 (patch)
tree6f47e11a32de6ef190667d0c12d92f9649e16b03 /src/webengine
parent28acdd2ad14d3a5fecc51b5b4bc9d05b6f80dbb5 (diff)
Add TakeFocus in WebContentsViewQt for passing on tab focus.
Chromium calls RenderViewHostDelegate::TakeFocus when the last focusable item within the page was reached. We then have to move the focus on to the next/previous QQuickItem. Change-Id: Id0128053602ff1220c1bced1b218050b66fef659 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp12
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h6
3 files changed, 18 insertions, 1 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 049e353b..2f5d868e 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -180,6 +180,18 @@ void QQuickWebEngineViewPrivate::runFileChooser(FileChooserMode mode, const QStr
ui()->showFilePicker(mode, defaultFileName, acceptedMimeTypes, adapter);
}
+void QQuickWebEngineViewPrivate::passOnFocus(bool reverse)
+{
+ Q_Q(QQuickWebEngineView);
+ // In one direction we would pass forward the focus to RenderWidgetHostViewQtDelegateQuick(Painted),
+ // which in return would forward the tab key event and therefore the focus back to the QQuickWebEngineView.
+ // This is why we skip RenderWidgetHostViewQtDelegateQuick in the focus chain.
+ QQuickItem* current = QQuickItemPrivate::nextPrevItemInTabFocusChain(q, !reverse);
+ if (!qobject_cast<RenderWidgetHostViewQtDelegateQuick*>(current) && !qobject_cast<RenderWidgetHostViewQtDelegateQuickPainted*>(current))
+ current = q;
+ focusNextPrev(current, !reverse);
+}
+
void QQuickWebEngineViewPrivate::titleChanged(const QString &title)
{
Q_Q(QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 37ac9edf..3de59746 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -141,6 +141,7 @@ public:
virtual void didRunJavaScript(const QVariant&, quint64) Q_DECL_OVERRIDE { }
virtual void didFetchDocumentMarkup(const QString&, quint64) Q_DECL_OVERRIDE { }
virtual void didFetchDocumentInnerText(const QString&, quint64) Q_DECL_OVERRIDE { }
+ virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE;
virtual void javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
void setDevicePixelRatio(qreal);
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index 9dbe7994..8f32689d 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -60,6 +60,10 @@ public:
: ItemBaseT(parent)
, m_client(client)
{
+ this->setFocus(true);
+ this->setActiveFocusOnTab(true);
+ this->setFlag(QQuickItem::ItemIsFocusScope);
+
this->setAcceptedMouseButtons(Qt::AllButtons);
this->setAcceptHoverEvents(true);
}
@@ -143,7 +147,7 @@ public:
void mousePressEvent(QMouseEvent *event)
{
- this->setFocus(true);
+ this->forceActiveFocus();
m_client->forwardEvent(event);
}