LibWeb: Replace InlinePaintable with PaintableWithLines created per line

InlinePaintable was an ad-hoc paintable type required to support the
fragmentation of inline nodes across multiple lines. It existed because
there was no way to associate multiple paintables with a single layout
node. This resulted in a lot of duplicated code between PaintableBox and
InlinePaintable. For example, most of the CSS properties like
background, border, shadows, etc. and hit-testing are almost identical
for both of them. However, the code had to be duplicated to account for
the fact that InlinePaintable creates a box for each line. And we had
quite many places that operate on paintables with a code like:
```
if (box.is_paintable_box()) {
  // do something
} else (box.is_inline_paintable()) {
  // do exactly the same as for paintable box but using InlinePaintable
}
```

This change replaces the usage of `InlinePaintable` with
`PaintableWithLines` created for each line, which is now possible
because we support having multiple paintables per layout node. By doing
that, we remove lots of duplicated code and bring our implementation
closer to the spec.
This commit is contained in:
Aliaksandr Kalenik 2024-10-13 21:29:47 +02:00 committed by Alexander Kalenik
commit 6a549f6270
Notes: github-actions[bot] 2024-10-16 18:26:41 +00:00
58 changed files with 364 additions and 290 deletions

View file

@ -171,83 +171,83 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<DIV>.ol) [8,8 784x255]
PaintableWithLines (BlockContainer(anonymous)) [24,8 768x0]
PaintableWithLines (BlockContainer<DIV>.li) [24,8 768x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [24,25 768x0]
PaintableWithLines (BlockContainer<DIV>.li) [24,25 768x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [24,42 768x0]
PaintableWithLines (BlockContainer<DIV>.li) [24,42 768x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [24,59 768x0]
PaintableWithLines (BlockContainer<DIV>.li) [24,59 768x153]
PaintableWithLines (BlockContainer(anonymous)) [24,59 768x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.ol) [24,76 768x136]
PaintableWithLines (BlockContainer(anonymous)) [40,76 752x0]
PaintableWithLines (BlockContainer<DIV>.li) [40,76 752x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [40,93 752x0]
PaintableWithLines (BlockContainer<DIV>.li) [40,93 752x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [40,110 752x0]
PaintableWithLines (BlockContainer<DIV>.li) [40,110 752x68]
PaintableWithLines (BlockContainer(anonymous)) [40,110 752x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<DIV>.ol) [40,127 752x51]
PaintableWithLines (BlockContainer(anonymous)) [56,127 736x0]
PaintableWithLines (BlockContainer<DIV>.li) [56,127 736x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [56,144 736x0]
PaintableWithLines (BlockContainer<DIV>.li) [56,144 736x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [56,161 736x0]
PaintableWithLines (BlockContainer<DIV>.li) [56,161 736x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [56,178 736x0]
PaintableWithLines (BlockContainer(anonymous)) [40,178 752x0]
PaintableWithLines (BlockContainer(anonymous)) [40,178 752x0]
PaintableWithLines (BlockContainer<DIV>.li) [40,178 752x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [40,195 752x0]
PaintableWithLines (BlockContainer<DIV>.li) [40,195 752x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [40,212 752x0]
PaintableWithLines (BlockContainer(anonymous)) [24,212 768x0]
PaintableWithLines (BlockContainer(anonymous)) [24,212 768x0]
PaintableWithLines (BlockContainer<DIV>.li) [24,212 768x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [24,229 768x0]
PaintableWithLines (BlockContainer<DIV>.li) [24,229 768x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [24,246 768x0]
PaintableWithLines (BlockContainer<DIV>.li) [24,246 768x17]
InlinePaintable (InlineNode(anonymous))
PaintableWithLines (InlineNode(anonymous))
TextPaintable (TextNode<#text>)
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [24,263 768x0]