Commit 36b4a246 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

Grid: Clean-up TODOs and remove extra call to ComputeTrackSizesForDefiniteSize.

This patch clean-up some unnecessary TODOs, and updates the code to
remove an extra call to ComputeTrackSizes, which was introduced by the
intrinsic-size patch earlier.

R=rego@igalia.com, chrishtr@chromium.org

Change-Id: Ie6c521ec0ca8f53b97fb84a0c62d7f4cfbdc0e5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1897907Reviewed-by: default avatarManuel Rego <rego@igalia.com>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712436}
parent 87851b71
...@@ -319,6 +319,7 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) { ...@@ -319,6 +319,7 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) {
// 2- Next, the track sizing algorithm resolves the sizes of the grid rows, // 2- Next, the track sizing algorithm resolves the sizes of the grid rows,
// using the grid column sizes calculated in the previous step. // using the grid column sizes calculated in the previous step.
bool recompute_with_track_based_height = false;
if (CachedHasDefiniteLogicalHeight()) { if (CachedHasDefiniteLogicalHeight()) {
ComputeTrackSizesForDefiniteSize( ComputeTrackSizesForDefiniteSize(
kForRows, AvailableLogicalHeight(kExcludeMarginBorderPadding)); kForRows, AvailableLogicalHeight(kExcludeMarginBorderPadding));
...@@ -327,13 +328,14 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) { ...@@ -327,13 +328,14 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) {
OverrideIntrinsicContentLogicalHeight()); OverrideIntrinsicContentLogicalHeight());
} else { } else {
ComputeTrackSizesForIndefiniteSize(track_sizing_algorithm_, kForRows); ComputeTrackSizesForIndefiniteSize(track_sizing_algorithm_, kForRows);
if (ShouldApplySizeContainment())
recompute_with_track_based_height = true;
} }
LayoutUnit track_based_logical_height = LayoutUnit track_based_logical_height =
track_sizing_algorithm_.ComputeTrackBasedSize() + track_sizing_algorithm_.ComputeTrackBasedSize() +
BorderAndPaddingLogicalHeight(); BorderAndPaddingLogicalHeight();
if (!CachedHasDefiniteLogicalHeight() && ShouldApplySizeContainment()) { if (recompute_with_track_based_height)
ComputeTrackSizesForDefiniteSize(kForRows, track_based_logical_height); ComputeTrackSizesForDefiniteSize(kForRows, track_based_logical_height);
}
// TODO(rego): We shouldn't need this once crbug.com/906530 is fixed. // TODO(rego): We shouldn't need this once crbug.com/906530 is fixed.
// Right now we need this because // Right now we need this because
...@@ -582,9 +584,9 @@ size_t LayoutGrid::ComputeAutoRepeatTracksCount( ...@@ -582,9 +584,9 @@ size_t LayoutGrid::ComputeAutoRepeatTracksCount(
base::Optional<LayoutUnit> available_size) const { base::Optional<LayoutUnit> available_size) const {
DCHECK(!available_size || available_size.value() != -1); DCHECK(!available_size || available_size.value() != -1);
bool is_row_axis = direction == kForColumns; bool is_row_axis = direction == kForColumns;
// TODO(vmpstr): If we have available_size or min-size specified (as // Since auto-fit collapses empty tracks, and contain: size dictates that
// determined below), then should still repeat tracks to fill the available // children should be ignored for the purposes of layout, we can conclude that
// space. // if these conditions hold we have 0 repetitions.
if (ShouldApplySizeContainment() && if (ShouldApplySizeContainment() &&
((is_row_axis && ((is_row_axis &&
StyleRef().GridAutoRepeatColumnsType() == AutoRepeatType::kAutoFit) || StyleRef().GridAutoRepeatColumnsType() == AutoRepeatType::kAutoFit) ||
...@@ -646,11 +648,10 @@ size_t LayoutGrid::ComputeAutoRepeatTracksCount( ...@@ -646,11 +648,10 @@ size_t LayoutGrid::ComputeAutoRepeatTracksCount(
: AdjustContentBoxLogicalHeightForBoxSizing(min_size_value); : AdjustContentBoxLogicalHeightForBoxSizing(min_size_value);
} }
// We can treat the intrinsic-size similar to min-size when filling the // See https://drafts.csswg.org/css-grid/#auto-repeat for explanation of why
// remainder of space. That is, we should fill the intrinsic size fully. // we use needs_to_fulfill_minimum_size. Note that we can treat the
// TODO(vmpstr): What happens in cases where max_size is specified but is // intrinsic-size similar to min-size when filling the remainder of space.
// smaller than min_size? The grid container would be sized to min_size but // That is, we should fill the intrinsic size fully.
// needs_to_fulfill_minimum_size below would be false.
if (!max_size.IsSpecified() && if (!max_size.IsSpecified() &&
(min_size.IsSpecified() || intrinsic_size_override)) { (min_size.IsSpecified() || intrinsic_size_override)) {
needs_to_fulfill_minimum_size = true; needs_to_fulfill_minimum_size = true;
......
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