From 20ac20bcea8954a980d1acdbc4e9fa55011fe088 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Thu, 30 Aug 2018 18:11:31 +0200 Subject: 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 Reviewed-by: Qt CI Bot --- .../windows/uiautomation/qwindowsuiautils.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') 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; -- cgit v1.2.3