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

[LayoutNG] Finish fragmentainer layout in the block layout algorithm.

Fragmentainers are a bit special, and they are also always block
containers. Therefore, just deal with them completely on our own in
NGBlockLayoutAlgorithm, instead of leaving the job to
FinishFragmentation().

The background here is that I'm working on some changes in
FinishFragmentation() where I'd otherwise have to make exceptions for
fragmentainers. Better to just avoid it.

No behavior changes.

Change-Id: Ib18168497bbe4de29aa365beb0c2c3d40aaeccff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236142Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776624}
parent 81fbe033
...@@ -2157,43 +2157,45 @@ bool NGBlockLayoutAlgorithm::FinalizeForFragmentation() { ...@@ -2157,43 +2157,45 @@ bool NGBlockLayoutAlgorithm::FinalizeForFragmentation() {
if (!ConstraintSpace().HasKnownFragmentainerBlockSize()) if (!ConstraintSpace().HasKnownFragmentainerBlockSize())
return true; return true;
LayoutUnit space_left = FragmentainerSpaceAvailable();
if (space_left <= LayoutUnit()) {
// The amount of space available may be zero, or even negative, if the
// border-start edge of this block starts exactly at, or even after the
// fragmentainer boundary. We're going to need a break before this block,
// because no part of it fits in the current fragmentainer. Due to margin
// collapsing with children, this situation is something that we cannot
// always detect prior to layout. The fragment produced by this algorithm
// is going to be thrown away. The parent layout algorithm will eventually
// detect that there's no room for a fragment for this node, and drop the
// fragment on the floor. Therefore it doesn't matter how we set up the
// container builder, so just return.
return true;
}
LayoutUnit consumed_block_size = LayoutUnit consumed_block_size =
BreakToken() ? BreakToken()->ConsumedBlockSize() : LayoutUnit(); BreakToken() ? BreakToken()->ConsumedBlockSize() : LayoutUnit();
LayoutUnit space_left = FragmentainerSpaceAvailable();
LayoutUnit block_size; LayoutUnit block_size;
if (container_builder_.IsFragmentainerBoxType() && if (container_builder_.IsFragmentainerBoxType()) {
ConstraintSpace().HasKnownFragmentainerBlockSize()) {
// We're building fragmentainers, and we know their block-size. Just use // We're building fragmentainers, and we know their block-size. Just use
// that. Calculating the size the regular way would cause some problems with // that. Calculating the size the regular way would cause some problems with
// overflow. For one, we don't want to produce a break token if there's no // overflow. For one, we don't want to produce a break token if there's no
// child content that requires it. // child content that requires it.
block_size = ConstraintSpace().FragmentainerBlockSize(); block_size = ConstraintSpace().FragmentainerBlockSize();
} else { container_builder_.SetBlockSize(block_size);
block_size = ComputeBlockSizeForFragment( container_builder_.SetConsumedBlockSize(consumed_block_size + block_size);
ConstraintSpace(), Style(), border_padding_, return true;
consumed_block_size + intrinsic_block_size_,
container_builder_.InitialBorderBoxSize().inline_size);
block_size -= consumed_block_size;
DCHECK_GE(block_size, LayoutUnit())
<< "Adding and subtracting the consumed_block_size shouldn't leave the "
"block_size for this fragment smaller than zero.";
if (space_left <= LayoutUnit()) {
// The amount of space available may be zero, or even negative, if the
// border-start edge of this block starts exactly at, or even after the
// fragmentainer boundary. We're going to need a break before this block,
// because no part of it fits in the current fragmentainer. Due to margin
// collapsing with children, this situation is something that we cannot
// always detect prior to layout. The fragment produced by this algorithm
// is going to be thrown away. The parent layout algorithm will eventually
// detect that there's no room for a fragment for this node, and drop the
// fragment on the floor. Therefore it doesn't matter how we set up the
// container builder, so just return.
return true;
}
} }
block_size = ComputeBlockSizeForFragment(
ConstraintSpace(), Style(), border_padding_,
consumed_block_size + intrinsic_block_size_,
container_builder_.InitialBorderBoxSize().inline_size);
block_size -= consumed_block_size;
DCHECK_GE(block_size, LayoutUnit())
<< "Adding and subtracting the consumed_block_size shouldn't leave the "
"block_size for this fragment smaller than zero.";
FinishFragmentation(ConstraintSpace(), BreakToken(), block_size, FinishFragmentation(ConstraintSpace(), BreakToken(), block_size,
intrinsic_block_size_, space_left, &container_builder_); intrinsic_block_size_, space_left, &container_builder_);
......
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