[orca] Attempt to piece together content from cells with multiple renderers



commit 52cbb105f29f1d79df70e2b5968a98f6e043682d
Author: = <=>
Date:   Mon May 8 05:07:35 2017 -0400

    Attempt to piece together content from cells with multiple renderers

 src/orca/generator.py        |    7 ++++++-
 src/orca/script_utilities.py |   40 +++++++---------------------------------
 2 files changed, 13 insertions(+), 34 deletions(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 08f498b..1f682a3 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -1083,7 +1083,12 @@ class Generator:
         """
         result = []
         rad = self._script.utilities.realActiveDescendant(obj)
-        return self._generateDisplayedText(rad, **args)
+
+        if not (rad.getRole() == pyatspi.ROLE_TABLE_CELL and rad.childCount):
+            return self._generateDisplayedText(rad, **args)
+
+        content = [self._script.utilities.displayedText(x).strip() for x in rad]
+        return [" ".join(filter(lambda x: x, content))]
 
     def _generateRealActiveDescendantRoleName(self, obj, **args ):
         """Objects, such as tables and trees, can represent individual cells
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 8835a49..deecc93 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -86,7 +86,6 @@ class Utilities:
     KEY_BINDING = 'keyBinding'
     NESTING_LEVEL = 'nestingLevel'
     NODE_LEVEL = 'nodeLevel'
-    REAL_ACTIVE_DESCENDANT = 'realActiveDescendant'
 
     def __init__(self, script):
         """Creates an instance of the Utilities class.
@@ -1794,39 +1793,14 @@ class Utilities:
         if self.isDead(obj):
             return None
 
-        try:
-            return self._script.\
-                generatorCache[self.REAL_ACTIVE_DESCENDANT][obj]
-        except:
-            if self.REAL_ACTIVE_DESCENDANT not in self._script.\
-                    generatorCache:
-                self._script.generatorCache[self.REAL_ACTIVE_DESCENDANT] = {}
-            activeDescendant = None
-
-        # If obj is a table cell and all of it's children are table cells
-        # (probably cell renderers), then return the first child which has
-        # a non zero length text string. If no such object is found, just
-        # fall through and use the default approach below. See bug #376791
-        # for more details.
-        #
-        if obj.getRole() == pyatspi.ROLE_TABLE_CELL and obj.childCount:
-            nonTableCellFound = False
-            for child in obj:
-                if child.getRole() != pyatspi.ROLE_TABLE_CELL:
-                    nonTableCellFound = True
-            if not nonTableCellFound:
-                for child in obj:
-                    try:
-                        text = child.queryText()
-                    except NotImplementedError:
-                        continue
-                    else:
-                        if text.getText(0, -1).strip():
-                            activeDescendant = child
+        if obj.getRole() != pyatspi.ROLE_TABLE_CELL:
+            return obj
 
-        self._script.generatorCache[self.REAL_ACTIVE_DESCENDANT][obj] = \
-            activeDescendant or obj
-        return self._script.generatorCache[self.REAL_ACTIVE_DESCENDANT][obj]
+        hasContent = [x for x in obj if self.displayedText(x).strip()]
+        if len(hasContent) == 1:
+            return hasContent[0]
+
+        return obj
 
     def statusBar(self, obj):
         """Returns the status bar in the window which contains obj.


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