diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-09-02 13:06:08 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-09-02 15:47:37 +0200 |
commit | 206543c7bef58fc559852553a3b2faba0b604259 (patch) | |
tree | 4fc3e0e57e6f9b50e276998fc04241035a2dffb6 /qadevOOo | |
parent | 38671e21d7dbcd5019912b9468305018de0c922e (diff) |
[API CHANGE] tdf#150683 a11y: Switch a11y child index to 64 bit
With 16k column support in Calc enabled by default in
commit 4c5f8ccf0a2320432b8fe91add1dcadf54d9fd58
Date: Tue Mar 8 12:44:49 2022 +0100
change default Calc number of columns to 16384 (tdf#50916)
, the number of Calc cells in a spreadsheet is larger than
SAL_MAX_INT32, meaning that a 32-bit a11y child index is no more
enough and using it resulted in integer overflows in
methods handling corresponding Calc cells in the a11y layer.
This e.g. had the effect of the Orca and NVDA screen readers
not announcing focused or selected cells properly when their
a11y child index was out of the 32-bit integer range.
Switch the internal a11y child indices to 64 bit to
be able to handle this properly internally.
Since the platform APIs (at least AT-SPI on Linux and
IAccessible2 on Windows; from what I can see LO's macOS
a11y bridge doesn't directly expose the child index)
are still restricted to 32 bit, larger child indices
still cannot be exposed via the platform APIs.
As a consequence, use of the the IAccessible2 and
AT-SPI methods that use the child index remains
problematic in those cases where the child index
is larger. However, as an alternative to using the
AT-SPI Table interface and the IAccessibleTable/
IAccessibleTable2 interfaces with the child index
to retrieve information about a specific cell,
both AT-SPI and IAccessible2 also provide interfaces
to retrieve that information directly
from the cell object (TableCell interface for AT-SPI,
IAccessibleTableCell for IAccessible2).
Those interfaces are already implemented/exposed
for winaccessibility (s. `CAccTable`) and the
qt5/qt6/kf5 VCL plugins (s. the `QAccessibleTableCellInterface`
methods implemented in `QtAccessibleInterface`).
With the switch to 64-bit internal a11y child indices,
these now behave correctly for cells with a child
index that doesn't fit into 32 bit as well.
NVDA on Windows already uses the IAccessibleTableCell
interface and thus announcing focused cells works fine
with this change in place.
Orca on Linux currently doesn't make use of the AT-SPI
TableCell interface yet, but with a suggested change to
do so [1], announcement of selected cells works
with the qt6 VCL plugin with a current qtbase dev branch
as well - when combined with the suggested changes
to implement support for the AT-SPI TableCell interface
in Qt [2] [3] and the LO change based on that [4] and
a fix for a nullptr dereference [5].
The gtk3 VCL plugin doesn't expose the AT-SPI
TableCell interface yet, but once it does so
(via `AtkTableCell`), it also works with the
suggested Orca change [1] in place.
(Adding that is planned for an upcoming change,
works with a local WIP patch.)
For handling return values that are larger than what
platform APIs support, the following approach has
been chosen for now:
1) When the return value is for the count of
(selected) children, the maximum value N
supported by the platform API is returned.
(This is what `ScAccessibleTableBase::getAccessibleChildCount`
did previously.)
The first N elements can be accessed by their
actual (selection) indices.
2) When the return value is the child/cell index,
-2 is returned for objects whose index is greater
than the maximum value supported by the platform
API.
Using a non-negative value would mean that the
index would refer to *another* actually existing
child. A child index of -1 on the other hand
tends to be interpreted as "child is invalid" or
"object isn't actually a child of its (previous)
parent any more)". For the Orca case, this would
result in objects with a child index of -1
not being announced, as they are considered
"zombies" [6].
What's still somewhat problematic is the case where
more than 2^31 children are *selected*, since access
to those children still happens by the index into
the selection in the platform APIs, and not all
selected items are accessible this way.
(Screen readers usually just retrieve
the first and last element from the selection and
announce those.)
Orca already seems to apply different handling for the
case for fully selected rows and columns, so
"All cells selected" or "Columns ... to ... selected"
is announced just fine even if more than 2^31
cells are selected.
(Side note: While Microsoft User Interface
Automation - UIA - also uses 32-bit indices, it also
has specific methods in the ISelectionProvider2
interface that allow to explicitly retrieve the
first and last selected item,
`ISelectionProvider2::get_FirstSelectedItem` and
`ISelectionProvider2::get_LastSelectedItem`, but
we currently don't support UIA on Windows.)
Bound checks at the beginning of the methods from the
`XAccessibleContext`, `XAccessibleSelection` and
`XAccessibleTable` interfaces that take a child index
(or in helper methods called by those) should generally
already prevent too large indices from being passed to
the methods in the lower layer code that take smaller
integer types. Such bound checking has been
been added in various places where it wasn't present yet.
If there any remaining issues of this
kind that show after this commit, they can probably be
solved in a similar way (s.e.g. the change to
`AccessibleBrowseBox::getAccessibleChild` in this
commit).
A few asserts were also added at
places where my understanding is that values shouldn't
be larger than what is supported by a called method
anyway.
A test case will be added in a following change.
[1] https://gitlab.gnome.org/GNOME/orca/-/merge_requests/131
[2] https://codereview.qt-project.org/c/qt/qtbase/+/428566
[3] https://codereview.qt-project.org/c/qt/qtbase/+/428567
[4] https://gerrit.libreoffice.org/c/core/+/138750
[5] https://codereview.qt-project.org/c/qt/qtbase/+/430157
[6] https://gitlab.gnome.org/GNOME/orca/-/blob/82c8542002e36e0d3d918088d583162d25136143/src/orca/script_utilities.py#L5155
Change-Id: I3af590c988b0e6754fc72545918412f39e8fea07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139258
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'qadevOOo')
8 files changed, 56 insertions, 57 deletions
diff --git a/qadevOOo/runner/util/AccessibilityTools.java b/qadevOOo/runner/util/AccessibilityTools.java index 562c03e67b41..672754d80f1a 100644 --- a/qadevOOo/runner/util/AccessibilityTools.java +++ b/qadevOOo/runner/util/AccessibilityTools.java @@ -103,13 +103,13 @@ public class AccessibilityTools { SearchedAccessible = xacc; return ac; } else { - int k = ac.getAccessibleChildCount(); + long k = ac.getAccessibleChildCount(); if (ac.getAccessibleChildCount() > 100) { k = 50; } - for (int i = 0; i < k; i++) { + for (long i = 0; i < k; i++) { try { XAccessibleContext ac2 = getAccessibleObjectForRoleIgnoreShowing_( ac.getAccessibleChild(i), role); @@ -135,13 +135,13 @@ public class AccessibilityTools { SearchedAccessible = xacc; return ac; } else { - int k = ac.getAccessibleChildCount(); + long k = ac.getAccessibleChildCount(); if (ac.getAccessibleChildCount() > 100) { k = 50; } - for (int i = 0; i < k; i++) { + for (long i = 0; i < k; i++) { try { XAccessibleContext ac2 = getAccessibleObjectForRole_(ac.getAccessibleChild(i), role); @@ -186,13 +186,13 @@ public class AccessibilityTools { return ac; } else { - int k = ac.getAccessibleChildCount(); + long k = ac.getAccessibleChildCount(); if (ac.getAccessibleChildCount() > 100) { k = 50; } - for (int i = 0; i < k; i++) { + for (long i = 0; i < k; i++) { try { XAccessibleContext ac1 = getAccessibleObjectForRoleIgnoreShowing( ac.getAccessibleChild(i), @@ -227,13 +227,13 @@ public class AccessibilityTools { SearchedAccessible = xacc; return ac; } else { - int k = ac.getAccessibleChildCount(); + long k = ac.getAccessibleChildCount(); if (ac.getAccessibleChildCount() > 100) { k = 50; } - for (int i = 0; i < k; i++) { + for (long i = 0; i < k; i++) { try { XAccessibleContext ac1 = getAccessibleObjectForRole( ac.getAccessibleChild(i), @@ -287,13 +287,13 @@ public class AccessibilityTools { logging(log,indent + indent + "StateType contains SHOWING: " + isShowing); - int k = ac.getAccessibleChildCount(); + long k = ac.getAccessibleChildCount(); if (ac.getAccessibleChildCount() > 100) { k = 50; } - for (int i = 0; i < k; i++) { + for (long i = 0; i < k; i++) { try { printAccessibleTree(log, ac.getAccessibleChild(i), indent + " "); @@ -305,10 +305,10 @@ public class AccessibilityTools { if (ac.getAccessibleChildCount() > 100) { k = ac.getAccessibleChildCount(); - int st = ac.getAccessibleChildCount() - 50; + long st = ac.getAccessibleChildCount() - 50; logging(log,indent + " " + " ...... [skipped] ......"); - for (int i = st; i < k; i++) { + for (long i = st; i < k; i++) { try { printAccessibleTree(log, ac.getAccessibleChild(i), indent + " "); diff --git a/qadevOOo/runner/util/UITools.java b/qadevOOo/runner/util/UITools.java index c9969d355752..438bd1c6a7fb 100644 --- a/qadevOOo/runner/util/UITools.java +++ b/qadevOOo/runner/util/UITools.java @@ -157,7 +157,7 @@ public class UITools { xListBoxAccess, AccessibleRole.LIST, true); } - for (int i=0;i<xList.getAccessibleChildCount();i++) { + for (long i=0;i<xList.getAccessibleChildCount();i++) { try { XAccessible xChild = xList.getAccessibleChild(i); XAccessibleContext xChildCont = diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java index fee660617693..2bf4caf14bdf 100644 --- a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java @@ -292,7 +292,7 @@ public class _XAccessibleComponent extends MultiMethodTest { "," + (chBnd.Y + curY) + ") - OK"); boolean res = false; - int expIndex; + long expIndex; String expName; String expDesc; @@ -314,7 +314,7 @@ public class _XAccessibleComponent extends MultiMethodTest { } if (!res) { - int gotIndex = xAcc.getAccessibleContext() + long gotIndex = xAcc.getAccessibleContext() .getAccessibleIndexInParent(); if (expIndex < gotIndex) { @@ -485,7 +485,7 @@ public class _XAccessibleComponent extends MultiMethodTest { } XAccessibleContext xAccCon = xAcc.getAccessibleContext(); - int cnt = xAccCon.getAccessibleChildCount(); + long cnt = xAccCon.getAccessibleChildCount(); // for cases when too many children exist checking only first 50 if (cnt > 50) { @@ -494,7 +494,7 @@ public class _XAccessibleComponent extends MultiMethodTest { ArrayList<XAccessibleComponent> childComp = new ArrayList<XAccessibleComponent>(); - for (int i = 0; i < cnt; i++) { + for (long i = 0; i < cnt; i++) { try { XAccessible child = xAccCon.getAccessibleChild(i); XAccessibleContext xAccConCh = child.getAccessibleContext(); diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java index f5b23c89bed7..8ce5e1647855 100644 --- a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java @@ -48,7 +48,7 @@ import util.AccessibilityTools; public class _XAccessibleContext extends MultiMethodTest { private static final String className = "com.sun.star.accessibility.XAccessibleContext"; public XAccessibleContext oObj = null; - private int childCount = 0; + private long childCount = 0; private XAccessible parent = null; // temporary while accessibility package is in com.sun.star @@ -85,13 +85,13 @@ public class _XAccessibleContext extends MultiMethodTest { log.println("testing 'getAccessibleChild()'..."); boolean bOK = true; - int counter = childCount; + long counter = childCount; if (childCount > 500) { counter = 500; } - for (int i = 0; i < counter; i++) { + for (long i = 0; i < counter; i++) { try { XAccessible ch = oObj.getAccessibleChild(i); XAccessibleContext chAC = ch.getAccessibleContext(); @@ -201,7 +201,7 @@ public class _XAccessibleContext extends MultiMethodTest { requiredMethod("getAccessibleParent()"); boolean bOK = true; - int idx = oObj.getAccessibleIndexInParent(); + long idx = oObj.getAccessibleIndexInParent(); XAccessibleContext parentAC = parent.getAccessibleContext(); diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java index 0cf632c47a38..d6b5a3cfbf71 100644 --- a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java @@ -56,7 +56,7 @@ public class _XAccessibleSelection extends MultiMethodTest { private static final String className = "com.sun.star.accessibility.XAccessibleSelection"; public XAccessibleSelection oObj = null; XAccessibleContext xAC = null; - int childCount; + long childCount; protected boolean multiSelection = true; protected boolean OneAlwaysSelected = false; @@ -131,7 +131,7 @@ public class _XAccessibleSelection extends MultiMethodTest { log.println("ChildCount: " + childCount); - int usedChildren = childCount; + long usedChildren = childCount; if (childCount > 500) { log.println("Restricting to 500"); @@ -140,7 +140,7 @@ public class _XAccessibleSelection extends MultiMethodTest { if (usedChildren > 0) { try { - for (int i = 0; i < usedChildren; i++) { + for (long i = 0; i < usedChildren; i++) { log.print("Trying to select child with index " + i + ": "); if (isSelectable(tEnv.getTestObject(), i)) { @@ -195,7 +195,7 @@ public class _XAccessibleSelection extends MultiMethodTest { res &= true; } - int SelectableChildCount = chkSelectable(tEnv.getTestObject()); + long SelectableChildCount = chkSelectable(tEnv.getTestObject()); if (SelectableChildCount > 500) { SelectableChildCount = 500; @@ -207,7 +207,7 @@ public class _XAccessibleSelection extends MultiMethodTest { try { oObj.selectAllAccessibleChildren(); - for (int k = 0; k < SelectableChildCount; k++) { + for (long k = 0; k < SelectableChildCount; k++) { log.println("Trying to select child with index " + k); if (isSelectable(tEnv.getTestObject(), k)) { @@ -289,7 +289,7 @@ public class _XAccessibleSelection extends MultiMethodTest { boolean res = true; boolean isSelected = true; - int SelectableChildCount = chkSelectable(tEnv.getTestObject()); + long SelectableChildCount = chkSelectable(tEnv.getTestObject()); if ((SelectableChildCount > 0) && multiSelection) { try { @@ -327,7 +327,7 @@ public class _XAccessibleSelection extends MultiMethodTest { if (multiSelection) { oObj.selectAllAccessibleChildren(); } else { - int usedChildren = childCount; + long usedChildren = childCount; if (childCount > 500) { log.println("Restricting to 500"); @@ -336,7 +336,7 @@ public class _XAccessibleSelection extends MultiMethodTest { if (usedChildren > 0) { try { - for (int i = 0; i < usedChildren; i++) { + for (long i = 0; i < usedChildren; i++) { if (isSelectable(tEnv.getTestObject(), i)) { log.print("Trying to select child with index "+i+": "); @@ -358,10 +358,10 @@ public class _XAccessibleSelection extends MultiMethodTest { } } - int sCount = chkSelectable(tEnv.getTestObject()); + long sCount = chkSelectable(tEnv.getTestObject()); log.println("Found " + sCount + " selectable Children"); - int selectedCount = oObj.getSelectedAccessibleChildCount(); + long selectedCount = oObj.getSelectedAccessibleChildCount(); log.println("After selecting all accessible " + selectedCount + " are selected"); @@ -398,7 +398,7 @@ public class _XAccessibleSelection extends MultiMethodTest { executeMethod("getSelectedAccessibleChildCount()"); boolean res = true; - int selectedCount = oObj.getSelectedAccessibleChildCount(); + long selectedCount = oObj.getSelectedAccessibleChildCount(); log.println("getSelectedAccessibleChildCount: " + selectedCount); try { @@ -421,14 +421,14 @@ public class _XAccessibleSelection extends MultiMethodTest { res &= true; } - int SelectableChildCount = chkSelectable(tEnv.getTestObject()); + long SelectableChildCount = chkSelectable(tEnv.getTestObject()); if (SelectableChildCount > 500) { SelectableChildCount = 500; } if (SelectableChildCount > 0) { - int k = 0; + long k = 0; try { for (k = 0; k < SelectableChildCount; k++) { log.println("Trying to select child with index " + k); @@ -468,7 +468,7 @@ public class _XAccessibleSelection extends MultiMethodTest { executeMethod("getSelectedAccessibleChild()"); boolean res = true; - int selCount = oObj.getSelectedAccessibleChildCount(); + long selCount = oObj.getSelectedAccessibleChildCount(); log.println("getSelectedAccessibleChildCount():" + selCount); try { @@ -499,13 +499,13 @@ public class _XAccessibleSelection extends MultiMethodTest { if ((childCount > 0) && (selCount > 0)) { try { - int maxCount = chkSelectable(tEnv.getTestObject()); + long maxCount = chkSelectable(tEnv.getTestObject()); if (childCount > 100) { maxCount = 100; } - for (int k = 0; k < maxCount; k++) { + for (long k = 0; k < maxCount; k++) { log.println("deselectAccessibleChild(" + k + ")"); if (oObj.isAccessibleChildSelected(k)) { @@ -513,7 +513,7 @@ public class _XAccessibleSelection extends MultiMethodTest { } } - int newSelCount = oObj.getSelectedAccessibleChildCount(); + long newSelCount = oObj.getSelectedAccessibleChildCount(); log.println("getSelectedAccessibleChildCount():" + newSelCount); @@ -533,17 +533,17 @@ public class _XAccessibleSelection extends MultiMethodTest { tRes.tested("deselectAccessibleChild()", res); } - protected static int chkSelectable(Object Testcase) { - int ret = 0; + protected static long chkSelectable(Object Testcase) { + long ret = 0; XAccessibleContext accCon = UnoRuntime.queryInterface( XAccessibleContext.class, Testcase); - int cc = accCon.getAccessibleChildCount(); + long cc = accCon.getAccessibleChildCount(); if (cc > 500) { return cc; } - for (int i = 0; i < cc; i++) { + for (long i = 0; i < cc; i++) { try { if ((accCon.getAccessibleChild(i).getAccessibleContext() .getAccessibleStateSet() @@ -558,7 +558,7 @@ public class _XAccessibleSelection extends MultiMethodTest { return ret; } - protected static boolean isSelectable(Object Testcase, int index) { + protected static boolean isSelectable(Object Testcase, long index) { XAccessibleContext accCon = UnoRuntime.queryInterface( XAccessibleContext.class, Testcase); boolean res = false; diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java index ee2400f44813..2e66b4306850 100644 --- a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java @@ -793,7 +793,7 @@ public class _XAccessibleTable extends MultiMethodTest { try { log.print("getAccessibleIndex(-1," + (colCount-1) + "):"); - int indx = oObj.getAccessibleIndex(-1, colCount - 1); + long indx = oObj.getAccessibleIndex(-1, colCount - 1); log.println(indx); log.println("Exception was expected"); res &= false; @@ -804,7 +804,7 @@ public class _XAccessibleTable extends MultiMethodTest { try { log.print("getAccessibleIndex(" + (rowCount-1) + ",-1):"); - int indx = oObj.getAccessibleIndex(rowCount - 1, -1); + long indx = oObj.getAccessibleIndex(rowCount - 1, -1); log.println(indx); log.println("Exception was expected"); res &= false; @@ -815,7 +815,7 @@ public class _XAccessibleTable extends MultiMethodTest { try { log.print("getAccessibleIndex(0," + colCount + "):"); - int indx = oObj.getAccessibleIndex(0, colCount); + long indx = oObj.getAccessibleIndex(0, colCount); log.println(indx); log.println("Exception was expected"); res &= false; @@ -826,7 +826,7 @@ public class _XAccessibleTable extends MultiMethodTest { try { log.print("getAccessibleIndex(" + rowCount + ",0):"); - int indx = oObj.getAccessibleIndex(rowCount, 0); + long indx = oObj.getAccessibleIndex(rowCount, 0); log.println(indx); log.println("Exception was expected"); res &= false; @@ -838,12 +838,11 @@ public class _XAccessibleTable extends MultiMethodTest { try { log.print("getAccessibleIndex(" + (rowCount-1) + "," + (colCount-1) + "): "); - int indx = oObj.getAccessibleIndex( - rowCount - 1, colCount - 1); + long indx = oObj.getAccessibleIndex(rowCount - 1, colCount - 1); log.println(indx); if (xCellAc != null) { XAccessibleContext xAC = xCellAc.getAccessibleContext(); - int expIndx = xAC.getAccessibleIndexInParent(); + long expIndx = xAC.getAccessibleIndexInParent(); log.println("Expected index: " + expIndx); res &= expIndx == indx; } else { @@ -877,7 +876,7 @@ public class _XAccessibleTable extends MultiMethodTest { boolean res = true; if (xACont != null) { - int childCount = xACont.getAccessibleChildCount(); + long childCount = xACont.getAccessibleChildCount(); log.println("accessible child count: " + childCount); try { @@ -947,7 +946,7 @@ public class _XAccessibleTable extends MultiMethodTest { boolean res = true; if (xACont != null) { - int childCount = xACont.getAccessibleChildCount(); + long childCount = xACont.getAccessibleChildCount(); log.println("accessible child count: " + childCount); try { @@ -997,4 +996,4 @@ public class _XAccessibleTable extends MultiMethodTest { tRes.tested("getAccessibleColumn()", res); } -}
\ No newline at end of file +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java index 37b59c323f5d..cdae4e041f98 100644 --- a/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java @@ -126,8 +126,8 @@ public class SwAccessibleDocumentView extends TestCase { if (first) SearchedContext = ac; else first=true; } else { - int k = ac.getAccessibleChildCount(); - for (int i=0;i<k;i++) { + long k = ac.getAccessibleChildCount(); + for (long i = 0; i < k; i++) { try { getAccessibleObjectForRole(ac.getAccessibleChild(i),role); if (SearchedContext != null) return ; diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java b/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java index 62f6e8454e3b..a1d79cc02c87 100644 --- a/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java +++ b/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java @@ -171,8 +171,8 @@ public class SwAccessiblePageView extends TestCase { if (first) SearchedContext = ac; else first=true; } else { - int k = ac.getAccessibleChildCount(); - for (int i=0;i<k;i++) { + long k = ac.getAccessibleChildCount(); + for (long i = 0; i < k; i++) { try { getAccessibleObjectForRole(ac.getAccessibleChild(i),role); if (SearchedContext != null) return ; |