[orca] Do loading check first when processing busy events; more debugging output



commit 9821512850109bd135ca2d20d391363eee330b02
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sun Oct 11 12:14:35 2015 -0400

    Do loading check first when processing busy events; more debugging output
    
    The former due to performance; the latter due to some weird bug I cannot
    reproduce.

 src/orca/scripts/web/script.py           |   10 +++++-----
 src/orca/scripts/web/script_utilities.py |    9 +++++++--
 2 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 750e6be..46257b9 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1015,6 +1015,11 @@ class Script(default.Script):
     def onBusyChanged(self, event):
         """Callback for object:state-changed:busy accessibility events."""
 
+        if event.detail1 and self._loadingDocumentContent:
+            msg = "WEB: Ignoring: Already loading document content"
+            debug.println(debug.LEVEL_INFO, msg)
+            return True
+
         if not self.utilities.inDocumentContent(event.source):
             msg = "WEB: Event source is not in document content"
             debug.println(debug.LEVEL_INFO, msg)
@@ -1025,11 +1030,6 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg)
             return True
 
-        if event.detail1 and self._loadingDocumentContent:
-            msg = "WEB: Ignoring: Already loading document content"
-            debug.println(debug.LEVEL_INFO, msg)
-            return True
-
         self._loadingDocumentContent = event.detail1
 
         obj, offset = self.utilities.getCaretContext()
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index f3c1d48..8b01a42 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -141,16 +141,21 @@ class Utilities(script_utilities.Utilities):
 
         def isDocument(x):
             try:
-                return x and x.getRole() in roles
+                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):
+            msg = "WEB: %s is document" % obj
+            debug.println(debug.LEVEL_INFO, msg)
             return obj
 
-        return pyatspi.findAncestor(obj, isDocument)
+        document = pyatspi.findAncestor(obj, isDocument)
+        msg = "WEB: Document for %s is %s" % (obj, document)
+        debug.println(debug.LEVEL_INFO, msg)
+        return document
 
     def _getDocumentsEmbeddedBy(self, frame):
         isEmbeds = lambda r: r.getRelationType() == pyatspi.RELATION_EMBEDS


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