Commit 7f407ad6 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Minor code reorgs in advance of fixing bug 1012136.

* Use temps for some minor repeated expressions, whose calculation will
  get slightly more cumbersome later.
* Other minor code movement to reduce later diffs.

Bug: none
Change-Id: I87d466901608191d9be3ecd0cbeea256e68e2937
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2021462
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737911}
parent 721bad98
......@@ -372,6 +372,7 @@ views::FlexRule BrowserActionsContainer::GetFlexRule() {
static_cast<const BrowserActionsContainer*>(view);
gfx::Size preferred_size = browser_actions->GetPreferredSize();
if (maximum_size.width()) {
const int max_width = *maximum_size.width();
int width;
if (browser_actions->resizing() || browser_actions->animating()) {
// When there are actions present, the floor on the size of the
......@@ -382,11 +383,11 @@ views::FlexRule BrowserActionsContainer::GetFlexRule() {
// The ceiling on the value is the lesser of the preferred and
// available size.
width = base::ClampToRange(preferred_size.width(), min_width,
*maximum_size.width());
max_width);
} else {
// When not animating or resizing, the desired width should always
// be based on the number of icons that can be displayed.
width = browser_actions->GetWidthForMaxWidth(*maximum_size.width());
width = browser_actions->GetWidthForMaxWidth(max_width);
}
preferred_size =
gfx::Size(width, browser_actions->GetHeightForWidth(width));
......
......@@ -1038,12 +1038,11 @@ gfx::Size AnimatingLayoutManager::DefaultFlexRuleImpl(
if (CanFitInBounds(preferred_size, size_bounds))
return preferred_size;
const base::Optional<int> bounds_main =
GetMainAxis(animating_layout->orientation(), size_bounds);
// Special case - if we're being asked for a zero-size layout we'll return the
// minimum size of the layout. This is because we're being probed for how
// small we can get, not being asked for an actual size.
const base::Optional<int> bounds_main =
GetMainAxis(animating_layout->orientation(), size_bounds);
if (bounds_main && *bounds_main <= 0)
return animating_layout->GetMinimumSize(view);
......@@ -1075,10 +1074,11 @@ gfx::Size AnimatingLayoutManager::DefaultFlexRuleImpl(
// TODO(dfried): This should be rare, but it is also inefficient. See if we
// can't add an alternative to GetPreferredHeightForWidth() that actually
// calculates the layout in this space so we don't have to do it twice.
const int height =
target_layout->GetPreferredHeightForWidth(view, *size_bounds.width());
size = gfx::Size(*size_bounds.width(), height);
const int width = *size_bounds.width();
size = gfx::Size(width,
target_layout->GetPreferredHeightForWidth(view, width));
} else {
DCHECK(size_bounds.height());
// The height is specified and too small. Fortunately the height of a
// layout can't (shouldn't?) affect its width.
size = gfx::Size(target_preferred.width(), *size_bounds.height());
......
This diff is collapsed.
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