Bug 1520611 - Prune children in Android. r=yzen

Differential Revision: https://phabricator.services.mozilla.com/D16743

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eitan Isaacson 2019-01-24 00:23:45 +00:00
Родитель 0ed303a220
Коммит e63779903d
3 изменённых файлов: 24 добавлений и 12 удалений

Просмотреть файл

@ -581,15 +581,20 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
}
}
auto childCount = ChildCount();
nsTArray<int32_t> children(childCount);
for (uint32_t i = 0; i < childCount; i++) {
auto child = static_cast<AccessibleWrap*>(GetChildAt(i));
children.AppendElement(child->VirtualViewID());
bool mustPrune =
IsProxy() ? nsAccUtils::MustPrune(Proxy()) : nsAccUtils::MustPrune(this);
if (!mustPrune) {
auto childCount = ChildCount();
nsTArray<int32_t> children(childCount);
for (uint32_t i = 0; i < childCount; i++) {
auto child = static_cast<AccessibleWrap*>(GetChildAt(i));
children.AppendElement(child->VirtualViewID());
}
GECKOBUNDLE_PUT(nodeInfo, "children",
jni::IntArray::New(children.Elements(), children.Length()));
}
GECKOBUNDLE_PUT(nodeInfo, "children",
jni::IntArray::New(children.Elements(), children.Length()));
GECKOBUNDLE_FINISH(nodeInfo);
return nodeInfo;

Просмотреть файл

@ -399,11 +399,21 @@ bool nsAccUtils::MustPrune(AccessibleOrProxy aAccessible) {
return true;
}
#if defined(ANDROID)
if (role == roles::LINK) {
// Always prune links in Android
return true;
}
#endif
if (role != roles::MENUITEM && role != roles::COMBOBOX_OPTION &&
role != roles::OPTION && role != roles::ENTRY &&
role != roles::FLAT_EQUATION && role != roles::PASSWORD_TEXT &&
role != roles::PUSHBUTTON && role != roles::TOGGLE_BUTTON &&
role != roles::GRAPHIC && role != roles::PROGRESSBAR &&
#if defined(ANDROID)
role != roles::HEADING &&
#endif
role != roles::SEPARATOR) {
// If it doesn't match any of these roles, don't prune its children.
return false;

Просмотреть файл

@ -839,12 +839,9 @@ class AccessibilityTest : BaseSessionTest() {
val buttonNode = createNodeInfo(rootNode.getChildId(2))
assertThat("Last node is a button", buttonNode.className.toString(), equalTo("android.widget.Button"))
assertThat("Button has a single text leaf", buttonNode.childCount, equalTo(1))
// The child text leaf is pruned, so this button is childless.
assertThat("Button has a single text leaf", buttonNode.childCount, equalTo(0))
assertThat("Button has correct text", buttonNode.text.toString(), equalTo("Submit"))
val textLeaf = createNodeInfo(buttonNode.getChildId(0))
assertThat("First node is a label", textLeaf.className.toString(), equalTo("android.view.View"))
assertThat("Text leaf has correct text", textLeaf.text.toString(), equalTo("Submit"))
}
@Setting(key = Setting.Key.FULL_ACCESSIBILITY_TREE, value = "true")