[orca] Fix issues related to Gecko using ROLE_TEXT for static text elements.
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix issues related to Gecko using ROLE_TEXT for static text elements.
- Date: Sat, 30 May 2015 03:57:34 +0000 (UTC)
commit 1315c7adb618a7c41dddf065d36ee1db904a93b6
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Fri May 29 20:03:45 2015 -0400
Fix issues related to Gecko using ROLE_TEXT for static text elements.
ROLE_TEXT is for textview-like widgets. Not spans with onClick handlers
or the time element or...
src/orca/formatting.py | 6 ++++++
src/orca/script_utilities.py | 11 +++++++++++
.../scripts/toolkits/Gecko/braille_generator.py | 3 +++
.../scripts/toolkits/Gecko/speech_generator.py | 3 +++
.../toolkits/Gecko/structural_navigation.py | 2 +-
test/html/heading-with-child-text.html | 2 +-
.../html_struct_nav_heading_with_child_text.py | 7 +++----
.../html_struct_nav_link_with_child_text.py | 7 ++++---
8 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 57179b7..a8c8c9b 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -314,6 +314,12 @@ formatting = {
'unfocused': 'labelAndName + roleName + value + availability + ' + MNEMONIC,
'basicWhereAmI' : 'labelAndName + roleName + value'
},
+ # TODO - JD: There is now an actual ROLE_STATIC in ATK and AT-SPI2. Next
+ # time we need to bump dependencies for more significant things, we need
+ # to remove this fake role and use it instead.
+ 'ROLE_STATIC': {
+ 'unfocused': '(displayedText or name) + roleName',
+ },
pyatspi.ROLE_TABLE: {
'focused': 'labelAndName + table',
'unfocused': 'labelAndName + table',
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 4e054a8..ec15ea5 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -591,6 +591,17 @@ class Utilities:
def isHidden(self, obj):
return False
+ def isStatic(self, obj):
+ role = obj.getRole()
+ try:
+ isStatic = role == pyatspi.ROLE_STATIC
+ except:
+ isStatic = False
+
+ if not isStatic and role == pyatspi.ROLE_TEXT:
+ isStatic = not obj.getState().contains(pyatspi.STATE_FOCUSABLE)
+ return isStatic
+
def isLayoutOnly(self, obj):
"""Returns True if the given object is a container which has
no presentable information (label, name, displayed text, etc.)."""
diff --git a/src/orca/scripts/toolkits/Gecko/braille_generator.py
b/src/orca/scripts/toolkits/Gecko/braille_generator.py
index f69793f..9d3ab63 100644
--- a/src/orca/scripts/toolkits/Gecko/braille_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/braille_generator.py
@@ -46,6 +46,7 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
doNotDisplay = [pyatspi.ROLE_FORM,
pyatspi.ROLE_SECTION,
pyatspi.ROLE_PARAGRAPH,
+ 'ROLE_STATIC',
pyatspi.ROLE_UNKNOWN]
state = obj.getState()
@@ -117,6 +118,8 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
if self._script.utilities.isClickableElement(obj) \
or self._script.utilities.isLink(obj):
oldRole = self._overrideRole(pyatspi.ROLE_LINK, args)
+ elif self._script.utilities.isStatic(obj):
+ oldRole = self._overrideRole('ROLE_STATIC', args)
# Treat menu items in collapsed combo boxes as if the combo box
# had focus. This will make things more consistent with how we
diff --git a/src/orca/scripts/toolkits/Gecko/speech_generator.py
b/src/orca/scripts/toolkits/Gecko/speech_generator.py
index 8366e9f..c72ecc6 100644
--- a/src/orca/scripts/toolkits/Gecko/speech_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/speech_generator.py
@@ -203,6 +203,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
if not force:
doNotSpeak.append(pyatspi.ROLE_TABLE_CELL)
doNotSpeak.append(pyatspi.ROLE_TEXT)
+ doNotSpeak.append('ROLE_STATIC')
if args.get('formatType', 'unfocused') != 'basicWhereAmI':
doNotSpeak.append(pyatspi.ROLE_LIST_ITEM)
doNotSpeak.append(pyatspi.ROLE_LIST)
@@ -387,6 +388,8 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
oldRole = self._overrideRole('default', args)
elif self._script.utilities.isLink(obj):
oldRole = self._overrideRole(pyatspi.ROLE_LINK, args)
+ elif self._script.utilities.isStatic(obj):
+ oldRole = self._overrideRole('ROLE_STATIC', args)
else:
oldRole = self._overrideRole(obj.getRole(), args)
diff --git a/src/orca/scripts/toolkits/Gecko/structural_navigation.py
b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
index fa5620c..a438065 100644
--- a/src/orca/scripts/toolkits/Gecko/structural_navigation.py
+++ b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
@@ -115,7 +115,7 @@ class GeckoStructuralNavigation(structural_navigation.StructuralNavigation):
if not obj:
return obj, offset
- if obj.getRole() == pyatspi.ROLE_SECTION \
+ if self._script.utilities.isTextBlockElement(obj) \
and not self._script.utilities.queryNonEmptyText(obj):
obj, offset = self._script.utilities.findNextCaretInOrder(obj, offset)
diff --git a/test/html/heading-with-child-text.html b/test/html/heading-with-child-text.html
index 6903abe..a81201e 100644
--- a/test/html/heading-with-child-text.html
+++ b/test/html/heading-with-child-text.html
@@ -3,7 +3,7 @@
</head>
<body>
<h1>line 1</h1>
-<h1><time datetime="2015-05-29">line 2</time></h2>
+<h1><time datetime="2015-05-29">line 2</time></h1>
<h1>line 3</h1>
</body>
</html>
diff --git a/test/keystrokes/firefox/html_struct_nav_heading_with_child_text.py
b/test/keystrokes/firefox/html_struct_nav_heading_with_child_text.py
index 6b927b2..69fa3b9 100644
--- a/test/keystrokes/firefox/html_struct_nav_heading_with_child_text.py
+++ b/test/keystrokes/firefox/html_struct_nav_heading_with_child_text.py
@@ -13,10 +13,9 @@ sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("h"))
sequence.append(utils.AssertPresentationAction(
"1. h for next heading",
- ["KNOWN ISSUE: We're presenting the role first because of the child text",
- "BRAILLE LINE: 'line 2'",
- " VISIBLE: 'line 2', cursor=1",
- "SPEECH OUTPUT: 'heading level 1 line 2'"]))
+ ["BRAILLE LINE: 'line 2 h1'",
+ " VISIBLE: 'line 2 h1', cursor=1",
+ "SPEECH OUTPUT: 'line 2 heading level 1'"]))
sequence.append(utils.AssertionSummaryAction())
sequence.start()
diff --git a/test/keystrokes/firefox/html_struct_nav_link_with_child_text.py
b/test/keystrokes/firefox/html_struct_nav_link_with_child_text.py
index 7e4e1e9..b6adf32 100644
--- a/test/keystrokes/firefox/html_struct_nav_link_with_child_text.py
+++ b/test/keystrokes/firefox/html_struct_nav_link_with_child_text.py
@@ -11,10 +11,11 @@ sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("k"))
sequence.append(utils.AssertPresentationAction(
"1. k for next link",
- ["KNOWN ISSUE: We're presenting this incorrectly because of the child text",
+ ["BRAILLE LINE: 'line 2'",
+ " VISIBLE: 'line 2', cursor=1",
"BRAILLE LINE: 'line 2'",
- " VISIBLE: 'line 2', cursor=0",
- "SPEECH OUTPUT: 'blank'"]))
+ " VISIBLE: 'line 2', cursor=1",
+ "SPEECH OUTPUT: 'line 2 link'"]))
sequence.append(utils.AssertionSummaryAction())
sequence.start()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]