wasm: convert a11y coordinates to window coordinates

The html accessibility elements are positioned relative
to the window a11y container. Convert the global (screen)
coordinates we get from QAccessibleIntreface::rect() to
window coordinates.

Pick-to: 6.5
Change-Id: Ifd4eb671def296b1eb418789b7ca85afa365e546
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
bb10
Morten Sørvig 2023-02-03 14:26:07 +01:00
parent 34c3682157
commit bf5dbc61b3
1 changed files with 11 additions and 1 deletions

View File

@ -328,7 +328,17 @@ void QWasmAccessibility::setHtmlElementVisibility(QAccessibleInterface *iface, b
void QWasmAccessibility::setHtmlElementGeometry(QAccessibleInterface *iface)
{
emscripten::val element = ensureHtmlElement(iface);
setHtmlElementGeometry(element, iface->rect());
// QAccessibleInterface gives us the geometry in global (screen) coordinates. Translate that
// to window geometry in order to position elements relative to window origin.
QWindow *window = getWindow(iface);
if (!window)
qCWarning(lcQpaAccessibility) << "Unable to find window for" << iface << "setting null geometry";
QRect screenGeometry = iface->rect();
QPoint windowPos = window ? window->mapFromGlobal(screenGeometry.topLeft()) : QPoint();
QRect windowGeometry(windowPos, screenGeometry.size());
setHtmlElementGeometry(element, windowGeometry);
}
void QWasmAccessibility::setHtmlElementGeometry(emscripten::val element, QRect geometry)