Chromium Code Reviews| 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 7bf9b8c076c591b7dd1de2f6653ef8387f359755..bf2f3ab703f2adebb7c5c4dd872e053813c20b85 100644 |
| --- a/chrome/browser/ui/views/toolbar/toolbar_view.cc |
| +++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc |
| @@ -612,22 +612,34 @@ void ToolbarView::Layout() { |
| theme_provider->GetDisplayProperty( |
| ThemeProperties::PROPERTY_TOOLBAR_VIEW_STANDARD_SPACING); |
| - int browser_actions_width = browser_actions_->GetPreferredSize().width(); |
| + int browser_actions_desired_width = |
| + browser_actions_->GetPreferredSize().width(); |
| int app_menu_width = app_menu_->GetPreferredSize().width(); |
| const int right_edge_spacing = theme_provider->GetDisplayProperty( |
| ThemeProperties::PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING); |
| const int location_bar_right_padding = theme_provider->GetDisplayProperty( |
| ThemeProperties::PROPERTY_TOOLBAR_VIEW_LOCATION_BAR_RIGHT_PADDING); |
| + |
| + // Don't allow the omnibox to shrink to the point of non-existence, so |
| + // subtract its minimum width from the available width to reserve it. |
| + int minimum_location_bar_width = location_bar_->GetMinimumSize().width(); |
| int available_width = std::max( |
| - 0, width() - right_edge_spacing - app_menu_width - browser_actions_width - |
| - (browser_actions_width > 0 ? element_padding : 0) - |
| - location_bar_right_padding - next_element_x); |
| + 0, width() - right_edge_spacing - app_menu_width - |
| + (browser_actions_desired_width > 0 ? element_padding : 0) - |
| + location_bar_right_padding - next_element_x - |
| + minimum_location_bar_width); |
| + int browser_actions_width = |
| + std::min(available_width, browser_actions_desired_width); |
| + available_width -= browser_actions_width; |
| + // The location bar takes whatever's left, plus the minimum width we "set |
| + // aside" above. |
|
Peter Kasting
2015/09/17 00:18:04
This helps, but I think instead of subtracting the
Devlin
2015/09/17 17:00:27
Done.
|
| + int location_bar_width = minimum_location_bar_width + available_width; |
| int location_height = location_bar_->GetPreferredSize().height(); |
| int location_y = CenteredChildY(height(), location_height); |
| location_bar_->SetBounds(next_element_x, location_y, |
| - std::max(available_width, 0), location_height); |
| + location_bar_width, location_height); |
| next_element_x = location_bar_->bounds().right() + location_bar_right_padding; |
| browser_actions_->SetBounds( |