layout: Simplify and improve the correctness of whitespace stripping in

text layout, and unify the inline layout paths for pre- and
normally-formatted text.

This fixes a lot of "jumpiness" and removes the `new_line_pos` stuff.

Closes #2260.
This commit is contained in:
Patrick Walton 2015-03-30 14:09:37 -07:00
parent 88aa07b7e0
commit 6d61468160
12 changed files with 485 additions and 461 deletions

View file

@ -151,6 +151,7 @@ flaky_cpu == append_style_a.html append_style_b.html
!= img_simple.html img_simple_ref.html
== img_size_a.html img_size_b.html
== incremental_float_a.html incremental_float_ref.html
== incremental_inline_layout_a.html incremental_inline_layout_ref.html
!= inline_background_a.html inline_background_ref.html
== inline_block_baseline_a.html inline_block_baseline_ref.html
== inline_block_border_a.html inline_block_border_ref.html
@ -184,6 +185,7 @@ flaky_cpu == append_style_a.html append_style_b.html
== legacy_td_bgcolor_attribute_a.html legacy_td_bgcolor_attribute_ref.html
== legacy_td_width_attribute_a.html legacy_td_width_attribute_ref.html
== letter_spacing_a.html letter_spacing_ref.html
== line_breaking_whitespace_collapse_a.html line_breaking_whitespace_collapse_ref.html
== line_height_a.html line_height_ref.html
!= linear_gradients_corners_a.html linear_gradients_corners_ref.html
== linear_gradients_lengths_a.html linear_gradients_lengths_ref.html

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
font-size: 72px;
}
</style>
</head>
<body>
<h1 id=h1>
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
</h1>
<script>
document.getElementById('h1').getBoundingClientRect(); // Trigger one layout.
document.getElementById('h1').getBoundingClientRect(); // Trigger another layout.
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
font-size: 72px;
}
</style>
</head>
<body>
<h1 id=h1>
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
Incremental Inline Layout
</h1>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/ahem.css">
<style>
p {
font-size: 10px;
font-family: Ahem, monospace;
width: 300px;
}
a {
color: blue;
}
</style>
</head>
<body>
<p>xxxxx xxxxx <a>xxxxx xxx xxxxx</a> xxxxxxxxxxx</p>
</body>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/ahem.css">
<style>
p {
font-size: 10px;
font-family: Ahem, monospace;
width: 300px;
}
a {
color: blue;
}
</style>
</head>
<body>
<p>xxxxx xxxxx <a>xxxxx xxx xxxxx</a><br>xxxxxxxxxxx</p>
</body>

View file

@ -18,9 +18,8 @@ fn test_transform_compress_none() {
let mode = CompressionMode::CompressNone;
for &test in test_strs.iter() {
let mut new_line_pos = vec![];
let mut trimmed_str = String::new();
transform_text(test, mode, true, &mut trimmed_str, &mut new_line_pos);
transform_text(test, mode, true, &mut trimmed_str);
assert_eq!(trimmed_str, test)
}
}
@ -52,9 +51,8 @@ fn test_transform_discard_newline() {
let mode = CompressionMode::DiscardNewline;
for &(test, oracle) in test_strs.iter() {
let mut new_line_pos = vec![];
let mut trimmed_str = String::new();
transform_text(test, mode, true, &mut trimmed_str, &mut new_line_pos);
transform_text(test, mode, true, &mut trimmed_str);
assert_eq!(trimmed_str, oracle)
}
}
@ -86,9 +84,8 @@ fn test_transform_compress_whitespace() {
let mode = CompressionMode::CompressWhitespace;
for &(test, oracle) in test_strs.iter() {
let mut new_line_pos = vec![];
let mut trimmed_str = String::new();
transform_text(test, mode, true, &mut trimmed_str, &mut new_line_pos);
transform_text(test, mode, true, &mut trimmed_str);
assert_eq!(&*trimmed_str, oracle)
}
}
@ -120,9 +117,8 @@ fn test_transform_compress_whitespace_newline() {
let mode = CompressionMode::CompressWhitespaceNewline;
for &(test, oracle) in test_strs.iter() {
let mut new_line_pos = vec![];
let mut trimmed_str = String::new();
transform_text(test, mode, true, &mut trimmed_str, &mut new_line_pos);
transform_text(test, mode, true, &mut trimmed_str);
assert_eq!(&*trimmed_str, oracle)
}
}
@ -157,9 +153,8 @@ fn test_transform_compress_whitespace_newline_no_incoming() {
let mode = CompressionMode::CompressWhitespaceNewline;
for &(test, oracle) in test_strs.iter() {
let mut new_line_pos = vec![];
let mut trimmed_str = String::new();
transform_text(test, mode, false, &mut trimmed_str, &mut new_line_pos);
transform_text(test, mode, false, &mut trimmed_str);
assert_eq!(trimmed_str, oracle)
}
}