@@ -339,6 +339,101 @@ Property value examples</h3>
339339 </table>
340340 </div>
341341
342+ <h2 id="combining-values">
343+ Combining Values: Interpolation, Addition, and Accumulation</h2>
344+
345+ Some procedures, for example
346+ <a href="https://www.w3.org/TR/css-transitions/">transitions</a>
347+ and <a href="https://www.w3.org/TR/css-animations/">animations</a> ,
348+ combine two CSS property values.
349+ The following combining operations--
350+ on the two <a>computed values</a> <var> V<sub> a</sub></var> and <var> V<sub> B</sub></var>
351+ yielding the <a>computed value</a> <var> V<sub> result</sub></var> --
352+ are defined:
353+
354+ <dl export>
355+ <dt> <dfn id="interpolation" lt="interpolation | interpolate | value interpolation">interpolation</dfn>
356+ <dd>
357+ Given two property values
358+ <var> V<sub> a</sub></var> and <var> V<sub> B</sub></var> ,
359+ produces an intermediate value
360+ <var> V<sub> result</sub></var>
361+ at a distance of <var> p</var>
362+ along the interval between
363+ <var> V<sub> a</sub></var> and <var> V<sub> a</sub></var>
364+ such that <var> p</var> = 0 produces <var> V<sub> a</sub></var>
365+ and <var> p</var> = 1 produces <var> V</var><sub> end</sub> .
366+
367+ The range of <var> p</var> is (−∞, ∞)
368+ due to the effect of <a>timing functions</a> .
369+ As a result, this procedure must also define
370+ extrapolation behavior for <var> p</var> outside [0, 1] .
371+
372+ <dt> <dfn id="addition" lt="value addition" local-lt="add | addition">addition</dfn>
373+ <dd>
374+ Given two property values
375+ <var> V<sub> a</sub></var> and <var> V<sub> B</sub></var> ,
376+ returns the sum of the two properties,
377+ <var> V</var><sub> result</sub> .
378+ For addition that is not commutative
379+ (for example, matrix multiplication)
380+ <var> V<sub> a</sub></var> represents
381+ the first term of the operation and
382+ <var> V<sub> B</sub></var> represents
383+ the second.
384+
385+ Note: While <a>addition</a>
386+ can often be expressed
387+ in terms of the same weighted sum function
388+ used to define <a>interpolation</a> ,
389+ this is not always the case.
390+ For example, interpolation of transform matrices involves
391+ decomposing and interpolating the matrix components
392+ whilst addition relies on matrix multiplication.
393+
394+ <dt> <dfn id="accumulation" lt="value accumulation" local-lt="accumulate | accumulation">accumulation</dfn>
395+ <dd>
396+ Given two property values
397+ <var> V<sub> a</sub></var> and <var> V<sub> B</sub></var> ,
398+ returns the result, <var> V<sub> result</sub></var> ,
399+ of combining the two operands
400+ such that <var> V<sub> B</sub></var>
401+ is treated as a <em> delta</em> from <var> V<sub> a</sub></var> .
402+ For accumulation that is not commutative
403+ (for example, accumulation of mismatched transform lists)
404+ <var> V<sub> a</sub></var> represents the first term of the operation
405+ and <var> V<sub> B</sub></var> represents the second.
406+
407+ <div class="note">
408+ Note: For many types of animation such as numbers or lengths,
409+ <a>accumulation</a> is defined to be identical
410+ to <a>addition</a> .
411+
412+ A common case where the definitions differ
413+ is for list-based types
414+ where <a>addition</a> may be defined as appending to a list
415+ whilst <a>accumulation</a> may be defined
416+ as component-based addition.
417+ For example, the filter list values ''blur(2)'' and ''blur(3)'' ,
418+ when <a>added</a> together would produce ''blur(2) blur(3)'' ,
419+ but when <a>accumulated</a> would produce ''blur(5)'' .
420+ </div>
421+ </dl>
422+
423+ These operations are only defined on <a>computed values</a> .
424+ (As a result, it is not necessary to define, for example,
425+ how to add a <<length>> value of ''15pt'' with ''5em''
426+ since such values will be resolved to their <a>canonical unit</a>
427+ before being passed to any of the above procedures.)
428+
429+ If a value type does not define a specific procedure for <a>addition</a>
430+ or is defined as <dfn export>not additive</dfn> ,
431+ its <a>addition</a> operation is simply
432+ <var> V<sub> result</sub></var> = <var> V<sub> a</sub></var> .
433+
434+ If a value types does not define a specific procedure for <a>accumulation</a> ,
435+ its <a>accumulation</a> operation is identical to <a>addition</a> .
436+
342437<h2 id="textual-values">
343438Textual Data Types</h2>
344439
@@ -687,6 +782,22 @@ Integers: the <<integer>> type</h3>
687782 The first digit of an integer may be immediately preceded by <css> -</css> or <css> +</css>
688783 to indicate the integer's sign.
689784
785+ <h4 id="combine-integers">
786+ Combination of <<integer>></h4>
787+
788+ <a>Interpolation</a> of <<integer>> is defined as
789+ <var> V</var><sub> result</sub> =
790+ round((1 - <var> p</var> ) × <var> V<sub> a</sub></var> +
791+ <var> p</var> × <var> V<sub> b</sub></var> );
792+ that is, interpolation happens in the real number space
793+ as for <<number>> s, and the result is converted to an <<integer>>
794+ by rounding to the nearest integer,
795+ with values halfway between adjacent integers rounded towards positive infinity.
796+
797+ <a>Addition</a> of <<number>> is defined as
798+ <var> V<sub> result</sub></var> =
799+ <var> V<sub> a</sub></var> + <var> V<sub> b</sub></var>
800+
690801<!--
691802██ ██ ██ ██ ██ ██ ████████ ████████ ████████
692803███ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██
@@ -719,6 +830,18 @@ Real Numbers: the <<number>> type</h3>
719830 do not match <<zero>> ;
720831 only literal <<number-token>> s do.
721832
833+ <h4 id="combine-numbers">
834+ Combination of <<number>></h4>
835+
836+ <a>Interpolation</a> of <<number>> is defined as
837+ <var> V</var><sub> result</sub> =
838+ (1 - <var> p</var> ) × <var> V<sub> a</sub></var> +
839+ <var> p</var> × <var> V<sub> b</sub></var>
840+
841+ <a>Addition</a> of <<number>> is defined as
842+ <var> V<sub> result</sub></var> =
843+ <var> V<sub> a</sub></var> + <var> V<sub> b</sub></var>
844+
722845<h3 id='dimensions'>
723846Numbers with Units: <a>dimension</a> values</h3>
724847
@@ -762,6 +885,20 @@ Compatible Units</h4>
762885 as <a>compatible</a> with the relevant class of <a>dimensions</a> ,
763886 and canonicalize accordingly.
764887
888+ <h4 id="combine-dimensions">
889+ Combination of Dimensions</h4>
890+
891+ <a>Interpolation</a> of <a>compatible</a> <a>dimensions</a>
892+ (for example, two <<length>> values)
893+ is defined as
894+ <var> V</var><sub> result</sub> =
895+ (1 - <var> p</var> ) × <var> V<sub> a</sub></var> +
896+ <var> p</var> × <var> V<sub> b</sub></var>
897+
898+ <a>Addition</a> of <a>compatible</a> <a>dimensions</a> is defined as
899+ <var> V<sub> result</sub></var> =
900+ <var> V<sub> a</sub></var> + <var> V<sub> b</sub></var>
901+
765902<!--
766903█████ ██
767904██ ██ ██
@@ -793,6 +930,18 @@ Percentages: the <<percentage>> type</h3>
793930 (e.g., the width of a <a>containing block</a> ),
794931 or something else.
795932
933+ <h4 id="combine-percentages">
934+ Combination of <<percentage>></h4>
935+
936+ <a>Interpolation</a> of <<percentage>> is defined as
937+ <var> V</var><sub> result</sub> =
938+ (1 - <var> p</var> ) × <var> V<sub> a</sub></var> +
939+ <var> p</var> × <var> V<sub> b</sub></var>
940+
941+ <a>Addition</a> of <<percentage>> is defined as
942+ <var> V<sub> result</sub></var> =
943+ <var> V<sub> a</sub></var> + <var> V<sub> b</sub></var>
944+
796945<h3 id="mixed-percentages">
797946Mixing Percentages and Dimensions</h3>
798947
@@ -837,6 +986,34 @@ Mixing Percentages and Dimensions</h3>
837986 A <number-percentage> will never be added,
838987 as <<number>> and <<percentage>> can't be combined in ''calc()'' .
839988
989+ <h4 id="combine-mixed">
990+ Combination of Percentage and Dimension Mixes</h4>
991+
992+ <a>Interpolation</a> of percengage-dimension value combinations
993+ (e.g. <<length-percentage>> , <<frequency-percentage>> , <<angle-percentage>> , <<time-percentage>>
994+ or equivalent notations)
995+ is defined as
996+ <ul>
997+ <li>
998+ equivalent to <a>interpolation</a> of <<length>>
999+ if both <var> V<sub> a</sub></var> and <var> V<sub> b</sub></var> are pure <<length>> values
1000+
1001+ <li>
1002+ equivalent to <a>interpolation</a> of <<percentage>>
1003+ if both <var> V<sub> a</sub></var> and <var> V<sub> b</sub></var> are pure <<percentage>> values
1004+ <li>
1005+ equivalent to converting both values into a ''calc()'' expression
1006+ representing the sum of the dimension type and a percentage
1007+ (each possibly zero)
1008+ and <a>interpolating</a> each component individually
1009+ (as a <<length>> /<<frequency>> /<<angle>> /<<time>>
1010+ and as a <<percentage>> , respectively)
1011+ </ul>
1012+
1013+ <a>Addition</a> of <<percentage>> is defined
1014+ the same as <a>interpolation</a>
1015+ except by <a>adding</a> each component
1016+ rather than <a>interpolating</a> it.
8401017
8411018<!--
8421019██ ████████ ██ ██ ██████ ████████ ██ ██
@@ -1493,6 +1670,30 @@ Colors: the <<color>> type</h3>
14931670 The <<color>> data type is defined in [[!CSS3COLOR]] .
14941671 UAs that support CSS Color Level 3 or its successor must interpret <<color>> as defined therein.
14951672
1673+ <h4 id="combine-colors">
1674+ Combination of <<color>></h4>
1675+
1676+ <a>Interpolation</a> of <<color>> is defined as
1677+ the independent interpolation of each component
1678+ (red, green, blue, alpha)
1679+ as a <<number>> .
1680+ Interpolation is done between premultiplied colors
1681+ (that is, colors for which the red, green, and blue components specified
1682+ have been multiplied by the alpha).
1683+
1684+ <a>Addition</a> of <<number>> is likewise defined as
1685+ the independent <a>addition</a> of each component
1686+ as a <<number>>
1687+ in premultiplied space.
1688+
1689+ ISSUE: Computed value needs to be able to represent
1690+ combinations of ''currentColor'' and an actual color.
1691+ Consider the value of 'text-emphasis-color' in
1692+ <code> div { text-emphasis: circle; transition: all 2s; }<br>
1693+ div:hover { text-emphasis-color: lime; }<br>
1694+ em { color: red; }</code>
1695+ See <a href="https://github.com/w3c/csswg-drafts/issues/445">Issue 445</a> .
1696+
14961697<!--
14971698████ ██ ██ ███ ██████ ████████
14981699 ██ ███ ███ ██ ██ ██ ██ ██
@@ -1512,6 +1713,13 @@ Images: the <<image>> type</h3>
15121713 UAs that do not yet support CSS Images Level 3
15131714 must interpret <<image>> as <<url>> .
15141715
1716+ <h4 id="combine-images">
1717+ Combination of <<image>></h4>
1718+
1719+ Note: Interpolation of <<image>> is defined in [[css-images-3#interpolation]] .
1720+
1721+ Images are <a>not additive</a> .
1722+
15151723<!--
15161724████████ ███████ ██████ ████ ████████ ████ ███████ ██ ██
15171725██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
@@ -1565,6 +1773,19 @@ Images: the <<image>> type</h3>
15651773 followed by a <<length>> .
15661774 </div>
15671775
1776+ <h4 id="combine-positions">
1777+ Combination of <<position>></h4>
1778+
1779+ <a>Interpolation</a> of <<position>> is defined as
1780+ the independent interpolation of each component (x, y)
1781+ normalized as an offset from the top left corner
1782+ as a <<length-percentage>> .
1783+
1784+ <a>Addition</a> of <<position>> is likewise defined as
1785+ the independent <a>addition</a> each component (x, y)
1786+ normalized as an offset from the top left corner
1787+ as a <<length-percentage>> .
1788+
15681789<h2 id="functional-notations">
15691790Functional Notations</h2>
15701791
0 commit comments