unitless angles (and times and frequencies) [css3-2d-transforms][css3-3d-transforms][css3-images]

View: New views
6 Messages — Rating Filter:   Alert me  

unitless angles (and times and frequencies) [css3-2d-transforms][css3-3d-transforms][css3-images]

by L. David Baron :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Both CSS 2.0 and css3-values are clear that '0' (without units) is
acceptable as a <length>, but not as an <angle>, <frequency>, or
<time>.

It turns out that:

 * unambiguous parsing of the new gradient syntax proposal depends
   on this (in particular, that '0' is not an angle)

 * css3-2d-transforms has a number of examples of using '0' as an
   angle, e.g., 'rotate(0)'

I think 'rotate(0)' is currently implemented in Mozilla, and I'm
guessing that, given the examples in the transforms spec, it's also
implemented in WebKit.


We either need to:
 * decide that CSS 2.0 and css3-values are correct, change the
   transforms examples, and possibly break some existing uses of
   transforms,
 * make a special exception for angles in transform functions, or
 * fix the gradients spec in some way.

My current inclination may actually be to make an exception for
transform functions.

-David

--
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/


Re: unitless angles (and times and frequencies) [css3-2d-transforms][css3-3d-transforms][css3-images]

by Tab Atkins Jr. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 4, 2009 at 10:18 AM, L. David Baron <dbaron@...> wrote:
> Both CSS 2.0 and css3-values are clear that '0' (without units) is
> acceptable as a <length>, but not as an <angle>, <frequency>, or
> <time>.
>
> It turns out that:
>
>  * unambiguous parsing of the new gradient syntax proposal depends
>   on this (in particular, that '0' is not an angle)

Indeed, I noticed this as a potential problem early on, but was
assured that angles weren't allowed to be unitless.

>  * css3-2d-transforms has a number of examples of using '0' as an
>   angle, e.g., 'rotate(0)'
>
> I think 'rotate(0)' is currently implemented in Mozilla, and I'm
> guessing that, given the examples in the transforms spec, it's also
> implemented in WebKit.
>
>
> We either need to:
>  * decide that CSS 2.0 and css3-values are correct, change the
>   transforms examples, and possibly break some existing uses of
>   transforms,
>  * make a special exception for angles in transform functions, or
>  * fix the gradients spec in some way.
>
> My current inclination may actually be to make an exception for
> transform functions.

I wouldn't have a problem with making an exception for the transform
function.  I believe it's unambiguous where angles are allowed.

~TJ


Re: unitless angles (and times and frequencies) [css3-2d-transforms][css3-3d-transforms][css3-images]

by Simon Fraser-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 4, 2009, at 10:18 AM, L. David Baron wrote:

> Both CSS 2.0 and css3-values are clear that '0' (without units) is
> acceptable as a <length>, but not as an <angle>, <frequency>, or
> <time>.
>
> It turns out that:
>
> * unambiguous parsing of the new gradient syntax proposal depends
>   on this (in particular, that '0' is not an angle)
>
> * css3-2d-transforms has a number of examples of using '0' as an
>   angle, e.g., 'rotate(0)'
>
> I think 'rotate(0)' is currently implemented in Mozilla, and I'm
> guessing that, given the examples in the transforms spec, it's also
> implemented in WebKit.
>
>
> We either need to:
> * decide that CSS 2.0 and css3-values are correct, change the
>   transforms examples, and possibly break some existing uses of
>   transforms,
> * make a special exception for angles in transform functions, or
> * fix the gradients spec in some way.
>
> My current inclination may actually be to make an exception for
> transform functions.

Unitless 0 for angles in transforms is very common. I'd prefer we don't
break that.

I'm close to proposing a slightly modified syntax for gradients, but I  
fear
it will have the same ambiguity about a parameter being a length vs.
an angle if unitless.

Simon



Re: unitless angles (and times and frequencies) [css3-2d-transforms][css3-3d-transforms][css3-images]

by Giovanni Campagna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/4 Simon Fraser <smfr@...>:

> On Nov 4, 2009, at 10:18 AM, L. David Baron wrote:
>
>> Both CSS 2.0 and css3-values are clear that '0' (without units) is
>> acceptable as a <length>, but not as an <angle>, <frequency>, or
>> <time>.
>>
>> It turns out that:
>>
>> * unambiguous parsing of the new gradient syntax proposal depends
>>  on this (in particular, that '0' is not an angle)
>>
>> * css3-2d-transforms has a number of examples of using '0' as an
>>  angle, e.g., 'rotate(0)'
>>
>> I think 'rotate(0)' is currently implemented in Mozilla, and I'm
>> guessing that, given the examples in the transforms spec, it's also
>> implemented in WebKit.
>>
>>
>> We either need to:
>> * decide that CSS 2.0 and css3-values are correct, change the
>>  transforms examples, and possibly break some existing uses of
>>  transforms,
>> * make a special exception for angles in transform functions, or
>> * fix the gradients spec in some way.
>>
>> My current inclination may actually be to make an exception for
>> transform functions.
>
> Unitless 0 for angles in transforms is very common. I'd prefer we don't
> break that.

Are you sure?
Angles can be used only in rotate / skew.
rotate(0), rotateX(0), rotateY(0), rotateZ(0), rotate3d(x,y,z,0),
skewX(0) and skewY(0) are all identity transforms, so I guess they're
not used much
the only difference is in skew(0,y) or skew(x,0), which could be
replaced by appropriate skewX / skewY

IHMO, allowing unit-less angles in transforms and only in transforms
would introduce additional complexity on implementers without any
clear advantage to authors, that would use 0rad or 0deg anyway, for
consistency with the rest of CSS

> I'm close to proposing a slightly modified syntax for gradients, but I fear
> it will have the same ambiguity about a parameter being a length vs.
> an angle if unitless.
>
> Simon
>
>
>

Giovanni


Re: unitless angles (and times and frequencies) [css3-2d-transforms][css3-3d-transforms][css3-images]

by Simon Fraser-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 5, 2009, at 5:42 am, Giovanni Campagna wrote:

>>
> Angles can be used only in rotate / skew.
> rotate(0), rotateX(0), rotateY(0), rotateZ(0), rotate3d(x,y,z,0),
> skewX(0) and skewY(0) are all identity transforms, so I guess they're
> not used much

Actually they are, to specify the initial state of transitions or  
animations
when you want the end state to have a matching list of transform  
functions
so that you don't fall into the "matrix decomposition" path for  
animations.

See
<http://www.w3.org/TR/2009/WD-css3-2d-transforms-20090320/#animation>

> the only difference is in skew(0,y) or skew(x,0), which could be
> replaced by appropriate skewX / skewY
>
> IHMO, allowing unit-less angles in transforms and only in transforms
> would introduce additional complexity on implementers without any
> clear advantage to authors, that would use 0rad or 0deg anyway, for
> consistency with the rest of CSS

I disagree; there's very little additional complexity (in WebKit at  
least).
The decision to allow unitless 0 is made per property.

Simon



Re: unitless angles (and times and frequencies) [css3-2d-transforms][css3-3d-transforms][css3-images]

by Boris Zbarsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/5/09 9:59 AM, Simon Fraser wrote:
> I disagree; there's very little additional complexity (in WebKit at least).
> The decision to allow unitless 0 is made per property.

Likewise for Gecko, effectively.

-Boris