[orca] Web: Clear the cache for all non-live-region children-changed events



commit ac37d8c597053d40c35d9a62bc73ce0846fef31d
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Dec 9 15:20:59 2020 +0100

    Web: Clear the cache for all non-live-region children-changed events
    
    If the document content changes anywhere around the current element,
    we can wind up with stale information that can break navigation in
    browse mode. Therefore, always dump all cached objects in response
    to children-changed events unless we're in a live region. Live
    region updates are typically presented rather than navigated within.

 src/orca/scripts/web/script.py | 55 ++++++++++++++++++------------------------
 1 file changed, 23 insertions(+), 32 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 9d856bd9e..e90b417a8 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1687,25 +1687,27 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg, True)
             return True
 
+        isLiveRegion = self.utilities.isLiveRegion(event.source)
         document = self.utilities.getDocumentForObject(event.source)
-        if document:
-            msg = "WEB: Clearing structural navigation cache for %s" % document
+        if document and not isLiveRegion:
+            msg = "WEB: Clearing all cached info for %s" % document
             debug.println(debug.LEVEL_INFO, msg, True)
             self.structuralNavigation.clearCache(document)
+            self.utilities.clearCaretContext(document)
+            self.utilities.clearCachedObjects()
         else:
             msg = "WEB: Could not get document for event source"
             debug.println(debug.LEVEL_INFO, msg, True)
             return False
 
-        if self.utilities.handleAsLiveRegion(event):
-            msg = "WEB: Event to be handled as live region"
-            debug.println(debug.LEVEL_INFO, msg, True)
-            self.liveRegionManager.handleEvent(event)
-            return True
-
-        if self.utilities.isLiveRegion(event.source):
-            msg = "WEB: Ignoring because live region event not to be handled."
-            debug.println(debug.LEVEL_INFO, msg, True)
+        if isLiveRegion:
+            if self.utilities.handleAsLiveRegion(event):
+                msg = "WEB: Event to be handled as live region"
+                debug.println(debug.LEVEL_INFO, msg, True)
+                self.liveRegionManager.handleEvent(event)
+            else:
+                msg = "WEB: Ignoring because live region event not to be handled."
+                debug.println(debug.LEVEL_INFO, msg, True)
             return True
 
         if self._loadingDocumentContent:
@@ -1739,19 +1741,6 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg, True)
             return True
 
-        obj, offset = self.utilities.getCaretContext(getZombieReplicant=False)
-        msg = "WEB: Context: %s, %i (focus: %s)" % (obj, offset, orca_state.locusOfFocus)
-        debug.println(debug.LEVEL_INFO, msg, True)
-
-        if self.utilities.isZombie(obj):
-            obj, offset = self.utilities.searchForCaretContext(event.source)
-            if obj:
-                msg = "WEB: Event handled by updating locusOfFocus and context"
-                debug.println(debug.LEVEL_INFO, msg, True)
-                orca.setLocusOfFocus(event, obj, False)
-                self.utilities.setCaretContext(obj, offset)
-                return True
-
         childRole = event.any_data.getRole()
         if childRole == pyatspi.ROLE_ALERT:
             if event.any_data == self.utilities.lastQueuedLiveRegion():
@@ -1796,19 +1785,21 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg, True)
             return True
 
-        if self.utilities.handleEventForRemovedChild(event):
-            msg = "WEB: Event handled for removed child."
+        if self.utilities.isLiveRegion(event.source):
+            msg = "WEB: Ignoring removal from live region."
             debug.println(debug.LEVEL_INFO, msg, True)
             return True
 
-        # TODO - JD: Handle this case.
-        if event.source == orca_state.locusOfFocus:
-            msg = "WEB: Parent is locusOfFocus."
+        document = self.utilities.getDocumentForObject(event.source)
+        if document:
+            msg = "WEB: Clearing all cached info for %s" % document
             debug.println(debug.LEVEL_INFO, msg, True)
-            return False
+            self.structuralNavigation.clearCache(document)
+            self.utilities.clearCaretContext(document)
+            self.utilities.clearCachedObjects()
 
-        if self.utilities.isLiveRegion(event.source):
-            msg = "WEB: Ignoring removal from live region."
+        if self.utilities.handleEventForRemovedChild(event):
+            msg = "WEB: Event handled for removed child."
             debug.println(debug.LEVEL_INFO, msg, True)
             return True
 


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