[orca] Always treat web objects with document roles as in document content



commit fa5d89019008d69ea6f3f0bcf73d9464022f121f
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Oct 12 13:02:10 2015 -0400

    Always treat web objects with document roles as in document content
    
    I suspect a timeout may be causing examining the tree to fail for some users

 src/orca/scripts/web/script.py           |    2 +-
 src/orca/scripts/web/script_utilities.py |   29 +++++++++++++++++------------
 2 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 46257b9..4bcaad1 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1249,7 +1249,7 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg)
             self.structuralNavigation.clearCache(document)
         else:
-            msg = "WEB: Event source is not in document content"
+            msg = "WEB: Could not get document for event source"
             debug.println(debug.LEVEL_INFO, msg)
             return False
 
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 8b01a42..fe27694 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -120,10 +120,25 @@ class Utilities(script_utilities.Utilities):
         self._currentAttrs = {}
         self._text = {}
 
+    def isDocument(self, obj):
+        roles = [pyatspi.ROLE_DOCUMENT_FRAME, pyatspi.ROLE_DOCUMENT_WEB, pyatspi.ROLE_EMBEDDED]
+
+        try:
+            rv = obj.getRole() in roles
+        except:
+            msg = "WEB: Exception getting role for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg)
+            rv = False
+
+        return rv
+
     def inDocumentContent(self, obj=None):
         if not obj:
             obj = orca_state.locusOfFocus
 
+        if self.isDocument(obj):
+            return True
+
         rv = self._inDocumentContent.get(hash(obj))
         if rv is not None:
             return rv
@@ -137,22 +152,12 @@ class Utilities(script_utilities.Utilities):
         if not obj:
             return None
 
-        roles = [pyatspi.ROLE_DOCUMENT_FRAME, pyatspi.ROLE_DOCUMENT_WEB, pyatspi.ROLE_EMBEDDED]
-
-        def isDocument(x):
-            try:
-                return x.getRole() in roles
-            except:
-                msg = "WEB: Exception getting role for %s" % x
-                debug.println(debug.LEVEL_INFO, msg)
-                return False
-
-        if isDocument(obj):
+        if self.isDocument(obj):
             msg = "WEB: %s is document" % obj
             debug.println(debug.LEVEL_INFO, msg)
             return obj
 
-        document = pyatspi.findAncestor(obj, isDocument)
+        document = pyatspi.findAncestor(obj, self.isDocument)
         msg = "WEB: Document for %s is %s" % (obj, document)
         debug.println(debug.LEVEL_INFO, msg)
         return document


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