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>
This commit is contained in:
parent
ff2a71e310
commit
20ac20bcea
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user