[orca] Ignore caret-moved events from outside the active grid in focus mode



commit 8c9391518ddf94f39b7bc2d4f4937050808bb56e
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Apr 6 17:39:14 2020 -0400

    Ignore caret-moved events from outside the active grid in focus mode
    
    If the user is arrowing within a grid in focus mode we should not be
    getting caret-moved events from outside the grid. And if we are, we
    should not present them nor update our state or mode. We are seeing
    this sort of thing happen in (at least) Chromium with (at least)
    Gmail when the user attempts to arrow past the last column.

 src/orca/scripts/web/script.py           |  5 +++++
 src/orca/scripts/web/script_utilities.py | 10 ++++++++++
 2 files changed, 15 insertions(+)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index f0cb78f19..fd851549f 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1505,6 +1505,11 @@ class Script(default.Script):
             self._saveLastCursorPosition(event.source, event.detail1)
             return True
 
+        if self._inFocusMode and self.utilities.caretMovedOutsideActiveGrid(event):
+            msg = "WEB: Event ignored: Caret moved outside active grid during focus mode"
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return True
+
         obj, offset = self.utilities.findFirstCaretContext(event.source, event.detail1)
 
         if self.utilities.caretMovedToSamePageFragment(event):
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 0d51a290f..8527f76ea 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -4147,6 +4147,16 @@ class Utilities(script_utilities.Utilities):
 
         return False
 
+    def caretMovedOutsideActiveGrid(self, event, oldFocus=None):
+        if not (event and event.type.startswith("object:text-caret-moved")):
+            return False
+
+        oldFocus = oldFocus or orca_state.locusOfFocus
+        if not self.isGridDescendant(oldFocus):
+            return False
+
+        return not self.isGridDescendant(event.source)
+
     def caretMovedToSamePageFragment(self, event, oldFocus=None):
         if not (event and event.type.startswith("object:text-caret-moved")):
             return False


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