[orca] Look for the deepest presentable items when generating the status bar



commit 242060ee0442e6268ce04fb083a4e5ccfdd202ca
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri May 8 16:55:25 2020 -0400

    Look for the deepest presentable items when generating the status bar
    
    _generateStatusBar was only looking at and presenting immediate children,
    and then prefering the displayed text of that item. This approach can
    cause us to miss certain items, as well as to incorrectly omit the role
    on interactive items, especially in web applications.
    
    Because status bars, even on the web, shouldn't have that many descendant
    objects, dive the tree locating presentable descendants.

 src/orca/script_utilities.py | 16 ++++++++++++++++
 src/orca/speech_generator.py | 17 +++++++++--------
 2 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index d9eebc2e0..1e041ad8a 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2189,6 +2189,19 @@ class Utilities:
 
         return obj
 
+    def isStatusBarDescendant(self, obj):
+        if not obj:
+            return False
+
+        isStatusBar = lambda x: x and x.getRole() == pyatspi.ROLE_STATUS_BAR
+        return pyatspi.findAncestor(obj, isStatusBar) is not None
+
+    def statusBarItems(self, obj):
+        if not (obj and obj.getRole() == pyatspi.ROLE_STATUS_BAR):
+            return []
+
+        return self.getOnScreenObjects(obj)
+
     def statusBar(self, obj):
         """Returns the status bar in the window which contains obj.
 
@@ -2197,6 +2210,9 @@ class Utilities:
           the status bar is sought.
         """
 
+        if obj.getRole() == pyatspi.ROLE_STATUS_BAR:
+            return obj
+
         # There are some objects which are not worth descending.
         #
         skipRoles = [pyatspi.ROLE_TREE,
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index cf6bcad3a..52512ff8e 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -564,6 +564,9 @@ class SpeechGenerator(generator.Generator):
         if parentRole == pyatspi.ROLE_LIST_BOX:
             doNotPresent.append(obj.getRole())
 
+        if self._script.utilities.isStatusBarDescendant(obj):
+            doNotPresent.append(pyatspi.ROLE_LABEL)
+
         if _settingsManager.getSetting('speechVerbosityLevel') \
                 == settings.VERBOSITY_LEVEL_BRIEF:
             doNotPresent.extend([pyatspi.ROLE_ICON, pyatspi.ROLE_CANVAS])
@@ -2314,21 +2317,19 @@ class SpeechGenerator(generator.Generator):
     def _generateStatusBar(self, obj, **args):
         """Returns an array of strings (and possibly voice and audio
         specifications) that represent the status bar of a window.
-        This method should initially be called with a top-level window.
         """
 
         statusBar = self._script.utilities.statusBar(obj)
         if not statusBar:
             return []
 
-        result = self._generateName(statusBar)
-        if result:
-            return result
+        items = self._script.utilities.statusBarItems(statusBar)
+        if not items:
+            return []
 
-        for child in statusBar:
-            childResult = self._generateDisplayedText(child)
-            if not childResult and child.getRole() != pyatspi.ROLE_LABEL:
-                childResult = self.generate(child, includeContext=False)
+        result = []
+        for child in items:
+            childResult = self.generate(child, includeContext=False)
             if childResult:
                 result.extend(childResult)
                 result.extend(self._generatePause(child, **args))


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