[orca] Add utility methods to get next and previous lines in web content
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Add utility methods to get next and previous lines in web content
- Date: Wed, 24 Jun 2015 14:16:49 +0000 (UTC)
commit 23ca7959072533ca9b19dfe5bde3787f62743f47
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Jun 24 10:16:25 2015 -0400
Add utility methods to get next and previous lines in web content
src/orca/caret_navigation.py | 59 +-------------------------
src/orca/scripts/web/script.py | 1 +
src/orca/scripts/web/script_utilities.py | 68 ++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 57 deletions(-)
---
diff --git a/src/orca/caret_navigation.py b/src/orca/caret_navigation.py
index 7e06e47..ebd17f0 100644
--- a/src/orca/caret_navigation.py
+++ b/src/orca/caret_navigation.py
@@ -322,35 +322,7 @@ class CaretNavigation:
debug.println(debug.LEVEL_INFO, msg)
return True
- obj, offset = script.utilities.getCaretContext()
- msg = "INFO: Current context is: %s, %i" % (obj, offset)
- debug.println(debug.LEVEL_INFO, msg)
-
- if obj and script.utilities.isZombie(obj):
- msg = "INFO: Current context obj %s is zombie" % obj
- debug.println(debug.LEVEL_INFO, msg)
-
- line = script.utilities.getLineContentsAtOffset(obj, offset)
- msg = "INFO: Line contents for %s, %i: %s" % (obj, offset, line)
- debug.println(debug.LEVEL_INFO, msg)
-
- if not (line and line[0]):
- return False
-
- 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)
-
- obj, offset = script.utilities.nextContext(lastObj, lastOffset, True)
- msg = "INFO: Next context is: %s, %i" % (obj, offset)
- debug.println(debug.LEVEL_INFO, msg)
-
- contents = script.utilities.getLineContentsAtOffset(obj, offset)
- if not contents:
- msg = "INFO: Could not get line contents for %s, %i" % (obj, offset)
- debug.println(debug.LEVEL_INFO, msg)
- return False
-
+ contents = script.utilities.getNextLineContents()
obj, start = contents[0][0], contents[0][1]
script.utilities.setCaretPosition(obj, start)
script.speakContents(contents)
@@ -371,35 +343,8 @@ class CaretNavigation:
debug.println(debug.LEVEL_INFO, msg)
return True
- obj, offset = script.utilities.getCaretContext()
- msg = "INFO: Current context is: %s, %i" % (obj, offset)
- debug.println(debug.LEVEL_INFO, msg)
-
- if obj and script.utilities.isZombie(obj):
- msg = "INFO: Current context obj %s is zombie" % obj
- debug.println(debug.LEVEL_INFO, msg)
-
- line = script.utilities.getLineContentsAtOffset(obj, offset)
- msg = "INFO: Line contents for %s, %i: %s" % (obj, offset, line)
- debug.println(debug.LEVEL_INFO, msg)
-
- if not (line and line[0]):
- return False
-
- firstObj, firstOffset = line[0][0], line[0][1]
- msg = "INFO: First context on line is: %s, %i" % (firstObj, firstOffset)
- debug.println(debug.LEVEL_INFO, msg)
-
- obj, offset = script.utilities.previousContext(firstObj, firstOffset, True)
- msg = "INFO: Previous context is: %s, %i" % (obj, offset)
- debug.println(debug.LEVEL_INFO, msg)
-
- contents = script.utilities.getLineContentsAtOffset(obj, offset)
- if not contents:
- msg = "INFO: Could not get line contents for %s, %i" % (obj, offset)
- debug.println(debug.LEVEL_INFO, msg)
- return False
+ contents = script.utilities.getPreviousLineContents()
obj, start = contents[0][0], contents[0][1]
script.utilities.setCaretPosition(obj, start)
script.speakContents(contents)
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 976ef4c..296a127 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -791,6 +791,7 @@ class Script(default.Script):
obj, start, end, string = contents[0]
self.utilities.setCaretPosition(obj, start)
+ self.updateBraille(obj)
# Hack: When panning to the left in a document, we want to start at
# the right/bottom of each new object. For now, we'll pan there.
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 1f390ac..69eb516 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -1055,6 +1055,74 @@ class Utilities(script_utilities.Utilities):
return objects
+ def getPreviousLineContents(self, obj=None, offset=-1, layoutMode=None, useCache=True):
+ if obj is None:
+ obj, offset = self.getCaretContext()
+
+ msg = "INFO: Current context is: %s, %i" % (obj, offset)
+ debug.println(debug.LEVEL_INFO, msg)
+
+ if obj and self.isZombie(obj):
+ msg = "INFO: Current context obj %s is zombie" % obj
+ debug.println(debug.LEVEL_INFO, msg)
+
+ line = self.getLineContentsAtOffset(obj, offset, layoutMode, useCache)
+ msg = "INFO: Line contents for %s, %i: %s" % (obj, offset, line)
+ debug.println(debug.LEVEL_INFO, msg)
+
+ if not (line and line[0]):
+ return []
+
+ firstObj, firstOffset = line[0][0], line[0][1]
+ msg = "INFO: First context on line is: %s, %i" % (firstObj, firstOffset)
+ debug.println(debug.LEVEL_INFO, msg)
+
+ obj, offset = self.previousContext(firstObj, firstOffset, True)
+ msg = "INFO: Previous context is: %s, %i" % (obj, offset)
+ debug.println(debug.LEVEL_INFO, msg)
+
+ contents = self.getLineContentsAtOffset(obj, offset, layoutMode, useCache)
+ if not contents:
+ msg = "INFO: Could not get line contents for %s, %i" % (obj, offset)
+ debug.println(debug.LEVEL_INFO, msg)
+ return []
+
+ return contents
+
+ def getNextLineContents(self, obj=None, offset=-1, layoutMode=None, useCache=True):
+ if obj is None:
+ obj, offset = self.getCaretContext()
+
+ msg = "INFO: Current context is: %s, %i" % (obj, offset)
+ debug.println(debug.LEVEL_INFO, msg)
+
+ if obj and self.isZombie(obj):
+ msg = "INFO: Current context obj %s is zombie" % obj
+ debug.println(debug.LEVEL_INFO, msg)
+
+ line = self.getLineContentsAtOffset(obj, offset, layoutMode, useCache)
+ msg = "INFO: Line contents for %s, %i: %s" % (obj, offset, line)
+ debug.println(debug.LEVEL_INFO, msg)
+
+ if not (line and line[0]):
+ return []
+
+ 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)
+
+ obj, offset = self.nextContext(lastObj, lastOffset, True)
+ msg = "INFO: Next context is: %s, %i" % (obj, offset)
+ debug.println(debug.LEVEL_INFO, msg)
+
+ contents = self.getLineContentsAtOffset(obj, offset, layoutMode, useCache)
+ if not contents:
+ msg = "INFO: Could not get line contents for %s, %i" % (obj, offset)
+ debug.println(debug.LEVEL_INFO, msg)
+ return []
+
+ return contents
+
def isFocusModeWidget(self, obj):
try:
role = obj.getRole()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]