Commit 50804eb1 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Added an accessibility role of titlebar to labels that are used as window titles

Makes our implementation more similar to native dialogs on Windows, like the Run dialog.

R=dmazzoni@chromium.org, sadrul@chromium.org

Bug: 779297
Change-Id: Idde84c1664f4cc7af43b6470825ff4cdc3ddd475
Tested: Using Inspect tool from the Windows SDK
Reviewed-on: https://chromium-review.googlesource.com/902842Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536715}
parent 08ab7e46
......@@ -143,6 +143,7 @@ RoleMap BuildRoleMap() {
{ax::mojom::Role::kTextFieldWithComboBox, NSAccessibilityComboBoxRole},
{ax::mojom::Role::kTime, NSAccessibilityGroupRole},
{ax::mojom::Role::kTimer, NSAccessibilityGroupRole},
{ax::mojom::Role::kTitleBar, NSAccessibilityStaticTextRole},
{ax::mojom::Role::kToggleButton, NSAccessibilityCheckBoxRole},
{ax::mojom::Role::kToolbar, NSAccessibilityToolbarRole},
{ax::mojom::Role::kTooltip, NSAccessibilityGroupRole},
......@@ -885,6 +886,7 @@ bool IsNameExposedInAXValueForRole(ax::mojom::Role role) {
case ax::mojom::Role::kListMarker:
case ax::mojom::Role::kMenuListOption:
case ax::mojom::Role::kStaticText:
case ax::mojom::Role::kTitleBar:
return true;
default:
return false;
......
......@@ -2689,6 +2689,9 @@ int AXPlatformNodeWin::MSAARole() {
case ax::mojom::Role::kTerm:
return ROLE_SYSTEM_LISTITEM;
case ax::mojom::Role::kTitleBar:
return ROLE_SYSTEM_TITLEBAR;
case ax::mojom::Role::kToggleButton:
return ROLE_SYSTEM_PUSHBUTTON;
......@@ -2755,7 +2758,6 @@ int AXPlatformNodeWin::MSAARole() {
case ax::mojom::Role::kPresentational:
case ax::mojom::Role::kSliderThumb:
case ax::mojom::Role::kSwitch:
case ax::mojom::Role::kTitleBar:
case ax::mojom::Role::kUnknown:
case ax::mojom::Role::kWebView:
return ROLE_SYSTEM_CLIENT;
......
......@@ -406,7 +406,11 @@ WordLookupClient* Label::GetWordLookupClient() {
}
void Label::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kStaticText;
if (text_context_ == style::CONTEXT_DIALOG_TITLE)
node_data->role = ax::mojom::Role::kTitleBar;
else
node_data->role = ax::mojom::Role::kStaticText;
node_data->SetName(full_text_->GetDisplayText());
}
......
......@@ -871,6 +871,21 @@ TEST_F(NativeWidgetMacAccessibilityTest, Label) {
// TODO(tapted): Add a test for multiline Labels (currently not supported).
}
// Labels used as title bars should be exposed as normal static text on Mac.
TEST_F(NativeWidgetMacAccessibilityTest, LabelUsedAsTitleBar) {
Label* label = new Label(base::SysNSStringToUTF16(kTestStringValue),
style::CONTEXT_DIALOG_TITLE, style::STYLE_PRIMARY);
label->SetSize(GetWidgetBounds().size());
widget()->GetContentsView()->AddChildView(label);
// Get the Label's accessibility object.
id ax_node = A11yElementAtMidpoint();
EXPECT_TRUE(ax_node);
EXPECT_NSEQ(NSAccessibilityStaticTextRole, AXRoleString());
EXPECT_NSEQ(kTestStringValue, AXValue());
}
class TestComboboxModel : public ui::ComboboxModel {
public:
TestComboboxModel() = default;
......
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