[Bug 12824] This doesn't say how to serialize non-zero alpha values: how many digits should be used? The correct answer is the minimum number necessary so that the resulting string evaluates to the same floating-point number as you started with.

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12824

--- Comment #3 from Aryeh Gregor <Simetrical+w3cbug@gmail.com> 2011-05-31 14:20:49 UTC ---
(In reply to comment #1)
> Actually, the correct answer may be to use however many are needed to ensure
> that your round-trip back to the same value you have now if you parse the
> result.

Good catch.

> For example, consider a UA that stores alpha internally as an integer in the
> range [0, 255] (a very common thing to do; Presto, WebKit nightly, and Gecko
> all do it).

Should this be standardized?  It has some author-visible implications.  To
start with, if alpha values are serialized as you suggest, setting and then
reading back strokeStyle or fillStyle will give you a different number of
digits in different UAs for the alpha, depending on how much internal precision
they have.

More than that, presumably it will also be detectable by drawing some
non-opaque things on top of each other and measuring the exact color of the
result.  If everything gets clamped to 8-bit integers, the rounding will be
different from if you use actual floats.

> Note that of the three Gecko is the only one that even tries to make the
> serialized value look "nice" (in the sense of using the smallest number of
> digits that will round-trip to the same integer; this means that 0.1 ends up
> serialized as "0.1" and not "0.09804" (Chrome) or "0.10196" (Presto and
> Safari)).

Actually, this bug was prompted by the fact that WebKit just changed to more
Gecko-like behavior here:

http://trac.webkit.org/changeset/87512

The commit summary said "The number of decimals for alpha values between 0 and
1 is not specified, so match Gecko and Presto by returning the lowest number of
decimals needed to represent the number", so my immediate reaction was to get
the number of decimal places standardized.  (I don't know why it says "and
Presto" -- I get the same results in Opera as you do.)

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Tuesday, 31 May 2011 14:20:54 UTC