Files
ladybird/Tests/LibWeb/Layout/expected/acid1.txt
Jelle Raaijmakers 9e9db9a9dd LibWeb: Store correct text offsets in PaintableFragment
Previously, we were collapsing whitespace in Layout::TextNode and then
passed the resulting string for further processing through ChunkIterator
-> InlineLevelIterator -> InlineFormattingContext -> LineBuilder ->
LineBoxFragment -> PaintableFragment. Our painting tree is where we deal
with things like range offsets into the underlying text nodes, but since
we modified the original string, the offsets were wrong.

This changes the way we generate fragments:

  * Layout::TextNode no longer collapses whitespace as part of its
    stored "text for rendering", but moves this logic to ChunkIterator
    which splits up this text into separate views whenever whitespace
    needs to be collapsed.

  * Layout::LineBox now only extends the last fragment if its end offset
    is equal to the new fragment's start offset. Otherwise, there's a
    gap caused by collapsing whitespace and we need to generate a
    separate fragment for that in order to have a correct start offset.

Some tests need new baselines because of the fixed start offsets.

Fixes #566.
2025-09-12 15:34:09 -04:00

189 lines
13 KiB
Plaintext

Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-inline
BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 420 0+0+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [0,0] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <body> at [20,20] [15+5+0 480 0+5+295] [15+5+0 380 0+5+15] children: not-inline
BlockContainer <(anonymous)> at [20,20] [0+0+0 480 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <dl> at [25,25] [0+0+5 470 5+0+0] [0+0+5 0 5+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <dt> at [40,40] floating [0+5+10 49.984375 10+5+0] [0+5+10 280 10+5+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 6, rect: [40,40 28.3125x10] baseline: 8
"toggle"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <dd> at [135,45] floating [10+10+10 340 10+10+0] [0+10+10 270 10+10+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [135,45] [0+0+0 340 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <ul> at [135,45] [0+0+0 340 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <li> at [150,60] floating [0+5+10 50 10+5+0] [0+5+10 90 10+5+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 7, rect: [150,60 37.890625x10] baseline: 8
"the way"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <li#bar> at [235,55] floating [10+0+10 139.96875 10+0+10] [0+0+10 90 10+0+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [235,55] [0+0+0 139.96875 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <p> at [235,55] [0+0+0 139.96875 0+0+0] [0+0+0 10 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 14, rect: [235,55 74.296875x10] baseline: 8
"the world ends"
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [235,65] [0+0+0 139.96875 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
InlineNode <form> at [235,65] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [235,65] [0+0+0 139.96875 0+0+0] [0+0+0 19 0+0+0] children: not-inline continuation
BlockContainer <p> at [235,65] [0+0+0 139.96875 0+0+0] [0+0+0 19 0+0+0] children: inline
frag 0 from TextNode start: 33, length: 5, rect: [235,65 27.5x19] baseline: 12.5
"bang "
frag 1 from RadioButton start: 0, length: 0, rect: [262.5,65 12x12] baseline: 12
TextNode <#text> (not painted)
RadioButton <input> at [262.5,65] inline-block [0+0+0 12 0+0+0] [0+0+0 12 0+0+0] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [235,84] [0+0+0 139.96875 0+0+0] [0+0+0 0 0+0+0] children: inline
InlineNode <form> at [235,84] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0] continuation
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [235,84] [0+0+0 139.96875 0+0+0] [0+0+0 19 0+0+0] children: not-inline continuation
BlockContainer <p> at [235,84] [0+0+0 139.96875 0+0+0] [0+0+0 19 0+0+0] children: inline
frag 0 from TextNode start: 33, length: 8, rect: [235,84 45.171875x19] baseline: 12.5
"whimper "
frag 1 from RadioButton start: 0, length: 0, rect: [280.171875,84 12x12] baseline: 12
TextNode <#text> (not painted)
RadioButton <input> at [280.171875,84] inline-block [0+0+0 12 0+0+0] [0+0+0 12 0+0+0] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [235,103] [0+0+0 139.96875 0+0+0] [0+0+0 0 0+0+0] children: inline
InlineNode <form> at [235,103] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0] continuation
TextNode <#text> (not painted)
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <li> at [409.96875,60] floating [0+5+10 50 10+5+0] [0+5+10 90 10+5+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 6, rect: [409.96875,60 31.59375x10] baseline: 8
"i grow"
frag 1 from TextNode start: 7, length: 3, rect: [409.96875,70 14.015625x10] baseline: 8
"old"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <li#baz> at [145,185] floating [0+0+10 100 10+0+0] [10+0+10 100 10+0+10] [BFC] children: inline
frag 0 from TextNode start: 0, length: 6, rect: [145,185 29.421875x10] baseline: 8
"pluot?"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [135,45] [0+0+0 340 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <blockquote> at [280,195] floating [20+5+0 50 0+15+10] [10+10+10 90 10+20+10] [BFC] children: not-inline
BlockContainer <(anonymous)> at [280,195] [0+0+0 50 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <address> at [280,195] [0+0+0 50 0+0+0] [0+0+0 20 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 3, rect: [280,195 17.28125x10] baseline: 8
"bar"
frag 1 from TextNode start: 4, length: 6, rect: [280,205 30.234375x10] baseline: 8
"maids,"
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [280,215] [0+0+0 50 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <h1> at [365,185] floating [0+0+10 100 10+0+0] [10+0+10 100 10+0+10] [BFC] children: inline
frag 0 from TextNode start: 0, length: 11, rect: [365,185 56.421875x10] baseline: 8
"sing to me,"
frag 1 from TextNode start: 12, length: 12, rect: [365,195 65.46875x10] baseline: 8
"erbarme dich"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [20,30] [0+0+0 480 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <p> at [20,335] [0+0+0 480 0+0+0] [0+0+0 65 0+0+0] children: inline
frag 0 from TextNode start: 13, length: 86, rect: [20,335 448.296875x13] baseline: 9.5
"This is a nonsensical document, but syntactically valid HTML 4.0. All 100%-conformant "
frag 1 from TextNode start: 111, length: 4, rect: [468.296875,335 25.390625x13] baseline: 9.5
"CSS1"
frag 2 from TextNode start: 116, length: 74, rect: [20,348 396.96875x13] baseline: 9.5
"agents should be able to render the document elements above this paragraph"
frag 3 from TextNode start: 203, length: 43, rect: [20,361 207.9375x13] baseline: 9.5
"indistinguishably (to the pixel) from this "
frag 4 from TextNode start: 0, length: 1, rect: [330.96875,361 5x13] baseline: 9.5
" "
frag 5 from TextNode start: 13, length: 30, rect: [335.96875,361 154.671875x13] baseline: 9.5
"(except font rasterization and"
frag 6 from TextNode start: 44, length: 56, rect: [20,374 286.6875x13] baseline: 9.5
"form widgets). All discrepancies should be traceable to "
frag 7 from TextNode start: 112, length: 33, rect: [306.6875,374 178.40625x13] baseline: 9.5
"CSS1 implementation shortcomings."
frag 8 from TextNode start: 146, length: 53, rect: [20,387 271.421875x13] baseline: 9.5
"Once you have finished evaluating this test, you can "
frag 9 from TextNode start: 211, length: 14, rect: [291.421875,387 74.171875x13] baseline: 9.5
"return to the "
frag 10 from TextNode start: 0, length: 1, rect: [425.5,387 2.71875x13] baseline: 9.5
"."
TextNode <#text> (not painted)
InlineNode <a> at [227.9375,361] [0+0+0 103.03125 0+0+0] [0+0+0 13 0+0+0]
frag 0 from TextNode start: 0, length: 20, rect: [227.9375,361 103.03125x13] baseline: 9.5
"reference rendering,"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
InlineNode <a> at [365.59375,387] [0+0+0 59.90625 0+0+0] [0+0+0 13 0+0+0]
frag 0 from TextNode start: 0, length: 11, rect: [365.59375,387 59.90625x13] baseline: 9.5
"parent page"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [20,400] [0+0+0 480 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x420]
PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0]
PaintableWithLines (BlockContainer<BODY>) [15,15 490x390]
PaintableWithLines (BlockContainer(anonymous)) [20,20 480x0]
PaintableWithLines (BlockContainer<DL>) [20,20 480x10] overflow: [20,20 480x320]
PaintableWithLines (BlockContainer<DT>) [25,25 79.984375x310]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DD>) [115,25 380x310]
PaintableWithLines (BlockContainer(anonymous)) [135,45 340x0]
PaintableWithLines (BlockContainer<UL>) [135,45 340x0] overflow: [135,45 339.96875x250]
PaintableWithLines (BlockContainer<LI>) [135,45 80x120]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<LI>#bar) [225,45 159.96875x110]
PaintableWithLines (BlockContainer(anonymous)) [235,55 139.96875x0]
PaintableWithLines (BlockContainer<P>) [235,55 139.96875x10]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [235,65 139.96875x0]
PaintableWithLines (InlineNode<FORM>) [235,65 0x10]
PaintableWithLines (BlockContainer(anonymous)) [235,65 139.96875x19]
PaintableWithLines (BlockContainer<P>) [235,65 139.96875x19]
TextPaintable (TextNode<#text>)
RadioButtonPaintable (RadioButton<INPUT>) [262.5,65 12x12]
PaintableWithLines (BlockContainer(anonymous)) [235,84 139.96875x0]
PaintableWithLines (InlineNode<FORM>) [235,84 0x10]
PaintableWithLines (BlockContainer(anonymous)) [235,84 139.96875x19]
PaintableWithLines (BlockContainer<P>) [235,84 139.96875x19]
TextPaintable (TextNode<#text>)
RadioButtonPaintable (RadioButton<INPUT>) [280.171875,84 12x12]
PaintableWithLines (BlockContainer(anonymous)) [235,103 139.96875x0]
PaintableWithLines (InlineNode<FORM>) [235,103 0x10]
PaintableWithLines (BlockContainer<LI>) [394.96875,45 80x120]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<LI>#baz) [135,175 120x120]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [135,45 340x0] overflow: [275,175 200x140]
PaintableWithLines (BlockContainer<BLOCKQUOTE>) [275,175 70x140]
PaintableWithLines (BlockContainer(anonymous)) [280,195 50x0]
PaintableWithLines (BlockContainer<ADDRESS>) [280,195 50x20]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [280,215 50x0]
PaintableWithLines (BlockContainer<H1>) [355,175 120x120]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [20,30 480x0]
PaintableWithLines (BlockContainer<P>) [20,335 480x65]
TextPaintable (TextNode<#text>)
PaintableWithLines (InlineNode<A>) [227.9375,361 103.03125x13]
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (InlineNode<A>) [365.59375,387 59.90625x13]
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [20,400 480x0]
SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x420] [children: 0] (z-index: auto)