Skip to content

Commit 6099974

Browse files
authored
Improve wording on web-animation integrations (w3c#870)
* Improve wording on how worklet animation interacts with web-animations (issue w3c#870) * Update web-animations spec link to be https://drafts.csswg.org which is more recent * Add section to deal with addition of "replace state" in Web animations. * Add issue to indicate our current shortcoming for async operations. * lots of small fixes
1 parent 70b9382 commit 6099974

File tree

1 file changed

+81
-58
lines changed

1 file changed

+81
-58
lines changed

css-animationworklet/Overview.bs

+81-58
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ urlPrefix: http://w3c.github.io/html/infrastructure.html#; type: dfn;
3939
text: structureddeserialize
4040
urlPrefix: https://www.w3.org/TR/css3-transitions/#; type: dfn;
4141
text: animatable properties
42-
urlPrefix: https://w3c.github.io/web-animations/#; type: dfn;
42+
urlPrefix: https://drafts.csswg.org/web-animations#; type: dfn;
4343
url: the-documents-default-timeline; text: default document timeline
4444
url: concept-animation; text: animation
4545
text: effect value
@@ -62,6 +62,11 @@ urlPrefix: https://w3c.github.io/web-animations/#; type: dfn;
6262
text: running
6363
text: composite operation
6464
text: animation class
65+
text: replace state
66+
text: active
67+
text: persisted
68+
text: removed
69+
6570
urlPrefix: https://w3c.github.io/web-animations/level-2/#;
6671
type: dfn;
6772
text: group effect
@@ -338,8 +343,8 @@ and owns the instance specific state such as animation effect and timeline. It c
338343

339344
- An <dfn>animator effect</dfn> which is an <a>animation effect</a>.
340345

341-
- An <dfn>animator current time</dfn> which is the corresponding <a>worklet animation</a>'s current
342-
time.
346+
- An <dfn>animator current time</dfn> which is equivalent to its corresponding
347+
<a>worklet animation</a>'s current time.
343348

344349
- An <dfn>animator timeline</dfn> which is a <a>timeline</a>.
345350

@@ -518,9 +523,9 @@ either <dfn>frame-requested</dfn> or <dfn>frame-current</dfn>. It is initially s
518523
<a>frame-current</a>. Different circumstances can cause the <a>animation requested flag</a> to be
519524
set to <a>frame-requested</a>. These include the following:
520525
- Changes in the <a>current time</a> of the animator's <a>timeline</a>
521-
- Changes in the <a>current time</a> of the animator's corresponding <a>Worklet Animation</a>
526+
- Changes in the <a>current time</a> of the animator's corresponding <a>worklet animation</a>
522527

523-
[[#running-animators]] resets the <a>animation requested flag</a> on animators to
528+
Performing <a>run animators</a> resets the <a>animation requested flag</a> on animators to
524529
<a>frame-current</a>.
525530

526531

@@ -531,8 +536,8 @@ Web Animations Integration {#web-animation-integration}
531536
Worklet Animation {#worklet-animation-desc}
532537
-------------------------------------------
533538
<dfn>Worklet animation</dfn> is a kind of <a>animation</a> that delegates the animation playback to
534-
an <a>animator instance</a>. It controls the lifetime and playback state of its corresponding
535-
<a>animator instance</a>.
539+
an <a>animator instance</a>. It controls the lifetime and playback state of its <a>corresponding
540+
animator instance</a>.
536541

537542
Being an <a>animation</a>, <a>worklet animation</a> has an <a>animation effect</a> and a
538543
<a>timeline</a>. However unlike other animations the worklet animation's <a>current time</a> does
@@ -543,14 +548,33 @@ animation's output.
543548

544549
<a>Worklet animation</a> has the following properties in addition to the {{Animation}} interface:
545550
- an <dfn>animation animator name</dfn> which identifies its <a>animator definition</a>.
546-
- a <dfn>serialized options</dfn> which is serializable object that is used when
551+
- a <dfn>serialized options</dfn> which is serializable options object that is used when
547552
constructing a new animator instance.
553+
- a <dfn>corresponding animator instance</dfn> which is an <a>Animator Instance</a>.
554+
555+
556+
The existence of <a>corresponding animator instance</a> for a <a>worklet animation</a> depends on
557+
the animation <a>play state</a>. See [[#web-animation-overrides]] for details on when and this
558+
correspondence changes.
559+
560+
<xmp class='idl'>
561+
[Exposed=Window,
562+
Constructor (DOMString animatorName,
563+
optional (AnimationEffect or sequence<AnimationEffect>)? effects = null,
564+
optional AnimationTimeline? timeline,
565+
optional any options)]
566+
interface WorkletAnimation : Animation {
567+
readonly attribute DOMString animatorName;
568+
};
569+
570+
</xmp>
571+
548572

549573
<figure>
550574
<img src="img/WorkletAnimation-timing-model.svg" width="600"
551575
alt="Overview of the WorkletAnimation timing model.">
552576
<figcaption>
553-
Overview of the WorkletAnimation timing model. <br>
577+
Overview of the worklet animation timing model. <br>
554578

555579
The animation current time is input to the animator instance, which produces a local time value
556580
for the animation effect. If the animator instance is running in a parallel global scope the
@@ -564,23 +588,10 @@ animation's output.
564588
Creating a Worklet Animation {#creating-worklet-animation}
565589
-----------------------------------------------------------
566590

567-
<xmp class='idl'>
568-
[Exposed=Window,
569-
Constructor (DOMString animatorName,
570-
optional (AnimationEffect or sequence<AnimationEffect>)? effects = null,
571-
optional AnimationTimeline? timeline,
572-
optional any options)]
573-
interface WorkletAnimation : Animation {
574-
readonly attribute DOMString animatorName;
575-
};
576-
577-
</xmp>
578-
579-
580591
<div algorithm="create-worklet-animation">
581592
<dfn constructor for=WorkletAnimation>WorkletAnimation(|animatorName|, |effects|, |timeline|, |options|)</dfn>
582593

583-
Creates a new {{WorkletAnimation}} object using the following procedure.
594+
Creates a new {{WorkletAnimation}} object using the following procedure:
584595

585596
1. Let |workletAnimation| be a new {{WorkletAnimation}} object.
586597

@@ -597,19 +608,22 @@ Creates a new {{WorkletAnimation}} object using the following procedure.
597608
: Otherwise,
598609
:: Let |effect| be undefined.
599610

600-
4. Run the procedure to <a>set the target effect of an animation</a> on |workletAnimation|
601-
passing |effect| as the new effect.
602-
603-
5. Let |serializedOptions| be the result of <a>StructuredSerialize</a>(|options|).
611+
4. Let |serializedOptions| be the result of <a>StructuredSerialize</a>(|options|).
604612
Rethrow any exceptions.
605613

606-
6. Set the <a>serialized options</a> of |workletAnimation| to |serializedOptions|.
614+
5. Set the <a>serialized options</a> of |workletAnimation| to |serializedOptions|.
615+
616+
6. Set the <a>animation animator name</a> of |workletAnimation| to |animatorName|.
617+
618+
7. Run the procedure to <a>set the target effect of an animation</a> on |workletAnimation|
619+
passing |effect| as the new effect. Note that this may trigger action to
620+
<a>set animator instance of worklet animation</a>. See [[#web-animation-overrides]] for more
621+
details.
607622

608-
7. Set the <a>animation animator name</a> of |workletAnimation| to |animatorName|.
609623
</div>
610624

611625

612-
Worklet Animation timing model {#timing-model}
626+
Worklet Animation Timing Model {#timing-model}
613627
------------------------------------
614628

615629
This section describes how <a>worklet animation's</a> timing model differs from other
@@ -653,19 +667,44 @@ Issue(811): Come with appropriate mechanism's for <a>animator instance</a> to ge
653667
it can react appropriately.
654668

655669

656-
Interaction with Animator Instances {#worklet-animation-animator-instances}
670+
Web Animations Overrides {#web-animation-overrides}
657671
-----------------------------------
658672

659-
A <a>worklet animation</a> corresponds to at most one <a>animator instance</a> at any time, and may
660-
have no current corresponding <a>animator instance</a>. The correspondance of an <a>animator
661-
instance</a> for a <a>worklet animation</a> depends on the animation <a>play state</a>.
673+
When a given worklet animation's <a>play state</a> changes from <a>idle</a> to <a>finished</a>,
674+
<a>running</a>, or <a>paused</a>, run the procedure to <a>associate animator instance of worklet
675+
animation</a> given the worket animation as |workletAnimation|.
676+
677+
When a given worklet animation's <a>play state</a> changes from <a>finished</a>, <a>running</a> or
678+
<a>paused</a> to <a>idle</a>, run the procedure to <a>disassociate animator
679+
instance of worklet animation</a> given the worklet animation as |workletAnimation|.
680+
681+
When a given worklet animation's <a>replace state</a> changes from <a>active</a> to either
682+
<a>persisted</a> or <a>removed</a> run the procedure to <a>disassociate animator
683+
instance of worklet animation</a> given the worklet animation as |workletAnimation|.
684+
685+
686+
Issue: In web-animation play state is updated before the actual change in particular some operations
687+
such as play() are asynchronous. We should really invoke these Animator related operation after the
688+
appropriate animation operation is complete instead of when play state has changed. This will
689+
require either finding (or introducing) q new hook in web animation or having override for each such
690+
async operation.
691+
692+
693+
When the procedure to <a>set the target effect of an animation</a> for a given worklet animation
694+
is called, then <a>set animator instance of worklet animation</a> given the worklet animation as
695+
|workletAnimation|.
696+
697+
When the procedure to <a>set the timeline of an animation</a> for a given |workletAnimation|
698+
is called, then <a>set animator instance of worklet animation</a> given the worklet animation as
699+
|workletAnimation|.
700+
662701

663702
<div algorithm="associate-animator-instance">
664703

665704
To <dfn>associate animator instance of worklet animation</dfn> given |workletAnimation|,
666705
the user agent <em>must</em> run the following steps:
667706

668-
1. If |workletAnimation| has a corresponding <a>animator instance</a>, abort the following steps.
707+
1. If |workletAnimation| has a <a>corresponding animator instance</a>, abort the following steps.
669708
2. Let |workletGlobalScope| be the {{AnimationWorkletGlobalScope}} associated with
670709
|workletAnimation|.
671710
3. <a>Queue a task</a> on |workletGlobalScope| to run the procedure to <a>create a new animator
@@ -675,8 +714,8 @@ the user agent <em>must</em> run the following steps:
675714
* The |workletAnimation|'s <a>animation effect</a> as effect.
676715
* The |workletAnimation|'s <a>serialized options</a> as options.
677716
* The |workletGlobalScope| as workletGlobalScope.
678-
4. If the procedure was successful, set the resulting <a>animator instance</a> as corresponding to
679-
|workletAnimation|.
717+
4. If the procedure was successful, set the resulting <a>animator instance</a> to be the
718+
<a>corresponding animator instance</a> of |workletAnimation|.
680719

681720
</div>
682721

@@ -685,19 +724,18 @@ the user agent <em>must</em> run the following steps:
685724
To <dfn>disassociate animator instance of worklet animation</dfn> given
686725
|workletAnimation|, the user age <em>must</em> run the following steps:
687726

688-
1. If |workletAnimation| does not have a corresponding <a>animator instance</a>, abort the
727+
1. If |workletAnimation| does not have a <a>corresponding animator instance</a>, abort the
689728
following steps.
690729
2. Let |workletGlobalScope| be the {{AnimationWorkletGlobalScope}} associated with
691730
|workletAnimation|.
692-
3. Let |animatorInstance| be |workletAnimation|'s corresponding <a>animator instance</a>.
731+
3. Let |animatorInstance| be |workletAnimation|'s <a>corresponding animator instance</a>.
693732
4. <a>Queue a task</a> on the |workletGlobalScope| to run the procedure to <a>remove an animator
694733
instance</a>, passing |animatorInstance| as instance and |workletGlobalScope| as
695734
workletGlobalScope.
696-
5. Set |workletAnimation| as having no corresponding <a>animator instance</a>.
735+
5. Set |workletAnimation|'s <a>corresponding animator instance</a> as undefined.
697736

698737
</div>
699738

700-
701739
<div algorithm="set-animator-instance">
702740

703741
To <dfn>set animator instance of worklet animation</dfn> given
@@ -708,21 +746,6 @@ To <dfn>set animator instance of worklet animation</dfn> given
708746

709747
</div>
710748

711-
When a given |workletAnimation|'s <a>play state</a> changes to <a>pending</a>, <a>running</a>, or
712-
<a>paused</a>, run the procedure to
713-
<a>associate animator instance of worklet animation</a> given |workletAnimation|.
714-
715-
716-
When a given |workletAnimation|'s <a>play state</a> changes to <a>idle</a> or <a>finished</a>,
717-
run the procedure to
718-
<a>disassociate animator instance of worklet animation</a> given |workletAnimation|.
719-
720-
When the procedure to <a>set the target effect of an animation</a> for a given |workletAnimation|
721-
is called, then <a>set animator instance of worklet animation</a> given |workletAnimation|.
722-
723-
When the procedure to <a>set the timeline of an animation</a> for a given |workletAnimation|
724-
is called, then <a>set animator instance of worklet animation</a> given |workletAnimation|.
725-
726749

727750

728751
ScrollTimeline {#scroll-timeline}
@@ -746,8 +769,8 @@ WorkletGroupEffect {#worklet-group-effect}
746769
{{WorkletGroupEffect}} is a type of <a>group effect</a> that allows its <a>child effect's</a>
747770
<a>local times</a> to be mutated individually.
748771

749-
When a {{WorkletGroupEffect}} is set as the <a>animation effect</a> of a {{WorkletAnimation}}, the
750-
corresponding <a>animator instance</a> can directly control the <a>child effects</a>' <a>local
772+
When a {{WorkletGroupEffect}} is set as the <a>animation effect</a> of a <a>worklet animation</a>,
773+
its <a>corresponding animator instance</a> can directly control the <a>child effects</a>' <a>local
751774
times</a>. This allows a single worklet animation to coordinate multiple effects - see
752775
[[#example-2]] for an example of such a use-case.
753776

0 commit comments

Comments
 (0)