[orca] Prefer object attributes over table interface for ARIA tables
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Prefer object attributes over table interface for ARIA tables
- Date: Wed, 5 Jun 2019 22:19:36 +0000 (UTC)
commit bb9e464d4b74e617907ef4bbee686ccedf260020
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Jun 5 18:17:06 2019 -0400
Prefer object attributes over table interface for ARIA tables
The table interface may reflect the physical table rather than the
conceptual table described by the author.
src/orca/generator.py | 7 +++--
src/orca/scripts/web/script_utilities.py | 46 ++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index ac05d7455..1a630c1d8 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -870,12 +870,11 @@ class Generator:
if self._script.utilities.isLayoutOnly(obj):
return []
- try:
- table = obj.queryTable()
- except:
+ rows, cols = self._script.utilities.rowAndColumnCount(obj)
+ if rows < 0 or cols < 0:
return []
- return [messages.tableSize(table.nRows, table.nColumns)]
+ return [messages.tableSize(rows, cols)]
def _generateTableCellRow(self, obj, **args):
"""Orca has a feature to automatically read an entire row of a table
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 0501ceba2..ae0064ea4 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2369,6 +2369,52 @@ class Utilities(script_utilities.Utilities):
self._isGridDescendant[hash(obj)] = rv
return rv
+ def _rowAndColumnIndices(self, obj):
+ rowindex = colindex = None
+
+ try:
+ attrs = dict([attr.split(':', 1) for attr in obj.getAttributes()])
+ except:
+ attrs = {}
+
+ rowindex = attrs.get('rowindex')
+ colindex = attrs.get('colindex')
+ if rowindex is not None and colindex is not None:
+ return rowindex, colindex
+
+ isRow = lambda x: x and x.getRole() == pyatspi.ROLE_TABLE_ROW
+ row = pyatspi.findAncestor(obj, isRow)
+ if not row:
+ return rowindex, colindex
+
+ try:
+ attrs = dict([attr.split(':', 1) for attr in row.getAttributes()])
+ except:
+ attrs = {}
+
+ rowindex = attrs.get('rowindex', rowindex)
+ colindex = attrs.get('colindex', colindex)
+ return rowindex, colindex
+
+ def coordinatesForCell(self, obj):
+ rowindex, colindex = self._rowAndColumnIndices(obj)
+ if rowindex is not None and colindex is not None:
+ return int(rowindex) - 1, int(colindex) - 1
+
+ return super().coordinatesForCell(obj)
+
+ def rowAndColumnCount(self, obj):
+ rows, cols = super().rowAndColumnCount(obj)
+
+ try:
+ attrs = dict([attr.split(':', 1) for attr in obj.getAttributes()])
+ except:
+ attrs = {}
+
+ rows = attrs.get('rowcount', rows)
+ cols = attrs.get('colcount', cols)
+ return int(rows), int(cols)
+
def shouldReadFullRow(self, obj):
if not (obj and self.inDocumentContent(obj)):
return super().shouldReadFullRow(obj)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]