mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
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:
parent
88aa07b7e0
commit
6d61468160
12 changed files with 485 additions and 461 deletions
|
@ -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
|
||||
|
|
32
tests/ref/incremental_inline_layout_a.html
Normal file
32
tests/ref/incremental_inline_layout_a.html
Normal 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>
|
||||
|
28
tests/ref/incremental_inline_layout_ref.html
Normal file
28
tests/ref/incremental_inline_layout_ref.html
Normal 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>
|
||||
|
19
tests/ref/line_breaking_whitespace_collapse_a.html
Normal file
19
tests/ref/line_breaking_whitespace_collapse_a.html
Normal 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>
|
||||
|
19
tests/ref/line_breaking_whitespace_collapse_ref.html
Normal file
19
tests/ref/line_breaking_whitespace_collapse_ref.html
Normal 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>
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue