Re: [cssom] comments on value serialization rules

On Wed, 17 Feb 2010 19:21:14 +0100, L. David Baron <dbaron@dbaron.org>  
wrote:
> Various comments on the value serialization rules in:
>   http://dev.w3.org/csswg/cssom/#serializing-css-values
> follow.

Thanks, much appreciated!


> For <angle>, <frequency>, <length>, <resolution>, and <time>, Gecko
> currently preserves the unit the author specified.  I'm ok with
> normalizing to a single unit, although I worry about two things:
>  * compatibility issues
>  * choice of what the canonical unit is
> In particular, I suspect serializing '12pt' to '4.2333mm' might lead
> to confusion, though maybe it would be good that authors learn that
> 'pt' are physical units.

This might go a way if physical units are going to be defined in terms of  
CSS pixels.


> The escaping rules presented for <string> and <uri> have bugs in
> that they produce values that don't round-trip correctly (e.g.,
> values with \n or \r in them, or values with \ in them).  I'd
> propose fixing that the way I did in Gecko, and also generally
> making the escaping rules for <identifier> more similar to those for
> <string> and <uri>, by making them as follows:

I used these rules, thanks!


>   Define "escape as an string" as a string represented by the
>   concatenation of, for each character:
>    * if the character is in the range U+0000 to U+001F, the
>      character serialized as a codepoint escape
>    * if the character is '"' (U+0022), "'" (U+0027),  or '\'
>      (U+005C), the character serialized as a character escape
>    * otherwise, the character itself

Do you think we can leave U+0027 out if we ensure that strings always end  
up between double quotes?


> These rules also have the advantages that they minimize the use of
> codepoint escapes (generally quite ugly due to the
> space-as-terminator) to ASCII nonprintables and escaping of digits,
> and that they escape all ASCII nonprintables (which could otherwise
> be quite confusing to read).
>
> Then <uri> and <string> can refer to "escape as a string" and
> <identifier> can refer to "escape as an identifier".

Done!


> Also, <uri> should end with '")' rather than ')"'.

Yeah, I noticed this while reading the example during the teleconference  
yesterday, fixed :-)


> For <color>, what Gecko does, I believe, is that it handles system
> colors, color keywords, and 'currentColor' like <keyword>, but
> handles 'transparent', 'rgb()', 'rgba()', 'hsl()', 'hsla()', '#rgb',
> and '#rrggbb' as color values which are serialized as follows:
>  * 'transparent' when R, G, B, and A components are all 0
>  * as 'rgb()' when A component is 255
>  * as 'rgba()' otherwise
> I'm not particularly committed to keeping it that way, though.
> However, I'm somewhat concerned about the idea of switching to
> #rrggbb notation since rgb() can handle out-of-sRGB values whereas
> #rrggbb cannot.  (Gecko doesn't currently implement that, but I'd
> like to.)

And then sometimes serialize to percentages? Or would you propose a change  
to the rgb() syntax as well? My main gripe here is <canvas> which uses  
#rrggbb and IE, which also uses #rrggbb (though I should probably test  
that again to be sure).


> Also, the title of the section following is misspelled
> ("Declaraton" needs an i).

Also fixed!


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Thursday, 18 February 2010 14:00:47 UTC