[css3-values] allowing more whitespace within calc()

I'm looking at the grammar for calc() in
http://dev.w3.org/csswg/css3-values/#the-calc-function with regard
to where white space is forbidden, optional, and allowed within the
grammar, and I'm not sure that the grammar in the spec is quite what
we want.

Now, I recall that we *did* intend to require white space around
both sides of '+' and '-' and 'mod' since otherwise we'd have major
parsing problems with '-' and 'mod'.  The grammar does reflect this.

The grammar also allows for optional whitespace around other
operators (*, /).

However, my concern is that the grammar does not allow for optional
whitespace inside of parentheses.  That seems incompatible with
whitespace in other parts of CSS, and I think we should change that.
In particular, the current grammar says that:
  calc( 5em + 2px )
is invalid because it does not allow whitespace either after the '('
or before the ')'.

I think the simplest way to fix this is to change the single production:
#  <length-expression> := <length-additive-expression>
into:
#  <length-expression> := S* <length-additive-expression> S*

This would allow whitespace inside the toplevel parentheses of the
calc() expression, inside inner parentheses within the <length-term>
production, and also in the <length-min-max> production that I
proposed in my previous email (with subject "[css3-values] Adding
min() and max() into calc() grammar").

-David

-- 
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/

Received on Thursday, 17 December 2009 01:39:21 UTC