Repository navigation
Conversation
A gradient now inherits stops, gradientUnits and gradientTransform from the gradients it references, of either kind, following the whole href chain with a cycle guard; geometry is inherited only from gradients of the same kind (SVG 1.1 §13.2.2, §13.2.3). Previously only stops were taken, only from the same kind, and they replaced the element's own.
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.
Gradients that reference another gradient through
xlink:hreflose most of what they should inherit. Per SVG 1.1 §13.2.2 and §13.2.3, a gradient inherits from the gradient it references, which may be of either kind:gradientUnitsandgradientTransform;x1…y2,cx…fr).makeGradient(for:)currently has three problems:radialGradientlooks up its href only amongradialGradients. A radial gradient that takes its stops from alinearGradient(common in Inkscape output) gets no stops, so the fill is dropped.x1…y2andxlink:hreffalls back toobjectBoundingBoxand loses the referenced units, geometry and transform.This change follows the whole href chain, across both kinds and with a cycle guard. Each attribute comes from the first gradient in the chain that specifies it. The DOM and the public API are unchanged.
Tests
LayerTree.Builder.GradientTests.swiftadds six tests:All 246 tests pass. Before the change, five of the new tests fail.
Real-world check
I rendered 41 TV-channel SVG logos and compared each with a resvg rendering of the same file. Three logos changed and none got worse:
gradientUnits)#142 covers gradient href chains as part of a much larger change. This PR is the focused subset, in case that is easier to review.