RE: [css3-values] calc(), whitespace, and DIMENSION tokens

3cm-2cm is a strange case. It really is a single dimension with numeric part 3 and dimension suffix cm-2cm... I think in this case the whitespace would have to be "required" to treat them as two tokens. Otherwise every dimension token has to be hand split. I can't hand my tokenizer to a calculator parsing function at all, instead I have to tokenize, produce a string, then hand the string for "non CSS" parsing. Which really isn't cool since CSS rules still apply in this case for known dimensions like cm and the intent of this user was to subtract two dimension values (or was it!)

We should definitely ensure that whatever we do for calc we also apply to :nth-child with the limitation that a "pseudo" and a "function" are somewhat separate in the grammar, though not so much in CSS 3 due to the functional_pseudo.

Unfortunately I don't have a prepared solution to offer. Only that it is clear that the intent of the calc function and the grammar are going to have some conflicts.

Justin Rogers [MSFT]

-----Original Message-----
From: www-style-request@w3.org [mailto:www-style-request@w3.org] On Behalf Of fantasai
Sent: Tuesday, March 11, 2008 3:42 PM
To: www-style@w3.org
Subject: [css3-values] calc(), whitespace, and DIMENSION tokens


The spec for calc() currently doesn't talk about whitespace at all. Perhaps
it's implied somewhere else, but I'm not familiar enough with the grammar to
know where.

I'll note that
   3cm-2cm
will be parsed as a single DIMENSION token and
   3cm -2cm
will be parsed as two DIMENSION tokens. Is that what we want? Is whitespace
required around minus and plus signs to treat them like operators or is
tokenization different inside calc() like it is inside :nth-child()?

I think it's fine to require white space around plus and minus signs in
calc() expressions, since that helps emphasize that they're lower precedence
than * and /. However, if we're requiring white space around these operators
in calc(), then we should at least allow white space around them in :nth-child().

http://www.w3.org/TR/CSS21/syndata.html#tokenization

~fantasai

Received on Wednesday, 12 March 2008 01:03:12 UTC