forked from mirrors/gecko-dev
Bug 1810596: When computing the text for a live region on Android, always include the text from the subtree. r=eeejay,geckoview-reviewers,ohall
Previously, we only included the subtree for roles which are allowed to be traversed during recursive name computation. This meant that no text would be produced for live regions with roles such as status, where name computation traversal is not allowed. Now, we first get the name to handle cases where the name is explicitly specified; e.g. images with alt text. We then add the subtree text if the name wasn't already computed from it. Differential Revision: https://phabricator.services.mozilla.com/D210628
This commit is contained in:
parent
6074fa2e41
commit
426407a812
3 changed files with 36 additions and 6 deletions
|
|
@ -403,12 +403,20 @@ int32_t AccessibleWrap::GetInputType(const nsString& aInputTypeAttr) {
|
|||
}
|
||||
|
||||
void AccessibleWrap::GetTextEquiv(nsString& aText) {
|
||||
if (nsTextEquivUtils::HasNameRule(this, eNameFromSubtreeIfReqRule)) {
|
||||
// This is an accessible that normally doesn't get its name from its
|
||||
// subtree, so we collect the text equivalent explicitly.
|
||||
nsTextEquivUtils::GetTextEquivFromSubtree(this, aText);
|
||||
} else {
|
||||
Name(aText);
|
||||
// 1. Start with the name, since it might have been explicitly specified.
|
||||
if (Name(aText) != eNameFromSubtree) {
|
||||
// 2. If the name didn't come from the subtree, add the text from the
|
||||
// subtree.
|
||||
if (aText.IsEmpty()) {
|
||||
nsTextEquivUtils::GetTextEquivFromSubtree(this, aText);
|
||||
} else {
|
||||
nsAutoString subtree;
|
||||
nsTextEquivUtils::GetTextEquivFromSubtree(this, subtree);
|
||||
if (!subtree.IsEmpty()) {
|
||||
aText.Append(' ');
|
||||
aText.Append(subtree);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="status" role="status"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1202,6 +1202,19 @@ class AccessibilityTest : BaseSessionTest() {
|
|||
})
|
||||
}
|
||||
|
||||
@Test fun testLiveRegionStatus() {
|
||||
loadTestPage("test-live-region-status")
|
||||
waitForInitialFocus()
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('#status').textContent = 'hello';")
|
||||
sessionRule.waitUntilCalled(object : EventDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAnnouncement(event: AccessibilityEvent) {
|
||||
assertThat("Announcement is correct", event.text[0].toString(), equalTo("hello"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun screenContainsNode(nodeId: Int): Boolean {
|
||||
var node = createNodeInfo(nodeId)
|
||||
var nodeBounds = Rect()
|
||||
|
|
|
|||
Loading…
Reference in a new issue