0

[LayoutNG] Correct HasSeenAllChildren() state in IFCs.

NGBlockBreakToken::HasSeenAllChildren() is currently not used in inline
formatting contexts (so doing it wrong currently doesn't cause any
damage), but this is likely to change.

formatting contexts. Remove that method, and call NextChild() for real
instead, and provide an inline break token when appropriate.

NGBlockChildIterator: :IsAtEnd() would just always return true in inline
Change-Id: I87bf5178588682cfaa8219dce0d90b472d097b1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2220047
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774595}
This commit is contained in:
Morten Stenshorne
2020-06-03 13:23:09 +00:00
committed by Commit Bot
parent 2475ea0812
commit 224baa1b51
3 changed files with 50 additions and 4 deletions

@ -43,9 +43,6 @@ class CORE_EXPORT NGBlockChildIterator {
Entry NextChild(
const NGInlineBreakToken* previous_inline_break_token = nullptr);
// Return true if there are no more children to process.
bool IsAtEnd() const { return !child_; }
private:
NGLayoutInputNode child_;
const NGBlockBreakToken* break_token_;

@ -785,7 +785,7 @@ inline scoped_refptr<const NGLayoutResult> NGBlockLayoutAlgorithm::Layout(
NGLayoutResult::kNeedsRelayoutWithNoForcedTruncateAtLineClamp);
}
if (child_iterator.IsAtEnd()) {
if (!child_iterator.NextChild(previous_inline_break_token.get()).node) {
// We've gone through all the children. This doesn't necessarily mean that
// we're done fragmenting, as there may be parallel flows [1] (visible
// overflow) still needing more space than what the current fragmentainer

@ -193,5 +193,54 @@ TEST_F(NGFragmentationTest, MultipleFragmentsNestedMulticol) {
EXPECT_EQ(child2->GetPhysicalFragment(3)->Size(), PhysicalSize(22, 100));
}
TEST_F(NGFragmentationTest, HasSeenAllChildrenIfc) {
SetBodyInnerHTML(R"HTML(
<div id="container">
<div style="columns:3; column-fill:auto; height:50px; line-height:20px; orphans:1; widows:1;">
<div id="ifc" style="height:300px;">
<br><br>
<br><br>
<br><br>
<br>
</div>
</div>
</div>
)HTML");
RunBlockLayoutAlgorithm(GetElementById("container"));
const LayoutBox* ifc = ToLayoutBox(GetLayoutObjectByElementId("ifc"));
ASSERT_EQ(ifc->PhysicalFragmentCount(), 6u);
const NGPhysicalBoxFragment* fragment = ifc->GetPhysicalFragment(0);
const NGBlockBreakToken* break_token =
DynamicTo<NGBlockBreakToken>(fragment->BreakToken());
ASSERT_TRUE(break_token);
EXPECT_FALSE(break_token->HasSeenAllChildren());
fragment = ifc->GetPhysicalFragment(1);
break_token = DynamicTo<NGBlockBreakToken>(fragment->BreakToken());
ASSERT_TRUE(break_token);
EXPECT_FALSE(break_token->HasSeenAllChildren());
fragment = ifc->GetPhysicalFragment(2);
break_token = DynamicTo<NGBlockBreakToken>(fragment->BreakToken());
ASSERT_TRUE(break_token);
EXPECT_FALSE(break_token->HasSeenAllChildren());
fragment = ifc->GetPhysicalFragment(3);
break_token = DynamicTo<NGBlockBreakToken>(fragment->BreakToken());
ASSERT_TRUE(break_token);
EXPECT_TRUE(break_token->HasSeenAllChildren());
fragment = ifc->GetPhysicalFragment(4);
break_token = DynamicTo<NGBlockBreakToken>(fragment->BreakToken());
ASSERT_TRUE(break_token);
EXPECT_TRUE(break_token->HasSeenAllChildren());
fragment = ifc->GetPhysicalFragment(5);
break_token = DynamicTo<NGBlockBreakToken>(fragment->BreakToken());
EXPECT_FALSE(break_token);
}
} // anonymous namespace
} // namespace blink