- From: L. David Baron <dbaron@dbaron.org>
- Date: Mon, 9 Aug 2010 17:12:07 -0700
- To: Håkon Wium Lie <howcome@opera.com>
- Cc: www-style@w3.org
On Tuesday 2010-08-10 01:05 +0200, Håkon Wium Lie wrote: > Also sprach L. David Baron: > > > > 4. Leaf values inside a calc() expression must all be either (a) > > > > numbers or (b) legal values for the property, or things that > > > > would be legal values if it weren't for range restrictions (such > > > > as the restriction that 'width' accepts only positive values). > > > > > > How about percentages? > > > > Percentages should be accepted when they are allowed values for the > > property, just like any other units. > > That works for percentages. However, we must somehow prohibit keywords > and such from being accepted, e.g.: > > calc(inherit) > > I'd like to see the text quoted above (as 4.) merged with this text: > > The semantic constraints are as follows: The context of the > expression imposes a <em>target type</em>, which is one of length, frequency, > angle, time, or number. Any PERCENTAGE token in the expression has the > target type. The NUMBER tokens are of type number, and the DIMENSION > tokens have types of their units ('cm' is length, 'deg' is angle > etc.). At each operator, the types of the left and right side have to > be compared and, if compatible, they yield a <em>result type</em>, roughly as > follows (the following ignores precedence rules on the operators for > simplicity): > > But I think you can do it better than me. How about replacing this portion of the above paragraph: The context of the expression imposes a target type, which is one of length, frequency, angle, time, or number. Any PERCENTAGE token in the expression has the target type. The NUMBER tokens are of type number, and the DIMENSION tokens have types of their units (‘cm’ is length, ‘deg’ is angle etc.). with: The context of the expression imposes a target type, which is one of length, frequency, angle, time, or number. NUMBER tokens are of type number. DIMENSION tokens have types of their units (‘cm’ is length, ‘deg’ is angle etc.); any DIMENSION whose type does not match the target type is not allowed and must be a parse error. If percentages are accepted in that context and convertible to the target type, a PERCENTAGE token in the expression has the target type; otherwise percentages are not allowed and must be a parse error. And then adding, below, the following two paragraphs: The value resulting from an expression must be clamped to the range allowed in the target context. For example, 'width: calc(5px - 10px)' is equivalent to 'width: 0px' since widths smaller than 0px are not allowed. Note: Except for range restrictions, all values allowed inside an expression are either numbers or values that are permitted in the context of the expression. -David -- L. David Baron http://dbaron.org/ Mozilla Corporation http://www.mozilla.com/
Received on Tuesday, 10 August 2010 00:12:51 UTC