[orca] Do not try to calculate node level for non-tree descendants



commit 41c5df13cd23a89f6f72872ec98a1e14ac16cc41
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Oct 14 13:03:05 2015 -0400

    Do not try to calculate node level for non-tree descendants

 src/orca/script_utilities.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 9307456..eb63a54 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -746,6 +746,19 @@ class Utilities:
 
         return False
 
+    def isTreeDescendant(self, obj):
+        if not obj:
+            return False
+
+        if obj.getRole() == pyatspi.ROLE_TREE_ITEM:
+            return True
+
+        isTree = lambda x: x and x.getRole() in [pyatspi.ROLE_TREE, pyatspi.ROLE_TREE_TABLE]
+        if pyatspi.findAncestor(obj, isTree):
+            return True
+
+        return False
+
     def isLayoutOnly(self, obj):
         """Returns True if the given object is a container which has
         no presentable information (label, name, displayed text, etc.)."""
@@ -1137,7 +1150,7 @@ class Utilities:
         -obj: the Accessible object
         """
 
-        if not obj:
+        if not self.isTreeDescendant(obj):
             return -1
 
         try:


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