@@ -1492,21 +1492,31 @@ Type Checking</h4>
14921492Computed Value</h4>
14931493
14941494 The computed value of a ''calc()'' expression is the expression
1495- with all components computed,
1496- with all multiplication/division subexpressions resolved,
1497- and with all addition/subtraction subexpressions resolved where both sides are the same type.
1495+ with all components computed.
14981496
14991497 Where percentages are not resolved at computed-value time,
15001498 they are not resolved in ''calc()'' expressions,
1501- e.g. ''calc(100% - 100% + 1em)'' resolves to ''calc(0% + 1em )'' ,
1502- not to ''calc( 1em) '' .
1499+ e.g. ''calc(100% - 100% + 1em)'' resolves to ''calc(1em + 0% )'' ,
1500+ not to ''1em'' .
15031501 If there are special rules for computing percentages in a value
15041502 (e.g. <a href="https://www.w3.org/TR/CSS21/visudet.html#the-height-property">the <css>height</css> property</a> ),
15051503 they apply whenever a ''calc()'' expression contains percentages.
15061504
1507- Note: Thus, the computed value of a ''calc()'' expression can be represented
1508- as either a number
1509- or a tuple of a dimension and a percentage.
1505+ <div class=note>
1506+ Note: The serialization rules do not preserve the structure of the computation,
1507+ so implementations can simplify the expressions
1508+ further than what is required here
1509+ when storing the values internally;
1510+ in particular, all ''calc()'' expressions can be reduced
1511+ to a sum of a <<number>> , a <<percentage>> , and some <<dimension>> s,
1512+ eliminating all multiplication or division,
1513+ and combining identical units.
1514+
1515+ At this time, all units can be absolutized
1516+ to a single unit per type at computed-value time,
1517+ so at that point the ''calc()'' expression can be reduced
1518+ to just a <<number>> , a <<percentage>> , and a single absolute <<dimension>> of the appropriate type.
1519+ </div>
15101520
15111521 If this resolution process results in only a single value
15121522 (one <<number>> , one <<dimension>> , or one <<percentage>> ),
@@ -1583,23 +1593,23 @@ Serialization</h4>
15831593
15841594 * Replacing nested ''calc()'' values with parentheses containing their contents
15851595 * Resolving all multiplications and divisions
1586- * Combining compatible units
1596+ * Combining identical units
15871597
1588- (Which units are compatible can vary based on what stage of the value computation pipeline it's in .
1589- For example, as a specified value, ''px '' and ''em '' are incompatible;
1590- as a computed value, they're compatible.)
1598+ Note: The value-computation process can transform disparate units into identical ones .
1599+ For example, ''em '' and ''px '' are obviously different at specified-value time,
1600+ but at computed- value time they're both absolutized to ''px'' .
15911601
1592- The result must be a summation of unique incompatible units.
1602+ The result must be a summation of unique units.
15931603 (Terms with a value of zero <strong> must</strong> be preserved in this summation.)
15941604
15951605 2. Serialize as a ''calc()'' containing the summation,
15961606 with the units ordered <a>ASCII case-insensitive</a> alphabetically,
1597- numbers coming before all units,
1598- and percentages coming after all units.
1607+ the number (if present) coming before all units,
1608+ and the percentage (if present) coming after all units.
15991609
16001610 <div class="example">
1601- For example, ''calc(20px + 30px)'' would first simplify to a single ''px'' value,
1602- then serialize as just ''50px'' .
1611+ For example, ''calc(20px + 30px)'' would serialize as ''calc(50px)'' as a specified value,
1612+ or as ''50px'' as a computed value .
16031613
16041614 A value like ''calc(20px + 0%)'' would serialize as ''calc(20px + 0%)'' ,
16051615 maintaining both terms in the serialized value.
0 commit comments