Commit 04faa46e authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Fix extension icon container resizing getting stuck at 0

In BrowserActionsContainer::GetFlexRule() the width is clamped between
a min width and a max width. If the min width is > max width it should
still win. This CL ensures this behaviour in the boundary condition and
fixes a bug where resizing the extension icons in the toolbar to 0 would
not be able to be reversed.

Before: https://bugs.chromium.org/p/chromium/issues/attachment?aid=439709&signed_aid=C2ncXrrBkAc-NH_GjVaSmg==&inline=1
After: https://bugs.chromium.org/p/chromium/issues/attachment?aid=439710&signed_aid=9D3JktJW8DssKm2eMOvAYg==&inline=1

Bug: 1066337
Change-Id: I6602673fdefb84ee0a3c2b1eaa728238d3175573
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2128039
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Auto-Submit: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754806}
parent 58ad1463
...@@ -371,7 +371,6 @@ views::FlexRule BrowserActionsContainer::GetFlexRule() { ...@@ -371,7 +371,6 @@ views::FlexRule BrowserActionsContainer::GetFlexRule() {
static_cast<const BrowserActionsContainer*>(view); static_cast<const BrowserActionsContainer*>(view);
gfx::Size preferred_size = browser_actions->GetPreferredSize(); gfx::Size preferred_size = browser_actions->GetPreferredSize();
if (maximum_size.width()) { if (maximum_size.width()) {
const int max_width = *maximum_size.width();
int width; int width;
if (browser_actions->resizing() || browser_actions->animating()) { if (browser_actions->resizing() || browser_actions->animating()) {
// When there are actions present, the floor on the size of the // When there are actions present, the floor on the size of the
...@@ -379,14 +378,15 @@ views::FlexRule BrowserActionsContainer::GetFlexRule() { ...@@ -379,14 +378,15 @@ views::FlexRule BrowserActionsContainer::GetFlexRule() {
const int min_width = browser_actions->num_toolbar_actions() == 0 const int min_width = browser_actions->num_toolbar_actions() == 0
? 0 ? 0
: browser_actions->GetResizeAreaWidth(); : browser_actions->GetResizeAreaWidth();
// The ceiling on the value is the lesser of the preferred and // If the provided maximum width is too small even for |min_width|,
// available size. // |min_width| takes precedence.
const int max_width = std::max(min_width, *maximum_size.width());
width = base::ClampToRange(preferred_size.width(), min_width, width = base::ClampToRange(preferred_size.width(), min_width,
max_width); max_width);
} else { } else {
// When not animating or resizing, the desired width should always // When not animating or resizing, the desired width should always
// be based on the number of icons that can be displayed. // be based on the number of icons that can be displayed.
width = browser_actions->GetWidthForMaxWidth(max_width); width = browser_actions->GetWidthForMaxWidth(*maximum_size.width());
} }
preferred_size = preferred_size =
gfx::Size(width, browser_actions->GetHeightForWidth(width)); gfx::Size(width, browser_actions->GetHeightForWidth(width));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment