Commit 7c4e39e3 authored by Joanmarie Diggs's avatar Joanmarie Diggs

Web: Also announce the header and sort order when aria-sort changes

Note: This support requires browsers to emit the expected signals.
Chromium will soon; Firefox doesn't yet.
parent bdb0fd3e
......@@ -809,16 +809,11 @@ class Generator:
return result
def _generateSortOrder(self, obj, **args):
if not self._script.utilities.isSorted(obj):
description = self._script.utilities.getSortOrderDescription(obj)
if not description:
return []
if self._script.utilities.isAscending(obj):
return [object_properties.SORT_ORDER_ASCENDING]
if self._script.utilities.isDescending(obj):
return [object_properties.SORT_ORDER_DESCENDING]
return [object_properties.SORT_ORDER_OTHER]
return [description]
def _generateTableCell2ChildLabel(self, obj, **args):
"""Returns an array of strings for use by speech and braille for the
......
......@@ -1399,12 +1399,31 @@ class Utilities:
return _settingsManager.getSetting('readFullRowInDocumentTable')
def isSorted(self, obj):
return False
def isAscending(self, obj):
return False
def isDescending(self, obj):
return False
def getSortOrderDescription(self, obj, includeName=False):
if not (obj and self.isSorted(obj)):
return ""
if self.isAscending(obj):
result = object_properties.SORT_ORDER_ASCENDING
elif self.isDescending(obj):
result = object_properties.SORT_ORDER_DESCENDING
else:
result = object_properties.SORT_ORDER_OTHER
if includeName and obj.name:
result = "%s. %s" % (obj.name, result)
return result
def isFocusableLabel(self, obj):
try:
role = obj.getRole()
......@@ -4190,6 +4209,20 @@ class Utilities:
return False
def containingTableHeader(self, obj):
if not obj:
return None
roles = [pyatspi.ROLE_COLUMN_HEADER,
pyatspi.ROLE_ROW_HEADER,
pyatspi.ROLE_TABLE_COLUMN_HEADER,
pyatspi.ROLE_TABLE_ROW_HEADER]
isHeader = lambda x: x and x.getRole() in roles
if isHeader(obj):
return obj
return pyatspi.findAncestor(obj, isHeader)
def columnHeadersForCell(self, obj):
if not (obj and obj.getRole() == pyatspi.ROLE_TABLE_CELL):
return []
......
......@@ -1807,6 +1807,10 @@ class Script(default.Script):
self.pointOfReference['last-table-sort-time'] = time.time()
self.presentMessage(messages.TABLE_REORDERED_COLUMNS)
header = self.utilities.containingTableHeader(orca_state.locusOfFocus)
if header:
self.presentMessage(self.utilities.getSortOrderDescription(header, True))
return True
def onDocumentLoadComplete(self, event):
......@@ -2038,6 +2042,10 @@ class Script(default.Script):
self.pointOfReference['last-table-sort-time'] = time.time()
self.presentMessage(messages.TABLE_REORDERED_ROWS)
header = self.utilities.containingTableHeader(orca_state.locusOfFocus)
if header:
self.presentMessage(self.utilities.getSortOrderDescription(header, True))
return True
def onSelectedChanged(self, event):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment