[orca] Web: Try to filter out duplicate caret-moved events resulting from click



commit ee411f2f0ef9e9908ad7a48f4f4083e662b5b67e
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Dec 14 12:53:23 2020 +0100

    Web: Try to filter out duplicate caret-moved events resulting from click
    
    We now clear our cache whenever the document or its descendant emits
    children-changed events. This prevents us from potentially getting
    stuck in a stale accessibility subtree. Unfortunately, if clicking
    with the mouse causes the browser to emit duplicate caret-moved events
    with a children-changed event in between, we'll double-speak that
    caret-moved event. Try to work around this by caching the last caret
    context resulting from a mouse click -- and not clearing that cache
    in response to children-changed.

 src/orca/scripts/web/script.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index d6f19e37e..14310fd55 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -74,6 +74,7 @@ class Script(default.Script):
         self._lastCommandWasCaretNav = False
         self._lastCommandWasStructNav = False
         self._lastCommandWasMouseButton = False
+        self._lastMouseButtonContext = None, -1
         self._lastMouseOverObject = None
         self._preMouseOverContext = None, -1
         self._inMouseOverObject = False
@@ -121,6 +122,7 @@ class Script(default.Script):
         self._lastCommandWasCaretNav = False
         self._lastCommandWasStructNav = False
         self._lastCommandWasMouseButton = False
+        self._lastMouseButtonContext = None, -1
         self._lastMouseOverObject = None
         self._preMouseOverContext = None, -1
         self._inMouseOverObject = False
@@ -536,6 +538,8 @@ class Script(default.Script):
         # won't know to dump the generator cache. See bgo#618827.
         self.generatorCache = {}
 
+        self._lastMouseButtonContext = None, -1
+
         handler = self.keyBindings.getInputHandler(keyboardEvent)
         if handler and self.caretNavigation.handles_navigation(handler):
             consumes = self.useCaretNavigationModel(keyboardEvent)
@@ -1560,6 +1564,13 @@ class Script(default.Script):
                 debug.println(debug.LEVEL_INFO, msg, True)
                 return True
 
+            if (event.source, event.detail1) == self._lastMouseButtonContext:
+                msg = "WEB: Event is for last mouse button context."
+                debug.println(debug.LEVEL_INFO, msg, True)
+                return True
+
+            self._lastMouseButtonContext = event.source, event.detail1
+
             msg = "WEB: Event handled: Last command was mouse button"
             debug.println(debug.LEVEL_INFO, msg, True)
             self.utilities.setCaretContext(event.source, event.detail1)
@@ -2405,6 +2416,7 @@ class Script(default.Script):
         self._lastCommandWasCaretNav = False
         self._lastCommandWasStructNav = False
         self._lastCommandWasMouseButton = False
+        self._lastMouseButtonContext = None, -1
         return False
 
     def getTransferableAttributes(self):


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