Skip to content

Truly independent web browser

LibWeb: Implement line-break: anywhere

sideshowbarker3bb236ef7f4a
diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.json
index c26452e9e66..2bafb902b14 100644
--- a/Libraries/LibWeb/CSS/Enums.json
+++ b/Libraries/LibWeb/CSS/Enums.json
@@ -792,6 +792,7 @@
"anchor-center"
],
"line-break": [
+ "anywhere",
"auto",
"loose",
"normal",
diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json
index 42675432dee..b86e2b662b7 100644
--- a/Libraries/LibWeb/CSS/Properties.json
+++ b/Libraries/LibWeb/CSS/Properties.json
@@ -3448,6 +3448,7 @@
"inherited": true,
"requires-computation": "never",
"valid-identifiers": [
+ "anywhere",
"auto",
"loose",
"normal",
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
index bc6bf47365c..3a2ca062605 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
@@ -154,7 +154,11 @@ pub(crate) fn hyphen_glyph_run(
pub(crate) fn soft_hyphen_hyphenates(style: StyleValues<'_>) -> bool {
// https://drafts.csswg.org/css-text-3/#valdef-word-break-break-all
// Hyphenation is not applied.
- style.hyphens() != hyphens::NONE && style.word_break() != word_break::BREAK_ALL
+ // https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere
+ // Hyphenation is not applied.
+ style.hyphens() != hyphens::NONE
+ && style.word_break() != word_break::BREAK_ALL
+ && style.line_break() != line_break::ANYWHERE
}
/// The inline size of the hyphen that a line ends in if it breaks right after `item`: none, unless the item's text ends
diff --git a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
index 274512ddd01..d38432ec1de 100644
--- a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
+++ b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
@@ -889,7 +889,7 @@ pub(crate) fn soft_wrap_opportunity_between(
let (Some(&last), Some(&first)) = (before.last(), after.first()) else {
return false;
};
- if last == SOFT_HYPHEN && !breaks_after_soft_hyphen {
+ if last == SOFT_HYPHEN && !breaks_after_soft_hyphen && line_break != line_break::ANYWHERE {
return false;
}
// NB: Whitespace gives its own soft wrap opportunities.
@@ -924,8 +924,9 @@ pub(crate) fn soft_wrap_opportunity_between(
text.extend_from_slice(&before[before_start..]);
let boundary = text.len();
text.extend_from_slice(&after[..after_end]);
- // OPTIMIZATION: Printable ASCII on both sides needs no line segmenter.
+ // OPTIMIZATION: Printable ASCII on both sides needs no line segmenter, unless line-break: anywhere breaks it.
if word_break != word_break::BREAK_ALL
+ && line_break != line_break::ANYWHERE
&& let Some(is_boundary) = ascii_line_break_at(&text, boundary)
{
return is_boundary;
@@ -1024,6 +1025,8 @@ fn break_all_adds_soft_wrap_opportunity(before: u32, after: u32, line_break: u8)
struct LineBreaker<'text> {
text: &'text [u16],
line_segmenter: LineSegmenter<'text>,
+ /// The grapheme clusters of the text, which `line-break: anywhere` breaks between.
+ grapheme_segmenter: std::cell::OnceCell<GraphemeSegmenter>,
word_break: u8,
line_break: u8,
breaks_after_soft_hyphen: bool,
@@ -1040,6 +1043,7 @@ impl<'text> LineBreaker<'text> {
Self {
text,
line_segmenter: LineSegmenter::new(text, line_break, line_break_language),
+ grapheme_segmenter: std::cell::OnceCell::new(),
word_break,
line_break,
breaks_after_soft_hyphen,
@@ -1047,6 +1051,20 @@ impl<'text> LineBreaker<'text> {
}
fn is_at_line_break_opportunity(&self, index: usize) -> bool {
+ // https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere
+ // "There is a soft wrap opportunity around every typographic character unit, including around any punctuation
+ // character or preserved white spaces, or in the middle of words, disregarding any prohibition against line
+ // breaks, even those introduced by characters with the GL, WJ, or ZWJ line breaking classes or mandated by the
+ // 'word-break' property."
+ if self.line_break == line_break::ANYWHERE {
+ return index > 0
+ && index < self.text.len()
+ && self
+ .grapheme_segmenter
+ .get_or_init(|| GraphemeSegmenter::new(self.text))
+ .next_boundary(index, true)
+ == Some(index);
+ }
// https://drafts.csswg.org/css-text-3/#valdef-hyphens-none
// Words are not hyphenated, even if characters inside the word explicitly define hyphenation opportunities.
if !self.breaks_after_soft_hyphen && index > 0 && self.text.get(index - 1) == Some(&SOFT_HYPHEN) {
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-001-ref.html
new file mode 100644
index 00000000000..daf17c9c0aa
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-001-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test Reference</title>
+<link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net/">
+<style>
+#green {
+ position: absolute;
+ background: green;
+ font-family: monospace;
+ width: 1ch;
+ height: 19em;
+}
+</style>
+
+<p>Test passes if there is a green rectangle below and no red.</p>
+<div id=green></div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-003-ref.html
new file mode 100644
index 00000000000..ceec198d03b
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-003-ref.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en" >
+<head>
+<meta charset="utf-8">
+<title>word-break: break-all, latin</title>
+<link rel='author' title='Richard Ishida' href='mailto:[email protected]'>
+<style type='text/css'>
+.test { word-break: break-all; }
+/* the CSS below is not part of the test */
+.test, .ref { border: 1px solid orange; margin: 20px; padding: 10px; width: 390px; font: 36px/1 sans-serif; }
+</style>
+</head>
+<body>
+<div id='instructions'>Test passes if the two orange boxes are the same.</div>
+<div class="ref"><span>Latin latin latin lati<br/>n</span></div>
+<div class="ref"><span>Latin latin latin lati<br/>n</span></div>
+</body>
+</html>
\ No newline at end of file
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html
new file mode 100644
index 00000000000..0e0300a72dc
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Text Reference File</title>
+<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">
+<style>
+div {
+ position: relative;
+ width: 100px;
+ height: 100px;
+ background: green;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div></div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-001.html
new file mode 100644
index 00000000000..61bd0082885
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-001.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net/">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-001-ref.html">
+<meta name="assert" content="line-break:anywhere puts a soft wrap opportunity around every typographic character unit,
+ including around punctuation or in the middle of words,
+ disregarding any prohibition against line breaks introduced by characters with the GL, JW, or ZJW character class.">
+<style>
+#green {
+ position: absolute;
+ background: green;
+ font-family: monospace;
+ width: 1ch;
+ height: 19em;
+}
+#test {
+ width: 1ch;
+ line-height: 1;
+ color: red;
+ font-family: monospace;
+ line-break: anywhere;
+}
+span {
+ background: red;
+}
+</style>
+
+<p>Test passes if there is a green rectangle below and no red.</p>
+<div id=green></div>
+<!-- with line breaks everywhere, none of the following characters should stick out from under the green div -->
+<div id=test>aa-a.a)a,a)a<span>&nbsp;</span>a&#xfeff;a&#x2060;a&#x200d;a・a</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-002.html
new file mode 100644
index 00000000000..007557d0317
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-002.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net/">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-001-ref.html">
+<meta name="assert" content="line-break:anywhere puts a soft wrap opportunity betwwen letters in the middle of words and hyphenation is not applied.">
+<style>
+#green {
+ position: absolute;
+ background: green;
+ font-family: monospace;
+ width: 1ch;
+ height: 19em;
+}
+#test {
+ width: 1ch;
+ line-height: 1;
+ color: red;
+ font-family: monospace;
+ line-break: anywhere;
+ hyphens: auto;
+}
+</style>
+
+<p>Test passes if there is a green rectangle below and no red.</p>
+<div id=green></div>
+<!-- Hyphenation, if it occurs, will produce a hyphen that sticks out from under the green rectangle.
+ Also, if the words fails to be wrapped between all letters, letters will also stick out from under the green rectangle -->
+<div id=test>no hyphenation</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-003.html
new file mode 100644
index 00000000000..b167eaa9899
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-003.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez" href="mailto:[email protected]" />
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-003-ref.html">
+<meta name="assert" content="line-break: anywhere means lines may break between any two typographic letter units.">
+<style type='text/css'>
+.test { line-break: anywhere; }
+/* the CSS below is not part of the test */
+.test, .ref { border: 1px solid orange; margin: 20px; padding: 10px; width: 390px; font: 36px/1 sans-serif; }
+</style>
+</head>
+<body>
+<div id='instructions'>Test passes if the two orange boxes are the same.</div>
+<div class="test"><div id="testdiv"><span id="testspan">Latin latin latin latin</span></div></div>
+<div class="ref"><span>Latin latin latin lati<br/>n</span></div>
+<script>
+var sentenceWidth = document.getElementById('testspan').offsetWidth
+document.getElementById('testdiv').style.width = String(sentenceWidth - 5)+'px'
+</script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-004.html
new file mode 100644
index 00000000000..c817332fee3
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-004.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<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" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-word-break-keep-all">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="The second word is broken, despite the word-break: keep-all, because line-break: anywhere disregarde any prohibition against line breaks mandate by word-break.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 25px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-height: 1;
+ word-break: keep-all;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XX X<br>XX</div>
+ <div class="test">XX XXX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-006.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-006.html
new file mode 100644
index 00000000000..caa535d2e9f
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-006.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break: anywhere' disgregard the prohibition against line breaks introduced by characters with the GL character class">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 25px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<br>&nbsp;XXX<br>X X <br>X</div>
+ <div class="test">XXXX&nbsp;XXXX X X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-007.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-007.html
new file mode 100644
index 00000000000..6bce136f956
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-007.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break:anywhere allows breaking opportunities around punctuaction characters.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 5ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">X XXX<br>XX</div>
+ <div class="test">X XX...</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-008.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-008.html
new file mode 100644
index 00000000000..08e946a8629
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-008.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="3. White Space and Wrapping: the white-space property" href="https://www.w3.org/TR/css-text-3/#white-space-property">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="break-all breaks between the last two letters, because breaking opportunities between the punctuaction characters are forbidden.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 5ch;
+ white-space: pre-wrap;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">X XXX<br>XX</div>
+ <div class="test">X XX...</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-009.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-009.html
new file mode 100644
index 00000000000..8f4cb0c8245
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-009.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="3. White Space and Wrapping: the white-space property" href="https://www.w3.org/TR/css-text-3/#white-space-property">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-break-spaces">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break: anywhere' disgregard the prohibition against line breaks introduced by characters with the GL character class">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 25px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ white-space: break-spaces;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<br>&nbsp;XXX<br>X X <br>X</div>
+ <div class="test">XXXX&nbsp;XXXX X X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-010.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-010.html
new file mode 100644
index 00000000000..e792bd2ce63
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-010.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="3. White Space and Wrapping: the white-space property" href="https://www.w3.org/TR/css-text-3/#white-space-property">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-white-space-pre-wrap">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break: anywhere' disgregard the prohibition against line breaks introduced by characters with the GL character class">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 25px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ white-space: pre-wrap;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<br>&nbsp;XXX<br>X X <br>X</div>
+ <div class="test">XXXX&nbsp;XXXX X X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-011.html
new file mode 100644
index 00000000000..c3795ee7595
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-011.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break:anywhere allows breaking opportunities around slash characters.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 5ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">X XXX<br>XX</div>
+ <div class="test">X XX///</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-012.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-012.html
new file mode 100644
index 00000000000..e5a7e3aae67
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-012.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break:anywhere allows breaking opportunities around backslash characters.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 5ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">X XXX<br>XX</div>
+ <div class="test">X XX\\\</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-013.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-013.html
new file mode 100644
index 00000000000..8c928a3f69b
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-013.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break:anywhere allows breaking opportunities before slash characters.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 3ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXX<br>XX</div>
+ <div class="test">XXX/X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-014.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-014.html
new file mode 100644
index 00000000000..9826f4c5b2f
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-014.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break:anywhere allows breaking opportunities before backslash characters.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 3ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXX<br>XX</div>
+ <div class="test">XXX\X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-015.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-015.html
new file mode 100644
index 00000000000..7f1a351b631
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-015.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break:anywhere allows breaking opportunities after backslash characters.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<br>X</div>
+ <div class="test">XXX\X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-016.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-016.html
new file mode 100644
index 00000000000..8baa9f2d5be
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-016.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<meta name="assert" content="line-break:anywhere allows breaking opportunities after slash characters.">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+div {
+ position: relative;
+ font-size: 20px;
+ font-family: Ahem;
+ line-height: 1em;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<br>X</div>
+ <div class="test">XXX/X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-017.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-017.html
new file mode 100644
index 00000000000..25cac9aa168
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-017.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.3. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="The text is wrapped into two lines, since there is no need to break the second line using the space in the middle.">
+<style>
+div {
+ position: relative;
+ font: 25px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 3ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXX<br>X X</div>
+ <div class="test">XXXX<span> </span>X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-001.html
new file mode 100644
index 00000000000..06e00636672
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-001.html
@@ -0,0 +1,39 @@
+
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere and the white-space property</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<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">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="'line-break: anywhere' can't prevent overflow under 'white-space: pre', because it line wrapping is not allowed. ">
+<style>
+div {
+ position: relative;
+ font: 10px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 3ch;
+ line-break: anywhere;
+
+ white-space: pre;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<span style="color: green">XXXX</span>XX</div>
+ <div class="test">XXXX XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-002.html
new file mode 100644
index 00000000000..589c8abaa80
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-002.html
@@ -0,0 +1,40 @@
+
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere and the white-space property</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<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-nowrap">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="'line-break: anywhere' can't prevent overflow under 'white-space: nowrap', because it line wrapping is not allowed. ">
+<style>
+div {
+ position: relative;
+ font: 10px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 5ch;
+ line-break: anywhere;
+
+ white-space: nowrap;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX XX</div>
+ <div class="test">XXXX XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-003.html
new file mode 100644
index 00000000000..8bdb7217125
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-003.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere and the white-space property</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<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">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="'line-break: anywhere' can't prevent overflow under 'white-space: pre', because it line wrapping is not allowed. ">
+<style>
+div {
+ position: relative;
+ font: 25px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 2ch;
+ line-break: anywhere;
+
+ white-space: pre;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red"><span style="color: green">X</span>XXX</div>
+ <div class="test"> XXX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-004.html
new file mode 100644
index 00000000000..b9b177797ca
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-004.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere and the white-space property</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<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-normal">
+<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.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="The line is wrapped ignoring the white space, which will be removed honoring 'white-space: normal'">
+<style>
+div {
+ position: relative;
+ font: 25px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+
+ white-space: normal;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXX<br>XX</div>
+ <div class="test">XXX<span style="background: red"> </span>XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-005.html
new file mode 100644
index 00000000000..8bb109626a2
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-005.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere and the white-space property</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<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-normal">
+<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.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="The line is wrapped ignoring the white space, which will be removed honoring 'white-space: normal'">
+<style>
+div {
+ position: relative;
+ font: 25px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+
+ white-space: normal;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<br>X</div>
+ <div class="test"><span style="background: red"> </span>XXXXX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-008.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-008.html
new file mode 100644
index 00000000000..5616cba68f0
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-and-white-space-008.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere and the white-space property</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<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-break-spaces">
+<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.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="'line-break: anywhere' allows preserved white spaces at the end of the line, honoring 'white-space: break-spaces'.">
+<style>
+div {
+ position: relative;
+ font: 25px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+
+ line-break: anywhere;
+ white-space: break-spaces;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XX<span style="color: green">XX<br>XX</span>XX<br>XXX</div>
+ <div class="test">XX XXXXX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-001.html
new file mode 100644
index 00000000000..91e859269af
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-001.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the WJ classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 2ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red"></div>
+ <div class="test">XX&#x2060;XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-002.html
new file mode 100644
index 00000000000..6424aa2a83a
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-002.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the WJ classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 2ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red"></div>
+ <div class="test">XX&#xFEFF;XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-003.html
new file mode 100644
index 00000000000..ce7b6fdd6ff
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-003.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the ZW classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 25px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ color: red;
+ background: green;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXX<br>XX</div>
+ <div class="test">..&#x200B;...X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-004.html
new file mode 100644
index 00000000000..2f8638f27e6
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-004.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 3ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red"></div>
+ <div class="test">XX&nbsp;XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-005.html
new file mode 100644
index 00000000000..56b90243f16
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-005.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 2ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XX<br><span style="color: green">X</span>X</div>
+ <div class="test">XX&nbsp;X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-006.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-006.html
new file mode 100644
index 00000000000..97747a4c6bc
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-006.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: red;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red"></div>
+ <div class="test">XX &nbsp;XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-007.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-007.html
new file mode 100644
index 00000000000..17e69cb9283
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-007.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 20px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ height: 100px;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 5ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XXXXX<br>XX</div>
+ <div class="test">XXX<span style="background: green"> &nbsp;X</span>XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-008.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-008.html
new file mode 100644
index 00000000000..ceb6ff51cc1
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-008.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 3ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XX<br>X</div>
+ <div class="test">XX&#x202F;X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-009.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-009.html
new file mode 100644
index 00000000000..b9f6887f8ba
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-009.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 2ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XX<br>X</div>
+ <div class="test">XX&#x180E;X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-010.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-010.html
new file mode 100644
index 00000000000..0d16090caca
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-010.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: red;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 3ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red"></div>
+ <div class="test">XX &#x180E;XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-011.html
new file mode 100644
index 00000000000..700a03bf187
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-011.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the GL classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 2ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XX<br>X</div>
+ <div class="test">XX&#x034F;X</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-015.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-015.html
new file mode 100644
index 00000000000..fc742b2c196
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-015.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the ZWJ classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 50px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: red;
+ height: 100px;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 2ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red"></div>
+ <div class="test">XX&#x200D;XX</div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-016.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-016.html
new file mode 100644
index 00000000000..98554060e74
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-016.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang=en>
+<meta charset="utf-8">
+<title>CSS Text Test: line-break: anywhere overrides behavior defined for the WJ, ZW, GL, and ZWJ classes</title>
+<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:[email protected]">
+<link rel="help" title="5.1. Line Breaking Details" href="https://drafts.csswg.org/css-text-3/#line-break-details">
+<link rel="help" title="5.3. Line Breaking Strictness: the line-break property" href="https://drafts.csswg.org/css-text-3/#line-break-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-line-break-anywhere">
+<link rel="match" href="../../../../../expected/wpt-import/css/css-text/line-break/reference/line-break-anywhere-004-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="flags" content="Ahem">
+<meta name="assert" content="Except where explicitly defined by 'line-break: anywhere' line breaking behavior defined for the ZWJ classes in [UAX14] must be honored. ">
+<style>
+div {
+ position: relative;
+ font: 25px / 1 Ahem;
+}
+.red {
+ position: absolute;
+ background: green;
+ color: red;
+ height: 100px;
+ z-index: -1;
+}
+.test {
+ color: green;
+ width: 4ch;
+ line-break: anywhere;
+}
+</style>
+<body>
+ <p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
+ <div class="red">XX X<br>X</div>
+ <div class="test">XX &#x200D;XX</div>
+</body>
diff --git a/Tests/LibWeb/Text/expected/line-break-anywhere-across-inline-boxes.txt b/Tests/LibWeb/Text/expected/line-break-anywhere-across-inline-boxes.txt
new file mode 100644
index 00000000000..d320006ad96
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/line-break-anywhere-across-inline-boxes.txt
@@ -0,0 +1,3 @@
+line-full-at-inline-box-start: height 40, first b on line 2
+line-full-at-inline-box-end: height 40, first b on line 2
+a manual soft hyphen widens the min-content by 0
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
index 6f4ebb436e5..a6c37709421 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
@@ -1,8 +1,8 @@
Harness status: OK
-Found 355 tests
+Found 356 tests
-355 Pass
+356 Pass
Pass accent-color
Pass border-collapse
Pass border-spacing
@@ -48,6 +48,7 @@ Pass hyphenate-character
Pass hyphens
Pass image-rendering
Pass letter-spacing
+Pass line-break
Pass line-height
Pass list-style-image
Pass list-style-position
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt
index 9eda65dd8b9..e50f36651fe 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 96 tests
-72 Pass
-24 Fail
+74 Pass
+22 Fail
Pass Animation of font in ::marker
Pass Animation of font-family in ::marker
Pass Animation of font-feature-settings in ::marker
@@ -32,7 +32,7 @@ Pass Animation of direction in ::marker
Pass Animation of content in ::marker
Pass Animation of hyphens in ::marker
Pass Animation of letter-spacing in ::marker
-Fail Animation of line-break in ::marker
+Pass Animation of line-break in ::marker
Pass Animation of overflow-wrap in ::marker
Pass Animation of tab-size in ::marker
Pass Animation of text-transform in ::marker
@@ -80,7 +80,7 @@ Pass Transition of direction in ::marker
Pass Transition of content in ::marker
Pass Transition of hyphens in ::marker
Pass Transition of letter-spacing in ::marker
-Fail Transition of line-break in ::marker
+Pass Transition of line-break in ::marker
Pass Transition of overflow-wrap in ::marker
Pass Transition of tab-size in ::marker
Pass Transition of text-transform in ::marker
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-computed.txt
new file mode 100644
index 00000000000..d464924c8fe
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-computed.txt
@@ -0,0 +1,10 @@
+Harness status: OK
+
+Found 5 tests
+
+5 Pass
+Pass Property line-break value 'auto'
+Pass Property line-break value 'loose'
+Pass Property line-break value 'normal'
+Pass Property line-break value 'strict'
+Pass Property line-break value 'anywhere'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-invalid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-invalid.txt
new file mode 100644
index 00000000000..be2e6d8848b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-invalid.txt
@@ -0,0 +1,10 @@
+Harness status: OK
+
+Found 5 tests
+
+5 Pass
+Pass e.style['line-break'] = "none" should not set the property value
+Pass e.style['line-break'] = "auto loose" should not set the property value
+Pass e.style['line-break'] = "strict normal" should not set the property value
+Pass e.style['line-break'] = "anywhere anywhere" should not set the property value
+Pass e.style['line-break'] = "after-white-space" should not set the property value
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-valid.txt
new file mode 100644
index 00000000000..b11cbd1747f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/line-break-valid.txt
@@ -0,0 +1,10 @@
+Harness status: OK
+
+Found 5 tests
+
+5 Pass
+Pass e.style['line-break'] = "auto" should set the property value
+Pass e.style['line-break'] = "loose" should set the property value
+Pass e.style['line-break'] = "normal" should set the property value
+Pass e.style['line-break'] = "strict" should set the property value
+Pass e.style['line-break'] = "anywhere" should set the property value
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-break.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-break.txt
index 9d317796346..6449fe6fdf1 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-break.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-break.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 36 tests
-35 Pass
-1 Fail
+36 Pass
Pass Can set 'line-break' to CSS-wide keywords: initial
Pass Can set 'line-break' to CSS-wide keywords: inherit
Pass Can set 'line-break' to CSS-wide keywords: unset
@@ -13,7 +12,7 @@ Pass Can set 'line-break' to the 'auto' keyword: auto
Pass Can set 'line-break' to the 'loose' keyword: loose
Pass Can set 'line-break' to the 'normal' keyword: normal
Pass Can set 'line-break' to the 'strict' keyword: strict
-Fail Can set 'line-break' to the 'anywhere' keyword: anywhere
+Pass Can set 'line-break' to the 'anywhere' keyword: anywhere
Pass Setting 'line-break' to a length: 0px throws TypeError
Pass Setting 'line-break' to a length: -3.14em throws TypeError
Pass Setting 'line-break' to a length: 3.14cm throws TypeError
diff --git a/Tests/LibWeb/Text/input/line-break-anywhere-across-inline-boxes.html b/Tests/LibWeb/Text/input/line-break-anywhere-across-inline-boxes.html
new file mode 100644
index 00000000000..2aefe978db1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/line-break-anywhere-across-inline-boxes.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<style>
+ @font-face { font-family: Ahem; src: url("../../Ref/data/fonts/Ahem.ttf"); }
+ body { font: 10px/20px Ahem; }
+ .c { width: 40px; line-break: anywhere; margin-bottom: 10px; }
+ .hyphen { width: min-content; line-break: anywhere; font: 40px sans-serif; }
+</style>
+<div class="c" id="line-full-at-inline-box-start">aaaa<span>bbbb</span></div>
+<div class="c" id="line-full-at-inline-box-end"><span>aaaa</span>bbbb</div>
+<div class="hyphen" id="soft-hyphen-manual" style="hyphens: manual">i&shy;i</div>
+<div class="hyphen" id="soft-hyphen-none" style="hyphens: none">i&shy;i</div>
+<script src="include.js"></script>
+<script>
+ asyncTest(async done => {
+ await document.fonts.load("10px Ahem");
+ for (const c of document.querySelectorAll(".c")) {
+ const text = [...c.querySelectorAll("*"), c].flatMap(element => [...element.childNodes]).find(node => node.nodeType === Node.TEXT_NODE && node.data.startsWith("b"));
+ const range = document.createRange();
+ range.setStart(text, 0);
+ range.setEnd(text, 1);
+ const line = (range.getClientRects()[0].top - c.getBoundingClientRect().top + 5) / 20;
+ println(`${c.id}: height ${c.getBoundingClientRect().height}, first b on line ${Math.floor(line) + 1}`);
+ }
+ const width = id => document.getElementById(id).getBoundingClientRect().width;
+ println(`a manual soft hyphen widens the min-content by ${width("soft-hyphen-manual") - width("soft-hyphen-none")}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-computed.html b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-computed.html
new file mode 100644
index 00000000000..be8eee4f95f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-computed.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Text: getComputedStyle().lineBreak</title>
+<link rel="help" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<meta name="assert" content="line-break computed value is specified keyword.">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../css/support/computed-testcommon.js"></script>
+</head>
+<body>
+<div id="target"></div>
+<script>
+test_computed_value("line-break", "auto");
+test_computed_value("line-break", "loose");
+test_computed_value("line-break", "normal");
+test_computed_value("line-break", "strict");
+test_computed_value("line-break", "anywhere");
+</script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-invalid.html b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-invalid.html
new file mode 100644
index 00000000000..7a5ecbdec72
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-invalid.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Text Module Test: parsing line-break with invalid values</title>
+<link rel="help" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<meta name="assert" content="line-break supports only the grammar 'auto | loose | normal | strict | anywhere'.">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("line-break", "none");
+test_invalid_value("line-break", "auto loose");
+test_invalid_value("line-break", "strict normal");
+test_invalid_value("line-break", "anywhere anywhere");
+test_invalid_value("line-break", "after-white-space");
+</script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-valid.html b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-valid.html
new file mode 100644
index 00000000000..00b03fc5343
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/line-break-valid.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Text Module Test: parsing line-break with valid values</title>
+<link rel="help" href="https://www.w3.org/TR/css-text-3/#propdef-line-break">
+<meta name="assert" content="line-break supports the full grammar 'auto | loose | normal | strict | anywhere'.">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("line-break", "auto");
+test_valid_value("line-break", "loose");
+test_valid_value("line-break", "normal");
+test_valid_value("line-break", "strict");
+test_valid_value("line-break", "anywhere");
+</script>
+</body>
+</html>