Skip to content

Commit ab8fcae

Browse files
Anders Hartvoll Ruudbirtles
authored andcommitted
[css + web-animations] Handle getKeyframes for CSSAnimations
In css-animations-2, instead of generating keyframes resembling computed keyframes, generate specified keyframes. Computing the keyframes at keyframe-creation-time creates too many questions regarding when/how property values inside the keyframes are computed. We can instead rely on the existing process for calculating computed keyframes, and apply that process at the time getKeyframes is called. This means that var() references (and dependencies in general, such as 'em' units) remain until computed-keyframe-time. This isn't a problem for shorthand expansion at keyframe-creation-time: if there's a var() in a shorthand, it expands using the "pending substitution value" [1] for its longhands. We can continue to resolve logical properties to physical at keyframe- creation-time as well, assuming 'direction' and 'writing-mode' are not allowed in keyframes. (FWIW, it's not allowed in Blink, but I'm not sure if this is spec'd). In web-animations-1, in the algorithm for getKeyframes, we either use the specified keyframes (+ compute missing offset) as the source, or the computed keyframes, depending on circumstance. This "circumstance" could definitely be tightened up a bit (instead of referring to whether or not calls to setKeyframes have taken place), but it probably makes sense to do this as a whole for all the "tainting" behavior described by css-animations-2 (Animations chapter), so I haven't tried to address that here. I'm not sure if we need to explicitly add somewhere that the computed keyframes contains the necessary offset/easing/composite values, or if it's already "understood" that these exist also for computed keyframes. (I didn't make a change here). Finally, the fact that getKeyframes returns objects listed as "dictionary ComputedKeyframe" is a bit awkward, since it's not consistent with the spec's "main" definition of computed keyframes. We should probably rename it. [1] https://drafts.csswg.org/css-variables/#pending-substitution-value
1 parent 8158958 commit ab8fcae

2 files changed

Lines changed: 18 additions & 25 deletions

File tree

css-animations-2/Overview.bs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ and the position of the animation in |element|'s 'animation-name' list,
299299
1. Iterate over all declarations in the keyframe block and
300300
add them to |keyframe| such that:
301301
302-
* All variable references are resolved to their current values.
303-
304302
* Each shorthand property is expanded to its longhand
305303
subproperties.
306304
@@ -318,9 +316,7 @@ and the position of the animation in |element|'s 'animation-name' list,
318316
have already added at this same |keyframe offset|,
319317
they should be skipped.
320318
321-
* All property values are replaced with their computed values.
322-
323-
1. Add each physical longhand property name that was added to |keyframe|
319+
1. Add each property name that was added to |keyframe|
324320
to |animated properties|.
325321
326322
1. If there is no keyframe in |keyframes| with offset 0,
@@ -363,20 +359,6 @@ the behavior for some edge cases.
363359
We should verify what current implementations do and possible remove the
364360
requirement to iterate in reverse.
365361
366-
Issue: In practice, implementations will likely maintain specified values and
367-
variable references internally and only resolve them to computed values when
368-
{{KeyframeEffect/getKeyframes()}} is called on a {{KeyframeEffect}}
369-
associated with a {{CSSAnimation}}
370-
(and, more specifically, a {{CSSAnimation}} whose effect has not been replaced
371-
and whose keyframes have not been overridden
372-
using {{KeyframeEffect/setKeyframes()}}).
373-
It is not clear that soing so would produce an observable difference in
374-
behavior, however.
375-
If it does, the above procedure might need to be adjusted so that the
376-
requirement to expand variables and convert to property values to computed
377-
values is limited to the result of {{KeyframeEffect/getKeyframes()}} and
378-
not the internal representation of keyframes.
379-
380362
## The 'animation-duration' property ## {#animation-duration}
381363
382364
The 'animation-duration' property specifies the [=iteration duration=]

web-animations-1/Overview.bs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5049,9 +5049,21 @@ interface KeyframeEffect : AnimationEffect {
50495049
used to prepare the result of this method is defined in prose below:
50505050

50515051
1. Let <var>result</var> be an empty sequence of objects.
5052-
1. Let <var>keyframes</var> be the result of applying the procedure to
5053-
<a>compute missing keyframe offsets</a> to the <a>keyframes</a>
5054-
for this <a>keyframe effect</a>.
5052+
1. Let <var>keyframes</var> be one of the following:
5053+
5054+
1. If this <a>keyframe effect</a> is associated with a
5055+
{{CSSAnimation}}, and its <a>keyframes</a> have not been replaced
5056+
by a successful call to {{KeyframeEffect/setKeyframes()}};
5057+
the <a>computed keyframes</a> for this <a>keyframe effect</a>.
5058+
5059+
1. Otherwise, the result of applying the procedure
5060+
<a>compute missing keyframe offsets</a> to the <a>keyframes</a>
5061+
for this <a>keyframe effect</a>.
5062+
5063+
Note: We return <a>computed keyframes</a> for CSS Animations
5064+
because not all keyframes specified in CSS can be
5065+
represented by a dictionary.
5066+
50555067
1. For each <var>keyframe</var> in <var>keyframes</var>
50565068
perform the following steps:
50575069

@@ -5077,9 +5089,8 @@ interface KeyframeEffect : AnimationEffect {
50775089
keyframe-specific <a>timing function</a>, and
50785090
<a>keyframe-specific composite operation</a>
50795091
values of <var>keyframe</var>.
5080-
1. For each animation property-value pair specified on
5081-
<var>keyframe</var>, <var>declaration</var>, perform the following
5082-
steps:
5092+
1. For each animation property-value pair in <var>keyframe</var>,
5093+
<var>declaration</var>, perform the following steps:
50835094

50845095
1. Let <var>property name</var> be the result of applying the
50855096
<a>animation property name to IDL attribute name</a> algorithm

0 commit comments

Comments
 (0)