Re: [css3-values] calc() and properties that disallow negative values

On Wed, Dec 16, 2009 at 6:17 PM, L. David Baron <dbaron@dbaron.org> wrote:
> 1. While parsing the contents of the calc(), values are accepted
>   even if, were they the lone value of the property, they would be
>   rejected due to their sign (or any other range restriction on the
>   value of the property).
>
>   For example:
>     width: calc(50% + -2px);
>   is a valid declaration even though -2px is not a valid value for
>   the 'width' property.

This seems like it should be possible in the first place.  Does calc()
current disallow this?  If so, then it should definitely be changed to
allow this; this construct is pretty necessary for a lot of the uses
calc() will be put to.

> 2. For properties whose values have restricted ranges, the computed
>   value of the calc() expression is clamped to the allowed range.
>
>   For example:
>     width: calc(50% - 200px);
>   computes to zero when the containing block's width is less than
>   or equal to 400px (whereas without the clamping it would become
>   negative when the containing block's width is less than 400px).

This seems unobjectionable.  I highly doubt that an author will *ever*
actually want their calc() expression to become invalid some of the
time.  It seems much more likely that I'll write an expression like
this and implicitly expect it to become 0 when the box is too small.
Requiring an explicit max() call in there seems unnecessary.

~TJ

Received on Thursday, 17 December 2009 03:15:30 UTC