[orca] Web: Support presentation of child position for description list values



commit cd79bac8782328d8ab04cddeb841718a2648cb39
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Jun 22 16:36:02 2022 +0200

    Web: Support presentation of child position for description list values
    
    NOTE: This functionality requires "speak child position" to be enabled
    on the "Speech" page in Orca's preferences dialog (it is not enabled by
    default).
    
    No user agent provides this, so we have to do some accessibility tree
    walking. It seems not too horrible given that we've already cached
    things as part of supporting child position for description list terms.
    
    See issue #248

 src/orca/formatting.py                               |  2 +-
 src/orca/script_utilities.py                         | 20 ++++++++++++++++++++
 .../scripts/toolkits/Chromium/script_utilities.py    |  6 ++++++
 3 files changed, 27 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index ac43e7a29..c6a0935e2 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -212,7 +212,7 @@ formatting = {
             'unfocused': '(labelOrName or (displayedText + allTextSelection)) + roleName + pause + 
termValueCount + pause + positionInList',
             },
         pyatspi.ROLE_DESCRIPTION_VALUE: {
-            'unfocused': '(labelOrName or (displayedText + allTextSelection) + roleName)',
+            'unfocused': '(labelOrName or (displayedText + allTextSelection)) + roleName + pause + 
positionInList',
             },
         pyatspi.ROLE_DIAL: {
             'focused': 'value',
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 4190f741f..bcbc7f19d 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -5150,6 +5150,8 @@ class Utilities:
         if not result:
             if self.isDescriptionListTerm(sibling):
                 return self.descriptionListTerms(obj)
+            if self.isDescriptionListDescription(sibling):
+                return self.valuesForTerm(self.termForValue(sibling))
 
         return result or [child for child in obj]
 
@@ -5210,6 +5212,24 @@ class Utilities:
         setSize = len(siblings)
         return position, setSize
 
+    def termForValue(self, obj):
+        if not self.isDescriptionListDescription(obj):
+            return None
+
+        try:
+            index = obj.getIndexInParent()
+        except:
+            msg = "ERROR: Exception getting index and sibling count for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return None
+
+        for i in range(index - 1, -1, -1):
+            child = obj.parent[i]
+            if self.isDescriptionListTerm(child):
+                return child
+
+        return None
+
     def valuesForTerm(self, obj):
         if not self.isDescriptionListTerm(obj):
             return []
diff --git a/src/orca/scripts/toolkits/Chromium/script_utilities.py 
b/src/orca/scripts/toolkits/Chromium/script_utilities.py
index 2a4f4ef06..f483ab5c0 100644
--- a/src/orca/scripts/toolkits/Chromium/script_utilities.py
+++ b/src/orca/scripts/toolkits/Chromium/script_utilities.py
@@ -543,6 +543,12 @@ class Utilities(web.Utilities):
         return False
 
     def _shouldCalculatePositionAndSetSize(self, obj):
+        # Chromium calculates posinset and setsize for description lists based on the
+        # number of terms present. If we want to present the number of values associated
+        # with a given term, we need to work those values out ourselves.
+        if self.isDescriptionListDescription(obj):
+            return True
+
         # Chromium has accessible menu items which are not focusable and therefore do not
         # have a posinset and setsize calculated. But they may claim to be the selected
         # item when an accessible child is selected (e.g. "zoom" when "+" or "-" gains focus.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]