1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:27:35 +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

@ -1,35 +1,35 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x121.15625 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x105.15625 children: not-inline
BlockContainer <div.wrapper> at (8,8) content-size 270x105.15625 children: not-inline
BlockContainer <div.constrained> at (8,8) content-size 270x105.15625 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 270x105.15625 children: inline
line 0 width: 261.0625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 1, length: 35, rect: [8,8 261.0625x17.46875]
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.wrapper> at (8,8) content-size 270x102 children: not-inline
BlockContainer <div.constrained> at (8,8) content-size 270x102 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 270x102 children: inline
line 0 width: 261.0625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 1, length: 35, rect: [8,8 261.0625x17]
"hello hello hello hello hello hello"
line 1 width: 261.0625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 37, length: 35, rect: [8,25 261.0625x17.46875]
line 1 width: 261.0625, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 37, length: 35, rect: [8,25 261.0625x17]
"hello hello hello hello hello hello"
line 2 width: 261.0625, height: 18.40625, bottom: 53.34375, baseline: 13.53125
frag 0 from TextNode start: 73, length: 35, rect: [8,42 261.0625x17.46875]
line 2 width: 261.0625, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 73, length: 35, rect: [8,42 261.0625x17]
"hello hello hello hello hello hello"
line 3 width: 261.0625, height: 17.875, bottom: 70.28125, baseline: 13.53125
frag 0 from TextNode start: 109, length: 35, rect: [8,60 261.0625x17.46875]
line 3 width: 261.0625, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 109, length: 35, rect: [8,59 261.0625x17]
"hello hello hello hello hello hello"
line 4 width: 261.0625, height: 18.34375, bottom: 88.21875, baseline: 13.53125
frag 0 from TextNode start: 145, length: 35, rect: [8,77 261.0625x17.46875]
line 4 width: 261.0625, height: 17, bottom: 85, baseline: 13.296875
frag 0 from TextNode start: 145, length: 35, rect: [8,76 261.0625x17]
"hello hello hello hello hello hello"
line 5 width: 81.6875, height: 17.8125, bottom: 105.15625, baseline: 13.53125
frag 0 from TextNode start: 181, length: 11, rect: [8,95 81.6875x17.46875]
line 5 width: 81.6875, height: 17, bottom: 102, baseline: 13.296875
frag 0 from TextNode start: 181, length: 11, rect: [8,93 81.6875x17]
"hello hello"
TextNode <#text>
BlockContainer <div> at (8,113.15625) content-size 270x0 children: not-inline
BlockContainer <div> at (8,110) content-size 270x0 children: not-inline
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x121.15625]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x105.15625]
PaintableWithLines (BlockContainer<DIV>.wrapper) [8,8 270x105.15625]
PaintableWithLines (BlockContainer<DIV>.constrained) [8,8 270x105.15625]
PaintableWithLines (BlockContainer(anonymous)) [8,8 270x105.15625]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x118]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x102]
PaintableWithLines (BlockContainer<DIV>.wrapper) [8,8 270x102]
PaintableWithLines (BlockContainer<DIV>.constrained) [8,8 270x102]
PaintableWithLines (BlockContainer(anonymous)) [8,8 270x102]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>) [8,113.15625 270x0]
PaintableWithLines (BlockContainer<DIV>) [8,110 270x0]