mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
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.
88 lines
5.5 KiB
Plaintext
88 lines
5.5 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 268 0+0+0] [BFC] children: not-inline
|
|
BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 252 0+0+8] children: not-inline
|
|
BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: inline
|
|
TextNode <#text> (not painted)
|
|
BlockContainer <div.outer> at [9,9] [0+1+0 300 0+1+482] [0+1+0 250 0+1+0] children: inline
|
|
frag 0 from TextNode start: 9, length: 24, rect: [61,9 212x16] baseline: 12.796875
|
|
"foo bar baz foo bar baz "
|
|
frag 1 from TextNode start: 9, length: 3, rect: [273,9 27.15625x16] baseline: 12.796875
|
|
"foo"
|
|
frag 2 from TextNode start: 13, length: 3, rect: [263,25 27.640625x16] baseline: 12.796875
|
|
"bar"
|
|
frag 3 from TextNode start: 17, length: 3, rect: [263,41 27.203125x16] baseline: 12.796875
|
|
"baz"
|
|
frag 4 from TextNode start: 21, length: 3, rect: [263,57 27.15625x16] baseline: 12.796875
|
|
"foo"
|
|
frag 5 from TextNode start: 25, length: 8, rect: [9,77 70.84375x16] baseline: 12.796875
|
|
"bar baz "
|
|
frag 6 from TextNode start: 41, length: 3, rect: [79.84375,77 27.15625x16] baseline: 12.796875
|
|
"foo"
|
|
frag 7 from TextNode start: 45, length: 11, rect: [9,93 98x16] baseline: 12.796875
|
|
"bar baz foo"
|
|
frag 8 from TextNode start: 57, length: 7, rect: [9,109 62.84375x16] baseline: 12.796875
|
|
"bar baz"
|
|
frag 9 from TextNode start: 9, length: 7, rect: [9,125 62.796875x16] baseline: 12.796875
|
|
"foo bar"
|
|
frag 10 from TextNode start: 17, length: 16, rect: [9,141 141.203125x16] baseline: 12.796875
|
|
"baz foo bar baz "
|
|
frag 11 from TextNode start: 41, length: 15, rect: [150.203125,141 133.15625x16] baseline: 12.796875
|
|
"foo bar baz foo"
|
|
frag 12 from TextNode start: 57, length: 8, rect: [9,157 70.84375x16] baseline: 12.796875
|
|
"bar baz "
|
|
frag 13 from TextNode start: 73, length: 23, rect: [79.84375,157 204x16] baseline: 12.796875
|
|
"foo bar baz foo bar baz"
|
|
frag 14 from TextNode start: 9, length: 23, rect: [61,173 204x16] baseline: 12.796875
|
|
"foo bar baz foo bar baz"
|
|
frag 15 from TextNode start: 9, length: 23, rect: [61,189 204x16] baseline: 12.796875
|
|
"foo bar baz foo bar baz"
|
|
frag 16 from TextNode start: 41, length: 24, rect: [61,205 212x16] baseline: 12.796875
|
|
"foo bar baz foo bar baz "
|
|
frag 17 from TextNode start: 73, length: 3, rect: [273,205 27.15625x16] baseline: 12.796875
|
|
"foo"
|
|
frag 18 from TextNode start: 77, length: 20, rect: [61,221 176.84375x16] baseline: 12.796875
|
|
"bar baz foo bar baz "
|
|
frag 19 from TextNode start: 105, length: 7, rect: [237.84375,221 62.796875x16] baseline: 12.796875
|
|
"foo bar"
|
|
frag 20 from TextNode start: 113, length: 16, rect: [9,237 141.203125x16] baseline: 12.796875
|
|
"baz foo bar baz "
|
|
frag 21 from TextNode start: 137, length: 15, rect: [150.203125,237 133.15625x16] baseline: 12.796875
|
|
"foo bar baz foo"
|
|
frag 22 from TextNode start: 153, length: 8, rect: [9,253 70.84375x16] baseline: 12.796875
|
|
"bar baz "
|
|
frag 23 from TextNode start: 169, length: 23, rect: [79.84375,253 204x16] baseline: 12.796875
|
|
"foo bar baz foo bar baz"
|
|
TextNode <#text> (not painted)
|
|
BlockContainer <div.lefty> at [10,10] floating [0+1+0 50 0+1+0] [0+1+0 50 0+1+0] [BFC] children: not-inline
|
|
TextNode <#text> (not painted)
|
|
BlockContainer <div.one> at [62,26] floating [0+1+0 200 0+1+0] [0+1+0 50 0+1+0] [BFC] children: not-inline
|
|
TextNode <#text> (not painted)
|
|
BlockContainer <div.two> at [108,78] floating [0+1+0 200 0+1+0] [0+1+0 50 0+1+0] [BFC] children: not-inline
|
|
TextNode <#text> (not painted)
|
|
BlockContainer <div.righty> at [76,110] floating [0+1+0 30 0+1+0] [0+1+0 30 0+1+0] [BFC] children: not-inline
|
|
TextNode <#text> (not painted)
|
|
BlockContainer <div.lefty.shwifty> at [10,174] floating [0+1+0 50 0+1+0] [0+1+0 50 0+1+0] [BFC] children: not-inline
|
|
TextNode <#text> (not painted)
|
|
BlockContainer <div.righty> at [278,174] floating [0+1+0 30 0+1+0] [0+1+0 30 0+1+0] [BFC] children: not-inline
|
|
TextNode <#text> (not painted)
|
|
|
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x268] overflow: [0,0 800x269]
|
|
PaintableWithLines (BlockContainer<BODY>) [8,8 784x252] overflow: [8,8 784x261]
|
|
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
|
|
PaintableWithLines (BlockContainer<DIV>.outer) [8,8 302x252] overflow: [9,9 300x260]
|
|
TextPaintable (TextNode<#text>)
|
|
PaintableWithLines (BlockContainer<DIV>.lefty) [9,9 52x52]
|
|
PaintableWithLines (BlockContainer<DIV>.one) [61,25 202x52]
|
|
PaintableWithLines (BlockContainer<DIV>.two) [107,77 202x52]
|
|
TextPaintable (TextNode<#text>)
|
|
PaintableWithLines (BlockContainer<DIV>.righty) [75,109 32x32]
|
|
TextPaintable (TextNode<#text>)
|
|
PaintableWithLines (BlockContainer<DIV>.lefty.shwifty) [9,173 52x52]
|
|
TextPaintable (TextNode<#text>)
|
|
PaintableWithLines (BlockContainer<DIV>.righty) [277,173 32x32]
|
|
TextPaintable (TextNode<#text>)
|
|
|
|
SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto)
|
|
SC for BlockContainer<HTML> [0,0 800x268] [children: 0] (z-index: auto)
|