W3C home > Mailing lists > Public > www-svg@w3.org > September 2012

Re: Initial Viewport

From: Dirk Schulze <dschulze@adobe.com>
Date: Wed, 12 Sep 2012 07:15:50 -0700
To: Nick Hofstede <Nick.Hofstede@inventivegroup.com>
CC: "www-svg@w3.org" <www-svg@w3.org>
Message-ID: <F5DEFC65-7E53-4BA6-8E36-39C6BE936499@adobe.com>
Hi Nick,

On Sep 12, 2012, at 1:53 PM, Nick Hofstede <Nick.Hofstede@inventivegroup.com> wrote:

> The longer Iím looking at this, the more confused I get Ö
>  
> http://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute says that if width or height arenít specified, 100% should be used.
> However, when I test this (test case attached), there is a difference between referencing an svg with width and height set to 100% and an svg with width and height omitted.
You are mixing up different things.

First, width and height attribute depend on the viewport of the SVG element (the window size, or the viewport that gets established of one ancestor). If you use (100%, 100%) it just means that the size of the SVG will be (100%,100%) of the viewport. If you use (200px,200px), then the SVG's size is 200px, 200px on the view port. It does not affect the transformation of the content. The content will still be drawn in the current transformation of the SVG's viewport. This is important, since the boundaries of an SVG element interact as clipping region.

viewBox defines the coordinates within the SVG element. Just imagine viewBox as some kind of transform that scales and transforms the content to let it fit into the boundaries of the SVG element.

As example:

<svg width="400" height="400" viewBox="0 0 100 100">
<rect width="100" height="100"/>
</svg>

The width and height attribute define the boundaries of the SVG. Every content that is outside of the boundaries gets clipped to the boundaries.
The viewBox defines the coordinates and size of the inner viewport, established by the SVG element itself. In the example it is similar to scaling the content by the factor 4 to make it fit into the SVG boundaries.

The browsers follow the specification on your examples.

Greetings,
Dirk

> Are all three browsers misinterpreting the specification in a consistent way, or is there a part of the specification Iím missing? (probably the latter)
>  
> With kind regards,
>  
> Nick Hofstede
>  
>  
> From: Nick Hofstede 
> Sent: dinsdag 11 september 2012 10:23
> To: www-svg@w3.org
> Subject: Initial Viewport
>  
> Hi,
>  
> Iím trying to figure out what the initial viewport should be of an embedded/referenced svg in the following case:
> -        The parent user agent doesnít provide a size for the referenced svg document (only a coordinate where it should be placed)
> -        The referenced svg document has width and height on the outermost svg element set to 100%
>  
> Browser tests using <img src=Ētest.svgĒ /> result in creative behavior (the results might be muddied by having to follow CSS rules anyway - the parent user agent Iím thinking of isnít using CSS to specify width/height).
>  
> Iíve been looking at
> http://www.w3.org/TR/SVGTiny12/coords.html#transform-viewport
> http://www.w3.org/TR/SVGTiny12/coords.html#IntrinsicSizing
>  
> Kind regards,
> Nick Hofstede
> 
>  
> 
> Inventive Designers' Email Disclaimer:
> http://www.inventivedesigners.com/email-disclaimer
> 
> -- 
> This message has been scanned for viruses and 
> dangerous content by MailScanner, and is 
> believed to be clean.
> 
> 
> Inventive Designers' Email Disclaimer:
> http://www.inventivedesigners.com/email-disclaimer
> <1.svg><2.svg><3.svg><referenced.html>
Received on Wednesday, 12 September 2012 14:16:22 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:52 GMT