Skip to content

<svg width> fails to scale contents to inferred height #41273

Closed

Description

@delan

Servo 0.0.3 renders this differently to Firefox:

data:text/html,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="300"><circle id="myCircle" cx="5" cy="5" r="4"/>

Servo Firefox
Image Image

it’s unclear to me whether the correct behaviour is specified anywhere.

Activity

  1. added
    C-untriaged
    on Dec 15, 2025
  2. delan commented on Dec 15, 2025

    @delan
    MemberAuthor

    this shows that Servo is inferring height as expected, but failing to scale the contents:

    data:text/html,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="300" style="border: 1px solid;"><circle id="myCircle" cx="5" cy="5" r="4"/>

    Image
  3. changed the title [-]<svg width> does not infer height from viewBox aspect ratio[/-] [+]<svg width> fails to scale contents to inferred height[/+] on Dec 15, 2025
  4. added
    A-content/images
    C-has-manual-testcase
    and removed
    C-untriaged
    on Dec 15, 2025
  5. simartin commented on Dec 20, 2025

    @simartin
    Contributor

    FWIW, it seems to be happening only if only one of height and width is specified; when both are, scaling seems to be happening

    This is with data:text/html,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="300" height="300" style="border: 1px solid;"><circle id="myCircle" cx="5" cy="5" r="4.8"/>

    Image
  6. added theissue type on Dec 24, 2025
  7. simartin commented on Mar 17, 2026

    @simartin
    Contributor

    @servo-highfive assign me

  8. added
    C-assigned
    on Mar 17, 2026
  9. servo-highfive commented on Mar 17, 2026

    @servo-highfive

    Hey @simartin! Thanks for your interest in working on this issue. It's now assigned to you!

  10. delan commented on Mar 18, 2026

    @delan
    MemberAuthor

    @Loirooriol was this fixed by #42577 (#42573)?

  11. delan commented on Mar 18, 2026

    @delan
    MemberAuthor

    ahh, i think they are actually unrelated, never mind. height vs width, and SVG contents vs replaced box.

  12. 5 remaining items

  13. simartin commented on May 5, 2026

    @simartin
    Contributor

    We give the SVG document to resvg that determines that the size is 10x300, and everything we see comes from this.

    This slide deck shows that not everybody agrees on what should happen in such cases.

    I am working on a patch to resvg implementing "the Firefox way", which makes sense to me, but I'm not super confident it will get approved especially if the standard does not give a definite answer on what to do in such cases.

    We will see where it gets... (I hope it gets approved because the alternative is for us to patch the SVG XML document before giving it to resvg, and I don't really want to do that ;-))

  14. simartin commented on May 5, 2026

    @simartin
    Contributor

    It looks pretty good with resvg patched locally (top is Servo, middle Firefox and bottom Chrome), so I'll go submit this patch 🤞

    Image
  15. simartin commented on May 5, 2026

    @simartin
    Contributor

    Funnily enough, my patch looks a lot like linebender/resvg#715, that seems to have disappeared since 🙃 Will figure out what happned and update here...

    EDIT: The code is still there, we just need it in some other place. Which increases the likelihood the patch is accepted.

  16. simartin commented on May 6, 2026

    @simartin
    Contributor

    This will be unfortunately blocked on a resvg upgrade, itself blocked on the minimum support rust version (see #43204 (comment))

  17. TimvdLippe commented on May 10, 2026

    @TimvdLippe
    Contributor

    Resvg has now been updated

  18. added a commit that references this issue on May 10, 2026
  19. simartin commented on Aug 1, 2026

    @simartin
    Contributor

    linebender/resvg#1045 has been merged today so this ticket will be fixed when the resvg folks do their next release and we integrate it.

  20. atouchet commented on Aug 3, 2026

    @atouchet
    Contributor
    Image

    I think this is fixed now with the resvg update in #46937.

  21. simartin commented on Aug 3, 2026

    @simartin
    Contributor

    Yes indeed, this is fixed now 🎉

    The ticket can be closed (I don't have the permissions to do it myself...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-content/imagesA-content/svgC-assignedC-has-manual-testcase

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions