Closed Bug 1523343 Opened 5 years ago Closed 5 years ago

SVG: Null/any transform causes translation in X axis

Categories

(Core :: SVG, defect, P3)

64 Branch
x86_64
Windows 7
defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox-esr60 --- wontfix
firefox65 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- fixed

People

(Reporter: paul.lebeau, Assigned: violet.bugreport)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Try the following SVG: https://jsfiddle.net/5fc9bz1u/

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<rect x="0" y="0" width="2.5" height="10"/>
<rect x="2.86" y="0" width="2.5" height="10"/>
<rect x="5.71" y="0" width="2.5" height="10"/>
<rect x="8.57" y="0" width="2.5" height="10"/>
<rect x="11.43" y="0" width="2.5" height="10"/>
</svg>

rect {
transform: scaleY(1);
}

The CSS transform scaleY seems to cause the rectangles to move (translate) in the X direction. Compare with non-transformed version: https://jsfiddle.net/5fc9bz1u/1/

In fact any transform at all seems to cause this movement. Eg. even translate(0,0)
https://jsfiddle.net/5fc9bz1u/2/

Interestingly, the issue disappears if the rectangles have X coordinates that are whole numbers. See: https://jsfiddle.net/5fc9bz1u/3/

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<rect x="0" y="0" width="2.5" height="10"/>
<rect x="3" y="0" width="2.5" height="10"/>
<rect x="6" y="0" width="2.5" height="10"/>
<rect x="9" y="0" width="2.5" height="10"/>
<rect x="12" y="0" width="2.5" height="10"/>
</svg>

Original Stack Overflow question reporting this issue: https://stackoverflow.com/questions/54406088/svg-rectangles-pushed-together-in-firefox-but-not-chrome-safari

Summary: SVG: Null/any transform translation in X axis → SVG: Null/any transform causes translation in X axis
Component: General → SVG
Product: Firefox → Core

After a little more investigation, it appears as if the x coordinate is getting rounded before the transformation is applied.

If I round the original x coordinates and remove the transform, I get the same result as the original example.

https://jsfiddle.net/5fc9bz1u/5/

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<rect x="0" y="0" width="2.5" height="10"/>
<rect x="3" y="0" width="2.5" height="10"/>
<rect x="6" y="0" width="2.5" height="10"/>
<rect x="9" y="0" width="2.5" height="10"/>
<rect x="11" y="0" width="2.5" height="10"/>
</svg>

rect {
}

Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Has Regression Range: --- → yes

Jonathan, I'm tracking 67 regression bugs and this showed up. Since this is marked as regressing from your bug, I'm wondering if you have looked into this.

Flags: needinfo?(jwatt)

The bug that regressed this landed two years ago. Given that, I don't think there's much reason to treat this differently to any other bug. Either way, I probably won't get to this any time soon.

Flags: needinfo?(jwatt)
Assignee: nobody → violet.bugreport
Status: NEW → ASSIGNED

When computing transform matrix, translation in SVG should not be rounded.
Checking !IsSVGTransformed() isn't the correct way, since an SVG frame may
have CSS transform applied.

Pushed by violet.bugreport@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/5830f058ab4e
Should not round translation for SVG frame r=longsonr
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
No longer blocks: 828240
Flags: in-testsuite+
Regressed by: 828240
Regressions: 1636119
Regressions: 1625422
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: