[orca] Web: Improve behavior of label ancestors of widgets



commit 5fe5f80c3502ce3b49454ea09f20df909c84db7b
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Jan 3 13:46:04 2022 +0100

    Web: Improve behavior of label ancestors of widgets
    
    * Never treat them as offscreen/hidden labels because doing so can cause
      us to skip over the widget should the label element be offscreen
    * Don't keep saying "clickable" when navigating within the label content.

 src/orca/scripts/web/script_utilities.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 345423eef..7e3516582 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -73,6 +73,7 @@ class Utilities(script_utilities.Utilities):
         self._isFocusableWithMathChild = {}
         self._mathNestingLevel = {}
         self._isOffScreenLabel = {}
+        self._labelIsAncestorOfLabelled = {}
         self._elementLinesAreSingleChars= {}
         self._elementLinesAreSingleWords= {}
         self._hasNoSize = {}
@@ -167,6 +168,7 @@ class Utilities(script_utilities.Utilities):
         self._isFocusableWithMathChild = {}
         self._mathNestingLevel = {}
         self._isOffScreenLabel = {}
+        self._labelIsAncestorOfLabelled = {}
         self._elementLinesAreSingleChars= {}
         self._elementLinesAreSingleWords= {}
         self._hasNoSize = {}
@@ -3249,6 +3251,23 @@ class Utilities(script_utilities.Utilities):
         self._elementLinesAreSingleChars[hash(obj)] = rv
         return rv
 
+    def labelIsAncestorOfLabelled(self, obj):
+        if not (obj and self.inDocumentContent(obj)):
+            return False
+
+        rv = self._labelIsAncestorOfLabelled.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        rv = False
+        for target in self.targetsForLabel(obj):
+            if pyatspi.findAncestor(target, lambda x: x == obj):
+                rv = True
+                break
+
+        self._labelIsAncestorOfLabelled[hash(obj)] = rv
+        return rv
+
     def isOffScreenLabel(self, obj):
         if not (obj and self.inDocumentContent(obj)):
             return False
@@ -3257,6 +3276,9 @@ class Utilities(script_utilities.Utilities):
         if rv is not None:
             return rv
 
+        if self.labelIsAncestorOfLabelled(obj):
+            return False
+
         rv = False
         targets = self.labelTargets(obj)
         if targets:
@@ -3514,6 +3536,9 @@ class Utilities(script_utilities.Utilities):
         if rv is not None:
             return rv
 
+        if self.labelIsAncestorOfLabelled(obj):
+            return False
+
         rv = False
         if not obj.getState().contains(pyatspi.STATE_FOCUSABLE) \
            and not self.isFocusModeWidget(obj):


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