Commit df0c4aea authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

kMenuItem valid child of kMenuListOption for PosInSet/SetSize.

This change allows kMenuItems to be valid children of kMenuListOption
elements for PosInSet and SetSize calculations. The motivating example
for this change was navigating through the app menu in the Chrome
toolbar using ChromeVox(the menu that contains buttons for new tab,
history, downloads, bookmarks, dev tools, etc.). ChromeVox would report
PosInSet and SetSize of 0 for many elements, due to the fact that
the elements are held within a kMenuListOption, not a kMenu. In the
PosInSet and SetSize code, we have checks to ensure valid parent-child
relationships. This is a case that must have been missed in the
initial implementation.

Change-Id: I8ab6182862cb9a4112d525044046a1e15048fc5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757467
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688669}
parent f6e90adc
...@@ -785,7 +785,8 @@ bool AXNode::SetRoleMatchesItemRole(const AXNode* ordered_set) const { ...@@ -785,7 +785,8 @@ bool AXNode::SetRoleMatchesItemRole(const AXNode* ordered_set) const {
case ax::mojom::Role::kListBox: case ax::mojom::Role::kListBox:
return item_role == ax::mojom::Role::kListBoxOption; return item_role == ax::mojom::Role::kListBoxOption;
case ax::mojom::Role::kMenuListPopup: case ax::mojom::Role::kMenuListPopup:
return item_role == ax::mojom::Role::kMenuListOption; return item_role == ax::mojom::Role::kMenuListOption ||
item_role == ax::mojom::Role::kMenuItem;
case ax::mojom::Role::kRadioGroup: case ax::mojom::Role::kRadioGroup:
return item_role == ax::mojom::Role::kRadioButton; return item_role == ax::mojom::Role::kRadioButton;
case ax::mojom::Role::kDescriptionList: case ax::mojom::Role::kDescriptionList:
......
...@@ -3337,6 +3337,29 @@ TEST(AXTreeTest, TestSetSizePosInSetUnkown) { ...@@ -3337,6 +3337,29 @@ TEST(AXTreeTest, TestSetSizePosInSetUnkown) {
EXPECT_OPTIONAL_EQ(2, item2->GetSetSize()); EXPECT_OPTIONAL_EQ(2, item2->GetSetSize());
} }
TEST(AXTreeTest, TestSetSizePosInSetMenuItemValidChildOfMenuListPopup) {
AXTreeUpdate initial_state;
initial_state.root_id = 1;
initial_state.nodes.resize(3);
initial_state.nodes[0].id = 1;
initial_state.nodes[0].child_ids = {2, 3};
initial_state.nodes[0].role = ax::mojom::Role::kMenuListPopup;
initial_state.nodes[1].id = 2;
initial_state.nodes[1].role = ax::mojom::Role::kMenuItem;
initial_state.nodes[2].id = 3;
initial_state.nodes[2].role = ax::mojom::Role::kMenuListOption;
AXTree tree(initial_state);
AXNode* menu = tree.GetFromId(1);
EXPECT_OPTIONAL_EQ(2, menu->GetSetSize());
AXNode* item1 = tree.GetFromId(2);
EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
EXPECT_OPTIONAL_EQ(2, item1->GetSetSize());
AXNode* item2 = tree.GetFromId(3);
EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
EXPECT_OPTIONAL_EQ(2, item2->GetSetSize());
}
TEST(AXTreeTest, OnNodeWillBeDeletedHasValidUnignoredParent) { TEST(AXTreeTest, OnNodeWillBeDeletedHasValidUnignoredParent) {
AXTreeUpdate initial_state; AXTreeUpdate initial_state;
initial_state.root_id = 1; initial_state.root_id = 1;
......
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