Skip to content

Commit 972b4c6

Browse files
authored
Merge pull request #1005 from Manishearth/cancel-raf-in-raf
Allow cancelling rAF callbacks from within rAF
2 parents a1e14e2 + 56e0c03 commit 972b4c6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

index.bs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame)
857857

858858
Each {{XRFrameRequestCallback}} object has a <dfn for="XRFrameRequestCallback">cancelled</dfn> boolean initially set to <code>false</code>.
859859

860-
Each {{XRSession}} has a <dfn>list of animation frame callbacks</dfn>, which is initially empty, and an <dfn>animation frame callback identifier</dfn>, which is a number which is initially zero.
860+
Each {{XRSession}} has a <dfn>list of animation frame callbacks</dfn>, which is initially empty, a <dfn>list of currently running animation frame callbacks</dfn>, which is also initially empty, and an <dfn>animation frame callback identifier</dfn>, which is a number which is initially zero.
861861

862862
<div class="algorithm" data-algorithm="request-animation-frame">
863863

@@ -879,7 +879,7 @@ The <dfn method for="XRSession">cancelAnimationFrame(|handle|)</dfn> method canc
879879
When this method is invoked, the user agent MUST run the following steps:
880880

881881
1. Let |session| be the target {{XRSession}} object.
882-
1. Find the entry in |session|'s [=list of animation frame callbacks=] that is associated with the value |handle|.
882+
1. Find the entry in |session|'s [=list of animation frame callbacks=] or |session|'s [=list of currently running animation frame callbacks=] that is associated with the value |handle|.
883883
1. If there is such an entry, set its [=cancelled=] boolean to <code>true</code> and remove it from |session|'s [=list of animation frame callbacks=].
884884

885885
</div>
@@ -892,15 +892,16 @@ When an {{XRSession}} |session| receives updated [=viewer=] state for timestamp
892892
1. If |session|'s [=pending render state=] is not <code>null</code>, [=apply the pending render state=].
893893
1. If |session|'s {{XRSession/renderState}}'s {{XRRenderState/baseLayer}} is <code>null</code>, abort these steps.
894894
1. If |session|'s [=XRSession/mode=] is {{XRSessionMode/"inline"}} and |session|'s {{XRSession/renderState}}'s [=XRRenderState/output canvas=] is <code>null</code>, abort these steps.
895-
1. Let |callbacks| be a list of the entries in |session|'s [=list of animation frame callback=], in the order in which they were added to the list.
895+
1. Set |session|'s [=list of currently running animation frame callbacks=] to be |session|'s [=list of animation frame callbacks=].
896896
1. Set |session|'s [=list of animation frame callbacks=] to the empty list.
897897
1. Set |frame|'s [=active=] boolean to <code>true</code>.
898898
1. Set |frame|'s [=animationFrame=] boolean to <code>true</code>.
899899
1. [=XRFrame/Apply frame updates=] for |frame|.
900-
1. For each entry in |callbacks|, in order:
901-
1. If the entry's [=cancelled=] boolean is <code>true</code>, continue to the next entry.
902-
1. [=Invoke the Web IDL callback function=], passing |now| and |frame| as the arguments
900+
1. For each |entry| in |session|'s [=list of currently running animation frame callbacks=], in order:
901+
1. If the |entry|'s [=cancelled=] boolean is <code>true</code>, continue to the next entry.
902+
1. [=Invoke the Web IDL callback function=] for |entry|, passing |now| and |frame| as the arguments
903903
1. If an exception is thrown, [=report the exception=].
904+
1. Set |session|'s [=list of currently running animation frame callbacks=] to the empty [=/list=].
904905
1. Set |frame|'s [=active=] boolean to <code>false</code>.
905906

906907
</div>

0 commit comments

Comments
 (0)