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.cpp | |
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.cpp')
-rw-r--r-- | src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 894dca4fa..8ba312822 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -483,4 +483,32 @@ void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged() m_client->visualPropertiesChanged(); } +#if QT_CONFIG(accessibility) +RenderWidgetHostViewQtDelegateWidgetAccessible::RenderWidgetHostViewQtDelegateWidgetAccessible(RenderWidgetHostViewQtDelegateWidget *o, QWebEngineView *view) + : QAccessibleWidget(o) + , m_view(view) +{ +} + +QAccessibleInterface *RenderWidgetHostViewQtDelegateWidgetAccessible::focusChild() const +{ + return QAccessible::queryAccessibleInterface(m_view)->focusChild(); +} + +int RenderWidgetHostViewQtDelegateWidgetAccessible::childCount() const +{ + return QAccessible::queryAccessibleInterface(m_view)->childCount(); +} + +QAccessibleInterface *RenderWidgetHostViewQtDelegateWidgetAccessible::child(int index) const +{ + return QAccessible::queryAccessibleInterface(m_view)->child(index); +} + +int RenderWidgetHostViewQtDelegateWidgetAccessible::indexOfChild(const QAccessibleInterface *c) const +{ + return QAccessible::queryAccessibleInterface(m_view)->indexOfChild(c); +} +#endif // QT_CONFIG(accessibility) + } // namespace QtWebEngineCore |