layout: Implement overflow-wrap/word-wrap per CSS-TEXT § 6.2.

This property is used by approximately 55% of page loads.

To implement the line breaking behavior, the "breaking strategy" has
been cleaned up and abstracted. This should allow us to easily support
other similar properties in the future, such as `text-overflow` and
`word-break`.
This commit is contained in:
Patrick Walton 2014-12-12 22:03:00 -08:00
parent 1be7d7cced
commit 6943ddb93e
8 changed files with 356 additions and 139 deletions

View file

@ -199,3 +199,4 @@ fragment=top != ../html/acid2.html acid2_ref.html
!= border_black_ridge.html border_black_groove.html
== text_indent_a.html text_indent_ref.html
== word_spacing_a.html word_spacing_ref.html
== overflow_wrap_a.html overflow_wrap_ref.html

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<!-- Tests that `overflow-wrap: break-word` breaks words if it needs to, but only when
necessary. -->
<link rel="stylesheet" type="text/css" href="css/ahem.css">
<style>
html, body {
margin: 0;
}
section {
word-wrap: break-word;
width: 300px;
color: purple;
}
</style>
</head>
<body>
<section>X XXXXXX</section>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<!-- Tests that `overflow-wrap: break-word` breaks words if it needs to, but only when
necessary. -->
<style>
section, nav {
background: purple;
position: absolute;
left: 0;
}
section {
width: 100px;
top: 0;
height: 100px;
}
nav {
top: 100px;
width: 300px;
height: 200px;
}
</style>
</head>
<body>
<section></section><nav></nav>
</body>
</html>