fix(usvg): use the viewport as the bbox of a sliced <image>#1059
Open
StefanoD wants to merge 1 commit into
Open
fix(usvg): use the viewport as the bbox of a sliced <image>#1059StefanoD wants to merge 1 commit into
StefanoD wants to merge 1 commit into
Conversation
An `<image>` with `preserveAspectRatio="… slice"` is scaled to *cover* its viewport and the overflow is cut away by a rectangular clip. Its bounding box is therefore the image's `x/y/width/height` rect (the viewport), but usvg derived it from the children, i.e. the oversized scaled-to-cover image. As a result, an `objectBoundingBox` clip-path (or mask/filter) applied to a sliced image was resolved against the wrong, much larger box. With a non-square viewport this scaled the clip shape anisotropically and made it collapse — e.g. a decorative arched window clipped to a tall image rendered as a flat top instead of the intended curve, differing from Chrome/Firefox. Set the slice wrapper group's bounding box to the image rect so downstream bbox-relative units are resolved correctly. Adds a regression test asserting the clip transform is built from the viewport rect and not the scaled image. Closes linebender#1034 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
|
I would have to investigate this one first. |
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.
An
<image>withpreserveAspectRatio="… slice"is scaled to cover its viewport and the overflow is cut away by a rectangular clip. Its bounding box is therefore the image'sx/y/width/heightrect (the viewport), but usvg derived it from the children, i.e. the oversized scaled-to-cover image.As a result, an
objectBoundingBoxclip-path (or mask/filter) applied to a sliced image was resolved against the wrong, much larger box. With a non-square viewport this scaled the clip shape anisotropically and made it collapse — e.g. a decorative arched window clipped to a tall image rendered as a flat top instead of the intended curve, differing from Chrome/Firefox.Set the slice wrapper group's bounding box to the image rect so downstream bbox-relative units are resolved correctly.
Adds a regression test asserting the clip transform is built from the viewport rect and not the scaled image.
Closes #1034
Generated by Claude