Commit 2ebb503a authored by Abigail Klein's avatar Abigail Klein Committed by Chromium LUCI CQ

[Mac A11y] Set the bookmarks buttons to have a role description and

expose role description in AXPlatformNodeMac.

This ensures that screen reader users have context about what type of
button they are focused on when their focus moves to a bookmarks
button. This is particularly important when screen reader users move
by accessible pane to the bookmarks bar.

This CL also removes the message name IDS_ACCNAME_BOOKMARKS_MENU which
was no longer being used.

description of UI elements.

Bug: 1097760
Change-Id: If8d567bc349d21138fac83b19958aaf340803b09
AX-Relnotes: Give bookmarks buttons a role description and expose role
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2605467Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Abigail Klein <abigailbklein@google.com>
Cr-Commit-Position: refs/heads/master@{#840207}
parent 15778162
...@@ -5867,9 +5867,11 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -5867,9 +5867,11 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_ACCNAME_BOOKMARKS_CHEVRON" desc="The accessible name for the chevron visible if not all the bookmark buttons fit."> <message name="IDS_ACCNAME_BOOKMARKS_CHEVRON" desc="The accessible name for the chevron visible if not all the bookmark buttons fit.">
Menu containing hidden bookmarks Menu containing hidden bookmarks
</message> </message>
<message name="IDS_ACCNAME_BOOKMARKS_MENU" desc="The accessible name for <message name="IDS_ACCNAME_BOOKMARK_BUTTON_ROLE_DESCRIPTION" desc="The accessible role description for bookmark buttons.">
the Bookmarks menu."> Bookmark button
Bookmarks menu </message>
<message name="IDS_ACCNAME_BOOKMARK_FOLDER_BUTTON_ROLE_DESCRIPTION" desc="The accessible role description for bookmark folders.">
Bookmark folder button
</message> </message>
<message name="IDS_ACCNAME_SEPARATOR" desc="The accessible name for a separator."> <message name="IDS_ACCNAME_SEPARATOR" desc="The accessible name for a separator.">
Separator Separator
......
780b32fd1ebbddc89a5510c18d33df92c06f782c
\ No newline at end of file
1f36bbc7f01bb4dc34731b29d71434030c557c84
\ No newline at end of file
...@@ -201,6 +201,13 @@ class BookmarkButtonBase : public views::LabelButton { ...@@ -201,6 +201,13 @@ class BookmarkButtonBase : public views::LabelButton {
return CreateBookmarkButtonBorder(); return CreateBookmarkButtonBorder();
} }
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
views::LabelButton::GetAccessibleNodeData(node_data);
node_data->AddStringAttribute(
ax::mojom::StringAttribute::kRoleDescription,
l10n_util::GetStringUTF8(IDS_ACCNAME_BOOKMARK_BUTTON_ROLE_DESCRIPTION));
}
private: private:
std::unique_ptr<gfx::SlideAnimation> show_animation_; std::unique_ptr<gfx::SlideAnimation> show_animation_;
...@@ -356,6 +363,14 @@ class BookmarkFolderButton : public BookmarkMenuButtonBase { ...@@ -356,6 +363,14 @@ class BookmarkFolderButton : public BookmarkMenuButtonBase {
return BookmarkMenuButtonBase::OnMousePressed(event); return BookmarkMenuButtonBase::OnMousePressed(event);
} }
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
BookmarkMenuButtonBase::GetAccessibleNodeData(node_data);
node_data->AddStringAttribute(
ax::mojom::StringAttribute::kRoleDescription,
l10n_util::GetStringUTF8(
IDS_ACCNAME_BOOKMARK_FOLDER_BUTTON_ROLE_DESCRIPTION));
}
private: private:
std::unique_ptr<gfx::SlideAnimation> show_animation_; std::unique_ptr<gfx::SlideAnimation> show_animation_;
......
...@@ -702,6 +702,10 @@ bool IsAXSetter(SEL selector) { ...@@ -702,6 +702,10 @@ bool IsAXSetter(SEL selector) {
} }
- (NSString*)AXRoleDescription { - (NSString*)AXRoleDescription {
if (_node->HasStringAttribute(ax::mojom::StringAttribute::kRoleDescription)) {
return [base::SysUTF8ToNSString(_node->GetStringAttribute(
ax::mojom::StringAttribute::kRoleDescription)) lowercaseString];
}
switch (_node->GetData().role) { switch (_node->GetData().role) {
case ax::mojom::Role::kTab: case ax::mojom::Role::kTab:
// There is no NSAccessibilityTabRole or similar (AXRadioButton is used // There is no NSAccessibilityTabRole or similar (AXRadioButton is used
...@@ -1011,6 +1015,10 @@ bool IsAXSetter(SEL selector) { ...@@ -1011,6 +1015,10 @@ bool IsAXSetter(SEL selector) {
return [self AXSubrole]; return [self AXSubrole];
} }
- (NSString*)accessibilityRoleDescription {
return [self AXRoleDescription];
}
- (BOOL)isAccessibilitySelectorAllowed:(SEL)selector { - (BOOL)isAccessibilitySelectorAllowed:(SEL)selector {
if (!_node) if (!_node)
return NO; return NO;
......
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