Commit 4b31ff1b authored by Wei Li's avatar Wei Li Committed by Commit Bot

Explicitly set focus behavior of certain Ash buttons

These buttons are subclasses of ImageButton or LabelButton. Since they
didn't set their focus behavior, they inherit the beahvior. This CL uses
DCHECK to assert such behavior, and set the behavior explicitly. So when
we change ImageButton and LabelButton's focus behavior later, these
buttons won't be affected.

Bug: 1001103
Change-Id: I88675c772b83348f68234d588a3c3884387fea84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495820Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Wei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820469}
parent d8db7fef
...@@ -39,6 +39,9 @@ class MinMaxButton : public views::ImageButton { ...@@ -39,6 +39,9 @@ class MinMaxButton : public views::ImageButton {
SetBackground(std::make_unique<SolidSourceBackground>(kHUDLegendBackground, SetBackground(std::make_unique<SolidSourceBackground>(kHUDLegendBackground,
/*radius=*/0)); /*radius=*/0));
SetProperty(kHUDClickHandler, HTCLIENT); SetProperty(kHUDClickHandler, HTCLIENT);
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
} }
MinMaxButton(const MinMaxButton&) = delete; MinMaxButton(const MinMaxButton&) = delete;
......
...@@ -76,6 +76,9 @@ class SettingsButton : public views::ImageButton { ...@@ -76,6 +76,9 @@ class SettingsButton : public views::ImageButton {
kHUDSettingsIconSize, kHUDDefaultColor)); kHUDSettingsIconSize, kHUDDefaultColor));
SetBorder(views::CreateEmptyBorder(gfx::Insets(kSettingsIconBorder))); SetBorder(views::CreateEmptyBorder(gfx::Insets(kSettingsIconBorder)));
SetProperty(kHUDClickHandler, HTCLIENT); SetProperty(kHUDClickHandler, HTCLIENT);
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
} }
SettingsButton(const SettingsButton&) = delete; SettingsButton(const SettingsButton&) = delete;
......
...@@ -88,6 +88,9 @@ HUDTabButton::HUDTabButton(Style style, ...@@ -88,6 +88,9 @@ HUDTabButton::HUDTabButton(Style style,
SetBorder(views::CreateEmptyBorder( SetBorder(views::CreateEmptyBorder(
kSettingsIconBorder, kTabOverlayWidth + kTabTitleBorder, kSettingsIconBorder, kTabOverlayWidth + kTabTitleBorder,
kSettingsIconBorder, kTabOverlayWidth + kTabTitleBorder)); kSettingsIconBorder, kTabOverlayWidth + kTabTitleBorder));
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
} }
void HUDTabButton::SetStyle(Style style) { void HUDTabButton::SetStyle(Style style) {
......
...@@ -132,6 +132,8 @@ class ToastOverlayButton : public views::LabelButton { ...@@ -132,6 +132,8 @@ class ToastOverlayButton : public views::LabelButton {
views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(), views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(),
kToastCornerRounding); kToastCornerRounding);
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
} }
ToastOverlayButton(const ToastOverlayButton&) = delete; ToastOverlayButton(const ToastOverlayButton&) = delete;
......
...@@ -31,6 +31,8 @@ CloseDeskButton::CloseDeskButton(views::ButtonListener* listener) ...@@ -31,6 +31,8 @@ CloseDeskButton::CloseDeskButton(views::ButtonListener* listener)
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
SetHasInkDropActionOnClick(true); SetHasInkDropActionOnClick(true);
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
SetEventTargeter(std::make_unique<views::ViewTargeter>(this)); SetEventTargeter(std::make_unique<views::ViewTargeter>(this));
......
...@@ -46,6 +46,8 @@ NewDeskButton::NewDeskButton(views::ButtonListener* listener) ...@@ -46,6 +46,8 @@ NewDeskButton::NewDeskButton(views::ButtonListener* listener)
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
SetHasInkDropActionOnClick(true); SetHasInkDropActionOnClick(true);
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
auto border = std::make_unique<WmHighlightItemBorder>(kCornerRadius); auto border = std::make_unique<WmHighlightItemBorder>(kCornerRadius);
border_ptr_ = border.get(); border_ptr_ = border.get();
......
...@@ -110,6 +110,8 @@ class OverviewCloseButton : public views::ImageButton { ...@@ -110,6 +110,8 @@ class OverviewCloseButton : public views::ImageButton {
SetMinimumImageSize(gfx::Size(kHeaderHeightDp, kHeaderHeightDp)); SetMinimumImageSize(gfx::Size(kHeaderHeightDp, kHeaderHeightDp));
SetAccessibleName(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); SetAccessibleName(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
views::InstallFixedSizeCircleHighlightPathGenerator( views::InstallFixedSizeCircleHighlightPathGenerator(
this, kCloseButtonInkDropRadiusDp); this, kCloseButtonInkDropRadiusDp);
......
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