Commit 83f9b669 authored by Hiroki Sato's avatar Hiroki Sato Committed by Commit Bot

Wire Android's ImportantForAccessibility to Chrome State

When DrawerLayout is opened, the contents behind the menu should not get
accessibility focus.
These nodes have ImportantForAccessibility=false attribute in Android.
This CL respects the attribute to set ignored state in Chrome side.

Bug: b:130186722
Test: unit_tests --gtest_filter="AXTreeSourceArcTest.*"
Test: manually confirmed with PlayStore, hangouts, Dropbox, etc. that drawer menu navigation is restricted in the menu.
Change-Id: I390920f3ec5ba2943a7474483f3180c8cd587ed7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1875853
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709780}
parent a11fa986
...@@ -88,14 +88,6 @@ void AccessibilityNodeInfoDataWrapper::PopulateAXRole( ...@@ -88,14 +88,6 @@ void AccessibilityNodeInfoDataWrapper::PopulateAXRole(
class_name); class_name);
} }
if (!GetProperty(AXBooleanProperty::IMPORTANCE) &&
!HasProperty(AXStringProperty::TEXT) &&
!HasProperty(AXStringProperty::CONTENT_DESCRIPTION) &&
!tree_source_->IsRootOfNodeTree(GetId())) {
out_data->role = ax::mojom::Role::kIgnored;
return;
}
if (GetProperty(AXBooleanProperty::EDITABLE)) { if (GetProperty(AXBooleanProperty::EDITABLE)) {
out_data->role = ax::mojom::Role::kTextField; out_data->role = ax::mojom::Role::kTextField;
return; return;
...@@ -263,13 +255,14 @@ void AccessibilityNodeInfoDataWrapper::PopulateAXState( ...@@ -263,13 +255,14 @@ void AccessibilityNodeInfoDataWrapper::PopulateAXState(
: ax::mojom::CheckedState::kFalse); : ax::mojom::CheckedState::kFalse);
} }
if (!GetProperty(AXBooleanProperty::ENABLED)) { if (!GetProperty(AXBooleanProperty::ENABLED))
out_data->SetRestriction(ax::mojom::Restriction::kDisabled); out_data->SetRestriction(ax::mojom::Restriction::kDisabled);
}
if (!GetProperty(AXBooleanProperty::VISIBLE_TO_USER)) { if (!GetProperty(AXBooleanProperty::VISIBLE_TO_USER))
out_data->AddState(ax::mojom::State::kInvisible); out_data->AddState(ax::mojom::State::kInvisible);
}
if (!GetProperty(AXBooleanProperty::IMPORTANCE))
out_data->AddState(ax::mojom::State::kIgnored);
} }
void AccessibilityNodeInfoDataWrapper::Serialize( void AccessibilityNodeInfoDataWrapper::Serialize(
......
...@@ -235,6 +235,7 @@ TEST_F(AXTreeSourceArcTest, ReorderChildrenByLayout) { ...@@ -235,6 +235,7 @@ TEST_F(AXTreeSourceArcTest, ReorderChildrenByLayout) {
event->node_data.push_back(AXNodeInfoData::New()); event->node_data.push_back(AXNodeInfoData::New());
AXNodeInfoData* root = event->node_data.back().get(); AXNodeInfoData* root = event->node_data.back().get();
root->id = 10; root->id = 10;
SetProperty(root, AXBooleanProperty::IMPORTANCE, true);
SetProperty(root, AXIntListProperty::CHILD_NODE_IDS, SetProperty(root, AXIntListProperty::CHILD_NODE_IDS,
std::vector<int>({1, 2})); std::vector<int>({1, 2}));
...@@ -856,6 +857,7 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) { ...@@ -856,6 +857,7 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) {
AXNodeInfoData* root = event->node_data.back().get(); AXNodeInfoData* root = event->node_data.back().get();
root->id = 10; root->id = 10;
SetProperty(root, AXIntListProperty::CHILD_NODE_IDS, std::vector<int>({1})); SetProperty(root, AXIntListProperty::CHILD_NODE_IDS, std::vector<int>({1}));
SetProperty(root, AXBooleanProperty::IMPORTANCE, true);
event->node_data.emplace_back(AXNodeInfoData::New()); event->node_data.emplace_back(AXNodeInfoData::New());
AXNodeInfoData* node1 = event->node_data.back().get(); AXNodeInfoData* node1 = event->node_data.back().get();
...@@ -876,9 +878,10 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) { ...@@ -876,9 +878,10 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) {
"id=100 window (0, 0)-(0, 0) child_ids=10\n" "id=100 window (0, 0)-(0, 0) child_ids=10\n"
" id=10 genericContainer INVISIBLE (0, 0)-(0, 0) restriction=disabled " " id=10 genericContainer INVISIBLE (0, 0)-(0, 0) restriction=disabled "
"modal=true child_ids=1\n" "modal=true child_ids=1\n"
" id=1 ignored INVISIBLE (0, 0)-(0, 0) restriction=disabled " " id=1 genericContainer IGNORED INVISIBLE (0, 0)-(0, 0) "
"child_ids=2\n" "restriction=disabled child_ids=2\n"
" id=2 ignored INVISIBLE (0, 0)-(0, 0) restriction=disabled\n"); " id=2 genericContainer IGNORED INVISIBLE (0, 0)-(0, 0) "
"restriction=disabled\n");
EXPECT_EQ(0U, tree()->GetFromId(10)->GetUnignoredChildCount()); EXPECT_EQ(0U, tree()->GetFromId(10)->GetUnignoredChildCount());
...@@ -887,6 +890,7 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) { ...@@ -887,6 +890,7 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) {
AXNodeInfoData* node3 = event->node_data.back().get(); AXNodeInfoData* node3 = event->node_data.back().get();
node3->id = 3; node3->id = 3;
SetProperty(node3, AXStringProperty::CONTENT_DESCRIPTION, "some text"); SetProperty(node3, AXStringProperty::CONTENT_DESCRIPTION, "some text");
SetProperty(node3, AXBooleanProperty::IMPORTANCE, true);
SetProperty(node2, AXIntListProperty::CHILD_NODE_IDS, std::vector<int>({3})); SetProperty(node2, AXIntListProperty::CHILD_NODE_IDS, std::vector<int>({3}));
// |node3| is unignored since it has some text. // |node3| is unignored since it has some text.
...@@ -896,10 +900,10 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) { ...@@ -896,10 +900,10 @@ TEST_F(AXTreeSourceArcTest, SerializeAndUnserialize) {
"id=100 window (0, 0)-(0, 0) child_ids=10\n" "id=100 window (0, 0)-(0, 0) child_ids=10\n"
" id=10 genericContainer INVISIBLE (0, 0)-(0, 0) restriction=disabled " " id=10 genericContainer INVISIBLE (0, 0)-(0, 0) restriction=disabled "
"modal=true child_ids=1\n" "modal=true child_ids=1\n"
" id=1 ignored INVISIBLE (0, 0)-(0, 0) restriction=disabled " " id=1 genericContainer IGNORED INVISIBLE (0, 0)-(0, 0) "
"child_ids=2\n" "restriction=disabled child_ids=2\n"
" id=2 ignored INVISIBLE (0, 0)-(0, 0) restriction=disabled " " id=2 genericContainer IGNORED INVISIBLE (0, 0)-(0, 0) "
"child_ids=3\n" "restriction=disabled child_ids=3\n"
" id=3 genericContainer INVISIBLE (0, 0)-(0, 0) " " id=3 genericContainer INVISIBLE (0, 0)-(0, 0) "
"restriction=disabled name=some text \n"); "restriction=disabled name=some text \n");
EXPECT_EQ(1U, tree()->GetFromId(10)->GetUnignoredChildCount()); EXPECT_EQ(1U, tree()->GetFromId(10)->GetUnignoredChildCount());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment