[orca] More work on insertion, deletion, mark, and suggestion roles



commit f7e8e01e4129b2de1645e1aad5a70b5e06f505ec
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Fri Jan 24 14:40:31 2020 -0500

    More work on insertion, deletion, mark, and suggestion roles
    
    This improves handling of block children (e.g. paragraphs) inside
    the roles.
    
    Also don't bother getting the name of the suggestion role; ARIA plans
    for this to be a role for which names are prohibited.

 src/orca/formatting.py                   |  5 ++++-
 src/orca/script_utilities.py             |  3 +++
 src/orca/scripts/web/script_utilities.py | 19 ++++++++++++++-----
 src/orca/speech_generator.py             | 29 ++++++++++++++++++++++++++++-
 4 files changed, 49 insertions(+), 7 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index ef03201cb..76c281697 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -180,19 +180,22 @@ formatting = {
             },
         # TODO - JD: When we bump dependencies to 2.34, remove this fake role and use the real one.
         'ROLE_CONTENT_DELETION': {
+            'focused': 'leaving or deletionStart',
             'unfocused': 'deletionStart + pause + displayedText + pause + deletionEnd',
             },
         # TODO - JD: When we bump dependencies to 2.34, remove this fake role and use the real one.
         'ROLE_CONTENT_INSERTION': {
+            'focused': 'leaving or insertionStart',
             'unfocused': 'insertionStart + pause + displayedText + pause + insertionEnd',
             },
         # TODO - JD: When we bump dependencies to 2.36, remove this fake role and use the real one.
         'ROLE_CONTENT_MARK': {
+            'focused': 'leaving or markStart',
             'unfocused': 'markStart + pause + displayedText + pause + markEnd',
             },
         # TODO - JD: When we bump dependencies to 2.36, remove this fake role and use the real one.
         'ROLE_CONTENT_SUGGESTION': {
-            'focused': 'leaving or (labelOrName + roleName)',
+            'focused': 'leaving or roleName',
             },
         pyatspi.ROLE_DESCRIPTION_TERM: {
             'unfocused': '(labelOrName or (displayedText + allTextSelection))',
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 05f2c7357..f30bbb8ed 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -782,6 +782,9 @@ class Utilities:
     def isContentSuggestion(self, obj):
         return False
 
+    def isInlineSuggestion(self, obj):
+        return False
+
     def isLastItemInInlineContentSuggestion(self, obj):
         return False
 
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 57db2ed2b..6229b682c 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2165,13 +2165,16 @@ class Utilities(script_utilities.Utilities):
 
         return 'suggestion' in self._getXMLRoles(obj)
 
-    def isLastItemInInlineContentSuggestion(self, obj):
-        suggestion = pyatspi.findAncestor(obj, self.isContentSuggestion)
-        if not (suggestion and suggestion.childCount):
+    def isInlineSuggestion(self, obj):
+        if not self.isContentSuggestion(obj):
             return False
 
-        displayStyle = self._getDisplayStyle(suggestion)
-        if "inline" not in displayStyle:
+        displayStyle = self._getDisplayStyle(obj)
+        return "inline" in displayStyle
+
+    def isLastItemInInlineContentSuggestion(self, obj):
+        suggestion = pyatspi.findAncestor(obj, self.isInlineSuggestion)
+        if not (suggestion and suggestion.childCount):
             return False
 
         return suggestion[-1] == obj
@@ -2743,6 +2746,12 @@ class Utilities(script_utilities.Utilities):
             rv = False
         elif self.isLandmark(obj):
             rv = False
+        elif self.isContentDeletion(obj):
+            rv = False
+        elif self.isContentInsertion(obj):
+            rv = False
+        elif self.isContentMarked(obj):
+            rv = False
         elif self.isContentSuggestion(obj):
             rv = False
         elif self.isDPub(obj):
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 467fd8514..b50e86ae7 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -396,6 +396,14 @@ class SpeechGenerator(generator.Generator):
         result.extend(self.voice(SYSTEM))
         return result
 
+    def _generateSuggestionStart(self, obj, **args):
+        if _settingsManager.getSetting('onlySpeakDisplayedText'):
+            return []
+
+        result = [messages.CONTENT_SUGGESTION_START]
+        result.extend(self.voice(SYSTEM))
+        return result
+
     def _generateAvailability(self, obj, **args):
         if _settingsManager.getSetting('onlySpeakDisplayedText'):
             return []
@@ -1679,6 +1687,9 @@ class SpeechGenerator(generator.Generator):
 
     def _getEnabledAndDisabledContextRoles(self):
         allRoles = [pyatspi.ROLE_BLOCK_QUOTE,
+                    'ROLE_CONTENT_DELETION',
+                    'ROLE_CONTENT_INSERTION',
+                    'ROLE_CONTENT_MARK',
                     'ROLE_CONTENT_SUGGESTION',
                     pyatspi.ROLE_FORM,
                     pyatspi.ROLE_LANDMARK,
@@ -1698,6 +1709,9 @@ class SpeechGenerator(generator.Generator):
                 enabled.append(pyatspi.ROLE_LIST)
             if _settingsManager.getSetting('sayAllContextPanel'):
                 enabled.extend([pyatspi.ROLE_PANEL,
+                                'ROLE_CONTENT_DELETION',
+                                'ROLE_CONTENT_INSERTION',
+                                'ROLE_CONTENT_MARK',
                                 'ROLE_CONTENT_SUGGESTION',
                                 'ROLE_DPUB_SECTION'])
             if _settingsManager.getSetting('sayAllContextNonLandmarkForm'):
@@ -1713,6 +1727,9 @@ class SpeechGenerator(generator.Generator):
                 enabled.append(pyatspi.ROLE_LIST)
             if _settingsManager.getSetting('speakContextPanel'):
                 enabled.extend([pyatspi.ROLE_PANEL,
+                                'ROLE_CONTENT_DELETION',
+                                'ROLE_CONTENT_INSERTION',
+                                'ROLE_CONTENT_MARK',
                                 'ROLE_CONTENT_SUGGESTION',
                                 'ROLE_DPUB_SECTION'])
             if _settingsManager.getSetting('speakContextNonLandmarkForm'):
@@ -1835,7 +1852,14 @@ class SpeechGenerator(generator.Generator):
                 result = ['']
         elif role == pyatspi.ROLE_FORM:
             result.append(messages.LEAVING_FORM)
-        elif role == 'ROLE_CONTENT_SUGGESTION':
+        elif role == 'ROLE_CONTENT_DELETION':
+            result.append(messages.CONTENT_DELETION_END)
+        elif role == 'ROLE_CONTENT_INSERTION':
+            result.append(messages.CONTENT_INSERTION_END)
+        elif role == 'ROLE_CONTENT_MARK':
+            result.append(messages.CONTENT_MARK_END)
+        elif role == 'ROLE_CONTENT_SUGGESTION' \
+             and not self._script.utilities.isInlineSuggestion(obj):
             result.append(messages.LEAVING_SUGGESTION)
         else:
             result = ['']
@@ -1972,6 +1996,9 @@ class SpeechGenerator(generator.Generator):
         args['includeOnly'] = [pyatspi.ROLE_BLOCK_QUOTE,
                                pyatspi.ROLE_FORM,
                                pyatspi.ROLE_LANDMARK,
+                               'ROLE_CONTENT_DELETION',
+                               'ROLE_CONTENT_INSERTION',
+                               'ROLE_CONTENT_MARK',
                                'ROLE_CONTENT_SUGGESTION',
                                'ROLE_DPUB_LANDMARK',
                                'ROLE_DPUB_SECTION',


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