Re: [css3-background] background-size and zero length

On 5/11/10 2:17 PM, Brian Manthos wrote:
> there are a growing number of property that have special behavior "at" zero.  Background-size and border-radius with box-shadow are two that have been discussed recently.
>
> I would prefer that CSS define "numbers within X of zero should be treated identically to zero".  Doing so makes interoperability a likelihood rather than luck.
>
> Another example that comes to mind is unit-less.  IIRC,<length>  values require units except for zero.  Given that the "near-zero" region is open to UA-discretion, what does that imply about "0.016" as a<length>?

If you're specifically asking about the Gecko behavior for <length>, then:

1)  During tokenization and parsing strings that look like numbers are
     parsed into a machine float (effectively; they're parsed into a
     machine double then stored in a float so as to avoid rounding
     problems with parsing into float directly).
2)  Whether a unit is required by the parser depends on whether the
     resulting machine float value tests == 0.0f.
3)  Specified values are stored as a pair of machine float and unit.
4)  When determining computed values, lengths are converted to integers
     with units of 1/60 px.

So to run into the problem of a small value not needing a unit in the 
above implementation, you would need a value that's too small to 
represent as a nonzero machine float.  Over here that seems to be around 
0.000000000000000000000000000000000000009 or so, but presumably depends 
on whether your hardware supports denormalized floats (chances are, it 
does).  That's obviously easier to hit if we allow scientific notation.  ;)

I agree that defining near-zero behavior more clearly might be beneficial.

-Boris

Received on Tuesday, 11 May 2010 19:01:16 UTC