Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2031)

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 2208973003: Add some extra height to bookmark bar if the font wants to be larger (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set a border on the BookmarkInstructionsView instance and update GetPreferredSize() to respect it. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index 884ab3339ad7d9c523d5c869b6a761fe2e16f75a..3d709cbbb9e3365588d472ea155fe4a9a88b01ef 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -172,7 +172,7 @@ static const int kAppsShortcutButtonTag = 2;
// Preferred padding between text and edge.
static const int kButtonPaddingHorizontal = 6;
-static const int kButtonPaddingVertical = 4;
+static const int kButtonPaddingVertical = 5;
static const gfx::ElideBehavior kElideBehavior = gfx::FADE_TAIL;
@@ -843,17 +843,29 @@ int BookmarkBarView::GetToolbarOverlap() const {
size_animation_.GetCurrentValue());
}
+int BookmarkBarView::GetPreferredHeight() const {
+ int height = 0;
+ for (int i = 0; i < child_count(); ++i) {
+ const views::View* view = child_at(i);
+ if (view->visible()) {
+ gfx::Size pref = view->GetPreferredSize();
+ height = std::max(pref.height(), height);
+ }
+ }
+ return std::max(height, chrome::kBookmarkBarHeight);
Evan Stade 2016/08/08 16:10:57 seems like this constant should be renamed to kBoo
kylix_rd 2016/08/08 17:05:23 That should be done in a separate CL. This constan
Evan Stade 2016/08/08 22:48:06 I don't really see why that should split off? It's
kylix_rd 2016/08/09 21:09:13 OK. I can add it to this review and then include t
+}
+
gfx::Size BookmarkBarView::GetPreferredSize() const {
gfx::Size prefsize;
if (IsDetached()) {
+ int padded_height = GetPreferredHeight();
prefsize.set_height(
- chrome::kBookmarkBarHeight +
- static_cast<int>(
- (chrome::kNTPBookmarkBarHeight - chrome::kBookmarkBarHeight) *
- (1 - size_animation_.GetCurrentValue())));
+ padded_height +
+ static_cast<int>((chrome::kNTPBookmarkBarHeight - padded_height) *
+ (1 - size_animation_.GetCurrentValue())));
} else {
- prefsize.set_height(static_cast<int>(chrome::kBookmarkBarHeight *
- size_animation_.GetCurrentValue()));
+ prefsize.set_height(static_cast<int>(GetPreferredHeight()) *
+ size_animation_.GetCurrentValue());
}
return prefsize;
}
@@ -879,7 +891,7 @@ gfx::Size BookmarkBarView::GetMinimumSize() const {
// if they are visible.
int width = GetHorizontalMargin();
- int height = chrome::kBookmarkBarHeight;
+ int height = GetPreferredHeight();
if (IsDetached()) {
double current_state = 1 - size_animation_.GetCurrentValue();
width += 2 * static_cast<int>(kNewTabHorizontalPadding * current_state);
@@ -925,7 +937,7 @@ void BookmarkBarView::Layout() {
int top_margin = IsDetached() ? kDetachedTopMargin : 0;
int y = top_margin;
int width = View::width() - 2 * GetHorizontalMargin();
- int height = chrome::kBookmarkBarHeight - kBottomMargin;
+ int height = GetPreferredHeight() - kBottomMargin;
int separator_margin = kSeparatorMargin;
if (IsDetached()) {
@@ -938,7 +950,7 @@ void BookmarkBarView::Layout() {
// 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
// also matches how we layout infobars.
- y += View::height() - chrome::kBookmarkBarHeight;
+ y += View::height() - GetPreferredHeight();
}
gfx::Size other_bookmarks_pref = other_bookmarks_button_->visible() ?
@@ -1657,6 +1669,8 @@ void BookmarkBarView::Init() {
UpdateBookmarksSeparatorVisibility();
instructions_ = new BookmarkBarInstructionsView(this);
+ instructions_->SetBorder(views::Border::CreateEmptyBorder(
+ kButtonPaddingVertical, 0, kButtonPaddingVertical, 0));
AddChildView(instructions_);
set_context_menu_controller(this);

Powered by Google App Engine
This is Rietveld 408576698