1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:57:46 +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,67 +1,67 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x132.40625 [BFC] children: not-inline
BlockContainer <html> at (0,0) content-size 800x131 [BFC] children: not-inline
BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
TextNode <#text>
BlockContainer <body> at (8,8) content-size 784x116.40625 children: not-inline
BlockContainer <body> at (8,8) content-size 784x115 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
TextNode <#text>
TableWrapper <(anonymous)> at (8,8) content-size 75.828125x116.40625 [BFC] children: not-inline
Box <table> at (9,9) content-size 73.828125x114.40625 table-box [TFC] children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 75.828125x115 [BFC] children: not-inline
Box <table> at (9,9) content-size 73.828125x113 table-box [TFC] children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tbody> at (9,9) content-size 67.828125x108.40625 table-row-group children: not-inline
Box <tbody> at (9,9) content-size 67.828125x107 table-row-group children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (11,11) content-size 67.828125x54.203125 table-row children: not-inline
Box <tr> at (11,11) content-size 67.828125x53.5 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (17,29.359375) content-size 11.5625x17.46875 table-cell [BFC] children: inline
line 0 width: 11.5625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 1, rect: [17,29.359375 11.5625x17.46875]
BlockContainer <td> at (17,29.25) content-size 11.5625x17 table-cell [BFC] children: inline
line 0 width: 11.5625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 1, rect: [17,29.25 11.5625x17]
"X"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (42.5625,17) content-size 32.265625x98.40625 table-cell [BFC] children: not-inline
BlockContainer <td> at (42.5625,17) content-size 32.265625x97 table-cell [BFC] children: not-inline
BlockContainer <(anonymous)> at (42.5625,17) content-size 32.265625x0 children: inline
TextNode <#text>
TableWrapper <(anonymous)> at (42.5625,17) content-size 32.265625x98.40625 [BFC] children: not-inline
Box <table> at (43.5625,18) content-size 30.265625x96.40625 table-box [TFC] children: not-inline
TableWrapper <(anonymous)> at (42.5625,17) content-size 32.265625x97 [BFC] children: not-inline
Box <table> at (43.5625,18) content-size 30.265625x95 table-box [TFC] children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tbody> at (43.5625,18) content-size 26.265625x88.40625 table-row-group children: not-inline
Box <tbody> at (43.5625,18) content-size 26.265625x87 table-row-group children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (45.5625,20) content-size 26.265625x29.46875 table-row children: not-inline
Box <tr> at (45.5625,20) content-size 26.265625x29 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (51.5625,26) content-size 14.265625x17.46875 table-cell [BFC] children: inline
line 0 width: 14.265625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 1, rect: [51.5625,26 14.265625x17.46875]
BlockContainer <td> at (51.5625,26) content-size 14.265625x17 table-cell [BFC] children: inline
line 0 width: 14.265625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 1, rect: [51.5625,26 14.265625x17]
"A"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (45.5625,51.46875) content-size 26.265625x29.46875 table-row children: not-inline
Box <tr> at (45.5625,51) content-size 26.265625x29 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (51.5625,57.46875) content-size 14.265625x17.46875 table-cell [BFC] children: inline
line 0 width: 9.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 1, rect: [51.5625,57.46875 9.34375x17.46875]
BlockContainer <td> at (51.5625,57) content-size 14.265625x17 table-cell [BFC] children: inline
line 0 width: 9.34375, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 1, rect: [51.5625,57 9.34375x17]
"B"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (45.5625,82.9375) content-size 26.265625x29.46875 table-row children: not-inline
Box <tr> at (45.5625,82) content-size 26.265625x29 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (51.5625,88.9375) content-size 14.265625x17.46875 table-cell [BFC] children: inline
line 0 width: 10.3125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 1, rect: [51.5625,88.9375 10.3125x17.46875]
BlockContainer <td> at (51.5625,88) content-size 14.265625x17 table-cell [BFC] children: inline
line 0 width: 10.3125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 1, rect: [51.5625,88 10.3125x17]
"C"
TextNode <#text>
BlockContainer <(anonymous)> at (42.5625,17) content-size 0x0 children: inline
@ -70,18 +70,18 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
TextNode <#text>
BlockContainer <(anonymous)> at (42.5625,17) content-size 0x0 children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (42.5625,115.40625) content-size 32.265625x0 children: inline
BlockContainer <(anonymous)> at (42.5625,114) content-size 32.265625x0 children: inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (11,67.203125) content-size 67.828125x54.203125 table-row children: not-inline
Box <tr> at (11,66.5) content-size 67.828125x53.5 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (17,85.5625) content-size 11.5625x17.46875 table-cell [BFC] children: inline
line 0 width: 11.09375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 1, rect: [17,85.5625 11.09375x17.46875]
BlockContainer <td> at (17,84.75) content-size 11.5625x17 table-cell [BFC] children: inline
line 0 width: 11.09375, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 1, rect: [17,84.75 11.09375x17]
"Y"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
@ -90,39 +90,39 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (8,124.40625) content-size 784x0 children: inline
BlockContainer <(anonymous)> at (8,123) content-size 784x0 children: inline
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x132.40625]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x131]
PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x116.40625]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x115]
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
PaintableWithLines (TableWrapper(anonymous)) [8,8 75.828125x116.40625]
PaintableBox (Box<TABLE>) [8,8 75.828125x116.40625]
PaintableBox (Box<TBODY>) [9,9 67.828125x108.40625] overflow: [9,9 71.828125x112.40625]
PaintableBox (Box<TR>) [11,11 67.828125x54.203125] overflow: [11,11 69.828125x110.40625]
PaintableWithLines (BlockContainer<TD>) [11,11 23.5625x54.1875]
PaintableWithLines (TableWrapper(anonymous)) [8,8 75.828125x115]
PaintableBox (Box<TABLE>) [8,8 75.828125x115]
PaintableBox (Box<TBODY>) [9,9 67.828125x107] overflow: [9,9 71.828125x111]
PaintableBox (Box<TR>) [11,11 67.828125x53.5] overflow: [11,11 69.828125x109]
PaintableWithLines (BlockContainer<TD>) [11,11 23.5625x53.5]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<TD>) [36.5625,11 44.265625x110.40625]
PaintableWithLines (BlockContainer<TD>) [36.5625,11 44.265625x109]
PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 32.265625x0]
PaintableWithLines (TableWrapper(anonymous)) [42.5625,17 32.265625x98.40625]
PaintableBox (Box<TABLE>) [42.5625,17 32.265625x98.40625] overflow: [42.5625,17 31.265625x97.40625]
PaintableBox (Box<TBODY>) [43.5625,18 26.265625x88.40625] overflow: [42.5625,17 29.265625x95.40625]
PaintableBox (Box<TR>) [45.5625,20 26.265625x29.46875]
PaintableWithLines (BlockContainer<TD>) [45.5625,20 26.265625x29.46875]
PaintableWithLines (TableWrapper(anonymous)) [42.5625,17 32.265625x97]
PaintableBox (Box<TABLE>) [42.5625,17 32.265625x97] overflow: [42.5625,17 31.265625x96]
PaintableBox (Box<TBODY>) [43.5625,18 26.265625x87] overflow: [42.5625,17 29.265625x94]
PaintableBox (Box<TR>) [45.5625,20 26.265625x29]
PaintableWithLines (BlockContainer<TD>) [45.5625,20 26.265625x29]
TextPaintable (TextNode<#text>)
PaintableBox (Box<TR>) [45.5625,51.46875 26.265625x29.46875]
PaintableWithLines (BlockContainer<TD>) [45.5625,51.46875 26.265625x29.46875]
PaintableBox (Box<TR>) [45.5625,51 26.265625x29]
PaintableWithLines (BlockContainer<TD>) [45.5625,51 26.265625x29]
TextPaintable (TextNode<#text>)
PaintableBox (Box<TR>) [45.5625,82.9375 26.265625x29.46875] overflow: [42.5625,17 29.265625x95.40625]
PaintableWithLines (BlockContainer<TD>) [45.5625,82.9375 26.265625x29.46875]
PaintableBox (Box<TR>) [45.5625,82 26.265625x29] overflow: [42.5625,17 29.265625x94]
PaintableWithLines (BlockContainer<TD>) [45.5625,82 26.265625x29]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 0x0]
PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 0x0]
PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 0x0]
PaintableWithLines (BlockContainer(anonymous)) [42.5625,115.40625 32.265625x0]
PaintableBox (Box<TR>) [11,67.203125 67.828125x54.203125]
PaintableWithLines (BlockContainer<TD>) [11,67.203125 23.5625x54.1875]
PaintableWithLines (BlockContainer(anonymous)) [42.5625,114 32.265625x0]
PaintableBox (Box<TR>) [11,66.5 67.828125x53.5]
PaintableWithLines (BlockContainer<TD>) [11,66.5 23.5625x53.5]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [8,124.40625 784x0]
PaintableWithLines (BlockContainer(anonymous)) [8,123 784x0]