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

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_view.cc

Issue 271013002: Compute minimum widths for the toolbar components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/toolbar/toolbar_view.cc
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
index a271814dd299ad1ef2a94d41e986c09c25a21d48..7e4a3ffc1a96135cb5a6ad1a8d6879a661f5f6ed 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -537,32 +537,32 @@ bool ToolbarView::GetAcceleratorForCommandId(int command_id,
gfx::Size ToolbarView::GetPreferredSize() {
gfx::Size size(location_bar_->GetPreferredSize());
if (is_display_mode_normal()) {
- size.Enlarge(
- kLeftEdgeSpacing + back_->GetPreferredSize().width() +
- forward_->GetPreferredSize().width() +
- reload_->GetPreferredSize().width() + kStandardSpacing +
- (show_home_button_.GetValue() ?
- home_->GetPreferredSize().width() : 0) +
- (origin_chip_view_->visible() ?
- (origin_chip_view_->GetPreferredSize().width() +
- 2 * kStandardSpacing) :
- 0) +
- browser_actions_->GetPreferredSize().width() +
- app_menu_->GetPreferredSize().width() + kRightEdgeSpacing,
- 0);
- gfx::ImageSkia* normal_background =
- GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);
- size.SetToMax(
- gfx::Size(0, normal_background->height() - content_shadow_height()));
- } else {
- const int kPopupBottomSpacingGlass = 1;
- const int kPopupBottomSpacingNonGlass = 2;
- size.Enlarge(
- 0,
- PopupTopSpacing() + (GetWidget()->ShouldWindowContentsBeTransparent() ?
- kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass));
+ int content_width = kLeftEdgeSpacing + back_->GetPreferredSize().width() +
+ forward_->GetPreferredSize().width() +
+ reload_->GetPreferredSize().width() +
+ (show_home_button_.GetValue() ? home_->GetPreferredSize().width() : 0) +
+ kStandardSpacing + browser_actions_->GetPreferredSize().width() +
+ app_menu_->GetPreferredSize().width() + kRightEdgeSpacing;
+ content_width += origin_chip_view_->visible() ?
+ (origin_chip_view_->GetPreferredSize().width() + kStandardSpacing) : 0;
+ size.Enlarge(content_width, 0);
}
- return size;
+ return SizeForContentSize(size);
+}
+
+gfx::Size ToolbarView::GetMinimumSize() {
+ gfx::Size size(location_bar_->GetMinimumSize());
+ if (is_display_mode_normal()) {
+ int content_width = kLeftEdgeSpacing + back_->GetMinimumSize().width() +
+ forward_->GetMinimumSize().width() + reload_->GetMinimumSize().width() +
+ (show_home_button_.GetValue() ? home_->GetMinimumSize().width() : 0) +
+ kStandardSpacing + browser_actions_->GetMinimumSize().width() +
+ app_menu_->GetMinimumSize().width() + kRightEdgeSpacing;
+ content_width += origin_chip_view_->visible() ?
+ (origin_chip_view_->GetMinimumSize().width() + kStandardSpacing) : 0;
+ size.Enlarge(content_width, 0);
+ }
+ return SizeForContentSize(size);
}
void ToolbarView::Layout() {
@@ -776,9 +776,25 @@ bool ToolbarView::ShouldShowIncompatibilityWarning() {
int ToolbarView::PopupTopSpacing() const {
const int kPopupTopSpacingNonGlass = 3;
- return GetWidget()->ShouldWindowContentsBeTransparent()
- ? 0
- : kPopupTopSpacingNonGlass;
+ return GetWidget()->ShouldWindowContentsBeTransparent() ?
+ 0 : kPopupTopSpacingNonGlass;
+}
+
+gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const {
+ if (is_display_mode_normal()) {
+ gfx::ImageSkia* normal_background =
+ GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);
+ size.SetToMax(
+ gfx::Size(0, normal_background->height() - content_shadow_height()));
+ } else {
+ const int kPopupBottomSpacingGlass = 1;
+ const int kPopupBottomSpacingNonGlass = 2;
+ size.Enlarge(
+ 0,
+ PopupTopSpacing() + (GetWidget()->ShouldWindowContentsBeTransparent() ?
+ kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass));
+ }
+ return size;
}
void ToolbarView::LoadImages() {

Powered by Google App Engine
This is Rietveld 408576698