Re: [cssom] Serializing non-opaque colors, background-position keywords

On Thu, 29 Jan 2015 20:03:24 +0100, Tab Atkins Jr. <jackalmage@gmail.com>  
wrote:

> On Thu, Jan 29, 2015 at 3:43 AM, Simon Pieters <simonp@opera.com> wrote:
>>>> Similarly for 'opacity' (although that is represented with higher
>>>> precision
>>>> I think).
>>>
>>> I would be totally fine with specifying that opacity must be
>>> serialized with 2 or 3 digits.
>>
>> OK. Presto serializes at most 2 digits. Are people OK with that? Or is  
>> the
>> Gecko/IE approach better?
>
> I'd prefer rgba() alpha and 'opacity' to serialize the same way.  They
> both use <alphavalue>, after all.

Yes, but they're stored differently in at least some implementations. If  
we say that 'opacity' can only be serialized up to three digits, it will  
not be equivalent to rgba() since 'opacity' will be able to serialize 1001  
different values but rgba() only 256.

We could limit to 6 digits like IE/Gecko but say that values less than  
0.0000005 must serialize as 0, which avoids serializing sci-not (and  
limiting digits there), and so masks all(?) float->double rounding errors.

Possibly the spec could have different strategies depending on how it's  
stored, and not tie it to rgba() vs. opacity.

>>>> == background-position keywords ==
>>>>
>>>> How should background-position: 0% top be serialized? For  
>>>> element.style,
>>>> Gecko round-trips keywords, Blink converts to percentages. For
>>>> getComputedStyle, both convert to percentages. I think the spec for
>>>> background-position says keywords compute to percentages.
>>>
>>> I'm fine with either percentages or keywords, as long as we don't have
>>> to remember which was specified and return it.  In other words, I'm
>>> okay if "top" always becomes 0%, or 0% always becomes "top" (or
>>> "left", whatever), but I'm not okay with 0% becoming 0% and "top"
>>> becoming "top".
>>
>> OK. Why?
>
> Because it requires more storage.  You have to remember whether it was
> specified with a keyword or not.

Yes, OK. My question for Gecko/IE stands:

Are Gecko/IE OK with not differentiating keywords and percentages in  
element.style?


>  In my preferred solutions, you can
> always store it as a percentage, and then, if you're required to
> serialize as keywords when possible, just do a check at serialization
> time for that.
>
> Also:
>
>>> I lean slightly towards percentages, though, as that means the
>>> serialization doesn't suddenly change at a few magic values.

cheers

-- 
Simon Pieters
Opera Software

Received on Friday, 30 January 2015 11:08:15 UTC