[orca] Don't sanity-check children if there are a huge number of them



commit a190cf92a105043ab941f19eef0296f32641fccc
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Aug 5 17:46:28 2015 -0400

    Don't sanity-check children if there are a huge number of them

 src/orca/script_utilities.py |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index a6181c7..a4eae88 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2909,6 +2909,18 @@ class Utilities:
         debug.println(debug.LEVEL_INFO, msg)
         return replicant
 
+    def getFunctionalChildCount(self, obj):
+        if not obj:
+            return None
+
+        result = []
+        pred = lambda r: r.getRelationType() == pyatspi.RELATION_NODE_PARENT_OF
+        relations = list(filter(pred, obj.getRelationSet()))
+        if relations:
+            return relations[0].getNTargets()
+
+        return obj.childCount
+
     def getFunctionalChildren(self, obj):
         if not obj:
             return None
@@ -2945,9 +2957,12 @@ class Utilities:
                 obj = selected[0]
 
         parent = self.getFunctionalParent(obj)
+        childCount = self.getFunctionalChildCount(parent)
+        if childCount > 100 and parent == obj.parent:
+            return obj.getIndexInParent(), childCount
+
         siblings = self.getFunctionalChildren(parent)
-        if not (isComboBox or pyatspi.utils.findAncestor(obj, isComboBox)) \
-           and len(siblings) < 100:
+        if len(siblings) < 100 and not pyatspi.utils.findAncestor(obj, isComboBox):
             layoutRoles = [pyatspi.ROLE_SEPARATOR, pyatspi.ROLE_TEAROFF_MENU_ITEM]
             isNotLayoutOnly = lambda x: not (self.isZombie(x) or x.getRole() in layoutRoles)
             siblings = list(filter(isNotLayoutOnly, siblings))


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