[orca] Work around Gecko's bogus claim that a word starts and ends on different lines



commit 8cf832b4156e82093d9499a7c6507abf589a19f7
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Jan 10 05:07:48 2017 -0500

    Work around Gecko's bogus claim that a word starts and ends on different lines

 src/orca/scripts/web/script_utilities.py |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 1b8db13..9e11ff7 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -826,8 +826,16 @@ class Utilities(script_utilities.Utilities):
             return span[0] <= offset <= span[1]
 
         def _onThisLine(span):
-            rangeExtents = list(text.getRangeExtents(span[0], span[0] + 1, 0))
-            return self.extentsAreOnSameLine(extents, rangeExtents)
+            start, end = span
+            startExtents = list(text.getRangeExtents(start, start + 1, 0))
+            endExtents = list(text.getRangeExtents(end - 1, end, 0))
+            if not self.extentsAreOnSameLine(startExtents, endExtents):
+                msg = "FAIL: Start %s and end %s of '%s' not on same line" \
+                      % (startExtents, endExtents, allText[start:end])
+                debug.println(debug.LEVEL_INFO, msg, True)
+                startExtents = endExtents
+
+            return self.extentsAreOnSameLine(extents, startExtents)
 
         spans = []
         charCount = text.characterCount
@@ -1406,6 +1414,12 @@ class Utilities(script_utilities.Utilities):
         debug.println(debug.LEVEL_INFO, msg, True)
 
         contents = self.getLineContentsAtOffset(obj, offset, layoutMode, useCache)
+        if line == contents:
+            obj, offset = self.nextContext(obj, offset, True)
+            msg = "WEB: Got same line. Trying again with %s, %i" % (obj, offset)
+            debug.println(debug.LEVEL_INFO, msg, True)
+            contents = self.getLineContentsAtOffset(obj, offset, layoutMode, useCache)
+
         if not contents:
             msg = "WEB: Could not get line contents for %s, %i" % (obj, offset)
             debug.println(debug.LEVEL_INFO, msg, True)


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