summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Sørvig <[email protected]>2023-02-03 14:26:07 +0100
committerQt Cherry-pick Bot <[email protected]>2023-02-03 18:49:04 +0000
commita4891f76caace13ed7932b92b79624c913e0f98c (patch)
tree5beae8172b0628421071f32203fe920eee214d28
parent577364b0e8933da081a3cfb3828adb03cf050266 (diff)
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. Change-Id: Ifd4eb671def296b1eb418789b7ca85afa365e546 Reviewed-by: Mikołaj Boc <[email protected]> (cherry picked from commit bf5dbc61b357e0897cafaca04f78ee4c093d5606) Reviewed-by: Qt Cherry-pick Bot <[email protected]>
-rw-r--r--src/plugins/platforms/wasm/qwasmaccessibility.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/plugins/platforms/wasm/qwasmaccessibility.cpp b/src/plugins/platforms/wasm/qwasmaccessibility.cpp
index bea7380bfc1..523f94578bc 100644
--- a/src/plugins/platforms/wasm/qwasmaccessibility.cpp
+++ b/src/plugins/platforms/wasm/qwasmaccessibility.cpp
@@ -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)