Skip to content

Commit

Permalink
[web-animations-1] Switch to using WebIDL definitions of promise algo…
Browse files Browse the repository at this point in the history
…rithms
  • Loading branch information
birtles committed Aug 29, 2019
1 parent 0db0c1c commit 0d82749
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions web-animations-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,14 @@ urlPrefix: https://heycam.github.io/webidl/#dfn-; type: dfn; spec: webidl
text: thrown; url: throw
text: convert ecmascript to idl value
urlPrefix: https://heycam.github.io/webidl/; type: dfn; spec: webidl
text: a new promise
text: create a new resolved Promise; url: a-promise-resolved-with
text: [EnforceRange]; url: EnforceRange
text: es to dictionary
text: es to DOMString; url: es-to-DOMString
text: DOMString to es; url: DOMString-to-es
text: reject a promise; url: reject
text: resolve a promise; url: resolve
urlPrefix: http://www.ecma-international.org/ecma-262/6.0/#sec-; type: dfn; spec: ecma-262
text: code realms
text: completion record specification type
Expand All @@ -132,8 +136,6 @@ urlPrefix: http://www.ecma-international.org/ecma-262/6.0/#sec-; type: dfn; spec
text: IteratorValue
text: Promise object; url: promise-objects
text: Promise; url: promise-objects
text: PromiseCapability record; url: promisecapability-records
text: Promise.resolve; url: promise.resolve
text: Type; url: ecmascript-data-types-and-values
text: well known symbols
text: [[DefineOwnProperty]]; url: ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc
Expand Down Expand Up @@ -868,7 +870,8 @@ The procedure to <dfn>reset an animation's pending tasks</dfn> for
promise</a> with a DOMException named "AbortError".
1. Let <var>animation</var>'s <a>current ready promise</a> be the result of
<a lt="create a new resolved Promise">creating a new resolved Promise
object</a>.
object</a> with value <var>animation</var> in the <a>relevant Realm</a> of
<var>animation</var>.

<h4 id="the-current-time-of-an-animation">The current time of an animation</h4>

Expand Down Expand Up @@ -1074,29 +1077,12 @@ following conditions are true:
* the animation is associated with a <a>timeline</a> that is not
<a lt="inactive timeline">inactive</a>.

<h4 id='promise-objects'>Promise objects</h4>

<a>Promise objects</a> are defined by [[!ECMA-262]].

To <dfn>resolve a Promise</dfn> with <var>value</var>,
call the \[[Call]] internal \[[Resolve]] method on the <a>PromiseCapability
record</a> for the promise, passing <code>undefined</code> as
<var>thisArgument</var> and (<var>value</var>) as <var>argumentsList</var>.

To <dfn>reject a Promise</dfn> with <var>reason</var>,
call the \[[Call]] internal \[[Reject]] method on the <a>PromiseCapability
record</a> for the promise, passing <code>undefined</code> as
<var>thisArgument</var> and
(<var>reason</var>) as <var>argumentsList</var>.

To <dfn>create a new resolved Promise</dfn> with <var>value</var>, call
<a>Promise.resolve</a>, passing <var>value</var> as <var ignore>x</var>.

<h4 id='the-current-ready-promise'>The current ready promise</h4>

Each <a>animation</a> has a <dfn>current ready promise</dfn>.
The <a>current ready promise</a> is initially a resolved <a>Promise</a> created
using the procedure to <a>create a new resolved Promise</a>.
using the procedure to <a>create a new resolved Promise</a> with the animation
itself as its value and created in the <a>relevant Realm</a> of the animation.

The object is replaced with a new <a>Promise object</a> every time the animation
queues a <a>pending play task</a> or a <a>pending pause task</a> when it
Expand Down Expand Up @@ -1190,8 +1176,8 @@ as CSS Animations [[CSS-ANIMATIONS-1]].
let its [=start time=] be <a>unresolved</a>.

1. If <var>has pending ready promise</var> is false,
let <var>animation</var>'s <a>current ready promise</a> be a new
(pending) <a>Promise</a> object.
let <var>animation</var>'s <a>current ready promise</a> be
<a>a new promise</a> in the <a>relevant Realm</a> of <var>animation</var>.

1. Schedule a task to run as soon as <var>animation</var> is <a>ready</a>.
The task shall perform the following steps:
Expand Down Expand Up @@ -1245,7 +1231,7 @@ as CSS Animations [[CSS-ANIMATIONS-1]].

</div>

1. <a lt="resolve a Promise">Resolve</a> <var>animation</var>'s <a>current
1. <a lt="resolve a promise">Resolve</a> <var>animation</var>'s <a>current
ready promise</a> with <var>animation</var>.

1. Run the procedure to <a>update an animation's finished state</a> for
Expand Down Expand Up @@ -1336,8 +1322,8 @@ follows:
1. If <var>animation</var> has a <a>pending play task</a>, cancel that task
and let <var>has pending ready promise</var> be true.
1. If <var>has pending ready promise</var> is false,
set <var>animation</var>'s <a>current ready promise</a> to a new
(pending) <a>Promise</a> object.
set <var>animation</var>'s <a>current ready promise</a> to
<a>a new promise</a> in the <a>relevant Realm</a> of <var>animation</var>.
1. Schedule a task to be executed at the first possible moment after
the user agent has performed any processing necessary to suspend
the playback of
Expand Down Expand Up @@ -1443,7 +1429,7 @@ Each animation has a <dfn>current finished promise</dfn>.
The <a>current finished promise</a> is initially a pending <a>Promise</a>
object.

The object is replaced with a new (pending) <a>Promise</a> object every time
The object is replaced with a new <a>promise</a> every time
the animation leaves the <a>finished play state</a>.

<h4 id="updating-the-finished-state">Updating the finished state</h4>
Expand Down Expand Up @@ -1597,7 +1583,7 @@ follows:
1. If <var>current finished state</var> is false and
<var>animation</var>'s <a>current finished promise</a> is already
resolved, set <var>animation</var>'s <a>current finished promise</a> to
a new (pending) Promise object.
<a>a new promise</a> in the <a>relevant Realm</a> of <var>animation</var>.

<div class="informative-bg">

Expand Down Expand Up @@ -1718,8 +1704,9 @@ as follows:
<var>animation</var>.
1. <a lt="reject a Promise">Reject</a> the <a>current finished promise</a>
with a DOMException named "AbortError".
1. Let <a>current finished promise</a> be a new (pending) <a>Promise</a>
object.
1. Let <a>current finished promise</a> be
<a>a new promise</a> in the <a>relevant Realm</a> of
<var>animation</var>.
1. <a lt="create an event">Create</a> an {{AnimationPlaybackEvent}},
|cancelEvent|.
1. Set |cancelEvent|'s {{Event/type}} attribute to <a lt="cancel
Expand Down

0 comments on commit 0d82749

Please sign in to comment.