[orca] Web: Improve presentation of unknown setsize and row/column count
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Web: Improve presentation of unknown setsize and row/column count
- Date: Mon, 20 Jun 2022 15:52:32 +0000 (UTC)
commit cdb04615c06c6ac7dac3b2f6adfa0305b47cd7f4
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Mon Jun 20 17:32:13 2022 +0200
Web: Improve presentation of unknown setsize and row/column count
* If a setsize is unknown for a list that has just been entered,
indicate a list of unknown size is being entered, rather than
presenting nothing.
* For items in a group, if the setsize is unknown, just present the
item's position/index (to minimize chattiness repeating "unknown")
* If both the row count and column count are unknown, indicate a
table of unknown size is being entered.
* If only the row count or the column count are unknown, present the
known quantity first, followed by the unknown quantity.
Note: Firefox does not expose -1 (or the INDETERMINATE state) for an
author-provided setsize of -1. And it does expose a calculated size.
That needs to be addressed in Firefox. Chrome does expose -1 so we
don't absolutely need the INDETERMINATE state, though it would be
nice to have it.
Fixes issue #251
src/orca/formatting.py | 1 +
src/orca/generator.py | 3 ++-
src/orca/messages.py | 33 ++++++++++++++++++++++++++++++++
src/orca/object_properties.py | 9 +++++++++
src/orca/script_utilities.py | 6 ++++++
src/orca/scripts/web/script_utilities.py | 14 ++++++++++++++
src/orca/scripts/web/speech_generator.py | 10 ++++++++--
7 files changed, 73 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 7c35ec528..7981cb2bc 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -67,6 +67,7 @@ formatting = {
'multiselect': object_properties.STATE_MULTISELECT_SPEECH,
'iconindex': object_properties.ICON_INDEX_SPEECH,
'groupindex': object_properties.GROUP_INDEX_SPEECH,
+ 'groupindextotalunknown':object_properties.GROUP_INDEX_TOTAL_UNKNOWN_SPEECH,
'clickable': object_properties.STATE_CLICKABLE,
'haslongdesc': object_properties.STATE_HAS_LONGDESC,
'hasdetails': object_properties.RELATION_HAS_DETAILS,
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 7a8d5df76..11161b3f3 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -968,7 +968,8 @@ class Generator:
rows, cols = self._script.utilities.rowAndColumnCount(obj)
# This suggests broken or missing table interface.
- if rows < 0 or cols < 0:
+ if (rows < 0 or cols < 0) \
+ and not self._script.utilities.rowOrColumnCountUnknown(obj):
return []
# This can happen if an author uses ARIA incorrectly, e.g. a grid whose
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 0cb2ffd10..4c5886653 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -2559,6 +2559,15 @@ def leavingNLists(count):
return ngettext("Leaving %d list.", "Leaving %d lists.", count) % count
def listItemCount(count):
+ if count == -1:
+ # Translators: This message describes a list in web content for which the
+ # size is unknown. Examples include unlimited scrolling news/article feeds
+ # on social media sites, and message lists on services such as gmail where
+ # you're currently viewing messages 1-100 out of some huge, unspecified
+ # number. Normally Orca announces "list with n items" when the count is
+ # known. This is the corresponding message for the unknown-count scenario.
+ return _("List of unknown size")
+
# Translators: This message describes a bulleted or numbered list.
return ngettext("List with %d item", "List with %d items", count) % count
@@ -2679,10 +2688,34 @@ def tableCount(count, onlyIfFound=True):
return ngettext("%d table", "%d tables", count) % count
def tableSize(nRows, nColumns):
+ if nRows == -1:
+ if nColumns == -1:
+ # Translators: This message describes a table for which both the
+ # number of rows and the number of columns are unknown. Normally
+ # Orca announces the table dimensions (e.g. "table with 100 rows
+ # 15 columns"). When both counts are unknown, it presents this.
+ return _("table of unknown size")
+
+ # Translators: This message describes a table for which the number of
+ # rows is unknown, but the number of columns is known. This might occur
+ # in a vertically infinitely scrollable table or grid on the web.
+ return ngettext("table with %d column, row count unknown",
+ "table with %d columns, row count unknown",
+ nColumns) % nColumns
+
+ if nColumns == -1:
+ # Translators: This message describes a table for which the number of
+ # columns is unknown, but the number of rows is known. This might occur
+ # in a horizontally infinitely scrollable table or grid on the web.
+ return ngettext("table with %d row, column count unknown",
+ "table with %d rows, column count unknown",
+ nRows) % nRows
+
# Translators: this represents the number of rows in a table.
rowString = ngettext("table with %d row",
"table with %d rows",
nRows) % nRows
+
# Translators: this represents the number of columns in a table.
colString = ngettext("%d column",
"%d columns",
diff --git a/src/orca/object_properties.py b/src/orca/object_properties.py
index 46df70cb1..479e2c90f 100644
--- a/src/orca/object_properties.py
+++ b/src/orca/object_properties.py
@@ -45,6 +45,15 @@ ICON_INDEX_SPEECH = _("on %(index)d of %(total)d")
# combobox item in a combobox, etc.
GROUP_INDEX_SPEECH = _("%(index)d of %(total)d")
+# Translators: this refers to the position of an item in a list for which the
+# size is unknown. Examples include unlimited scrolling news/article feeds
+# on social media sites, and message lists on services such as gmail where
+# you're currently viewing messages 1-100 out of some huge, unspecified
+# number. Normally Orca announces both the position of the item and the
+# total number (e.g. "3 of 5"). This is the corresponding message for the
+# unknown-count scenario.
+GROUP_INDEX_TOTAL_UNKNOWN_SPEECH = _("item %(index)d")
+
# Translators: This message describes a list item in a document. Nesting level
# is how "deep" the item is (e.g., a level of 2 represents a list item inside a
# list that's inside another list).
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 3775a5da3..1d51fa490 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4509,6 +4509,12 @@ class Utilities:
row, col = table.getRowAtIndex(index), table.getColumnAtIndex(index)
return table.getRowExtentAt(row, col), table.getColumnExtentAt(row, col)
+ def setSizeUnknown(self, obj):
+ return obj.getState().contains(pyatspi.STATE_INDETERMINATE)
+
+ def rowOrColumnCountUnknown(self, obj):
+ return obj.getState().contains(pyatspi.STATE_INDETERMINATE)
+
def rowAndColumnCount(self, obj, preferAttribute=True):
try:
table = obj.queryTable()
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 108dd933a..bb720af4d 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2997,6 +2997,20 @@ class Utilities(script_utilities.Utilities):
return super().coordinatesForCell(obj, preferAttribute)
+ def setSizeUnknown(self, obj):
+ if super().setSizeUnknown(obj):
+ return True
+
+ attrs = self.objectAttributes(obj)
+ return attrs.get('setsize') == '-1'
+
+ def rowOrColumnCountUnknown(self, obj):
+ if super().rowOrColumnCountUnknown(obj):
+ return True
+
+ attrs = self.objectAttributes(obj)
+ return attrs.get('rowcount') == '-1' or attrs.get('colcount') == '-1'
+
def rowAndColumnCount(self, obj, preferAttribute=True):
rows, cols = super().rowAndColumnCount(obj)
if not preferAttribute:
diff --git a/src/orca/scripts/web/speech_generator.py b/src/orca/scripts/web/speech_generator.py
index 3c4e345ff..0cd04abdf 100644
--- a/src/orca/scripts/web/speech_generator.py
+++ b/src/orca/scripts/web/speech_generator.py
@@ -711,13 +711,19 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
position = int(position)
total = int(total)
- if position < 0 or total < 0:
+ if position < 0:
return []
+ stringType = 'groupindex'
+ if total < 0:
+ if not self._script.utilities.setSizeUnknown(obj):
+ return []
+ stringType += 'totalunknown'
+
result = []
result.append(self._script.formatting.getString(
mode='speech',
- stringType='groupindex') \
+ stringType=stringType) \
% {"index" : position,
"total" : total})
result.extend(self.voice(speech_generator.SYSTEM, obj=obj, **args))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]