Commit dec7374a authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Include all fragments to visual overflow for inline children

This patch includes all block-fragmented fragments when
computing visual overflow.

When uniting, it should stitch the block offset, but this
patch does not do that because the multicol container cannot
compute visual overflow in the block direction. This is
tracked in <crbug.com/1144203>.

Eliminates one call to |CurrentFragment|. One more use to go,
other than usages in tests. It will be in following patches.

Bug: 1061423
Change-Id: Iaef43b93c8643f42929739dc2221a1eaf3226c3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2509609
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822875}
parent 57f9a769
...@@ -2431,22 +2431,28 @@ void LayoutBlockFlow::AddVisualOverflowFromInlineChildren() { ...@@ -2431,22 +2431,28 @@ void LayoutBlockFlow::AddVisualOverflowFromInlineChildren() {
AddContentsVisualOverflow(child_rect); AddContentsVisualOverflow(child_rect);
} }
} }
} else if (const NGPhysicalBoxFragment* fragment = CurrentFragment()) { } else if (PhysicalFragmentCount()) {
if (const NGFragmentItems* items = fragment->Items()) { // TODO(crbug.com/1144203): This should compute in the stitched coordinate
for (NGInlineCursor cursor(*fragment, *items); cursor; // system, but overflows in the block direction is converted to the inline
cursor.MoveToNextSkippingChildren()) { // direction in the multicol container. Just unite overflows in the inline
const NGFragmentItem* child = cursor.CurrentItem(); // direction only for now.
DCHECK(child); for (const NGPhysicalBoxFragment& fragment : PhysicalFragments()) {
if (child->HasSelfPaintingLayer()) if (const NGFragmentItems* items = fragment.Items()) {
continue; for (NGInlineCursor cursor(fragment, *items); cursor;
PhysicalRect child_rect = child->InkOverflow(); cursor.MoveToNextSkippingChildren()) {
if (!child_rect.IsEmpty()) { const NGFragmentItem* child = cursor.CurrentItem();
child_rect.offset += child->OffsetInContainerBlock(); DCHECK(child);
AddContentsVisualOverflow(child_rect); if (child->HasSelfPaintingLayer())
continue;
PhysicalRect child_rect = child->InkOverflow();
if (!child_rect.IsEmpty()) {
child_rect.offset += child->OffsetInContainerBlock();
AddContentsVisualOverflow(child_rect);
}
} }
} else if (fragment.HasFloatingDescendantsForPaint()) {
AddVisualOverflowFromFloats(fragment);
} }
} else if (fragment->HasFloatingDescendantsForPaint()) {
AddVisualOverflowFromFloats(*fragment);
} }
} else { } else {
for (RootInlineBox* curr = FirstRootBox(); curr; for (RootInlineBox* curr = FirstRootBox(); curr;
......
...@@ -242,5 +242,48 @@ TEST_F(NGFragmentationTest, HasSeenAllChildrenIfc) { ...@@ -242,5 +242,48 @@ TEST_F(NGFragmentationTest, HasSeenAllChildrenIfc) {
EXPECT_FALSE(break_token); EXPECT_FALSE(break_token);
} }
TEST_F(NGFragmentationTest, InkOverflowInline) {
SetBodyInnerHTML(R"HTML(
<style>
#container {
font-size: 10px;
column-width: 100px;
column-gap: 10px;
width: 210px;
line-height: 15px;
height: 15px;
}
atomic {
display: inline-block;
width: 100px;
height: 10px;
background: blue;
}
.w15 {
width: 150px;
background: orange;
}
</style>
<div id="container">
<div>
<!-- 1st column does not have ink overflow. -->
<atomic></atomic>
<!-- 2nd column has 50px ink overflow to right. -->
<atomic><atomic class="w15"></atomic></atomic>
</div>
</div>
)HTML");
const auto* container =
To<LayoutBlockFlow>(GetLayoutObjectByElementId("container"));
const auto* flow_thread = To<LayoutBlockFlow>(container->FirstChild());
DCHECK(flow_thread->IsLayoutFlowThread());
// |flow_thread| is in the stitched coordinate system.
EXPECT_EQ(flow_thread->PhysicalVisualOverflowRect(),
PhysicalRect(0, 0, 150, 30));
// TOOD(crbug.com/1144203): This should be (0, 0, 260, 15).
EXPECT_EQ(container->PhysicalVisualOverflowRect(),
PhysicalRect(0, 0, 210, 15));
}
} // anonymous namespace } // anonymous namespace
} // namespace blink } // namespace blink
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