[orca] Flat-review: Sanity-check object have prsentable text



commit 4608174be436c25bcc0b149c3b41176c0f9c51d6
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Apr 20 13:47:07 2020 -0400

    Flat-review: Sanity-check object have prsentable text
    
    Some objects which implement the accessible text interface have non-
    presentable characters (e.g. private-use-area unicode symbols) as their
    sole content. In these instances, we want to use the accessible name of
    the object rather than its text.

 src/orca/flat_review.py                  | 13 ++++---------
 src/orca/script_utilities.py             | 12 +++++++++++-
 src/orca/scripts/web/script_utilities.py | 10 ----------
 3 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/src/orca/flat_review.py b/src/orca/flat_review.py
index f38a10f9a..84fa330eb 100644
--- a/src/orca/flat_review.py
+++ b/src/orca/flat_review.py
@@ -561,19 +561,14 @@ class Context:
         Returns a list of Zones.
         """
 
-        try:
-            text = accessible.queryText()
-        except NotImplementedError:
+        if not self.script.utilities.hasPresentableText(accessible):
             return []
-        else:
-            zones = []
+
+        zones = []
+        text = accessible.queryText()
 
         # TODO - JD: This is here temporarily whilst I sort out the rest
         # of the text-related mess.
-        if not re.search("[^\ufffc]", text.getText(0, -1)):
-            return []
-
-        # TODO - JD: Ditto.
         if "EditableText" in pyatspi.listInterfaces(accessible) \
            and accessible.getState().contains(pyatspi.STATE_SINGLE_LINE):
             extents = accessible.queryComponent().getExtents(0)
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 95d5ce3af..6616e88a3 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2037,6 +2037,16 @@ class Utilities:
     def isListItemMarker(self, obj):
         return False
 
+    def hasPresentableText(self, obj):
+        if self.isStaticTextLeaf(obj):
+            return False
+
+        text = self.queryNonEmptyText(obj)
+        if not text:
+            return False
+
+        return bool(re.search(r"\w+", text.getText(0, -1)))
+
     def getOnScreenObjects(self, root, extents=None):
         if not self.isOnScreen(root, extents):
             return []
@@ -2086,7 +2096,7 @@ class Utilities:
         hasNameOrDescription = (root.name or root.description)
         if role in [pyatspi.ROLE_PAGE_TAB, pyatspi.ROLE_IMAGE] and hasNameOrDescription:
             objects.append(root)
-        elif "Text" in interfaces and re.match("\w+", root.queryText().getText(0, -1)):
+        elif self.hasPresentableText(root):
             objects.append(root)
 
         for child in root:
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 4d8b3d06c..7e8ac57fe 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -1794,16 +1794,6 @@ class Utilities(script_utilities.Utilities):
 
         return contents
 
-    def hasPresentableText(self, obj):
-        if self.isStaticTextLeaf(obj):
-            return False
-
-        text = self.queryNonEmptyText(obj)
-        if not text:
-            return False
-
-        return bool(re.search(r"\w", text.getText(0, -1)))
-
     def updateCachedTextSelection(self, obj):
         if not self.inDocumentContent(obj):
             super().updateCachedTextSelection(obj)


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