From fa8752df6a2c9cdec3d9108614bf2bf9b713626b Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Fri, 13 Sep 2024 18:56:14 +0200 Subject: [PATCH] Fix precision issue with line heights (#33438) When computing the ascent and descent in an inline formatting context, we weren't taking into account that app units have precision limitations. Therefore, in some cases we were getting a line height that was slightly taller than the value specified in `line-height`. Signed-off-by: Oriol Brufau Co-authored-by: Martin Robinson --- components/layout_2020/flow/inline/mod.rs | 6 +++++- .../meta/css/CSS2/tables/fixed-table-layout-003b01.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b02.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b03.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b04.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b05.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b06.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b07.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b08.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b09.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b10.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b11.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003b12.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c01.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c02.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c03.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c04.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c05.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c06.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c07.xht.ini | 2 -- .../meta/css/CSS2/tables/fixed-table-layout-003c08.xht.ini | 2 -- 21 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b01.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b02.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b03.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b04.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b05.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b06.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b07.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b08.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b09.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b10.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b11.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b12.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c01.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c02.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c03.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c04.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c05.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c06.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c07.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c08.xht.ini diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs index 9e93644f094..19d8980f926 100644 --- a/components/layout_2020/flow/inline/mod.rs +++ b/components/layout_2020/flow/inline/mod.rs @@ -1815,8 +1815,12 @@ impl InlineContainerState { ascent = font_metrics_of_first_font.ascent; descent = font_metrics_of_first_font.descent; let half_leading = (line_height - (ascent + descent)).scale_by(0.5); + // We want the sum of `ascent` and `descent` to equal `line_height`. + // If we just add `half_leading` to both, then we may not get `line_height` + // due to precision limitations of `Au`. Instead, we set `descent` to + // the value that will guarantee the correct sum. ascent += half_leading; - descent += half_leading; + descent = line_height - ascent; } LineBlockSizes { diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b01.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b01.xht.ini deleted file mode 100644 index a2eb9d76325..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b01.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b01.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b02.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b02.xht.ini deleted file mode 100644 index 1ffc770f94a..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b02.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b02.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b03.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b03.xht.ini deleted file mode 100644 index 89bf3660b25..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b03.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b03.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b04.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b04.xht.ini deleted file mode 100644 index 5d74d444b47..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b04.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b04.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b05.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b05.xht.ini deleted file mode 100644 index f6daa39f735..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b05.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b05.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b06.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b06.xht.ini deleted file mode 100644 index ff9c943aabc..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b06.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b06.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b07.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b07.xht.ini deleted file mode 100644 index 8d064f14feb..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b07.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b07.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b08.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b08.xht.ini deleted file mode 100644 index 1ac28e11028..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b08.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b08.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b09.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b09.xht.ini deleted file mode 100644 index 0c94c573916..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b09.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b09.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b10.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b10.xht.ini deleted file mode 100644 index 5216a678904..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b10.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b10.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b11.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b11.xht.ini deleted file mode 100644 index 44bd69aaa5d..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b11.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b11.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b12.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b12.xht.ini deleted file mode 100644 index 9bf7c48d5e6..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003b12.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003b12.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c01.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c01.xht.ini deleted file mode 100644 index 7997b2df600..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c01.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c01.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c02.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c02.xht.ini deleted file mode 100644 index f45a17492f2..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c02.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c02.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c03.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c03.xht.ini deleted file mode 100644 index bc7bdd43de7..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c03.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c03.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c04.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c04.xht.ini deleted file mode 100644 index 9f21980c160..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c04.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c04.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c05.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c05.xht.ini deleted file mode 100644 index d9e02340a21..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c05.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c05.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c06.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c06.xht.ini deleted file mode 100644 index e6a1cd91f1e..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c06.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c06.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c07.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c07.xht.ini deleted file mode 100644 index 32abd51caf4..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c07.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c07.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c08.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c08.xht.ini deleted file mode 100644 index 6a59c294df0..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-003c08.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-003c08.xht] - expected: FAIL