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 { ...@@ -33,8 +33,10 @@ namespace {
class StackingBarLabelButton : public views::LabelButton { class StackingBarLabelButton : public views::LabelButton {
public: public:
StackingBarLabelButton(views::ButtonListener* listener, StackingBarLabelButton(views::ButtonListener* listener,
const base::string16& text) const base::string16& text,
: views::LabelButton(listener, text) { UnifiedMessageCenterView* message_center_view)
: views::LabelButton(listener, text),
message_center_view_(message_center_view) {
SetEnabledTextColors(kUnifiedMenuButtonColorActive); SetEnabledTextColors(kUnifiedMenuButtonColorActive);
SetHorizontalAlignment(gfx::ALIGN_CENTER); SetHorizontalAlignment(gfx::ALIGN_CENTER);
SetBorder(views::CreateEmptyBorder(gfx::Insets())); SetBorder(views::CreateEmptyBorder(gfx::Insets()));
...@@ -51,6 +53,11 @@ class StackingBarLabelButton : public views::LabelButton { ...@@ -51,6 +53,11 @@ class StackingBarLabelButton : public views::LabelButton {
~StackingBarLabelButton() override = default; ~StackingBarLabelButton() override = default;
// views::LabelButton: // views::LabelButton:
void AboutToRequestFocusFromTabTraversal(bool reverse) override {
if (message_center_view_->collapsed() && HasFocus())
message_center_view_->FocusOut(reverse);
}
gfx::Size CalculatePreferredSize() const override { gfx::Size CalculatePreferredSize() const override {
return gfx::Size(label()->GetPreferredSize().width() + return gfx::Size(label()->GetPreferredSize().width() +
kStackingNotificationClearAllButtonPadding.width(), kStackingNotificationClearAllButtonPadding.width(),
...@@ -58,9 +65,7 @@ class StackingBarLabelButton : public views::LabelButton { ...@@ -58,9 +65,7 @@ class StackingBarLabelButton : public views::LabelButton {
kStackingNotificationClearAllButtonPadding.height()); kStackingNotificationClearAllButtonPadding.height());
} }
const char* GetClassName() const override { const char* GetClassName() const override { return "StackingBarLabelButton"; }
return "StackingBarClearAllButton";
}
int GetHeightForWidth(int width) const override { int GetHeightForWidth(int width) const override {
return label()->GetPreferredSize().height() + return label()->GetPreferredSize().height() +
...@@ -108,7 +113,7 @@ class StackingBarLabelButton : public views::LabelButton { ...@@ -108,7 +113,7 @@ class StackingBarLabelButton : public views::LabelButton {
private: private:
SkColor background_color_ = gfx::kPlaceholderColor; SkColor background_color_ = gfx::kPlaceholderColor;
UnifiedMessageCenterView* message_center_view_;
DISALLOW_COPY_AND_ASSIGN(StackingBarLabelButton); DISALLOW_COPY_AND_ASSIGN(StackingBarLabelButton);
}; };
...@@ -132,11 +137,13 @@ StackedNotificationBar::StackedNotificationBar( ...@@ -132,11 +137,13 @@ StackedNotificationBar::StackedNotificationBar(
clear_all_button_(new StackingBarLabelButton( clear_all_button_(new StackingBarLabelButton(
this, this,
l10n_util::GetStringUTF16( 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( expand_all_button_(new StackingBarLabelButton(
this, this,
l10n_util::GetStringUTF16( 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); SetVisible(false);
message_center::MessageCenter::Get()->AddObserver(this); message_center::MessageCenter::Get()->AddObserver(this);
int left_padding = features::IsUnifiedMessageCenterRefactorEnabled() int left_padding = features::IsUnifiedMessageCenterRefactorEnabled()
......
...@@ -497,6 +497,10 @@ void UnifiedMessageCenterView::NotifyRectBelowScroll() { ...@@ -497,6 +497,10 @@ void UnifiedMessageCenterView::NotifyRectBelowScroll() {
SetNotificationRectBelowScroll(rect_below_scroll); SetNotificationRectBelowScroll(rect_below_scroll);
} }
void UnifiedMessageCenterView::FocusOut(bool reverse) {
message_center_bubble_->FocusOut(reverse);
}
void UnifiedMessageCenterView::FocusEntered(bool reverse) { void UnifiedMessageCenterView::FocusEntered(bool reverse) {
views::View* focus_view = views::View* focus_view =
reverse ? GetLastFocusableChild() : GetFirstFocusableChild(); reverse ? GetLastFocusableChild() : GetFirstFocusableChild();
......
...@@ -90,6 +90,9 @@ class ASH_EXPORT UnifiedMessageCenterView ...@@ -90,6 +90,9 @@ class ASH_EXPORT UnifiedMessageCenterView
// Count number of notifications that are above visible area. // Count number of notifications that are above visible area.
std::vector<message_center::Notification*> GetStackedNotifications() const; 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. // 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 // This is the first visible child unless reverse is true, in which case
// it is the last visible child. // 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