a11y atspi: Handle AT-SPI Text's ScrollSubstringTo

This implements handling for the ScrollSubstringTo
method from the AT-SPI Text interface by calling
QAccessibleTextInterface::scrollToSubstring with
the given text offsets.

While the AT-SPI method has an additional parameter
for the scroll type that specifies where on screen
to place the given substring (s. doc at [1]), there
is no equivalent in
QAccessibleTextInterface::scrollToSubstring,
so ignore that parameter.

[1] https://lazka.github.io/pgi-docs/Atspi-2.0/classes/Text.html#Atspi.Text.scroll_substring_to

Fixes: QTBUG-105854
Change-Id: I390e1316c5c55cb646a299499a5f87c9c6945a44
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Michael Weghorn 2022-08-22 09:38:24 +02:00
parent 88974b0a3e
commit 45121669f5

View File

@ -557,6 +557,12 @@ QString AtSpiAdaptor::introspect(const QString &path) const
" <arg direction=\"out\" type=\"a{ss}\"/>\n"
" <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
" </method>\n"
" <method name=\"ScrollSubstringTo\">\n"
" <arg direction=\"in\" name=\"startOffset\" type=\"i\"/>\n"
" <arg direction=\"in\" name=\"endOffset\" type=\"i\"/>\n"
" <arg direction=\"in\" name=\"type\" type=\"u\"/>\n"
" <arg direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" </interface>\n"
);
@ -1868,6 +1874,13 @@ bool AtSpiAdaptor::textInterface(QAccessibleInterface *interface, const QString
int offset = message.arguments().at(0).toInt();
interface->textInterface()->setCursorPosition(offset);
sendReply(connection, message, true);
} else if (function == "ScrollSubstringTo"_L1) {
int startOffset = message.arguments().at(0).toInt();
int endOffset = message.arguments().at(1).toInt();
// ignore third parameter (scroll type), since QAccessibleTextInterface::scrollToSubstring doesn't have that
qCInfo(lcAccessibilityAtspi) << "AtSpiAdaptor::ScrollSubstringTo doesn'take take scroll type into account.";
interface->textInterface()->scrollToSubstring(startOffset, endOffset);
sendReply(connection, message, true);
} else if (function == "SetSelection"_L1) {
int selectionNum = message.arguments().at(0).toInt();
int startOffset = message.arguments().at(1).toInt();