[orca] Prevent Orca from wandering into empty, hidden ARIA alerts



commit 10a5de1f579e94829aa77066078eecc1839fd4ec
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Apr 27 17:03:17 2020 -0400

    Prevent Orca from wandering into empty, hidden ARIA alerts
    
    Riot has an ARIA alert positioned in between the message list and the
    input field. We don't want to wander into this element when in browse
    mode if it has no message to present.

 src/orca/scripts/web/script_utilities.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index e752e1dd8..5a90d9a95 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2181,6 +2181,9 @@ class Utilities(script_utilities.Utilities):
         self._treatAsDiv[hash(obj)] = rv
         return rv
 
+    def isAriaAlert(self, obj):
+        return 'alert' in self._getXMLRoles(obj)
+
     def isBlockquote(self, obj):
         if super().isBlockquote(obj):
             return True
@@ -3771,7 +3774,7 @@ class Utilities(script_utilities.Utilities):
                  pyatspi.ROLE_STATIC,
                  pyatspi.ROLE_TABLE_ROW]
 
-        if role not in roles:
+        if role not in roles and not self.isAriaAlert(obj):
             rv = False
         elif state.contains(pyatspi.STATE_FOCUSABLE) or state.contains(pyatspi.STATE_FOCUSED):
             rv = False
@@ -4835,8 +4838,7 @@ class Utilities(script_utilities.Utilities):
             return False
 
         if event.type.startswith("object:text-changed:insert"):
-            isAlert = lambda x: x and x.getRole() == pyatspi.ROLE_ALERT
-            alert = pyatspi.findAncestor(event.source, isAlert)
+            alert = pyatspi.findAncestor(event.source, self.isAriaAlert)
             if alert and self.focusedObject(alert) == event.source:
                 msg = "WEB: Focused source will be presented as part of alert"
                 debug.println(debug.LEVEL_INFO, msg, True)


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