Bug 1668142 - Support AXDirectionPrevious in rotor with no start element. r=morgan

Depends on D91875

Differential Revision: https://phabricator.services.mozilla.com/D91878
This commit is contained in:
Eitan Isaacson 2020-10-01 18:55:57 +00:00
parent f4182287b4
commit 34f9d53bb7
2 changed files with 33 additions and 2 deletions

View File

@ -77,9 +77,22 @@ using namespace mozilla::a11y;
AccessibleOrProxy geckoRootAcc = [self rootGeckoAccessible];
AccessibleOrProxy geckoStartAcc = [self startGeckoAccessible];
Pivot p = Pivot(geckoRootAcc);
AccessibleOrProxy match = mSearchForward ? p.Next(geckoStartAcc, rule)
: p.Prev(geckoStartAcc, rule);
AccessibleOrProxy match;
if (mSearchForward) {
match = p.Next(geckoStartAcc, rule);
} else {
if (geckoRootAcc == geckoStartAcc) {
match = p.Last(rule);
} else {
match = p.Prev(geckoStartAcc, rule);
}
}
while (!match.IsNull() && resultLimit != 0) {
if (!mSearchForward && match == geckoRootAcc) {
break;
}
// we use mResultLimit != 0 to capture the case where mResultLimit is -1
// when it is set from the params dictionary. If that's true, we want
// to return all matches (ie. have no limit)

View File

@ -1521,5 +1521,23 @@ addAccessibleTask(
["p2"],
"Result is next group sibling"
);
searchPred = {
AXSearchKey: "AXAnyTypeSearchKey",
AXImmediateDescendantsOnly: 1,
AXResultsLimit: -1,
AXDirection: "AXDirectionPrevious",
};
results = searchRoot.getParameterizedAttributeValue(
"AXUIElementsForSearchPredicate",
NSDictionary(searchPred)
);
Assert.deepEqual(
results.map(r => r.getAttributeValue("AXDOMIdentifier")),
["p2", "p1"],
"A reverse search should return groups in reverse"
);
}
);