W3C home > Mailing lists > Public > www-style@w3.org > January 2010

Re: [css3-values] calc()'s <number-multiplicative-expression> incorrect

From: L. David Baron <dbaron@dbaron.org>
Date: Fri, 1 Jan 2010 21:16:25 -0500
To: www-style@w3.org
Message-ID: <20100102021625.GA14334@pickering.dbaron.org>
On Wednesday 2009-12-23 11:24 -0500, L. David Baron wrote:
> However, I think if we want the spec to allow division by values,
> it's better not to use the grammar to do the dimension-checking.
> For example, the current grammar allows these:
>   (3em / 100%) * 3em
>   3em / 100% * 3em
>   3em * (3em / 100%)
> but disallows this:
>   3em * 3em / 100%
> which seems very strange.  I would much rather they either be all
> allowed or all disallowed.

Actually, there's a bit of a problem with division-by-values that I
just noticed (while trying to implement division by values with my
proposal for allowing all 4 of the above, although the problem is
present even without my changes).

The spec (editor's draft, [1]) currently requires rejecting values
that involve division by zero at parse time.  (Parse time rejection
is better in CSS since it allows for a better fallback mechanism:
fallback to the next highest declaration in the cascade.)

However, if we allow division by values, determination of what is
division by zero can't be made at parse time.  For example:
  width: calc(3em / (3em - 30px) * 20px);
involves division by  zero when the font size is 10px (so 3em - 30px
is 0), but otherwise does not.

It's not clear to me what to do about this.


[1] http://dev.w3.org/csswg/css3-values/#the-calc-function

L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Saturday, 2 January 2010 02:16:56 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:13:42 UTC