W3C home > Mailing lists > Public > www-style@w3.org > December 2009

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 16 Dec 2009 21:14:02 -0600
Message-ID: <dd0fbad0912161914ocfd3fedr6d5ef6c1c25c2e41@mail.gmail.com>
To: "L. David Baron" <dbaron@dbaron.org>
Cc: www-style <www-style@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 03:47:12 GMT