Skip to content

Commit

Permalink
[uia] Fixed bug where ValuePattern was exposed on all gridcells
Browse files Browse the repository at this point in the history
This CL fixes unwanted behavior, where the UIA_ValuePattern was being
exposed on every single gridcell element.

According to
https://learn.microsoft.com/en-us/dotnet/framework/ui-automation/control-pattern-mapping-for-ui-automation-clients
where a gridcell maps to a Data Item control type, ValuePattern is only
supported conditionally.

We have made it so ValuePattern is only exposed on gridcells when they
are editable.

Change-Id: I9bd2ce09d1fcf5fd9b07848b9438a1db26904945
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4303907
Commit-Queue: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Reviewed-by: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Commit-Queue: Javier Contreras <javiercon@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1113675}
  • Loading branch information
Javier Contreras Tenorio authored and Chromium LUCI CQ committed Mar 7, 2023
1 parent b92f20e commit 9841a43
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ bool IsValuePatternSupported(AXPlatformNodeDelegate* delegate) {

// https://www.w3.org/TR/html-aam-1.0/
// The HTML AAM maps "href [a; area]" to UIA Value.Value
if (delegate->IsCellOrHeaderOfAriaGrid() &&
!delegate->HasState(ax::mojom::State::kEditable)) {
return false;
}
return delegate->GetData().IsRangeValueSupported() ||
delegate->IsReadOnlySupported() || IsLink(delegate->GetRole()) ||
delegate->GetRole() == ax::mojom::Role::kColorWell ||
Expand Down
90 changes: 81 additions & 9 deletions ui/accessibility/platform/ax_platform_node_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6517,24 +6517,24 @@ TEST_F(AXPlatformNodeWinTest, GetPatternProviderSupportedPatterns) {
UIA_TablePatternId, UIA_TextChildPatternId}),
GetSupportedPatternsFromNodeId(grid_without_header_id));

EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
UIA_GridItemPatternId, UIA_TableItemPatternId,
UIA_TextChildPatternId, UIA_SelectionItemPatternId}),
EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridItemPatternId,
UIA_TableItemPatternId, UIA_TextChildPatternId,
UIA_SelectionItemPatternId}),
GetSupportedPatternsFromNodeId(grid_without_header_cell_id));

EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
UIA_SelectionPatternId, UIA_GridPatternId,
UIA_TablePatternId, UIA_TextChildPatternId}),
GetSupportedPatternsFromNodeId(grid_with_header_id));

EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
UIA_GridItemPatternId, UIA_TableItemPatternId,
UIA_TextChildPatternId, UIA_SelectionItemPatternId}),
EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridItemPatternId,
UIA_TableItemPatternId, UIA_TextChildPatternId,
UIA_SelectionItemPatternId}),
GetSupportedPatternsFromNodeId(grid_with_header_column_header_id));

EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
UIA_GridItemPatternId, UIA_TableItemPatternId,
UIA_TextChildPatternId, UIA_SelectionItemPatternId}),
EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridItemPatternId,
UIA_TableItemPatternId, UIA_TextChildPatternId,
UIA_SelectionItemPatternId}),
GetSupportedPatternsFromNodeId(grid_with_header_cell_id));

EXPECT_EQ(PatternSet({UIA_ValuePatternId, UIA_ScrollItemPatternId,
Expand Down Expand Up @@ -6741,6 +6741,78 @@ TEST_F(AXPlatformNodeWinTest, GetPatternProviderInvokePattern) {
EXPECT_EQ(nullptr, invoke_provider.Get());
}

TEST_F(AXPlatformNodeWinTest, GetPatternProviderGridCellValuePattern) {
// ++1 kRootWebArea
// ++++2 kGrid
// ++++++3 kRow
// ++++++++4 kCell
// +++++++++++5 kStaticText
// ++++++++6 kCell
// +++++++++++7 kStaticText
// ++++++++8 kCell
// +++++++++++9 kStaticText

AXNodeData root_1;
AXNodeData table_2;
AXNodeData row_3;
AXNodeData cell_4;
AXNodeData st_5;
AXNodeData cell_6;
AXNodeData st_7;
AXNodeData cell_8;
AXNodeData st_9;

root_1.id = 1;
table_2.id = 2;
row_3.id = 3;
cell_4.id = 4;
st_5.id = 5;
cell_6.id = 6;
st_7.id = 7;
cell_8.id = 8;
st_9.id = 9;

root_1.role = ax::mojom::Role::kRootWebArea;
root_1.child_ids = {table_2.id};

table_2.role = ax::mojom::Role::kGrid;
table_2.child_ids = {row_3.id};

row_3.role = ax::mojom::Role::kRow;
row_3.child_ids = {cell_4.id, cell_6.id, cell_8.id};

cell_4.role = ax::mojom::Role::kCell;
cell_4.AddState(ax::mojom::State::kEditable);
cell_4.child_ids = {st_5.id};

cell_6.role = ax::mojom::Role::kCell;
cell_6.AddState(ax::mojom::State::kEditable);
cell_6.AddState(ax::mojom::State::kRichlyEditable);
cell_6.AddIntAttribute(ax::mojom::IntAttribute::kRestriction,
static_cast<int>(ax::mojom::Restriction::kReadOnly));
cell_6.child_ids = {st_7.id};

cell_8.role = ax::mojom::Role::kCell;
cell_8.child_ids = {st_9.id};

Init(root_1, table_2, row_3, cell_4, st_5, cell_6, st_7, cell_8, st_9);

AXPlatformNodeWinTest::PatternSet cell_4_patterns =
GetSupportedPatternsFromNodeId(cell_4.id);
AXPlatformNodeWinTest::PatternSet cell_6_patterns =
GetSupportedPatternsFromNodeId(cell_6.id);
AXPlatformNodeWinTest::PatternSet cell_8_patterns =
GetSupportedPatternsFromNodeId(cell_8.id);

// Since the first two gridcell nodes are editable, we should find the
// ValuePattern exposed in those cells.
EXPECT_NE(cell_4_patterns.find(UIA_ValuePatternId), cell_4_patterns.end());
EXPECT_NE(cell_6_patterns.find(UIA_ValuePatternId), cell_6_patterns.end());
// Since the last gridcell node is not editable, we should not find
// ValuePattern exposed for it.
EXPECT_EQ(cell_8_patterns.find(UIA_ValuePatternId), cell_8_patterns.end());
}

TEST_F(AXPlatformNodeWinTest, IExpandCollapsePatternProviderAction) {
ui::AXNodeData root;
root.id = 1;
Expand Down

0 comments on commit 9841a43

Please sign in to comment.