Re-resolve viewport-dependent lengths for viewBox-less SVG against the used size - #642
Open
nicoburns wants to merge 1 commit into
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
staging-devin-ai-integration
Bot
force-pushed
the
devin/1786151607-block-replaced-sizing
branch
from
August 8, 2026 02:34
8cfe721 to
cc929f6
Compare
staging-devin-ai-integration
Bot
force-pushed
the
devin/1786155474-svg-viewport-reresolution
branch
from
August 8, 2026 02:34
da8d27c to
48f2111
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #634. An SVG with a
viewBoxscales to its CSS box (object-fit contain, unchanged). An SVG without one cannot be scaled: its percentage lengths must instead re-resolve against the element's used size.SvgImageDatanow retains the SVG source, andtree_for_viewport(w, h)re-parses it with the rootwidth/heightattributes replaced by the used content-box size (cached per size; usvg has no API to override the root viewport after parsing, henceset_root_svg_size_attrsrewriting the root tag):The viewport is re-resolved in unzoomed CSS px so the existing object-fit transform applies zoom/HiDPI scaling to 1:1 content (keeps
css/css-viewport/zoom/svg-path.htmlpassing). Fixes e.g.css/CSS2/normal-flow/block-replaced-height-006.xhtandcss/css-transforms/{scale,rotate,skewX,skewY}/svg-*, where viewBox-less SVG content was previously object-fit scaled against usvg's fallback size.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/51256d0b440341bd874c6dc59e138478
Requested by: @nicoburns
WPT results
79 newly passing, 5 newly failing (net +74).
Full diff (84 changed tests)
Generated by the WPT workflow.