[orca] Revert "Fix backspacing text"
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Revert "Fix backspacing text"
- Date: Wed, 27 Jun 2018 18:49:04 +0000 (UTC)
commit 475481b955143835c4dcadb92f442fcdc83e8d2e
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Jun 27 14:47:54 2018 -0400
Revert "Fix backspacing text"
This reverts commit 93dae3f2c50cebb294af1b424d1adb49bd6acae6.
It introduces regressions in braille updating in Firefox.
src/orca/braille.py | 15 ++++-----------
src/orca/scripts/default.py | 26 ++++++++++++--------------
src/orca/scripts/web/script_utilities.py | 16 ++++++----------
3 files changed, 22 insertions(+), 35 deletions(-)
---
diff --git a/src/orca/braille.py b/src/orca/braille.py
index c4aa0a900..88a6cf6c3 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -530,7 +530,7 @@ class Text(Region):
if orca_state.activeScript and self.accessible:
[string, self.caretOffset, self.lineOffset] = \
orca_state.activeScript.getTextLineAtCaret(
- self.accessible, offset=startOffset, startOffset=startOffset, endOffset=endOffset)
+ self.accessible, startOffset=startOffset, endOffset=endOffset)
else:
string = ""
self.caretOffset = 0
@@ -585,11 +585,9 @@ class Text(Region):
True. Otherwise, return False.
"""
- if not _regionWithFocus:
- return False
-
[string, caretOffset, lineOffset] = \
- orca_state.activeScript.getTextLineAtCaret(self.accessible)
+ orca_state.activeScript.getTextLineAtCaret(self.accessible,
+ self.startOffset)
cursorOffset = min(caretOffset - lineOffset, len(string))
@@ -1177,7 +1175,7 @@ def refresh(panToCursor=True,
# right of the display if we need to pan right.
#
if panToCursor and (cursorOffset >= 0):
- if cursorOffset < _displaySize[0]:
+ if len(string) <= _displaySize[0]:
viewport[0] = 0
elif targetCursorCell:
viewport[0] = max(0, cursorOffset - targetCursorCell + 1)
@@ -1188,8 +1186,6 @@ def refresh(panToCursor=True,
else:
rangeForOffset = _getRangeForOffset(cursorOffset)
viewport[0] = max(0, rangeForOffset[0])
- if cursorOffset >= (viewport[0] + _displaySize[0]):
- viewport[0] = max(0, cursorOffset - _displaySize[0] + 1)
startPos, endPos = _adjustForWordWrap()
viewport[0] = startPos
@@ -1438,9 +1434,6 @@ def _getRangeForOffset(offset):
for r in ranges:
if r[0] <= offset < r[1]:
return r
- for r in ranges:
- if offset == r[1]:
- return r
return [0, 0]
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index eb1b14d95..6b025ccd2 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3591,10 +3591,7 @@ class Script(script.Script):
except NotImplementedError:
return ["", 0, 0]
- if offset is None:
- offset = max(0, text.caretOffset)
-
- # The offset might be positioned at the very end of the text area.
+ # The caret might be positioned at the very end of the text area.
# In these cases, calling text.getTextAtOffset on an offset that's
# not positioned to a character can yield unexpected results. In
# particular, we'll see the Gecko toolkit return a start and end
@@ -3608,16 +3605,17 @@ class Script(script.Script):
# to see if that character is a newline - if it is, we'll treat it
# as the line.
#
- if offset == text.characterCount:
- offset = max(0, offset - 1)
- character = text.getText(offset, offset + 1)
+ if text.caretOffset == text.characterCount:
+ caretOffset = max(0, text.caretOffset - 1)
+ character = text.getText(caretOffset, caretOffset + 1)
else:
+ caretOffset = text.caretOffset
character = None
- if (offset == text.characterCount) \
+ if (text.caretOffset == text.characterCount) \
and (character == "\n"):
lineString = ""
- startOffset = offset
+ startOffset = caretOffset
else:
# Get the line containing the caret. [[[TODO: HACK WDW - If
# there's only 1 character in the string, well, we get it. We
@@ -3625,14 +3623,14 @@ class Script(script.Script):
# is broken if there is just one character in the string.]]]
#
if (text.characterCount == 1):
- lineString = text.getText(offset, offset + 1)
- startOffset = offset
+ lineString = text.getText(caretOffset, caretOffset + 1)
+ startOffset = caretOffset
else:
- if offset == -1:
- offset = text.characterCount
+ if caretOffset == -1:
+ caretOffset = text.characterCount
try:
[lineString, startOffset, endOffset] = text.getTextAtOffset(
- offset, pyatspi.TEXT_BOUNDARY_LINE_START)
+ caretOffset, pyatspi.TEXT_BOUNDARY_LINE_START)
except:
return ["", 0, 0]
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index c982e4a4f..a9ec6eeff 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -792,7 +792,7 @@ class Utilities(script_utilities.Utilities):
return attrs
- def findObjectInContents(self, obj, offset, contents, usingCache=False):
+ def findObjectInContents(self, obj, offset, contents):
if not obj or not contents:
return -1
@@ -801,10 +801,6 @@ class Utilities(script_utilities.Utilities):
match = [x for x in matches if x[1] <= offset < x[2]]
if match and match[0] and match[0] in contents:
return contents.index(match[0])
- if not usingCache:
- match = [x for x in matches if offset == x[2]]
- if match and match[0] and match[0] in contents:
- return contents.index(match[0])
if not self.isTextBlockElement(obj):
return -1
@@ -1117,7 +1113,7 @@ class Utilities(script_utilities.Utilities):
offset = max(0, offset)
if useCache:
- if self.findObjectInContents(obj, offset, self._currentSentenceContents, usingCache=True) != -1:
+ if self.findObjectInContents(obj, offset, self._currentSentenceContents) != -1:
return self._currentSentenceContents
boundary = pyatspi.TEXT_BOUNDARY_SENTENCE_START
@@ -1185,7 +1181,7 @@ class Utilities(script_utilities.Utilities):
offset = max(0, offset)
if useCache:
- if self.findObjectInContents(obj, offset, self._currentCharacterContents, usingCache=True) != -1:
+ if self.findObjectInContents(obj, offset, self._currentCharacterContents) != -1:
return self._currentCharacterContents
boundary = pyatspi.TEXT_BOUNDARY_CHAR
@@ -1202,7 +1198,7 @@ class Utilities(script_utilities.Utilities):
offset = max(0, offset)
if useCache:
- if self.findObjectInContents(obj, offset, self._currentWordContents, usingCache=True) != -1:
+ if self.findObjectInContents(obj, offset, self._currentWordContents) != -1:
return self._currentWordContents
boundary = pyatspi.TEXT_BOUNDARY_WORD_START
@@ -1272,7 +1268,7 @@ class Utilities(script_utilities.Utilities):
offset = max(0, offset)
if useCache:
- if self.findObjectInContents(obj, offset, self._currentObjectContents, usingCache=True) != -1:
+ if self.findObjectInContents(obj, offset, self._currentObjectContents) != -1:
return self._currentObjectContents
objIsLandmark = self.isLandmark(obj)
@@ -1333,7 +1329,7 @@ class Utilities(script_utilities.Utilities):
offset = max(0, offset)
if useCache:
- if self.findObjectInContents(obj, offset, self._currentLineContents, usingCache=True) != -1:
+ if self.findObjectInContents(obj, offset, self._currentLineContents) != -1:
return self._currentLineContents
if layoutMode is None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]