[orca] More work on recovery from zombified elements



commit 831946ff0411b5d6cf03429850f49352bb85df85
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Feb 14 05:42:42 2017 -0500

    More work on recovery from zombified elements

 src/orca/scripts/web/script.py |   48 +++++++++++++++++----------------------
 1 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index f6592de..72a176a 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1492,31 +1492,22 @@ class Script(default.Script):
 
         if self.utilities.isZombie(obj):
             obj, offset = self.utilities.getCaretContext(getZombieReplicant=True)
-            if obj and self.utilities.isZombie(orca_state.locusOfFocus):
-                msg = "WEB: Updating focus and context to %s, %i" % (obj, offset)
-                debug.println(debug.LEVEL_INFO, msg, True)
-                orca.setLocusOfFocus(event, obj, notifyScript=False)
-                self.utilities.setCaretContext(obj, offset)
-
-        contextDocument = self.utilities.getDocumentForObject(obj)
-        if obj and document == contextDocument and self.utilities.isZombie(obj):
-            msg = "WEB: Context obj %s is Zombie." % obj
-            debug.println(debug.LEVEL_INFO, msg, True)
-            if self._inFocusMode:
-                msg = "WEB: Not looking for replicant due to focus mode."
-                debug.println(debug.LEVEL_INFO, msg, True)
-                return False
-
-            replicant = self.utilities.findReplicant(event.source, obj)
-            if replicant:
-                # Refrain from actually touching the replicant by grabbing
-                # focus or setting the caret in it. Doing so will only serve
-                # to anger it.
-                msg = "WEB: Event handled by updating locusOfFocus and context"
-                debug.println(debug.LEVEL_INFO, msg, True)
-                orca.setLocusOfFocus(event, replicant, False)
-                self.utilities.setCaretContext(replicant, offset)
-                return True
+            if not obj:
+                if self._inFocusMode:
+                    msg = "WEB: Not looking for replicant due to focus mode."
+                    debug.println(debug.LEVEL_INFO, msg, True)
+                    return False
+
+                obj = self.utilities.findReplicant(event.source, obj)
+                if obj:
+                    # Refrain from actually touching the replicant by grabbing
+                    # focus or setting the caret in it. Doing so will only serve
+                    # to anger it.
+                    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:
@@ -1614,8 +1605,8 @@ class Script(default.Script):
               % (obj, offset, orca_state.locusOfFocus)
         debug.println(debug.LEVEL_INFO, msg, True)
 
-        if obj and self.utilities.isZombie(obj):
-            msg = "WEB: Clearing context - obj is zombie"
+        if not obj or self.utilities.isZombie(obj):
+            msg = "WEB: Clearing context - obj is null or zombie"
             debug.println(debug.LEVEL_INFO, msg, True)
             self.utilities.clearCaretContext()
 
@@ -1625,6 +1616,9 @@ class Script(default.Script):
                 debug.println(debug.LEVEL_INFO, msg, True)
                 orca.setLocusOfFocus(event, obj, False)
                 self.utilities.setCaretContext(obj, offset)
+            else:
+                msg = "WEB: Search for caret context failed"
+                debug.println(debug.LEVEL_INFO, msg, True)
 
         if self._lastCommandWasCaretNav:
             msg = "WEB: Event ignored: Last command was caret nav"


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