Accessibility Linux: Fix methods returning rects as iiii for AT-SPI
According to the spec rects get returned with iiii but we were directly serializing QRect resulting in (iiii) as signature. This would trip up Orca when trying to use flat review in text edits. Task-number: QTBUG-39702 Change-Id: I8d6769688586e678d27cc4341de5176a91f057fc Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
f360dc9297
commit
f3e86a8cc8
@ -1952,17 +1952,17 @@ QVariantList AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, in
|
||||
return list;
|
||||
}
|
||||
|
||||
QRect AtSpiAdaptor::getCharacterExtents(QAccessibleInterface *interface, int offset, uint coordType) const
|
||||
QList<QVariant> AtSpiAdaptor::getCharacterExtents(QAccessibleInterface *interface, int offset, uint coordType) const
|
||||
{
|
||||
QRect rect = interface->textInterface()->characterRect(offset);
|
||||
|
||||
if (coordType == ATSPI_COORD_TYPE_WINDOW)
|
||||
rect = translateRectToWindowCoordinates(interface, rect);
|
||||
|
||||
return rect;
|
||||
return QList<QVariant>() << rect.x() << rect.y() << rect.width() << rect.height();
|
||||
}
|
||||
|
||||
QRect AtSpiAdaptor::getRangeExtents(QAccessibleInterface *interface,
|
||||
QList<QVariant> AtSpiAdaptor::getRangeExtents(QAccessibleInterface *interface,
|
||||
int startOffset, int endOffset, uint coordType) const
|
||||
{
|
||||
if (endOffset == -1)
|
||||
@ -1970,7 +1970,7 @@ QRect AtSpiAdaptor::getRangeExtents(QAccessibleInterface *interface,
|
||||
|
||||
QAccessibleTextInterface *textInterface = interface->textInterface();
|
||||
if (endOffset <= startOffset || !textInterface)
|
||||
return QRect();
|
||||
return QList<QVariant>() << -1 << -1 << 0 << 0;
|
||||
|
||||
QRect rect = textInterface->characterRect(startOffset);
|
||||
for (int i=startOffset + 1; i <= endOffset; i++)
|
||||
@ -1980,7 +1980,7 @@ QRect AtSpiAdaptor::getRangeExtents(QAccessibleInterface *interface,
|
||||
if (coordType == ATSPI_COORD_TYPE_WINDOW)
|
||||
rect = translateRectToWindowCoordinates(interface, rect);
|
||||
|
||||
return rect;
|
||||
return QList<QVariant>() << rect.x() << rect.y() << rect.width() << rect.height();
|
||||
}
|
||||
|
||||
QRect AtSpiAdaptor::translateRectToWindowCoordinates(QAccessibleInterface *interface, const QRect &rect)
|
||||
|
@ -125,8 +125,8 @@ private:
|
||||
// text helper functions
|
||||
QVariantList getAttributes(QAccessibleInterface *, int offset, bool includeDefaults) const;
|
||||
QVariantList getAttributeValue(QAccessibleInterface *, int offset, const QString &attributeName) const;
|
||||
QRect getCharacterExtents(QAccessibleInterface *, int offset, uint coordType) const;
|
||||
QRect getRangeExtents(QAccessibleInterface *, int startOffset, int endOffset, uint coordType) 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;
|
||||
static bool inheritsQAction(QObject *object);
|
||||
|
||||
|
@ -421,14 +421,22 @@ void tst_QAccessibilityLinux::testTextEdit()
|
||||
QCOMPARE(callResult.at(2).toInt(), 17);
|
||||
|
||||
// Check if at least CharacterExtents and RangeExtents give a consistent result
|
||||
QDBusReply<QRect> replyRect20 = textInterface->call(QDBus::Block, "GetCharacterExtents", 20, ATSPI_COORD_TYPE_SCREEN);
|
||||
QVERIFY(replyRect20.isValid());
|
||||
QRect r1 = replyRect20.value();
|
||||
QDBusReply<QRect> replyRect21 = textInterface->call(QDBus::Block, "GetCharacterExtents", 21, ATSPI_COORD_TYPE_SCREEN);
|
||||
QRect r2 = replyRect21.value();
|
||||
QDBusReply<QRect> reply = textInterface->call(QDBus::Block, "GetRangeExtents", 20, 21, ATSPI_COORD_TYPE_SCREEN);
|
||||
QRect rect = reply.value();
|
||||
QCOMPARE(rect, r1|r2);
|
||||
|
||||
QDBusMessage replyRect20 = textInterface->call(QDBus::Block, "GetCharacterExtents", 20, ATSPI_COORD_TYPE_SCREEN);
|
||||
QCOMPARE(replyRect20.type(), QDBusMessage::ReplyMessage);
|
||||
QCOMPARE(replyRect20.signature(), QStringLiteral("iiii"));
|
||||
callResult = replyRect20.arguments();
|
||||
QRect r1 = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt());
|
||||
QDBusMessage replyRect21 = textInterface->call(QDBus::Block, "GetCharacterExtents", 21, ATSPI_COORD_TYPE_SCREEN);
|
||||
QCOMPARE(replyRect21.type(), QDBusMessage::ReplyMessage);
|
||||
QCOMPARE(replyRect21.signature(), QStringLiteral("iiii"));
|
||||
callResult = replyRect21.arguments();
|
||||
QRect r2 = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt());
|
||||
|
||||
QDBusMessage replyRange = textInterface->call(QDBus::Block, "GetRangeExtents", 20, 21, ATSPI_COORD_TYPE_SCREEN);
|
||||
callResult = replyRange.arguments();
|
||||
QRect rectRangeExtents = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt());
|
||||
QCOMPARE(rectRangeExtents, r1|r2);
|
||||
|
||||
m_window->clearChildren();
|
||||
delete textInterface;
|
||||
|
Loading…
Reference in New Issue
Block a user