Commit e874837d authored by Koji Ishii's avatar Koji Ishii Committed by Chromium LUCI CQ

Include empty text item after forced break into the line

When |NGLineBreaker| finds a forced break, it includes
following close-tags but not empty text items. This caused an
additional empty line when there are spaces before/after
the close-tags, which causes the `widows` property to count
the empty lines.

This patch changes |NGLineBreaker| to include them as well.

Bug: 1156773
Change-Id: Id01966dd57dce3185d384544e9af662fd43917c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2584431Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836547}
parent 243bbb6b
...@@ -1421,6 +1421,10 @@ void NGLineBreaker::HandleControlItem(const NGInlineItem& item, ...@@ -1421,6 +1421,10 @@ void NGLineBreaker::HandleControlItem(const NGInlineItem& item,
HandleCloseTag(next_item, line_info); HandleCloseTag(next_item, line_info);
continue; continue;
} }
if (next_item.Type() == NGInlineItem::kText && !next_item.Length()) {
HandleEmptyText(next_item, line_info);
continue;
}
break; break;
} }
......
...@@ -605,6 +605,38 @@ TEST_F(NGLineBreakerTest, SplitTextZero) { ...@@ -605,6 +605,38 @@ TEST_F(NGLineBreakerTest, SplitTextZero) {
EXPECT_EQ("ab", lines[1].first); EXPECT_EQ("ab", lines[1].first);
} }
TEST_F(NGLineBreakerTest, ForcedBreakFollowedByCloseTag) {
SetBodyInnerHTML(R"HTML(
<!DOCTYPE html>
<div id="container">
<div><span>line<br></span></div>
<div>
<span>line<br></span>
</div>
<div>
<span>
line<br>
</span>
</div>
<div>
<span>line<br> </span>
</div>
<div>
<span>line<br> </span>&#32;&#32;
</div>
</div>
)HTML");
const LayoutObject* container = GetLayoutObjectByElementId("container");
for (const LayoutObject* child = container->SlowFirstChild(); child;
child = child->NextSibling()) {
NGInlineCursor cursor(*To<LayoutBlockFlow>(child));
wtf_size_t line_count = 0;
for (cursor.MoveToFirstLine(); cursor; cursor.MoveToNextLine())
++line_count;
EXPECT_EQ(line_count, 1u);
}
}
TEST_F(NGLineBreakerTest, TableCellWidthCalculationQuirkOutOfFlow) { TEST_F(NGLineBreakerTest, TableCellWidthCalculationQuirkOutOfFlow) {
NGInlineNode node = CreateInlineNode(R"HTML( NGInlineNode node = CreateInlineNode(R"HTML(
<style> <style>
......
...@@ -1095,7 +1095,6 @@ crbug.com/1079031 virtual/layout_ng_block_frag/fast/multicol/tall-line-in-short- ...@@ -1095,7 +1095,6 @@ crbug.com/1079031 virtual/layout_ng_block_frag/fast/multicol/tall-line-in-short-
crbug.com/1079031 virtual/layout_ng_block_frag/fast/multicol/transform-with-fixedpos.html [ Failure ] crbug.com/1079031 virtual/layout_ng_block_frag/fast/multicol/transform-with-fixedpos.html [ Failure ]
crbug.com/1058792 virtual/layout_ng_block_frag/fast/multicol/vertical-lr/composited-relpos-overlapping-will-change.html [ Failure ] crbug.com/1058792 virtual/layout_ng_block_frag/fast/multicol/vertical-lr/composited-relpos-overlapping-will-change.html [ Failure ]
crbug.com/1058792 virtual/layout_ng_block_frag/fast/multicol/vertical-rl/composited-relpos-overlapping-will-change.html [ Failure ] crbug.com/1058792 virtual/layout_ng_block_frag/fast/multicol/vertical-rl/composited-relpos-overlapping-will-change.html [ Failure ]
crbug.com/829028 virtual/layout_ng_block_frag/fast/multicol/widows.html [ Failure ]
crbug.com/1079031 virtual/layout_ng_block_frag/fragmentation/content-preceding-first-fragmentainer.html [ Crash Failure ] crbug.com/1079031 virtual/layout_ng_block_frag/fragmentation/content-preceding-first-fragmentainer.html [ Crash Failure ]
crbug.com/1079031 virtual/layout_ng_block_frag/fragmentation/relayout-abspos.html [ Failure ] crbug.com/1079031 virtual/layout_ng_block_frag/fragmentation/relayout-abspos.html [ Failure ]
......
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