From f5358e5932bc8701621389c265c4ea86c92c536c Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 17 Feb 2023 13:48:38 +0100 Subject: [PATCH] a11y: Add new relations DescriptionFor, Described, Flows{From,To} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../accessible/linux/qspi_constant_mappings.cpp | 9 +++++++++ src/gui/accessible/qaccessible.cpp | 16 ++++++++++------ src/gui/accessible/qaccessible_base.h | 4 ++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/gui/accessible/linux/qspi_constant_mappings.cpp b/src/gui/accessible/linux/qspi_constant_mappings.cpp index b3e8816df51..4fc7bdf83cb 100644 --- a/src/gui/accessible/linux/qspi_constant_mappings.cpp +++ b/src/gui/accessible/linux/qspi_constant_mappings.cpp @@ -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; } diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index a1ed334d54b..b382f200377 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -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. diff --git a/src/gui/accessible/qaccessible_base.h b/src/gui/accessible/qaccessible_base.h index ac50c2626e3..74926a3565a 100644 --- a/src/gui/accessible/qaccessible_base.h +++ b/src/gui/accessible/qaccessible_base.h @@ -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)