Skip to content

Commit 4f4cbad

Browse files
committed
Make calc() sometimes have a resolved type of <integer>.
1 parent f8a3d0e commit 4f4cbad

1 file changed

Lines changed: 30 additions & 17 deletions

File tree

css3-values/Overview.src.html

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -883,11 +883,12 @@ <h3 id="calc-notation">
883883
as component values. The ''calc()'' expression represents the result of the
884884
mathematical calculation it contains, using standard operator precedence
885885
rules. It can be used wherever
886-
<code>&lt;length&gt;</code>,
887-
<code>&lt;frequency&gt;</code>,
888-
<code>&lt;angle&gt;</code>,
889-
<code>&lt;time&gt;</code>, or
890-
<code>&lt;number&gt;</code>
886+
<var>&lt;length&gt;</var>,
887+
<var>&lt;frequency&gt;</var>,
888+
<var>&lt;angle&gt;</var>,
889+
<var>&lt;time&gt;</var>,
890+
<var>&lt;number&gt;</var>, or
891+
<var>&lt;integer></var>
891892
values are allowed.</p>
892893

893894
<p>
@@ -1006,18 +1007,24 @@ <h4 id='calc-syntax'>
10061007
<h4 id='calc-type-checking'>
10071008
Type Checking</h4>
10081009

1009-
<p>A math expression has a <dfn>resolved type</dfn>, which is one of
1010-
<var>&lt;length></var>, <var>&lt;frequency></var>, <var>&lt;angle></var>, <var>&lt;time></var>, or
1011-
<var>&lt;number></var>. The <i>resolved type</i> must be valid for where the
1012-
expression is placed; otherwise, the expression is invalid.
1013-
The <i>resolved type</i> of the expression is determined by the
1014-
types of the values it contains. <code>NUMBER</code> tokens
1015-
are of type <var>&lt;number></var>. A <code>DIMENSION</code> token's type is given
1016-
by its unit (''cm'' is <var>&lt;length></var>, ''deg'' is <var>&lt;angle></var>, etc.).
1017-
If percentages are accepted in the context in which the expression
1018-
is placed, a <code>PERCENTAGE</code> token has the type of the value that
1019-
percentages are relative to; otherwise, a math expression containing
1020-
percentages is invalid.</p>
1010+
<p>
1011+
A math expression has a <dfn>resolved type</dfn>, which is one of
1012+
<var>&lt;length></var>,
1013+
<var>&lt;frequency></var>,
1014+
<var>&lt;angle></var>,
1015+
<var>&lt;time></var>,
1016+
<var>&lt;number></var>, or
1017+
<var>&lt;integer></var>.
1018+
The <i>resolved type</i> must be valid for where the expression is placed;
1019+
otherwise, the expression is invalid.
1020+
The <i>resolved type</i> of the expression is determined by the types of the values it contains.
1021+
<code>NUMBER</code> tokens are of type <var>&lt;number></var>.
1022+
A <code>DIMENSION</code> token's type is given by its unit
1023+
(''cm'' is <var>&lt;length></var>, ''deg'' is <var>&lt;angle></var>, etc.).
1024+
If percentages are accepted in the context in which the expression is placed,
1025+
a <code>PERCENTAGE</code> token has the type of the value that percentages are relative to;
1026+
otherwise,
1027+
a math expression containing percentages is invalid.</p>
10211028

10221029
<p>Operators form sub-expressions, which gain types based on their arguments.
10231030
To make expressions simpler, operators have restrictions on the
@@ -1043,6 +1050,12 @@ <h4 id='calc-type-checking'>
10431050
(as purely-numeric expressions can be evaluated without any additional
10441051
information at parse time).</p>
10451052

1053+
<p>
1054+
If the type of the result,
1055+
after resolving all subexpressions,
1056+
is an integral <code>&lt;number></code>,
1057+
the calc()&apos;s resolved type is <code>&lt;integer></code>.
1058+
10461059
<h4 id='calc-range'>
10471060
Range Checking</h4>
10481061

0 commit comments

Comments
 (0)