[orca] Fix bug in line navigation of MathML content



commit 561adc5aacd67abb12b2717ebb0af7a018aa9eae
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Aug 11 17:51:15 2015 -0400

    Fix bug in line navigation of MathML content

 src/orca/scripts/web/script_utilities.py           |   24 +++++++-
 .../firefox/math_line_nav_mathvariant.py           |   68 +++++++++----------
 test/keystrokes/firefox/math_line_nav_mrow.py      |   15 +----
 3 files changed, 58 insertions(+), 49 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 7522935..8c664da 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -383,6 +383,24 @@ class Utilities(script_utilities.Utilities):
 
         return prevobj, prevoffset
 
+    def lastContext(self, root):
+        offset = 0
+        text = self.queryNonEmptyText(root)
+        if text:
+            offset = text.characterCount - 1
+
+        def _isInRoot(o):
+            return o == root or pyatspi.utils.findAncestor(o, lambda x: x == root)
+
+        obj = root
+        while obj:
+            lastobj, lastoffset = self.nextContext(obj, offset)
+            if not (lastobj and _isInRoot(lastobj)):
+                break
+            obj, offset = lastobj, lastoffset
+
+        return obj, offset
+
     def contextsAreOnSameLine(self, a, b):
         if a == b:
             return True
@@ -1132,7 +1150,11 @@ class Utilities(script_utilities.Utilities):
         if not (line and line[0]):
             return []
 
-        lastObj, lastOffset = line[-1][0], line[-1][2] - 1
+        math = self.getMathAncestor(obj)
+        if math:
+            lastObj, lastOffset = self.lastContext(math)
+        else:
+            lastObj, lastOffset = line[-1][0], line[-1][2] - 1
         msg = "INFO: Last context on line is: %s, %i" % (lastObj, lastOffset)
         debug.println(debug.LEVEL_INFO, msg)
 
diff --git a/test/keystrokes/firefox/math_line_nav_mathvariant.py 
b/test/keystrokes/firefox/math_line_nav_mathvariant.py
index 94dc5a3..cbdfe1a 100644
--- a/test/keystrokes/firefox/math_line_nav_mathvariant.py
+++ b/test/keystrokes/firefox/math_line_nav_mathvariant.py
@@ -26,45 +26,41 @@ sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
     "3. Line Down",
-    ["KNOWN ISSUE: We seem to get stuck on the previous item.",
-     "BRAILLE LINE:  'math'",
+    ["BRAILLE LINE:  'End of first case'",
+     "     VISIBLE:  'End of first case', cursor=1",
+     "SPEECH OUTPUT: 'End of first case'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+    "4. Line Down",
+    ["BRAILLE LINE:  'math'",
+     "     VISIBLE:  'math', cursor=0",
+     "SPEECH OUTPUT: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q 
r s t u v w x y z'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+    "5. Line Down",
+    ["BRAILLE LINE:  'End of second case'",
+     "     VISIBLE:  'End of second case', cursor=1",
+     "SPEECH OUTPUT: 'End of second case'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+    "6. Line Down",
+    ["BRAILLE LINE:  'math'",
      "     VISIBLE:  'math', cursor=0",
      "SPEECH OUTPUT: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q 
r s t u v w x y z'"]))
-#     "BRAILLE LINE:  'End of first case'",
-#     "     VISIBLE:  'End of first case', cursor=1",
-#     "SPEECH OUTPUT: 'End of first case'"]))
 
-#sequence.append(utils.StartRecordingAction())
-#sequence.append(KeyComboAction("Down"))
-#sequence.append(utils.AssertPresentationAction(
-#    "4. Line Down",
-#    ["BRAILLE LINE:  'math'",
-#     "     VISIBLE:  'math', cursor=0",
-#     "SPEECH OUTPUT: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q 
r s t u v w x y z'"]))
-#
-#sequence.append(utils.StartRecordingAction())
-#sequence.append(KeyComboAction("Down"))
-#sequence.append(utils.AssertPresentationAction(
-#    "5. Line Down",
-#    ["BRAILLE LINE:  'End of second case'",
-#     "     VISIBLE:  'End of second case', cursor=1",
-#     "SPEECH OUTPUT: 'End of second case'"]))
-#
-#sequence.append(utils.StartRecordingAction())
-#sequence.append(KeyComboAction("Down"))
-#sequence.append(utils.AssertPresentationAction(
-#    "6. Line Down",
-#    ["BRAILLE LINE:  'math'",
-#     "     VISIBLE:  'math', cursor=0",
-#     "SPEECH OUTPUT: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q 
r s t u v w x y z'"]))
-#
-#sequence.append(utils.StartRecordingAction())
-#sequence.append(KeyComboAction("Down"))
-#sequence.append(utils.AssertPresentationAction(
-#    "7. Line Down",
-#    ["BRAILLE LINE:  'End of test'",
-#     "     VISIBLE:  'End of test', cursor=1",
-#     "SPEECH OUTPUT: 'End of test'"]))
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+    "7. Line Down",
+    ["BRAILLE LINE:  'End of test'",
+     "     VISIBLE:  'End of test', cursor=1",
+     "SPEECH OUTPUT: 'End of test'"]))
 
 sequence.append(utils.AssertionSummaryAction())
 sequence.start()
diff --git a/test/keystrokes/firefox/math_line_nav_mrow.py b/test/keystrokes/firefox/math_line_nav_mrow.py
index 797567c..823679b 100644
--- a/test/keystrokes/firefox/math_line_nav_mrow.py
+++ b/test/keystrokes/firefox/math_line_nav_mrow.py
@@ -42,18 +42,9 @@ sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
     "5. Line Down",
-    ["KNOWN ISSUE: And we seem to be getting stuck here",
-     "BRAILLE LINE:  'math'",
-     "     VISIBLE:  'math', cursor=0",
-     "SPEECH OUTPUT: 'left paren x ≪̸ y right paren logical and left paren X ⊂⃒ Y right paren'"]))
-
-#sequence.append(utils.StartRecordingAction())
-#sequence.append(KeyComboAction("Down"))
-#sequence.append(utils.AssertPresentationAction(
-#    "5. Line Down",
-#    ["BRAILLE LINE:  'End of test'",
-#     "     VISIBLE:  'End of test', cursor=1",
-#     "SPEECH OUTPUT: 'End of test'"]))
+    ["BRAILLE LINE:  'End of test'",
+     "     VISIBLE:  'End of test', cursor=1",
+     "SPEECH OUTPUT: 'End of test'"]))
 
 sequence.append(utils.AssertionSummaryAction())
 sequence.start()


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