This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12540 - Reevaluate handling of invalid viewBox values
Summary: Reevaluate handling of invalid viewBox values
Status: NEW
Alias: None
Product: SVG
Classification: Unclassified
Component: Transformations (show other bugs)
Version: SVG 2.0
Hardware: All All
: P3 normal
Target Milestone: Working Draft
Assignee: Doug Schepers
QA Contact: SVG Public List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-22 17:04 UTC by Jonathan Watt
Modified: 2011-04-22 17:10 UTC (History)
0 users

See Also:


Attachments

Description Jonathan Watt 2011-04-22 17:04:13 UTC
About the viewBox attribute's 'width' and 'height' components, the spec says "A value of zero disables rendering of the element":

  http://www.w3.org/TR/SVG11/coords.html#ViewBoxAttribute
  http://www.w3.org/TR/SVGTiny12/coords.html#ViewBoxAttribute

However, Opera, Webkit and IE9 all display SVG files where the viewBox's width/height has a value of zero. E.g.:

  http://srufaculty.sru.edu/david.dailey/svg/newstuff/path5.svg
  http://srufaculty.sru.edu/david.dailey/svg/newstuff/path6.svg
  http://srufaculty.sru.edu/david.dailey/svg/newstuff/path7.svg
  http://srufaculty.sru.edu/david.dailey/svg/newstuff/path8.svg

Actually it's not quite so simple. Consider an SVG file containing the following markup:

<svg xmlns="http://www.w3.org/2000/svg"
     viewBox="0 0 0 0">
  <rect height="100%" width="100%" fill="orange"/>
  <rect height="100" width="100" fill="pink"/>
</svg>

IE shows both the orange and pink rects, so it seems to ignore the invalid viewBox attribute completely. Opera and Webkit both display the pink rect, but do not display the orange rect, so they seem to be ignoring the invalid (singular) implicit transform implied by the viewBox attribute, but seem to still be resolving percentage lengths against the viewBox (any percentage of zero is zero, so the orange rect's dimensions resolve to 0px x 0px).

Mozilla displays none of the SVG at all, since it follows the spec on this point.

I'm happy for Mozilla to either continue to follow what the spec currently says to do, or to agree to change the spec to do what IE9 does (ignore the broken viewBox completely), but I don't think that the Opera/Webkit behavior is good. Either way we should agree on interop behavior here.
Comment 1 Jonathan Watt 2011-04-22 17:10:25 UTC
One minor thing to consider in any decision is what a width/height of zero actually means. Imagine an animation of the viewBox width/height to zero - essentially what you're doing is zooming in on the SVG until you have a magnification of infinity. Ideally for a SMIL animation like this the viewport would be filled with the color at the focal point. Failing that though, I don't see any strong advantage in choosing between options:

 A) disable rendering of the element
 B) act as if the invalid viewBox attribute wasn't present