mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
Add support for static SVG images using resvg
crate (#36721)
This change adds support for rendering static SVG images using the `resvg` crate, allowing svg sources in the `img` tag and in CSS `background` and `content` properties. There are some limitations in using resvg: 1. There is no support for animations or interactivity as these would require implementing the full DOM layer of SVG specification. 2. Only system fonts can be used for text rendering. There is some mechanism to provide a custom font resolver to usvg, but that is not explored in this change. 3. resvg's handling of certain edge cases involving lack of explicit `width` and `height` on the root svg element deviates from what the specification expects from browsers. For example, resvg uses the values in `viewBox` to derive the missing width or height dimension, but without scaling that dimension to preserve the aspect ratio. It also doesn't allow overriding this behavior. Demo screenshot:  <details> <summary>Source</summary> ``` <style> #svg1 { border: 1px solid red; } #svg2 { border: 1px solid red; width: 300px; } #svg3 { border: 1px solid red; width: 300px; height: 200px; object-fit: contain; } #svg4 { border: 1px solid red; width: 300px; height: 200px; object-fit: cover; } #svg5 { border: 1px solid red; width: 300px; height: 200px; object-fit: fill; } #svg6 { border: 1px solid red; width: 300px; height: 200px; object-fit: none; } </style> </head> <body> <div> <img id="svg1" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo"> </div> <div> <img id="svg2" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo"> <img id="svg3" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo"> <img id="svg4" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo"> </div> <div> <img id="svg5" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo"> <img id="svg6" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo"> </div> </body> ``` </details> --------- Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
324196351e
commit
8a20e42de4
267 changed files with 2374 additions and 544 deletions
|
@ -1,2 +0,0 @@
|
|||
[2d.layer.global-states.filter.ctx-filter.no-transform.tentative.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[2d.layer.global-states.filter.ctx-filter.rotation.tentative.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[2d.layer.global-states.filter.no-cxt-filter.no-transform.tentative.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[2d.layer.global-states.filter.no-cxt-filter.rotation.tentative.html]
|
||||
expected: FAIL
|
|
@ -1,5 +1,3 @@
|
|||
[drawimage_svg_image_with_foreign_object_does_not_taint.html]
|
||||
expected: TIMEOUT
|
||||
[Canvas should not be tainted after drawing SVG including <foreignObject>]
|
||||
expected: TIMEOUT
|
||||
|
||||
expected: FAIL
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
[canvas-createImageBitmap-resize.html]
|
||||
expected: TIMEOUT
|
||||
[createImageBitmap from an ImageData with resize option.]
|
||||
expected: NOTRUN
|
||||
expected: FAIL
|
||||
|
||||
[createImageBitmap from a HTMLImageElement with resize option.]
|
||||
expected: FAIL
|
||||
|
@ -10,10 +9,10 @@
|
|||
expected: FAIL
|
||||
|
||||
[createImageBitmap from an ImageBitmap with resize option.]
|
||||
expected: NOTRUN
|
||||
expected: FAIL
|
||||
|
||||
[createImageBitmap from a Blob with resize option.]
|
||||
expected: FAIL
|
||||
|
||||
[createImageBitmap from a HTMLImageElement of svg with no specified size with resize option.]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
[canvas-display-p3-drawImage.https.html]
|
||||
expected: TIMEOUT
|
||||
[sRGB-FF0000FF.png, Context srgb, ImageData display-p3, scaleImage=false]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -409,97 +408,97 @@
|
|||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context srgb, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context srgb, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context srgb, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context srgb, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context display-p3, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context display-p3, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context display-p3, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-FF0000.svg, Context display-p3, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context srgb, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context srgb, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context srgb, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context srgb, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context display-p3, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context display-p3, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context display-p3, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[sRGB-BB0000.svg, Context display-p3, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context srgb, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context srgb, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context srgb, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context srgb, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context display-p3, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context display-p3, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context display-p3, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-1-0-0.svg, Context display-p3, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context srgb, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context srgb, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context srgb, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context srgb, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context display-p3, ImageData srgb, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context display-p3, ImageData srgb, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context display-p3, ImageData display-p3, scaleImage=false]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
[Display-P3-0.7333-0-0.svg, Context display-p3, ImageData display-p3, scaleImage=true]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue