[orca] Add support for in-process ARIA feature for alternative text for cell indices



commit 609bd936cc4d402b2c482d2f90ef1afc0e3972fe
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Jun 5 19:35:51 2019 -0400

    Add support for in-process ARIA feature for alternative text for cell indices

 src/orca/scripts/web/script_utilities.py | 29 +++++++++++++++++++++++++++++
 src/orca/scripts/web/speech_generator.py |  6 ++++++
 2 files changed, 35 insertions(+)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index ae0064ea4..8560df28d 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2396,6 +2396,35 @@ class Utilities(script_utilities.Utilities):
         colindex = attrs.get('colindex', colindex)
         return rowindex, colindex
 
+    def labelForCellCoordinates(self, obj):
+        try:
+            attrs = dict([attr.split(':', 1) for attr in obj.getAttributes()])
+        except:
+            attrs = {}
+
+        # The ARIA feature is still in the process of being discussed.
+        collabel = attrs.get('colindextext', attrs.get('coltext'))
+        rowlabel = attrs.get('rowindextext', attrs.get('rowtext'))
+        if collabel is not None and rowlabel is not None:
+            return '%s%s' % (collabel, rowlabel)
+
+        isRow = lambda x: x and x.getRole() == pyatspi.ROLE_TABLE_ROW
+        row = pyatspi.findAncestor(obj, isRow)
+        if not row:
+            return ''
+
+        try:
+            attrs = dict([attr.split(':', 1) for attr in row.getAttributes()])
+        except:
+            attrs = {}
+
+        collabel = attrs.get('colindextext', attrs.get('coltext', collabel))
+        rowlabel = attrs.get('rowindextext', attrs.get('rowtext', rowlabel))
+        if collabel is not None and rowlabel is not None:
+            return '%s%s' % (collabel, rowlabel)
+
+        return ''
+
     def coordinatesForCell(self, obj):
         rowindex, colindex = self._rowAndColumnIndices(obj)
         if rowindex is not None and colindex is not None:
diff --git a/src/orca/scripts/web/speech_generator.py b/src/orca/scripts/web/speech_generator.py
index 445e9b639..9d1050e24 100644
--- a/src/orca/scripts/web/speech_generator.py
+++ b/src/orca/scripts/web/speech_generator.py
@@ -503,6 +503,12 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
             return result
 
         if _settingsManager.getSetting('speakCellCoordinates'):
+            label = self._script.utilities.labelForCellCoordinates(obj)
+            if label:
+                result.append(label)
+                result.extend(self.voice(speech_generator.SYSTEM))
+                return result
+
             row, col = self._script.utilities.coordinatesForCell(obj)
             if self._script.utilities.cellRowChanged(obj):
                 result.append(messages.TABLE_ROW % (row + 1))


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