[webkit-dev] Support for SVG preserveAspectRatio in <img>
Leif Arne Storset
lstorset at opera.com
Wed Feb 3 05:12:09 PST 2010
Eric Seidel <eric at webkit.org> skreiv Tue, 02 Feb 2010 21:04:33 +0100
> Definitely a bug.
> Some of these are on file, some are not:
Thanks, Eric and Dean, for your feedback. I have reported bug 34521 .
Hopefully I will be able to host the test case soon. Best of luck on
implementation! Feel free to ask me if you have questions or concerns.
> On Tue, Feb 2, 2010 at 8:17 AM, Leif Arne Storset <lstorset at opera.com>
>> While doing some SVG-related work over here I discovered that WebKit's
>> rendering of SVG in <img> tags differs from Opera's. Since WebKit and
>> Opera to my knowledge are the only engines that currently support SVG in
>> <img> we thought it would be worthwhile to make sure we are compatible.
>> As far as I can tell from the latest nightly builds (and the latest
>> release on Linux), WebKit will render an SVG in <img> much like a
>> 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
>> if it is missing), but preserveAspectRatio  seems not to be applied
>> an SVG in <img>, and the default rendering (whether there is a viewbox
>> 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 , and applies preserveAspectRatio as specified
>> SVG 1.1 (note that pAR has a default value 'xMidYMid meet'). The viewBox
>> (whether specified or synthetic) are used together with pAR when
>> the SVG into the viewport established by the <img> element.
>> The attached images and test case illustrate the two renderings.
>> A quick Google search of webkit.org revealed little on
>> except a reference to a 2008 bug in SVGImageElement. However, for
>> <svg:image> (that is: <image> elements inside of an <svg>), pAR seems to
>> be applied as per the spec.
>> 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 , 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
>> I hope you find these recommendations useful. Please let me know if I
>> be of further assistance. If desired I can file a bug in your issue
>> Leif Arne Storset
>> Layout developer, Opera Software
>>  http://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute
>>  http://www.w3.org/Graphics/SVG/WG/track/issues/2258
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
More information about the webkit-dev