Commit 0ef4384b authored by Javier Fernández García-Boente's avatar Javier Fernández García-Boente Committed by Chromium LUCI CQ

Ensure the break-offset is greater than the non-hangable run end

The ShapeLineBreaker::NextBreakOpportunity function determines the
non-hangable run end based on the currently break-offset. This value
is, by definition, always smaller than the break-offset. However, if
the break-offset value exceed the range_end, we use this as the actual
offset.

If we have reached this scenario because there is no breaking
opportunity to prevent the overflow, then we just call ShapeToEnd and
return. Otherwise, we continue processing the text item. In this
situation, we must ensure that the new offset is greater than the
previously computed non-hangable run end, since it's possible that we
end up using it as the final offset, leading to the assert violation
described in the bug, since the used break-offset is smaller than the
item's end.

This CL adds the logic to prevent this situation, clearing the
non-hangable run end and computing it again, if necessary, based on
the new offset.

Bug: 1161793
Change-Id: Ie10ffae3c654aefa626d80abd01bd38e026c9e27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2604908
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842461}
parent 7175de90
......@@ -362,6 +362,14 @@ scoped_refptr<const ShapeResultView> ShapingLineBreaker::ShapeLine(
if (result_out->is_overflow)
return ShapeToEnd(start, first_safe, range_start, range_end);
break_opportunity.offset = range_end;
if (break_opportunity.non_hangable_run_end &&
range_end < break_opportunity.non_hangable_run_end) {
break_opportunity.non_hangable_run_end = base::nullopt;
}
if (IsBreakableSpace(text[range_end - 1])) {
break_opportunity.non_hangable_run_end =
FindNonHangableEnd(text, range_end - 1);
}
}
CheckBreakOffset(break_opportunity.offset, start, range_end);
......
......@@ -247,6 +247,9 @@ crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-spa
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-005.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-006.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-007.html [ Failure ]
crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-017.html [ Failure ]
crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-020.html [ Failure ]
crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-023.html [ Failure ]
### external/wpt/css/css-text/word-break/
crbug.com/591099 external/wpt/css/css-text/word-break/word-break-break-all-004.html [ Failure ]
......
......@@ -1545,10 +1545,10 @@ crbug.com/1129834 external/wpt/css/css-text/white-space/trailing-other-space-sep
crbug.com/1129834 external/wpt/css/css-text/white-space/trailing-other-space-separators-002.html [ Failure ]
crbug.com/1129834 external/wpt/css/css-text/white-space/trailing-other-space-separators-003.html [ Failure ]
crbug.com/1129834 external/wpt/css/css-text/white-space/trailing-other-space-separators-004.html [ Failure ]
crbug.com/1129834 external/wpt/css/css-text/white-space/full-width-leading-spaces-004.html [ Failure ]
crbug.com/1129834 external/wpt/css/css-text/white-space/trailing-ideographic-space-001.html [ Failure ]
crbug.com/1129834 external/wpt/css/css-text/white-space/trailing-ideographic-space-002.html [ Failure ]
crbug.com/1162836 external/wpt/css/css-text/white-space/full-width-leading-spaces-004.html [ Failure ]
# Follow up the spec change for U+2010, U+2013
crbug.com/1052717 external/wpt/css/css-text/line-break/line-break-loose-hyphens-001.html [ Failure ]
......
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-none">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Disabled hypenation and unicode-bidi 'plaintext' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: plaintext;
hyphens: none;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>&#x3000;&#x3000;</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-none">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Disabled hypenation and unicode-bidi 'plaintext' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: plaintext;
hyphens: none;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>XX</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-none">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Disabled hypenation and unicode-bidi 'plaintext' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: plaintext;
hyphens: none;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>X&#x3000;</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-isolate">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-none">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Disabled hypenation and unicode-bidi 'isolate' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: isolate;
hyphens: none;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>&#x3000;&#x3000;</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-isolate">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-none">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Disabled hypenation and unicode-bidi 'isolate' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: isolate;
hyphens: none;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>XX</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-isolate">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-none">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Disabled hypenation and unicode-bidi 'isolate' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: isolate;
hyphens: none;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>X&#x3000;</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-auto">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Auto hypenation and unicode-bidi 'plaintext' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: plaintext;
hyphens: auto;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>&#x3000;&#x3000;</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-auto">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Auto hypenation and unicode-bidi 'plaintext' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: plaintext;
hyphens: auto;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>XX</span></div>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text level 3 Test: handling trailing ideographic space sequence</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-normal">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-hyphens-auto">
<link rel="match" href="reference/white-space-break-spaces-005-ref.html">
<meta name="assert" content="Auto hypenation and unicode-bidi 'plaintext' should not affect, hence the trailing ideographic spaces must hang; however, the rest of the sequence is wrapped due to the forced break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 50px/1 Ahem;
width: 1ch;
}
span {
background: green;
color: transparent;
unicode-bidi: plaintext;
hyphens: auto;
}
.ref {
position: absolute;
color: red;
z-index: -1;
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="ref">XX<br>XX</div>
<div><span>X&#x3000;<br>X&#x3000;</span></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