diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2019-11-12 10:57:12 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2020-01-24 12:31:50 +0100 |
commit | ffdf7eceed26c99c81accaf1529024bd0bf40f44 (patch) | |
tree | a25914e8fa450622d31d146e00cbf8803085ff73 /src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h | |
parent | 08cad56d16ce56a89ae98f6f8a6589d3cc369e6b (diff) |
Fix widget accessibility on macOS
macOS Accessibility queries the window for the focused accessibility
element. The window forwards the query to the widget with active focus.
This widget is the RWHVQtDelegateWidget if a web element is focused
in QWebEngineView. Therefore, a QAccessibleWidget interface has been
implemented for the RWHVQtDelegateWidget to forward the request to the
QWebEngineView.
The focused accessibility element expected to be returned by the
QAccessibleInterface::focusChild() method. In case of the macOS accessibility
backend, it is called by the accessibilityFocusedUIElement() NSAccessibility
API function. It expects the focused web accessibility element otherwise
VoiceOver won't focus properly.
The focused web accessiblity element is looked up by the new
BrowserAccessibilityQt::focusChild() method.
RenderWidgetHostviewQtDelegateWidget::focusChild() and
QWebengineViewAccessible::focusChild() methods have been also implemented
to forward it.
This patch depends on a focusChild() fix in qtbase:
a132e02540 Fix QAccessibleWidget::focusChild() to return focused descendant
Microsoft Narrator also uses focusChild() to query the current focused
element when it starts but it is still functional without this fix.
Task-number: QTBUG-78284
Task-number: QTBUG-81539
Change-Id: I3c4861e58622ccbb5046c60c4efcc19842400a88
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h')
-rw-r--r-- | src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index 18f848da5..df1806b6f 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -43,11 +43,13 @@ #include "render_widget_host_view_qt_delegate.h" #include "web_contents_adapter_client.h" +#include <QAccessibleWidget> #include <QQuickItem> #include <QQuickWidget> QT_BEGIN_NAMESPACE class QWebEnginePage; +class QWebEngineView; class QWebEnginePagePrivate; QT_END_NAMESPACE @@ -115,6 +117,21 @@ private: QMetaObject::Connection m_parentDestroyedConnection; }; +#if QT_CONFIG(accessibility) +class RenderWidgetHostViewQtDelegateWidgetAccessible : public QAccessibleWidget +{ +public: + RenderWidgetHostViewQtDelegateWidgetAccessible(RenderWidgetHostViewQtDelegateWidget *o, QWebEngineView *view); + + QAccessibleInterface *focusChild() const override; + int childCount() const override; + QAccessibleInterface *child(int index) const override; + int indexOfChild(const QAccessibleInterface *child) const override; +private: + QWebEngineView *m_view; +}; +#endif // QT_CONFIG(accessibility) + } // namespace QtWebEngineCore #endif |