[orca] Intercept deprecated focus: event for web content



commit 0526b319b17145ad471a085440db02c1a0c9a687
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Tue Jan 21 11:39:02 2020 -0500

    Intercept deprecated focus: event for web content
    
    User agents emit object:state-changed:focused correctly for web content.
    It's only the application toolkits / browser UI which sometimes fails
    to do so. And the event handler for focus: events was bypassing logic
    needed for proper presentation of web content.

 src/orca/scripts/toolkits/Gecko/script.py |  6 ++++--
 src/orca/scripts/web/script.py            | 11 +++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 38d1857af..b5ffae340 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -189,8 +189,10 @@ class Script(web.Script):
     def onFocus(self, event):
         """Callback for focus: accessibility events."""
 
-        # We should get proper state-changed events for these.
-        if self.utilities.inDocumentContent(event.source):
+        # This event is deprecated. We should get object:state-changed:focused
+        # events instead.
+
+        if super().onFocus(event):
             return
 
         if self.utilities.isLayoutOnly(event.source):
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 85d80520e..58e81ae63 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1774,6 +1774,17 @@ class Script(default.Script):
 
         return False
 
+    def onFocus(self, event):
+        """Callback for focus: accessibility events."""
+
+        # We should get proper state-changed events for these.
+        if self.utilities.inDocumentContent(event.source):
+            msg = "WEB: Ignoring because object:state-changed-focused expected."
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return True
+
+        return False
+
     def onFocusedChanged(self, event):
         """Callback for object:state-changed:focused accessibility events."""
 


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