Commit 7d0ec4d5 authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

[omnibox] Make AX announcement when section headers are hidden/shown

When the section headers are hidden or shown by a user, currently,
screen readers give no indication that anything has changed.

This CL fixes that and adds two new explicit announcements:
 - "Related to recent searches" section shown
 - "Related to recent searches" section hidden

They are announced when the user shows or hides a section.

It also fixes a bug in OmniboxPopupContentsView that caused some weird
reentrant-like behavior, where updating the popup bounds would cause it
to call UpdatePopupAppearance again.

This bug suppressed the announcements, so this is needed too.

Bug: 1099790
Change-Id: I96d847bc304d91a37ac306e2d9a27438d68856e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2291234Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790566}
parent 7f710dc5
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include <numeric> #include <numeric>
#include "base/auto_reset.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/optional.h" #include "base/optional.h"
...@@ -62,7 +63,10 @@ class OmniboxPopupContentsView::AutocompletePopupWidget ...@@ -62,7 +63,10 @@ class OmniboxPopupContentsView::AutocompletePopupWidget
new RoundedOmniboxResultsFrame(contents, contents->location_bar_view_)); new RoundedOmniboxResultsFrame(contents, contents->location_bar_view_));
} }
void SetTargetBounds(const gfx::Rect& bounds) { SetBounds(bounds); } void SetTargetBounds(const gfx::Rect& bounds) {
base::AutoReset<bool> reset(&is_setting_popup_bounds_, true);
SetBounds(bounds);
}
void ShowAnimated() { void ShowAnimated() {
// Set the initial opacity to 0 and ease into fully opaque. // Set the initial opacity to 0 and ease into fully opaque.
...@@ -116,6 +120,8 @@ class OmniboxPopupContentsView::AutocompletePopupWidget ...@@ -116,6 +120,8 @@ class OmniboxPopupContentsView::AutocompletePopupWidget
ThemeCopyingWidget::OnGestureEvent(event); ThemeCopyingWidget::OnGestureEvent(event);
} }
bool is_setting_popup_bounds() const { return is_setting_popup_bounds_; }
private: private:
std::unique_ptr<ui::ScopedLayerAnimationSettings> std::unique_ptr<ui::ScopedLayerAnimationSettings>
GetScopedAnimationSettings() { GetScopedAnimationSettings() {
...@@ -134,6 +140,9 @@ class OmniboxPopupContentsView::AutocompletePopupWidget ...@@ -134,6 +140,9 @@ class OmniboxPopupContentsView::AutocompletePopupWidget
// True if the popup is in the process of closing via animation. // True if the popup is in the process of closing via animation.
bool is_animating_closed_ = false; bool is_animating_closed_ = false;
// True if the popup's bounds are currently being set.
bool is_setting_popup_bounds_ = false;
DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget);
}; };
...@@ -465,9 +474,15 @@ void OmniboxPopupContentsView::FireAXEventsForNewActiveDescendant( ...@@ -465,9 +474,15 @@ void OmniboxPopupContentsView::FireAXEventsForNewActiveDescendant(
void OmniboxPopupContentsView::OnWidgetBoundsChanged( void OmniboxPopupContentsView::OnWidgetBoundsChanged(
views::Widget* widget, views::Widget* widget,
const gfx::Rect& new_bounds) { const gfx::Rect& new_bounds) {
DCHECK_EQ(popup_.get(), widget);
DCHECK(popup_);
// This is called on rotation or device scale change. We have to re-align to // This is called on rotation or device scale change. We have to re-align to
// the new location bar location. // the new location bar location.
DCHECK_EQ(popup_.get(), widget);
// Ignore cases when we are internally updating the popup bounds.
if (popup_->is_setting_popup_bounds())
return;
UpdatePopupAppearance(); UpdatePopupAppearance();
} }
......
...@@ -195,9 +195,17 @@ class OmniboxRowView::HeaderView : public views::View, ...@@ -195,9 +195,17 @@ class OmniboxRowView::HeaderView : public views::View,
suggestion_group_hidden_ = omnibox::IsSuggestionGroupIdHidden( suggestion_group_hidden_ = omnibox::IsSuggestionGroupIdHidden(
row_view_->pref_service_, suggestion_group_id_); row_view_->pref_service_, suggestion_group_id_);
if (was_hidden != suggestion_group_hidden_) if (was_hidden != suggestion_group_hidden_) {
NotifyAccessibilityEvent(ax::mojom::Event::kExpandedChanged, true); NotifyAccessibilityEvent(ax::mojom::Event::kExpandedChanged, true);
// Because this view doesn't have true focus (it stays on the textfield),
// we also need to manually announce state changes.
GetViewAccessibility().AnnounceText(l10n_util::GetStringFUTF16(
suggestion_group_hidden_ ? IDS_ACC_HEADER_SECTION_HIDDEN
: IDS_ACC_HEADER_SECTION_SHOWN,
header_text_));
}
header_toggle_button_->SetToggled(suggestion_group_hidden_); header_toggle_button_->SetToggled(suggestion_group_hidden_);
} }
......
...@@ -252,4 +252,11 @@ ...@@ -252,4 +252,11 @@
<message name="IDS_ACC_HEADER_HIDE_SUGGESTIONS_BUTTON" desc="Announcement for the Hide Suggestions button on section headers."> <message name="IDS_ACC_HEADER_HIDE_SUGGESTIONS_BUTTON" desc="Announcement for the Hide Suggestions button on section headers.">
Hide the &quot;<ph name="SECTION">$1<ex>related to recent searches</ex></ph>&quot; section Hide the &quot;<ph name="SECTION">$1<ex>related to recent searches</ex></ph>&quot; section
</message> </message>
<!-- Accessibility announcements made when suggestion sections are shown or hidden. -->
<message name="IDS_ACC_HEADER_SECTION_SHOWN" desc="Announcement that lets the user know the suggestions section has been Shown.">
&quot;<ph name="SECTION">$1<ex>Related to recent searches</ex></ph>&quot; section shown
</message>
<message name="IDS_ACC_HEADER_SECTION_HIDDEN" desc="Announcement that lets the user know the suggestions section has been Hidden.">
&quot;<ph name="SECTION">$1<ex>Related to recent searches</ex></ph>&quot; section hidden
</message>
</grit-part> </grit-part>
a9ab2311d9da9c937ae448002339197fc5a7b8dd
\ No newline at end of file
6ef77e632dced69fe032d1ff85284d9dff628abf
\ No newline at end of file
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