Skip to content

Commit 93ab72f

Browse files
authored
[AnimationWorklet] Make animator ctor a proper callback type instead of VoidFunction (w3c#865)
Previously the callback type was VoidFunction which is incorrect since it is expected to return the new instance.
1 parent f42236e commit 93ab72f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

css-animationworklet/Overview.bs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,29 +303,34 @@ animation as needed by {{AnimationWorkletGlobalScope}}. It consists of:
303303

304304
- An <dfn>animator name</dfn> <<ident>>#.
305305

306-
- A <dfn>class constructor</dfn> which is a <a>VoidFunction</a> <a>callback function</a> type.
306+
- A <dfn>class constructor</dfn> which is a {{AnimatorInstanceConstructor}} <a>callback function</a> type.
307307

308308
- An <dfn>animate function</dfn> which is a <a>Function</a> <a>callback function</a> type.
309309

310310
- A <dfn>stateful flag</dfn>
311311

312312

313+
313314
Registering an Animator Definition {#registering-animator-definition}
314315
-------------------------------------
315316
An {{AnimationWorkletGlobalScope}} has a <dfn>animator name to animator definition map</dfn>.
316-
The map gets populated when {{registerAnimator(name, animatorCtorValue)}} is called.
317+
The map gets populated when {{registerAnimator(name, animatorCtor)}} is called.
317318

318319

319320
<xmp class='idl'>
321+
320322
[ Exposed=AnimationWorklet, Global=AnimationWorklet ]
321323
interface AnimationWorkletGlobalScope : WorkletGlobalScope {
322-
void registerAnimator(DOMString name, VoidFunction animatorCtor);
324+
void registerAnimator(DOMString name, AnimatorInstanceConstructor animatorCtor);
323325
};
326+
327+
callback AnimatorInstanceConstructor = any (any options, optional any state);
328+
324329
</xmp>
325330

326331
<div algorithm="register-animator">
327332

328-
When the <dfn method for=AnimationWorkletGlobalScope>registerAnimator(|name|, |animatorCtorValue|)</dfn>
333+
When the <dfn method for=AnimationWorkletGlobalScope>registerAnimator(|name|, |animatorCtor|)</dfn>
329334
method is called in a {{AnimationWorkletGlobalScope}}, the user agent <em>must</em> run the
330335
following steps:
331336

@@ -335,14 +340,11 @@ following steps:
335340
2. If |name| exists as a key in the <a>animator name to animator definition map</a>,
336341
<a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
337342

338-
3. If the result of <a>IsConstructor</a>(|animatorCtorValue|) is false, <a>throw</a> a
343+
3. If the result of <a>IsConstructor</a>(|animatorCtor|) is <b>false</b>, <a>throw</a> a
339344
<a>TypeError</a> and abort all these steps.
340345

341-
4. Let |animatorCtor| be the result of <a>converting</a> animatorCtorValue to the
342-
<a>VoidFunction</a> <a>callback function</a> type. If an exception is thrown, rethrow the
343-
exception and abort all these steps.
344346

345-
4. Let |prototype| be the result of <a>Get</a>(|animatorCtorValue|, "prototype").
347+
4. Let |prototype| be the result of <a>Get</a>(|animatorCtor|, "prototype").
346348

347349

348350
5. If <a>SameValue</a>(|prototype|, {{StatelessAnimator}}) is <b>true</b> set |stateful| to be
@@ -426,8 +428,8 @@ To <dfn>create a new animator instance</dfn> given a |name|, |timeline|, |effect
426428
5. Let |state| be <a>StructuredDeserialize</a>(|serializedState|).
427429

428430
6. Let |animatorInstance| be the result of <a>constructing</a> |animatorCtor| with
429-
[|options|, |state| as args. If an exception is thrown, rethrow the exception and abort all
430-
these steps.
431+
«|options|, |state|» as arguments. If an exception is thrown, rethrow the exception and
432+
abort all these steps.
431433

432434
7. Set the following on |animatorInstance| with:
433435
- <a>animator name</a> being |name|
@@ -530,7 +532,7 @@ To <dfn>migrate an animator instance</dfn> from one {{WorkletGlobalScope}} to an
530532

531533
3. Let |stateful| be the <a>stateful flag</a> of |definition|.
532534

533-
4. If |stateful| is <a>false</a> then abort the following steps.
535+
4. If |stateful| is <b>false</b> then abort the following steps.
534536

535537
5. Let |state| be the result of <a>Get</a>(|instance|, "state"). If any exception is thrown,
536538
rethrow the exception and abort the following steps.

0 commit comments

Comments
 (0)