Commit f4793783 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fix accessibility issues in message center

- introduce MessageCenterScrollView and use for
MessageCenterView::scroller_. We need this because the |scroller_| is
the one that gets focused when a user invokes Alt+Shift+N.

- remove accessibility bits from MessageCenterView including accessible
data and focusability.

Test: with ChromeVox, press Alt+Shift+N and tab around. Verify that the
scroller gets focused and outputs correctly when first entering message
center and that tabbing never reaches the MessageCenterView, but only
reaches the scroller_. Previously, both were tab stops.

Bug: 
Change-Id: I1c8b06f157bbb4749f61cdd6a4f80c5693d76f48
Reviewed-on: https://chromium-review.googlesource.com/801344
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521130}
parent cd47059e
...@@ -108,6 +108,22 @@ class EmptyNotificationView : public views::View { ...@@ -108,6 +108,22 @@ class EmptyNotificationView : public views::View {
DISALLOW_COPY_AND_ASSIGN(EmptyNotificationView); DISALLOW_COPY_AND_ASSIGN(EmptyNotificationView);
}; };
class MessageCenterScrollView : public views::ScrollView {
public:
explicit MessageCenterScrollView(MessageCenterView* owner) : owner_(owner) {}
private:
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->role = ui::AX_ROLE_DIALOG;
node_data->SetName(owner_->GetButtonBarTitle());
}
MessageCenterView* owner_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterScrollView);
};
} // namespace } // namespace
// MessageCenterView /////////////////////////////////////////////////////////// // MessageCenterView ///////////////////////////////////////////////////////////
...@@ -129,7 +145,7 @@ MessageCenterView::MessageCenterView( ...@@ -129,7 +145,7 @@ MessageCenterView::MessageCenterView(
message_center_->AddObserver(this); message_center_->AddObserver(this);
set_notify_enter_exit_on_child(true); set_notify_enter_exit_on_child(true);
SetBackground(views::CreateSolidBackground(kBackgroundColor)); SetBackground(views::CreateSolidBackground(kBackgroundColor));
SetFocusBehavior(views::View::FocusBehavior::ALWAYS); SetFocusBehavior(views::View::FocusBehavior::NEVER);
button_bar_ = new MessageCenterButtonBar( button_bar_ = new MessageCenterButtonBar(
this, message_center, initially_settings_visible, GetButtonBarTitle()); this, message_center, initially_settings_visible, GetButtonBarTitle());
...@@ -137,7 +153,7 @@ MessageCenterView::MessageCenterView( ...@@ -137,7 +153,7 @@ MessageCenterView::MessageCenterView(
const int button_height = button_bar_->GetPreferredSize().height(); const int button_height = button_bar_->GetPreferredSize().height();
scroller_ = new views::ScrollView(); scroller_ = new MessageCenterScrollView(this);
scroller_->SetBackgroundColor(kBackgroundColor); scroller_->SetBackgroundColor(kBackgroundColor);
scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height); scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height);
scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false));
...@@ -266,6 +282,12 @@ void MessageCenterView::SetIsClosing(bool is_closing) { ...@@ -266,6 +282,12 @@ void MessageCenterView::SetIsClosing(bool is_closing) {
message_center_->AddObserver(this); message_center_->AddObserver(this);
} }
base::string16 MessageCenterView::GetButtonBarTitle() const {
return is_locked_ ?
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_LOCKSCREEN) :
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_TITLE);
}
void MessageCenterView::OnDidChangeFocus(views::View* before, void MessageCenterView::OnDidChangeFocus(views::View* before,
views::View* now) { views::View* now) {
// Update the button visibility when the focus state is changed. // Update the button visibility when the focus state is changed.
...@@ -356,11 +378,6 @@ void MessageCenterView::OnMouseExited(const ui::MouseEvent& event) { ...@@ -356,11 +378,6 @@ void MessageCenterView::OnMouseExited(const ui::MouseEvent& event) {
Update(true /* animate */); Update(true /* animate */);
} }
void MessageCenterView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ui::AX_ROLE_DIALOG;
node_data->SetName(GetButtonBarTitle());
}
void MessageCenterView::OnNotificationAdded(const std::string& id) { void MessageCenterView::OnNotificationAdded(const std::string& id) {
int index = 0; int index = 0;
const NotificationList::Notifications& notifications = const NotificationList::Notifications& notifications =
...@@ -543,13 +560,6 @@ void MessageCenterView::AddNotificationAt(const Notification& notification, ...@@ -543,13 +560,6 @@ void MessageCenterView::AddNotificationAt(const Notification& notification,
message_list_view_->AddNotificationAt(view, index); message_list_view_->AddNotificationAt(view, index);
} }
base::string16 MessageCenterView::GetButtonBarTitle() const {
if (is_locked_)
return l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_LOCKSCREEN);
return l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_TITLE);
}
void MessageCenterView::Update(bool animate) { void MessageCenterView::Update(bool animate) {
bool no_message_views = (message_list_view_->GetNotificationCount() == 0); bool no_message_views = (message_list_view_->GetNotificationCount() == 0);
......
...@@ -71,6 +71,8 @@ class ASH_EXPORT MessageCenterView ...@@ -71,6 +71,8 @@ class ASH_EXPORT MessageCenterView
void SetIsClosing(bool is_closing); void SetIsClosing(bool is_closing);
base::string16 GetButtonBarTitle() const;
// Overridden from views::FocusChangeListener // Overridden from views::FocusChangeListener
void OnWillChangeFocus(views::View* before, views::View* now) override {} void OnWillChangeFocus(views::View* before, views::View* now) override {}
void OnDidChangeFocus(views::View* before, views::View* now) override; void OnDidChangeFocus(views::View* before, views::View* now) override;
...@@ -82,7 +84,7 @@ class ASH_EXPORT MessageCenterView ...@@ -82,7 +84,7 @@ class ASH_EXPORT MessageCenterView
protected: protected:
// Potentially sets the reposition target, and then returns whether or not it // Potentially sets the reposition target, and then returns whether or not it
// was was set. // was set.
virtual bool SetRepositionTarget(); virtual bool SetRepositionTarget();
// Overridden from views::View: // Overridden from views::View:
...@@ -91,7 +93,6 @@ class ASH_EXPORT MessageCenterView ...@@ -91,7 +93,6 @@ class ASH_EXPORT MessageCenterView
int GetHeightForWidth(int width) const override; int GetHeightForWidth(int width) const override;
bool OnMouseWheel(const ui::MouseWheelEvent& event) override; bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
void OnMouseExited(const ui::MouseEvent& event) override; void OnMouseExited(const ui::MouseEvent& event) override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// Overridden from MessageCenterObserver: // Overridden from MessageCenterObserver:
void OnNotificationAdded(const std::string& id) override; void OnNotificationAdded(const std::string& id) override;
...@@ -137,7 +138,6 @@ class ASH_EXPORT MessageCenterView ...@@ -137,7 +138,6 @@ class ASH_EXPORT MessageCenterView
void AddNotificationAt(const message_center::Notification& notification, void AddNotificationAt(const message_center::Notification& notification,
int index); int index);
base::string16 GetButtonBarTitle() const;
void Update(bool animate); void Update(bool animate);
void SetVisibilityMode(Mode mode, bool animate); void SetVisibilityMode(Mode mode, bool animate);
void UpdateButtonBarStatus(); void UpdateButtonBarStatus();
......
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