[orca] Don't bother testing preformatted/code elements for single-word lines



commit a83bca34a67d01820de7f85bb1a64bad0f1dc184
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Feb 17 13:16:45 2020 +0100

    Don't bother testing preformatted/code elements for single-word lines
    
    The single-word-lines test is designed to catch off-screen text which an
    author has provided just for screen readers, but which appears broken to
    us thanks to the associated CSS. This test can return a false positive for
    preformatted/code elements. And the odds are authors won't be hiding text
    for screen reader users in pre/code elements, so....

 src/orca/scripts/web/script_utilities.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 042600d68..f91248e94 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2732,10 +2732,22 @@ class Utilities(script_utilities.Utilities):
         self._isLayoutOnly[hash(obj)] = rv
         return rv
 
+    def elementIsPreformattedText(self, obj):
+        if self._getTag(obj) in ["pre", "code"]:
+            return True
+
+        if "code" in self._getXMLRoles(obj):
+            return True
+
+        return False
+
     def elementLinesAreSingleWords(self, obj):
         if not (obj and self.inDocumentContent(obj)):
             return False
 
+        if self.elementIsPreformattedText(obj):
+            return False
+
         rv = self._elementLinesAreSingleWords.get(hash(obj))
         if rv is not None:
             return rv


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