patternContentUnits and percentage resolving in external patterns

Hi www-svg,

while going over the pattern code in Opera we have found the handling of  
the following scenario to be a bit unclear in the spec:

Example:
--------

<svg xmlns="http://www.w3.org/2000/svg">
   <rect fill="url(external.svg#pattern) red" width="100" height="100"/>
</svg>


External.svg:
-------------

<svg xmlns="http://www.w3.org/2000/svg">
   <defs>
     <pattern id="pattern" patternContentUnits="userSpaceOnUse" width="10"  
height="10">
       <circle cx="10%" cy="10%" r="5%" fill="lime"/>
     </pattern>
   </defs>
</svg>


The SVG 1.1 spec[1] says this:
[[ If patternContentUnits="userSpaceOnUse", the user coordinate system for  
the contents of the 'pattern' element is the coordinate system that  
results from taking the current user coordinate system in place at the  
time when the 'pattern' element is referenced (i.e., the user coordinate  
system for the element referencing the 'pattern' element via a 'fill' or  
'stroke' property) and then applying the transform specified by attribute  
patternTransform. ]]

Now, in the example above that would be the rect element in the main svg  
file. The <pattern> element doesn't establish a viewport[3]. Is the  
intention that the percentages are to be resolved not by using the nearest  
containing viewport (as defined in 7.10 [2]) but to the viewport that  
referenced the pattern in this case? As you may note in this example the  
referenced svg has no actual viewport since it's not displayed, and it has  
no absolute width or height to resolve percentage units against.

In general it's probably advisable to use a 'viewBox' attribute on the  
<pattern> element if it's meant to be reusable, but it would be nice to  
hear some thoughts on the above.

What would be the most reasonable way to deal with such cases?

Cheers
/Erik

[1] http://www.w3.org/TR/SVG11/pservers.html#Patterns
[2] http://www.w3.org/TR/SVG11/coords.html#Units
[3] http://www.w3.org/TR/SVG11/coords.html#ElementsThatEstablishViewports

-- 
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed

Received on Thursday, 25 February 2010 15:36:55 UTC