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

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
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8751ad783b4cac8136723fc2ca34bc4d66b69b55..8566c842aae5c24d2abefcbcf2dedda8b86bc9e5 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -541,32 +541,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() {
@@ -780,9 +780,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() {
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698