W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] Inconsistency between canvas and CSS color serialization

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 3 Feb 2011 11:39:06 -0800
Message-ID: <AANLkTikW5ihPmLsSa5Or+hmB=uBoO8RPfgi_Wyyk8Uhj@mail.gmail.com>
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
separate argument.)

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.

~TJ
Received on Thursday, 3 February 2011 11:39:06 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC