1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:47:45 +00:00

LibWeb: Bring CSS line-height closer to other engines

This patch makes a few changes to the way we calculate line-height:

- `line-height: normal` is now resolved using metrics from the used
  font (specifically, round(A + D + lineGap)).

- `line-height: calc(...)` is now resolved at style compute time.

- `line-height` values are now absolutized at style compute time.

As a consequence of the above, we no longer need to walk the DOM
ancestor chain looking for line-heights during style computation.
Instead, values are inherited, resolved and absolutized locally.

This is not only much faster, but also makes our line-height metrics
match those of other engines like Gecko and Blink.
This commit is contained in:
Andreas Kling 2024-01-12 12:39:40 +01:00
parent f0722671c3
commit e7de5cb4d2
385 changed files with 6889 additions and 6893 deletions

View file

@ -2,71 +2,71 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x118 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x102 children: not-inline
BlockContainer <div> at (9,9) content-size 100x100 children: inline
line 0 width: 98, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 1, length: 3, rect: [9,9 27.15625x17.46875]
line 0 width: 98, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 1, length: 3, rect: [9,9 27.15625x17]
"foo"
frag 1 from TextNode start: 4, length: 1, rect: [36,9 9x17.46875]
frag 1 from TextNode start: 4, length: 1, rect: [36,9 9x17]
" "
frag 2 from TextNode start: 5, length: 3, rect: [45,9 27.640625x17.46875]
frag 2 from TextNode start: 5, length: 3, rect: [45,9 27.640625x17]
"bar"
frag 3 from TextNode start: 8, length: 1, rect: [73,9 9x17.46875]
frag 3 from TextNode start: 8, length: 1, rect: [73,9 9x17]
" "
frag 4 from TextNode start: 9, length: 3, rect: [82,9 27.203125x17.46875]
frag 4 from TextNode start: 9, length: 3, rect: [82,9 27.203125x17]
"baz"
line 1 width: 98, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 13, length: 3, rect: [9,26 27.15625x17.46875]
line 1 width: 98, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 13, length: 3, rect: [9,26 27.15625x17]
"foo"
frag 1 from TextNode start: 16, length: 1, rect: [36,26 8x17.46875]
frag 1 from TextNode start: 16, length: 1, rect: [36,26 8x17]
" "
frag 2 from TextNode start: 17, length: 3, rect: [44,26 27.640625x17.46875]
frag 2 from TextNode start: 17, length: 3, rect: [44,26 27.640625x17]
"bar"
frag 3 from TextNode start: 20, length: 1, rect: [72,26 8x17.46875]
frag 3 from TextNode start: 20, length: 1, rect: [72,26 8x17]
" "
frag 4 from TextNode start: 21, length: 3, rect: [80,26 27.203125x17.46875]
frag 4 from TextNode start: 21, length: 3, rect: [80,26 27.203125x17]
"baz"
line 2 width: 98, height: 18.40625, bottom: 53.34375, baseline: 13.53125
frag 0 from TextNode start: 1, length: 3, rect: [9,43 27.15625x17.46875]
line 2 width: 98, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 1, length: 3, rect: [9,43 27.15625x17]
"foo"
frag 1 from TextNode start: 4, length: 1, rect: [36,43 9x17.46875]
frag 1 from TextNode start: 4, length: 1, rect: [36,43 9x17]
" "
frag 2 from TextNode start: 5, length: 3, rect: [45,43 27.640625x17.46875]
frag 2 from TextNode start: 5, length: 3, rect: [45,43 27.640625x17]
"bar"
frag 3 from TextNode start: 8, length: 1, rect: [73,43 9x17.46875]
frag 3 from TextNode start: 8, length: 1, rect: [73,43 9x17]
" "
frag 4 from TextNode start: 9, length: 3, rect: [82,43 27.203125x17.46875]
frag 4 from TextNode start: 9, length: 3, rect: [82,43 27.203125x17]
"baz"
line 3 width: 98, height: 17.875, bottom: 70.28125, baseline: 13.53125
frag 0 from TextNode start: 13, length: 3, rect: [9,61 27.15625x17.46875]
line 3 width: 98, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 13, length: 3, rect: [9,60 27.15625x17]
"foo"
frag 1 from TextNode start: 16, length: 1, rect: [36,61 9x17.46875]
frag 1 from TextNode start: 16, length: 1, rect: [36,60 9x17]
" "
frag 2 from TextNode start: 17, length: 3, rect: [45,61 27.640625x17.46875]
frag 2 from TextNode start: 17, length: 3, rect: [45,60 27.640625x17]
"bar"
frag 3 from TextNode start: 20, length: 1, rect: [73,61 9x17.46875]
frag 3 from TextNode start: 20, length: 1, rect: [73,60 9x17]
" "
frag 4 from TextNode start: 21, length: 3, rect: [82,61 27.203125x17.46875]
frag 4 from TextNode start: 21, length: 3, rect: [82,60 27.203125x17]
"baz"
line 4 width: 98, height: 18.34375, bottom: 88.21875, baseline: 13.53125
frag 0 from TextNode start: 25, length: 3, rect: [9,78 27.15625x17.46875]
line 4 width: 98, height: 17, bottom: 85, baseline: 13.296875
frag 0 from TextNode start: 25, length: 3, rect: [9,77 27.15625x17]
"foo"
frag 1 from TextNode start: 28, length: 1, rect: [36,78 8x17.46875]
frag 1 from TextNode start: 28, length: 1, rect: [36,77 8x17]
" "
frag 2 from TextNode start: 29, length: 3, rect: [44,78 27.640625x17.46875]
frag 2 from TextNode start: 29, length: 3, rect: [44,77 27.640625x17]
"bar"
frag 3 from TextNode start: 32, length: 1, rect: [72,78 8x17.46875]
frag 3 from TextNode start: 32, length: 1, rect: [72,77 8x17]
" "
frag 4 from TextNode start: 33, length: 3, rect: [80,78 27.203125x17.46875]
frag 4 from TextNode start: 33, length: 3, rect: [80,77 27.203125x17]
"baz"
line 5 width: 98, height: 17.8125, bottom: 105.15625, baseline: 13.53125
frag 0 from TextNode start: 1, length: 3, rect: [9,96 27.15625x17.46875]
line 5 width: 98, height: 17, bottom: 102, baseline: 13.296875
frag 0 from TextNode start: 1, length: 3, rect: [9,94 27.15625x17]
"foo"
frag 1 from TextNode start: 4, length: 1, rect: [36,96 8x17.46875]
frag 1 from TextNode start: 4, length: 1, rect: [36,94 8x17]
" "
frag 2 from TextNode start: 5, length: 3, rect: [44,96 27.640625x17.46875]
frag 2 from TextNode start: 5, length: 3, rect: [44,94 27.640625x17]
"bar"
frag 3 from TextNode start: 8, length: 1, rect: [72,96 8x17.46875]
frag 3 from TextNode start: 8, length: 1, rect: [72,94 8x17]
" "
frag 4 from TextNode start: 9, length: 3, rect: [80,96 27.203125x17.46875]
frag 4 from TextNode start: 9, length: 3, rect: [80,94 27.203125x17]
"baz"
TextNode <#text>
BreakNode <br>
@ -76,8 +76,8 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x118]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x102] overflow: [8,8 784x105.46875]
PaintableWithLines (BlockContainer<DIV>) [8,8 102x102] overflow: [9,9 100.203125x104.46875]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x102] overflow: [8,8 784x103]
PaintableWithLines (BlockContainer<DIV>) [8,8 102x102] overflow: [9,9 100.203125x102]
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)