[orca] Stop using fake roles for ROLE_STATIC, ROLE_MATH_FRACTION, and ROLE_MATH_ROOT



commit 7e7d56bf38fd438cf838d67bc3a4b704b24494bc
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Mar 27 06:05:37 2017 -0400

    Stop using fake roles for ROLE_STATIC, ROLE_MATH_FRACTION, and ROLE_MATH_ROOT

 README                                    |    6 +-
 configure.ac                              |    8 ++--
 src/orca/formatting.py                    |   12 +----
 src/orca/generator.py                     |    8 +---
 src/orca/script_utilities.py              |   23 +---------
 src/orca/scripts/web/braille_generator.py |    9 ++--
 src/orca/scripts/web/script_utilities.py  |   61 +++++++++++-----------------
 src/orca/scripts/web/sound_generator.py   |    2 -
 src/orca/scripts/web/speech_generator.py  |    4 +-
 9 files changed, 44 insertions(+), 89 deletions(-)
---
diff --git a/README b/README
index b2453c2..d348517 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Orca v3.24.1pre
+Orca v3.25.1pre
 
 Introduction
 ========================================================================
@@ -23,7 +23,7 @@ requests.
 Dependencies
 ========================================================================
 
-Orca v3.24.x is supported on GNOME 3.24.x only.  We highly suggest you
+Orca v3.25.x is supported on GNOME 3.25.x only.  We highly suggest you
 use the latest releases of GNOME because they contain accessibility
 infrastructure and application bug fixes that help Orca work better.
 
@@ -39,7 +39,7 @@ Orca also has the following dependencies:
 * py-setproctitle  - Python library to set the process title (optional)
 * gstreamer-1.0    - GStreamer - Streaming media framework (optional)
 
-YOU ALSO NEED THE LATEST AT-SPI2, PYATSPI2 AND ATK FOR THE GNOME 3.24.x
+YOU ALSO NEED THE LATEST AT-SPI2, PYATSPI2 AND ATK FOR THE GNOME 3.25.x
 RELEASES.  THEY CONTAIN VERY IMPORTANT BUG FIXES!
 
 NOTE: If you have multiple versions of the Python interpreter installed
diff --git a/configure.ac b/configure.ac
index 542d706..a67381d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,12 +1,12 @@
 m4_define([orca_major_version], [3])
-m4_define([orca_minor_version], [24])
+m4_define([orca_minor_version], [25])
 m4_define([orca_micro_version], [1pre])
 m4_define([orca_version],
           [orca_major_version.orca_minor_version.orca_micro_version])
 
-m4_define(pygobject_required_version, 3.10)
-m4_define(atspi_required_version, 2.12)
-m4_define(atkbridge_required_version, 2.12)
+m4_define(pygobject_required_version, 3.18)
+m4_define(atspi_required_version, 2.18)
+m4_define(atkbridge_required_version, 2.18)
 
 AC_INIT([orca],
         [orca_version],
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index f2b09dc..80ab4dc 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -267,13 +267,10 @@ formatting = {
         'ROLE_MATH_FENCED': {
             'unfocused': 'fencedStart + pause + fencedContents + pause + fencedEnd',
         },
-        # TODO - JD: When we bump dependencies to 2.16, remove this fake role and use the real one.
-        'ROLE_MATH_FRACTION': {
+        pyatspi.ROLE_MATH_FRACTION: {
             'unfocused': 'fractionStart + pause + fractionNumerator + fractionLine + fractionDenominator + 
pause + fractionEnd + pause',
         },
-        # TODO - JD: When we bump dependencies to 2.16, remove this fake role and use the real one
-        # (assuming, of course, we've solved the square root/nth root identification problem too).
-        'ROLE_MATH_ROOT': {
+        pyatspi.ROLE_MATH_ROOT: {
             'unfocused': 'rootStart + rootBase + pause + rootEnd + pause',
         },
         # TODO - JD: When we bump dependencies to TBD, remove this fake role and use the real one.
@@ -389,10 +386,7 @@ formatting = {
             'unfocused': 'labelAndName + roleName + value + availability + ' + MNEMONIC,
             'basicWhereAmI' : 'labelAndName + roleName + value'
             },
-        # TODO - JD: There is now an actual ROLE_STATIC in ATK and AT-SPI2. Next
-        # time we need to bump dependencies for more significant things, we need
-        # to remove this fake role and use it instead.
-        'ROLE_STATIC': {
+        pyatspi.ROLE_STATIC: {
             'unfocused': '(displayedText or name) + roleName',
         },
         'ROLE_SWITCH': {
diff --git a/src/orca/generator.py b/src/orca/generator.py
index adb65d7..1da2281 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -1164,10 +1164,6 @@ class Generator:
 
     def _getAlternativeRole(self, obj, **args):
         if self._script.utilities.isMath(obj):
-            if self._script.utilities.isMathFraction(obj):
-                return 'ROLE_MATH_FRACTION'
-            if self._script.utilities.isMathRoot(obj):
-                return 'ROLE_MATH_ROOT'
             if self._script.utilities.isMathSubOrSuperScript(obj):
                 return 'ROLE_MATH_SCRIPT_SUBSUPER'
             if self._script.utilities.isMathUnderOrOverScript(obj):
@@ -1182,10 +1178,10 @@ class Generator:
                 return 'ROLE_MATH_TABLE'
             if self._script.utilities.isMathTableRow(obj):
                 return 'ROLE_MATH_TABLE_ROW'
-        if self._script.utilities.isStatic(obj):
-            return 'ROLE_STATIC'
         if self._script.utilities.isSwitch(obj):
             return 'ROLE_SWITCH'
+        if self._script.utilities.isAnchor(obj):
+            return pyatspi.ROLE_STATIC
         if self._script.utilities.isBlockquote(obj):
             return pyatspi.ROLE_BLOCK_QUOTE
         if self._script.utilities.isLandmark(obj):
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 379713d..e53d2ac 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -631,6 +631,9 @@ class Utilities:
 
         return toolbar is not None
 
+    def isAnchor(self, obj):
+        return False
+
     def isComboBoxWithToggleDescendant(self, obj):
         return False
 
@@ -702,21 +705,12 @@ class Utilities:
     def isMathFenced(self, obj):
         return False
 
-    def isMathFraction(self, obj):
-        return False
-
     def isMathFractionWithoutBar(self, obj):
         return False
 
     def isMathPhantom(self, obj):
         return False
 
-    def isMathRoot(self, obj):
-        return False
-
-    def isMathNthRoot(self, obj):
-        return False
-
     def isMathMultiScript(self, obj):
         return False
 
@@ -1079,17 +1073,6 @@ class Utilities:
 
         return _settingsManager.getSetting('readFullRowInDocumentTable')
 
-    def isStatic(self, obj):
-        role = obj.getRole()
-        try:
-            isStatic = role == pyatspi.ROLE_STATIC
-        except:
-            isStatic = False
-
-        if not isStatic and role == pyatspi.ROLE_TEXT:
-            isStatic = not obj.getState().contains(pyatspi.STATE_FOCUSABLE)
-        return isStatic
-
     def isFocusableLabel(self, obj):
         try:
             role = obj.getRole()
diff --git a/src/orca/scripts/web/braille_generator.py b/src/orca/scripts/web/braille_generator.py
index 9036d63..751e9eb 100644
--- a/src/orca/scripts/web/braille_generator.py
+++ b/src/orca/scripts/web/braille_generator.py
@@ -59,9 +59,9 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
             return [roledescription]
 
         doNotDisplay = [pyatspi.ROLE_FORM,
-                        pyatspi.ROLE_SECTION,
                         pyatspi.ROLE_PARAGRAPH,
-                        'ROLE_STATIC',
+                        pyatspi.ROLE_STATIC,
+                        pyatspi.ROLE_SECTION,
                         pyatspi.ROLE_UNKNOWN]
 
         state = obj.getState()
@@ -161,9 +161,8 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
         if self._script.utilities.isClickableElement(obj) \
            or self._script.utilities.isLink(obj):
             oldRole = self._overrideRole(pyatspi.ROLE_LINK, args)
-        elif self._script.utilities.isStatic(obj) \
-             or self._script.utilities.isAnchor(obj):
-            oldRole = self._overrideRole('ROLE_STATIC', args)
+        elif self._script.utilities.isAnchor(obj):
+            oldRole = self._overrideRole(pyatspi.ROLE_STATIC, args)
         elif self._script.utilities.treatAsDiv(obj, offset=args.get('startOffset')):
             oldRole = self._overrideRole(pyatspi.ROLE_SECTION, args)
 
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 6422da7..e84d7fb 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -1600,15 +1600,10 @@ class Utilities(script_utilities.Utilities):
                  pyatspi.ROLE_PARAGRAPH,
                  pyatspi.ROLE_ROW_HEADER,
                  pyatspi.ROLE_SECTION,
+                 pyatspi.ROLE_STATIC,
                  pyatspi.ROLE_TEXT,
                  pyatspi.ROLE_TABLE_CELL]
 
-        # TODO - JD: This protection won't be needed once we bump dependencies to 2.16.
-        try:
-            roles.append(pyatspi.ROLE_STATIC)
-        except:
-            pass
-
         return roles
 
     def unrelatedLabels(self, root, onlyShowing=True):
@@ -1797,11 +1792,14 @@ class Utilities(script_utilities.Utilities):
     def isMathFenced(self, obj):
         return self._getTag(obj) == 'mfenced'
 
-    def isMathFraction(self, obj):
-        return self._getTag(obj) == 'mfrac'
-
     def isMathFractionWithoutBar(self, obj):
-        if not self.isMathFraction(obj):
+        try:
+            role = obj.getRole()
+        except:
+            msg = "ERROR: Exception getting role for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+
+        if role != pyatspi.ROLE_MATH_FRACTION:
             return False
 
         try:
@@ -1822,12 +1820,6 @@ class Utilities(script_utilities.Utilities):
     def isMathPhantom(self, obj):
         return self._getTag(obj) == 'mphantom'
 
-    def isMathRoot(self, obj):
-        return self.isMathSquareRoot(obj) or self.isMathNthRoot(obj)
-
-    def isMathNthRoot(self, obj):
-        return self._getTag(obj) == 'mroot'
-
     def isMathMultiScript(self, obj):
         return self._getTag(obj) == 'mmultiscripts'
 
@@ -1886,30 +1878,33 @@ class Utilities(script_utilities.Utilities):
         return pyatspi.findAncestor(obj, self.isMathTopLevel)
 
     def getMathDenominator(self, obj):
-        if not self.isMathFraction(obj):
-            return None
+        try:
+            return obj[1]
+        except:
+            pass
 
-        return obj[1]
+        return None
 
     def getMathNumerator(self, obj):
-        if not self.isMathFraction(obj):
-            return None
+        try:
+            return obj[0]
+        except:
+            pass
 
-        return obj[0]
+        return None
 
     def getMathRootBase(self, obj):
-        if self.isMathNthRoot(obj):
-            return obj[0]
-
         if self.isMathSquareRoot(obj):
             return obj
 
+        try:
+            return obj[0]
+        except:
+            pass
+
         return None
 
     def getMathRootIndex(self, obj):
-        if not self.isMathNthRoot(obj):
-            return None
-
         try:
             return obj[1]
         except:
@@ -2459,17 +2454,9 @@ class Utilities(script_utilities.Utilities):
             return rv
 
         role = obj.getRole()
-
-        # TODO - JD: This protection won't be needed once we bump dependencies to 2.16.
-        try:
-            if role == pyatspi.ROLE_STATIC:
-                role = pyatspi.ROLE_TEXT
-        except:
-            pass
-
         if role == pyatspi.ROLE_LINK and not self.isAnchor(obj):
             rv = True
-        elif role == pyatspi.ROLE_TEXT \
+        elif role == pyatspi.ROLE_STATIC \
            and obj.parent.getRole() == pyatspi.ROLE_LINK \
            and obj.name and obj.name == obj.parent.name:
             rv = True
diff --git a/src/orca/scripts/web/sound_generator.py b/src/orca/scripts/web/sound_generator.py
index ca381ff..718451a 100644
--- a/src/orca/scripts/web/sound_generator.py
+++ b/src/orca/scripts/web/sound_generator.py
@@ -93,8 +93,6 @@ class SoundGenerator(sound_generator.SoundGenerator):
             oldRole = self._overrideRole('default', args)
         elif self._script.utilities.isLink(obj):
             oldRole = self._overrideRole(pyatspi.ROLE_LINK, args)
-        elif self._script.utilities.isAnchor(obj):
-            oldRole = 'ROLE_STATIC'
         elif self._script.utilities.treatAsDiv(obj):
             oldRole = self._overrideRole(pyatspi.ROLE_SECTION, args)
         else:
diff --git a/src/orca/scripts/web/speech_generator.py b/src/orca/scripts/web/speech_generator.py
index 50b4191..847bc4f 100644
--- a/src/orca/scripts/web/speech_generator.py
+++ b/src/orca/scripts/web/speech_generator.py
@@ -284,7 +284,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
         if not force:
             doNotSpeak.append(pyatspi.ROLE_TABLE_CELL)
             doNotSpeak.append(pyatspi.ROLE_TEXT)
-            doNotSpeak.append('ROLE_STATIC')
+            doNotSpeak.append(pyatspi.ROLE_STATIC)
             if args.get('formatType', 'unfocused') != 'basicWhereAmI':
                 doNotSpeak.append(pyatspi.ROLE_LIST_ITEM)
                 doNotSpeak.append(pyatspi.ROLE_LIST)
@@ -478,8 +478,6 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
             oldRole = self._overrideRole('default', args)
         elif self._script.utilities.isLink(obj):
             oldRole = self._overrideRole(pyatspi.ROLE_LINK, args)
-        elif self._script.utilities.isAnchor(obj):
-            oldRole = 'ROLE_STATIC'
         elif self._script.utilities.treatAsDiv(obj, offset=args.get('startOffset')):
             oldRole = self._overrideRole(pyatspi.ROLE_SECTION, args)
         else:


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