Commit c02b895e authored by Gavin Williams's avatar Gavin Williams Committed by Commit Bot

a11y: Update Shortcuts search box

Stop showing the back button in the search box to remove an unnecessary
tab stop.

Keep the placeholder text left justified and a consistent color with or
without focus.

Video: https://bugs.chromium.org/p/chromium/issues/detail?id=1005166#c27

Fixed: 1005166
Change-Id: Ie6daa2fd659122ca88bda39c2ab2dd36de2acf98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499803
Commit-Queue: Gavin Williams <gavinwill@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821315}
parent 5d9d7c58
...@@ -38,6 +38,10 @@ constexpr int kSearchBoxIconSize = 24; ...@@ -38,6 +38,10 @@ constexpr int kSearchBoxIconSize = 24;
// The size of the image button in the search box. // The size of the image button in the search box.
constexpr int kSearchBoxButtonSizeDip = 40; constexpr int kSearchBoxButtonSizeDip = 40;
// Color of placeholder text in zero query state.
constexpr SkColor kZeroQuerySearchboxColor =
SkColorSetARGB(0x8A, 0x00, 0x00, 0x00);
} // namespace ash } // namespace ash
#endif // ASH_SEARCH_BOX_SEARCH_BOX_CONSTANTS_H_ #endif // ASH_SEARCH_BOX_SEARCH_BOX_CONSTANTS_H_
...@@ -47,10 +47,6 @@ constexpr SkColor kSelectedColor = SkColorSetARGB(15, 0, 0, 0); ...@@ -47,10 +47,6 @@ constexpr SkColor kSelectedColor = SkColorSetARGB(15, 0, 0, 0);
constexpr SkColor kSearchTextColor = SkColorSetRGB(0x33, 0x33, 0x33); constexpr SkColor kSearchTextColor = SkColorSetRGB(0x33, 0x33, 0x33);
// Color of placeholder text in zero query state.
constexpr SkColor kZeroQuerySearchboxColor =
SkColorSetARGB(0x8A, 0x00, 0x00, 0x00);
} // namespace } // namespace
// A background that paints a solid white rounded rect with a thin grey // A background that paints a solid white rounded rect with a thin grey
......
...@@ -336,7 +336,6 @@ void KeyboardShortcutView::BackButtonPressed() { ...@@ -336,7 +336,6 @@ void KeyboardShortcutView::BackButtonPressed() {
void KeyboardShortcutView::ActiveChanged(ash::SearchBoxViewBase* sender) { void KeyboardShortcutView::ActiveChanged(ash::SearchBoxViewBase* sender) {
const bool is_search_box_active = sender->is_search_box_active(); const bool is_search_box_active = sender->is_search_box_active();
is_search_box_empty_ = sender->IsSearchBoxTrimmedQueryEmpty(); is_search_box_empty_ = sender->IsSearchBoxTrimmedQueryEmpty();
sender->ShowBackOrGoogleIcon(is_search_box_active);
if (is_search_box_active) { if (is_search_box_active) {
base::RecordAction( base::RecordAction(
base::UserMetricsAction("KeyboardShortcutViewer.Search")); base::UserMetricsAction("KeyboardShortcutViewer.Search"));
......
...@@ -183,13 +183,14 @@ TEST_F(KeyboardShortcutViewTest, FocusOnSearchBox) { ...@@ -183,13 +183,14 @@ TEST_F(KeyboardShortcutViewTest, FocusOnSearchBox) {
// Press a key should enter search mode. // Press a key should enter search mode.
KeyPress(ui::VKEY_A, /*should_insert=*/true); KeyPress(ui::VKEY_A, /*should_insert=*/true);
EXPECT_TRUE(GetSearchBoxView()->back_button()->GetVisible()); EXPECT_FALSE(GetSearchBoxView()->back_button()->GetVisible());
EXPECT_TRUE(GetSearchBoxView()->close_button()->GetVisible());
EXPECT_FALSE(GetSearchBoxView()->search_box()->GetText().empty()); EXPECT_FALSE(GetSearchBoxView()->search_box()->GetText().empty());
// Case 2: Exit search mode by clicking |back_button|. The focus should be on // Case 2: Exit search mode by clicking |close_button|. The focus should be on
// search box. // search box.
GetSearchBoxView()->ButtonPressed( GetSearchBoxView()->ButtonPressed(
GetSearchBoxView()->back_button(), GetSearchBoxView()->close_button(),
ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON)); ui::EF_LEFT_MOUSE_BUTTON));
......
...@@ -36,8 +36,7 @@ KSVSearchBoxView::KSVSearchBoxView(ash::SearchBoxViewDelegate* delegate) ...@@ -36,8 +36,7 @@ KSVSearchBoxView::KSVSearchBoxView(ash::SearchBoxViewDelegate* delegate)
UpdateBackgroundColor(kDefaultSearchBoxBackgroundColor); UpdateBackgroundColor(kDefaultSearchBoxBackgroundColor);
search_box()->SetBackgroundColor(SK_ColorTRANSPARENT); search_box()->SetBackgroundColor(SK_ColorTRANSPARENT);
search_box()->SetColor(gfx::kGoogleGrey900); search_box()->SetColor(gfx::kGoogleGrey900);
search_box()->set_placeholder_text_color(gfx::kGoogleGrey900); SetPlaceholderTextAttributes();
search_box()->set_placeholder_text_draw_flags(gfx::Canvas::TEXT_ALIGN_CENTER);
const base::string16 search_box_name( const base::string16 search_box_name(
l10n_util::GetStringUTF16(IDS_KSV_SEARCH_BOX_ACCESSIBILITY_NAME)); l10n_util::GetStringUTF16(IDS_KSV_SEARCH_BOX_ACCESSIBILITY_NAME));
search_box()->SetPlaceholderText(search_box_name); search_box()->SetPlaceholderText(search_box_name);
...@@ -139,4 +138,17 @@ void KSVSearchBoxView::SetupBackButton() { ...@@ -139,4 +138,17 @@ void KSVSearchBoxView::SetupBackButton() {
back->SetVisible(false); back->SetVisible(false);
} }
void KSVSearchBoxView::OnSearchBoxActiveChanged(bool active) {
// Update to override default placeholder attributes set by base class when
// the search box is no longer active.
SetPlaceholderTextAttributes();
}
void KSVSearchBoxView::SetPlaceholderTextAttributes() {
search_box()->set_placeholder_text_color(ash::kZeroQuerySearchboxColor);
search_box()->set_placeholder_text_draw_flags(
base::i18n::IsRTL() ? gfx::Canvas::TEXT_ALIGN_RIGHT
: gfx::Canvas::TEXT_ALIGN_LEFT);
}
} // namespace keyboard_shortcut_viewer } // namespace keyboard_shortcut_viewer
...@@ -31,12 +31,16 @@ class KSVSearchBoxView : public ash::SearchBoxViewBase { ...@@ -31,12 +31,16 @@ class KSVSearchBoxView : public ash::SearchBoxViewBase {
void SetAccessibleValue(const base::string16& value); void SetAccessibleValue(const base::string16& value);
// SearchBoxViewBase:
void OnSearchBoxActiveChanged(bool active) override;
private: private:
// SearchBoxViewBase: // SearchBoxViewBase:
void UpdateBackgroundColor(SkColor color) override; void UpdateBackgroundColor(SkColor color) override;
void UpdateSearchBoxBorder() override; void UpdateSearchBoxBorder() override;
void SetupCloseButton() override; void SetupCloseButton() override;
void SetupBackButton() override; void SetupBackButton() override;
void SetPlaceholderTextAttributes();
// Accessibility data value. Used to pronounce the number of search results. // Accessibility data value. Used to pronounce the number of search results.
base::string16 accessible_value_; base::string16 accessible_value_;
......
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