1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 03:27:44 +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,39 +1,39 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (1,1) content-size 798x161.21875 [BFC] children: not-inline
BlockContainer <body> at (10,10) content-size 780x143.21875 children: not-inline
BlockContainer <div.px-indent> at (11,11) content-size 778x68.9375 children: not-inline
BlockContainer <(anonymous)> at (11,11) content-size 778x17.46875 children: inline
line 0 width: 142.390625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 11, rect: [61,11 92.390625x17.46875]
BlockContainer <html> at (1,1) content-size 798x158 [BFC] children: not-inline
BlockContainer <body> at (10,10) content-size 780x140 children: not-inline
BlockContainer <div.px-indent> at (11,11) content-size 778x68 children: not-inline
BlockContainer <(anonymous)> at (11,11) content-size 778x17 children: inline
line 0 width: 142.390625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 11, rect: [61,11 92.390625x17]
"50px indent"
TextNode <#text>
BlockContainer <p> at (12,45.46875) content-size 776x17.46875 children: inline
line 0 width: 140.921875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 12, rect: [62,45.46875 90.921875x17.46875]
BlockContainer <p> at (12,45) content-size 776x17 children: inline
line 0 width: 140.921875, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 12, rect: [62,45 90.921875x17]
"is inherited"
TextNode <#text>
BlockContainer <div.pct-indent> at (11,81.9375) content-size 100x70.28125 children: inline
line 0 width: 80.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 3, rect: [61,81.9375 30.34375x17.46875]
BlockContainer <div.pct-indent> at (11,81) content-size 100x68 children: inline
line 0 width: 80.34375, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 3, rect: [61,81 30.34375x17]
"50%"
line 1 width: 88.15625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 4, length: 11, rect: [11,98.9375 88.15625x17.46875]
line 1 width: 88.15625, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 4, length: 11, rect: [11,98 88.15625x17]
"indent snip"
line 2 width: 78.703125, height: 18.40625, bottom: 53.34375, baseline: 13.53125
frag 0 from TextNode start: 16, length: 9, rect: [11,115.9375 78.703125x17.46875]
line 2 width: 78.703125, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 16, length: 9, rect: [11,115 78.703125x17]
"snap snib"
line 3 width: 37.765625, height: 17.875, bottom: 70.28125, baseline: 13.53125
frag 0 from TextNode start: 26, length: 4, rect: [11,133.9375 37.765625x17.46875]
line 3 width: 37.765625, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 26, length: 4, rect: [11,132 37.765625x17]
"snab"
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x163.21875]
PaintableWithLines (BlockContainer<BODY>) [9,9 782x145.21875]
PaintableWithLines (BlockContainer<DIV>.px-indent) [10,10 780x70.9375]
PaintableWithLines (BlockContainer(anonymous)) [11,11 778x17.46875]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x160]
PaintableWithLines (BlockContainer<BODY>) [9,9 782x142]
PaintableWithLines (BlockContainer<DIV>.px-indent) [10,10 780x70]
PaintableWithLines (BlockContainer(anonymous)) [11,11 778x17]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<P>) [11,44.46875 778x19.46875]
PaintableWithLines (BlockContainer<P>) [11,44 778x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.pct-indent) [10,80.9375 102x72.28125]
PaintableWithLines (BlockContainer<DIV>.pct-indent) [10,80 102x70]
TextPaintable (TextNode<#text>)