mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
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 <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
a76daaf04c
commit
fa8752df6a
21 changed files with 5 additions and 41 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue