Blink Animations:�The Interpolation Stack
Casually responsible for over half the files in core/animation
smcgruer@, 2019/08/13
Disclaimer
I wasn't kidding about the number of files
$ find renderer/core/animation/ -name *.cc -o -name *.h | wc -l
264
$ find renderer/core/animation/ -name *.cc -o -name *.h | xargs wc -l
...
41426 total
$ find renderer/core/animation/ -name *interpolation* | wc -l
142
$ find renderer/core/animation/ -name *interpolation* | xargs wc -l
...
16229 total
So what is interpolation all about?
The problem with animating CSS (and SVG)
The problem with animating CSS (and SVG)
font-weight: 400;
font-weight: 500;
@ 50%
font-weight: 450;
width: 10px;
width: 50%
@ 20%
width: 8px + 10%;
The problem with animating CSS (and SVG)
font-family: serif;
font-family: emoji;
@ 50%
font-family: ???;
display: block;
display: grid
@ 20%
display: ???
The problem with animating CSS (and SVG)
visibility: visible;
visibility: hidden;
@ 0%
visible
transform: rotate(180deg) translateX(20px)
@ 50%
transform: scale(1.5) rotate(90deg) translateX(10px)
transform: scale(2) rotate(0);
@ 100%
hidden
@ 1%
visible
@ 99%
visible
Blink Interpolation's big secret
Some simple examples
font-weight: 500
InterpolableNumber(500), nullptr
width: 10px
InterpolableList(
InterpolableNumber(10),� InterpolableNumber(0),� …
), NonInterpolableValue(has-percentage)
display: grid
InterpolableList(), NonInterpolableValue(CSSValue*)
How many pixels?
How many percent?
Getting into the weeds
Diving right in
InvalidatableInterpolation (1/4)
InvalidatableInterpolation (2/4)
InvalidatableInterpolation (2/4)
TypedInterpolationValue
InterpolationValue
InterpolationType
InterpolableValue
NonInterpolableValue
PropertySpecificKeyframe
EnsureValidConversion
CSS/SVG Value
InvalidatableInterpolation (3/4)
An aside: InterpolationEnvironment
InvalidatableInterpolation (4/4)
Applying interpolated values
CSSTransformInterpolationType
Finished... right… ?
Additive composition, by the spec
Compute underlying value first
Then apply it to both keyframes before interpolating
Spec authors hate this one weird trick!
We call these the 'underlying fraction'
Additive composition, in the code
composite: 'add'
composite: 'replace'
composite: 'replace'
composite: 'add'
effect_1
effect_2
effect_3
effect_4
composite: 'replace'
composite: 'add'
effect_3
effect_4
Additive composition, in the code
InterpolationType::Composite examples
Things I Didn't Mention (but probably should have)
Open Questions
The End
(Congratulations.)