1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16: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,43 +1,43 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x127.15625 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x111.15625 children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 276x111.15625 [BFC] children: not-inline
Box <table> at (8,8) content-size 276x111.15625 table-box [TFC] children: not-inline
Box <tbody> at (8,8) content-size 272x107.15625 table-row-group children: not-inline
Box <tr> at (10,10) content-size 272x107.15625 table-row children: not-inline
BlockContainer <td> at (11,11) content-size 270x105.15625 table-cell [BFC] children: not-inline
BlockContainer <div> at (11,11) content-size 270x105.15625 children: not-inline
BlockContainer <(anonymous)> at (11,11) 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: [11,11 261.0625x17.46875]
BlockContainer <html> at (0,0) content-size 800x124 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x108 children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 276x108 [BFC] children: not-inline
Box <table> at (8,8) content-size 276x108 table-box [TFC] children: not-inline
Box <tbody> at (8,8) content-size 272x104 table-row-group children: not-inline
Box <tr> at (10,10) content-size 272x104 table-row children: not-inline
BlockContainer <td> at (11,11) content-size 270x102 table-cell [BFC] children: not-inline
BlockContainer <div> at (11,11) content-size 270x102 children: not-inline
BlockContainer <(anonymous)> at (11,11) 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: [11,11 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: [11,28 261.0625x17.46875]
line 1 width: 261.0625, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 37, length: 35, rect: [11,28 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: [11,45 261.0625x17.46875]
line 2 width: 261.0625, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 73, length: 35, rect: [11,45 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: [11,63 261.0625x17.46875]
line 3 width: 261.0625, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 109, length: 35, rect: [11,62 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: [11,80 261.0625x17.46875]
line 4 width: 261.0625, height: 17, bottom: 85, baseline: 13.296875
frag 0 from TextNode start: 145, length: 35, rect: [11,79 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: [11,98 81.6875x17.46875]
line 5 width: 81.6875, height: 17, bottom: 102, baseline: 13.296875
frag 0 from TextNode start: 181, length: 11, rect: [11,96 81.6875x17]
"hello hello"
TextNode <#text>
BlockContainer <div> at (11,116.15625) content-size 270x0 children: not-inline
BlockContainer <div> at (11,113) content-size 270x0 children: not-inline
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x127.15625]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x111.15625]
PaintableWithLines (TableWrapper(anonymous)) [8,8 276x111.15625]
PaintableBox (Box<TABLE>) [8,8 276x111.15625]
PaintableBox (Box<TBODY>) [8,8 272x107.15625] overflow: [8,8 274x109.15625]
PaintableBox (Box<TR>) [10,10 272x107.15625]
PaintableWithLines (BlockContainer<TD>) [10,10 272x107.15625]
PaintableWithLines (BlockContainer<DIV>) [11,11 270x105.15625]
PaintableWithLines (BlockContainer(anonymous)) [11,11 270x105.15625]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x124]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x108]
PaintableWithLines (TableWrapper(anonymous)) [8,8 276x108]
PaintableBox (Box<TABLE>) [8,8 276x108]
PaintableBox (Box<TBODY>) [8,8 272x104] overflow: [8,8 274x106]
PaintableBox (Box<TR>) [10,10 272x104]
PaintableWithLines (BlockContainer<TD>) [10,10 272x104]
PaintableWithLines (BlockContainer<DIV>) [11,11 270x102]
PaintableWithLines (BlockContainer(anonymous)) [11,11 270x102]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>) [11,116.15625 270x0]
PaintableWithLines (BlockContainer<DIV>) [11,113 270x0]