[orca] Cache the status bar for web apps



commit 8180be094552664a5afac56dfb3cfc8a563b5c08
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat May 9 16:53:58 2020 -0400

    Cache the status bar for web apps
    
    Tree dives can be non-performant. So cache the object and sanity-check
    it to be sure it's not gone defunct on us before getting its items.

 src/orca/scripts/web/script_utilities.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index c8fefaf21..716c68e85 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -115,7 +115,7 @@ class Utilities(script_utilities.Utilities):
         self._currentCharacterContents = None
         self._lastQueuedLiveRegionEvent = None
         self._findContainer = None
-
+        self._statusBar = None
         self._validChildRoles = {pyatspi.ROLE_LIST: [pyatspi.ROLE_LIST_ITEM]}
 
     def _cleanupContexts(self):
@@ -186,6 +186,7 @@ class Utilities(script_utilities.Utilities):
         self._priorContexts = {}
         self._lastQueuedLiveRegionEvent = None
         self._findContainer = None
+        self._statusBar = None
 
     def clearContentCache(self):
         self._currentObjectContents = None
@@ -4964,6 +4965,15 @@ class Utilities(script_utilities.Utilities):
         self._lastQueuedLiveRegionEvent = event
         return True
 
+    def statusBar(self, obj):
+        if self._statusBar and not self.isZombie(self._statusBar):
+            msg = "WEB: Returning cached status bar: %s" % self._statusBar
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return self._statusBar
+
+        self._statusBar = super().statusBar(obj)
+        return self._statusBar
+
     def getOnScreenObjects(self, root, extents=None):
         if self._treatObjectAsWhole(root):
             return [root]


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