|
25 | 25 |
|
26 | 26 | <h1 id=css3-template>CSS3 Values and Units</h1> |
27 | 27 |
|
28 | | - <h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 9 August 2010</h2> |
| 28 | + <h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 10 August 2010</h2> |
29 | 29 |
|
30 | 30 | <dl> |
31 | 31 | <dt>This version: |
32 | 32 |
|
33 | 33 | <dd><a |
34 | | - href="http://www.w3.org/TR/2010/ED-css3-values-20100809">http://www.w3.org/TR/2010/ED-css3-values-20100809</a> |
| 34 | + href="http://www.w3.org/TR/2010/ED-css3-values-20100810">http://www.w3.org/TR/2010/ED-css3-values-20100810</a> |
35 | 35 |
|
36 | 36 | <dt>Latest version: |
37 | 37 |
|
@@ -860,57 +860,58 @@ <h4 id=the-calc-min-and-max-functions><span class=secno>6.3.3. </span>The |
860 | 860 | <pre> |
861 | 861 | S : calc | min | max; |
862 | 862 | calc : "calc(" S* sum ")" S*; |
863 | | -min : "min(" S* sum [ "," S* sum ]* )"" S*; |
864 | | -max : "max(" S* sum [ "," S* sum ]* ")" S*; |
865 | | -sum : product [ S+ [ "+" | "-" ] 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*; |
| 863 | +min : "min(" S* sum [ "," S* sum ]* ")" S*; |
875 | 864 | max : "max(" S* sum [ "," S* sum ]* ")" S*; |
876 | 865 | sum : product [ [ "+" | "-" ] S* product ]*; |
877 | 866 | product : unit [ [ "*" | "/" | "mod" ] S* unit ]*; |
878 | 867 | unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* | |
879 | 868 | min | max | "(" S* sum ")" S* ]; |
880 | 869 | </pre> |
881 | | ---> |
882 | 870 |
|
883 | | - <p>Division by zero is a parse error. <!-- |
884 | | -<p>Values inside a calc() expression must all be either (a) |
885 | | -numbers or (b) legal values for the property, or values that |
886 | | -would be legal if it weren't for range restrictions (such |
887 | | -as the restriction that ‘<code class=property>width</code>’ accepts only positive values). |
888 | | ---> |
889 | | - |
890 | | - |
891 | | - <p>The semantic constraints are as follows: The context of the expression |
892 | | - imposes a <em>target type</em>, which is one of length, frequency, angle, |
893 | | - time, or number. Any PERCENTAGE token in the expression has the target |
894 | | - type. The NUMBER tokens are of type number, and the DIMENSION tokens have |
895 | | - types of their units (‘<code class=property>cm</code>’ is |
896 | | - length, ‘<code class=property>deg</code>’ is angle etc.). At |
897 | | - each operator, the types of the left and right side have to be compared |
898 | | - and, if compatible, they yield a <em>result type</em>, roughly as follows |
899 | | - (the following ignores precedence rules on the operators for simplicity): |
| 871 | + <p>The context of the expression imposes a target type, which is one of |
| 872 | + length, frequency, angle, time, or number. NUMBER tokens are of type |
| 873 | + number. DIMENSION tokens have types of their units (‘<code |
| 874 | + class=property>cm</code>’ is length, ‘<code |
| 875 | + class=property>deg</code>’ is angle etc.); any DIMENSION whose type |
| 876 | + does not match the target type is not allowed and must be a parse error. |
| 877 | + If percentages are accepted in that context and convertible to the target |
| 878 | + type, a PERCENTAGE token in the expression has the target type; otherwise |
| 879 | + percentages are not allowed and must be a parse error. |
| 880 | + |
| 881 | + <p>To make expressions simpler, operators have restriction on the types |
| 882 | + they accept. At each operator, the types of the left and right side have |
| 883 | + to be checked for these restrictions. If compatible, they return roughly |
| 884 | + as follows (the following ignores precedence rules on the operators for |
| 885 | + simplicity): |
900 | 886 |
|
901 | 887 | <ol> |
902 | 888 | <li>At ",", "+", "-":<br> |
903 | 889 | check: both sides have the same type<br> |
904 | 890 | return: that type |
905 | 891 |
|
906 | 892 | <li>At "*":<br> |
907 | | - check: at least one side is "number" return: the type of the other side |
| 893 | + check: at least one side is "number" <br> |
| 894 | + return: the type of the other side |
908 | 895 |
|
909 | 896 | <li>At "/":<br> |
910 | 897 | check: right side is "number"<br> |
911 | 898 | return: the type of the left side |
912 | 899 | </ol> |
913 | 900 |
|
| 901 | + <p>Division by zero is a parse error. |
| 902 | + |
| 903 | + <p>The value resulting from an expression must be clamped to the range |
| 904 | + allowed in the target context. |
| 905 | + |
| 906 | + <div class=example> These two are equivalentequivalent to ‘<code |
| 907 | + class=css>width: 0px</code>’ since widths smaller than 0px are not |
| 908 | + allowed. |
| 909 | + <pre> |
| 910 | +width: calc(5px - 10px); |
| 911 | +width: 0px; |
| 912 | +</pre> |
| 913 | + </div> |
| 914 | + |
914 | 915 | <p>Given the complexities of ‘<code |
915 | 916 | class=property>width</code>’ and ‘<code |
916 | 917 | class=property>height</code>’ on table cells and table elements, |
|
0 commit comments