a11y: Add new relations DescriptionFor, Described, Flows{From,To}

This is equivalent to the corresponding relation types defined
in the IAccessible2 spec [1] (IA2_RELATION_DESCRIPTION_FOR,
IA2_RELATION_DESCRIBED_BY, IA2_RELATION_FLOWS_FROM,
IA2_RELATION_FLOWS_TO) and for AT-SPI on Linux [2]
(relation types ATSPI_RELATION_DESCRIPTION_FOR,
ATSPI_RELATION_DESCRIBED_BY, ATSPI_RELATION_FLOWS_FROM,
ATSPI_RELATION_FLOWS_TO).

User Interface Automation (UIA) on Windows also has corresponding
properties for 3 of them [3]: UIA_DescribedByPropertyId,
UIA_FlowsFromPropertyId, UIA_FlowsToPropertyId.

This commit adds the new flags and implements the mapping for
the AT-SPI case.
Note that the relation type is conceptually always "inverted"
when comparing Qt and AT-SPI (or Qt and UIA)
as clarified in afbfe30093d49eff0ec4c28c220d33c233b9f807.

"QAccessible::Description" instead of "QAccessible::DescriptionFor"
would align better with the naming scheme of the other relations, but
that is already used in the Text enum.

[1] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/group__grp_relations.html
[2] https://lazka.github.io/pgi-docs/Atspi-2.0/enums.html#Atspi.RelationType
[3] https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids

[ChangeLog][QtGui][QAccessible::RelationFlag] Added new relation
flags DescriptionFor, Described, FlowsFrom and FlowsTo.

Fixes: QTBUG-105864
Change-Id: If2d46099eeea75e177358c821d1ae833a553bd0e
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
Michael Weghorn 2023-02-17 13:48:38 +01:00
parent 6990f23813
commit f5358e5932
3 changed files with 23 additions and 6 deletions

View File

@ -97,6 +97,7 @@ QSpiUIntList spiStateSetFromSpiStates(quint64 states)
AtspiRelationType qAccessibleRelationToAtSpiRelation(QAccessible::Relation relation)
{
// direction of the relation is "inversed" in Qt and AT-SPI
switch (relation) {
case QAccessible::Label:
return ATSPI_RELATION_LABELLED_BY;
@ -106,6 +107,14 @@ AtspiRelationType qAccessibleRelationToAtSpiRelation(QAccessible::Relation relat
return ATSPI_RELATION_CONTROLLED_BY;
case QAccessible::Controlled:
return ATSPI_RELATION_CONTROLLER_FOR;
case QAccessible::DescriptionFor:
return ATSPI_RELATION_DESCRIBED_BY;
case QAccessible::Described:
return ATSPI_RELATION_DESCRIPTION_FOR;
case QAccessible::FlowsFrom:
return ATSPI_RELATION_FLOWS_TO;
case QAccessible::FlowsTo:
return ATSPI_RELATION_FLOWS_FROM;
default:
qWarning() << "Cannot return AT-SPI relation for:" << relation;
}

View File

@ -367,12 +367,16 @@ Q_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core");
the returned list, and the \c origin object is the one represented
by the calling interface.
\value Label The \c returned object is the label for the \c origin object.
\value Labelled The \c returned object is labelled by the \c origin object.
\value Controller The \c returned object controls the \c origin object.
\value Controlled The \c returned object is controlled by the \c origin object.
\value AllRelations Used as a mask to specify that we are interesting in information
about all relations
\value Label The \c returned object is the label for the \c origin object.
\value Labelled The \c returned object is labelled by the \c origin object.
\value Controller The \c returned object controls the \c origin object.
\value Controlled The \c returned object is controlled by the \c origin object.
\value [since 6.6] DescriptionFor The \c returned object provides a description for the \c origin object.
\value [since 6.6] Described The \c returned object is described by the \c origin object.
\value [since 6.6] FlowsFrom Content logically flows from the \c returned object to the \c origin object.
\value [since 6.6] FlowsTo Content logically flows to the \c returned object from the \c origin object.
\value AllRelations Used as a mask to specify that we are interesting in information
about all relations
Implementations of relations() return a combination of these flags.
Some values are mutually exclusive.

View File

@ -331,6 +331,10 @@ public:
Labelled = 0x00000002,
Controller = 0x00000004,
Controlled = 0x00000008,
DescriptionFor = 0x00000010,
Described = 0x00000020,
FlowsFrom = 0x00000040,
FlowsTo = 0x00000080,
AllRelations = 0xffffffff
};
Q_DECLARE_FLAGS(Relation, RelationFlag)