@@ -1603,8 +1603,11 @@ Mathematical Expressions: ''calc()'', ''min()'', and ''max()''</h3>
16031603 <<frequency>> ,
16041604 <<angle>> ,
16051605 <<time>> ,
1606+ <<flex>> ,
1607+ <<resolution>> ,
16061608 <<percentage>> ,
1607- or <<number>>
1609+ <<number>> ,
1610+ or <<integer>>
16081611 values are allowed.
16091612 Components of a [=math function=] can be literal values,
16101613 other [=math functions=] ,
@@ -1700,7 +1703,7 @@ Type Checking</h4>
17001703 A [=math function=] can be many possible types,
17011704 such as <<length>> , <<number>> , etc.,
17021705 depending on the expression it contains,
1703- as defined in [[#type-checking-exprs]] .
1706+ as defined below .
17041707 It can be used anywhere a value of that type is allowed.
17051708
17061709 <div class=example>
@@ -1715,42 +1718,6 @@ Type Checking</h4>
17151718 (It gets rounded to the nearest integer,
17161719 as specified in [[#calc-range]] .)
17171720
1718- Note: Because <<number-token>> s are always interpreted as <<number>> s or <<integer>> s,
1719- "unitless 0" <<length>> s aren't supported in [=math functions=] .
1720- That is, ''width: calc(0 + 5px);'' is invalid,
1721- because it's trying to add a <<number>> to a <<length>> ,
1722- even though both ''width: 0;''
1723- and ''width: 5px;''
1724- are valid.
1725-
1726- If percentages are accepted in the context in which the expression is placed,
1727- and they are defined to be relative to another type besides <<number>> ,
1728- a <<percentage-token>> is treated as that type.
1729- For example, in the 'width' property, percentages have the <<length>> type.
1730- A percentage only has the <<percentage>> type if in that context
1731- <<percentage>> values are not used-value compatible with any other type.
1732- If percentages are not normally allowed in place of the ''calc()'' ,
1733- then a ''calc()'' expression containing percentages is invalid in that context.
1734-
1735- Note: Note that <<percentage>> s relative to <<number>> s,
1736- such as in 'opacity' ,
1737- are not allowed in ''calc()'' .
1738- Allowing this would cause significant problems with "unit algebra"
1739- (allowing multiplication/division of <<dimension>> s),
1740- and in every case so far,
1741- doesn't provide any new functionality.
1742- (For example, ''opacity: 25%'' is identical to ''opacity: .25'' ;
1743- it's just a trivial syntax transform.)
1744-
1745- Note: Altho there are a few properties in which a bare <<number>>
1746- becomes a <<length>> at used-value time
1747- (specifically, 'line-height' and 'tab-size' ),
1748- <<number>> s never become "length-like" in ''calc()'' .
1749- They always stay as <<number>> s.
1750-
1751- <h5 id="type-checking-exprs">
1752- Type-Checking Expressions</h5>
1753-
17541721 Operators form sub-expressions, which gain types based on their arguments.
17551722 In previous versions of this specification,
17561723 multiplication and division were limited in what arguments they could take,
@@ -1784,18 +1751,38 @@ Type-Checking Expressions</h5>
17841751 the entire [=math function=] is invalid.
17851752 Otherwise, the sub-expression's [=CSSNumericValue/type=] is the returned type.
17861753
1787- * The [=CSSNumericValue/type=] of a literal
1788- is the result of [=creating a type=]
1789- from the literal's unit,
1790- if it's a <<dimension>> ,
1791- or from "number"
1792- if it's a <<number>> .
1793- For <<percentage>> s,
1794- if they're relative to another type
1795- (as defined in the previous section),
1796- their type is [=create a type|created=]
1797- from the [=canonical unit=] of the type they're resolved to;
1798- otherwise it's [=create a type|created=] from "percentage".
1754+ * Anything else is a terminal value,
1755+ whose [=CSSNumericValue/type=] is determined based on its CSS type:
1756+
1757+ <dl class=switch>
1758+ : <<number>>
1759+ : <<integer>>
1760+ :: [=CSSNumericValue/type=] is «[ ] » (empty map)
1761+ : <<length>>
1762+ :: [=CSSNumericValue/type=] is «[ "length" → 1 ] »
1763+ : <<angle>>
1764+ :: [=CSSNumericValue/type=] is «[ "angle" → 1 ] »
1765+ : <<time>>
1766+ :: [=CSSNumericValue/type=] is «[ "time" → 1 ] »
1767+ : <<frequency>>
1768+ :: [=CSSNumericValue/type=] is «[ "frequency" → 1 ] »
1769+ : <<resolution>>
1770+ :: [=CSSNumericValue/type=] is «[ "resolution" → 1 ] »
1771+ : <<flex>>
1772+ :: [=CSSNumericValue/type=] is «[ "flex" → 1 ] »
1773+ : <<percentage>>
1774+ ::
1775+ If, in the context in which the [=math function=] is placed,
1776+ <<percentage>> s are resolved relative to another type of value
1777+ (such as in 'width' , where <<percentage>> is resolved against a <<length>> ),
1778+ and that other type is <em> not</em> <<number>> ,
1779+ the [=CSSNumericValue/type=] is determined as the other type.
1780+
1781+ Otherwise,
1782+ [=CSSNumericValue/type=] is «[ "percent" → 1 ] ».
1783+ : anything else
1784+ :: The [=math function=] is invalid.
1785+ </dl>
17991786
18001787 * The [=CSSNumericValue/type=] of a ''calc()'' expression
18011788 is the [=CSSNumericValue/type=] of its contained expression.
@@ -1827,6 +1814,34 @@ Type-Checking Expressions</h5>
18271814 For example, ''calc(5px - 5px + 10s)'' and ''calc(0 * 5px + 10s)'' are both invalid
18281815 due to the attempt to add a length and a time.
18291816
1817+ Note: Note that <<percentage>> s relative to <<number>> s,
1818+ such as in 'opacity' ,
1819+ are not <em> combinable</em> with those numbers--
1820+ ''opacity: calc(.25 + 25%)'' is invalid.
1821+ Allowing this would cause significant problems with "unit algebra"
1822+ (allowing multiplication/division of <<dimension>> s),
1823+ and in every case so far,
1824+ doesn't provide any new functionality.
1825+ (For example, ''opacity: 25%'' is identical to ''opacity: .25'' ;
1826+ it's just a trivial syntax transform.)
1827+ You can still perform other operations with them,
1828+ such as ''opacity: calc(100% / 3);'' ,
1829+ which is valid.
1830+
1831+ Note: Because <<number-token>> s are always interpreted as <<number>> s or <<integer>> s,
1832+ "unitless 0" <<length>> s aren't supported in [=math functions=] .
1833+ That is, ''width: calc(0 + 5px);'' is invalid,
1834+ because it's trying to add a <<number>> to a <<length>> ,
1835+ even though both ''width: 0;''
1836+ and ''width: 5px;''
1837+ are valid.
1838+
1839+ Note: Altho there are a few properties in which a bare <<number>>
1840+ becomes a <<length>> at used-value time
1841+ (specifically, 'line-height' and 'tab-size' ),
1842+ <<number>> s never become "length-like" in ''calc()'' .
1843+ They always stay as <<number>> s.
1844+
18301845<h4 id='calc-computed-value'>
18311846Computed Value</h4>
18321847
0 commit comments