[orca] Fix false positive resulting from author using aria-labelledby to label itself



commit 412e1380fbe9901f4c440cdcf1e66b7f654fd6d2
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Jun 9 11:31:41 2020 -0400

    Fix false positive resulting from author using aria-labelledby to label itself
    
    If an author uses aria-labelledby on a partially-offscreen element pointing
    to itself, we might skip over the object due to falsely believing it is an
    off-screen label. Therefore remove any self-referential "labels" before doing
    this check.

 src/orca/scripts/web/script_utilities.py | 35 ++++++++++++++++----------------
 1 file changed, 17 insertions(+), 18 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index e77211f4b..3792f4274 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -3076,22 +3076,16 @@ class Utilities(script_utilities.Utilities):
             return rv
 
         rv = False
-        isLabelFor = lambda x: x.getRelationType() == pyatspi.RELATION_LABEL_FOR
-        try:
-            relationSet = obj.getRelationSet()
-        except:
-            pass
-        else:
-            relations = list(filter(isLabelFor, relationSet))
-            if relations:
-                try:
-                    text = obj.queryText()
-                    end = text.characterCount
-                except:
-                    end = 1
-                x, y, width, height = self.getExtents(obj, 0, end)
-                if x < 0 or y < 0:
-                    rv = True
+        targets = self.labelTargets(obj)
+        if targets:
+            try:
+                text = obj.queryText()
+                end = text.characterCount
+            except:
+                end = 1
+            x, y, width, height = self.getExtents(obj, 0, end)
+            if x < 0 or y < 0:
+                rv = True
 
         self._isOffScreenLabel[hash(obj)] = rv
         return rv
@@ -3194,9 +3188,14 @@ class Utilities(script_utilities.Utilities):
             return []
 
         r = relations[0]
-        rv = [r.getTarget(i) for i in range(r.getNTargets())]
-        rv = [hash(x) for x in rv if x is not None]
+        rv = set([r.getTarget(i) for i in range(r.getNTargets())])
 
+        if obj in rv:
+            msg = 'WARNING: %s claims to be a label for itself' % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            rv.remove(obj)
+
+        rv = [hash(x) for x in rv if x is not None]
         self._labelTargets[hash(obj)] = rv
         return rv
 


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