a11y atspi: Send correct D-Bus reply for GetAttributeValue

Only return a string for the attribute value
(an empty string if the attribute is not set).

The previous implementation was based on the incorrect
signature in the XML spec for the AT-SPI Text interface from
before the AT-SPI commit that removed the extra out params [1]:

    commit 8786849ce6e9914383aa766ff9ce7e00f5b2178d
    Author: Patryk Kaczmarek <patryk.k@samsung.com>
    Date:   Mon Sep 28 14:23:15 2015 +0200

        Fixed atspi_text_ functions

          * atspi_text_get_text_attribute_value
              Fixed dbus signature in _atspi_dbus_call function
              and add missing argument for string.

          * atspi_text_get_default_attributes
              Receiving return value by reference from hash table

        https://bugzilla.gnome.org/show_bug.cgi?id=755731

[1] 8786849ce6

Fixes: QTBUG-105752
Change-Id: I66d3c484ecc4b469684635723242c915e4365e6a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit e6599bfa6134cfd3097c9cb8ec45801ae810f3df)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Michael Weghorn 2022-08-18 11:12:29 +02:00 committed by Qt Cherry-pick Bot
parent 48fd29fa47
commit db0db36ddc
2 changed files with 4 additions and 12 deletions

View File

@ -451,9 +451,6 @@ QString AtSpiAdaptor::introspect(const QString &path) const
" <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"attributeName\"/>\n"
" <arg direction=\"out\" type=\"s\"/>\n"
" <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n"
" <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"defined\"/>\n"
" </method>\n"
" <method name=\"GetAttributes\">\n"
" <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
@ -1761,7 +1758,7 @@ bool AtSpiAdaptor::textInterface(QAccessibleInterface *interface, const QString
} else if (function == "GetAttributeValue"_L1) {
int offset = message.arguments().at(0).toInt();
QString attributeName = message.arguments().at(1).toString();
connection.send(message.createReply(getAttributeValue(interface, offset, attributeName)));
connection.send(message.createReply(QVariant(getAttributeValue(interface, offset, attributeName))));
} else if (function == "GetAttributes"_L1) {
int offset = message.arguments().at(0).toInt();
connection.send(message.createReply(getAttributes(interface, offset, true)));
@ -2027,9 +2024,8 @@ QVariantList AtSpiAdaptor::getAttributes(QAccessibleInterface *interface, int of
return list;
}
QVariantList AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, int offset, const QString &attributeName) const
QString AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, int offset, const QString &attributeName) const
{
QString mapped;
QString joined;
QSpiAttributeSet map;
int startOffset;
@ -2044,11 +2040,7 @@ QVariantList AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, in
if (!attribute.isNull())
map[attribute.name] = attribute.value;
}
mapped = map[attributeName];
const bool defined = !mapped.isEmpty();
QVariantList list;
list << mapped << startOffset << endOffset << defined;
return list;
return map[attributeName];
}
QList<QVariant> AtSpiAdaptor::getCharacterExtents(QAccessibleInterface *interface, int offset, uint coordType) const

View File

@ -101,7 +101,7 @@ private:
// text helper functions
QVariantList getAttributes(QAccessibleInterface *, int offset, bool includeDefaults) const;
QVariantList getAttributeValue(QAccessibleInterface *, int offset, const QString &attributeName) const;
QString getAttributeValue(QAccessibleInterface *, int offset, const QString &attributeName) const;
QList<QVariant> getCharacterExtents(QAccessibleInterface *, int offset, uint coordType) const;
QList<QVariant> getRangeExtents(QAccessibleInterface *, int startOffset, int endOffset, uint coordType) const;
QAccessible::TextBoundaryType qAccessibleBoundaryType(int atspiTextBoundaryType) const;