Skip to content

Commit

Permalink
Revamp after PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
noamr committed Oct 15, 2021
1 parent eec1edd commit 0f4aab0
Showing 1 changed file with 89 additions and 53 deletions.
142 changes: 89 additions & 53 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2184,14 +2184,17 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<dfn data-x-href="https://infra.spec.whatwg.org/#string-position-variable">position variable</dfn></li>
<li><dfn data-x-href="https://infra.spec.whatwg.org/#skip-ascii-whitespace">skip ASCII whitespace</dfn></li>
<li>The <dfn data-x-href="https://infra.spec.whatwg.org/#ordered-map">ordered map</dfn> data structure and the associated definitions for
<dfn data-x="map key" data-x-href="https://infra.spec.whatwg.org/#map-key">key</dfn>,
<dfn data-x="map value" data-x-href="https://infra.spec.whatwg.org/#map-value">value</dfn>,
<dfn data-x="map entry" data-x-href="https://infra.spec.whatwg.org/#map-entry">entry</dfn>,
<dfn data-x="map exists" data-x-href="https://infra.spec.whatwg.org/#map-exists">exists</dfn>,
<dfn data-x="map get" data-x-href="https://infra.spec.whatwg.org/#map-get">getting the value of an entry</dfn>,
<dfn data-x="map set" data-x-href="https://infra.spec.whatwg.org/#map-set">setting the value of an entry</dfn>,
<dfn data-x="map remove" data-x-href="https://infra.spec.whatwg.org/#map-remove">removing an entry</dfn>,
<dfn data-x="map clear" data-x-href="https://infra.spec.whatwg.org/#map-clear">clear</dfn>,
<dfn data-x="map empty" data-x-href="https://infra.spec.whatwg.org/#map-is-empty">empty</dfn>,
<dfn data-x="map get the keys" data-x-href="https://infra.spec.whatwg.org/#map-getting-the-keys">getting the keys</dfn>,
<dfn data-x="map get the values" data-x-href="https://infra.spec.whatwg.org/#map-getting-the-values">getting the values</dfn>,
<dfn data-x="map size" data-x-href="https://infra.spec.whatwg.org/#map-size">size</dfn>, and
<dfn data-x="map iterate" data-x-href="https://infra.spec.whatwg.org/#map-iterate">iterate</dfn></li>
<li>The <dfn data-x-href="https://infra.spec.whatwg.org/#list">list</dfn> data structure and the associated definitions for
Expand Down Expand Up @@ -4089,7 +4092,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<ul class="brief">
<li><dfn data-x-href="https://w3c.github.io/requestidlecallback/#the-requestidlecallback-method"><code>requestIdleCallback()</code></dfn></li>
<li><dfn data-x-href="https://w3c.github.io/requestidlecallback/#start-an-idle-period">start an idle period</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/requestidlecallback/#dfn-idle-task-task-source">idle-task task source</dfn></li>
</ul>
</dd>

Expand Down Expand Up @@ -88978,7 +88980,7 @@ dictionary <dfn dictionary>PageTransitionEventInit</dfn> : <span>EventInit</span
data-x="concept-EventSource-forcibly-close">forcibly close</span>
<var>eventSource</var>.</p></li>

<li><p>Empty <var>window</var>'s <span>list of active timers</span>.</p></li>
<li><p>Empty <var>window</var>'s <span>map of active timers</span>.</p></li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -93188,16 +93190,15 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
which is initially false. It is used to prevent reentrant invocation of the <span>perform a
microtask checkpoint</span> algorithm.</p>

<p>Each <span>window event loop</span> has a <span>DOMHighResTimeStamp</span>
<p>Each <span>window event loop</span> has a <code>DOMHighResTimeStamp</code>
<dfn>last render opportunity time</dfn>, initially set to zero.</p>

<p>Each <span>window event loop</span> has a <span>DOMHighResTimeStamp</span>
<p>Each <span>window event loop</span> has a <code>DOMHighResTimeStamp</code>
<dfn>last idle period start time</dfn>, initially set to zero.</p>

<p>To get the <dfn for="window event loop">same-loop windows</dfn> for a
<span>window event loop</span> <var>loop</var>, return all <code>Window</code> objects whose
<span>relevant agent</span>'s <span data-x="concept-agent-event-loop">event loop</span> is
<var>loop</var>.</p>
<p>To get the <dfn>same-loop windows</dfn> for a <span>window event loop</span> <var>loop</var>,
return all <code>Window</code> objects whose <span>relevant agent</span>'s
<span data-x="concept-agent-event-loop">event loop</span> is <var>loop</var>.</p>


<h5>Queuing tasks</h5>
Expand Down Expand Up @@ -93579,46 +93580,73 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
<li>this <span>event loop</span>'s <span>microtask queue</span> is <span data-x="list is
empty">empty</span></li>
<li><var>hasARenderingOpportunity</var> is false</li>
<li>
<p><span>currently running task</span>'s <span data-x="concept-task-source">source</span> is
not the <span>idle-task task source</span> <ref spec=REQUESTIDLECALLBACK>

<p class="note">This is to ensure that the idle tasks themselves don't generate a new idle
period. See
<a href="https://github.com/w3c/requestidlecallback/issues/96">requestIdleCallback #96</a>.</p>
<li>
</ul>

<p>then for each <code>Window</code> <var>win</var> in the <span>same-loop windows</span> for
this <span>event loop</span>, <span>start an idle period</span> for <var>win</var> with the
following steps to compute the current idle period deadline: <ref spec=REQUESTIDLECALLBACK></p>
<p>then:

<ol>
<li>
<p>Let <var>deadline</var> be this <span>event loop</span>'s
<span>last idle period start time</span> plus 50.</p>
<p>Let <var>computeDeadline</var> be the following steps:</p>

<p class="note">The cap of 50ms in the future is to ensure responsiveness to new user input
within the threshold of human perception.</p>
</li>
<ol>
<li>
<p>Let <var>deadline</var> be this <span>event loop</span>'s
<span>last idle period start time</span> plus 50.</p>

<li><p>Check for potential pending rendering: If any <code>Window</code> in the
<span>same-loop windows</span> for this <span>event loop</span>'s <span>map of animation frame
callbacks</span> is not empty, or if the user agent believes that the <code>Window</code>
might have pending rendering updates, set <var>deadline</var> to this <span>event loop</span>'s
<span>last render opportunity time</span> plus 16, if it is less than
<var>deadline</var>.</p></li>
<p class="note">The cap of 50ms in the future is to ensure responsiveness to new user input
within the threshold of human perception.</p>
</li>

<li><p>Check for pending timers: for each <code>Window</code> <var>win</var> in the
<span>same-loop windows</span> for this <span>event loop</span>: For each <var>timerEntry</var>
in <var>window</var>'s <span>list of active timers</span>, set <var>deadline</var> to the
result of calling <var>timerEntry</var>'s <span>estimate next callback time</span> if it is
less than <var>deadline</var>.</p></li>
<li><p>Let <var>hasPendingRenders</var> be false.

<li><p>If <var>deadline</var> is less than the <span>current high resolution time</span>,
return zero.</p></li>
<li>
<p>For each <code>Window</code> <var>windowInSameLoop</var> the <span>same-loop windows</span>
for this <span>event loop</span>, do the following:</p>

<li><p>Return <var>deadline</var>.</p></li>
<ol>
<li><p>If <var>windowInSameLoop</var>'s <span>map of animation frame callbacks</span> is
not <span data-x="map empty">empty</span>, or if the user agent believes that the
<var>windowInSameLoop</var> might have pending rendering updates, set
<var>hasPendingRenders</var> to true.</p></li>

<li><p>Let <var>timerCallbackEstimates</var> be the result of
<span data-x="map get the values">getting the values</span> of
<var>windowInSameLoop</var>'s <span>map of active timers</span></p>.</li>

<li>
<p>For each <var>estimate</var> in <var>timerCallbackEstimates</var>, do the
following:</p>

<ol>
<li><p>Let <var>timeoutDeadline</var> be the result of calling
<var>estimateTimerCallback</var>.</p></li>

<li><p>If <var>timeoutDeadline</var> is less than <var>deadline</var>, set
<var>deadline</var> to <var>timeoutDeadline</var>.</p></li>
</ol>
</li>
</ol>
</li>

<li>
<p>If <var>hasPendingRenders</var> is true, then:</p>

<ol>
<li><p>Let <var>nextRenderDeadline</var> be this <span>event loop</span>'s
<span>last render opportunity time</span> plus 16.</p></li>

<li><p>If <var>nextRenderDeadline</var> is less than
<var>deadline</var>, then return <var>nextRenderDeadline</var>.</p></li>
</ol>
</li>

<li><p>Return <var>deadline</var>.</p></li>
</ol>
</li>

<li><p>For each <code>Window</code> <var>win</var> in the <span>same-loop windows</span> for
this <span>event loop</span>, <span>start an idle period</span> for <var>win</var> with
<var>computeDeadline</var>. <ref spec=REQUESTIDLECALLBACK></p></li>
</ol>
</li>

Expand Down Expand Up @@ -96035,10 +96063,16 @@ enum <dfn enum>DOMParserSupportedType</dfn> {
<div w-nodev>

<p>Objects that implement the <code>WindowOrWorkerGlobalScope</code> mixin have a <dfn
export>list of active timers</dfn>. Each entry in this lists is identified by a number, which must
be unique within the list for the lifetime of the object that implements the
<code>WindowOrWorkerGlobalScope</code> mixin, and has an <dfn>estimate next callback time</dfn>,
an algorithm returing a <span>DOMHighResTimestamp</span>.</p>
export>map of active timers</dfn>, which is a <span>map</span>, initially empty. Each
<span data-x="map key">key</span> in this map is identified by a number, which must be unique
within the list for the lifetime of the object that implements the
<code>WindowOrWorkerGlobalScope</code> mixin, and each <span data-x="map value">value</span> is an
algorithm returing a <code>DOMHighResTimeStamp</code>, representing the next estimated callback
time for that timer.</p>

<p>To get the <dfn export>list of active timers</dfn> for <code>WindowOrWorkerGlobalScope</code>
<var>global</var>, return the result of <span data-x="map get the keys">getting
the keys</span> for <var>global</var>'s <span>map of active timers</span>.

<hr>

Expand All @@ -96062,14 +96096,12 @@ enum <dfn enum>DOMParserSupportedType</dfn> {
id="dom-windowtimers-clearTimeout">clearTimeout(<var>handle</var>)</code></dfn> and <dfn method
for="WindowOrWorkerGlobalScope" data-x="dom-clearInterval"><code
id="dom-windowtimers-clearInterval">clearInterval(<var>handle</var>)</code></dfn> methods must
clear the entry identified as <var>handle</var> from the <span>list of active timers</span> of the
<code>WindowOrWorkerGlobalScope</code> object on which the method was invoked, if any, where
<var>handle</var> is the argument passed to the method. (If <var>handle</var> does not identify an
entry in the <span>list of active timers</span> of the <code>WindowOrWorkerGlobalScope</code>
object on which the method was invoked, the method does nothing.)</p>
<span data-x="map remove">remove</span> <span>map of active timers</span>[<var>handle</var>] of
the <code>WindowOrWorkerGlobalScope</code> object on which the method was invoked, if any, where
<var>handle</var> is the argument passed to the method.

<p class="note">Because <code data-x="dom-clearTimeout">clearTimeout()</code> and <code
data-x="dom-clearInterval">clearInterval()</code> clear entries from the same list, either method
data-x="dom-clearInterval">clearInterval()</code> clear entries from the same map, either method
can be used to clear timers created by <code data-x="dom-setTimeout">setTimeout()</code> or <code
data-x="dom-setInterval">setInterval()</code>.</p>

Expand Down Expand Up @@ -96106,8 +96138,8 @@ enum <dfn enum>DOMParserSupportedType</dfn> {
following substeps:</p>

<ol>
<li><p>If the entry for <var>handle</var> in the <span>list of active timers</span> has been
cleared, then abort these steps.</p></li>
<li><p>If <var>handle</var> does not <span data-x="map exists">exist</span> in the
<span>map of active timers</span>, then abort these steps.</p></li>

<li>
<p>Run the appropriate set of steps from the following list:</p>
Expand Down Expand Up @@ -96207,15 +96239,18 @@ enum <dfn enum>DOMParserSupportedType</dfn> {
<li><p>Let <var>startTime</var> be the <span>current high resolution time</span>.</p></li>

<li>
<p>Set the <span>estimate next callback time</span> algorithm for the entry in the
<span>list of active timers</span> associated with <var>handle</var> to the following steps:</p>
<p><span data-x="map set">Set</span> <span>map of active timers</span>[<var>handle</var>] to the
following steps:</p>

<ol>
<li>
<p>Let <var>estimatedCallbackTime</var> be <var>startTime</var> plus <var>timeout</var>,
plus the duration in milliseconds in which the document has not been
<span>fully active</span> since <var>startTime</var>, plus a number representing an
<span>implementation-defined</span> length of time in milliseconds.</p>

<p class="note">The implementation-defined extra times allows implementation to extend the
length of timeout according to its own heuristics and optimizations.</p>
</li>

<li><p>Let <var>now</var> be the <span>current high resolution time</span>.</p></li>
Expand Down Expand Up @@ -102345,7 +102380,8 @@ interface <dfn interface>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope
</li>

<li>
<p>Empty the <var>worker global scope</var>'s <span>list of active timers</span>.</p>
<p><span data-x="map clear">Clear</span> the <var>worker global scope</var>'s
<span>map of active timers</span>.</p>
</li>

<li>
Expand Down

0 comments on commit 0f4aab0

Please sign in to comment.