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

Unified Diff: chrome/browser/ui/views/toolbar/browser_actions_container.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/browser_actions_container.cc
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
index 6e24af64c0a6ee3ba8fd40e6e67554b4291b3203..748d84b1bb7905050fc687931783440d8cc4a27a 100644
--- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc
+++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
@@ -208,19 +208,23 @@ void BrowserActionsContainer::RemoveObserver(
}
gfx::Size BrowserActionsContainer::GetPreferredSize() {
- if (browser_action_views_.empty())
- return gfx::Size(ToolbarView::kStandardSpacing, 0);
-
// We calculate the size of the view by taking the current width and
// subtracting resize_amount_ (the latter represents how far the user is
// resizing the view or, if animating the snapping, how far to animate it).
// But we also clamp it to a minimum size and the maximum size, so that the
// container can never shrink too far or take up more space than it needs. In
- // other words: ContainerMinSize() < width() - resize < ClampTo(MAX).
- int clamped_width = std::min(
- std::max(ContainerMinSize(), container_width_ - resize_amount_),
+ // other words: MinimumNonemptyWidth() < width() - resize < ClampTo(MAX).
+ int preferred_width = std::min(
+ std::max(MinimumNonemptyWidth(), container_width_ - resize_amount_),
IconCountToWidth(-1, false));
- return gfx::Size(clamped_width, 0);
+ // Height will be ignored by the ToolbarView.
+ return gfx::Size(preferred_width, 0);
+}
+
+gfx::Size BrowserActionsContainer::GetMinimumSize() {
+ int min_width = std::min(MinimumNonemptyWidth(), IconCountToWidth(-1, false));
+ // Height will be ignored by the ToolbarView.
+ return gfx::Size(min_width, 0);
}
void BrowserActionsContainer::Layout() {
@@ -853,7 +857,7 @@ size_t BrowserActionsContainer::WidthToIconCount(int pixels) const {
std::max(0, available_space + kItemSpacing) / IconWidth(true));
}
-int BrowserActionsContainer::ContainerMinSize() const {
+int BrowserActionsContainer::MinimumNonemptyWidth() const {
return ToolbarView::kStandardSpacing + kChevronSpacing +
chevron_->GetPreferredSize().width() + ToolbarView::kStandardSpacing;
}
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_actions_container.h ('k') | chrome/browser/ui/views/toolbar/toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698