0

Migrate views::Border factory methods to ColorVariant

Bug: b:400775304
Change-Id: Iebba6631fed1d2b1a6568765ff5f6a2c8e3a029e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6341495
Reviewed-by: Elly FJ <ellyjones@chromium.org>
Commit-Queue: Zoraiz Naeem <zoraiznaeem@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1431685}
This commit is contained in:
Zoraiz Naeem
2025-03-12 12:16:05 -07:00
committed by Chromium LUCI CQ
parent 2e8003b739
commit 767d503007
41 changed files with 97 additions and 129 deletions

@@ -245,7 +245,7 @@ GameDashboardToolbarView::GameDashboardToolbarView(
SetCrossAxisAlignment(views::BoxLayout::CrossAxisAlignment::kCenter); SetCrossAxisAlignment(views::BoxLayout::CrossAxisAlignment::kCenter);
SetBackground(views::CreateRoundedRectBackground( SetBackground(views::CreateRoundedRectBackground(
cros_tokens::kCrosSysSystemBaseElevatedOpaque, kCornerRadius)); cros_tokens::kCrosSysSystemBaseElevatedOpaque, kCornerRadius));
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
1, kCornerRadius, ui::ColorIds::kColorCrosSystemHighlightBorder)); 1, kCornerRadius, ui::ColorIds::kColorCrosSystemHighlightBorder));
shadow_ = SystemShadow::CreateShadowOnNinePatchLayerForView( shadow_ = SystemShadow::CreateShadowOnNinePatchLayerForView(
this, SystemShadow::Type::kElevation12); this, SystemShadow::Type::kElevation12);

@@ -63,7 +63,7 @@ GameDashboardWelcomeDialog::GameDashboardWelcomeDialog() {
gfx::Insets::VH(kPrimaryLayoutInsideBorder, kPrimaryLayoutInsideBorder)); gfx::Insets::VH(kPrimaryLayoutInsideBorder, kPrimaryLayoutInsideBorder));
SetBackground(views::CreateRoundedRectBackground( SetBackground(views::CreateRoundedRectBackground(
cros_tokens::kCrosSysSystemBaseElevatedOpaque, kDialogCornerRadius)); cros_tokens::kCrosSysSystemBaseElevatedOpaque, kDialogCornerRadius));
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
game_dashboard::kWelcomeDialogBorderThickness, kDialogCornerRadius, game_dashboard::kWelcomeDialogBorderThickness, kDialogCornerRadius,
ui::ColorIds::kColorHighlightBorderHighlight1)); ui::ColorIds::kColorHighlightBorderHighlight1));
shadow_ = SystemShadow::CreateShadowOnNinePatchLayerForView( shadow_ = SystemShadow::CreateShadowOnNinePatchLayerForView(

@@ -259,7 +259,7 @@ FixedLengthCodeInput::FixedLengthCodeInput(int length,
field->SetFontList(views::Textfield::GetDefaultFontList().Derive( field->SetFontList(views::Textfield::GetDefaultFontList().Derive(
kAccessCodeFontSizeDeltaDp, gfx::Font::FontStyle::NORMAL, kAccessCodeFontSizeDeltaDp, gfx::Font::FontStyle::NORMAL,
gfx::Font::Weight::NORMAL)); gfx::Font::Weight::NORMAL));
field->SetBorder(views::CreateThemedSolidSidedBorder( field->SetBorder(views::CreateSolidSidedBorder(
gfx::Insets::TLBR(0, 0, kAccessCodeInputFieldUnderlineThicknessDp, 0), gfx::Insets::TLBR(0, 0, kAccessCodeInputFieldUnderlineThicknessDp, 0),
text_color_id)); text_color_id));
field->SetGroup(kFixedLengthInputGroup); field->SetGroup(kFixedLengthInputGroup);
@@ -344,7 +344,7 @@ void FixedLengthCodeInput::SetInputColorId(ui::ColorId color_id) {
field->SetTextColorId(color_id); field->SetTextColorId(color_id);
// We don't update the underline color to red. // We don't update the underline color to red.
if (color_id != error_color_id) { if (color_id != error_color_id) {
field->SetBorder(views::CreateThemedSolidSidedBorder( field->SetBorder(views::CreateSolidSidedBorder(
gfx::Insets::TLBR(0, 0, kAccessCodeInputFieldUnderlineThicknessDp, 0), gfx::Insets::TLBR(0, 0, kAccessCodeInputFieldUnderlineThicknessDp, 0),
color_id)); color_id));
} }
@@ -531,7 +531,7 @@ void FixedLengthCodeInput::SetReadOnly(bool read_only) {
for (ash::AccessibleInputField* field : input_fields_) { for (ash::AccessibleInputField* field : input_fields_) {
field->SetReadOnly(read_only); field->SetReadOnly(read_only);
field->SetBackground(nullptr); field->SetBackground(nullptr);
field->SetBorder(views::CreateThemedSolidSidedBorder( field->SetBorder(views::CreateSolidSidedBorder(
gfx::Insets::TLBR(0, 0, kAccessCodeInputFieldUnderlineThicknessDp, 0), gfx::Insets::TLBR(0, 0, kAccessCodeInputFieldUnderlineThicknessDp, 0),
underline_color_id)); underline_color_id));
field->SetCursorEnabled(!read_only); field->SetCursorEnabled(!read_only);

@@ -77,9 +77,9 @@ LoginShelfButton::LoginShelfButton(PressedCallback callback,
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
views::InkDrop::Get(this)->SetMode(views::InkDropHost::InkDropMode::OFF); views::InkDrop::Get(this)->SetMode(views::InkDropHost::InkDropMode::OFF);
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(kButtonHighlightWidthDp,
kButtonHighlightWidthDp, kButtonHighlightRadiusDp, kButtonHighlightRadiusDp,
ui::kColorCrosSystemHighlight)); ui::kColorCrosSystemHighlight));
// PillButton has some custom tooltip logic that runs, but we don't want here. // PillButton has some custom tooltip logic that runs, but we don't want here.
SetUseLabelAsDefaultTooltip(false); SetUseLabelAsDefaultTooltip(false);
UpdateTooltipText(label()); UpdateTooltipText(label());

@@ -251,7 +251,7 @@ LoginShelfView::LoginShelfView() {
ButtonId id) -> LoginShelfButton* { ButtonId id) -> LoginShelfButton* {
View* button_container = AddChildView(std::make_unique<View>()); View* button_container = AddChildView(std::make_unique<View>());
button_container->SetLayoutManager(std::make_unique<views::FillLayout>()); button_container->SetLayoutManager(std::make_unique<views::FillLayout>());
button_container->SetBorder(views::CreateThemedRoundedRectBorder( button_container->SetBorder(views::CreateRoundedRectBorder(
kButtonHighlightBorderWidth, kButtonHighlightBorderRadius, kButtonHighlightBorderWidth, kButtonHighlightBorderRadius,
ui::kColorCrosSystemHighlightBorder)); ui::kColorCrosSystemHighlightBorder));
button_container->SetID(kButtonContainerDiff + id); button_container->SetID(kButtonContainerDiff + id);

@@ -49,8 +49,8 @@ constexpr int kFirstChipOffsetX =
void SetupChip(views::LabelButton* chip, bool first) { void SetupChip(views::LabelButton* chip, bool first) {
chip->SetHorizontalAlignment(gfx::ALIGN_CENTER); chip->SetHorizontalAlignment(gfx::ALIGN_CENTER);
chip->SetBorder(views::CreatePaddedBorder( chip->SetBorder(views::CreatePaddedBorder(
views::CreateThemedRoundedRectBorder(1, kChipHeight, views::CreateRoundedRectBorder(1, kChipHeight,
cros_tokens::kCrosSysSeparator), cros_tokens::kCrosSysSeparator),
kChipInsets)); kChipInsets));
// Add a border to space out chips on all chips but the first. // Add a border to space out chips on all chips but the first.
chip->SetProperty(views::kMarginsKey, chip->SetProperty(views::kMarginsKey,

@@ -124,7 +124,7 @@ HoldingSpaceItemScreenCaptureView::HoldingSpaceItemScreenCaptureView(
kColorAshShieldAndBase80)))) kColorAshShieldAndBase80))))
.AddChild(views::Builder<views::View>() .AddChild(views::Builder<views::View>()
.SetCanProcessEventsWithinSubtree(false) .SetCanProcessEventsWithinSubtree(false)
.SetBorder(views::CreateThemedRoundedRectBorder( .SetBorder(views::CreateRoundedRectBorder(
kBorderThickness, kHoldingSpaceCornerRadius, kBorderThickness, kHoldingSpaceCornerRadius,
kColorAshSeparatorColor))) kColorAshSeparatorColor)))
.BuildChildren(); .BuildChildren();

@@ -80,9 +80,9 @@ class CalendarEmptyEventListView : public PillButton {
controller_(controller) { controller_(controller) {
SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_CENTER); SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_CENTER);
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(kOpenGoogleCalendarBorderThickness,
kOpenGoogleCalendarBorderThickness, GetPreferredSize().height() / 2, GetPreferredSize().height() / 2,
kColorAshHairlineBorderColor)); kColorAshHairlineBorderColor));
SetTooltipText( SetTooltipText(
l10n_util::GetStringUTF16(IDS_ASH_CALENDAR_NO_EVENT_BUTTON_TOOL_TIP)); l10n_util::GetStringUTF16(IDS_ASH_CALENDAR_NO_EVENT_BUTTON_TOOL_TIP));
} }

@@ -103,7 +103,7 @@ class Separator : public views::View {
views::Builder<views::View>() views::Builder<views::View>()
// make sure that the view is displayed by setting non-zero size // make sure that the view is displayed by setting non-zero size
.SetPreferredSize(gfx::Size(1, 1)) .SetPreferredSize(gfx::Size(1, 1))
.SetBorder(views::CreateThemedSolidSidedBorder( .SetBorder(views::CreateSolidSidedBorder(
gfx::Insets::TLBR(0, 0, kUnifiedNotificationSeparatorThickness, gfx::Insets::TLBR(0, 0, kUnifiedNotificationSeparatorThickness,
0), 0),
cros_tokens::kCrosSysSeparator)) cros_tokens::kCrosSysSeparator))

@@ -190,7 +190,7 @@ std::unique_ptr<views::ImageView> CreateSecondaryImageView(
.SetSize(gfx::Size(kSecondaryIconViewSize, kSecondaryIconViewSize)) .SetSize(gfx::Size(kSecondaryIconViewSize, kSecondaryIconViewSize))
.SetBackground(views::CreateRoundedRectBackground( .SetBackground(views::CreateRoundedRectBackground(
kSecondaryIconBackgroundColorId, kSecondaryIconViewSize / 2)) kSecondaryIconBackgroundColorId, kSecondaryIconViewSize / 2))
.SetBorder(views::CreateThemedRoundedRectBorder( .SetBorder(views::CreateRoundedRectBorder(
1, kSecondaryIconViewSize / 2, 1, kSecondaryIconViewSize / 2,
cros_tokens::kCrosSysSystemOnBaseOpaque)) cros_tokens::kCrosSysSystemOnBaseOpaque))
.Build(); .Build();

@@ -41,7 +41,7 @@ class OverviewDropTargetView : public views::View {
background_view_->SetBackground(views::CreateRoundedRectBackground( background_view_->SetBackground(views::CreateRoundedRectBackground(
kColorAshShieldAndBase20, corner_radius)); kColorAshShieldAndBase20, corner_radius));
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
kDropTargetBorderThickness, corner_radius, kDropTargetBorderThickness, corner_radius,
cros_tokens::kCrosSysSystemBaseElevated)); cros_tokens::kCrosSysSystemBaseElevated));
} }

@@ -49,7 +49,7 @@ ActionTypeButton::ActionTypeButton(PressedCallback callback,
SetVisible(true); SetVisible(true);
SetBackground(views::CreateRoundedRectBackground(SK_ColorTRANSPARENT, SetBackground(views::CreateRoundedRectBackground(SK_ColorTRANSPARENT,
/*radius=*/kCornerRadius)); /*radius=*/kCornerRadius));
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
/*thickness=*/kBorderThickness, /*thickness=*/kBorderThickness,
/*radius=*/kCornerRadius, cros_tokens::kCrosSysHoverOnSubtle)); /*radius=*/kCornerRadius, cros_tokens::kCrosSysHoverOnSubtle));
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY); SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
@@ -89,7 +89,7 @@ void ActionTypeButton::RefreshColors() {
/*radius=*/kCornerRadius)); /*radius=*/kCornerRadius));
SetBorder(is_selected SetBorder(is_selected
? views::CreateEmptyBorder(/*thickness=*/kBorderThickness) ? views::CreateEmptyBorder(/*thickness=*/kBorderThickness)
: views::CreateThemedRoundedRectBorder( : views::CreateRoundedRectBorder(
/*thickness=*/kBorderThickness, /*thickness=*/kBorderThickness,
/*radius=*/kCornerRadius, /*radius=*/kCornerRadius,
cros_tokens::kCrosSysHoverOnSubtle)); cros_tokens::kCrosSysHoverOnSubtle));

@@ -265,7 +265,7 @@ void EditLabel::SetToFocused() {
SetEnabledTextColors(IsInputUnbound() && !action_->is_new() SetEnabledTextColors(IsInputUnbound() && !action_->is_new()
? cros_tokens::kCrosSysError ? cros_tokens::kCrosSysError
: cros_tokens::kCrosSysOnSurface); : cros_tokens::kCrosSysOnSurface);
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
/*thickness=*/2, kCornerRadius, cros_tokens::kCrosSysPrimary)); /*thickness=*/2, kCornerRadius, cros_tokens::kCrosSysPrimary));
} }

@@ -204,8 +204,7 @@ void CandidateView::SetHighlighted(bool highlighted) {
if (highlighted) { if (highlighted) {
SetBackground( SetBackground(
views::CreateSolidBackground(ui::kColorTextfieldSelectionBackground)); views::CreateSolidBackground(ui::kColorTextfieldSelectionBackground));
SetBorder( SetBorder(views::CreateSolidBorder(1, ui::kColorFocusableBorderFocused));
views::CreateThemedSolidBorder(1, ui::kColorFocusableBorderFocused));
// Cancel currently focused one. // Cancel currently focused one.
for (View* view : parent()->children()) { for (View* view : parent()->children()) {

@@ -22,10 +22,10 @@ BnplLinkedIssuerPill::BnplLinkedIssuerPill()
views::style::CONTEXT_DIALOG_BODY_TEXT, views::style::CONTEXT_DIALOG_BODY_TEXT,
views::style::STYLE_SECONDARY) { views::style::STYLE_SECONDARY) {
// TODO(kylixrd): Find appropriate metrics on ChromeLayoutProvider. // TODO(kylixrd): Find appropriate metrics on ChromeLayoutProvider.
SetBackground(views::CreateRoundedRectBackground( SetBackground(views::CreateRoundedRectBackground(ui::kColorBadgeBackground,
ui::ColorVariant(ui::kColorBadgeBackground), gfx::RoundedCornersF(8))); gfx::RoundedCornersF(8)));
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(0, 8, gfx::Insets::TLBR(0, 4, 0, 4),
0, 8, gfx::Insets::TLBR(0, 4, 0, 4), ui::kColorBadgeBackground)); ui::kColorBadgeBackground));
} }
BnplLinkedIssuerPill::~BnplLinkedIssuerPill() = default; BnplLinkedIssuerPill::~BnplLinkedIssuerPill() = default;

@@ -107,8 +107,8 @@ std::unique_ptr<views::BoxLayoutView> CreateTipTextContainer(
.SetBetweenChildSpacing(kContainerChildSpace) .SetBetweenChildSpacing(kContainerChildSpace)
.SetBackground( .SetBackground(
views::CreateSolidBackground(kColorPaymentsFeedbackTipBackground)) views::CreateSolidBackground(kColorPaymentsFeedbackTipBackground))
.SetBorder(views::CreateThemedSolidBorder( .SetBorder(views::CreateSolidBorder(kTipValuePromptBorderThickness,
kTipValuePromptBorderThickness, kColorPaymentsFeedbackTipBorder)) kColorPaymentsFeedbackTipBorder))
.Build(); .Build();
container->AddChildView( container->AddChildView(

@@ -373,7 +373,7 @@ class BookmarkBarView::ButtonSeparatorView : public views::Separator {
border_insets.left() + separator_thickness_ + border_insets.right(), border_insets.left() + separator_thickness_ + border_insets.right(),
gfx::kFaviconSize)); gfx::kFaviconSize));
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
separator_thickness_ / 2, separator_thickness_ / 2, border_insets, separator_thickness_ / 2, separator_thickness_ / 2, border_insets,
kColorBookmarkBarSeparatorChromeRefresh)); kColorBookmarkBarSeparatorChromeRefresh));
} }

@@ -243,10 +243,9 @@ void SavedTabGroupButton::UpdateButtonLayout() {
if (!local_group_id_.has_value()) { if (!local_group_id_.has_value()) {
SetBorder(views::CreateEmptyBorder(insets)); SetBorder(views::CreateEmptyBorder(insets));
} else { } else {
std::unique_ptr<views::Border> border = std::unique_ptr<views::Border> border = views::CreateRoundedRectBorder(
views::CreateThemedRoundedRectBorder( kBorderThickness, kButtonRadius,
kBorderThickness, kButtonRadius, GetSavedTabGroupOutlineColorId(tab_group_color_id_));
GetSavedTabGroupOutlineColorId(tab_group_color_id_));
SetBorder(views::CreatePaddedBorder(std::move(border), insets)); SetBorder(views::CreatePaddedBorder(std::move(border), insets));
} }

@@ -193,8 +193,8 @@ ShareThisTabDialogView::ShareThisTabDialogView(
CreateDialogWidget(this, params.context, nullptr)->Show(); CreateDialogWidget(this, params.context, nullptr)->Show();
} }
source_view_->SetBorder(views::CreateThemedRoundedRectBorder( source_view_->SetBorder(
1, 4, ui::kColorSysPrimaryContainer)); views::CreateRoundedRectBorder(1, 4, ui::kColorSysPrimaryContainer));
SetButtonLabel(ui::mojom::DialogButton::kOk, SetButtonLabel(ui::mojom::DialogButton::kOk,
l10n_util::GetStringUTF16(IDS_SHARE_THIS_TAB_DIALOG_ALLOW)); l10n_util::GetStringUTF16(IDS_SHARE_THIS_TAB_DIALOG_ALLOW));

@@ -33,7 +33,7 @@ CastDeviceFooterView::CastDeviceFooterView(
base::RepeatingClosure stop_casting_callback, base::RepeatingClosure stop_casting_callback,
media_message_center::MediaColorTheme media_color_theme) media_message_center::MediaColorTheme media_color_theme)
: stop_casting_callback_(std::move(stop_casting_callback)) { : stop_casting_callback_(std::move(stop_casting_callback)) {
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
kBackgroundBorderThickness, kBackgroundCornerRadius, kBackgroundBorderThickness, kBackgroundCornerRadius,
media_color_theme.device_selector_border_color_id)); media_color_theme.device_selector_border_color_id));
SetBackground(views::CreateRoundedRectBackground( SetBackground(views::CreateRoundedRectBackground(

@@ -118,7 +118,7 @@ CastDeviceSelectorView::CastDeviceSelectorView(
: device_list_host_(std::move(device_list_host)), : device_list_host_(std::move(device_list_host)),
device_list_client_(this, std::move(device_list_client)), device_list_client_(this, std::move(device_list_client)),
media_color_theme_(media_color_theme) { media_color_theme_(media_color_theme) {
SetBorder(views::CreateThemedRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
kBackgroundBorderThickness, kBackgroundCornerRadius, kBackgroundBorderThickness, kBackgroundCornerRadius,
media_color_theme_.device_selector_border_color_id)); media_color_theme_.device_selector_border_color_id));
SetBackground(views::CreateRoundedRectBackground( SetBackground(views::CreateRoundedRectBackground(

@@ -106,8 +106,8 @@ void StyleMenuButton(views::LabelButton* button, const gfx::VectorIcon& icon) {
auto color_id = button->GetEnabled() ? ui::kColorSysTonalOutline auto color_id = button->GetEnabled() ? ui::kColorSysTonalOutline
: ui::kColorButtonBorderDisabled; : ui::kColorButtonBorderDisabled;
button->SetBorder(views::CreatePaddedBorder( button->SetBorder(views::CreatePaddedBorder(
views::CreateThemedRoundedRectBorder(kButtonBorderThickness, views::CreateRoundedRectBorder(kButtonBorderThickness,
kButtonCornerRadius, color_id), kButtonCornerRadius, color_id),
kButtonPadding)); kButtonPadding));
} }

@@ -35,7 +35,7 @@ std::unique_ptr<views::View> CreatePreviewBadge() {
const int kBorderThickness = 0; const int kBorderThickness = 0;
const int kRoundedRadius = const int kRoundedRadius =
GetLayoutConstant(LOCATION_BAR_CHILD_CORNER_RADIUS); GetLayoutConstant(LOCATION_BAR_CHILD_CORNER_RADIUS);
badge_view->SetBorder(views::CreateThemedRoundedRectBorder( badge_view->SetBorder(views::CreateRoundedRectBorder(
kBorderThickness, kRoundedRadius, kBorderThickness, kRoundedRadius,
gfx::Insets::TLBR(kVerticalInset, kLeftInset, kVerticalInset, gfx::Insets::TLBR(kVerticalInset, kLeftInset, kVerticalInset,
kRightInset), kRightInset),

@@ -46,7 +46,7 @@ MediaCoordinator::MediaCoordinator(
const int kBorderThickness = const int kBorderThickness =
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL); provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
media_view_->SetBorder(views::CreateThemedRoundedRectBorder( media_view_->SetBorder(views::CreateRoundedRectBorder(
kBorderThickness, kRoundedRadius, ui::kColorSysSurface4)); kBorderThickness, kRoundedRadius, ui::kColorSysSurface4));
media_view_->SetBackground(views::CreateRoundedRectBackground( media_view_->SetBackground(views::CreateRoundedRectBackground(
ui::kColorSysSurface4, kRoundedRadius)); ui::kColorSysSurface4, kRoundedRadius));

@@ -61,7 +61,7 @@ MediaViewControllerBase::MediaViewControllerBase(
const int kBorderThickness = const int kBorderThickness =
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL); provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
base_view_->SetBorder(views::CreateThemedRoundedRectBorder( base_view_->SetBorder(views::CreateRoundedRectBorder(
kBorderThickness, kRoundedRadius, ui::kColorMenuBackground)); kBorderThickness, kRoundedRadius, ui::kColorMenuBackground));
base_view_->SetBackground(views::CreateRoundedRectBackground( base_view_->SetBackground(views::CreateRoundedRectBackground(
ui::kColorMenuBackground, kRoundedRadius)); ui::kColorMenuBackground, kRoundedRadius));

@@ -179,7 +179,7 @@ TabListRowView::TabListRowView(
favicon->SetBackground(views::CreateRoundedRectBackground( favicon->SetBackground(views::CreateRoundedRectBackground(
ui::kColorSysNeutralContainer, kFaviconCornerRadius)); ui::kColorSysNeutralContainer, kFaviconCornerRadius));
favicon->SetBorder(views::CreateThemedRoundedRectBorder( favicon->SetBorder(views::CreateRoundedRectBorder(
kFaviconBorderThickness, kFaviconCornerRadius, kFaviconBorderThickness, kFaviconCornerRadius,
ui::kColorSysNeutralContainer)); ui::kColorSysNeutralContainer));

@@ -213,7 +213,7 @@ class ImageCarouselView : public views::View {
throbber->Start(); throbber->Start();
throbber_container_view->AddChildView(std::move(throbber)); throbber_container_view->AddChildView(std::move(throbber));
throbber_container_view->SetBorder(views::CreateThemedSolidBorder( throbber_container_view->SetBorder(views::CreateSolidBorder(
/*thickness=*/1, ui::kColorSysSecondaryContainer)); /*thickness=*/1, ui::kColorSysSecondaryContainer));
throbber_container_view->SetProperty( throbber_container_view->SetProperty(
views::kMarginsKey, gfx::Insets::TLBR(0, 0, 0, image_padding_)); views::kMarginsKey, gfx::Insets::TLBR(0, 0, 0, image_padding_));

@@ -11,6 +11,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "cc/paint/paint_flags.h" #include "cc/paint/paint_flags.h"
#include "ui/color/color_provider.h" #include "ui/color/color_provider.h"
#include "ui/color/color_variant.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/geometry/dip_util.h"
@@ -294,14 +295,15 @@ std::unique_ptr<Border> NullBorder() {
return nullptr; return nullptr;
} }
std::unique_ptr<Border> CreateSolidBorder(int thickness, SkColor color) { std::unique_ptr<Border> CreateSolidBorder(int thickness,
return std::make_unique<SolidSidedBorder>(gfx::Insets(thickness), color); ui::ColorVariant color) {
} if (auto color_id = color.GetColorId()) {
return std::make_unique<ThemedSolidSidedBorder>(gfx::Insets(thickness),
*color_id);
}
std::unique_ptr<Border> CreateThemedSolidBorder(int thickness, return std::make_unique<SolidSidedBorder>(gfx::Insets(thickness),
ui::ColorId color) { *color.GetSkColor());
return std::make_unique<ThemedSolidSidedBorder>(gfx::Insets(thickness),
color);
} }
std::unique_ptr<Border> CreateEmptyBorder(const gfx::Insets& insets) { std::unique_ptr<Border> CreateEmptyBorder(const gfx::Insets& insets) {
@@ -314,7 +316,7 @@ std::unique_ptr<Border> CreateEmptyBorder(int thickness) {
std::unique_ptr<Border> CreateRoundedRectBorder(int thickness, std::unique_ptr<Border> CreateRoundedRectBorder(int thickness,
float corner_radius, float corner_radius,
SkColor color) { ui::ColorVariant color) {
return CreateRoundedRectBorder(thickness, corner_radius, gfx::Insets(), return CreateRoundedRectBorder(thickness, corner_radius, gfx::Insets(),
color); color);
} }
@@ -322,35 +324,23 @@ std::unique_ptr<Border> CreateRoundedRectBorder(int thickness,
std::unique_ptr<Border> CreateRoundedRectBorder(int thickness, std::unique_ptr<Border> CreateRoundedRectBorder(int thickness,
float corner_radius, float corner_radius,
const gfx::Insets& paint_insets, const gfx::Insets& paint_insets,
SkColor color) { ui::ColorVariant color) {
if (auto color_id = color.GetColorId()) {
return std::make_unique<ThemedRoundedRectBorder>(thickness, corner_radius,
paint_insets, *color_id);
}
return std::make_unique<RoundedRectBorder>(thickness, corner_radius, return std::make_unique<RoundedRectBorder>(thickness, corner_radius,
paint_insets, color); paint_insets, *color.GetSkColor());
}
std::unique_ptr<Border> CreateThemedRoundedRectBorder(int thickness,
float corner_radius,
ui::ColorId color_id) {
return CreateThemedRoundedRectBorder(thickness, corner_radius, gfx::Insets(),
color_id);
}
std::unique_ptr<Border> CreateThemedRoundedRectBorder(
int thickness,
float corner_radius,
const gfx::Insets& paint_insets,
ui::ColorId color_id) {
return std::make_unique<ThemedRoundedRectBorder>(thickness, corner_radius,
paint_insets, color_id);
} }
std::unique_ptr<Border> CreateSolidSidedBorder(const gfx::Insets& insets, std::unique_ptr<Border> CreateSolidSidedBorder(const gfx::Insets& insets,
SkColor color) { ui::ColorVariant color) {
return std::make_unique<SolidSidedBorder>(insets, color); if (auto color_id = color.GetColorId()) {
} return std::make_unique<ThemedSolidSidedBorder>(insets, *color_id);
}
std::unique_ptr<Border> CreateThemedSolidSidedBorder(const gfx::Insets& insets, return std::make_unique<SolidSidedBorder>(insets, *color.GetSkColor());
ui::ColorId color_id) {
return std::make_unique<ThemedSolidSidedBorder>(insets, color_id);
} }
std::unique_ptr<Border> CreatePaddedBorder(std::unique_ptr<Border> border, std::unique_ptr<Border> CreatePaddedBorder(std::unique_ptr<Border> border,
@@ -360,7 +350,7 @@ std::unique_ptr<Border> CreatePaddedBorder(std::unique_ptr<Border> border,
std::unique_ptr<Border> CreateBorderPainter(std::unique_ptr<Painter> painter, std::unique_ptr<Border> CreateBorderPainter(std::unique_ptr<Painter> painter,
const gfx::Insets& insets) { const gfx::Insets& insets) {
return base::WrapUnique(new BorderPainter(std::move(painter), insets)); return std::make_unique<BorderPainter>(std::move(painter), insets);
} }
} // namespace views } // namespace views

@@ -9,6 +9,7 @@
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/color/color_id.h" #include "ui/color/color_id.h"
#include "ui/color/color_variant.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/views/views_export.h" #include "ui/views/views_export.h"
@@ -84,34 +85,21 @@ VIEWS_EXPORT std::unique_ptr<Border> NullBorder();
// Creates a border that is a simple line of the specified thickness and color. // Creates a border that is a simple line of the specified thickness and color.
VIEWS_EXPORT std::unique_ptr<Border> CreateSolidBorder(int thickness, VIEWS_EXPORT std::unique_ptr<Border> CreateSolidBorder(int thickness,
SkColor color); ui::ColorVariant color);
// Creates a border that is a simple line of the specified thickness and color,
// which updates on theme changes.
VIEWS_EXPORT std::unique_ptr<Border> CreateThemedSolidBorder(int thickness,
ui::ColorId color);
// Creates a border that is a rounded rectangle of the specified thickness and // Creates a border that is a rounded rectangle of the specified thickness and
// color. // color.
// NOTE: `corner_radius` is an OUTER EDGE RADIUS, not a stroke radius! // NOTE: `corner_radius` is an OUTER EDGE RADIUS, not a stroke radius!
VIEWS_EXPORT std::unique_ptr<Border> VIEWS_EXPORT std::unique_ptr<Border> CreateRoundedRectBorder(
CreateRoundedRectBorder(int thickness, float corner_radius, SkColor color); int thickness,
float corner_radius,
ui::ColorVariant color);
VIEWS_EXPORT std::unique_ptr<Border> CreateRoundedRectBorder( VIEWS_EXPORT std::unique_ptr<Border> CreateRoundedRectBorder(
int thickness, int thickness,
float corner_radius, float corner_radius,
const gfx::Insets& paint_insets, const gfx::Insets& paint_insets,
SkColor color); ui::ColorVariant color);
// Same as above except the color updates with theme changes.
VIEWS_EXPORT std::unique_ptr<Border> CreateThemedRoundedRectBorder(
int thickness,
float corner_radius,
ui::ColorId color_id);
VIEWS_EXPORT std::unique_ptr<Border> CreateThemedRoundedRectBorder(
int thickness,
float corner_radius,
const gfx::Insets& paint_insets,
ui::ColorId color_id);
// Creates a border for reserving space. The returned border does not paint // Creates a border for reserving space. The returned border does not paint
// anything. // anything.
@@ -125,13 +113,7 @@ VIEWS_EXPORT std::unique_ptr<Border> CreateEmptyBorder(int thickness);
// in |insets|. // in |insets|.
VIEWS_EXPORT std::unique_ptr<Border> CreateSolidSidedBorder( VIEWS_EXPORT std::unique_ptr<Border> CreateSolidSidedBorder(
const gfx::Insets& insets, const gfx::Insets& insets,
SkColor color); ui::ColorVariant color);
// Creates a border of the specified color with thickness on each side specified
// in |insets|. The border updates on theme changes.
VIEWS_EXPORT std::unique_ptr<Border> CreateThemedSolidSidedBorder(
const gfx::Insets& insets,
ui::ColorId color_id);
// Creates a new border that draws |border| and adds additional padding. This is // Creates a new border that draws |border| and adds additional padding. This is
// equivalent to changing the insets of |border| without changing how or what it // equivalent to changing the insets of |border| without changing how or what it

@@ -420,8 +420,8 @@ class SelectedColorPatchView : public views::View {
SelectedColorPatchView::SelectedColorPatchView() { SelectedColorPatchView::SelectedColorPatchView() {
SetVisible(true); SetVisible(true);
SetBorder(CreateThemedSolidBorder(kBorderWidth, SetBorder(
ui::kColorFocusableBorderUnfocused)); CreateSolidBorder(kBorderWidth, ui::kColorFocusableBorderUnfocused));
} }
void SelectedColorPatchView::SetColor(SkColor color) { void SelectedColorPatchView::SetColor(SkColor color) {

@@ -570,7 +570,7 @@ void Combobox::UpdateBorder() {
SetBorder(nullptr); SetBorder(nullptr);
return; return;
} }
SetBorder(CreateThemedRoundedRectBorder( SetBorder(CreateRoundedRectBorder(
kBorderThickness, GetCornerRadius(), kBorderThickness, GetCornerRadius(),
invalid_ invalid_
? ui::kColorAlertHighSeverity ? ui::kColorAlertHighSeverity

@@ -439,8 +439,7 @@ void MenuScrollViewContainer::CreateDefaultBorder() {
// When a custom background color is used, ensure that the border uses // When a custom background color is used, ensure that the border uses
// the custom background color for its insets. // the custom background color for its insets.
if (border_color_id_.has_value()) { if (border_color_id_.has_value()) {
SetBorder( SetBorder(views::CreateSolidSidedBorder(insets, border_color_id_.value()));
views::CreateThemedSolidSidedBorder(insets, border_color_id_.value()));
return; return;
} }

@@ -34,8 +34,8 @@ TooltipViewAura::TooltipViewAura()
SetBackground(views::CreateSolidBackground(ui::kColorTooltipBackground)); SetBackground(views::CreateSolidBackground(ui::kColorTooltipBackground));
SetBorder(views::CreatePaddedBorder( SetBorder(views::CreatePaddedBorder(
views::CreateThemedSolidBorder(kTooltipBorderThickness, views::CreateSolidBorder(kTooltipBorderThickness,
ui::kColorTooltipForeground), ui::kColorTooltipForeground),
kBorderInset - gfx::Insets(kTooltipBorderThickness))); kBorderInset - gfx::Insets(kTooltipBorderThickness)));
GetViewAccessibility().SetRole(ax::mojom::Role::kTooltip); GetViewAccessibility().SetRole(ax::mojom::Role::kTooltip);

@@ -267,7 +267,7 @@ void ActionsExample::CreateExampleView(View* container) {
Builder<View>() Builder<View>()
.CopyAddressTo(&action_panel_) .CopyAddressTo(&action_panel_)
.SetLayoutManager(std::make_unique<FlowLayout>()) .SetLayoutManager(std::make_unique<FlowLayout>())
.SetBorder(CreateThemedSolidBorder( .SetBorder(CreateSolidBorder(
1, ui::kColorFocusableBorderUnfocused)), 1, ui::kColorFocusableBorderUnfocused)),
Builder<BoxLayoutView>() Builder<BoxLayoutView>()
.CopyAddressTo(&control_panel_) .CopyAddressTo(&control_panel_)

@@ -64,7 +64,7 @@ class AnimationGallery : public BoxLayoutView, public TextfieldController {
.AddChild( .AddChild(
Builder<AnimatedImageView>() Builder<AnimatedImageView>()
.CopyAddressTo(&animated_image_view_) .CopyAddressTo(&animated_image_view_)
.SetBorder(CreateThemedSolidBorder( .SetBorder(CreateSolidBorder(
1, ExamplesColorIds:: 1, ExamplesColorIds::
kColorAnimatedImageViewExampleBorder))), kColorAnimatedImageViewExampleBorder))),
Builder<BoxLayoutView>() Builder<BoxLayoutView>()

@@ -61,7 +61,7 @@ FadingView::FadingView() {
.AddChildren( .AddChildren(
Builder<BoxLayoutView>() Builder<BoxLayoutView>()
.CopyAddressTo(&primary_view_) .CopyAddressTo(&primary_view_)
.SetBorder(CreateThemedRoundedRectBorder( .SetBorder(CreateRoundedRectBorder(
1, kCornerRadius, 1, kCornerRadius,
ExamplesColorIds::kColorFadeAnimationExampleBorder)) ExamplesColorIds::kColorFadeAnimationExampleBorder))
.SetBackground(CreateRoundedRectBackground( .SetBackground(CreateRoundedRectBackground(
@@ -83,7 +83,7 @@ FadingView::FadingView() {
.SetVerticalAlignment(gfx::ALIGN_MIDDLE)), .SetVerticalAlignment(gfx::ALIGN_MIDDLE)),
Builder<BoxLayoutView>() Builder<BoxLayoutView>()
.CopyAddressTo(&secondary_view_) .CopyAddressTo(&secondary_view_)
.SetBorder(CreateThemedRoundedRectBorder( .SetBorder(CreateRoundedRectBorder(
1, kCornerRadius, 1, kCornerRadius,
ExamplesColorIds::kColorFadeAnimationExampleBorder)) ExamplesColorIds::kColorFadeAnimationExampleBorder))
.SetBackground(CreateRoundedRectBackground( .SetBackground(CreateRoundedRectBackground(

@@ -82,7 +82,7 @@ void InkDropExample::CreateExampleView(View* container) {
.AddChildren( .AddChildren(
Builder<InkDropView>() Builder<InkDropView>()
.CopyAddressTo(&ink_drop_view_) .CopyAddressTo(&ink_drop_view_)
.SetBorder(CreateThemedRoundedRectBorder( .SetBorder(CreateRoundedRectBorder(
1, 4, ExamplesColorIds::kColorInkDropExampleBorder)) 1, 4, ExamplesColorIds::kColorInkDropExampleBorder))
.SetProperty(kMarginsKey, gfx::Insets(10)), .SetProperty(kMarginsKey, gfx::Insets(10)),
Builder<BoxLayoutView>() Builder<BoxLayoutView>()

@@ -44,8 +44,7 @@ class ExamplePreferredSizeLabel : public Label {
public: public:
ExamplePreferredSizeLabel() { ExamplePreferredSizeLabel() {
SetBorder( SetBorder(CreateSolidBorder(1, ExamplesColorIds::kColorLabelExampleBorder));
CreateThemedSolidBorder(1, ExamplesColorIds::kColorLabelExampleBorder));
} }
ExamplePreferredSizeLabel(const ExamplePreferredSizeLabel&) = delete; ExamplePreferredSizeLabel(const ExamplePreferredSizeLabel&) = delete;
@@ -128,8 +127,8 @@ void LabelExample::CreateExampleView(View* container) {
container->AddChildView(std::move(label)); container->AddChildView(std::move(label));
label = std::make_unique<Label>(u"Label with thick border"); label = std::make_unique<Label>(u"Label with thick border");
label->SetBorder(CreateThemedSolidBorder( label->SetBorder(
20, ExamplesColorIds::kColorLabelExampleThickBorder)); CreateSolidBorder(20, ExamplesColorIds::kColorLabelExampleThickBorder));
container->AddChildView(std::move(label)); container->AddChildView(std::move(label));
label = std::make_unique<Label>( label = std::make_unique<Label>(
@@ -172,8 +171,8 @@ void LabelExample::ContentsChanged(Textfield* sender,
void LabelExample::AddCustomLabel(View* container) { void LabelExample::AddCustomLabel(View* container) {
std::unique_ptr<View> control_container = std::make_unique<View>(); std::unique_ptr<View> control_container = std::make_unique<View>();
control_container->SetBorder(CreateThemedSolidBorder( control_container->SetBorder(
2, ExamplesColorIds::kColorLabelExampleCustomBorder)); CreateSolidBorder(2, ExamplesColorIds::kColorLabelExampleCustomBorder));
control_container->SetBackground(CreateSolidBackground( control_container->SetBackground(CreateSolidBackground(
ExamplesColorIds::kColorLabelExampleCustomBackground)); ExamplesColorIds::kColorLabelExampleCustomBackground));
control_container->SetLayoutManager( control_container->SetLayoutManager(

@@ -238,7 +238,7 @@ void MenuExample::CreateExampleView(View* container) {
.Build(); .Build();
example_menu_button->SetBorder(CreatePaddedBorder( example_menu_button->SetBorder(CreatePaddedBorder(
CreateThemedRoundedRectBorder(1, 5, kColorMenuButtonExampleBorder), CreateRoundedRectBorder(1, 5, kColorMenuButtonExampleBorder),
LayoutProvider::Get()->GetInsetsMetric( LayoutProvider::Get()->GetInsetsMetric(
InsetsMetric::INSETS_LABEL_BUTTON))); InsetsMetric::INSETS_LABEL_BUTTON)));

@@ -75,8 +75,8 @@ class MultilineExample::RenderTextView : public View {
RenderTextView() : render_text_(gfx::RenderText::CreateRenderText()) { RenderTextView() : render_text_(gfx::RenderText::CreateRenderText()) {
render_text_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); render_text_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD);
render_text_->SetMultiline(true); render_text_->SetMultiline(true);
SetBorder(CreateThemedSolidBorder( SetBorder(
2, ExamplesColorIds::kColorMultilineExampleBorder)); CreateSolidBorder(2, ExamplesColorIds::kColorMultilineExampleBorder));
} }
RenderTextView(const RenderTextView&) = delete; RenderTextView(const RenderTextView&) = delete;
@@ -205,7 +205,7 @@ void MultilineExample::CreateExampleView(View* container) {
label_ = container->AddChildView(std::make_unique<PreferredSizeLabel>()); label_ = container->AddChildView(std::make_unique<PreferredSizeLabel>());
label_->SetText(kTestString); label_->SetText(kTestString);
label_->SetMultiLine(true); label_->SetMultiLine(true);
label_->SetBorder(CreateThemedSolidBorder( label_->SetBorder(CreateSolidBorder(
2, ExamplesColorIds::kColorMultilineExampleLabelBorder)); 2, ExamplesColorIds::kColorMultilineExampleLabelBorder));
elision_checkbox_ = container->AddChildView(std::make_unique<Checkbox>( elision_checkbox_ = container->AddChildView(std::make_unique<Checkbox>(

@@ -175,8 +175,8 @@ class VectorIconGallery : public View, public TextfieldController {
image_view_container_->RemoveAllChildViews(); image_view_container_->RemoveAllChildViews();
image_view_ = image_view_ =
image_view_container_->AddChildView(std::make_unique<ImageView>()); image_view_container_->AddChildView(std::make_unique<ImageView>());
image_view_->SetBorder(CreateThemedSolidBorder( image_view_->SetBorder(
1, ExamplesColorIds::kColorVectorExampleImageBorder)); CreateSolidBorder(1, ExamplesColorIds::kColorVectorExampleImageBorder));
auto image_layout = auto image_layout =
std::make_unique<BoxLayout>(BoxLayout::Orientation::kHorizontal); std::make_unique<BoxLayout>(BoxLayout::Orientation::kHorizontal);