Commit b309e305 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Block-size % resolution inside columns.

We were resolving the block-size of column content against the columns,
but that's only correct if the column happens to take up all the space
in a multicol container (which typically ISN'T the case when there are
column spanners, or when a lone column row is balanced to use less space
than what's specified on the multicol container).

So, resolve percentage block-size against the computed content-box
block-size of the multicol container (not the columns).

Also provide the correct percentage resolution size in the initial
column balancing pass. This doesn't really do much for correctness,
since the column stretching machinery will eventually give us the right
column size, but this will hopefully give a better initial size guess,
so that we don't have to stretch and re-lay out as many times as we
would have without this change.

Some work left to do (TODO added) for OOF descendants. No intended
behavior changes there for now.

Bug: 829028
Change-Id: Iddc5b1f53ca375a05768385bab35ce2215c2ccbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412728Reviewed-by: default avatarAlison Maher <almaher@microsoft.com>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807365}
parent 46a09bea
......@@ -584,7 +584,7 @@ scoped_refptr<const NGLayoutResult> NGColumnLayoutAlgorithm::LayoutRow(
do {
// Lay out one column. Each column will become a fragment.
NGConstraintSpace child_space = CreateConstraintSpaceForColumns(
ConstraintSpace(), Style().GetWritingMode(), column_size,
ConstraintSpace(), column_size, ColumnPercentageResolutionSize(),
is_first_fragmentainer, balance_columns);
NGFragmentGeometry fragment_geometry =
......@@ -1014,7 +1014,7 @@ NGConstraintSpace NGColumnLayoutAlgorithm::CreateConstraintSpaceForBalancing(
ConstraintSpace(), Style().GetWritingMode(), /* is_new_fc */ true);
space_builder.SetFragmentationType(kFragmentColumn);
space_builder.SetAvailableSize({column_size.inline_size, kIndefiniteSize});
space_builder.SetPercentageResolutionSize(column_size);
space_builder.SetPercentageResolutionSize(ColumnPercentageResolutionSize());
space_builder.SetIsAnonymous(true);
space_builder.SetIsInColumnBfc();
space_builder.SetIsInsideBalancedColumns();
......
......@@ -72,6 +72,15 @@ class CORE_EXPORT NGColumnLayoutAlgorithm
// such as break-before:avoid or break-after:avoid.
scoped_refptr<const NGLayoutResult> RelayoutAndBreakEarlier();
// Get the percentage resolution size to use for column content (i.e. not
// spanners).
LogicalSize ColumnPercentageResolutionSize() const {
// Percentage block-size on children is resolved against the content-box of
// the multicol container (just like in regular block layout), while
// percentage inline-size is restricted by the columns.
return LogicalSize(column_inline_size_, ChildAvailableSize().block_size);
}
NGConstraintSpace CreateConstraintSpaceForBalancing(
const LogicalSize& column_size) const;
NGConstraintSpace CreateConstraintSpaceForSpanner(
......
......@@ -679,14 +679,14 @@ bool AttemptSoftBreak(const NGConstraintSpace& space,
NGConstraintSpace CreateConstraintSpaceForColumns(
const NGConstraintSpace& parent_space,
WritingMode writing_mode,
const LogicalSize& column_size,
LogicalSize column_size,
LogicalSize percentage_resolution_size,
bool is_first_fragmentainer,
bool balance_columns) {
NGConstraintSpaceBuilder space_builder(parent_space, writing_mode,
/* is_new_fc */ true);
NGConstraintSpaceBuilder space_builder(
parent_space, parent_space.GetWritingMode(), /* is_new_fc */ true);
space_builder.SetAvailableSize(column_size);
space_builder.SetPercentageResolutionSize(column_size);
space_builder.SetPercentageResolutionSize(percentage_resolution_size);
// To ensure progression, we need something larger than 0 here. The spec
// actually says that fragmentainers have to accept at least 1px of content.
......
......@@ -262,8 +262,8 @@ bool AttemptSoftBreak(const NGConstraintSpace&,
// Calculate the constraint space for columns of a multi-column layout.
NGConstraintSpace CreateConstraintSpaceForColumns(
const NGConstraintSpace& parent_space,
WritingMode writing_mode,
const LogicalSize& column_size,
LogicalSize column_size,
LogicalSize percentage_resolution_size,
bool is_first_fragmentainer,
bool balance_columns);
......
......@@ -1159,12 +1159,16 @@ const NGConstraintSpace& NGOutOfFlowLayoutPart::GetFragmentainerConstraintSpace(
column_size.block_size = column_size.block_size.ClampNegativeToZero();
}
// TODO(layout-dev): Calculate correct percentage resolution size.
LogicalSize percentage_resolution_size = column_size;
// TODO(bebeaudr): Need to handle different fragmentation types. It won't
// always be multi-column.
NGConstraintSpace fragmentainer_constraint_space =
CreateConstraintSpaceForColumns(
*container_builder_->ConstraintSpace(), container_writing_mode,
column_size, is_first_fragmentainer, /* balance_columns */ false);
CreateConstraintSpaceForColumns(*container_builder_->ConstraintSpace(),
column_size, percentage_resolution_size,
is_first_fragmentainer,
/* balance_columns */ false);
return fragmentainer_constraint_space_map_
.insert(stored_index, fragmentainer_constraint_space)
......
......@@ -1043,8 +1043,6 @@ crbug.com/1079031 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/mul
crbug.com/1079031 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-rule-fraction-003.xht [ Crash Failure ]
crbug.com/1079031 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-009.html [ Crash Failure ]
crbug.com/1079031 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-010.html [ Failure ]
crbug.com/829028 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-children-height-002.html [ Failure ]
crbug.com/829028 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-children-height-003.html [ Failure ]
crbug.com/829028 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-children-height-006.html [ Failure ]
crbug.com/829028 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-children-height-008.html [ Failure ]
crbug.com/874051 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-fieldset-002.html [ Failure Crash ]
......
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