SVG aspect ratio not preserved when used as background-image, but is in Chrome.
Categories
(Core :: SVG, defect, P3)
Tracking
()
People
(Reporter: twisniewski, Assigned: violet.bugreport)
References
Details
(Whiteboard: [webcompat])
Attachments
(5 files)
In the attached test-case, Gecko stretches the SVG background-image to the specified background-size in the CSS, while Blink seems to preserve the aspect ratio of the image (as though using the default xMidYMid value for preserveAspectRatio on the SVG).
This is causing cosmetic interop issues on the swift.org site, as per https://webcompat.com/issues/24815
Reporter | ||
Comment 1•5 years ago
|
||
Comment 2•5 years ago
|
||
Edge agrees with Chrome as well, and I haven't tested Safari but I'll bet they also agree.
BTW, this only seems to happen for SVG images that have an explicit 'width' and 'height'. If the image just has a viewBox but no width or height, then we match Chrome on this and scale in an aspect-ratio-preserving way.
We also get this right (i.e. we don't stretch the image) for a testcase with <img style="height...width...">
with height/width values that are similar to the background-size
values in the current testcase.
So, only the background-size
drawing path seems to be broken here.
Comment 3•5 years ago
|
||
Comment 4•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 6•5 years ago
|
||
When an SVG is used as a CSS background-image, we previously used the same behavior as
a normal image. It will stretch if the background-size is incompatible with the intrinsic
size of the SVG. This is a webcompat issue.
Now we use the painting destination rect size instead to avoid stretching.
Pushed by violet.bugreport@gmail.com: https://hg.mozilla.org/integration/autoland/rev/449e2049eeef Should not set SVG viewport to intrinsic size when painting background image r=longsonr
Comment 9•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Description
•