Support context paint in SVG use elements#2745
Draft
moreaki wants to merge 2 commits into
Draft
Conversation
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.
Stacked on #2744.
Context
#2744 adds marker-scoped support for the SVG 2
context-fillandcontext-strokepaint values, fixing the concrete marker case from #2667. The SVG 2 paint definition also says that an element inside a subtree instantiated by auseelement has thatuseelement as its context element.This draft PR adds that second small context-paint case on top of #2744, so maintainers can decide whether they want to include it as a follow-up feature.
Changes
useelement.useelement as the context element while its referenced subtree is drawn.context-fillandcontext-strokeare resolved independently for multipleuseinstances with different solid paint values.Scope and limitations
This intentionally supports the simple solid-color case. It does not try to solve the harder paint-server geometry case for contextual
url(#gradient)orurl(#pattern)values. For those, SVG 2 requires the paint server coordinate space and bounding box to come from the context element, which needs additional gradient/pattern plumbing beyond this small follow-up.Until #2744 lands, this PR’s diff includes the marker context-paint groundwork from #2744 plus one additional commit for
useelements.Tests
venv/bin/python -m pytest tests/draw/svg/test_defs.py::test_use_context_paint tests/draw/svg/test_defs.py::test_use_symbol_color tests/draw/svg/test_markers.py::test_markers_context_paintvenv/bin/python -m pytest tests/draw/svgvenv/bin/python -m ruff check weasyprint/svg/__init__.py tests/draw/svg/test_defs.py tests/draw/svg/test_markers.py