Commit 1c05300e authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Fix focus traversal for collapsed message center

Bug: 1022559
Change-Id: Ib13a8d519b4d2d09f4411d5a729ef66d17f0cab6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1904620Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715124}
parent 923b1cc5
......@@ -33,8 +33,10 @@ namespace {
class StackingBarLabelButton : public views::LabelButton {
public:
StackingBarLabelButton(views::ButtonListener* listener,
const base::string16& text)
: views::LabelButton(listener, text) {
const base::string16& text,
UnifiedMessageCenterView* message_center_view)
: views::LabelButton(listener, text),
message_center_view_(message_center_view) {
SetEnabledTextColors(kUnifiedMenuButtonColorActive);
SetHorizontalAlignment(gfx::ALIGN_CENTER);
SetBorder(views::CreateEmptyBorder(gfx::Insets()));
......@@ -51,6 +53,11 @@ class StackingBarLabelButton : public views::LabelButton {
~StackingBarLabelButton() override = default;
// views::LabelButton:
void AboutToRequestFocusFromTabTraversal(bool reverse) override {
if (message_center_view_->collapsed() && HasFocus())
message_center_view_->FocusOut(reverse);
}
gfx::Size CalculatePreferredSize() const override {
return gfx::Size(label()->GetPreferredSize().width() +
kStackingNotificationClearAllButtonPadding.width(),
......@@ -58,9 +65,7 @@ class StackingBarLabelButton : public views::LabelButton {
kStackingNotificationClearAllButtonPadding.height());
}
const char* GetClassName() const override {
return "StackingBarClearAllButton";
}
const char* GetClassName() const override { return "StackingBarLabelButton"; }
int GetHeightForWidth(int width) const override {
return label()->GetPreferredSize().height() +
......@@ -108,7 +113,7 @@ class StackingBarLabelButton : public views::LabelButton {
private:
SkColor background_color_ = gfx::kPlaceholderColor;
UnifiedMessageCenterView* message_center_view_;
DISALLOW_COPY_AND_ASSIGN(StackingBarLabelButton);
};
......@@ -132,11 +137,13 @@ StackedNotificationBar::StackedNotificationBar(
clear_all_button_(new StackingBarLabelButton(
this,
l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_CLEAR_ALL_BUTTON_LABEL))),
IDS_ASH_MESSAGE_CENTER_CLEAR_ALL_BUTTON_LABEL),
message_center_view)),
expand_all_button_(new StackingBarLabelButton(
this,
l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_EXPAND_ALL_NOTIFICATIONS_BUTTON_LABEL))) {
IDS_ASH_MESSAGE_CENTER_EXPAND_ALL_NOTIFICATIONS_BUTTON_LABEL),
message_center_view)) {
SetVisible(false);
message_center::MessageCenter::Get()->AddObserver(this);
int left_padding = features::IsUnifiedMessageCenterRefactorEnabled()
......
......@@ -497,6 +497,10 @@ void UnifiedMessageCenterView::NotifyRectBelowScroll() {
SetNotificationRectBelowScroll(rect_below_scroll);
}
void UnifiedMessageCenterView::FocusOut(bool reverse) {
message_center_bubble_->FocusOut(reverse);
}
void UnifiedMessageCenterView::FocusEntered(bool reverse) {
views::View* focus_view =
reverse ? GetLastFocusableChild() : GetFirstFocusableChild();
......
......@@ -90,6 +90,9 @@ class ASH_EXPORT UnifiedMessageCenterView
// Count number of notifications that are above visible area.
std::vector<message_center::Notification*> GetStackedNotifications() const;
// Relinquish focus and transfer it to the quick settings widget.
void FocusOut(bool reverse);
// Set the first child view to be focused when focus is acquired.
// This is the first visible child unless reverse is true, in which case
// it is the last visible child.
......
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