[orca] More work on trying to make off-screen text suck less



commit eec5e1fa617c6d3882dbefd8cde64da3a0f0042f
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Apr 24 10:41:32 2019 -0400

    More work on trying to make off-screen text suck less
    
    User agents treat this stuff as if it were laid out with only a single
    word -- and sometimes a single character -- per line. In those cases,
    just return the text.

 src/orca/scripts/web/script_utilities.py | 36 ++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index cc695a9f5..ed587591d 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -70,6 +70,7 @@ class Utilities(script_utilities.Utilities):
         self._mathNestingLevel = {}
         self._isOffScreenLabel = {}
         self._isOffScreenLink = {}
+        self._isOffScreenTextBlockElement = {}
         self._hasExplicitName = {}
         self._hasNoSize = {}
         self._hasLongDesc = {}
@@ -143,6 +144,7 @@ class Utilities(script_utilities.Utilities):
         self._mathNestingLevel = {}
         self._isOffScreenLabel = {}
         self._isOffScreenLink = {}
+        self._isOffScreenTextBlockElement = {}
         self._hasExplicitName = {}
         self._hasNoSize = {}
         self._hasLongDesc = {}
@@ -1177,11 +1179,18 @@ class Utilities(script_utilities.Utilities):
                     math = self.getMathAncestor(obj)
                 return [[math, 0, 1, '']]
 
+            # Because user agents will give us this text word at a time.
             if self.isOffScreenLink(obj) and self.queryNonEmptyText(obj) and obj.name:
                 msg = "WEB: Returning name as contents for %s (is off-screen)" % obj
                 debug.println(debug.LEVEL_INFO, msg, True)
                 return [[obj, 0, len(obj.name), obj.name]]
 
+            # Because user agents will give us this text word at a time.
+            if self.isOffScreenTextBlockElement(obj) and self.queryNonEmptyText(obj):
+                msg = "WEB: Returning all text as contents for %s (is off-screen)" % obj
+                debug.println(debug.LEVEL_INFO, msg, True)
+                boundary = None
+
         role = obj.getRole()
         if role == pyatspi.ROLE_INTERNAL_FRAME and obj.childCount == 1:
             return self._getContentsForObj(obj[0], 0, boundary)
@@ -2444,6 +2453,29 @@ class Utilities(script_utilities.Utilities):
         self._isLayoutOnly[hash(obj)] = rv
         return rv
 
+    def isOffScreenTextBlockElement(self, obj):
+        if not (obj and self.inDocumentContent(obj)):
+            return False
+
+        rv = self._isOffScreenTextBlockElement.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        rv = False
+        if self.isTextBlockElement(obj):
+            x, y, width, height = self.getExtents(obj, 0, -1)
+            if x < 0 or y < 0:
+                msg = "WEB: %s is off-screen text block (%i, %i)" % (obj, x, y)
+                debug.println(debug.LEVEL_INFO, msg, True)
+                rv = True
+            elif width == 1 or height == 1:
+                msg = "WEB: %s is off-screen text block (%i x %i)" % (obj, width, height)
+                debug.println(debug.LEVEL_INFO, msg, True)
+                rv = True
+
+        self._isOffScreenTextBlockElement[hash(obj)] = rv
+        return rv
+
     def isOffScreenLink(self, obj):
         if not (obj and self.inDocumentContent(obj)):
             return False
@@ -2459,6 +2491,10 @@ class Utilities(script_utilities.Utilities):
                 msg = "WEB: %s is off-screen link (%i, %i)" % (obj, x, y)
                 debug.println(debug.LEVEL_INFO, msg, True)
                 rv = True
+            elif width == 1 or height == 1:
+                msg = "WEB: %s is off-screen link (%i x %i)" % (obj, width, height)
+                debug.println(debug.LEVEL_INFO, msg, True)
+                rv = True
 
         self._isOffScreenLink[hash(obj)] = rv
         return rv


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