Skip to content

Fix percentage based stroke-width in SVG shapes upon viewbox change #51652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Mar 27, 2025

When svg elements are rendered with relative (percentage based)
stroke-width, it isn't being recalculated on viewbox change.
This poses an issue when the size of the viewbox changes such that
the size of new viewbox differs from the original viewbox. In this
scenario, the paint isn't invalidated and thus stroke is scaled
wrongly and not adjusting well with the viewport.

We have implemented a bool ComputeHasRelativeLengths() and used it
in the LayoutSVGShape such that it uses the stroke-width data to
determine if the current SVG element Layout has relative values and
uses the same to trigger paint recalculation upon viewbox update.

Bug: 384605094
Change-Id: I095c3d927af99e2b9ff1bf4acf086b61ed6d980a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6388735
Reviewed-by: Fredrik Söderquist <[email protected]>
Reviewed-by: Ian Kilpatrick <[email protected]>
Commit-Queue: Vinay Singh <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1443290}

When svg elements are rendered with relative (percentage based)
stroke-width, it isn't being recalculated on viewbox change.
This poses an issue when the size of the viewbox changes such that
the size of new viewbox differs from the original viewbox. In this
scenario, the paint isn't invalidated and thus stroke is scaled
wrongly and not adjusting well with the viewport.

We have implemented a `bool ComputeHasRelativeLengths()` and used it
in the LayoutSVGShape such that it uses the stroke-width data to
determine if the current SVG element Layout has relative values and
uses the same to trigger paint recalculation upon viewbox update.

Bug: 384605094
Change-Id: I095c3d927af99e2b9ff1bf4acf086b61ed6d980a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6388735
Reviewed-by: Fredrik Söderquist <[email protected]>
Reviewed-by: Ian Kilpatrick <[email protected]>
Commit-Queue: Vinay Singh <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1443290}
Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot merged commit 1faf591 into master Apr 7, 2025
15 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-6388735 branch April 7, 2025 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants