[orca] Web: Dump cache for text insertion when focus is dead



commit 293a4d691c59a2edfa1cfdd704e9e7eff9e03077
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Feb 26 17:27:00 2021 +0100

    Web: Dump cache for text insertion when focus is dead
    
    Also add more debugging to hunt down weird problem.

 src/orca/script_utilities.py             |  2 ++
 src/orca/scripts/web/script.py           | 10 +++++++---
 src/orca/scripts/web/script_utilities.py | 17 ++++++++++++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 1a2944dab..f3fad0a9d 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4934,6 +4934,8 @@ class Utilities:
         return False
 
     def findReplicant(self, root, obj):
+        msg = "INFO: Searching for replicant for %s in %s" % (obj, root)
+        debug.println(debug.LEVEL_INFO, msg, True)
         if not (root and obj):
             return None
 
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index f78708987..78f520f25 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1734,7 +1734,7 @@ class Script(default.Script):
                 debug.println(debug.LEVEL_INFO, msg, True)
                 self.utilities.dumpCache(document, preserveContext=False)
             elif self.utilities.isDead(orca_state.locusOfFocus):
-                msg = "WEB: Dumping cache and context: dead focus %s" % orca_state.locusOfFocus
+                msg = "WEB: Dumping cache: dead focus %s" % orca_state.locusOfFocus
                 debug.println(debug.LEVEL_INFO, msg, True)
                 self.utilities.dumpCache(document, preserveContext=True)
             elif pyatspi.findAncestor(orca_state.locusOfFocus, lambda x: x == event.source):
@@ -1846,7 +1846,7 @@ class Script(default.Script):
                 debug.println(debug.LEVEL_INFO, msg, True)
                 self.utilities.dumpCache(document, preserveContext=False)
             elif self.utilities.isDead(orca_state.locusOfFocus):
-                msg = "WEB: Dumping cache and context: dead focus %s" % orca_state.locusOfFocus
+                msg = "WEB: Dumping cache: dead focus %s" % orca_state.locusOfFocus
                 debug.println(debug.LEVEL_INFO, msg, True)
                 self.utilities.dumpCache(document, preserveContext=True)
             elif pyatspi.findAncestor(orca_state.locusOfFocus, lambda x: x == event.source):
@@ -2366,7 +2366,11 @@ class Script(default.Script):
         self.utilities.clearContentCache()
 
         document = self.utilities.getDocumentForObject(event.source)
-        if document:
+        if self.utilities.isDead(orca_state.locusOfFocus):
+            msg = "WEB: Dumping cache: dead focus %s" % orca_state.locusOfFocus
+            debug.println(debug.LEVEL_INFO, msg, True)
+            self.utilities.dumpCache(document, preserveContext=True)
+        else:
             msg = "WEB: Clearing structural navigation cache for %s" % document
             debug.println(debug.LEVEL_INFO, msg, True)
             self.structuralNavigation.clearCache(document)
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index ca59e9249..87406e6af 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -4647,13 +4647,22 @@ class Utilities(script_utilities.Utilities):
         return obj, offset
 
     def getCaretContext(self, documentFrame=None, getZombieReplicant=False, searchIfNeeded=True):
+        msg = "WEB: Getting caret context"
+        debug.println(debug.LEVEL_INFO, msg, True)
+
         if not documentFrame or self.isZombie(documentFrame):
             documentFrame = self.documentFrame()
 
         if not documentFrame:
             if not searchIfNeeded:
+                msg = "WEB: Returning None, -1: No document and no search requested."
+                debug.println(debug.LEVEL_INFO, msg, True)
                 return None, -1
-            return self._getCaretContextViaLocusOfFocus()
+
+            obj, offset = self._getCaretContextViaLocusOfFocus()
+            msg = "WEB: Returning %s, %i (from locusOfFocus)" % (obj, offset)
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return obj, offset
 
         context = self._caretContexts.get(hash(documentFrame.parent))
         if not context or documentFrame != self.getTopLevelDocumentForObject(context[0]):
@@ -4663,6 +4672,8 @@ class Utilities(script_utilities.Utilities):
         elif not getZombieReplicant:
             return context
         elif self.isZombie(context[0]):
+            msg = "WEB: Context is Zombie. Searching for replicant."
+            debug.println(debug.LEVEL_INFO, msg, True)
             obj, offset = self.findContextReplicant()
             if obj:
                 caretObj, caretOffset = self.searchForCaretContext(obj.parent)
@@ -5002,6 +5013,8 @@ class Utilities(script_utilities.Utilities):
 
             parent = obj.parent
             if self.isZombie(parent):
+                msg = "WEB: Finding next caret in order. Parent is Zombie."
+                debug.println(debug.LEVEL_INFO, msg, True)
                 replicant = self.findReplicant(self.documentFrame(), parent)
                 if replicant and not self.isZombie(replicant):
                     parent = replicant
@@ -5066,6 +5079,8 @@ class Utilities(script_utilities.Utilities):
 
             parent = obj.parent
             if self.isZombie(parent):
+                msg = "WEB: Finding previous caret in order. Parent is Zombie."
+                debug.println(debug.LEVEL_INFO, msg, True)
                 replicant = self.findReplicant(self.documentFrame(), parent)
                 if replicant and not self.isZombie(replicant):
                     parent = replicant


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