[svgwg] patternTransform browser implementations do not match spec

AmeliaBR has just created a new issue for 
https://github.com/w3c/svgwg:

== patternTransform browser implementations do not match spec ==
The definition of the SVG `patternTransform` attribute says ([SVG 
1.1](https://www.w3.org/TR/SVG11/pservers.html#PatternElementPatternTransformAttribute))([SVG
 
2](https://svgwg.org/svg2-draft/pservers.html#PatternElementPatternTransformAttribute)):

> Contains the definition of an optional additional transformation 
from the pattern coordinate system onto the target coordinate system 
(i.e., 'userSpaceOnUse' or 'objectBoundingBox'). This allows for 
things such as skewing the pattern tiles. This additional 
transformation matrix is post-multiplied to (i.e., inserted to the 
right of) any previously defined transformations, including the 
implicit transformation necessary to convert from object bounding box 
units to local coordinate system.

In other words, when using `objectBoundingBox` units, a translation of
 0.5,0.5 should shift the pattern tile by half the width and height of
 the box being painted.  And a rotation around the point 0.5, 0.5 
should be a rotation around the center of the box.

[This is how it works with 
`gradientTransform`](//codepen.io/AmeliaBR/pen/zovxyg/?editors=1000).

But none of the browsers apply it this way for `patternTransform`.  
Instead they use they always apply the transforms in user space 
coordinates. So a translation of 0.5,0.5 is just a shift of half a 
pixel in each direction.

But what's really weird is the `rotate(45, 0.5,0.5)` transform. It 
seems like it is rotating around the middle of the userSpace 
coordinate system, not around the center of the box/pattern tile, nor 
around the 0.5px,0.5px point.

My guess is part of the problem is that there are *two* coordinate 
systems for patterns: the pattern tile (`patternUnits`) versus the 
pattern contents (`patternContentUnits`).  So it's not really clear 
what should happen, according to spec, if these don't match each 
other, or if there is a `viewBox` on the pattern.  I personally would 
expect the transform to apply to each pattern tile in the units used 
to define the pattern tile dimension. But that's not exactly spelled 
out in the spec.

But what I don't know is why *no one ever brought up the issue with 
the spec* so that it could get fixed. 

So, something's gotta give. Either pave the erratic cowpath and spec 
what the browsers are doing (after first clearly figuring out what 
that is), or tighten up the definition and then file bugs on every 
browser.  All of which is now made more complicated by the fact that 
`patternTransform` is supposed to also be affected by 
`transform-origin` and other CSS Transforms properties.

PS, Thanks to @yoksel for identifying this problem in [her SVG 
Conundrum pen](//codepen.io/yoksel/full/mOJaOE/)


Please view or discuss this issue at 
https://github.com/w3c/svgwg/issues/293 using your GitHub account

Received on Wednesday, 9 November 2016 00:34:48 UTC