Commit 983949b1 authored by Wei Li's avatar Wei Li Committed by Commit Bot

Explicitly set button focus behaviors

To safely change Button class' default focus behavior, we need to
explicitly set all subclasses' focus behavior. To show these changes are
preserving the existing behavior, this CL adds DCHECKs to show the
current behavior. We will delete all the DCHECKs once Button's default
behavior is being flipped.

Bug: 1001103
Change-Id: Ic76bc2ffaa3dfb90b7cd93b59c0a6051e9f5d9d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2473562Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Wei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817723}
parent e035213f
......@@ -52,6 +52,8 @@ class PageSwitcherButton : public views::Button {
public:
explicit PageSwitcherButton(bool is_root_app_grid_page_switcher)
: is_root_app_grid_page_switcher_(is_root_app_grid_page_switcher) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
SetInkDropMode(InkDropMode::ON);
views::InstallFixedSizeCircleHighlightPathGenerator(
this, is_root_app_grid_page_switcher ? kInkDropRadiusForRootGrid
......
......@@ -13,6 +13,8 @@
namespace ash {
SearchResultBaseView::SearchResultBaseView() {
DCHECK_EQ(FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
SetInstallFocusRingOnFocus(false);
}
......
......@@ -253,6 +253,8 @@ class LoginPasswordView::EasyUnlockIcon : public views::Button,
public:
EasyUnlockIcon(const gfx::Size& size, int corner_radius)
: views::Button(this) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
SetPreferredSize(size);
SetLayoutManager(std::make_unique<views::FillLayout>());
icon_ = AddChildView(
......
......@@ -39,6 +39,8 @@ SwitchAccessMenuButton::SwitchAccessMenuButton(std::string action_name,
image_view_(new views::ImageView()),
label_(new views::Label(l10n_util::GetStringUTF16(label_text_id),
views::style::CONTEXT_BUTTON)) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
std::unique_ptr<views::BoxLayout> layout = std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical,
gfx::Insets(kButtonTopPaddingDip, kLabelMinSidePaddingDip,
......
......@@ -147,6 +147,9 @@ UnifiedMediaControlsView::MediaActionButton::CreateInkDropRipple() const {
UnifiedMediaControlsView::UnifiedMediaControlsView(
UnifiedMediaControlsController* controller)
: views::Button(this), controller_(controller) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
SetBackground(views::CreateRoundedRectBackground(
AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive),
......
......@@ -312,6 +312,9 @@ NotifierSettingsView::NotifierButton::NotifierButton(
const NotifierMetadata& notifier,
views::ButtonListener* listener)
: views::Button(listener), notifier_id_(notifier.notifier_id) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
auto icon_view = std::make_unique<views::ImageView>();
auto name_view = std::make_unique<views::Label>(notifier.name);
auto checkbox = std::make_unique<NotifierViewCheckbox>(base::string16(),
......
......@@ -50,6 +50,8 @@ class PageIndicatorView::PageIndicatorButton : public views::Button,
explicit PageIndicatorButton(UnifiedSystemTrayController* controller,
int page)
: views::Button(this), controller_(controller), page_number_(page) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
SetInkDropMode(InkDropMode::ON);
const AshColorProvider::RippleAttributes ripple_attributes =
......
......@@ -32,6 +32,9 @@ UnifiedManagedDeviceView::UnifiedManagedDeviceView(
icon_(new views::ImageView),
label_(new views::Label),
controller_(controller) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal,
kUnifiedManagedDeviceViewPadding, kUnifiedManagedDeviceSpacing));
......
......@@ -218,6 +218,8 @@ DeskPreviewView::DeskPreviewView(DeskMiniView* mini_view)
SetFocusPainter(nullptr);
SetInkDropMode(InkDropMode::OFF);
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
SetPaintToLayer(ui::LAYER_TEXTURED);
layer()->SetFillsBoundsOpaquely(false);
......
......@@ -144,6 +144,9 @@ CandidateView::CandidateView(views::ButtonListener* listener,
theme.GetSystemColor(ui::NativeTheme::kColorId_FocusedBorderColor)));
infolist_icon_ = AddChildView(std::move(infolist_icon));
}
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
}
void CandidateView::GetPreferredWidths(int* shortcut_width,
......
......@@ -102,6 +102,9 @@ SuggestionView::SuggestionView(views::ButtonListener* listener)
suggestion_label_ = AddChildView(CreateSuggestionLabel());
annotation_label_ = AddChildView(CreateAnnotationLabel());
annotation_label_->SetVisible(false);
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
}
SuggestionView::~SuggestionView() = default;
......
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