[whatwg] Inconsistency between canvas and CSS color serialization
Tab Atkins Jr.
jackalmage at gmail.com
Thu Feb 3 11:39:06 PST 2011
On Thu, Feb 3, 2011 at 11:17 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> On 2/3/11 1:58 PM, Tab Atkins Jr. wrote:
>> The alpha value is just a<number>, so whatever we decide on, we
>> should make the standard serialization for<number> and document it in
>> the CSSOM.
> I'm not sure it's that simple.
> In particular, the way browsers actually _store_ the alpha value is not as
> an infinite-precision decimal (which is what <number> is in CSS).
> For example, in the case of Gecko the alpha value is stored as an integer in
> the range [0,255]. When serializing we do a floating-point division by 255
> and then try to make the result not have 6 useless significant figures (in
> fact I believe we always output either 2 or 3).
> This is quite different from other <number> uses....
Webkit stores alpha the same way. I don't believe that's a problem
here, though - it just means that the <number> has fairly limited
precision. There's nothing requiring browsers to store a particular
precision for <number>s. (Whether or not there should be is a
The serialized value will round-trip as the same thing, right? As
long as that's true, then the convenient fiction that you actually
store the value you serialize as can be maintained.
More information about the whatwg