Commit fbaba9ed authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Set cross-axis space and populate flex map even for unbounded main axis.

This has no visible effect today since the caller does not read either
of these unless the main axis is bounded, but is necessary in the future
to better handle layout in unbounded input cases.  It also feels better
from an API layering perspective since these field are initialized more
consistently, and it's entirely up to the caller what to do with them.

Bug: 1012136
Change-Id: Ibd0f3ac0104a33d1ce156b58a859435be8df999e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2026375
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806847}
parent 026da6f9
...@@ -507,6 +507,7 @@ void FlexLayout::InitializeChildData( ...@@ -507,6 +507,7 @@ void FlexLayout::InitializeChildData(
const base::Optional<int> available_cross = const base::Optional<int> available_cross =
GetAvailableCrossAxisSize(*data, view_index, bounds); GetAvailableCrossAxisSize(*data, view_index, bounds);
SetCrossAxis(&child_layout.available_size, orientation(), available_cross);
flex_child.preferred_size = flex_child.preferred_size =
GetPreferredSizeForRule(flex_child.flex.rule(), child, available_cross); GetPreferredSizeForRule(flex_child.flex.rule(), child, available_cross);
...@@ -516,25 +517,19 @@ void FlexLayout::InitializeChildData( ...@@ -516,25 +517,19 @@ void FlexLayout::InitializeChildData(
flex_child.current_size = flex_child.current_size =
GetCurrentSizeForRule(flex_child.flex.rule(), child, GetCurrentSizeForRule(flex_child.flex.rule(), child,
NormalizedSizeBounds(0, available_cross)); NormalizedSizeBounds(0, available_cross));
SetCrossAxis(&child_layout.available_size, orientation(),
available_cross);
DCHECK_GE(flex_child.preferred_size.main(), DCHECK_GE(flex_child.preferred_size.main(),
flex_child.current_size.main()) flex_child.current_size.main())
<< " in " << child->GetClassName(); << " in " << child->GetClassName();
// Keep track of non-hidden flex controls.
const bool can_flex =
flex_child.flex.weight() > 0 ||
flex_child.current_size.main() < flex_child.preferred_size.main();
if (can_flex)
(*flex_order_to_index)[flex_child.flex.order()].push_back(view_index);
} else { } else {
// All non-flex or unbounded controls get preferred size. // All non-flex or unbounded controls get preferred size.
flex_child.current_size = flex_child.preferred_size; flex_child.current_size = flex_child.preferred_size;
} }
// Keep track of non-hidden flex controls.
if (flex_child.flex.weight() > 0 ||
flex_child.current_size.main() < flex_child.preferred_size.main())
(*flex_order_to_index)[flex_child.flex.order()].push_back(view_index);
child_layout.visible = flex_child.current_size.main() > 0; child_layout.visible = flex_child.current_size.main() > 0;
} }
} }
......
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