Commit 515ed073 authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Rename local kColor constants (browser/ui)

When building using jumbo unnamed namespaces gets merged
and variables with the same name conflict. This happens
for the variables kFooterBackgroundColor and kSeparatorColor
in ui/views/autofill/autofill_popup_view_native_views.cc and
ui/views/passwords/password_generation_popup_view_views.cc.

This commit solves the issue by renaming the constants to
something more file specific. It also renames other variables
in the same namespace, so the naming is locally consistent.

Bug: 773275
Change-Id: I3f71efeaa29eccdbe646e7c2fb512f218c2f010a
Reviewed-on: https://chromium-review.googlesource.com/1118260Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Cr-Commit-Position: refs/heads/master@{#571897}
parent 17031f42
...@@ -41,16 +41,16 @@ namespace { ...@@ -41,16 +41,16 @@ namespace {
// By spec, dropdowns should have a min width of 64, and should always have // By spec, dropdowns should have a min width of 64, and should always have
// a width which is a multiple of 12. // a width which is a multiple of 12.
const int kDropdownWidthMultiple = 12; const int kAutofillPopupDropdownWidthMultiple = 12;
const int kDropdownMinWidth = 64; const int kAutofillPopupDropdownMinWidth = 64;
// TODO(crbug.com/831603): Determine how colors should be shared with menus // TODO(crbug.com/831603): Determine how colors should be shared with menus
// and/or omnibox, and how these should interact (if at all) with native // and/or omnibox, and how these should interact (if at all) with native
// theme colors. // theme colors.
const SkColor kAutofillBackgroundColor = SK_ColorWHITE; const SkColor kAutofillPopupBackgroundColor = SK_ColorWHITE;
const SkColor kSelectedBackgroundColor = gfx::kGoogleGrey200; const SkColor kAutofillPopupSelectedBackgroundColor = gfx::kGoogleGrey200;
const SkColor kFooterBackgroundColor = gfx::kGoogleGrey050; const SkColor kAutofillPopupFooterBackgroundColor = gfx::kGoogleGrey050;
const SkColor kSeparatorColor = gfx::kGoogleGrey200; const SkColor kAutofillPopupSeparatorColor = gfx::kGoogleGrey200;
int GetCornerRadius() { int GetCornerRadius() {
return ChromeLayoutProvider::Get()->GetCornerRadiusMetric( return ChromeLayoutProvider::Get()->GetCornerRadiusMetric(
...@@ -226,7 +226,8 @@ class AutofillPopupSuggestionView : public AutofillPopupItemView { ...@@ -226,7 +226,8 @@ class AutofillPopupSuggestionView : public AutofillPopupItemView {
// AutofillPopupRowView: // AutofillPopupRowView:
std::unique_ptr<views::Background> CreateBackground() override { std::unique_ptr<views::Background> CreateBackground() override {
return views::CreateSolidBackground( return views::CreateSolidBackground(
is_selected_ ? kSelectedBackgroundColor : kAutofillBackgroundColor); is_selected_ ? kAutofillPopupSelectedBackgroundColor
: kAutofillPopupBackgroundColor);
} }
private: private:
...@@ -259,13 +260,14 @@ class AutofillPopupFooterView : public AutofillPopupItemView { ...@@ -259,13 +260,14 @@ class AutofillPopupFooterView : public AutofillPopupItemView {
/*left=*/0, /*left=*/0,
/*bottom=*/0, /*bottom=*/0,
/*right=*/0, /*right=*/0,
/*color=*/kSeparatorColor)); /*color=*/kAutofillPopupSeparatorColor));
AutofillPopupItemView::CreateContent(); AutofillPopupItemView::CreateContent();
} }
std::unique_ptr<views::Background> CreateBackground() override { std::unique_ptr<views::Background> CreateBackground() override {
return views::CreateSolidBackground(is_selected_ ? kSelectedBackgroundColor return views::CreateSolidBackground(
: kFooterBackgroundColor); is_selected_ ? kAutofillPopupSelectedBackgroundColor
: kAutofillPopupFooterBackgroundColor);
} }
private: private:
...@@ -321,7 +323,7 @@ class AutofillPopupSeparatorView : public AutofillPopupRowView { ...@@ -321,7 +323,7 @@ class AutofillPopupSeparatorView : public AutofillPopupRowView {
/*left=*/0, /*left=*/0,
/*bottom=*/views::MenuConfig::instance().separator_thickness, /*bottom=*/views::MenuConfig::instance().separator_thickness,
/*right=*/0, /*right=*/0,
/*color=*/kSeparatorColor)); /*color=*/kAutofillPopupSeparatorColor));
SchedulePaint(); SchedulePaint();
} }
...@@ -384,7 +386,7 @@ AutofillPopupViewNativeViews::AutofillPopupViewNativeViews( ...@@ -384,7 +386,7 @@ AutofillPopupViewNativeViews::AutofillPopupViewNativeViews(
layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START); layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
CreateChildViews(); CreateChildViews();
SetBackground(views::CreateSolidBackground(kAutofillBackgroundColor)); SetBackground(views::CreateSolidBackground(kAutofillPopupBackgroundColor));
} }
AutofillPopupViewNativeViews::~AutofillPopupViewNativeViews() {} AutofillPopupViewNativeViews::~AutofillPopupViewNativeViews() {}
...@@ -411,17 +413,17 @@ gfx::Size AutofillPopupViewNativeViews::CalculatePreferredSize() const { ...@@ -411,17 +413,17 @@ gfx::Size AutofillPopupViewNativeViews::CalculatePreferredSize() const {
gfx::Size size = AutofillPopupBaseView::CalculatePreferredSize(); gfx::Size size = AutofillPopupBaseView::CalculatePreferredSize();
if (contents_width < size.width()) { if (contents_width < size.width()) {
contents_width = size.width(); contents_width = size.width();
// Use multiples of |kDropdownWidthMultiple| if the required width is larger // Use multiples of |kAutofillPopupDropdownWidthMultiple| if the required
// than the element width. // width is larger than the element width.
if (contents_width % kDropdownWidthMultiple) { if (contents_width % kAutofillPopupDropdownWidthMultiple) {
contents_width += contents_width += kAutofillPopupDropdownWidthMultiple -
kDropdownWidthMultiple - (contents_width % kDropdownWidthMultiple); (contents_width % kAutofillPopupDropdownWidthMultiple);
} }
} }
// Notwithstanding all the above rules, enforce a hard minimum so the dropdown // Notwithstanding all the above rules, enforce a hard minimum so the dropdown
// is not too small to interact with. // is not too small to interact with.
size.set_width(std::max(kDropdownMinWidth, contents_width)); size.set_width(std::max(kAutofillPopupDropdownMinWidth, contents_width));
return size; return size;
} }
...@@ -516,7 +518,7 @@ void AutofillPopupViewNativeViews::CreateChildViews() { ...@@ -516,7 +518,7 @@ void AutofillPopupViewNativeViews::CreateChildViews() {
if (has_footer) { if (has_footer) {
views::View* footer_container = new views::View(); views::View* footer_container = new views::View();
footer_container->SetBackground( footer_container->SetBackground(
views::CreateSolidBackground(kFooterBackgroundColor)); views::CreateSolidBackground(kAutofillPopupFooterBackgroundColor));
views::BoxLayout* footer_layout = footer_container->SetLayoutManager( views::BoxLayout* footer_layout = footer_container->SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical)); std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical));
......
...@@ -27,10 +27,11 @@ ...@@ -27,10 +27,11 @@
namespace { namespace {
// Background color of the bottom part of the prompt. // Background color of the bottom part of the prompt.
constexpr SkColor kFooterBackgroundColor = gfx::kGoogleGrey050; constexpr SkColor kPasswordGenerationPopupFooterBackgroundColor =
gfx::kGoogleGrey050;
// Color of the separator between the password and help sections. // Color of the separator between the password and help sections.
constexpr SkColor kSeparatorColor = gfx::kGoogleGrey200; constexpr SkColor kPasswordGenerationPopupSeparatorColor = gfx::kGoogleGrey200;
} // namespace } // namespace
...@@ -190,8 +191,8 @@ void PasswordGenerationPopupViewViews::CreateLayoutAndChildren() { ...@@ -190,8 +191,8 @@ void PasswordGenerationPopupViewViews::CreateLayoutAndChildren() {
link_style.disable_line_wrapping = false; link_style.disable_line_wrapping = false;
help_label->AddStyleRange(controller_->HelpTextLinkRange(), link_style); help_label->AddStyleRange(controller_->HelpTextLinkRange(), link_style);
help_label->SetBackground( help_label->SetBackground(views::CreateSolidBackground(
views::CreateSolidBackground(kFooterBackgroundColor)); kPasswordGenerationPopupFooterBackgroundColor));
help_label->SetBorder( help_label->SetBorder(
views::CreateEmptyBorder(kVerticalPadding, kHorizontalMargin, views::CreateEmptyBorder(kVerticalPadding, kHorizontalMargin,
kVerticalPadding, kHorizontalMargin)); kVerticalPadding, kHorizontalMargin));
...@@ -210,7 +211,7 @@ void PasswordGenerationPopupViewViews::OnPaint(gfx::Canvas* canvas) { ...@@ -210,7 +211,7 @@ void PasswordGenerationPopupViewViews::OnPaint(gfx::Canvas* canvas) {
if (password_view_) { if (password_view_) {
gfx::Rect divider_bounds(0, password_view_->bounds().bottom(), gfx::Rect divider_bounds(0, password_view_->bounds().bottom(),
password_view_->width(), 1); password_view_->width(), 1);
canvas->FillRect(divider_bounds, kSeparatorColor); canvas->FillRect(divider_bounds, kPasswordGenerationPopupSeparatorColor);
} }
} }
......
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