[orca/gnome-42] Web: Don't allow time element or role to be parsed as sentences



commit e3a1cc97d1547e6bd7ec2330a32ee5794443f9b7
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Jun 30 18:25:40 2022 +0200

    Web: Don't allow time element or role to be parsed as sentences
    
    Because the time element has various punctuation marks in it, user
    agents sometimes expose it as being divided into multiple sentences.
    Given a time element inside of a link while doing a SayAll by
    sentence, we can theoretically repeat "link" after each substring
    reported to us as a full sentence. Alternatively we might say "link"
    only once, but somewhere in the middle rather than at the end.
    
    This commit solves that problem by always treating the time element
    as a single sentence, rather than asking user agents for its sentences.
    
    Fixes issue #247

 src/orca/scripts/web/script_utilities.py | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index ed4a05991..3fe55dd58 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -1408,6 +1408,11 @@ class Utilities(script_utilities.Utilities):
         if not obj:
             return []
 
+        if boundary == pyatspi.TEXT_BOUNDARY_SENTENCE_START and self.isTime(obj):
+            text = self.queryNonEmptyText(obj)
+            if text:
+                return [[obj, 0, text.characterCount, text.getText(0, -1)]]
+
         if boundary == pyatspi.TEXT_BOUNDARY_LINE_START:
             if self.isMath(obj):
                 if self.isMathTopLevel(obj):
@@ -3087,6 +3092,9 @@ class Utilities(script_utilities.Utilities):
         self._isNavigableToolTipDescendant[hash(obj)] = rv
         return rv
 
+    def isTime(self, obj):
+        return 'time' in self._getXMLRoles(obj) or 'time' == self._getTag(obj)
+
     def isToolBarDescendant(self, obj):
         if not obj:
             return False


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