servo/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents
Mukilan Thiyagarajan 8a20e42de4
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:
![servo - resvg
img](https://github.com/user-attachments/assets/8ecb2de2-ab7c-48e2-9f08-2d09d2cb8791)

<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>
2025-05-27 11:02:40 +00:00
..
initial-empty-document Sync WPT with upstream (11-05-2025) (#36954) 2025-05-11 01:41:53 +00:00
javascript-url-abort Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
multiple-globals
refresh Add support for static SVG images using resvg crate (#36721) 2025-05-27 11:02:40 +00:00
replace-before-load Sync WPT with upstream (18-05-2025) (#37040) 2025-05-18 01:43:27 +00:00
source Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
003.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
004.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
005.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
006.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
007.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
008.html.ini Sync WPT with upstream (04-05-2025) (#36829) 2025-05-04 01:43:02 +00:00
010.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
012.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
abort-document-load.html.ini
about-srcdoc-navigation-blocked.window.js.ini Update web-platform-tests to revision b'a10b8c0164b4c4521040898ee9394738aca488b0' (#31144) 2024-01-21 06:53:06 +00:00
child-navigates-parent-cross-origin.window.js.ini
cross-origin-top-navigation-with-user-activation-in-parent.window.js.ini
cross-origin-top-navigation-without-user-activation.window.js.ini
failure-check-sequence.https.html.ini
grandparent_location_aboutsrcdoc.sub.window.js.ini Update web-platform-tests to revision b'd988aeeb33edc4d452899921799b8bed69fff65d' (#33178) 2024-08-25 01:37:49 +00:00
grandparent_session_aboutsrcdoc.sub.window.js.ini Update web-platform-tests to revision b'd988aeeb33edc4d452899921799b8bed69fff65d' (#33178) 2024-08-25 01:37:49 +00:00
javascript-url-load-as-html.xhtml.ini Sync WPT with upstream (04-10-2023) (#30493) 2023-10-06 00:51:48 +00:00
javascript-url-no-beforeunload.window.js.ini
javascript-url-referrer.window.js.ini Update web-platform-tests to revision b'86de4ffa4e439098e05f05de7d8cae1c24ff84fb' (#32200) 2024-05-01 15:47:11 +00:00
javascript-url-return-value-handling-dynamic.html.ini Sync WPT with upstream (07-01-2024) (#31018) 2024-01-08 05:36:08 +00:00
javascript-url-security-check-failure.sub.html.ini
javascript-url-security-check-same-origin-domain.sub.html.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00
javascript-url-task-queuing.html.ini
navigate-to-unparseable-url.html.ini Sync WPT with upstream (04-02-2024) (#31256) 2024-02-05 06:17:23 +00:00
navigation-unload-cross-origin.sub.window.js.ini Sync WPT with upstream (13-04-2025) (#36488) 2025-04-13 02:52:15 +00:00
navigation-unload-same-origin.window.js.ini Sync WPT with upstream (04-05-2025) (#36829) 2025-05-04 01:43:02 +00:00
plugin-document.historical.html.ini
redirect-to-about.window.js.ini
redirect-to-data.html.ini
redirect-to-unparseable-url.html.ini
top-level-data-url.window.js.ini Run same tests for layout-2020 and layout-2013 (#30092) 2023-08-15 00:28:32 +00:00