Commit 5b2fbb09 authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Rename kSeparatorWidth to be unique (browser/ui)

When building using Jumbo unnamed namespaces gets merged
and variables with the same name conflict. This happens
for the variables kSeparatorWidth in:
chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
chrome/browser/ui/views/location_bar/icon_label_bubble_view.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.

Change-Id: I2ae24ce5b67372286a5aa4e48a0bc125606ff778
Reviewed-on: https://chromium-review.googlesource.com/1146641
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577166}
parent 4a92d725
...@@ -123,32 +123,33 @@ using views::MenuButton; ...@@ -123,32 +123,33 @@ using views::MenuButton;
using views::View; using views::View;
// Maximum size of buttons on the bookmark bar. // Maximum size of buttons on the bookmark bar.
static const int kMaxButtonWidth = 150; static const int kBookmarkBarMaxButtonWidth = 150;
// Margins around the content. // Margins around the content.
static const int kDetachedTopMargin = 1; // When attached, we use 0 and let the // When attached, we use 0 and let the
// toolbar above serve as the margin. // toolbar above serve as the margin.
static const int kBottomMargin = 4; static const int kBookmarkBarDetachedTopMargin = 1;
static const int kHorizontalMargin = 8; static const int kBookmarkBarBottomMargin = 4;
static const int kBookmarkBarHorizontalMargin = 8;
// Padding between buttons. // Padding between buttons.
static const int kBookmarkBarButtonPadding = 8; static const int kBookmarkBarButtonPadding = 8;
// Width of the drop indicator. // Width of the drop indicator.
static const int kDropIndicatorWidth = 2; static const int kBookmarkBarDropIndicatorWidth = 2;
// Distance between the bottom of the bar and the separator. // Distance between the bottom of the bar and the separator.
static const int kSeparatorMargin = 1; static const int kBookmarkBarSeparatorMargin = 1;
// Width of the separator between the recently bookmarked button and the // Width of the separator between the recently bookmarked button and the
// overflow indicator. // overflow indicator.
static const int kSeparatorWidth = 9; static const int kBookmarkBarSeparatorWidth = 9;
// Left-padding for the instructional text. // Left-padding for the instructional text.
static const int kInstructionsPadding = 6; static const int kBookmarkBarInstructionsPadding = 6;
// Tag for the 'Apps Shortcut' button. // Tag for the 'Apps Shortcut' button.
static const int kAppsShortcutButtonTag = 2; static const int kBookmarkBarAppsShortcutButtonTag = 2;
namespace { namespace {
...@@ -605,7 +606,7 @@ class BookmarkBarView::ButtonSeparatorView : public views::View { ...@@ -605,7 +606,7 @@ class BookmarkBarView::ButtonSeparatorView : public views::View {
gfx::Size CalculatePreferredSize() const override { gfx::Size CalculatePreferredSize() const override {
// We get the full height of the bookmark bar, so that the height returned // We get the full height of the bookmark bar, so that the height returned
// here doesn't matter. // here doesn't matter.
return gfx::Size(kSeparatorWidth, 1); return gfx::Size(kBookmarkBarSeparatorWidth, 1);
} }
void GetAccessibleNodeData(ui::AXNodeData* node_data) override { void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
...@@ -906,7 +907,7 @@ gfx::Size BookmarkBarView::GetMinimumSize() const { ...@@ -906,7 +907,7 @@ gfx::Size BookmarkBarView::GetMinimumSize() const {
// button, by which one can access all the Bookmark Bar items, and the "Other // button, by which one can access all the Bookmark Bar items, and the "Other
// Bookmarks" folder, along with appropriate margins and button padding. // Bookmarks" folder, along with appropriate margins and button padding.
// It should also contain the Managed Bookmarks folder, if it is visible. // It should also contain the Managed Bookmarks folder, if it is visible.
int width = kHorizontalMargin; int width = kBookmarkBarHorizontalMargin;
int height = GetPreferredHeight(); int height = GetPreferredHeight();
if (IsDetached()) { if (IsDetached()) {
...@@ -944,18 +945,19 @@ void BookmarkBarView::Layout() { ...@@ -944,18 +945,19 @@ void BookmarkBarView::Layout() {
if (!model_) if (!model_)
return; return;
int x = kHorizontalMargin; int x = kBookmarkBarHorizontalMargin;
int top_margin = IsDetached() ? kDetachedTopMargin : 0; int top_margin = IsDetached() ? kBookmarkBarDetachedTopMargin : 0;
int y = top_margin; int y = top_margin;
int width = View::width() - 2 * kHorizontalMargin; int width = View::width() - 2 * kBookmarkBarHorizontalMargin;
int preferred_height = GetPreferredHeight(); int preferred_height = GetPreferredHeight();
int height = preferred_height - kBottomMargin; int height = preferred_height - kBookmarkBarBottomMargin;
int separator_margin = kSeparatorMargin; int separator_margin = kBookmarkBarSeparatorMargin;
if (IsDetached()) { if (IsDetached()) {
double current_state = 1 - size_animation_.GetCurrentValue(); double current_state = 1 - size_animation_.GetCurrentValue();
y += (View::height() - preferred_height) / 2; y += (View::height() - preferred_height) / 2;
separator_margin -= static_cast<int>(kSeparatorMargin * current_state); separator_margin -=
static_cast<int>(kBookmarkBarSeparatorMargin * current_state);
} else { } else {
// For the attached appearance, pin the content to the bottom of the bar // For the attached appearance, pin the content to the bottom of the bar
// when animating in/out, as shrinking its height instead looks weird. This // when animating in/out, as shrinking its height instead looks weird. This
...@@ -971,7 +973,7 @@ void BookmarkBarView::Layout() { ...@@ -971,7 +973,7 @@ void BookmarkBarView::Layout() {
gfx::Size apps_page_shortcut_pref = apps_page_shortcut_->visible() ? gfx::Size apps_page_shortcut_pref = apps_page_shortcut_->visible() ?
apps_page_shortcut_->GetPreferredSize() : gfx::Size(); apps_page_shortcut_->GetPreferredSize() : gfx::Size();
int max_x = kHorizontalMargin + width - overflow_pref.width() - int max_x = kBookmarkBarHorizontalMargin + width - overflow_pref.width() -
bookmarks_separator_pref.width(); bookmarks_separator_pref.width();
if (other_bookmarks_button_->visible()) if (other_bookmarks_button_->visible())
max_x -= other_bookmarks_pref.width() + kBookmarkBarButtonPadding; max_x -= other_bookmarks_pref.width() + kBookmarkBarButtonPadding;
...@@ -999,10 +1001,8 @@ void BookmarkBarView::Layout() { ...@@ -999,10 +1001,8 @@ void BookmarkBarView::Layout() {
if (show_instructions) { if (show_instructions) {
gfx::Size pref = instructions_->GetPreferredSize(); gfx::Size pref = instructions_->GetPreferredSize();
instructions_->SetBounds( instructions_->SetBounds(
x + kInstructionsPadding, y, x + kBookmarkBarInstructionsPadding, y,
std::min(static_cast<int>(pref.width()), std::min(static_cast<int>(pref.width()), max_x - x), height);
max_x - x),
height);
} else { } else {
bool last_visible = x < max_x; bool last_visible = x < max_x;
int button_count = GetBookmarkButtonCount(); int button_count = GetBookmarkButtonCount();
...@@ -1044,11 +1044,9 @@ void BookmarkBarView::Layout() { ...@@ -1044,11 +1044,9 @@ void BookmarkBarView::Layout() {
// Separator. // Separator.
if (bookmarks_separator_view_->visible()) { if (bookmarks_separator_view_->visible()) {
bookmarks_separator_view_->SetBounds(x, bookmarks_separator_view_->SetBounds(
y - top_margin, x, y - top_margin, bookmarks_separator_pref.width(),
bookmarks_separator_pref.width(), height + top_margin + kBookmarkBarBottomMargin - separator_margin);
height + top_margin + kBottomMargin -
separator_margin);
x += bookmarks_separator_pref.width(); x += bookmarks_separator_pref.width();
} }
...@@ -1092,7 +1090,7 @@ void BookmarkBarView::PaintChildren(const views::PaintInfo& paint_info) { ...@@ -1092,7 +1090,7 @@ void BookmarkBarView::PaintChildren(const views::PaintInfo& paint_info) {
int h = height(); int h = height();
if (index == GetBookmarkButtonCount()) { if (index == GetBookmarkButtonCount()) {
if (index == 0) { if (index == 0) {
x = kHorizontalMargin; x = kBookmarkBarHorizontalMargin;
} else { } else {
x = GetBookmarkButton(index - 1)->x() + x = GetBookmarkButton(index - 1)->x() +
GetBookmarkButton(index - 1)->width(); GetBookmarkButton(index - 1)->width();
...@@ -1107,8 +1105,9 @@ void BookmarkBarView::PaintChildren(const views::PaintInfo& paint_info) { ...@@ -1107,8 +1105,9 @@ void BookmarkBarView::PaintChildren(const views::PaintInfo& paint_info) {
// Since the drop indicator is painted directly onto the canvas, we must // Since the drop indicator is painted directly onto the canvas, we must
// make sure it is painted in the right location if the locale is RTL. // make sure it is painted in the right location if the locale is RTL.
gfx::Rect indicator_bounds = GetMirroredRect( gfx::Rect indicator_bounds =
gfx::Rect(x - kDropIndicatorWidth / 2, y, kDropIndicatorWidth, h)); GetMirroredRect(gfx::Rect(x - kBookmarkBarDropIndicatorWidth / 2, y,
kBookmarkBarDropIndicatorWidth, h));
ui::PaintRecorder recorder(paint_info.context(), size()); ui::PaintRecorder recorder(paint_info.context(), size());
// TODO(sky/glen): make me pretty! // TODO(sky/glen): make me pretty!
...@@ -1544,7 +1543,7 @@ void BookmarkBarView::ButtonPressed(views::Button* sender, ...@@ -1544,7 +1543,7 @@ void BookmarkBarView::ButtonPressed(views::Button* sender,
WindowOpenDisposition disposition_from_event_flags = WindowOpenDisposition disposition_from_event_flags =
ui::DispositionFromEventFlags(event.flags()); ui::DispositionFromEventFlags(event.flags());
if (sender->tag() == kAppsShortcutButtonTag) { if (sender->tag() == kBookmarkBarAppsShortcutButtonTag) {
OpenURLParams params(GURL(chrome::kChromeUIAppsURL), OpenURLParams params(GURL(chrome::kChromeUIAppsURL),
Referrer(), Referrer(),
disposition_from_event_flags, disposition_from_event_flags,
...@@ -1756,7 +1755,7 @@ views::LabelButton* BookmarkBarView::CreateAppsPageShortcutButton() { ...@@ -1756,7 +1755,7 @@ views::LabelButton* BookmarkBarView::CreateAppsPageShortcutButton() {
button->SetImage(views::Button::STATE_NORMAL, button->SetImage(views::Button::STATE_NORMAL,
*GetImageSkiaNamed(IDR_BOOKMARK_BAR_APPS_SHORTCUT)); *GetImageSkiaNamed(IDR_BOOKMARK_BAR_APPS_SHORTCUT));
button->set_context_menu_controller(this); button->set_context_menu_controller(this);
button->set_tag(kAppsShortcutButtonTag); button->set_tag(kBookmarkBarAppsShortcutButtonTag);
return button; return button;
} }
...@@ -1810,7 +1809,7 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node, ...@@ -1810,7 +1809,7 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node,
button->SetImage(views::Button::STATE_NORMAL, favicon); button->SetImage(views::Button::STATE_NORMAL, favicon);
} }
button->SetMaxSize(gfx::Size(kMaxButtonWidth, 0)); button->SetMaxSize(gfx::Size(kBookmarkBarMaxButtonWidth, 0));
} }
bool BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model, bool BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model,
......
...@@ -32,15 +32,15 @@ namespace { ...@@ -32,15 +32,15 @@ namespace {
// Amount of space reserved for the separator that appears after the icon or // Amount of space reserved for the separator that appears after the icon or
// label. // label.
constexpr int kSeparatorWidth = 1; constexpr int kIconLabelBubbleSeparatorWidth = 1;
// Amount of space on either side of the separator that appears after the icon // Amount of space on either side of the separator that appears after the icon
// or label. // or label.
constexpr int kSpaceBesideSeparator = 8; constexpr int kIconLabelBubbleSpaceBesideSeparator = 8;
// The length of the separator's fade animation. These values are empirical. // The length of the separator's fade animation. These values are empirical.
constexpr int kFadeInDurationMs = 250; constexpr int kIconLabelBubbleFadeInDurationMs = 250;
constexpr int kFadeOutDurationMs = 175; constexpr int kIconLabelBubbleFadeOutDurationMs = 175;
} // namespace } // namespace
...@@ -79,13 +79,13 @@ void IconLabelBubbleView::SeparatorView::UpdateOpacity() { ...@@ -79,13 +79,13 @@ void IconLabelBubbleView::SeparatorView::UpdateOpacity() {
// separator should fade out. // separator should fade out.
views::InkDropState state = ink_drop->GetTargetInkDropState(); views::InkDropState state = ink_drop->GetTargetInkDropState();
float opacity = 0.0f; float opacity = 0.0f;
float duration = kFadeOutDurationMs; float duration = kIconLabelBubbleFadeOutDurationMs;
if (!ink_drop->IsHighlightFadingInOrVisible() && if (!ink_drop->IsHighlightFadingInOrVisible() &&
(state == views::InkDropState::HIDDEN || (state == views::InkDropState::HIDDEN ||
state == views::InkDropState::ACTION_TRIGGERED || state == views::InkDropState::ACTION_TRIGGERED ||
state == views::InkDropState::DEACTIVATED)) { state == views::InkDropState::DEACTIVATED)) {
opacity = 1.0f; opacity = 1.0f;
duration = kFadeInDurationMs; duration = kIconLabelBubbleFadeInDurationMs;
} }
if (!layer()) if (!layer())
...@@ -437,13 +437,14 @@ int IconLabelBubbleView::GetInternalSpacing() const { ...@@ -437,13 +437,14 @@ int IconLabelBubbleView::GetInternalSpacing() const {
int IconLabelBubbleView::GetPrefixedSeparatorWidth() const { int IconLabelBubbleView::GetPrefixedSeparatorWidth() const {
return ShouldShowSeparator() || ShouldShowExtraEndSpace() return ShouldShowSeparator() || ShouldShowExtraEndSpace()
? kSeparatorWidth + kSpaceBesideSeparator ? kIconLabelBubbleSeparatorWidth +
kIconLabelBubbleSpaceBesideSeparator
: 0; : 0;
} }
int IconLabelBubbleView::GetEndPadding() const { int IconLabelBubbleView::GetEndPadding() const {
if (ShouldShowSeparator()) if (ShouldShowSeparator())
return kSpaceBesideSeparator; return kIconLabelBubbleSpaceBesideSeparator;
return GetInsets().right(); return GetInsets().right();
} }
......
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