[orca] Fix presentation of focusable text with MathML children



commit 668663581654769f436c2017053669c3600ee9d6
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Jan 3 12:20:58 2019 -0500

    Fix presentation of focusable text with MathML children
    
    https://gitlab.gnome.org/GNOME/orca/issues/26

 src/orca/scripts/web/script.py           |  5 ++++
 src/orca/scripts/web/script_utilities.py | 40 ++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 5afa0b7b6..5c4536389 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1191,6 +1191,11 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg, True)
             contents = self.utilities.getLineContentsAtOffset(newFocus, caretOffset)
             utterances = self.speechGenerator.generateContents(contents)
+        elif self.utilities.isFocusedWithMathChild(newFocus):
+            msg = "WEB: New focus %s has math child. Generating line contents." % newFocus
+            debug.println(debug.LEVEL_INFO, msg, True)
+            contents = self.utilities.getLineContentsAtOffset(newFocus, caretOffset)
+            utterances = self.speechGenerator.generateContents(contents)
         elif newFocus.getRole() == pyatspi.ROLE_HEADING:
             msg = "WEB: New focus %s is heading. Generating object contents." % newFocus
             debug.println(debug.LEVEL_INFO, msg, True)
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 68b8ee976..0ae97c81a 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -65,6 +65,7 @@ class Utilities(script_utilities.Utilities):
         self._isLayoutOnly = {}
         self._isDPub = {}
         self._isMath = {}
+        self._isFocusableWithMathChild = {}
         self._mathNestingLevel = {}
         self._isOffScreenLabel = {}
         self._hasExplicitName = {}
@@ -131,6 +132,7 @@ class Utilities(script_utilities.Utilities):
         self._isLayoutOnly = {}
         self._isDPub = {}
         self._isMath = {}
+        self._isFocusableWithMathChild = {}
         self._mathNestingLevel = {}
         self._isOffScreenLabel = {}
         self._hasExplicitName = {}
@@ -1716,6 +1718,44 @@ class Utilities(script_utilities.Utilities):
 
         return []
 
+    def isFocusableWithMathChild(self, obj):
+        if not (obj and self.inDocumentContent(obj)):
+            return False
+
+        rv = self._isFocusableWithMathChild.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        try:
+            state = obj.getState()
+        except:
+            msg = "WEB: Exception getting state for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        rv = False
+        if state.contains(pyatspi.STATE_FOCUSABLE) and not self.isDocument(obj):
+            for child in obj:
+                if self.isMathTopLevel(child):
+                    rv = True
+                    break
+
+        self._isFocusableWithMathChild[hash(obj)] = rv
+        return rv
+
+    def isFocusedWithMathChild(self, obj):
+        if not self.isFocusableWithMathChild(obj):
+            return False
+
+        try:
+            state = obj.getState()
+        except:
+            msg = "WEB: Exception getting state for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        return state.contains(pyatspi.STATE_FOCUSED)
+
     def isTextBlockElement(self, obj):
         if not (obj and self.inDocumentContent(obj)):
             return False


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