[css3-values] calc() grammar needs flexibility about units

The grammar for the calc function in
http://dev.w3.org/csswg/css3-values/#the-calc-function currently
says:
#   <atomic-length> := <number><length-unit>

This unnecessarily restricts calc() to lengths, contradicting even
the examples in the specification, which use both lengths and
percentages.

However, it seems that the values allowed in calc() expressions
should be allowed to be whatever numbers with units are allowed on a
value at the point where the calc(), min(), or max() occurs.  These
could be lengths, percentages, angles, times, or frequencies.

I think the <atomic-length> production in the calc() grammar should
be changed to explain this (and, in particular, that it is dependent
on what types of values are allowed at the point where the calc()
expression is used).

Furthermore, I think the use of "length" in the production names in
the calc() grammar should probably be replaced with "value" or
something similar, to reflect that these productions are not
specific to lengths.


That said, it's possible we want to leave most of the restriction in
the prose that says:
  # The calc(<expression>) function can be used wherever length
  # values are allowed, with the syntax given below.
and not allow calc() for angles, times, or frequencies.  However, if
we do this, the specification still needs updating for percentages,
since we want to allow percentages inside calc() where percentages
are otherwise allowed.

-David

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

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