1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:57:44 +00:00

LibWeb: Support transforms, stroking, gradients, etc for SVG <text>

This makes use of the new Gfx::Path::text() to handle SVG text elements,
with this text is just a regular path, and can be manipulated like any
other graphics element.

This removes the SVGTextPaintable and makes both <text> and geometry
elements use a new (shared) SVGPathPaintable. This is identical to the
old SVGGeometryPaintable. This simplifies painting as once something is
resolved to a Gfx::Path, the painting logic is the same.
This commit is contained in:
MacDue 2023-11-04 21:31:35 +00:00 committed by Alexander Kalenik
parent 50d33f79fa
commit 4c5d48f861
30 changed files with 144 additions and 180 deletions

View file

@ -9,7 +9,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
frag 2 from Box start: 0, length: 0, rect: [319,51 0x108]
SVGSVGBox <svg> at (9,9) content-size 300x150 [SVG] children: inline
InlineNode <a>
SVGTextBox <text> at (29,9) content-size 198.90625x80 children: inline
SVGTextBox <text> at (29,25.015625) content-size 193.59375x67.578125 children: inline
TextNode <#text>
TextNode <#text>
Box <math> at (319,51) content-size 0x108 children: not-inline

View file

@ -8,4 +8,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x100]
PaintableBox (Box<BODY>) [0,0 800x100]
SVGSVGPaintable (SVGSVGBox<svg>) [0,0 200x100]
SVGGeometryPaintable (SVGGeometryBox<rect>) [0,0 200x100]
SVGPathPaintable (SVGGeometryBox<rect>) [0,0 200x100]

View file

@ -8,4 +8,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x16]
PaintableBox (Box<BODY>) [8,8 784x0]
SVGSVGPaintable (SVGSVGBox<svg>) [400,8 0x0]
SVGGeometryPaintable (SVGGeometryBox<rect>) [400,8 0x0]
SVGPathPaintable (SVGGeometryBox<rect>) [400,8 0x0]

View file

@ -108,39 +108,39 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x257.46875]
SVGSVGPaintable (SVGSVGBox<svg>) [8,83 102x52]
SVGGeometryPaintable (SVGGeometryBox<circle>) [34,84 50x50]
SVGPathPaintable (SVGGeometryBox<circle>) [34,84 50x50]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [118,83 102x52]
SVGGeometryPaintable (SVGGeometryBox<circle>) [119,84 50x50]
SVGPathPaintable (SVGGeometryBox<circle>) [119,84 50x50]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [228,83 102x52]
SVGGeometryPaintable (SVGGeometryBox<circle>) [279,84 50x50]
SVGPathPaintable (SVGGeometryBox<circle>) [279,84 50x50]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [338,83 102x52]
SVGGeometryPaintable (SVGGeometryBox<circle>) [339,84 100x100]
SVGPathPaintable (SVGGeometryBox<circle>) [339,84 100x100]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [448,83 102x52]
SVGGeometryPaintable (SVGGeometryBox<circle>) [449,59 100x100]
SVGPathPaintable (SVGGeometryBox<circle>) [449,59 100x100]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [558,83 102x52]
SVGGeometryPaintable (SVGGeometryBox<circle>) [559,34 100x100]
SVGPathPaintable (SVGGeometryBox<circle>) [559,34 100x100]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [668,8 52x127]
SVGGeometryPaintable (SVGGeometryBox<circle>) [669,9 50x50]
SVGPathPaintable (SVGGeometryBox<circle>) [669,9 50x50]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [728,8 52x127]
SVGGeometryPaintable (SVGGeometryBox<circle>) [729,46.5 50x50]
SVGPathPaintable (SVGGeometryBox<circle>) [729,46.5 50x50]
SVGSVGPaintable (SVGSVGBox<svg>) [8,135 52x127]
SVGGeometryPaintable (SVGGeometryBox<circle>) [9,211 50x50]
SVGPathPaintable (SVGGeometryBox<circle>) [9,211 50x50]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [68,135 52x127]
SVGGeometryPaintable (SVGGeometryBox<circle>) [69,136 125x125]
SVGPathPaintable (SVGGeometryBox<circle>) [69,136 125x125]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [128,135 52x127]
SVGGeometryPaintable (SVGGeometryBox<circle>) [91.5,136 125x125]
SVGPathPaintable (SVGGeometryBox<circle>) [91.5,136 125x125]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [188,135 52x127]
SVGGeometryPaintable (SVGGeometryBox<circle>) [114,136 125x125]
SVGPathPaintable (SVGGeometryBox<circle>) [114,136 125x125]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [248,200 162x62]
SVGGeometryPaintable (SVGGeometryBox<circle>) [299,201 60x60]
SVGPathPaintable (SVGGeometryBox<circle>) [299,201 60x60]

View file

@ -6,16 +6,16 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
SVGSVGBox <svg> at (8,8) content-size 784x261.328125 [SVG] children: inline
TextNode <#text>
TextNode <#text>
SVGTextBox <text.small> at (73.34375,79.859375) content-size 50.265625x42.46875 children: inline
SVGTextBox <text.small> at (73.34375,88.359375) content-size 48.109375x37.484375 children: inline
TextNode <#text>
TextNode <#text>
SVGTextBox <text.heavy> at (138.6875,24.328125) content-size 153.703125x98 children: inline
SVGTextBox <text.heavy> at (138.6875,43.953125) content-size 148.234375x79.71875 children: inline
TextNode <#text>
TextNode <#text>
SVGTextBox <text.small> at (187.671875,145.1875) content-size 36.90625x42.46875 children: inline
SVGTextBox <text.small> at (187.671875,153.703125) content-size 34.59375x34.703125 children: inline
TextNode <#text>
TextNode <#text>
SVGTextBox <text.Rrrrr> at (220.34375,57) content-size 526.609375x130.65625 children: inline
SVGTextBox <text.Rrrrr> at (220.34375,83.15625) content-size 519.34375x115.359375 children: inline
TextNode <#text>
TextNode <#text>
TextNode <#text>
@ -24,7 +24,7 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x261.328125]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 784x261.328125]
SVGTextPaintable (SVGTextBox<text>.small) [73.34375,79.859375 50.265625x42.46875]
SVGTextPaintable (SVGTextBox<text>.heavy) [138.6875,24.328125 153.703125x98]
SVGTextPaintable (SVGTextBox<text>.small) [187.671875,145.1875 36.90625x42.46875]
SVGTextPaintable (SVGTextBox<text>.Rrrrr) [220.34375,57 526.609375x130.65625]
SVGPathPaintable (SVGTextBox<text>.small) [73.34375,88.359375 48.109375x37.484375]
SVGPathPaintable (SVGTextBox<text>.heavy) [138.6875,43.953125 148.234375x79.71875]
SVGPathPaintable (SVGTextBox<text>.small) [187.671875,153.703125 34.59375x34.703125]
SVGPathPaintable (SVGTextBox<text>.Rrrrr) [220.34375,83.15625 519.34375x115.359375]

View file

@ -100,33 +100,33 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x700]
PaintableWithLines (BlockContainer<BODY>) [50,50 700x600]
SVGSVGPaintable (SVGSVGBox<svg>) [50,150 200x100]
SVGGraphicsPaintable (SVGGraphicsBox<g>) [45.6875,199.828125 118.78125x47.453125]
SVGGeometryPaintable (SVGGeometryBox<path>) [45.6875,199.828125 118.78125x47.453125]
SVGPathPaintable (SVGGeometryBox<path>) [45.6875,199.828125 118.78125x47.453125]
SVGGraphicsPaintable (SVGGraphicsBox<g>) [84.5,159.5 81x81]
SVGGeometryPaintable (SVGGeometryBox<path>) [84.5,159.5 81x81]
SVGPathPaintable (SVGGeometryBox<path>) [84.5,159.5 81x81]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [258,50 200x200]
SVGGeometryPaintable (SVGGeometryBox<rect>) [268,60 30x20]
SVGGeometryPaintable (SVGGeometryBox<rect>) [288,130 110x90]
SVGPathPaintable (SVGGeometryBox<rect>) [268,60 30x20]
SVGPathPaintable (SVGGeometryBox<rect>) [288,130 110x90]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [466,50 200x200]
SVGGeometryPaintable (SVGGeometryBox<rect>) [506,90 120x120]
SVGGeometryPaintable (SVGGeometryBox<rect>) [471.359375,90 189.28125x120]
SVGPathPaintable (SVGGeometryBox<rect>) [506,90 120x120]
SVGPathPaintable (SVGGeometryBox<rect>) [471.359375,90 189.28125x120]
SVGSVGPaintable (SVGSVGBox<svg>) [50,250 200x200]
SVGGeometryPaintable (SVGGeometryBox<rect>) [120.59375,320.59375 58.828125x58.828125]
SVGGeometryPaintable (SVGGeometryBox<rect>) [52.4375,310.375 68.140625x68.140625]
SVGGeometryPaintable (SVGGeometryBox<rect>) [179.40625,321.484375 68.140625x68.140625]
SVGPathPaintable (SVGGeometryBox<rect>) [120.59375,320.59375 58.828125x58.828125]
SVGPathPaintable (SVGGeometryBox<rect>) [52.4375,310.375 68.140625x68.140625]
SVGPathPaintable (SVGGeometryBox<rect>) [179.40625,321.484375 68.140625x68.140625]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [258,250 200x200]
SVGGeometryPaintable (SVGGeometryBox<circle>) [278,270 160x160]
SVGGeometryPaintable (SVGGeometryBox<circle>) [338,270 40x160]
SVGGeometryPaintable (SVGGeometryBox<circle>) [278,330 160x40]
SVGGeometryPaintable (SVGGeometryBox<circle>) [338,330 40x40]
SVGPathPaintable (SVGGeometryBox<circle>) [278,270 160x160]
SVGPathPaintable (SVGGeometryBox<circle>) [338,270 40x160]
SVGPathPaintable (SVGGeometryBox<circle>) [278,330 160x40]
SVGPathPaintable (SVGGeometryBox<circle>) [338,330 40x40]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [466,250 200x200]
SVGGeometryPaintable (SVGGeometryBox<rect>) [506,290 120x120]
SVGGeometryPaintable (SVGGeometryBox<rect>) [506,255.359375 120x189.28125]
SVGPathPaintable (SVGGeometryBox<rect>) [506,290 120x120]
SVGPathPaintable (SVGGeometryBox<rect>) [506,255.359375 120x189.28125]
SVGSVGPaintable (SVGSVGBox<svg>) [50,450 200x200]
SVGGeometryPaintable (SVGGeometryBox<rect>) [60,460 80x80]
SVGGeometryPaintable (SVGGeometryBox<rect>) [160,460 80x80]
SVGGeometryPaintable (SVGGeometryBox<rect>) [60,560 80x80]
SVGGeometryPaintable (SVGGeometryBox<rect>) [160,560 80x80]
SVGPathPaintable (SVGGeometryBox<rect>) [60,460 80x80]
SVGPathPaintable (SVGGeometryBox<rect>) [160,460 80x80]
SVGPathPaintable (SVGGeometryBox<rect>) [60,560 80x80]
SVGPathPaintable (SVGGeometryBox<rect>) [160,560 80x80]

View file

@ -13,4 +13,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x800]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x800]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x784]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 784x784]
SVGGeometryPaintable (SVGGeometryBox<circle>) [47.1875,47.1875 548.796875x548.796875]
SVGPathPaintable (SVGGeometryBox<circle>) [47.1875,47.1875 548.796875x548.796875]

View file

@ -10,4 +10,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x800]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x800]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x784]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 784x784]
SVGGeometryPaintable (SVGGeometryBox<rect>) [8,8 784x784]
SVGPathPaintable (SVGGeometryBox<rect>) [8,8 784x784]

View file

@ -19,5 +19,5 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x800]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x784]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 784x784]
SVGGraphicsPaintable (SVGGraphicsBox<g>) [121.671875,121.671875 556.65625x556.65625]
SVGGeometryPaintable (SVGGeometryBox<circle>) [121.671875,121.671875 399.84375x399.84375]
SVGGeometryPaintable (SVGGeometryBox<circle>) [278.484375,278.484375 399.84375x399.84375]
SVGPathPaintable (SVGGeometryBox<circle>) [121.671875,121.671875 399.84375x399.84375]
SVGPathPaintable (SVGGeometryBox<circle>) [278.484375,278.484375 399.84375x399.84375]

View file

@ -15,4 +15,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 24x24]
SVGGraphicsPaintable (SVGGraphicsBox<g>) [8,8 24x24]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 24x24]
SVGGeometryPaintable (SVGGeometryBox<rect>) [8,8 24x24]
SVGPathPaintable (SVGGeometryBox<rect>) [8,8 24x24]

View file

@ -10,6 +10,6 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x170]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x154]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 102x52]
SVGGeometryPaintable (SVGGeometryBox<rect>) [21.5,21.5 75x25]
SVGPathPaintable (SVGGeometryBox<rect>) [21.5,21.5 75x25]
SVGSVGPaintable (SVGSVGBox<svg>) [8,60 202x102]
SVGGeometryPaintable (SVGGeometryBox<rect>) [34,86 150x50]
SVGPathPaintable (SVGGeometryBox<rect>) [34,86 150x50]

View file

@ -10,4 +10,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x116]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x100]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 100x100]
SVGGeometryPaintable (SVGGeometryBox<path>) [8,10 100x48]
SVGPathPaintable (SVGGeometryBox<path>) [8,10 100x48]

View file

@ -10,4 +10,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x116]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x100]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 100x100]
SVGGeometryPaintable (SVGGeometryBox<path>) [28,28 60x60]
SVGPathPaintable (SVGGeometryBox<path>) [28,28 60x60]

View file

@ -27,4 +27,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 300x150]
PaintableBox (Box<use>) [8,8 0x0]
PaintableBox (Box<symbol>#braces) [8,8 0x0]
SVGGeometryPaintable (SVGGeometryBox<path>) [92.375,26.75 131.25x112.15625]
SVGPathPaintable (SVGGeometryBox<path>) [92.375,26.75 131.25x112.15625]

View file

@ -10,4 +10,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x118]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x102]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 102x102]
SVGGeometryPaintable (SVGGeometryBox<rect>) [29,29 60x60]
SVGPathPaintable (SVGGeometryBox<rect>) [29,29 60x60]

View file

@ -8,4 +8,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x800]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x800]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x784]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 784x784]
SVGGeometryPaintable (SVGGeometryBox<rect>) [8,8 784x784]
SVGPathPaintable (SVGGeometryBox<rect>) [8,8 784x784]

View file

@ -26,4 +26,4 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
ImagePaintable (ImageBox<IMG>) [8,21 0x0]
TextPaintable (TextNode<#text>)
SVGSVGPaintable (SVGSVGBox<svg>) [16,21 0x0]
SVGGeometryPaintable (SVGGeometryBox<rect>) [16,21 1x1]
SVGPathPaintable (SVGGeometryBox<rect>) [16,21 1x1]

View file

@ -4,11 +4,11 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
line 0 width: 300, height: 150, bottom: 150, baseline: 150
frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 300x150]
SVGSVGBox <svg> at (8,8) content-size 300x150 [SVG] children: not-inline
SVGTextBox <text> at (8,-8) content-size 0x16 children: not-inline
SVGTextBox <text> at (8,8) content-size 0x0 children: not-inline
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x150]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 300x150] overflow: [8,-8 300x166]
SVGTextPaintable (SVGTextBox<text>) [8,-8 0x16]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 300x150]
SVGPathPaintable (SVGTextBox<text>) [8,8 0x0]