diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_child_iterator.h b/third_party/blink/renderer/core/layout/ng/ng_block_child_iterator.h index 3b7636ad53053..d75eb17c8d55d 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_child_iterator.h +++ b/third_party/blink/renderer/core/layout/ng/ng_block_child_iterator.h @@ -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_; diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc index 92cec5b9d10ae..d3dff1318fa73 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc @@ -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 diff --git a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_test.cc b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_test.cc index a0ddc40690f12..fc9deaea2e9fb 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_test.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_test.cc @@ -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