[vector_graphics_compiler] support percentage units SVG shape attributes#10577
[vector_graphics_compiler] support percentage units SVG shape attributes#10577auto-submit[bot] merged 13 commits intoflutter:mainfrom
Conversation
Signed-off-by: Steven Landow <steven@landow.dev>
There was a problem hiding this comment.
Code Review
This pull request adds support for percentage units in SVG shape attributes like rect, circle, ellipse, and line, which is a valuable feature. The changes correctly resolve percentage values against the viewport dimensions, and the circle radius calculation correctly uses the normalized diagonal as per the SVG specification. The addition of new tests to verify this functionality is also great. I've found a minor issue with a misleading comment in the new percentage parsing logic and have suggested a correction to improve clarity. Overall, the changes are well-implemented.
jtmcdole
left a comment
There was a problem hiding this comment.
Added a question. Sorry for the delay.
| parserState.attribute('cy', def: '0'), | ||
| percentageRef: vh, | ||
| )!; | ||
| // For radius percentage, use the normalized diagonal per SVG spec. |
There was a problem hiding this comment.
can you link to the spec section?
|
|
||
| // Handle percentage values first. | ||
| // Check inline to avoid circular import with parsers.dart. | ||
| final bool isPercent = rawDouble?.endsWith('%') ?? false; |
There was a problem hiding this comment.
Is the provided rawDouble guaranteed to be trimmed? It seems like it would be safer to trim before doing this check.
| final bool isPercent = rawDouble?.endsWith('%') ?? false; | ||
| if (isPercent) { | ||
| if (percentageRef == null || percentageRef.isInfinite) { | ||
| // If no reference dimension is available, treat as 0. |
There was a problem hiding this comment.
This says "treat as 0", but it returns null, not 0, so it's not clear to me what this comment means.
There was a problem hiding this comment.
I ended up changing it and forgot to update the comment.
| @@ -2,6 +2,10 @@ | |||
There was a problem hiding this comment.
See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#updating-a-changelog-that-has-a-next for why CI is failing the changelog check.
There was a problem hiding this comment.
I should probably revert the pubspec version change, right?
There was a problem hiding this comment.
Which of the version change exemptions do you believe this change falls under?
There was a problem hiding this comment.
nvm misread your guide
|
I think this is good to go now |
|
@jtmcdole FYI this is still waiting on an engine team approval to land. |
|
Should this technically have been a minor bump in symver?
|
|
Yeah, probably. There's a lot of grey area in minor vs bugfix when the API itself doesn't change, but this does make more sense as a minor version. I'll adjust it. |
flutter/packages@59f905c...9da22bf 2026-02-19 mit@google.com [cupertino_ui, material_ui] Fix capitalization in README section headers (flutter/packages#11058) 2026-02-18 engine-flutter-autoroll@skia.org Manual roll Flutter from 6e4a481 to c023e5b (17 revisions) (flutter/packages#11060) 2026-02-18 steven@landow.dev [vector_graphics_compiler] support percentage units SVG shape attributes (flutter/packages#10577) 2026-02-18 stuartmorgan@google.com [local_auth] Convert example app to Swift (flutter/packages#11003) 2026-02-18 stuartmorgan@google.com [ci] Fix syntax error in auto-labeler (flutter/packages#11052) 2026-02-18 github-admin@google.com Refactor Github Action per b/485167538 (flutter/packages#11051) 2026-02-18 katelovett@google.com [material_ui] Add material_ui package (flutter/packages#11043) 2026-02-18 katelovett@google.com [cupertino_ui] Add cupertino_ui package (flutter/packages#11042) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Adds percentage unit support for SVG shape attributes
SVG shapes like
<rect>,<circle>,<ellipse>, and<line>can have percentage values for their position and size attributes (e.g., width="50%", cx="50%"). Previouslythese weren't handled correctly. Easy to test with any image like https://placeholdit.com/600x400/dddddd/999999
This adds:
List which issues are fixed by this PR. You must list at least one issue.
I'm not sure if it fixes these issues, as they have no description. I can file a new issue if needed.
flutter/flutter#158844
flutter/flutter#158845
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3