Commit c7d8cda0 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[FlexNG] Prefer a baseline from an empty child with baseline alignment.

Previously if a fragment didn't provide a baseline, and had baseline
alignment we wouldn't consider it as having the default baseline.

This was incorrect. Causing fast/css-grid-layout/grid-baseline.html
to fail when FlexNG was turned on:
https://test-results.appspot.com/data/layout_results/linux-rel/294412/webkit_layout_tests%20%28with%20patch%29/layout-test-results/results.html

Instead this patch changes the flex baseline propagation logic to prefer
any flex-item with baseline alignment, even if we have to synthesize
the baseline.

Bug: 845235
Change-Id: I4cc40da42a8d6be41b028f1170246b8004f0654d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024546Reviewed-by: default avatarDavid Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736082}
parent fa85f826
......@@ -856,26 +856,21 @@ void NGFlexLayoutAlgorithm::PropagateBaselineFromChild(
NGBoxFragment fragment(ConstraintSpace().GetWritingMode(),
ConstraintSpace().Direction(), physical_fragment);
if (base::Optional<LayoutUnit> baseline = fragment.Baseline()) {
LayoutUnit baseline_offset = block_offset + *baseline;
// We prefer a baseline from a child with baseline alignment, and no
// auto-margins in the cross axis.
if (FlexLayoutAlgorithm::AlignmentForChild(Style(), flex_item.style) ==
ItemPosition::kBaseline &&
!flex_item.HasAutoMarginsInCrossAxis()) {
container_builder_.SetBaseline(baseline_offset);
return;
}
// Set the fallback baseline to this (if not set yet).
*fallback_baseline = fallback_baseline->value_or(baseline_offset);
LayoutUnit baseline_offset =
block_offset + fragment.Baseline().value_or(fragment.BlockSize());
// We prefer a baseline from a child with baseline alignment, and no
// auto-margins in the cross axis (even if we have to synthesize the
// baseline).
if (FlexLayoutAlgorithm::AlignmentForChild(Style(), flex_item.style) ==
ItemPosition::kBaseline &&
!flex_item.HasAutoMarginsInCrossAxis()) {
container_builder_.SetBaseline(baseline_offset);
return;
}
// Use the block-end border-box edge as the last resort baseline.
*fallback_baseline =
fallback_baseline->value_or(block_offset + fragment.BlockSize());
// Set the fallback baseline if it doesn't have a value yet.
*fallback_baseline = fallback_baseline->value_or(baseline_offset);
}
base::Optional<MinMaxSize> NGFlexLayoutAlgorithm::ComputeMinMaxSize(
......
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