[orca] Simplify and fix bugs in the speech generator's ancestry generation



commit 6d6c09b97e1d6ff7075d9a9c509ed35a73cab46f
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Oct 21 11:06:01 2013 -0400

    Simplify and fix bugs in the speech generator's ancestry generation

 src/orca/script_utilities.py |   16 ++++++++++------
 src/orca/speech_generator.py |   39 ++++-----------------------------------
 2 files changed, 14 insertions(+), 41 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 2f7df04..d98ff13 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -767,8 +767,8 @@ class Utilities:
         return False
 
     def isLayoutOnly(self, obj):
-        """Returns True if the given object is a table and is for layout
-        purposes only."""
+        """Returns True if the given object is a container which has
+        no presentable information (label, name, displayed text, etc.)."""
 
         layoutOnly = False
 
@@ -786,10 +786,14 @@ class Utilities:
                 if attribute == "layout-guess:true":
                     layoutOnly = True
                     break
-        elif role == pyatspi.ROLE_PANEL:
-            text = self.displayedText(obj)
-            label = self.displayedLabel(obj)
-            if not ((label and len(label)) or (text and len(text))):
+        elif role == pyatspi.ROLE_TABLE_CELL and obj.childCount:
+            layoutOnly = obj[0].getRole() == pyatspi.ROLE_TABLE_CELL
+        elif role == pyatspi.ROLE_SCROLL_PANE:
+            layoutOnly = True
+        elif role == pyatspi.ROLE_LIST_BOX:
+            layoutOnly = False
+        else:
+            if not (self.displayedText(obj) or self.displayedLabel(obj)):
                 layoutOnly = True
 
         if layoutOnly:
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 720b1be..24fb426 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -257,7 +257,7 @@ class SpeechGenerator(generator.Generator):
         acss = self.voice(SYSTEM)
         role = args.get('role', obj.getRole())
 
-        doNotPresent = [pyatspi.ROLE_UNKNOWN]
+        doNotPresent = [pyatspi.ROLE_UNKNOWN, pyatspi.ROLE_FILLER]
 
         # egg-list-box, e.g. privacy panel in gnome-control-center
         if obj.parent and obj.parent.getRole() == pyatspi.ROLE_LIST_BOX:
@@ -1480,46 +1480,15 @@ class SpeechGenerator(generator.Generator):
         previous object with focus.
         """
         result = []
-        acss = self.voice(DEFAULT)
         priorObj = args.get('priorObj', None)
-        requireText = args.get('requireText', True)
         commonAncestor = self._script.utilities.commonAncestor(priorObj, obj)
         if obj != commonAncestor:
             parent = obj.parent
-            if parent \
-                and (obj.getRole() == pyatspi.ROLE_TABLE_CELL) \
-                and (parent.getRole() == pyatspi.ROLE_TABLE_CELL):
-                parent = parent.parent
-            while parent and (parent.parent != parent):
-                if parent == commonAncestor:
+            while parent and not parent in [commonAncestor, parent.parent]:
+                if parent.getRole() == pyatspi.ROLE_APPLICATION:
                     break
                 if not self._script.utilities.isLayoutOnly(parent):
-                    text = self._script.utilities.displayedLabel(parent)
-                    if not text \
-                       and (not requireText \
-                            or (requireText \
-                                and 'Text' in pyatspi.listInterfaces(parent))):
-                        text = self._script.utilities.displayedText(parent)
-                    try:
-                        pRole = parent.getRole()
-                    except:
-                        pRole = None
-                    if not text \
-                       and pRole in [pyatspi.ROLE_MENU, pyatspi.ROLE_PAGE_TAB]:
-                        text = parent.name
-                    if text and len(text.strip()):
-                        roleInfo = self._generateRoleName(parent)
-                        if roleInfo:
-                            roleInfo.reverse()
-                        # Push announcement of cell to the end
-                        #
-                        if pRole not in \
-                               [pyatspi.ROLE_TABLE_CELL, pyatspi.ROLE_FILLER]:
-                            result.extend(roleInfo)
-                        result.extend(acss)
-                        result.append(text)
-                        if pRole == pyatspi.ROLE_TABLE_CELL:
-                            result.extend(roleInfo)
+                    result.append(self.generate(parent))
                 parent = parent.parent
         result.reverse()
         return result


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