Closed Bug 1524901 Opened 5 years ago Closed 5 years ago

SVG aspect ratio not preserved when used as background-image, but is in Chrome.

Categories

(Core :: SVG, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox67 --- wontfix
firefox68 --- fixed

People

(Reporter: twisniewski, Assigned: violet.bugreport)

References

Details

(Whiteboard: [webcompat])

Attachments

(5 files)

Attached image swift.svg

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

Flags: webcompat?
Attached file test.html

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.

Priority: -- → P3
Attached file testcase 2
Assignee: nobody → violet.bugreport
Status: NEW → ASSIGNED

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
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Regressions: 1567987
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: