Wrong non-scaling-stroke rendering in a nested svg
Categories
(Core :: SVG, defect)
Tracking
()
People
(Reporter: rayhan.azizi9, Assigned: longsonr)
References
Details
Attachments
(5 files, 1 external file, 1 obsolete file)
Steps to reproduce:
Render this SVG
<svg id="svg3" width="300" height="200" style="overflow: visible">
<svg
width="100%" height="100%" style="overflow: visible" preserveAspectRatio="xMidYMid meet"
viewBox="-1.6111111640930176 -1.1111111640930176 3.222222328186035 2.222222328186035"
>
<svg overflow="visible" x="0" y="0">
<polygon
style=" fill: rgb(199, 199, 199); stroke: black; stroke-width: 1px;
stroke-linejoin: round; vector-effect: non-scaling-stroke;"
points="-1.5,1 1.5,1 1.5,-1 -1.5,-1"
></polygon>
</svg>
</svg>
</svg>
or the full HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<svg id="svg3" width="300" height="200" style="overflow: visible">
<svg
width="100%" height="100%" style="overflow: visible" preserveAspectRatio="xMidYMid meet"
viewBox="-1.6111111640930176 -1.1111111640930176 3.222222328186035 2.222222328186035"
>
<svg overflow="visible" x="0" y="0">
<polygon
style=" fill: rgb(199, 199, 199); stroke: black; stroke-width: 1px;
stroke-linejoin: round; vector-effect: non-scaling-stroke;"
points="-1.5,1 1.5,1 1.5,-1 -1.5,-1"
></polygon>
</svg>
</svg>
</svg>
</body>
</html>
Actual results:
Starting from version 127 forward, the calculation of polygon stroke with vector-effect: non-scaling-stroke inside the nested SVG is incorrect. The scale is wrong.
I believe because the viewBox attribute is not properly inherited to the inner svg
attached (bug.png)
Expected results:
The scale should be correct. The calculation for the width of the border should follow the viewBox attribute in the parent's parent <svg> element
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Graphics: WebRender' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
| Assignee | ||
Comment 2•2 years ago
|
||
| Assignee | ||
Comment 3•2 years ago
|
||
Please explain with reference to the SVG specification why you think Firefox is incorrect.
Per https://www.w3.org/TR/SVG2/painting.html#non-scaling-stroke
The stroke outline is calculated in the following manner: first, the shape's path is transformed into the host coordinate space. Stroke outline is calculated in the host coordinate space. The resulting outline is transformed back to the user coordinate system.
Note that an <svg> element establishes a new viewport per https://www.w3.org/TR/SVG2/coords.html#EstablishingANewSVGViewport
Updated•2 years ago
|
Comment 4•2 years ago
|
||
Seems like the report here is at the level of svg, not graphics, even if this is not a valid bug that would be a better place. Please revert if I'm mistaken.
| Reporter | ||
Comment 5•2 years ago
|
||
Top
- Eye of GNOME 45.3
- Brave Browser Version 1.67.119 Chromium: 126.0.6478.114 (Official Build) (64-bit)
- Mozilla firefox-127.0.r20240606181944
Bottom
4. GIMP 2.10.38
5. Inkscape 1.2.2 (b0a8486541, 2022-12-01)
6. Canva (as of June 21st 2024)
| Reporter | ||
Comment 6•2 years ago
|
||
| Reporter | ||
Comment 7•2 years ago
|
||
I'm not sure if this is an actual bug or not, I can't say that I understand the SVG specification. I just noticed that other software renders it differently
I've attached a screenshot, comparing how other software renders the same SVG file (comparison.png)
- Eye of GNOME 45.3
- Brave Browser Version 1.67.119 Chromium: 126.0.6478.114 (Official Build) (64-bit)
- Mozilla firefox-127.0.r20240606181944
- GIMP 2.10.38
- Inkscape 1.2.2 (b0a8486541, 2022-12-01)
- Canva (as of June 21st 2024)
It might be the case that Firefox is the one that actually correctly follows the specs while the other software doesn't handle this case yet
| Comment hidden (obsolete) |
Comment 9•2 years ago
|
||
Should someone file bugs on other browsers and/or land a wpt test?
| Assignee | ||
Comment 10•2 years ago
|
||
I guess so, yes.
| Assignee | ||
Comment 12•2 years ago
|
||
| Comment hidden (obsolete) |
| Comment hidden (obsolete) |
Updated•2 years ago
|
| Comment hidden (obsolete) |
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
| Comment hidden (obsolete) |
| Assignee | ||
Comment 17•2 years ago
|
||
It seems that https://github.com/w3c/svgwg/issues/582 supersedes the spec here and so we'll need to revert the viewport/screen support in favour of that interpretation.
| Assignee | ||
Comment 18•2 years ago
|
||
This implements https://github.com/w3c/svgwg/issues/582 and therefore mostly reverts bug 1904891
Updated•2 years ago
|
| Assignee | ||
Comment 19•2 years ago
|
||
Comment 20•2 years ago
|
||
Comment 22•2 years ago
|
||
| bugherder | ||
| Assignee | ||
Comment 24•2 years ago
|
||
Comment on attachment 9412279 [details]
Bug 1903546 - fix non-scaling-stroke r=emilio
Beta/Release Uplift Approval Request
- User impact if declined: non-scaling-stroke will be incorrect for nested <svg> elements.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): This reverts most of the changes in bug 1904891 which is currently in beta. That bug implements part of the SVG specification that has been superseded and is not compatible with Chrome or Safari. This bug restores that compatibility.
- String changes made/needed: none
- Is Android affected?: Yes
Comment 25•2 years ago
|
||
Comment on attachment 9412279 [details]
Bug 1903546 - fix non-scaling-stroke r=emilio
Approved for 129.0b4
Comment 26•2 years ago
|
||
| uplift | ||
Updated•2 years ago
|
Updated•1 year ago
|
Description
•