diff options
author | Andre de la Rocha <andre.rocha@qt.io> | 2018-08-30 18:11:31 +0200 |
---|---|---|
committer | Andre de la Rocha <andre.rocha@qt.io> | 2018-09-04 19:48:01 +0000 |
commit | 20ac20bcea8954a980d1acdbc4e9fa55011fe088 (patch) | |
tree | 12bee4bfb70419dca02d151ba59880078fb93021 /src/plugins/platforms/windows | |
parent | ff2a71e310b18a43a41daf2d197f5715f7c26d29 (diff) |
Windows QPA: Fix missing accessibility info with WebEngineView
It seems when a WebEngineView is parented by a window its accessible
interface will not know its parent, which prevented the root of an
UI Automation fragment from being found, causing missing accessibility
info. This change adds a workaround to avoid this issue.
Task-number: QTBUG-70199
Change-Id: Ia7cfc9f410c4f0ef3b5f9d1700748a9a3e29b7c2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r-- | src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp index 294eed7701..89e5aad6a6 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp @@ -57,11 +57,25 @@ QWindow *windowForAccessible(const QAccessibleInterface *accessible) { QWindow *window = accessible->window(); if (!window) { - QAccessibleInterface *acc = accessible->parent(); - while (acc && acc->isValid() && !window) { - window = acc->window(); - QAccessibleInterface *par = acc->parent(); + const QAccessibleInterface *acc = accessible; + const QAccessibleInterface *par = accessible->parent(); + while (par && par->isValid() && !window) { + window = par->window(); acc = par; + par = par->parent(); + } + if (!window) { + // Workaround for WebEngineView not knowing its parent. + const auto appWindows = QGuiApplication::topLevelWindows(); + for (QWindow *w : appWindows) { + if (QAccessibleInterface *root = w->accessibleRoot()) { + int count = root->childCount(); + for (int i = 0; i < count; ++i) { + if (root->child(i) == acc) + return w; + } + } + } } } return window; |