Skip to content

Commit 4d78d5a

Browse files
committed
x
1 parent c235348 commit 4d78d5a

1 file changed

Lines changed: 14 additions & 66 deletions

File tree

css3-values/Overview.html

Lines changed: 14 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,22 @@ <h4 id=the-calc-min-and-max-functions><span class=secno>6.3.3. </span>The
863863
min : "min(" S* sum [ "," S* sum ]* )"" S*;
864864
max : "max(" S* sum [ "," S* sum ]* ")" S*;
865865
sum : product [ [ "+" | "-" ] S* product ]*;
866+
product : unit [[ "*" S* unit ] | [ "/" S* NUMBER ]] *;
867+
unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* |
868+
min | max | "(" S* sum ")" S* ];
869+
</pre>
870+
<!--
871+
<pre>
872+
S : calc | min | max;
873+
calc : "calc(" S* sum ")" S*;
874+
min : "min(" S* sum [ "," S* sum ]* )"" S*;
875+
max : "max(" S* sum [ "," S* sum ]* ")" S*;
876+
sum : product [ [ "+" | "-" ] S* product ]*;
866877
product : unit [ [ "*" | "/" | "mod" ] S* unit ]*;
867878
unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* |
868879
min | max | "(" S* sum ")" S* ];
869880
</pre>
881+
-->
870882

871883
<p>The semantic constraints are as follows: The context of the expression
872884
imposes a target type, which is one of length, frequency, angle, time, or
@@ -886,73 +898,9 @@ <h4 id=the-calc-min-and-max-functions><span class=secno>6.3.3. </span>The
886898
check: at least one side is "number" return: the type of the other side
887899

888900
<li>At "/":<br>
889-
check: either right side is "number," or both have the same type<br>
890-
return: if the former, type of left side; otherwise "number"
891-
892-
<li>At "mod": <br>
893-
check: both sides have the same type<br>
894-
return: "number"
901+
check: right side is "number"<br>
902+
return: the type of the left side
895903
</ol>
896-
<!--
897-
<p>A value is ignored if a division by zero or other mathematical
898-
errors occur in the calculation.
899-
900-
<div class="example">
901-
<p>In this example, the second declaration will be ignored due to a
902-
division by zero.
903-
<pre>
904-
p {
905-
margin: 1em;
906-
margin: calc(1em-2px) calc(1em/0)
907-
}
908-
</pre>
909-
</div>
910-
911-
<p class=issue>Issue: At a later date new operators such as min/max, conditionals, new constants, division by length units etc. may be added.
912-
913-
914-
<p>The expression language is defined by &lsquo;<code class=property>length-expression</code>&rsquo; below:
915-
916-
<pre>
917-
&lt;length> := calc( &lt;length-expression> ) | &lt;atomic-length>
918-
919-
&lt;length-expression> := S* &lt;length-additive-expression> S*
920-
921-
&lt;length-additive-expression> :=
922-
&lt;length-multiplicative-expression> |
923-
&lt;length-additive-expression> S+ '+' S+ &lt;length-multiplicative-expression> |
924-
&lt;length-additive-expression> S+ '-' S+ &lt;length-multiplicative-expression>
925-
926-
&lt;length-multiplicative-expression>
927-
&lt;length-term> |
928-
&lt;length-multiplicative-expression> S* '*' S* &lt;number-term> |
929-
&lt;number-multiplicative-expression> S* '*' S* &lt;length-term> |
930-
&lt;length-multiplicative-expression> S* '/' S* &lt;number-term> |
931-
&lt;length-multiplicative-expression> S+ 'mod' S+ &lt;number-term>
932-
933-
&lt;length-term> := '(' &lt;length-expression> ')' | &lt;atomic-length>
934-
935-
&lt;number-additive-expression> :=
936-
&lt;number-multiplicative-expression> |
937-
&lt;number-additive-expression> S+ '+' S+ &lt;number-multiplicative-expression> |
938-
&lt;number-additive-expression> S+ '-' S+ &lt;number-multiplicative-expression>
939-
940-
&lt;number-multiplicative-expression> :=
941-
&lt;number-term> |
942-
&lt;length-multiplicative-expression> S* '/' S* &lt;length-term> |
943-
&lt;length-multiplicative-expression> S+ 'mod' S+ &lt;length-term>
944-
945-
&lt;number-term> := '(' *S &lt;number-additive-expression> *S ')' | &lt;number>
946-
947-
&lt;atomic-length> := &lt;number>&lt;length-unit>
948-
</pre>
949-
950-
<div class="note">Note that &lsquo;<code class=property>mod</code>&rsquo; is used instead of &lsquo;<code class=css>%</code>&rsquo; for modulus since it is very easy to
951-
get confused about whether &lsquo;<code class=css>%</code>&rsquo; is acting as a unit or an operator. At
952-
least with &lsquo;<code class=property>mod</code>&rsquo; it always causes a parse error &mdash; invalid unit &mdash; in the
953-
otherwise ambiguous cases.
954-
</div>
955-
-->
956904

957905
<h3 id=ltstringgt><span class=secno>6.4. </span>&lt;string&gt;</h3>
958906

0 commit comments

Comments
 (0)