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,46 +1,46 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (1,1) content-size 798x130.21875 [BFC] children: not-inline
BlockContainer <body> at (10,10) content-size 780x112.21875 children: not-inline
BlockContainer <div.foo> at (11,11) content-size 93.765625x35.40625 children: inline
line 0 width: 43.578125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 6, rect: [11,11 43.578125x17.46875]
BlockContainer <html> at (1,1) content-size 798x126 [BFC] children: not-inline
BlockContainer <body> at (10,10) content-size 780x108 children: not-inline
BlockContainer <div.foo> at (11,11) content-size 93.765625x34 children: inline
line 0 width: 43.578125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 6, rect: [11,11 43.578125x17]
"width:"
line 1 width: 93.765625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 7, length: 11, rect: [11,28 93.765625x17.46875]
line 1 width: 93.765625, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 7, length: 11, rect: [11,28 93.765625x17]
"min-content"
TextNode <#text>
BlockContainer <(anonymous)> at (10,47.40625) content-size 780x0 children: inline
BlockContainer <(anonymous)> at (10,46) content-size 780x0 children: inline
TextNode <#text>
BlockContainer <div.bar> at (11,48.40625) content-size 93.765625x35.40625 children: inline
line 0 width: 81.3125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 10, rect: [11,48.40625 81.3125x17.46875]
BlockContainer <div.bar> at (11,47) content-size 93.765625x34 children: inline
line 0 width: 81.3125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 10, rect: [11,47 81.3125x17]
"max-width:"
line 1 width: 93.765625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 11, length: 11, rect: [11,65.40625 93.765625x17.46875]
line 1 width: 93.765625, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 11, length: 11, rect: [11,64 93.765625x17]
"min-content"
TextNode <#text>
BlockContainer <(anonymous)> at (10,84.8125) content-size 780x0 children: inline
BlockContainer <(anonymous)> at (10,82) content-size 780x0 children: inline
TextNode <#text>
BlockContainer <div.baz> at (11,85.8125) content-size 93.765625x35.40625 children: inline
line 0 width: 76.4375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 10, rect: [11,85.8125 76.4375x17.46875]
BlockContainer <div.baz> at (11,83) content-size 93.765625x34 children: inline
line 0 width: 76.4375, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 10, rect: [11,83 76.4375x17]
"min-width:"
line 1 width: 93.765625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 11, length: 11, rect: [11,102.8125 93.765625x17.46875]
line 1 width: 93.765625, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 11, length: 11, rect: [11,100 93.765625x17]
"min-content"
TextNode <#text>
BlockContainer <(anonymous)> at (10,122.21875) content-size 780x0 children: inline
BlockContainer <(anonymous)> at (10,118) content-size 780x0 children: inline
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x132.21875]
PaintableWithLines (BlockContainer<BODY>) [9,9 782x114.21875]
PaintableWithLines (BlockContainer<DIV>.foo) [10,10 95.765625x37.40625]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x128]
PaintableWithLines (BlockContainer<BODY>) [9,9 782x110]
PaintableWithLines (BlockContainer<DIV>.foo) [10,10 95.765625x36]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [10,47.40625 780x0]
PaintableWithLines (BlockContainer<DIV>.bar) [10,47.40625 95.765625x37.40625]
PaintableWithLines (BlockContainer(anonymous)) [10,46 780x0]
PaintableWithLines (BlockContainer<DIV>.bar) [10,46 95.765625x36]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [10,84.8125 780x0]
PaintableWithLines (BlockContainer<DIV>.baz) [10,84.8125 95.765625x37.40625]
PaintableWithLines (BlockContainer(anonymous)) [10,82 780x0]
PaintableWithLines (BlockContainer<DIV>.baz) [10,82 95.765625x36]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [10,122.21875 780x0]
PaintableWithLines (BlockContainer(anonymous)) [10,118 780x0]