[orca/gnome-3-14] Fix several issues in label inference for Gecko content



commit 67b757545fc66f0fe1f0055b638e783ff3fee6fb
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Sep 13 18:12:16 2014 -0400

    Fix several issues in label inference for Gecko content

 src/orca/label_inference.py                        |   24 +++++---------------
 src/orca/script_utilities.py                       |    3 ++
 .../scripts/toolkits/Gecko/script_utilities.py     |   14 ++++++++++-
 .../scripts/toolkits/WebKitGtk/script_utilities.py |    4 +++
 .../firefox/label_inference_bug_546815.py          |   10 +++-----
 .../firefox/label_inference_bugzilla_search.py     |   12 +++++-----
 test/keystrokes/firefox/label_inference_entries.py |   15 +++++-------
 7 files changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/src/orca/label_inference.py b/src/orca/label_inference.py
index 6eb50a0..3af8727 100644
--- a/src/orca/label_inference.py
+++ b/src/orca/label_inference.py
@@ -260,24 +260,15 @@ class LabelInference:
             start, end = self._script.utilities.getHyperlinkRange(obj)
             obj = obj.parent
 
-        boundary = pyatspi.TEXT_BOUNDARY_LINE_START
-
         try:
             text = obj.queryText()
-        except NotImplementedError:
-            pass
-        except AttributeError:
-            debug.println(debug.LEVEL_FINE, "INFER _getLineContents: no obj")
+        except:
+            start = 0
         else:
             if start == None:
                 start = max(0, text.caretOffset)
-            else:
-                start = max(0, start - 1)
-            string, start, end = text.getTextAtOffset(start, boundary)
-            if string.endswith('\n'):
-                start = end
 
-        rv = self._script.utilities.getObjectsFromEOCs(obj, start, boundary)
+        rv = self._script.utilities.getLineContentsAtOffset(obj, start)
         self._lineCache[key] = rv
 
         return rv
@@ -414,9 +405,8 @@ class LabelInference:
         if not (objWidth and objHeight):
             return None
 
-        boundary = pyatspi.TEXT_BOUNDARY_LINE_START
-        prevLine = self._script.utilities.getObjectsFromEOCs(
-            prevObj, start, boundary)
+        start = max(start - 1, 0)
+        prevLine = self._script.utilities.getLineContentsAtOffset(prevObj, start)
         if not (prevLine and prevLine[0]):
             return None
 
@@ -474,9 +464,7 @@ class LabelInference:
         if not (objWidth and objHeight):
             return None
 
-        boundary = pyatspi.TEXT_BOUNDARY_LINE_START
-        nextLine = self._script.utilities.getObjectsFromEOCs(
-            lastObj, end, boundary)
+        nextLine = self._script.utilities.getLineContentsAtOffset(lastObj, end)
         if not (nextLine and nextLine[0]):
             return None
 
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 40c2951..392daf8 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2676,6 +2676,9 @@ class Utilities:
             debug.printException(debug.LEVEL_WARNING)
             return ""
 
+    def getLineContentsAtOffset(self, obj, offset, layoutMode=True):
+        return []
+
     def getObjectsFromEOCs(self, obj, offset=None, boundary=None):
         """Breaks the string containing a mixture of text and embedded object
         characters into a list of (obj, startOffset, endOffset, string) tuples.
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py 
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 2ef1f20..1185138 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -637,8 +637,18 @@ class Utilities(script_utilities.Utilities):
             return [[obj, start, end, string]]
 
         stringOffset = offset - start
-        strings = [m.span() for m in re.finditer("[^\ufffc]+", string)]
-        strings = list(filter(lambda x: x[0] <= stringOffset <= x[1], strings))
+        try:
+            char = string[stringOffset]
+        except:
+            pass
+        else:
+            if char == self.EMBEDDED_OBJECT_CHARACTER:
+                childIndex = self._script.getChildIndex(obj, offset)
+                child = obj[childIndex]
+                return [[child, 0, 1, ""]]
+
+        ranges = [m.span() for m in re.finditer("[^\ufffc]+", string)]
+        strings = list(filter(lambda x: x[0] <= stringOffset <= x[1], ranges))
         if len(strings) == 1:
             rangeStart, rangeEnd = strings[0]
             start += rangeStart
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py 
b/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
index 9ef627c..74cb47c 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
@@ -95,6 +95,10 @@ class Utilities(script_utilities.Utilities):
 
         return text
 
+    def getLineContentsAtOffset(self, obj, offset, layoutMode=True):
+        return self.getObjectsFromEOCs(
+            obj, offset, pyatspi.TEXT_BOUNDARY_LINE_START)
+
     def getObjectsFromEOCs(self, obj, offset=None, boundary=None):
         """Breaks the string containing a mixture of text and embedded object
         characters into a list of (obj, startOffset, endOffset, string) tuples.
diff --git a/test/keystrokes/firefox/label_inference_bug_546815.py 
b/test/keystrokes/firefox/label_inference_bug_546815.py
index 033d904..f037d1c 100644
--- a/test/keystrokes/firefox/label_inference_bug_546815.py
+++ b/test/keystrokes/firefox/label_inference_bug_546815.py
@@ -85,10 +85,9 @@ sequence.append(KeyComboAction("Tab"))
 sequence.append(KeyReleaseAction(0, None, "KP_Insert"))
 sequence.append(utils.AssertPresentationAction(
     "8. Next form field",
-    ["KNOWN ISSUE: This is broken",
-     "BRAILLE LINE:  '< > check box bird'",
+    ["BRAILLE LINE:  '< > check box bird'",
      "     VISIBLE:  '< > check box bird', cursor=0",
-     "SPEECH OUTPUT: 'check box not checked'"]))
+     "SPEECH OUTPUT: 'bird check box not checked'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyPressAction(0, None, "KP_Insert"))
@@ -116,10 +115,9 @@ sequence.append(KeyComboAction("Tab"))
 sequence.append(KeyReleaseAction(0, None, "KP_Insert"))
 sequence.append(utils.AssertPresentationAction(
     "11. Next form field",
-    ["KNOWN ISSUE: This is broken",
-     "BRAILLE LINE:  '&=y radio button cabernet sauvignon'",
+    ["BRAILLE LINE:  '&=y radio button cabernet sauvignon'",
      "     VISIBLE:  '&=y radio button cabernet sauvig', cursor=0",
-     "SPEECH OUTPUT: 'selected radio button'"]))
+     "SPEECH OUTPUT: 'cabernet sauvignon selected radio button'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyPressAction(0, None, "KP_Insert"))
diff --git a/test/keystrokes/firefox/label_inference_bugzilla_search.py 
b/test/keystrokes/firefox/label_inference_bugzilla_search.py
index 24e220f..3f30087 100644
--- a/test/keystrokes/firefox/label_inference_bugzilla_search.py
+++ b/test/keystrokes/firefox/label_inference_bugzilla_search.py
@@ -28,7 +28,7 @@ sequence.append(utils.AssertPresentationAction(
      "     VISIBLE:  'Summary: contains all of the wor', cursor=0",
      "BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=1",
-     "SPEECH OUTPUT: 'entry'"]))
+     "SPEECH OUTPUT: 'Summary: entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Tab"))
@@ -125,7 +125,7 @@ sequence.append(utils.AssertPresentationAction(
     "11. Tab",
     ["BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=1",
-     "SPEECH OUTPUT: 'entry'"]))
+     "SPEECH OUTPUT: 'A Comment: entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Tab"))
@@ -141,7 +141,7 @@ sequence.append(utils.AssertPresentationAction(
     "13. Tab",
     ["BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=1",
-     "SPEECH OUTPUT: 'entry'"]))
+     "SPEECH OUTPUT: 'Whiteboard: entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Tab"))
@@ -175,7 +175,7 @@ sequence.append(utils.AssertPresentationAction(
      "     VISIBLE:  'Keywords: contains all of the ke', cursor=0",
      "BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=1",
-     "SPEECH OUTPUT: 'entry'"]))
+     "SPEECH OUTPUT: 'Keywords entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Tab"))
@@ -369,7 +369,7 @@ sequence.append(utils.AssertPresentationAction(
     "37. Tab",
     ["BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=1",
-     "SPEECH OUTPUT: '(comma-separated list) entry'"]))
+     "SPEECH OUTPUT: 'bugs numbered: entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Tab"))
@@ -388,7 +388,7 @@ sequence.append(utils.AssertPresentationAction(
      "     VISIBLE:  'Now $l', cursor=4",
      "BRAILLE LINE:  'Now $l'",
      "     VISIBLE:  'Now $l', cursor=4",
-     "SPEECH OUTPUT: '(YYYY-MM-DD or relative dates) entry Now selected'"]))
+     "SPEECH OUTPUT: 'and entry Now selected'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Tab"))
diff --git a/test/keystrokes/firefox/label_inference_entries.py 
b/test/keystrokes/firefox/label_inference_entries.py
index 11801bc..b421642 100644
--- a/test/keystrokes/firefox/label_inference_entries.py
+++ b/test/keystrokes/firefox/label_inference_entries.py
@@ -87,10 +87,9 @@ sequence.append(KeyComboAction("Tab"))
 sequence.append(KeyReleaseAction(0, None, "KP_Insert"))
 sequence.append(utils.AssertPresentationAction(
     "8. Next form field",
-    ["KNOWN ISSUE: We are not infering the label here.",
-     "BRAILLE LINE:  ' $l'",
+    ["BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=0",
-     "SPEECH OUTPUT: 'entry'"]))
+     "SPEECH OUTPUT: 'First Name entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyPressAction(0, None, "KP_Insert"))
@@ -98,10 +97,9 @@ sequence.append(KeyComboAction("Tab"))
 sequence.append(KeyReleaseAction(0, None, "KP_Insert"))
 sequence.append(utils.AssertPresentationAction(
     "9. Next form field",
-    ["KNOWN ISSUE: We are not infering the label here.",
-     "BRAILLE LINE:  ' $l'",
+    ["BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=0",
-     "SPEECH OUTPUT: 'entry'"]))
+     "SPEECH OUTPUT: 'M.I. entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyPressAction(0, None, "KP_Insert"))
@@ -109,10 +107,9 @@ sequence.append(KeyComboAction("Tab"))
 sequence.append(KeyReleaseAction(0, None, "KP_Insert"))
 sequence.append(utils.AssertPresentationAction(
     "10. Next form field",
-    ["KNOWN ISSUE: We are not infering the label here.",
-     "BRAILLE LINE:  ' $l'",
+    ["BRAILLE LINE:  ' $l'",
      "     VISIBLE:  ' $l', cursor=0",
-     "SPEECH OUTPUT: 'entry'"]))
+     "SPEECH OUTPUT: 'Last Name entry'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyPressAction(0, None, "KP_Insert"))


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