@@ -1334,6 +1334,11 @@ <h3 id=calc-notation><span class=secno>8.1. </span> Mathematical
13341334 href ="#time-value "> < var > <time> </ var > </ a > , < a
13351335 href ="#number-value "> < var > <number> </ var > </ a > , or < a
13361336 href ="#integer-value "> < var > <integer> </ var > </ a > values are allowed.
1337+ Components of a ‘< a href ="#calc "> < code class =css > calc()</ code > </ a > ’
1338+ expression can be literal values, ‘< a href ="#attr "> < code
1339+ class =css > attr()</ code > </ a > ’ expressions, or < a
1340+ href ="#percentage-value "> < var > <percentage> </ var > </ a > values that
1341+ resolve to one of the preceding types.
13371342
13381343 < p > The computed value of a calc() expression is the expression with all
13391344 components computed, with all multiplication/division subexpressions
@@ -1420,8 +1425,9 @@ <h4 id=calc-syntax><span class=secno>8.1.1. </span> Syntax</h4>
14201425math : calc S*;
14211426calc : "calc(" S* sum S* ")";
14221427sum : product [ S+ [ "+" | "-" ] S+ product ]*;
1423- product : unit [ S* [ "*" | "/" ] S* unit ]*;
1424- unit : ["+"|"-"]? [ NUMBER | DIMENSION | PERCENTAGE | "(" S* sum S* ")" ];</ pre >
1428+ product : unit [ S* [ "*" S* unit | "/" S* NUMBER ] ]*;
1429+ attr : "attr(" S* wqname [ S+ type-keyword ]? S* [ "," [ unit | calc ] S* ]? ")";
1430+ unit : [ NUMBER | DIMENSION | PERCENTAGE | "(" S* sum S* ")" | attr ];</ pre >
14251431
14261432 < p class =note > Note that the grammar requires spaces around binary ‘< code
14271433 class =css > +</ code > ’ and ‘< code class =css > -</ code > ’ operators. The
@@ -1463,12 +1469,15 @@ <h4 id=calc-type-checking><span class=secno>8.1.2. </span> Type Checking</h4>
14631469 href ="#resolved-type "> < i > resolved type</ i > </ a > of the expression is
14641470 determined by the types of the values it contains. < a
14651471 href ="#number "> < code > NUMBER</ code > </ a > tokens are of type < a
1466- href ="#number-value "> < var > <number> </ var > </ a > . A < a
1472+ href ="#number-value "> < var > <number> </ var > </ a > or < a
1473+ href ="#integer-value "> < var > <integer> </ var > </ a > . A < a
14671474 href ="#dimension "> < code > DIMENSION</ code > </ a > token's type is given by its
14681475 unit (‘< code class =css > cm</ code > ’ is < a
14691476 href ="#length-value "> < var > <length> </ var > </ a > , ‘< a href ="#deg "> < code
14701477 class =css > deg</ code > </ a > ’ is < a
1471- href ="#angle-value "> < var > <angle> </ var > </ a > , etc.). If percentages are
1478+ href ="#angle-value "> < var > <angle> </ var > </ a > , etc.). An ‘< a
1479+ href ="#attr "> < code class =css > attr()</ code > </ a > ’ expression's type is
1480+ given by its < var > <type-or-unit> </ var > argument. If percentages are
14721481 accepted in the context in which the expression is placed, a < a
14731482 href ="#percentage "> < code > PERCENTAGE</ code > </ a > token has the type of the
14741483 value that percentages are relative to; otherwise, a math expression
0 commit comments