Bug 1198336 - P3: Implement AXLiveRegionSearchKey. r=morgan

I think VoiceOver uses this to pull in all live regions so it
can check for deletions when they change later on.

Differential Revision: https://phabricator.services.mozilla.com/D96293
This commit is contained in:
Eitan Isaacson 2020-11-11 21:12:33 +00:00
parent 61086eeb1a
commit 5950c43ca4
4 changed files with 44 additions and 16 deletions

View File

@ -329,6 +329,13 @@ using namespace mozilla::a11y;
: RotorMacRoleRule(@"AXTextField");
[matches addObjectsFromArray:[self getMatchesForRule:rule]];
}
if ([key isEqualToString:@"AXLiveRegionSearchKey"]) {
RotorLiveRegionRule rule = mImmediateDescendantsOnly
? RotorLiveRegionRule(geckoRootAcc)
: RotorLiveRegionRule();
[matches addObjectsFromArray:[self getMatchesForRule:rule]];
}
}
return matches;

View File

@ -112,3 +112,12 @@ class RotorHeadingLevelRule : public RotorRoleRule {
private:
int32_t mLevel;
};
class RotorLiveRegionRule : public RotorRule {
public:
explicit RotorLiveRegionRule(AccessibleOrProxy& aDirectDescendantsFrom)
: RotorRule(aDirectDescendantsFrom) {}
explicit RotorLiveRegionRule() : RotorRule() {}
uint16_t Match(const AccessibleOrProxy& aAccOrProxy) override;
};

View File

@ -307,3 +307,15 @@ uint16_t RotorHeadingLevelRule::Match(const AccessibleOrProxy& aAccOrProxy) {
return result;
}
uint16_t RotorLiveRegionRule::Match(const AccessibleOrProxy& aAccOrProxy) {
uint16_t result = RotorRule::Match(aAccOrProxy);
if ((result & nsIAccessibleTraversalRule::FILTER_MATCH)) {
mozAccessible* nativeMatch = GetNativeFromGeckoAccessible(aAccOrProxy);
if (![nativeMatch moxIsLiveRegion]) {
result &= ~nsIAccessibleTraversalRule::FILTER_MATCH;
}
}
return result;
}

View File

@ -99,22 +99,22 @@ addAccessibleTask(
<div id="status" role="status"></div>
<output id="output"></output>`;
});
await loadComplete;
let webArea = (await loadComplete)[0];
liveRegionRemoved = waitForEvent(EVENT_LIVE_REGION_REMOVED, "status");
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("status")
.setAttribute("aria-live", "off");
});
await liveRegionRemoved;
liveRegionRemoved = waitForEvent(EVENT_LIVE_REGION_REMOVED, "output");
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("output")
.setAttribute("aria-live", "off");
});
await liveRegionRemoved;
is(webArea.getAttributeValue("AXRole"), "AXWebArea", "web area yeah");
const searchPred = {
AXSearchKey: "AXLiveRegionSearchKey",
AXResultsLimit: -1,
AXDirection: "AXDirectionNext",
};
const liveRegions = webArea.getParameterizedAttributeValue(
"AXUIElementsForSearchPredicate",
NSDictionary(searchPred)
);
Assert.deepEqual(
liveRegions.map(r => r.getAttributeValue("AXDOMIdentifier")),
["region-1", "region-2", "status", "output"],
"SearchPredicate returned all live regions"
);
}
);