Skip to content

Commit

Permalink
Trailing spaces that hang don't contribute to intrinsic size
Browse files Browse the repository at this point in the history
During the min-content contribution we should use the non-hangable run
end, unless the white-space property is set to 'break-spaces'.

Additionally, we should ensure that hanging trailing spaces doesn't
account for the NGItemResult's inline size.

Bug: 972992, 1071928
Change-Id: Ife1b3212164b1494e822fa141cd44896e6359ef9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418678
Reviewed-by: Koji Ishii <[email protected]>
Commit-Queue: Javier Fernandez <[email protected]>
Cr-Commit-Position: refs/heads/master@{#879781}
  • Loading branch information
javifernandez authored and chromium-wpt-export-bot committed May 6, 2021
1 parent bee9f7d commit a03d7c3
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 9 deletions.
35 changes: 35 additions & 0 deletions css/css-text/overflow-wrap/overflow-wrap-min-content-size-009.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Test: min-content sizing and white-space: pre-wrap</title>
<link rel="author" title="Javier Fernandez" href="mailto:[email protected]">
<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/#overflow-wrap-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-overflow-wrap-anywhere">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#propdef-white-space">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap">
<link rel="match" href="reference/overflow-wrap-min-content-size-009-ref.html">
<meta name="assert" content="Using 'overflow-wrap:anywhere' doesn't prevent the tabs sequence to hang (inconditionally) , honoring 'white-space: pre-wrap' hence glyphs **are not** considered when calculating min-content intrinsic sizes.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 20px/1 Ahem;
}
.test {
color: green;
background: red;
z-index: -1;

width: min-content;
white-space: pre-wrap;
overflow-wrap: anywhere
}
.ref {
position: absolute;
background: green;
color: transparent;
}
</style>

<p>Test passes if there is a green box below and no red.
<div class="ref"><br><br>X</div>
<div class="test">&#9;&#9;<span>XX</span></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Test reference</title>
<link rel="author" title="Javier Fernandez" href="mailto:[email protected]">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 20px/1 Ahem;
position: absolute;
background: green;
color: transparent;
}
</style>

<p>Test passes if there is a green box below and no red.
<div>X<br>X<br>X</div>
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

<p>This test passes if there is a green square and no red.

<div>XX<br>XX</div>
<div>XX<span>X</span><br>XX</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
font: 25px/1 Ahem;
color: green;
}
span { color: blue; }
</style>

<p>This test passes if there is a green square and no red.

<div>XX<span>X</span><br>XX</div>
<div>XX<br>XX</div>
25 changes: 25 additions & 0 deletions css/css-text/white-space/white-space-intrinsic-size-005.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Test: min-content sizing and white-space: pre-wrap</title>
<link rel="author" title="Javier Fernandez" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#propdef-white-space">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-004-ref.html">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved spaces at the end of the line unconditioanlly hang, hence they do not affect the intrinsic min-content size.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 25px/1 Ahem;
color: green;
background: red;

width: min-content;
white-space: pre-wrap;
}
span { background: blue; } /* If the space is removed instead of hanging, there will be no blue box*/
</style>

<p>This test passes if there is a green square and no red.

<div>XX<span>&#x0020;</span>XX</div>
23 changes: 23 additions & 0 deletions css/css-text/white-space/white-space-intrinsic-size-006.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Test: min-content sizing and white-space: pre-wrap</title>
<link rel="author" title="Javier Fernandez" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#propdef-white-space">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved spaces unconditionally hang if they might overflow otherwise, hence they do not affect the intrinsic min-content size.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 25px/1 Ahem;
color: green;
background: red;

width: min-content;
white-space: pre-wrap;
}
</style>

<p>This test passes if there is a green square and no red.

<div>XX&#x0020;XX</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="help" title="3. White Space and Wrapping: the white-space property" 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="help" title="4.1.3. Phase II: Trimming and Positioning" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-004-ref.html">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved white space at the end of a soft-wrapped line is hanged when white-space is pre-wrap.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="help" title="5.5. Overflow Wrapping: the overflow-wrap/word-wrap property" href="https://drafts.csswg.org/css-text-3/#overflow-wrap-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-overflow-wrap-break-word">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-004-ref.html">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved white space at the end of a soft-wrapped line is hanged when white-space is pre-wrap.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
Expand All @@ -20,6 +21,9 @@
white-space: pre-wrap;
overflow-wrap: break-word;
}
span {
background: blue;
}
</style>

<p>This test passes if there is a green square and no red.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<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" title="5.5. Overflow Wrapping: the overflow-wrap/word-wrap property" href="https://drafts.csswg.org/css-text-3/#overflow-wrap-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-overflow-wrap-break-word">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-004-ref.html">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved white space at the end of a soft-wrapped line is hanged when white-space is pre-wrap.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<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" title="5.5. Overflow Wrapping: the overflow-wrap/word-wrap property" href="https://drafts.csswg.org/css-text-3/#overflow-wrap-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-overflow-wrap-anywhere">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-004-ref.html">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved white space at the end of a soft-wrapped line is hanged when white-space is pre-wrap.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="help" title="5.2. Breaking Rules for Letters: the word-break property" href="https://drafts.csswg.org/css-text-3/#word-break-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-word-break-break-all">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-004-ref.html">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved white space at the end of a soft-wrapped line is hanged when white-space is pre-wrap.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
Expand All @@ -20,6 +21,7 @@
white-space: pre-wrap;
word-break: break-all;
}
span { background: blue; } /* If the space is removed instead of hanging, there will be no blue box*/
</style>

<p>This test passes if there is a green square and no red.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<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" title="5.2. Breaking Rules for Letters: the word-break property" href="https://drafts.csswg.org/css-text-3/#word-break-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-word-break-break-all">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-004-ref.html">
<link rel="match" href="reference/white-space-pre-wrap-trailing-spaces-alt-004-ref.html">
<meta name="assert" content="Preserved white space at the end of a soft-wrapped line is hanged when white-space is pre-wrap.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
Expand Down
4 changes: 2 additions & 2 deletions css/css-text/word-break/word-break-min-content-006.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Test: overflow-wrap: anywhere and intrinsic sizing</title>
<title>CSS Text Test: word-break: break-word and intrinsic sizing</title>
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org/">
<link rel="author" title="Mozilla" href="https://www.mozilla.org/">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#overflow-wrap-property">
<meta name="flags" content="">
<link rel="match" href="../overflow-wrap/reference/overflow-wrap-min-content-size-002-ref.html">
<meta name="assert" content="overflow-wrap:anywhere doesn't break grapheme cluster and min-content intrinsic size should take that into account.">
<meta name="assert" content="'word-break: break-word' doesn't break grapheme cluster and min-content intrinsic size should take that into account.">
<style>
#wrapper {
width: 0px;
Expand Down
35 changes: 35 additions & 0 deletions css/css-text/word-break/word-break-min-content-007.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Test: min-content sizing and white-space: pre-wrap</title>
<link rel="author" title="Javier Fernandez" href="mailto:[email protected]">
<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/#word-break-property">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-word-break-break-word">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#propdef-white-space">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap">
<link rel="match" href="../overflow-wrap/reference/overflow-wrap-min-content-size-009-ref.html">
<meta name="assert" content="word-break: break-word should behave as overflow-wrap: anywhere, so breaking opportunities **are not** considered when calculating min-content intrinsic sizes.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
div {
font: 20px/1 Ahem;
}
.test {
color: green;
background: red;
z-index: -1;

width: min-content;
white-space: pre-wrap;
word-break: break-word;
}
.ref {
position: absolute;
background: green;
color: transparent;
}
</style>

<p>Test passes if there is a green box below and no red.
<div class="ref"><br><br>X</div>
<div class="test">&#9;&#9;<span>XX</span></div>

0 comments on commit a03d7c3

Please sign in to comment.