[orca] Strip whitespace when name comes from contents rather than author



commit b42416a712ea772a553d5ca1ce96183f66f4c5d0
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Jul 13 15:46:16 2019 -0400

    Strip whitespace when name comes from contents rather than author
    
    If the user agent incorrectly adds whitespace, it can take up useless
    space in braille.

 src/orca/scripts/web/braille_generator.py | 11 +++++++++--
 src/orca/scripts/web/speech_generator.py  |  6 +++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/scripts/web/braille_generator.py b/src/orca/scripts/web/braille_generator.py
index d5db779e8..7da7df54d 100644
--- a/src/orca/scripts/web/braille_generator.py
+++ b/src/orca/scripts/web/braille_generator.py
@@ -111,7 +111,10 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
             return []
 
         if self._script.utilities.inDocumentContent(obj) and obj.name:
-            return [obj.name]
+            name = obj.name
+            if not self._script.utilities.hasExplicitName(obj):
+                name = name.strip()
+            return [name]
 
         return super()._generateLabelOrName(obj, **args)
 
@@ -145,7 +148,11 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
         if obj.name and not self._script.utilities.hasValidName(obj):
             return []
 
-        return super()._generateName(obj, **args)
+        result = super()._generateName(obj, **args)
+        if result and result[0] and not self._script.utilities.hasExplicitName(obj):
+            result[0] = result[0].strip()
+
+        return result
 
     def _generateExpandedEOCs(self, obj, **args):
         """Returns the expanded embedded object characters for an object."""
diff --git a/src/orca/scripts/web/speech_generator.py b/src/orca/scripts/web/speech_generator.py
index 0878a2b77..27a5ad4a0 100644
--- a/src/orca/scripts/web/speech_generator.py
+++ b/src/orca/scripts/web/speech_generator.py
@@ -207,7 +207,11 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
             if self._script.utilities.preferDescriptionOverName(obj):
                 result = [obj.description]
             else:
-                result = [obj.name]
+                name = obj.name
+                if not self._script.utilities.hasExplicitName(obj):
+                    name = name.strip()
+                result = [name]
+
             result.extend(self.voice(speech_generator.DEFAULT))
             return result
 


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