[orca] Replace a few more instances of pyatspi's findAllDescendants with our own



commit 8792814c552ea93cb28fd29d85a1a41fdd36b890
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Jun 14 21:13:19 2019 -0400

    Replace a few more instances of pyatspi's findAllDescendants with our own

 src/orca/braille_generator.py                         |  2 +-
 src/orca/liveregions.py                               |  3 ++-
 src/orca/script_utilities.py                          | 14 +++-----------
 src/orca/scripts/apps/gnome-shell/script_utilities.py |  2 +-
 src/orca/scripts/apps/soffice/script_utilities.py     |  6 +++---
 src/orca/speech_generator.py                          |  2 +-
 6 files changed, 11 insertions(+), 18 deletions(-)
---
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index 64f04e31b..498e29d60 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -340,7 +340,7 @@ class BrailleGenerator(generator.Generator):
         isWidget = lambda x: x and x.getRole() in widgetRoles
         result = []
         if obj.parent and obj.parent.getRole() == pyatspi.ROLE_LIST_BOX:
-            widgets = pyatspi.findAllDescendants(obj, isWidget)
+            widgets = self._script.utilities.findAllDescendants(obj, isWidget)
             for widget in widgets:
                 result.extend(self.generate(widget, includeContext=False))
                 result.append(braille.Region(" "))
diff --git a/src/orca/liveregions.py b/src/orca/liveregions.py
index 86bb83d31..bb833fe64 100644
--- a/src/orca/liveregions.py
+++ b/src/orca/liveregions.py
@@ -343,7 +343,8 @@ class LiveRegionManager:
             # look through all the objects on the page and set/add to
             # politeness overrides.  This only adds live regions with good
             # markup.
-            matches = pyatspi.findAllDescendants(docframe, self.matchLiveRegion)
+            matches = self._script.utilities.findAllDescendants(
+                docframe, self.matchLiveRegion)
             for match in matches:
                 objectid = self._getObjectId(match)
                 self._politenessOverrides[(uri, objectid)] = LIVE_OFF
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index bcf34ff73..556ae6626 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -485,7 +485,7 @@ class Utilities:
 
         textObjects = []
         for detail in details:
-            textObjects.extend(pyatspi.findAllDescendants(detail, self.queryNonEmptyText))
+            textObjects.extend(self.findAllDescendants(detail, self.queryNonEmptyText))
 
         return textObjects
 
@@ -3629,22 +3629,14 @@ class Utilities:
         role = obj.getRole()
         if role == pyatspi.ROLE_MENU and not children:
             pred = lambda x: x and x.getState().contains(pyatspi.STATE_SELECTED)
-            try:
-                children = pyatspi.findAllDescendants(obj, pred)
-            except:
-                msg = "ERROR: Exception calling findAllDescendants on %s" % obj
-                debug.println(debug.LEVEL_INFO, msg, True)
+            children = self.findAllDescendants(obj, pred)
 
         if role == pyatspi.ROLE_COMBO_BOX \
            and children and children[0].getRole() == pyatspi.ROLE_MENU:
             children = self.selectedChildren(children[0])
             if not children and obj.name:
                 pred = lambda x: x and x.name == obj.name
-                try:
-                    children = pyatspi.findAllDescendants(obj, pred)
-                except:
-                    msg = "ERROR: Exception calling findAllDescendants on %s" % obj
-                    debug.println(debug.LEVEL_INFO, msg, True)
+                children = self.findAllDescendants(obj, pred)
 
         return children
 
diff --git a/src/orca/scripts/apps/gnome-shell/script_utilities.py 
b/src/orca/scripts/apps/gnome-shell/script_utilities.py
index 6d28715c3..5e848d2e2 100644
--- a/src/orca/scripts/apps/gnome-shell/script_utilities.py
+++ b/src/orca/scripts/apps/gnome-shell/script_utilities.py
@@ -45,7 +45,7 @@ class Utilities(script_utilities.Utilities):
                 return []
 
             isSelected = lambda x: x and x.getState().contains(pyatspi.STATE_SELECTED)
-            children = pyatspi.findAllDescendants(obj, isSelected)
+            children = self.findAllDescendants(obj, isSelected)
         else:
             children = []
             for x in range(selection.nSelectedChildren):
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py 
b/src/orca/scripts/apps/soffice/script_utilities.py
index 80854e6c3..68fa04499 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -350,7 +350,7 @@ class Utilities(script_utilities.Utilities):
             return None
 
         isParagraph = lambda x: x and x.getRole() == pyatspi.ROLE_PARAGRAPH
-        allParagraphs = pyatspi.findAllDescendants(toolbar, isParagraph)
+        allParagraphs = self.findAllDescendants(toolbar, isParagraph)
         if len(allParagraphs) == 1:
             self._script.inputLineForCell = allParagraphs[0]
 
@@ -539,12 +539,12 @@ class Utilities(script_utilities.Utilities):
             return None, None
 
         hasRole = lambda x: x and x.getRole() == pyatspi.ROLE_SPLIT_PANE
-        panes = pyatspi.findAllDescendants(parent, hasRole)
+        panes = self.findAllDescendants(parent, hasRole)
         if not panes:
             return None, None
 
         slidePane = taskPane = None
-        if pyatspi.findAllDescendants(panes[0], self.isDocument):
+        if self.findAllDescendants(panes[0], self.isDocument):
             slidePane = panes[0]
             if len(panes) == 2:
                 taskPane = panes[1]
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 9167d510a..7b6380778 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -2118,7 +2118,7 @@ class SpeechGenerator(generator.Generator):
         isWidget = lambda x: x and x.getRole() in widgetRoles
         result = []
         if obj.parent and obj.parent.getRole() == pyatspi.ROLE_LIST_BOX:
-            widgets = pyatspi.findAllDescendants(obj, isWidget)
+            widgets = self._script.utilities.findAllDescendants(obj, isWidget)
             for widget in widgets:
                 if self._script.utilities.isShowingAndVisible(widget):
                     result.append(self.generate(widget, includeContext=False))


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