Inherit dominant-baseline into nested <tspan> elements#1070
Open
StefanoD wants to merge 1 commit into
Open
Conversation
`dominant-baseline` was listed in `is_non_inheritable`, so usvg only let a `<tspan>` pick up the value from its *direct* parent element. For a nested `<tspan>` whose immediate parent does not carry the property, the value of an ancestor `<text>` was therefore lost and the span fell back to `auto` (alphabetic baseline). The nested run then sat on a different baseline than its siblings — the "weird" positioning reported in linebender#864. `dominant-baseline` is actually an *inherited* property, unlike its siblings `alignment-baseline` and `baseline-shift`: - SVG 2 / CSS Inline Layout Module Level 3 define it with "Inherited: yes". https://www.w3.org/TR/SVG2/text.html#BaselineAlignmentProperties - Chromium marks it `inherited: true` (field group `svginherited`), while `alignment-baseline` and `baseline-shift` are not inherited: https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/core/css/css_properties.json5 (`name: "dominant-baseline" ... inherited: true`) - Inkscape declares it as an inheriting `SPIEnum` (default `inherits = true`). Removing it from `is_non_inheritable` makes `find_attribute`/`resolve_inherit` walk the full ancestor chain, matching Chrome's rendering (verified by comparison) and the spec. Fixes linebender#864. Tests: - usvg: `nested_tspan_inherits_dominant_baseline` and the override variant assert the resolved baseline on the spans; they fail before the fix (`Auto` vs `TextAfterEdge`). - resvg: render test `text/dominant-baseline/inherited-through-nested-tspan` (reference PNG optimized with oxipng). All existing baseline tests are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
dominant-baselinewas listed inis_non_inheritable, so usvg only let a<tspan>pick up the value from its direct parent element. For a nested<tspan>whose immediate parent does not carry the property, the value of an ancestor<text>was therefore lost and the span fell back toauto(alphabetic baseline). The nested run then sat on a different baseline than its siblings — the "weird" positioning reported in #864.dominant-baselineis actually an inherited property, unlike its siblingsalignment-baselineandbaseline-shift:inherited: true(field groupsvginherited), whilealignment-baselineandbaseline-shiftare not inherited: https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/core/css/css_properties.json5 (name: "dominant-baseline" ... inherited: true)SPIEnum(defaultinherits = true).Removing it from
is_non_inheritablemakesfind_attribute/resolve_inheritwalk the full ancestor chain, matching Chrome's rendering (verified by comparison) and the spec.Fixes #864.
Generated with Claude