Commit ab3f818a authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

[omnibox] Add more explanatory AX names for the section toggle button

Currently the section toggle buttons just announce the tooltips, which
are a succinct "Show Suggestions" or "Hide Suggestions".

This CL makes the announcement a more explanatory:
"Show the 'Related to recent searches' section"

Bug: 1099788
Change-Id: I7a8e982ab9bf1b62d8e5f5200174ff2ebb19488a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2295929
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788762}
parent c7c59357
...@@ -39,15 +39,15 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -39,15 +39,15 @@ class OmniboxRowView::HeaderView : public views::View,
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal)); views::BoxLayout::Orientation::kHorizontal));
header_text_ = AddChildView(std::make_unique<views::Label>()); header_label_ = AddChildView(std::make_unique<views::Label>());
header_text_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT); header_label_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
layout->SetFlexForView(header_text_, 1); layout->SetFlexForView(header_label_, 1);
const gfx::FontList& font = const gfx::FontList& font =
views::style::GetFont(CONTEXT_OMNIBOX_PRIMARY, views::style::GetFont(CONTEXT_OMNIBOX_PRIMARY,
views::style::STYLE_PRIMARY) views::style::STYLE_PRIMARY)
.DeriveWithWeight(gfx::Font::Weight::MEDIUM); .DeriveWithWeight(gfx::Font::Weight::MEDIUM);
header_text_->SetFontList(font); header_label_->SetFontList(font);
header_toggle_button_ = header_toggle_button_ =
AddChildView(views::CreateVectorToggleImageButton(this)); AddChildView(views::CreateVectorToggleImageButton(this));
...@@ -74,11 +74,12 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -74,11 +74,12 @@ class OmniboxRowView::HeaderView : public views::View,
void SetHeader(int suggestion_group_id, const base::string16& header_text) { void SetHeader(int suggestion_group_id, const base::string16& header_text) {
suggestion_group_id_ = suggestion_group_id; suggestion_group_id_ = suggestion_group_id;
header_text_ = header_text;
// TODO(tommycli): Our current design calls for uppercase text here, but // TODO(tommycli): Our current design calls for uppercase text here, but
// it seems like an open question what should happen for non-Latin locales. // it seems like an open question what should happen for non-Latin locales.
// Moreover, it seems unusual to do case conversion in Views in general. // Moreover, it seems unusual to do case conversion in Views in general.
header_text_->SetText(base::i18n::ToUpper(header_text)); header_label_->SetText(base::i18n::ToUpper(header_text_));
if (row_view_->pref_service_) { if (row_view_->pref_service_) {
suggestion_group_hidden_ = omnibox::IsSuggestionGroupIdHidden( suggestion_group_hidden_ = omnibox::IsSuggestionGroupIdHidden(
...@@ -146,7 +147,7 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -146,7 +147,7 @@ class OmniboxRowView::HeaderView : public views::View,
SkColor text_color = GetOmniboxColor( SkColor text_color = GetOmniboxColor(
GetThemeProvider(), OmniboxPart::RESULTS_TEXT_DIMMED, part_state); GetThemeProvider(), OmniboxPart::RESULTS_TEXT_DIMMED, part_state);
header_text_->SetEnabledColor(text_color); header_label_->SetEnabledColor(text_color);
SkColor icon_color = GetOmniboxColor(GetThemeProvider(), SkColor icon_color = GetOmniboxColor(GetThemeProvider(),
OmniboxPart::RESULTS_ICON, part_state); OmniboxPart::RESULTS_ICON, part_state);
...@@ -164,6 +165,8 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -164,6 +165,8 @@ class OmniboxRowView::HeaderView : public views::View,
header_toggle_button_->SetImage(views::Button::STATE_NORMAL, arrow_up); header_toggle_button_->SetImage(views::Button::STATE_NORMAL, arrow_up);
header_toggle_button_->SetTooltipText( header_toggle_button_->SetTooltipText(
l10n_util::GetStringUTF16(IDS_TOOLTIP_HEADER_HIDE_SUGGESTIONS_BUTTON)); l10n_util::GetStringUTF16(IDS_TOOLTIP_HEADER_HIDE_SUGGESTIONS_BUTTON));
header_toggle_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ACC_HEADER_HIDE_SUGGESTIONS_BUTTON, header_text_));
// The "toggled" button state corresponds with the group being hidden. // The "toggled" button state corresponds with the group being hidden.
// The button's action is therefore to Show the group, when clicked. // The button's action is therefore to Show the group, when clicked.
...@@ -171,6 +174,9 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -171,6 +174,9 @@ class OmniboxRowView::HeaderView : public views::View,
&arrow_down); &arrow_down);
header_toggle_button_->SetToggledTooltipText( header_toggle_button_->SetToggledTooltipText(
l10n_util::GetStringUTF16(IDS_TOOLTIP_HEADER_SHOW_SUGGESTIONS_BUTTON)); l10n_util::GetStringUTF16(IDS_TOOLTIP_HEADER_SHOW_SUGGESTIONS_BUTTON));
header_toggle_button_->SetToggledAccessibleName(l10n_util::GetStringFUTF16(
IDS_ACC_HEADER_SHOW_SUGGESTIONS_BUTTON, header_text_));
header_toggle_button_focus_ring_->SchedulePaint(); header_toggle_button_focus_ring_->SchedulePaint();
// It's a little hokey that we're stealing the logic for the background // It's a little hokey that we're stealing the logic for the background
...@@ -200,7 +206,7 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -200,7 +206,7 @@ class OmniboxRowView::HeaderView : public views::View,
OmniboxRowView* const row_view_; OmniboxRowView* const row_view_;
// The Label containing the header text. This is never nullptr. // The Label containing the header text. This is never nullptr.
views::Label* header_text_; views::Label* header_label_;
// The button used to toggle hiding suggestions with this header. // The button used to toggle hiding suggestions with this header.
views::ToggleImageButton* header_toggle_button_; views::ToggleImageButton* header_toggle_button_;
...@@ -209,6 +215,9 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -209,6 +215,9 @@ class OmniboxRowView::HeaderView : public views::View,
// The group ID associated with this header. // The group ID associated with this header.
int suggestion_group_id_ = 0; int suggestion_group_id_ = 0;
// The unmodified header text for this header.
base::string16 header_text_;
// Stores whether or not the group was hidden. This is used to fire correct // Stores whether or not the group was hidden. This is used to fire correct
// accessibility change events. // accessibility change events.
bool suggestion_group_hidden_ = false; bool suggestion_group_hidden_ = false;
......
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