1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:47: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,19 +1,19 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x332.34375 children: not-inline
BlockContainer <body> at (8,8) content-size 784x323 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
TextNode <#text>
BlockContainer <div> at (8,8) content-size 784x0 children: inline
TextNode <#text>
BlockContainer <div#lefty> at (8,8) content-size 100x100 floating [BFC] children: inline
line 0 width: 10.859375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 1, rect: [8,8 10.859375x17.46875]
line 0 width: 10.859375, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 1, rect: [8,8 10.859375x17]
"L"
TextNode <#text>
TextNode <#text>
BlockContainer <div#righty> at (742,8) content-size 50x50 floating [BFC] children: inline
line 0 width: 13.6875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 1, rect: [742,8 13.6875x17.46875]
line 0 width: 13.6875, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 1, rect: [742,8 13.6875x17]
"R"
TextNode <#text>
TextNode <#text>
@ -22,14 +22,14 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <div> at (8,8) content-size 784x0 children: inline
TextNode <#text>
BlockContainer <div#lefty2> at (108,8) content-size 80x80 floating [BFC] children: inline
line 0 width: 19.671875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 2, rect: [108,8 19.671875x17.46875]
line 0 width: 19.671875, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 2, rect: [108,8 19.671875x17]
"L2"
TextNode <#text>
TextNode <#text>
BlockContainer <div#righty2> at (712,8) content-size 30x30 floating [BFC] children: inline
line 0 width: 22.5, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 2, rect: [712,8 22.5x17.46875]
line 0 width: 22.5, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 2, rect: [712,8 22.5x17]
"R2"
TextNode <#text>
TextNode <#text>
@ -38,84 +38,84 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <div> at (8,8) content-size 784x0 children: inline
TextNode <#text>
BlockContainer <div#lefty3> at (188,8) content-size 40x40 floating [BFC] children: inline
line 0 width: 19.953125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 2, rect: [188,8 19.953125x17.46875]
line 0 width: 19.953125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 2, rect: [188,8 19.953125x17]
"L3"
TextNode <#text>
TextNode <#text>
BlockContainer <div#righty3> at (692,8) content-size 20x20 floating [BFC] children: inline
line 0 width: 22.78125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 2, rect: [692,8 22.78125x17.46875]
line 0 width: 22.78125, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 0, length: 2, rect: [692,8 22.78125x17]
"R3"
TextNode <#text>
TextNode <#text>
BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
TextNode <#text>
BlockContainer <div> at (8,8) content-size 784x332.34375 children: inline
line 0 width: 414.5625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 1, length: 47, rect: [228,8 414.5625x17.46875]
BlockContainer <div> at (8,8) content-size 784x323 children: inline
line 0 width: 414.5625, height: 17, bottom: 17, baseline: 13.296875
frag 0 from TextNode start: 1, length: 47, rect: [228,8 414.5625x17]
"lorem ipsum lorem ipsum lorem ipsum lorem ipsum"
line 1 width: 414.5625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
frag 0 from TextNode start: 49, length: 47, rect: [228,25 414.5625x17.46875]
line 1 width: 414.5625, height: 17, bottom: 34, baseline: 13.296875
frag 0 from TextNode start: 49, length: 47, rect: [228,25 414.5625x17]
"lorem ipsum lorem ipsum lorem ipsum lorem ipsum"
line 2 width: 466.90625, height: 18.40625, bottom: 53.34375, baseline: 13.53125
frag 0 from TextNode start: 97, length: 53, rect: [228,42 466.90625x17.46875]
line 2 width: 466.90625, height: 17, bottom: 51, baseline: 13.296875
frag 0 from TextNode start: 97, length: 53, rect: [228,42 466.90625x17]
"lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 3 width: 573.5, height: 17.875, bottom: 70.28125, baseline: 13.53125
frag 0 from TextNode start: 151, length: 65, rect: [188,60 573.5x17.46875]
line 3 width: 573.5, height: 17, bottom: 68, baseline: 13.296875
frag 0 from TextNode start: 151, length: 65, rect: [188,59 573.5x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum"
line 4 width: 572.546875, height: 18.34375, bottom: 88.21875, baseline: 13.53125
frag 0 from TextNode start: 217, length: 65, rect: [188,77 572.546875x17.46875]
line 4 width: 572.546875, height: 17, bottom: 85, baseline: 13.296875
frag 0 from TextNode start: 217, length: 65, rect: [188,76 572.546875x17]
"lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 5 width: 679.140625, height: 17.8125, bottom: 105.15625, baseline: 13.53125
frag 0 from TextNode start: 283, length: 77, rect: [108,95 679.140625x17.46875]
line 5 width: 679.140625, height: 17, bottom: 102, baseline: 13.296875
frag 0 from TextNode start: 283, length: 77, rect: [108,93 679.140625x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum"
line 6 width: 783.828125, height: 18.28125, bottom: 123.09375, baseline: 13.53125
frag 0 from TextNode start: 361, length: 89, rect: [8,112 783.828125x17.46875]
line 6 width: 783.828125, height: 17, bottom: 119, baseline: 13.296875
frag 0 from TextNode start: 361, length: 89, rect: [8,110 783.828125x17]
"lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 7 width: 731.484375, height: 17.75, bottom: 140.03125, baseline: 13.53125
frag 0 from TextNode start: 451, length: 83, rect: [8,130 731.484375x17.46875]
line 7 width: 731.484375, height: 17, bottom: 136, baseline: 13.296875
frag 0 from TextNode start: 451, length: 83, rect: [8,127 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 8 width: 731.484375, height: 18.21875, bottom: 157.96875, baseline: 13.53125
frag 0 from TextNode start: 535, length: 83, rect: [8,147 731.484375x17.46875]
line 8 width: 731.484375, height: 17, bottom: 153, baseline: 13.296875
frag 0 from TextNode start: 535, length: 83, rect: [8,144 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 9 width: 731.484375, height: 17.6875, bottom: 174.90625, baseline: 13.53125
frag 0 from TextNode start: 619, length: 83, rect: [8,165 731.484375x17.46875]
line 9 width: 731.484375, height: 17, bottom: 170, baseline: 13.296875
frag 0 from TextNode start: 619, length: 83, rect: [8,161 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 10 width: 731.484375, height: 18.15625, bottom: 192.84375, baseline: 13.53125
frag 0 from TextNode start: 703, length: 83, rect: [8,182 731.484375x17.46875]
line 10 width: 731.484375, height: 17, bottom: 187, baseline: 13.296875
frag 0 from TextNode start: 703, length: 83, rect: [8,178 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 11 width: 731.484375, height: 17.625, bottom: 209.78125, baseline: 13.53125
frag 0 from TextNode start: 787, length: 83, rect: [8,200 731.484375x17.46875]
line 11 width: 731.484375, height: 17, bottom: 204, baseline: 13.296875
frag 0 from TextNode start: 787, length: 83, rect: [8,195 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 12 width: 731.484375, height: 18.09375, bottom: 227.71875, baseline: 13.53125
frag 0 from TextNode start: 871, length: 83, rect: [8,217 731.484375x17.46875]
line 12 width: 731.484375, height: 17, bottom: 221, baseline: 13.296875
frag 0 from TextNode start: 871, length: 83, rect: [8,212 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 13 width: 731.484375, height: 17.5625, bottom: 244.65625, baseline: 13.53125
frag 0 from TextNode start: 955, length: 83, rect: [8,235 731.484375x17.46875]
line 13 width: 731.484375, height: 17, bottom: 238, baseline: 13.296875
frag 0 from TextNode start: 955, length: 83, rect: [8,229 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 14 width: 731.484375, height: 18.03125, bottom: 262.59375, baseline: 13.53125
frag 0 from TextNode start: 1039, length: 83, rect: [8,252 731.484375x17.46875]
line 14 width: 731.484375, height: 17, bottom: 255, baseline: 13.296875
frag 0 from TextNode start: 1039, length: 83, rect: [8,246 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 15 width: 731.484375, height: 17.5, bottom: 279.53125, baseline: 13.53125
frag 0 from TextNode start: 1123, length: 83, rect: [8,270 731.484375x17.46875]
line 15 width: 731.484375, height: 17, bottom: 272, baseline: 13.296875
frag 0 from TextNode start: 1123, length: 83, rect: [8,263 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 16 width: 731.484375, height: 17.96875, bottom: 297.46875, baseline: 13.53125
frag 0 from TextNode start: 1207, length: 83, rect: [8,287 731.484375x17.46875]
line 16 width: 731.484375, height: 17, bottom: 289, baseline: 13.296875
frag 0 from TextNode start: 1207, length: 83, rect: [8,280 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 17 width: 731.484375, height: 18.4375, bottom: 315.40625, baseline: 13.53125
frag 0 from TextNode start: 1291, length: 83, rect: [8,304 731.484375x17.46875]
line 17 width: 731.484375, height: 17, bottom: 306, baseline: 13.296875
frag 0 from TextNode start: 1291, length: 83, rect: [8,297 731.484375x17]
"ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
line 18 width: 45.296875, height: 17.90625, bottom: 332.34375, baseline: 13.53125
frag 0 from TextNode start: 1375, length: 5, rect: [8,322 45.296875x17.46875]
line 18 width: 45.296875, height: 17, bottom: 323, baseline: 13.296875
frag 0 from TextNode start: 1375, length: 5, rect: [8,314 45.296875x17]
"ipsum"
TextNode <#text>
BlockContainer <(anonymous)> at (8,340.34375) content-size 784x0 children: inline
BlockContainer <(anonymous)> at (8,331) content-size 784x0 children: inline
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x332.34375]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x323]
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
PaintableWithLines (BlockContainer<DIV>) [8,8 784x0]
PaintableWithLines (BlockContainer<DIV>#lefty) [8,8 100x100]
@ -135,6 +135,6 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<DIV>#righty3) [692,8 20x20] overflow: [692,8 22.78125x20]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
PaintableWithLines (BlockContainer<DIV>) [8,8 784x332.34375]
PaintableWithLines (BlockContainer<DIV>) [8,8 784x323]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [8,340.34375 784x0]
PaintableWithLines (BlockContainer(anonymous)) [8,331 784x0]