[orca] Chromium: Remove some unwanted noise from frame name when there is no URL



commit b25faee27e28cb1d31d7aef54f1cafbbbcf0de3c
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Feb 20 12:56:49 2020 +0100

    Chromium: Remove some unwanted noise from frame name when there is no URL
    
    If the active document in Chrome/Chromium lacks a URL, the frame name
    includes "untitled" and (depending on the version being used) "Google
    Chrome Dev". Some users find this annoying. And it's easy enough to
    detect and correct, substituting the app name for the noise....

 src/orca/script_utilities.py                            | 2 +-
 src/orca/scripts/toolkits/Chromium/braille_generator.py | 9 +++++++++
 src/orca/scripts/toolkits/Chromium/speech_generator.py  | 9 +++++++++
 src/orca/scripts/web/script_utilities.py                | 4 ++--
 4 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 9c7813073..d6f27ae64 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1197,7 +1197,7 @@ class Utilities:
         obj = obj or orca_state.locusOfFocus
         return self.getContainingDocument(obj) is not None
 
-    def activeDocument(self):
+    def activeDocument(self, window=None):
         return self.getContainingDocument(orca_state.locusOfFocus)
 
     def getContainingDocument(self, obj):
diff --git a/src/orca/scripts/toolkits/Chromium/braille_generator.py 
b/src/orca/scripts/toolkits/Chromium/braille_generator.py
index 3a48141a9..33b4865e9 100644
--- a/src/orca/scripts/toolkits/Chromium/braille_generator.py
+++ b/src/orca/scripts/toolkits/Chromium/braille_generator.py
@@ -39,6 +39,15 @@ class BrailleGenerator(web.BrailleGenerator):
     def __init__(self, script):
         super().__init__(script)
 
+    def _generateLabelOrName(self, obj, **args):
+        if obj.getRole() == pyatspi.ROLE_FRAME:
+            document = self._script.utilities.activeDocument(obj)
+            if document and not self._script.utilities.documentFrameURI(document):
+                # Eliminates including "untitled" in the frame name.
+                return super()._generateLabelOrName(obj.parent)
+
+        return super()._generateLabelOrName(obj)
+
     def generateBraille(self, obj, **args):
         if self._script.utilities.inDocumentContent(obj):
             return super().generateBraille(obj, **args)
diff --git a/src/orca/scripts/toolkits/Chromium/speech_generator.py 
b/src/orca/scripts/toolkits/Chromium/speech_generator.py
index bcafe736a..841b211f3 100644
--- a/src/orca/scripts/toolkits/Chromium/speech_generator.py
+++ b/src/orca/scripts/toolkits/Chromium/speech_generator.py
@@ -64,6 +64,15 @@ class SpeechGenerator(web.SpeechGenerator):
 
         return super()._generateListBoxItemWidgets(obj, **args)
 
+    def _generateLabelOrName(self, obj, **args):
+        if obj.getRole() == pyatspi.ROLE_FRAME:
+            document = self._script.utilities.activeDocument(obj)
+            if document and not self._script.utilities.documentFrameURI(document):
+                # Eliminates including "untitled" in the frame name.
+                return super()._generateLabelOrName(obj.parent)
+
+        return super()._generateLabelOrName(obj)
+
     def _generateRoleName(self, obj, **args):
         if self._script.utilities.isListItemMarker(obj):
             return []
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 527ad1507..35cb9b538 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -306,9 +306,9 @@ class Utilities(script_utilities.Utilities):
         orca_state.activeWindow = window
         return True
 
-    def activeDocument(self):
+    def activeDocument(self, window=None):
         isShowing = lambda x: x and x.getState().contains(pyatspi.STATE_SHOWING)
-        documents = self._getDocumentsEmbeddedBy(orca_state.activeWindow)
+        documents = self._getDocumentsEmbeddedBy(window or orca_state.activeWindow)
         documents = list(filter(isShowing, documents))
         if len(documents) == 1:
             return documents[0]


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