Created attachment 48014 [details] Test case (First mentioned on webkit-dev [3]) As far as I can tell from the latest nightly builds (and the latest Chrome release on Linux), WebKit will render an SVG in <img> much like a bitmap: it will resolve the width and height of the image and stretch it to fill the content box. It will respect any viewbox (presumably synthesizing one if it is missing), but preserveAspectRatio [1] seems not to be applied to an SVG in <img>, and the default rendering (whether there is a viewbox or not) is as if preserveAspectRatio="none". Opera (Presto engine) will also resolve image dimensions and synthesize missing viewboxes, and will synthesize a viewBox if it can, as outlined in SVG WG ISSUE-2258 [2], and applies preserveAspectRatio as specified in SVG 1.1 (note that pAR has a default value 'xMidYMid meet'). The viewBox (whether specified or synthetic) are used together with pAR when rendering the SVG into the viewport established by the <img> element. The attached images and test case illustrate the two renderings. We believe that not applying the pAR on svg in <img> means that WebKit has invalid rendering behaviour according to the SVG 1.1 specification. To enhance cross-browser compatibility it would be good if WebKit also considered synthesizing viewBoxes as outlined in [2], as this makes it easier to reuse existing svg content created by svg editors such as Inkscape (such content most often has a width and height, but lacks a viewBox). [1] http://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute [2] http://www.w3.org/Graphics/SVG/WG/track/issues/2258 [3] https://lists.webkit.org/pipermail/webkit-dev/2010-February/011514.html
Created attachment 48015 [details] Images for test case
Created attachment 48016 [details] Chrome rendering
Created attachment 48017 [details] Opera rendering
I'm working on this, now that <object>/<embed>/<iframe> intrinsic sizing has been properly implemented.
I can reproduce Operas rendering now, finally :-) Also works with zooming, etc - as expected. I still need to fix some related bugs (16167) before I'll upload the patch.
47156 fixes this.
Here is a hosted test case: http://phrogz.net/SVG/svg-via-img.html The two <img> tag in this file are fixed size (one using width/height attributes, the other using width/height style) and reference this SVG file: http://phrogz.net/SVG/heart.svg which has 100% height and width. In Safari and Chrome, resizing the browser window causes the aspect ratio of the SVG displayed in the SVG tags to change. In Firefox the images appear unchanging, as intended.
Thanks for the additional testcases. Unfortunately the fix did not land yet, I'll update the bug once it happens.
Fixed in r98852. Thanks for the testcase! This one http://phrogz.net/SVG/svg-via-img.html is fixed as well.
Nice! Thanks for contributing to compat and compliance.