From 30b1983069ad159510f9e5d66daccff009e8b258 Mon Sep 17 00:00:00 2001 From: Ian Kilpatrick Date: Mon, 16 Nov 2020 19:12:44 +0000 Subject: [PATCH] [GridNG] Allow stretching in block-axis. This block-stretching logic as: https://chromium-review.googlesource.com/c/chromium/src/+/2513771 ... did for the inline-axis. Previously we didn't have the concept of "stretching" the block-axis instead relying on the parent layout algorithm to set a fixed block-size. This allow stretching (similar to the inline-dimension). The failing tests (which I'll update in the test expectations) are due to this specification issue: https://github.com/w3c/csswg-drafts/issues/5713 The changes in layout_replaced.cc are needed to transfer the stretched size through the aspect-ratio. Bug: 1045599 Change-Id: Ifdd8653d81a1ead84a0afbf5ebd31ba0b75dc8ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523743 Commit-Queue: Ian Kilpatrick Reviewed-by: Kurt Catti-Schmidt Reviewed-by: David Grogan Reviewed-by: Morten Stenshorne Cr-Commit-Position: refs/heads/master@{#827854} GitOrigin-RevId: eaff997ccac677831d0a3c72e638ddf6528276d7 --- .../core/layout/box_layout_extra_input.h | 4 +++ blink/renderer/core/layout/layout_box.cc | 20 +++++++++-- blink/renderer/core/layout/layout_box.h | 8 ++--- blink/renderer/core/layout/layout_replaced.cc | 7 ++-- .../ng/grid/ng_grid_layout_algorithm.cc | 8 +---- .../layout/ng/ng_block_layout_algorithm.cc | 3 +- .../renderer/core/layout/ng/ng_block_node.cc | 4 +++ .../layout/ng/ng_column_layout_algorithm.cc | 9 +++-- .../core/layout/ng/ng_constraint_space.h | 8 ++++- .../layout/ng/ng_constraint_space_builder.h | 12 ++++++- .../core/layout/ng/ng_layout_utils.cc | 7 +++- .../core/layout/ng/ng_length_utils.cc | 31 +++++++++------- .../renderer/core/layout/ng/ng_length_utils.h | 4 ++- .../core/layout/ng/ng_length_utils_test.cc | 3 -- blink/web_tests/TestExpectations | 36 +++++++------------ ...nment-with-aspect-ratio-001.tentative.html | 8 +++++ ...nment-with-aspect-ratio-002.tentative.html | 8 +++++ ...nment-with-aspect-ratio-003.tentative.html | 8 +++++ 18 files changed, 124 insertions(+), 64 deletions(-) create mode 100644 blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-001.tentative.html create mode 100644 blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-002.tentative.html create mode 100644 blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-003.tentative.html diff --git a/blink/renderer/core/layout/box_layout_extra_input.h b/blink/renderer/core/layout/box_layout_extra_input.h index 0fd51ae4091c..d3ad120bd294 100644 --- a/blink/renderer/core/layout/box_layout_extra_input.h +++ b/blink/renderer/core/layout/box_layout_extra_input.h @@ -33,6 +33,10 @@ struct BoxLayoutExtraInput { // purposes of percent block-size resolution. bool is_override_block_size_definite = true; + // If an 'auto' inline/block-size should stretch to the available size. + bool stretch_inline_size_if_auto = false; + bool stretch_block_size_if_auto = false; + // Available inline size. https://drafts.csswg.org/css-sizing/#available LayoutUnit available_inline_size; diff --git a/blink/renderer/core/layout/layout_box.cc b/blink/renderer/core/layout/layout_box.cc index 64661d67daf2..780b6a2a5fe7 100644 --- a/blink/renderer/core/layout/layout_box.cc +++ b/blink/renderer/core/layout/layout_box.cc @@ -2042,6 +2042,16 @@ bool LayoutBox::IsOverrideLogicalHeightDefinite() const { return extra_input_ && extra_input_->is_override_block_size_definite; } +bool LayoutBox::StretchInlineSizeIfAuto() const { + NOT_DESTROYED(); + return extra_input_ && extra_input_->stretch_inline_size_if_auto; +} + +bool LayoutBox::StretchBlockSizeIfAuto() const { + NOT_DESTROYED(); + return extra_input_ && extra_input_->stretch_block_size_if_auto; +} + bool LayoutBox::HasOverrideLogicalHeight() const { NOT_DESTROYED(); if (extra_input_ && extra_input_->override_block_size) @@ -5048,12 +5058,15 @@ LayoutUnit LayoutBox::ComputeReplacedLogicalWidthRespectingMinMaxWidth( LayoutUnit LayoutBox::ComputeReplacedLogicalWidthUsing( SizeType size_type, - const Length& logical_width) const { + Length logical_width) const { NOT_DESTROYED(); DCHECK(size_type == kMinSize || size_type == kMainOrPreferredSize || !logical_width.IsAuto()); if (size_type == kMinSize && logical_width.IsAuto()) return AdjustContentBoxLogicalWidthForBoxSizing(LayoutUnit()); + if (size_type == kMainOrPreferredSize && logical_width.IsAuto() && + StretchInlineSizeIfAuto()) + logical_width = Length::FillAvailable(); switch (logical_width.GetType()) { case Length::kFixed: @@ -5176,12 +5189,15 @@ LayoutUnit LayoutBox::ComputeReplacedLogicalHeightRespectingMinMaxHeight( LayoutUnit LayoutBox::ComputeReplacedLogicalHeightUsing( SizeType size_type, - const Length& logical_height) const { + Length logical_height) const { NOT_DESTROYED(); DCHECK(size_type == kMinSize || size_type == kMainOrPreferredSize || !logical_height.IsAuto()); if (size_type == kMinSize && logical_height.IsAuto()) return AdjustContentBoxLogicalHeightForBoxSizing(LayoutUnit()); + if (size_type == kMainOrPreferredSize && logical_height.IsAuto() && + StretchBlockSizeIfAuto()) + logical_height = Length::FillAvailable(); switch (logical_height.GetType()) { case Length::kFixed: diff --git a/blink/renderer/core/layout/layout_box.h b/blink/renderer/core/layout/layout_box.h index a76085800212..523843771f8c 100644 --- a/blink/renderer/core/layout/layout_box.h +++ b/blink/renderer/core/layout/layout_box.h @@ -1010,6 +1010,8 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject { LayoutUnit OverrideLogicalHeight() const; LayoutUnit OverrideLogicalWidth() const; bool IsOverrideLogicalHeightDefinite() const; + bool StretchInlineSizeIfAuto() const; + bool StretchBlockSizeIfAuto() const; bool HasOverrideLogicalHeight() const; bool HasOverrideLogicalWidth() const; void SetOverrideLogicalHeight(LayoutUnit); @@ -1400,13 +1402,11 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject { SizeType, const Length& height, LayoutUnit intrinsic_content_height) const; - LayoutUnit ComputeReplacedLogicalWidthUsing(SizeType, - const Length& width) const; + LayoutUnit ComputeReplacedLogicalWidthUsing(SizeType, Length width) const; LayoutUnit ComputeReplacedLogicalWidthRespectingMinMaxWidth( LayoutUnit logical_width, ShouldComputePreferred = kComputeActual) const; - LayoutUnit ComputeReplacedLogicalHeightUsing(SizeType, - const Length& height) const; + LayoutUnit ComputeReplacedLogicalHeightUsing(SizeType, Length height) const; LayoutUnit ComputeReplacedLogicalHeightRespectingMinMaxHeight( LayoutUnit logical_height) const; diff --git a/blink/renderer/core/layout/layout_replaced.cc b/blink/renderer/core/layout/layout_replaced.cc index 70e8a5fbedbd..2de36b641f2c 100644 --- a/blink/renderer/core/layout/layout_replaced.cc +++ b/blink/renderer/core/layout/layout_replaced.cc @@ -133,7 +133,7 @@ void LayoutReplaced::Paint(const PaintInfo& paint_info) const { bool LayoutReplaced::HasReplacedLogicalHeight() const { NOT_DESTROYED(); if (StyleRef().LogicalHeight().IsAuto()) - return false; + return StretchBlockSizeIfAuto(); if (StyleRef().LogicalHeight().IsSpecified()) { if (HasAutoHeightOrContainingBlockWithAutoHeight()) @@ -762,7 +762,7 @@ LayoutUnit LayoutReplaced::ComputeConstrainedLogicalWidth( LayoutUnit LayoutReplaced::ComputeReplacedLogicalWidth( ShouldComputePreferred should_compute_preferred) const { NOT_DESTROYED(); - if (!StyleRef().LogicalWidth().IsAuto()) { + if (!StyleRef().LogicalWidth().IsAuto() || StretchInlineSizeIfAuto()) { return ComputeReplacedLogicalWidthRespectingMinMaxWidth( ComputeReplacedLogicalWidthUsing(kMainOrPreferredSize, StyleRef().LogicalWidth()), @@ -778,7 +778,8 @@ LayoutUnit LayoutReplaced::ComputeReplacedLogicalWidth( ConstrainIntrinsicSizeToMinMax(intrinsic_sizing_info); if (StyleRef().LogicalWidth().IsAuto()) { - bool computed_height_is_auto = StyleRef().LogicalHeight().IsAuto(); + bool computed_height_is_auto = + StyleRef().LogicalHeight().IsAuto() && !StretchBlockSizeIfAuto(); // If 'height' and 'width' both have computed values of 'auto' and the // element also has an intrinsic width, then that intrinsic width is the diff --git a/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc b/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc index f6b9dd529257..fad3817179f7 100644 --- a/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc +++ b/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc @@ -1201,14 +1201,8 @@ void NGGridLayoutAlgorithm::PlaceGridItem(const GridItemData& grid_item, builder.SetAvailableSize(size); builder.SetPercentageResolutionSize(size); - // TODO(ikilpatrick): We need a slightly different constraint space API now. - // Instead of a "shrink-to-fit" bit, we should have a "is-stretched" bit to - // indicate if 'auto' should stretch to fill the available space. This should - // apply to both the inline, and block axis. E.g. - // IsInlineSizeStretched / IsBlockSizeStretched or similar. - builder.SetIsFixedBlockSize(item_style.LogicalHeight().IsAuto() && - grid_item.is_block_axis_stretched); builder.SetStretchInlineSizeIfAuto(grid_item.is_inline_axis_stretched); + builder.SetStretchBlockSizeIfAuto(grid_item.is_block_axis_stretched); scoped_refptr result = grid_item.node.Layout(builder.ToConstraintSpace()); diff --git a/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc b/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc index 07d9a502377c..f63ddf126211 100644 --- a/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc +++ b/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc @@ -2522,7 +2522,8 @@ NGConstraintSpace NGBlockLayoutAlgorithm::CreateConstraintSpaceForChild( if (IsParallelWritingMode(ConstraintSpace().GetWritingMode(), child_writing_direction.GetWritingMode())) { - if (!child.GetLayoutBox()->AutoWidthShouldFitContent()) + if (!child.GetLayoutBox()->AutoWidthShouldFitContent() && + !child.IsReplaced()) builder.SetStretchInlineSizeIfAuto(true); } diff --git a/blink/renderer/core/layout/ng/ng_block_node.cc b/blink/renderer/core/layout/ng/ng_block_node.cc index d175659c55bc..f452c0207754 100644 --- a/blink/renderer/core/layout/ng/ng_block_node.cc +++ b/blink/renderer/core/layout/ng/ng_block_node.cc @@ -283,6 +283,10 @@ void SetupBoxLayoutExtraInput(const NGConstraintSpace& space, input->is_override_block_size_definite = !space.IsFixedBlockSizeIndefinite(); } + input->stretch_inline_size_if_auto = space.StretchInlineSizeIfAuto(); + input->stretch_block_size_if_auto = + space.StretchBlockSizeIfAuto() && + space.AvailableSize().block_size != kIndefiniteSize; } bool CanUseCachedIntrinsicInlineSizes(const MinMaxSizesInput& input, diff --git a/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc b/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc index f5910d0af49b..4767ac39f26e 100644 --- a/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc +++ b/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc @@ -999,9 +999,12 @@ LayoutUnit NGColumnLayoutAlgorithm::ConstrainColumnBlockSize( LayoutUnit max = ResolveMaxBlockLength( ConstraintSpace(), style, BorderPadding(), style.LogicalMaxHeight(), LengthResolvePhase::kLayout); - LayoutUnit extent = ResolveMainBlockLength( - ConstraintSpace(), style, BorderPadding(), style.LogicalHeight(), - kIndefiniteSize, LengthResolvePhase::kLayout); + LayoutUnit extent = kIndefiniteSize; + if (!style.LogicalHeight().IsAuto()) { + extent = ResolveMainBlockLength(ConstraintSpace(), style, BorderPadding(), + style.LogicalHeight(), kIndefiniteSize, + LengthResolvePhase::kLayout); + } if (extent != kIndefiniteSize) { // A specified height/width will just constrain the maximum length. max = std::min(max, extent); diff --git a/blink/renderer/core/layout/ng/ng_constraint_space.h b/blink/renderer/core/layout/ng/ng_constraint_space.h index 8ba859315c18..97ee48a46c06 100644 --- a/blink/renderer/core/layout/ng/ng_constraint_space.h +++ b/blink/renderer/core/layout/ng/ng_constraint_space.h @@ -440,11 +440,14 @@ class CORE_EXPORT NGConstraintSpace final { return bitfields_.is_fixed_block_size_indefinite; } - // Return true if the inline-size property when 'auto' should stretch to + // Return true if the respective size property when 'auto' should stretch to // consume the available space. If false, it behaves as "shrink-to-fit". bool StretchInlineSizeIfAuto() const { return bitfields_.stretch_inline_size_if_auto; } + bool StretchBlockSizeIfAuto() const { + return bitfields_.stretch_block_size_if_auto; + } bool IsPaintedAtomically() const { return bitfields_.is_painted_atomically; } @@ -1282,6 +1285,7 @@ class CORE_EXPORT NGConstraintSpace final { static_cast(NGBaselineAlgorithmType::kFirstLine)), cache_slot(static_cast(NGCacheSlot::kLayout)), stretch_inline_size_if_auto(false), + stretch_block_size_if_auto(false), is_fixed_inline_size(false), is_fixed_block_size(false), is_fixed_block_size_indefinite(false), @@ -1311,6 +1315,7 @@ class CORE_EXPORT NGConstraintSpace final { bool AreSizeConstraintsEqual(const Bitfields& other) const { return stretch_inline_size_if_auto == other.stretch_inline_size_if_auto && + stretch_block_size_if_auto == other.stretch_block_size_if_auto && is_fixed_inline_size == other.is_fixed_inline_size && is_fixed_block_size == other.is_fixed_block_size && is_fixed_block_size_indefinite == @@ -1341,6 +1346,7 @@ class CORE_EXPORT NGConstraintSpace final { // Size constraints. unsigned stretch_inline_size_if_auto : 1; + unsigned stretch_block_size_if_auto : 1; unsigned is_fixed_inline_size : 1; unsigned is_fixed_block_size : 1; unsigned is_fixed_block_size_indefinite : 1; diff --git a/blink/renderer/core/layout/ng/ng_constraint_space_builder.h b/blink/renderer/core/layout/ng/ng_constraint_space_builder.h index 5178e626d0f3..818ed92a98f0 100644 --- a/blink/renderer/core/layout/ng/ng_constraint_space_builder.h +++ b/blink/renderer/core/layout/ng/ng_constraint_space_builder.h @@ -141,7 +141,17 @@ class CORE_EXPORT NGConstraintSpaceBuilder final { } void SetStretchInlineSizeIfAuto(bool b) { - space_.bitfields_.stretch_inline_size_if_auto = b; + if (LIKELY(is_in_parallel_flow_)) + space_.bitfields_.stretch_inline_size_if_auto = b; + else + space_.bitfields_.stretch_block_size_if_auto = b; + } + + void SetStretchBlockSizeIfAuto(bool b) { + if (LIKELY(is_in_parallel_flow_)) + space_.bitfields_.stretch_block_size_if_auto = b; + else + space_.bitfields_.stretch_inline_size_if_auto = b; } void SetIsPaintedAtomically(bool b) { diff --git a/blink/renderer/core/layout/ng/ng_layout_utils.cc b/blink/renderer/core/layout/ng/ng_layout_utils.cc index c562f8c38a38..8bd76fff45e9 100644 --- a/blink/renderer/core/layout/ng/ng_layout_utils.cc +++ b/blink/renderer/core/layout/ng/ng_layout_utils.cc @@ -60,7 +60,10 @@ inline bool InlineLengthMayChange(const ComputedStyle& style, inline bool BlockLengthMayChange(const Length& length, const NGConstraintSpace& new_space, const NGConstraintSpace& old_space) { - if (length.IsFillAvailable()) { + DCHECK_EQ(new_space.StretchBlockSizeIfAuto(), + old_space.StretchBlockSizeIfAuto()); + if (length.IsFillAvailable() || + (length.IsAuto() && new_space.StretchBlockSizeIfAuto())) { if (new_space.AvailableSize().block_size != old_space.AvailableSize().block_size) return true; @@ -85,6 +88,8 @@ bool SizeMayChange(const NGBlockNode& node, old_space.IsFixedBlockSizeIndefinite()); DCHECK_EQ(new_space.StretchInlineSizeIfAuto(), old_space.StretchInlineSizeIfAuto()); + DCHECK_EQ(new_space.StretchBlockSizeIfAuto(), + old_space.StretchBlockSizeIfAuto()); DCHECK_EQ(new_space.TableCellChildLayoutMode(), old_space.TableCellChildLayoutMode()); diff --git a/blink/renderer/core/layout/ng/ng_length_utils.cc b/blink/renderer/core/layout/ng/ng_length_utils.cc index 3a59ce9ff54d..6cf641f9a3d9 100644 --- a/blink/renderer/core/layout/ng/ng_length_utils.cc +++ b/blink/renderer/core/layout/ng/ng_length_utils.cc @@ -202,7 +202,6 @@ LayoutUnit ResolveBlockLengthInternal( } return value; } - case Length::kAuto: case Length::kMinContent: case Length::kMaxContent: case Length::kMinIntrinsic: @@ -212,7 +211,7 @@ LayoutUnit ResolveBlockLengthInternal( // border and padding. We cannot check for this if we are // block-fragmented, though, because then the block-start border/padding // may be in a different fragmentainer than the block-end border/padding. - if (intrinsic_size != LayoutUnit(-1) && + if (intrinsic_size != kIndefiniteSize && !constraint_space.HasBlockFragmentation()) DCHECK_GE(intrinsic_size, border_padding.BlockSum()); #endif // DCHECK_IS_ON() @@ -222,6 +221,7 @@ LayoutUnit ResolveBlockLengthInternal( case Length::kExtendToZoom: NOTREACHED() << "These should only be used for viewport definitions"; FALLTHROUGH; + case Length::kAuto: case Length::kNone: default: NOTREACHED(); @@ -557,17 +557,17 @@ namespace { // Computes the block-size for a fragment, ignoring the fixed block-size if set. LayoutUnit ComputeBlockSizeForFragmentInternal( - const NGConstraintSpace& constraint_space, + const NGConstraintSpace& space, const ComputedStyle& style, const NGBoxStrut& border_padding, LayoutUnit intrinsic_size, base::Optional inline_size, const LayoutUnit* opt_percentage_resolution_block_size_for_min_max = nullptr) { - MinMaxSizes min_max = ComputeMinMaxBlockSize( - constraint_space, style, border_padding, intrinsic_size, - opt_percentage_resolution_block_size_for_min_max); - const Length& logical_height = style.LogicalHeight(); + MinMaxSizes min_max = + ComputeMinMaxBlockSize(space, style, border_padding, intrinsic_size, + opt_percentage_resolution_block_size_for_min_max); + Length logical_height = style.LogicalHeight(); // Scrollable percentage-sized children of table cells, in the table // "measure" phase contribute nothing to the row height measurement. // See: https://drafts.csswg.org/css-tables-3/#row-layout @@ -580,19 +580,24 @@ LayoutUnit ComputeBlockSizeForFragmentInternal( // things to consider, would be checking the row and row-group, and also other // properties, such as {min,max}-block-size. if (logical_height.IsPercentOrCalc() && - constraint_space.TableCellChildLayoutMode() == + space.TableCellChildLayoutMode() == NGTableCellChildLayoutMode::kMeasureRestricted && (style.OverflowBlockDirection() == EOverflow::kAuto || style.OverflowBlockDirection() == EOverflow::kScroll)) return min_max.min_size; + const bool is_logical_height_auto = logical_height.IsAuto(); + if (is_logical_height_auto) { + logical_height = space.StretchBlockSizeIfAuto() ? Length::FillAvailable() + : Length::FitContent(); + } // TODO(cbiesinger): Audit callers of ResolveMainBlockLength to see whether // they need to respect aspect ratio. - LayoutUnit extent = ResolveMainBlockLength( - constraint_space, style, border_padding, logical_height, intrinsic_size, - LengthResolvePhase::kLayout, - opt_percentage_resolution_block_size_for_min_max); - if (UNLIKELY((extent == kIndefiniteSize || logical_height.IsAuto()) && + LayoutUnit extent = + ResolveMainBlockLength(space, style, border_padding, logical_height, + intrinsic_size, LengthResolvePhase::kLayout, + opt_percentage_resolution_block_size_for_min_max); + if (UNLIKELY((extent == kIndefiniteSize || is_logical_height_auto) && !style.AspectRatio().IsAuto() && inline_size)) { extent = BlockSizeFromAspectRatio(border_padding, style.LogicalAspectRatio(), diff --git a/blink/renderer/core/layout/ng/ng_length_utils.h b/blink/renderer/core/layout/ng/ng_length_utils.h index 3dbbdaefe600..69e7f0c4341b 100644 --- a/blink/renderer/core/layout/ng/ng_length_utils.h +++ b/blink/renderer/core/layout/ng/ng_length_utils.h @@ -244,6 +244,7 @@ inline LayoutUnit ResolveMainBlockLength( LengthResolvePhase phase, const LayoutUnit* opt_percentage_resolution_block_size_for_min_max = nullptr) { + DCHECK(!length.IsAuto()); if (UNLIKELY((length.IsPercentOrCalc() || length.IsFillAvailable()) && BlockLengthUnresolvable( constraint_space, length, phase, @@ -265,6 +266,7 @@ inline LayoutUnit ResolveMainBlockLength( LengthResolvePhase phase, const LayoutUnit* opt_percentage_resolution_block_size_for_min_max = nullptr) { + DCHECK(!length.IsAuto()); if (UNLIKELY((length.IsPercentOrCalc() || length.IsFillAvailable()) && BlockLengthUnresolvable( constraint_space, length, phase, @@ -272,7 +274,7 @@ inline LayoutUnit ResolveMainBlockLength( return intrinsic_block_size_func(); LayoutUnit intrinsic_block_size = kIndefiniteSize; - if (length.IsAutoOrContentOrIntrinsic()) + if (length.IsContentOrIntrinsic()) intrinsic_block_size = intrinsic_block_size_func(); return ResolveBlockLengthInternal( diff --git a/blink/renderer/core/layout/ng/ng_length_utils_test.cc b/blink/renderer/core/layout/ng/ng_length_utils_test.cc index f30d29a1b910..535724dcb1f0 100644 --- a/blink/renderer/core/layout/ng/ng_length_utils_test.cc +++ b/blink/renderer/core/layout/ng/ng_length_utils_test.cc @@ -163,9 +163,6 @@ TEST_F(NGLengthUtilsTest, testResolveInlineLength) { TEST_F(NGLengthUtilsTest, testResolveBlockLength) { EXPECT_EQ(LayoutUnit(90), ResolveMainBlockLength(Length::Percent(30))); EXPECT_EQ(LayoutUnit(150), ResolveMainBlockLength(Length::Fixed(150))); - EXPECT_EQ(LayoutUnit(0), ResolveMainBlockLength(Length::Auto())); - EXPECT_EQ(LayoutUnit(300), ResolveMainBlockLength(Length::FillAvailable())); - EXPECT_EQ(LayoutUnit(300), ResolveMainBlockLength(Length::FillAvailable())); } diff --git a/blink/web_tests/TestExpectations b/blink/web_tests/TestExpectations index 4575f95b56ce..5a2598f668ef 100644 --- a/blink/web_tests/TestExpectations +++ b/blink/web_tests/TestExpectations @@ -3333,6 +3333,8 @@ crbug.com/921722 external/wpt/css/css-grid/abspos/descendant-static-position-001 crbug.com/921722 external/wpt/css/css-grid/abspos/descendant-static-position-002.html [ Failure ] crbug.com/921722 external/wpt/css/css-grid/abspos/descendant-static-position-003.html [ Failure ] crbug.com/941987 external/wpt/css/css-grid/alignment/grid-baseline-align-cycles-001.html [ Failure ] +crbug.com/1045599 external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-001.tentative.html [ Failure ] +crbug.com/1045599 external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-002.tentative.html [ Failure ] crbug.com/759665 external/wpt/css/css-grid/animation/grid-template-columns-001.html [ Failure ] crbug.com/759665 external/wpt/css/css-grid/animation/grid-template-rows-001.html [ Failure ] crbug.com/935102 external/wpt/css/css-grid/layout-algorithm/grid-flex-track-intrinsic-sizes-002.html [ Failure ] @@ -3484,12 +3486,10 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/gri crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-align-justify-overflow.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-align-justify-stretch-with-orthogonal-flows.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-align-justify-stretch.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-align-stretching-replaced-items.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-align.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-029.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-030.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-031.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-032.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-035.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-036.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-style-changes-001.html [ Failure ] @@ -3658,11 +3658,6 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/gri crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-014.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-015.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-016.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-002.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-005.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-006.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-007.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-008.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-009.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-010.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-011.html [ Failure ] @@ -3671,11 +3666,6 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/gri crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-014.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-015.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-016.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-002.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-005.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-006.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-007.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-008.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-009.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-010.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-011.html [ Failure ] @@ -3684,11 +3674,6 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/gri crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-014.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-015.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-lr-016.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-002.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-005.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-006.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-007.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-008.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-009.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-010.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-self-alignment-stretch-vertical-rl-011.html [ Failure ] @@ -3838,8 +3823,6 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/gr crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-minimum-width-vertical-rl-002.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-margins-001.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-margins-002.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-margins-006.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-margins-014.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-margins-vertical-lr-001.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-margins-vertical-lr-002.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-margins-vertical-rl-001.html [ Failure ] @@ -3860,7 +3843,6 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/gr crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-001.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-relative-offsets-002.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-items-sizing-alignment-001.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-layout-z-order-a.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-layout-z-order-b.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-minimum-size-grid-items-001.html [ Failure ] @@ -3876,7 +3858,6 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/gr crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-minimum-size-grid-items-023.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-minimum-size-grid-items-024.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-minimum-size-grid-items-025.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/percentage-size-subitems-002.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-order-property-auto-placement-001.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-order-property-auto-placement-002.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/grid-items/grid-order-property-auto-placement-003.html [ Failure ] @@ -3938,8 +3919,6 @@ crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algori crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/flex-and-intrinsic-sizes-002.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/flex-sizing-columns-min-max-width-001.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/flex-sizing-rows-min-max-height-001.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/grid-as-flex-item-should-not-shrink-to-fit-003.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/grid-as-flex-item-should-not-shrink-to-fit-004.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/grid-as-flex-item-should-not-shrink-to-fit-007.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/grid-automatic-minimum-for-auto-columns-001.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/layout-algorithm/grid-container-percentage-001.html [ Failure ] @@ -4063,7 +4042,6 @@ crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/maximize-tracks-de crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/min-content-row-must-shrink-when-column-grows.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/min-height-border-box.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/min-width-height-auto-and-margins.html [ Failure ] -crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/min-width-height-auto.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/min-width-margin-box.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/minmax-fixed-logical-height-only.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/minmax-fixed-logical-width-only.html [ Failure ] @@ -4093,6 +4071,16 @@ crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/preferred-width-co crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/relayout-indefinite-heights.html [ Failure ] crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/repeating-layout-must-produce-the-same-results.html [ Failure ] +# All these failures are due to bad tests, but waiting on CSSWG to confirm. Essentially they involve +# a replaced element, with stretching in one axis. The current implementation (and these tests) +# assume that they should loose their aspect-ratio when they shouldn't. +crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-011.html [ Failure ] +crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-012.html [ Failure ] +crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-013.html [ Failure ] +crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-014.html [ Failure ] +crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-017.html [ Failure ] +crbug.com/1045599 virtual/layout-ng-grid/external/wpt/css/css-grid/alignment/grid-alignment-implies-size-change-018.html [ Failure ] + # These pass but hit DCHECKS crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001.html [ Crash Failure ] crbug.com/1045599 virtual/layout-ng-grid/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-002.html [ Crash Failure ] diff --git a/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-001.tentative.html b/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-001.tentative.html new file mode 100644 index 000000000000..d7ab97b9ec00 --- /dev/null +++ b/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-001.tentative.html @@ -0,0 +1,8 @@ + + + + +

Test passes if there is a filled green square and no red.

+
+ +
diff --git a/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-002.tentative.html b/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-002.tentative.html new file mode 100644 index 000000000000..1a4e344dd045 --- /dev/null +++ b/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-002.tentative.html @@ -0,0 +1,8 @@ + + + + +

Test passes if there is a filled green square and no red.

+
+ +
diff --git a/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-003.tentative.html b/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-003.tentative.html new file mode 100644 index 000000000000..2c27480d5a7a --- /dev/null +++ b/blink/web_tests/external/wpt/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-003.tentative.html @@ -0,0 +1,8 @@ + + + + +

Test passes if there is a filled green square and no red.

+
+ +