1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-29 10:47:36 +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,140 +1,140 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (1,1) content-size 798x458.28125 [BFC] children: not-inline
BlockContainer <body> at (10,10) content-size 780x440.28125 children: not-inline
Box <div.grid> at (11,11) content-size 500x438.28125 [GFC] children: not-inline
BlockContainer <html> at (1,1) content-size 798x446 [BFC] children: not-inline
BlockContainer <body> at (10,10) content-size 780x428 children: not-inline
Box <div.grid> at (11,11) content-size 500x426 [GFC] children: not-inline
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.left-margin-auto.right-margin-auto> at (99.71875,12) content-size 322.5625x17.46875 [BFC] children: inline
line 0 width: 322.5625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 38, rect: [99.71875,12 322.5625x17.46875]
BlockContainer <div.left-margin-auto.right-margin-auto> at (99.71875,12) content-size 322.5625x17 [BFC] children: inline
line 0 width: 322.5625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 38, rect: [99.71875,12 322.5625x17]
"auto horizontal margins and auto width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.left-margin-auto> at (252.375,31.46875) content-size 257.625x17.46875 [BFC] children: inline
line 0 width: 257.625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 31, rect: [252.375,31.46875 257.625x17.46875]
BlockContainer <div.left-margin-auto> at (252.375,31) content-size 257.625x17 [BFC] children: inline
line 0 width: 257.625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 31, rect: [252.375,31 257.625x17]
"auto left margin and auto width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.right-margin-auto> at (12,50.9375) content-size 268.484375x17.46875 [BFC] children: inline
line 0 width: 268.484375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 32, rect: [12,50.9375 268.484375x17.46875]
BlockContainer <div.right-margin-auto> at (12,50) content-size 268.484375x17 [BFC] children: inline
line 0 width: 268.484375, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 32, rect: [12,50 268.484375x17]
"auto right margin and auto width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.left-margin-auto.right-margin-auto.fit-content-width> at (75.25,70.40625) content-size 371.484375x17.46875 [BFC] children: inline
line 0 width: 371.484375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 45, rect: [75.25,70.40625 371.484375x17.46875]
BlockContainer <div.left-margin-auto.right-margin-auto.fit-content-width> at (75.25,69) content-size 371.484375x17 [BFC] children: inline
line 0 width: 371.484375, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 45, rect: [75.25,69 371.484375x17]
"auto horizontal margins and fit-content width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.left-margin-auto.fit-content-width> at (203.453125,89.875) content-size 306.546875x17.46875 [BFC] children: inline
line 0 width: 306.546875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 38, rect: [203.453125,89.875 306.546875x17.46875]
BlockContainer <div.left-margin-auto.fit-content-width> at (203.453125,88) content-size 306.546875x17 [BFC] children: inline
line 0 width: 306.546875, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 38, rect: [203.453125,88 306.546875x17]
"auto left margin and fit-content width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.right-margin-auto.fit-content-width> at (12,109.34375) content-size 317.40625x17.46875 [BFC] children: inline
line 0 width: 317.40625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 39, rect: [12,109.34375 317.40625x17.46875]
BlockContainer <div.right-margin-auto.fit-content-width> at (12,107) content-size 317.40625x17 [BFC] children: inline
line 0 width: 317.40625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 39, rect: [12,107 317.40625x17]
"auto right margin and fit-content width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.left-margin-auto.right-margin-auto.fixed-width> at (236,128.8125) content-size 50x105.15625 [BFC] children: inline
line 0 width: 36.328125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 4, rect: [236,128.8125 36.328125x17.46875]
BlockContainer <div.left-margin-auto.right-margin-auto.fixed-width> at (236,126) content-size 50x102 [BFC] children: inline
line 0 width: 36.328125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 4, rect: [236,126 36.328125x17]
"auto"
line 1 width: 81.84375, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 5, length: 10, rect: [236,145.8125 81.84375x17.46875]
line 1 width: 81.84375, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 5, length: 10, rect: [236,143 81.84375x17]
"horizontal"
line 2 width: 61.453125, height: 18.40625, bottom: 53.34375, baseline: 13.53125
frag 0 from TextNode start: 16, length: 7, rect: [236,162.8125 61.453125x17.46875]
line 2 width: 61.453125, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 16, length: 7, rect: [236,160 61.453125x17]
"margins"
line 3 width: 26.8125, height: 17.875, bottom: 70.28125, baseline: 13.53125
frag 0 from TextNode start: 24, length: 3, rect: [236,180.8125 26.8125x17.46875]
line 3 width: 26.8125, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 24, length: 3, rect: [236,177 26.8125x17]
"and"
line 4 width: 37.28125, height: 18.34375, bottom: 88.21875, baseline: 13.53125
frag 0 from TextNode start: 28, length: 5, rect: [236,197.8125 37.28125x17.46875]
line 4 width: 37.28125, height: 17, bottom: 85, baseline: 13.296875
frag 0 from TextNode start: 28, length: 5, rect: [236,194 37.28125x17]
"fixed"
line 5 width: 39.796875, height: 17.8125, bottom: 105.15625, baseline: 13.53125
frag 0 from TextNode start: 34, length: 5, rect: [236,215.8125 39.796875x17.46875]
line 5 width: 39.796875, height: 17, bottom: 102, baseline: 13.296875
frag 0 from TextNode start: 34, length: 5, rect: [236,211 39.796875x17]
"width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.left-margin-auto.fixed-width> at (460,235.96875) content-size 50x105.15625 [BFC] children: inline
line 0 width: 36.328125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 4, rect: [460,235.96875 36.328125x17.46875]
BlockContainer <div.left-margin-auto.fixed-width> at (460,230) content-size 50x102 [BFC] children: inline
line 0 width: 36.328125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 4, rect: [460,230 36.328125x17]
"auto"
line 1 width: 26.25, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 5, length: 4, rect: [460,252.96875 26.25x17.46875]
line 1 width: 26.25, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 5, length: 4, rect: [460,247 26.25x17]
"left"
line 2 width: 52.109375, height: 18.40625, bottom: 53.34375, baseline: 13.53125
frag 0 from TextNode start: 10, length: 6, rect: [460,269.96875 52.109375x17.46875]
line 2 width: 52.109375, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 10, length: 6, rect: [460,264 52.109375x17]
"margin"
line 3 width: 26.8125, height: 17.875, bottom: 70.28125, baseline: 13.53125
frag 0 from TextNode start: 17, length: 3, rect: [460,287.96875 26.8125x17.46875]
line 3 width: 26.8125, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 17, length: 3, rect: [460,281 26.8125x17]
"and"
line 4 width: 37.28125, height: 18.34375, bottom: 88.21875, baseline: 13.53125
frag 0 from TextNode start: 21, length: 5, rect: [460,304.96875 37.28125x17.46875]
line 4 width: 37.28125, height: 17, bottom: 85, baseline: 13.296875
frag 0 from TextNode start: 21, length: 5, rect: [460,298 37.28125x17]
"fixed"
line 5 width: 39.796875, height: 17.8125, bottom: 105.15625, baseline: 13.53125
frag 0 from TextNode start: 27, length: 5, rect: [460,322.96875 39.796875x17.46875]
line 5 width: 39.796875, height: 17, bottom: 102, baseline: 13.296875
frag 0 from TextNode start: 27, length: 5, rect: [460,315 39.796875x17]
"width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <div.right-margin-auto.fixed-width> at (12,343.125) content-size 50x105.15625 [BFC] children: inline
line 0 width: 36.328125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 4, rect: [12,343.125 36.328125x17.46875]
BlockContainer <div.right-margin-auto.fixed-width> at (12,334) content-size 50x102 [BFC] children: inline
line 0 width: 36.328125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 4, rect: [12,334 36.328125x17]
"auto"
line 1 width: 37.109375, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 5, length: 5, rect: [12,360.125 37.109375x17.46875]
line 1 width: 37.109375, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 5, length: 5, rect: [12,351 37.109375x17]
"right"
line 2 width: 52.109375, height: 18.40625, bottom: 53.34375, baseline: 13.53125
frag 0 from TextNode start: 11, length: 6, rect: [12,377.125 52.109375x17.46875]
line 2 width: 52.109375, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 11, length: 6, rect: [12,368 52.109375x17]
"margin"
line 3 width: 26.8125, height: 17.875, bottom: 70.28125, baseline: 13.53125
frag 0 from TextNode start: 18, length: 3, rect: [12,395.125 26.8125x17.46875]
line 3 width: 26.8125, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 18, length: 3, rect: [12,385 26.8125x17]
"and"
line 4 width: 37.28125, height: 18.34375, bottom: 88.21875, baseline: 13.53125
frag 0 from TextNode start: 22, length: 5, rect: [12,412.125 37.28125x17.46875]
line 4 width: 37.28125, height: 17, bottom: 85, baseline: 13.296875
frag 0 from TextNode start: 22, length: 5, rect: [12,402 37.28125x17]
"fixed"
line 5 width: 39.796875, height: 17.8125, bottom: 105.15625, baseline: 13.53125
frag 0 from TextNode start: 28, length: 5, rect: [12,430.125 39.796875x17.46875]
line 5 width: 39.796875, height: 17, bottom: 102, baseline: 13.296875
frag 0 from TextNode start: 28, length: 5, rect: [12,419 39.796875x17]
"width"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (10,450.28125) content-size 780x0 children: inline
BlockContainer <(anonymous)> at (10,438) content-size 780x0 children: inline
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x460.28125]
PaintableWithLines (BlockContainer<BODY>) [9,9 782x442.28125]
PaintableBox (Box<DIV>.grid) [10,10 502x440.28125] overflow: [11,11 501.109375x438.28125]
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.right-margin-auto) [98.71875,11 324.5625x19.46875]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x448]
PaintableWithLines (BlockContainer<BODY>) [9,9 782x430]
PaintableBox (Box<DIV>.grid) [10,10 502x428] overflow: [11,11 501.109375x426]
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.right-margin-auto) [98.71875,11 324.5625x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.left-margin-auto) [251.375,30.46875 259.625x19.46875]
PaintableWithLines (BlockContainer<DIV>.left-margin-auto) [251.375,30 259.625x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.right-margin-auto) [11,49.9375 270.484375x19.46875]
PaintableWithLines (BlockContainer<DIV>.right-margin-auto) [11,49 270.484375x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.right-margin-auto.fit-content-width) [74.25,69.40625 373.484375x19.46875]
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.right-margin-auto.fit-content-width) [74.25,68 373.484375x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.fit-content-width) [202.453125,88.875 308.546875x19.46875]
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.fit-content-width) [202.453125,87 308.546875x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.right-margin-auto.fit-content-width) [11,108.34375 319.40625x19.46875]
PaintableWithLines (BlockContainer<DIV>.right-margin-auto.fit-content-width) [11,106 319.40625x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.right-margin-auto.fixed-width) [235,127.8125 52x107.15625] overflow: [236,128.8125 81.84375x105.15625]
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.right-margin-auto.fixed-width) [235,125 52x104] overflow: [236,126 81.84375x102]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.fixed-width) [459,234.96875 52x107.15625] overflow: [460,235.96875 52.109375x105.15625]
PaintableWithLines (BlockContainer<DIV>.left-margin-auto.fixed-width) [459,229 52x104] overflow: [460,230 52.109375x102]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.right-margin-auto.fixed-width) [11,342.125 52x107.15625] overflow: [12,343.125 52.109375x105.15625]
PaintableWithLines (BlockContainer<DIV>.right-margin-auto.fixed-width) [11,333 52x104] overflow: [12,334 52.109375x102]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [10,450.28125 780x0]
PaintableWithLines (BlockContainer(anonymous)) [10,438 780x0]