Add support for pre-wrap and pre-line values for white-space.

This is mostly straightforward.  I had to modify a couple of places
which were accidentally discarding whitespace.

Fixes #1513.
This commit is contained in:
Eli Friedman 2015-10-12 19:02:14 -07:00
parent 5e4f132b3b
commit 3a451ff845
17 changed files with 427 additions and 104 deletions

View file

@ -3047,6 +3047,54 @@
"url": "/_mozilla/css/visibility_hidden.html"
}
],
"css/white-space-mixed-002.htm": [
{
"path": "css/white-space-mixed-002.htm",
"references": [
[
"/_mozilla/css/white-space-mixed-002-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-mixed-002.htm"
}
],
"css/white-space-normal-001.htm": [
{
"path": "css/white-space-normal-001.htm",
"references": [
[
"/_mozilla/css/white-space-normal-001-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-normal-001.htm"
}
],
"css/white-space-pre-line.htm": [
{
"path": "css/white-space-pre-line.htm",
"references": [
[
"/_mozilla/css/white-space-pre-line-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-pre-line.htm"
}
],
"css/white-space-pre-wrap.htm": [
{
"path": "css/white-space-pre-wrap.htm",
"references": [
[
"/_mozilla/css/white-space-pre-wrap-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-pre-wrap.htm"
}
],
"css/whitespace_nowrap_a.html": [
{
"path": "css/whitespace_nowrap_a.html",
@ -6888,6 +6936,54 @@
"url": "/_mozilla/css/visibility_hidden.html"
}
],
"css/white-space-mixed-002.htm": [
{
"path": "css/white-space-mixed-002.htm",
"references": [
[
"/_mozilla/css/white-space-mixed-002-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-mixed-002.htm"
}
],
"css/white-space-normal-001.htm": [
{
"path": "css/white-space-normal-001.htm",
"references": [
[
"/_mozilla/css/white-space-normal-001-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-normal-001.htm"
}
],
"css/white-space-pre-line.htm": [
{
"path": "css/white-space-pre-line.htm",
"references": [
[
"/_mozilla/css/white-space-pre-line-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-pre-line.htm"
}
],
"css/white-space-pre-wrap.htm": [
{
"path": "css/white-space-pre-wrap.htm",
"references": [
[
"/_mozilla/css/white-space-pre-wrap-ref.htm",
"=="
]
],
"url": "/_mozilla/css/white-space-pre-wrap.htm"
}
],
"css/whitespace_nowrap_a.html": [
{
"path": "css/whitespace_nowrap_a.html",

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 B

View file

@ -0,0 +1,42 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- This is a lightly modified copy of
tests/wpt/css-tests/css21_dev/html4/reference/white-space-mixed-002-ref.htm,
changed to work around a bug in Servo's float handling.
-->
<html>
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
<style type="text/css">
div
{
background-color: yellow;
border: blue solid medium;
margin-left: 20px;
width: 140px;
margin-top: 36px;
}
div+div { margin-top: 56px; }
img {vertical-align: top;}
img:first-child {float: right;}
</style>
</head>
<body>
<p>Test passes if the contents of the 2 blue stripes are <strong>identical</strong>.</p>
<div><img src="swatch-orange.png" width="20" height="20" alt="Image download support must be enabled"><img src="swatch-orange.png" width="20" height="20" alt="Image download support must be enabled"></div>
<div><img src="swatch-orange.png" width="20" height="20" alt="Image download support must be enabled"><img src="swatch-orange.png" width="20" height="20" alt="Image download support must be enabled"></div>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- This is an exact copy of tests/wpt/css-tests/css21_dev/html4/white-space-mixed-002.htm;
the corresponding reference page is modified so Servo passes.
-->
<html>
<head>
<title>CSS Test: white-space: mixed tests (simple)</title>
<link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch">
<link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> <!-- 2012-06-29 -->
<link rel="alternate" href="http://www.hixie.ch/tests/adhoc/css/text/white-space/mixed/002.html" type="text/html">
<link rel="help" href="http://www.w3.org/TR/CSS21/text.html#white-space-model">
<link rel="match" href="reference/white-space-mixed-002-ref.htm">
<meta name="flags" content="ahem">
<style type="text/css">
.test { border: solid blue; font: 1.25em/1 Ahem; background: yellow; color: orange; float: left; clear: left; margin: 1em; }
.normal { white-space: normal; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre; }
</style>
</head>
<body>
<p>Test passes if the contents of the 2 blue stripes are <strong>identical</strong>.</p>
<div class="test normal">[<span class="normal"> </span><span class="pre"> </span><span class="normal"> </span><span class="pre"> </span><span class="normal"> </span>]</div>
<div class="test pre">[ ]</div>
</body>
</html>

View file

@ -0,0 +1,41 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- This is a lightly modified copy of
tests/wpt/css-tests/css21_dev/html4/reference/white-space-normal-001-ref.htm,
changed to work around a bug in Servo's margin handling (?).
-->
<html>
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
<style type="text/css">
div
{
background-color: green;
border: black solid medium;
height: 120px;
text-align: center;
width: 60px;
margin-top: 19px;
}
img
{
vertical-align: top;
}
</style>
</head>
<body>
<p>Test passes if there is a rectangle with 3 columns (1 dark green, 1 light green and then 1 dark green) and if there is <strong>no red</strong>.</p>
<div><img src="swatch-lime.png" width="20" height="120" alt="Image download support must be enabled"></div>
</body>
</html>

View file

@ -0,0 +1,50 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- This is an exact copy of tests/wpt/css-tests/css21_dev/html4/white-space-normal-001.htm;
the corresponding reference page is modified so Servo passes.
-->
<html>
<head>
<title>CSS Test: white-space normal: simple tests</title>
<link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch">
<link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> <!-- 2012-06-29 -->
<link rel="alternate" href="http://www.hixie.ch/tests/adhoc/css/text/white-space/normal/001.html" type="text/html">
<link rel="help" href="http://www.w3.org/TR/CSS21/text.html#white-space-model">
<link rel="match" href="reference/white-space-normal-001-ref.htm">
<meta name="flags" content="ahem">
<style type="text/css">
* { white-space: normal; }
div { display: block; }
span { display: inline; }
table { padding: 0; border-spacing: 0; border: solid; }
td { font: 20px/1 Ahem; color: red; background: red; padding: 0; }
.red { background: red; }
.green { color: green; background: lime; }
.check { width: 3em; background: lime; color: green; }
</style>
</head>
<body>
<p>Test passes if there is a rectangle with 3 columns (1 dark green, 1 light green and then 1 dark green) and if there is <strong>no red</strong>.</p>
<table>
<tr>
<td>
<div class="red"> </div>
<div class="red"> <div></div></div>
<div class="red"> <div> </div></div>
<div class="red"><div> </div></div>
<div class="red"><div> </div> </div>
<div class="red"><div></div> </div>
<div class="red"> <div></div> </div>
<div class="red"> <div> </div> </div>
<div class="green"><span>X</span> <span>X</span></div>
<div class="green"> <span>X</span> <span>X</span></div>
<div class="green"><span>X</span> <span>X</span> </div>
<div class="green"> <div></div> <span>X</span> <span>X</span> </div>
<div class="green"> <span>X</span> <span>X</span> <div></div> </div>
<div class="check">X X</div>
</td>
</tr>
</table>
</body>
</html>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>whitespace pre-line basic functionality test</title>
<style>
div { white-space: normal; font: 1.25em/1 Ahem; width: 6em }
</style>
</head>
<body>
<div>X<br>
XX<br>
XX XX<br>
XX<br>
</div>
</body>
</html>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>whitespace pre-line basic functionality test</title>
<style>
div { white-space: pre-line; font: 1.25em/1 Ahem; width: 6em }
</style>
</head>
<body>
<div>X<!--newline in pre-line-->
XX<!--whitespace at start of line-->
XX XX XX<!-- wrapping -->
</div>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>whitespace pre-wrap basic functionality test</title>
<style>
div { white-space: normal; font: 1.25em/1 Ahem; width: 6em }
</style>
</head>
<body>
<div>X<br>
&nbsp;&nbsp;XX<br>
&nbsp;&nbsp;XX<br>
XX<br>
X&nbsp;&nbsp;X<br>
X<br>
X<br>
</div>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>whitespace pre-wrap basic functionality test</title>
<style>
div { white-space: pre-wrap; font: 1.25em/1 Ahem; width: 6em }
</style>
</head>
<body>
<div>X<!--newline in pre-wrap-->
XX<!--whitespace at start of line-->
XX XX<!--wrapping-->
X X<!--whitespace in middle line-->
X <!--trailing whitespace-->
X
</div>
</body>
</html>