Commit 4a0e78dd authored by Javier Fernández García-Boente's avatar Javier Fernández García-Boente Committed by Commit Bot

[css-text] Set should_create_line_box on ItemResult of empty lines

When a sequence of preserved space is longer than the line size, we are
handle it as trailing space. The HandleTrailingSpace function creates a
new ItemResult to handle this trailing preserved spaces. In general, it
doesn't need to enable the 'should_create_line_box' flag, since the
previous ItemResult associated to that line already has it.

However, in case of a ItemResult longer than the line, we would end up
with this newly created instance, which flag is disabled by default.

This CL enables the 'should_create_line_box' flag for ItemResult with
'end' offset exceeding the line size. This ensures that lines that are
all preserved spaces will required a LineBox, hence it should account
for computing the box's size.

Bug: 1136748
Change-Id: I0df602d3c13129e4369e351c142601c1806214c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503550
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821530}
parent 9c7646a3
......@@ -1221,6 +1221,7 @@ void NGLineBreaker::HandleTrailingSpaces(const NGInlineItem& item,
// instead.
DCHECK(shape_result);
NGInlineItemResult* item_result = AddItem(item, end, line_info);
item_result->should_create_line_box = true;
item_result->non_hangable_run_end = offset_;
item_result->has_only_trailing_spaces = true;
item_result->shape_result = ShapeResultView::Create(shape_result);
......
<!doctype html>
<meta charset=utf-8>
<title>CSS Text test: breaking opportunities at leading spaces with white-space:pre-wrap</title>
<link rel="author" title="Javier Fernandez" href="mailto:jfernandez@igalia.com" />
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Empty line with preserved white spaces must account for box sizing.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
.ref {
position: absolute;
background: red;
width: 100px;
height: 100px;
z-index: -1;
}
.test {
font: 50px/1 Ahem;
width: 2ch;
background: green;
color: green;
white-space: pre-wrap;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref"></div>
<div class="test">&#32;&#32;&#32;X</div>
<!doctype html>
<meta charset=utf-8>
<title>CSS Text test: breaking opportunities at leading spaces with white-space:pre-wrap</title>
<link rel="author" title="Javier Fernandez" href="mailto:jfernandez@igalia.com" />
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Empty line with preserved white spaces must account for box sizing.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
.ref {
position: absolute;
background: red;
width: 100px;
height: 100px;
z-index: -1;
}
.test {
font: 25px/1 Ahem;
width: 4ch;
background: green;
color: green;
white-space: pre-wrap;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref"></div>
<div class="test">&#32;&#32;&#32;&#32;&#32;XXXX<br>&#32;&#32;&#32;&#32;&#32;X</div>
<!doctype html>
<meta charset=utf-8>
<title>CSS Text test: breaking opportunities at leading spaces with white-space:pre-wrap</title>
<link rel="author" title="Javier Fernandez" href="mailto:jfernandez@igalia.com" />
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Empty line with preserved white spaces must account fpor box sizing.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
.ref {
position: absolute;
background: red;
width: 100px;
height: 100px;
z-index: -1;
}
.test {
font: 50px/1 Ahem;
width: 2ch;
background: green;
color: green;
white-space: pre-wrap;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref"></div>
<div class="test">&#32;<span>&#32;&#32;</span>X</div>
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