[orca] Fix some minor issues in the web script
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix some minor issues in the web script
- Date: Sat, 13 Jun 2015 05:02:41 +0000 (UTC)
commit 8981b8869fcdbed4eb156c7d27cd6d0ea0a10e88
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Jun 13 01:01:20 2015 -0400
Fix some minor issues in the web script
src/orca/generator.py | 9 +++-
.../scripts/apps/evolution/script_utilities.py | 2 +-
src/orca/scripts/default.py | 3 +-
.../scripts/toolkits/Gecko/script_utilities.py | 3 +
src/orca/scripts/web/script.py | 6 +++
src/orca/scripts/web/script_utilities.py | 47 +++++++++-----------
src/orca/scripts/web/speech_generator.py | 4 ++
test/keystrokes/firefox/line_nav_bug_592383.py | 2 +-
test/keystrokes/firefox/line_nav_descriptions.py | 2 +-
test/keystrokes/firefox/line_nav_enter_bug.py | 4 +-
test/keystrokes/firefox/line_nav_sun_java.py | 2 +-
test/keystrokes/firefox/line_nav_wiki_up.py | 2 +-
.../firefox/object_nav_descriptions_down.py | 6 +-
.../firefox/object_nav_descriptions_up.py | 6 +-
.../keystrokes/firefox/object_nav_links_in_text.py | 2 +-
.../keystrokes/firefox/object_nav_links_on_line.py | 4 +-
.../firefox/object_nav_simple_form_up.py | 2 +-
17 files changed, 59 insertions(+), 47 deletions(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 4fa154c..c7ba7cb 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -389,9 +389,12 @@ class Generator:
is different from that of the name and label.
"""
result = []
- label = self._script.utilities.displayedLabel(obj)
- if obj.description and not obj.description in [obj.name, label]:
- result.append(obj.description)
+ if obj.description:
+ label = self._script.utilities.displayedLabel(obj) or ""
+ name = obj.name or ""
+ desc = obj.description.lower()
+ if not (desc in name.lower() or desc in label.lower()):
+ result.append(obj.description)
return result
def _generateLabel(self, obj, **args):
diff --git a/src/orca/scripts/apps/evolution/script_utilities.py
b/src/orca/scripts/apps/evolution/script_utilities.py
index 184f451..fe9c8c4 100644
--- a/src/orca/scripts/apps/evolution/script_utilities.py
+++ b/src/orca/scripts/apps/evolution/script_utilities.py
@@ -101,7 +101,7 @@ class Utilities(WebKitGtk.Utilities):
def setCaretAtStart(self, obj):
if self.isReceivedMessageContent(obj):
- obj = self.utilities.findMessageBodyChild(obj) or obj
+ obj = self.findMessageBodyChild(obj) or obj
child, index = super().setCaretAtStart(obj)
if child and index == -1:
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 42578db..bc56ac2 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -742,6 +742,7 @@ class Script(script.Script):
try:
role = obj.getRole()
state = obj.getState()
+ name = obj.name
except:
return
@@ -749,7 +750,7 @@ class Script(script.Script):
# changes after the focus or selection has changed, even though the
# name has not.
names = self.pointOfReference.get('names', {})
- names[hash(obj)] = obj.name
+ names[hash(obj)] = name
self.pointOfReference['names'] = names
# We want to save the offset for text objects because some apps and
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index c5d5d8f..4355039 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -42,6 +42,9 @@ class Utilities(web.Utilities):
def __init__(self, script):
super().__init__(script)
+ def _attemptBrokenTextRecovery(self):
+ return True
+
def inFindToolbar(self, obj=None):
if not obj:
obj = orca_state.locusOfFocus
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index dcba33b..976ef4c 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1205,6 +1205,12 @@ class Script(default.Script):
def onChildrenChanged(self, event):
"""Callback for object:children-changed accessibility events."""
+ document = self.utilities.getDocumentForObject(event.source)
+ if document:
+ msg = "WEB: Clearing structural navigation cache for %s" % document
+ debug.println(debug.LEVEL_INFO, msg)
+ self.structuralNavigation.clearCache(document)
+
if self.utilities.handleAsLiveRegion(event):
msg = "WEB: Event to be handled as live region"
debug.println(debug.LEVEL_INFO, msg)
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 2d88c95..1f390ac 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -604,6 +604,9 @@ class Utilities(script_utilities.Utilities):
return string, rangeStart, rangeEnd
+ def _attemptBrokenTextRecovery(self):
+ return False
+
def _getTextAtOffset(self, obj, offset, boundary):
if not obj:
msg = "WEB: Results for text at offset %i for %s using %s:\n" \
@@ -651,6 +654,13 @@ class Utilities(script_utilities.Utilities):
string, start, end = text.getTextAtOffset(offset, boundary)
# The above should be all that we need to do, but....
+ if not self._attemptBrokenTextRecovery():
+ s = string.replace(self.EMBEDDED_OBJECT_CHARACTER, "[OBJ]").replace("\n", "\\n")
+ msg = "WEB: Results for text at offset %i for %s using %s:\n" \
+ " String: '%s', Start: %i, End: %i.\n" \
+ " Not checking for broken text." % (offset, obj, boundary, s, start, end)
+ debug.println(debug.LEVEL_INFO, msg)
+ return string, start, end
needSadHack = False
testString, testStart, testEnd = text.getTextAtOffset(start, boundary)
@@ -1045,19 +1055,6 @@ class Utilities(script_utilities.Utilities):
return objects
- def justEnteredObject(self, obj, startOffset, endOffset):
- lastKey, mods = self.lastKeyAndModifiers()
- if (lastKey == "Down" and not mods) or self._script.inSayAll():
- return startOffset == 0
-
- if lastKey == "Up" and not mods:
- text = self.queryNonEmptyText(obj)
- if not text:
- return True
- return endOffset == text.characterCount
-
- return True
-
def isFocusModeWidget(self, obj):
try:
role = obj.getRole()
@@ -1099,7 +1096,7 @@ class Utilities(script_utilities.Utilities):
return False
def isTextBlockElement(self, obj):
- if not obj:
+ if not (obj and self.inDocumentContent(obj)):
return False
rv = self._isTextBlockElement.get(hash(obj))
@@ -1108,10 +1105,6 @@ class Utilities(script_utilities.Utilities):
role = obj.getRole()
state = obj.getState()
-
- if not (obj and self.inDocumentContent(obj)):
- return False
-
textBlockElements = [pyatspi.ROLE_CAPTION,
pyatspi.ROLE_COLUMN_HEADER,
pyatspi.ROLE_DOCUMENT_FRAME,
@@ -1128,9 +1121,7 @@ class Utilities(script_utilities.Utilities):
pyatspi.ROLE_TEXT,
pyatspi.ROLE_TABLE_CELL]
- if not self.inDocumentContent(obj):
- rv = False
- elif not role in textBlockElements:
+ if not role in textBlockElements:
rv = False
elif state.contains(pyatspi.STATE_EDITABLE):
rv = False
@@ -1597,21 +1588,24 @@ class Utilities(script_utilities.Utilities):
return obj.getRole() in doNotDescend
def _searchForCaretContext(self, obj):
- context = [None, -1]
+ contextObj, contextOffset = None, -1
while obj:
try:
offset = obj.queryText().caretOffset
except:
obj = None
else:
- context = [obj, offset]
+ contextObj, contextOffset = obj, offset
childIndex = self.getChildIndex(obj, offset)
if childIndex >= 0 and obj.childCount:
obj = obj[childIndex]
else:
break
- return context
+ if contextObj:
+ return self.findNextCaretInOrder(contextObj, max(-1, contextOffset - 1))
+
+ return None, -1
def _getCaretContextViaLocusOfFocus(self):
obj = orca_state.locusOfFocus
@@ -1625,7 +1619,9 @@ class Utilities(script_utilities.Utilities):
return obj, offset
def getCaretContext(self, documentFrame=None):
- documentFrame = documentFrame or self.documentFrame()
+ if not documentFrame or self.isZombie(documentFrame):
+ documentFrame = self.documentFrame()
+
if not documentFrame:
return self._getCaretContextViaLocusOfFocus()
@@ -1634,7 +1630,6 @@ class Utilities(script_utilities.Utilities):
return context
obj, offset = self._searchForCaretContext(documentFrame)
- obj, offset = self.findNextCaretInOrder(obj, max(-1, offset - 1))
self.setCaretContext(obj, offset, documentFrame)
return obj, offset
diff --git a/src/orca/scripts/web/speech_generator.py b/src/orca/scripts/web/speech_generator.py
index d2e232d..3ab6360 100644
--- a/src/orca/scripts/web/speech_generator.py
+++ b/src/orca/scripts/web/speech_generator.py
@@ -113,6 +113,10 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
if role == pyatspi.ROLE_TEXT and formatType != 'basicWhereAmI':
return []
+ # TODO - JD: This is private.
+ if role == pyatspi.ROLE_LINK and self._script._lastCommandWasCaretNav:
+ return []
+
return super()._generateDescription(obj, **args)
def _generateHasLongDesc(self, obj, **args):
diff --git a/test/keystrokes/firefox/line_nav_bug_592383.py b/test/keystrokes/firefox/line_nav_bug_592383.py
index ca4327e..2524447 100644
--- a/test/keystrokes/firefox/line_nav_bug_592383.py
+++ b/test/keystrokes/firefox/line_nav_bug_592383.py
@@ -60,7 +60,7 @@ sequence.append(KeyComboAction("<Control>End"))
sequence.append(utils.AssertPresentationAction(
"7. End of file",
["BRAILLE LINE: 'Here's another normal paragraph.'",
- " VISIBLE: 'Here's another normal paragraph.', cursor=32",
+ " VISIBLE: 'Here's another normal paragraph.', cursor=0",
"SPEECH OUTPUT: 'Here's another normal paragraph.'"]))
sequence.append(utils.StartRecordingAction())
diff --git a/test/keystrokes/firefox/line_nav_descriptions.py
b/test/keystrokes/firefox/line_nav_descriptions.py
index d7e2f59..e2b4c14 100644
--- a/test/keystrokes/firefox/line_nav_descriptions.py
+++ b/test/keystrokes/firefox/line_nav_descriptions.py
@@ -18,7 +18,7 @@ sequence.append(utils.AssertPresentationAction(
"1. Line Down",
["BRAILLE LINE: 'Foo, Bar, and Baz.'",
" VISIBLE: 'Foo, Bar, and Baz.', cursor=1",
- "SPEECH OUTPUT: 'Foo link Title of the Foo link.'",
+ "SPEECH OUTPUT: 'Foo link'",
"SPEECH OUTPUT: ','",
"SPEECH OUTPUT: 'Bar link'",
"SPEECH OUTPUT: ', and'",
diff --git a/test/keystrokes/firefox/line_nav_enter_bug.py b/test/keystrokes/firefox/line_nav_enter_bug.py
index 56a9c21..0a89b7b 100644
--- a/test/keystrokes/firefox/line_nav_enter_bug.py
+++ b/test/keystrokes/firefox/line_nav_enter_bug.py
@@ -15,7 +15,7 @@ sequence.append(utils.AssertPresentationAction(
"1. Top of file",
["BRAILLE LINE: 'Home Bugzilla'",
" VISIBLE: 'Home Bugzilla', cursor=1",
- "SPEECH OUTPUT: 'Home link Back to the Gnome Bugzilla home page'",
+ "SPEECH OUTPUT: 'Home link'",
"SPEECH OUTPUT: 'Bugzilla'"]))
sequence.append(utils.StartRecordingAction())
@@ -456,7 +456,7 @@ sequence.append(utils.AssertPresentationAction(
"47. Line Up",
["BRAILLE LINE: 'Home Bugzilla'",
" VISIBLE: 'Home Bugzilla', cursor=1",
- "SPEECH OUTPUT: 'Home link Back to the Gnome Bugzilla home page'",
+ "SPEECH OUTPUT: 'Home link'",
"SPEECH OUTPUT: 'Bugzilla'"]))
sequence.append(utils.AssertionSummaryAction())
diff --git a/test/keystrokes/firefox/line_nav_sun_java.py b/test/keystrokes/firefox/line_nav_sun_java.py
index 0c994b0..af67eac 100644
--- a/test/keystrokes/firefox/line_nav_sun_java.py
+++ b/test/keystrokes/firefox/line_nav_sun_java.py
@@ -38,7 +38,7 @@ sequence.append(utils.AssertPresentationAction(
"3. Line Down",
["BRAILLE LINE: 'APIs Downloads Products Support Training Participate'",
" VISIBLE: 'APIs Downloads Products Support ', cursor=1",
- "SPEECH OUTPUT: 'APIs link See All APIs'",
+ "SPEECH OUTPUT: 'APIs link'",
"SPEECH OUTPUT: 'Downloads link'",
"SPEECH OUTPUT: 'Products link'",
"SPEECH OUTPUT: 'Support link'",
diff --git a/test/keystrokes/firefox/line_nav_wiki_up.py b/test/keystrokes/firefox/line_nav_wiki_up.py
index 11b814c..88d5f0c 100644
--- a/test/keystrokes/firefox/line_nav_wiki_up.py
+++ b/test/keystrokes/firefox/line_nav_wiki_up.py
@@ -19,7 +19,7 @@ sequence.append(KeyComboAction("<Control>End"))
sequence.append(utils.AssertPresentationAction(
"1. Bottom of file",
["BRAILLE LINE: 'Hosted by Red Hat.'",
- " VISIBLE: 'Hosted by Red Hat.', cursor=19",
+ " VISIBLE: 'Hosted by Red Hat.', cursor=0",
"SPEECH OUTPUT: 'Hosted by'",
"SPEECH OUTPUT: 'Red Hat link'",
"SPEECH OUTPUT: '.'"]))
diff --git a/test/keystrokes/firefox/object_nav_descriptions_down.py
b/test/keystrokes/firefox/object_nav_descriptions_down.py
index ba059c5..37b17bf 100644
--- a/test/keystrokes/firefox/object_nav_descriptions_down.py
+++ b/test/keystrokes/firefox/object_nav_descriptions_down.py
@@ -19,7 +19,7 @@ sequence.append(utils.AssertPresentationAction(
"1. Line Down",
["BRAILLE LINE: 'Foo,'",
" VISIBLE: 'Foo,', cursor=1",
- "SPEECH OUTPUT: 'Foo link Title of the Foo link.'",
+ "SPEECH OUTPUT: 'Foo link'",
"SPEECH OUTPUT: ','"]))
sequence.append(utils.StartRecordingAction())
@@ -28,7 +28,7 @@ sequence.append(utils.AssertPresentationAction(
"2. Line Down",
["BRAILLE LINE: 'Bar,'",
" VISIBLE: 'Bar,', cursor=1",
- "SPEECH OUTPUT: 'Bar link ARIA description text.'",
+ "SPEECH OUTPUT: 'Bar link'",
"SPEECH OUTPUT: ','"]))
sequence.append(utils.StartRecordingAction())
@@ -45,7 +45,7 @@ sequence.append(utils.AssertPresentationAction(
"4. Line Down",
["BRAILLE LINE: 'Baz.'",
" VISIBLE: 'Baz.', cursor=1",
- "SPEECH OUTPUT: 'Baz link Title of the Baz link.'",
+ "SPEECH OUTPUT: 'Baz link'",
"SPEECH OUTPUT: '.'"]))
sequence.append(utils.StartRecordingAction())
diff --git a/test/keystrokes/firefox/object_nav_descriptions_up.py
b/test/keystrokes/firefox/object_nav_descriptions_up.py
index e287b06..8a653a2 100644
--- a/test/keystrokes/firefox/object_nav_descriptions_up.py
+++ b/test/keystrokes/firefox/object_nav_descriptions_up.py
@@ -131,7 +131,7 @@ sequence.append(utils.AssertPresentationAction(
"15. Line Up",
["BRAILLE LINE: 'Baz.'",
" VISIBLE: 'Baz.', cursor=1",
- "SPEECH OUTPUT: 'Baz link Title of the Baz link.'",
+ "SPEECH OUTPUT: 'Baz link'",
"SPEECH OUTPUT: '.'"]))
sequence.append(utils.StartRecordingAction())
@@ -148,7 +148,7 @@ sequence.append(utils.AssertPresentationAction(
"17. Line Up",
["BRAILLE LINE: 'Bar,'",
" VISIBLE: 'Bar,', cursor=1",
- "SPEECH OUTPUT: 'Bar link ARIA description text.'",
+ "SPEECH OUTPUT: 'Bar link'",
"SPEECH OUTPUT: ','"]))
sequence.append(utils.StartRecordingAction())
@@ -157,7 +157,7 @@ sequence.append(utils.AssertPresentationAction(
"18. Line Up",
["BRAILLE LINE: 'Foo,'",
" VISIBLE: 'Foo,', cursor=1",
- "SPEECH OUTPUT: 'Foo link Title of the Foo link.'",
+ "SPEECH OUTPUT: 'Foo link'",
"SPEECH OUTPUT: ','"]))
sequence.append(utils.AssertionSummaryAction())
diff --git a/test/keystrokes/firefox/object_nav_links_in_text.py
b/test/keystrokes/firefox/object_nav_links_in_text.py
index ba2a3fe..24c51d2 100644
--- a/test/keystrokes/firefox/object_nav_links_in_text.py
+++ b/test/keystrokes/firefox/object_nav_links_in_text.py
@@ -13,7 +13,7 @@ sequence.append(utils.AssertPresentationAction(
"1. Top of file",
["BRAILLE LINE: 'Home'",
" VISIBLE: 'Home', cursor=1",
- "SPEECH OUTPUT: 'Home link Back to the Gnome Bugzilla home page'"]))
+ "SPEECH OUTPUT: 'Home link'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("H"))
diff --git a/test/keystrokes/firefox/object_nav_links_on_line.py
b/test/keystrokes/firefox/object_nav_links_on_line.py
index ae349bf..b06bdd6 100644
--- a/test/keystrokes/firefox/object_nav_links_on_line.py
+++ b/test/keystrokes/firefox/object_nav_links_on_line.py
@@ -17,7 +17,7 @@ sequence.append(utils.AssertPresentationAction(
"1. Top of file",
["BRAILLE LINE: 'Home'",
" VISIBLE: 'Home', cursor=1",
- "SPEECH OUTPUT: 'Home link Back to the Gnome Bugzilla home page'"]))
+ "SPEECH OUTPUT: 'Home link'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
@@ -241,7 +241,7 @@ sequence.append(utils.AssertPresentationAction(
"29. line Up",
["BRAILLE LINE: 'Home'",
" VISIBLE: 'Home', cursor=1",
- "SPEECH OUTPUT: 'Home link Back to the Gnome Bugzilla home page'"]))
+ "SPEECH OUTPUT: 'Home link'"]))
sequence.append(utils.AssertionSummaryAction())
sequence.start()
diff --git a/test/keystrokes/firefox/object_nav_simple_form_up.py
b/test/keystrokes/firefox/object_nav_simple_form_up.py
index d1e2444..a597701 100644
--- a/test/keystrokes/firefox/object_nav_simple_form_up.py
+++ b/test/keystrokes/firefox/object_nav_simple_form_up.py
@@ -16,7 +16,7 @@ sequence.append(KeyComboAction("<Control>End"))
sequence.append(utils.AssertPresentationAction(
"1. End of file",
["BRAILLE LINE: 'No'",
- " VISIBLE: 'No', cursor=3",
+ " VISIBLE: 'No', cursor=0",
"SPEECH OUTPUT: 'No'"]))
sequence.append(utils.StartRecordingAction())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]