Commit 51591e43 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Don't pass exclusion spaces across formatting contexts.

We already did reset the exclusion space when entering a new formatting
context, but when leaving it, we'd return the final exclusion space for
that inner formatting context to the parent algorithm. Although it was
ignored by the parent algorithm, let's just make sure that we don't
return it at all.

Exclusion spaces are also ignored by legacy layout, which is fine, since
we never let the two engines cooperate inside one and the same
formatting context.

Add DCHECKs that verify that we don't "leak" exclusion spaces across
formatting context boundaries.

No behavioral changes intended.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: If025a5d4b5b6c96399f5719aed6cd3ab4d76c556
Reviewed-on: https://chromium-review.googlesource.com/1158409Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580157}
parent 050128c6
......@@ -59,6 +59,8 @@ class CORE_EXPORT NGExclusionSpace {
return GetDerivedGeometry().LastFloatBlockStart();
}
bool IsEmpty() const { return !num_exclusions_; }
bool operator==(const NGExclusionSpace& other) const;
bool operator!=(const NGExclusionSpace& other) const {
return !(*this == other);
......
......@@ -682,8 +682,11 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() {
PropagateBaselinesFromChildren();
DCHECK(exclusion_space_);
container_builder_.SetExclusionSpace(std::move(exclusion_space_));
// An exclusion space is confined to nodes within the same formatting context.
if (!ConstraintSpace().IsNewFormattingContext()) {
DCHECK(exclusion_space_);
container_builder_.SetExclusionSpace(std::move(exclusion_space_));
}
if (ConstraintSpace().UseFirstLineStyle())
container_builder_.SetStyleVariant(NGStyleVariant::kFirstLine);
......@@ -1045,9 +1048,18 @@ NGBlockLayoutAlgorithm::LayoutNewFormattingContext(
child_available_size_.block_size};
auto child_space =
CreateConstraintSpaceForChild(child, child_data, child_available_size);
// All formatting context roots (like this child) should start with an empty
// exclusion space.
DCHECK(child_space->ExclusionSpace().IsEmpty());
scoped_refptr<NGLayoutResult> layout_result =
child.Layout(*child_space, child_break_token);
// Since this child establishes a new formatting context, no exclusion space
// should be returned.
DCHECK(!layout_result->ExclusionSpace());
DCHECK(layout_result->PhysicalFragment());
NGFragment fragment(ConstraintSpace().GetWritingMode(),
*layout_result->PhysicalFragment());
......
......@@ -716,13 +716,6 @@ scoped_refptr<NGLayoutResult> NGBlockNode::RunOldLayout(
builder.SetBlockSize(box_size.block_size);
builder.SetPadding(ComputePadding(constraint_space, box_->StyleRef()));
// For now we copy the exclusion space straight through, this is incorrect
// but needed as not all elements which participate in a BFC are switched
// over to LayoutNG yet.
// TODO(ikilpatrick): Remove this once the above isn't true.
builder.SetExclusionSpace(
std::make_unique<NGExclusionSpace>(constraint_space.ExclusionSpace()));
CopyBaselinesFromOldLayout(constraint_space, &builder);
UpdateShapeOutsideInfoIfNeeded(
constraint_space.PercentageResolutionSize().inline_size);
......
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