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

Re: [css3-values] proposal for handling division and units in calc() [ACTION-205]

From: Håkon Wium Lie <howcome@opera.com>
Date: Mon, 9 Aug 2010 20:26:47 +0200
Message-ID: <19552.18535.107127.820357@gargle.gargle.HOWL>
To: "L. David Baron" <dbaron@dbaron.org>
Cc: www-style@w3.org
Also sprach L. David Baron:

 > Therefore, I propose that:
 > 
 >  1. We drop the 'mod' operator since it only makes sense when
 >     both operands have the same units.

Right. Removed from:

  http://dev.w3.org/csswg/css3-values/

 >  2. The right operand to the '/' operator be required to be unitless
 >     (that is, a number or an expression composed of numbers).

I've changed the formal grammar to be:

   product : unit [[ "*" S* unit ] | [ "/" S* NUMBER ]] *;

and the pseudo-semantic constraints to be:

  <ol>
  <li>At ",", "+", "-":<br>
     check: both sides have the same type<br>
     return: that type
  <li>At "*":<br>
    check: at least one side is "number" return: the type of the other side
  <li>At "/":<br> 
     check: right side is "number"<br>
     return: the type of the left side
  </ol>

Does this look right?

 >  3. Division by zero be a parse error (as I think it was in earlier
 >     drafts of the specification, perhaps?).

I've added:

   Division by zero is a parse error.

 >  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?

-h&kon
              Håkon Wium Lie                          CTO °þe®ª
howcome@opera.com                  http://people.opera.com/howcome
Received on Monday, 9 August 2010 18:27:32 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:30 GMT