W3C home > Mailing lists > Public > www-style@w3.org > November 2010

Re: [css3-2d-transforms] Interop: matrix() values e,f <number> or <length>

From: Chris Marrin <cmarrin@apple.com>
Date: Fri, 19 Nov 2010 10:26:09 -0800
Message-id: <21C0DA4C-C07A-4D7D-A199-19C3B2AC444F@apple.com>
To: www-style list <www-style@w3.org>

On Nov 18, 2010, at 7:12 AM, Boris Zbarsky wrote:

> On 11/18/10 9:58 AM, Boris Zbarsky wrote:
>> How does that follow? If _I_'m using matrix() in a web page, I'm
>> probably doing math in support of some physics, personally, and I better
>> be using correct units everywhere to stay sane instead of having units
>> magically implied somewhere!
> To clarify, what you're saying is "The syntax should have no units, but the semantics should be that the number is treated as if it had units of px".  Or something.  The current 2d transform spec actually doesn't define what the heck the matrix() syntax means for nonzero e and f, except by linking to SVG.  In SVG there is in fact a privileged unit: user units; so in SVG assuming that e and f are given in user units makes sense. In fact, in SVG you always have to use user units in all the transform stuff (including in translate()).  You can't use other units even if you wanted to.

I'm not sure what "user units" are in SVG. But yes, I believe units should not be allowed in the matrix() function syntax. Certainly values being produced in the matrix operations have _some_ units, I think we just have to agree what those units are.

I think this brings up the bigger issue. In what "units" are the 16 floating points values of CSSMatrix kept? For instance, if I say:

    var mat = new CSSMatrix("translate3D(50%, 10em, 20cm)");

This will produce an identity matrix, except for the values at m41 and m42. What values are those? Are they, in all cases converted to pixels? This is what the WebKit implementation does today, and I think it's reasonable. But I think it's important that all implementations produce the same results.

This brings up a glaring problem with CSSMatrix. When you construct one, it is not associated with any element, so you can't use an element's style to convert units. Today, when we encounter the above CSSMatrix constructor I believe we just convert 50% to a value of 50 or something equally arbitrary. We should probably amend CSSMatrix to allow an element to be passed to the constructor. This brings up the next sticky issue of what happens when, for instance, the client size of the element changes. Do values in the CSSMatrix change? Madness!

Anyway, we need to clarify all these issues in the prose of the spec.

Received on Friday, 19 November 2010 18:26:50 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:41 UTC