Skip to content

Commit

Permalink
Fix object providence in event loops
Browse files Browse the repository at this point in the history
Closes #4337, by being much clearer about how browsing contexts,
Documents, and Windows documents are selected for each turn of the event
loop processing model.

This also fixes an issue where the "report the duration of the update
the rendering step" referenced the out-of-scope variable "docs".
  • Loading branch information
domenic authored Mar 26, 2020
1 parent f87a58c commit edf19e2
Showing 1 changed file with 48 additions and 44 deletions.
92 changes: 48 additions & 44 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -89211,6 +89211,8 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<li><p><i>Microtasks</i>: <span>Perform a microtask checkpoint</span>.</p></li>

<li><p>Let <var>hasARenderingOpportunity</var> be false.</p></li>

<li><p>Let <var>now</var> be the <span>current high resolution time</span>. <ref
spec=HRT></p></li>

Expand Down Expand Up @@ -89238,9 +89240,9 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<ol>
<li>
<p>Let <var>docs</var> be the list of <code>Document</code> objects associated with the
<span>event loop</span> in question, sorted arbitrarily except that the following conditions
must be met:</p>
<p>Let <var>docs</var> be all <code>Document</code> objects whose <span>relevant
agent</span>'s <span>event loop</span> is this event loop, sorted arbitrarily except that the
following conditions must be met:</p>

<ul>
<li><p>Any <code>Document</code> <var>B</var> whose <span
Expand All @@ -89262,11 +89264,9 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
</li>

<li>
<p><i>Rendering opportunites</i>: If there are <span data-x="browsing context">browsing
contexts</span> <var>browsingContexts</var> that do not have a <span>rendering
opportunity</span>, then remove from <var>docs</var> all <code>Document</code> objects whose
<span data-x="concept-document-bc">browsing context</span> is in
<var>browsingContexts</var>.</p>
<p><i>Rendering opportunities</i>: Remove from <var>docs</var> all <code>Document</code>
objects whose <span data-x="concept-document-bc">browsing context</span> do not have a
<span>rendering opportunity</span>.</p>

<p>A <span>browsing context</span> has a <dfn>rendering opportunity</dfn> if the user agent is
currently able to present the contents of the <span>browsing context</span> to the user,
Expand All @@ -89288,19 +89288,23 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
a much slower 4 rendering opportunities per second, or even less.</p>
</li>

<li><p><i>Unnecessary rendering</i>: If there are <span data-x="browsing context">browsing
contexts</span> <var>browsingContexts</var> for which the user agent believes updating the
rendering would have no visible effect and which possess no <code>Document</code> objects with
a non-empty <span>map of animation frame callbacks</span>, then remove from <var>docs</var>
all <code>Document</code> objects whose <span data-x="concept-document-bc">browsing
context</span> is in <var>browsingContexts</var>.</p></li>
<li><p>If <var>docs</var> is not empty, then set <var>hasARenderingOpportunity</var> to
true.</p></li>

<li>
<p>If there are <span data-x="browsing context">browsing contexts</span>
<var>browsingContexts</var> for which the user agent believes it's preferrable to skip
updating the rendering for other reasons, then remove from <var>docs</var> all
<code>Document</code> objects whose <span data-x="concept-document-bc">browsing context</span>
is in <var>browsingContexts</var>.</p>
<p><i>Unnecessary rendering</i>: Remove from <var>docs</var> all <code>Document</code> objects
which meet both of the following conditions:</p>

<ul class="brief">
<li>The user agent believes that updating the rendering of the <code>Document</code>'s <span
data-x="concept-document-bc">browsing context</span> would have no visible effect, and</li>
<li>The <code>Document</code>'s <span>map of animation frame callbacks</span> is empty.</li>
</ul>
</li>

<li>
<p>Remove from <var>docs</var> all <code>Document</code> objects for which the user agent
believes that it's preferrable to skip updating the rendering for other reasons.</p>

<div class="note">
<p>The step labeled <i>Rendering opportunities</i> prevents the user agent from updating the
Expand Down Expand Up @@ -89359,6 +89363,25 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, update the
rendering or user interface of that <code>Document</code> and its <span
data-x="concept-document-bc">browsing context</span> to reflect the current state.</p></li>

<li>
<p>Report the duration of the <span>update the rendering</span> step by performing the
following steps:</p>

<ol>
<li><p>Let <var>rendering end time</var> be the <span>current high resolution
time</span>.</p></li>

<li><p>Let <var>top-level browsing contexts</var> be the set of all <span data-x="top-level
browsing context">top-level browsing contexts</span> of the <span
data-x="concept-document-bc">browsing contexts</span> of all <span>fully active</span>
<code>Document</code>s in <var>docs</var>.</p></li>

<li><p><span>Report long tasks</span>, passing in <var>now</var> (repurposed as meaning the
beginning of the <span>update the rendering</span> step), <var>rendering end time</var>, and
<var>top-level browsing contexts</var>.</p></li>
</ol>
</li>
</ol>
</li>

Expand All @@ -89367,36 +89390,17 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<ul class="brief">
<li>this is a <span>window event loop</span></li>
<li>there is no <span data-x="concept-task">task</span> in the <span>event loop</span>'s
<li>there is no <span data-x="concept-task">task</span> in this <span>event loop</span>'s
<span data-x="task queue">task queues</span> whose <span
data-x="concept-task-document">document</span> is <span>fully active</span></li>
<li>the <span>event loop</span>'s <span>microtask queue</span> is <span data-x="list is
<li>this <span>event loop</span>'s <span>microtask queue</span> is <span data-x="list is
empty">empty</span></li>
<li>none of the <span data-x="browsing context">browsing contexts</span> have a
<span>rendering opportunity</span></li>
<li><var>hasARenderingOpportunity</var> is false</li>
</ul>

<p>then for each <span>browsing context</span>, run the steps in the <span>start an idle period
algorithm</span>, passing the <code>Window</code> associated with that <span>browsing
context</span>. <ref spec="REQUESTIDLECALLBACK"></p>
</li>

<li>
<p>Report the duration of the <span>update the rendering</span> step by performing the
following steps:</p>

<ol>
<li><p>Let <var>rendering end time</var> be the <span>current high resolution
time</span>.</p></li>

<li><p>Let <var>top-level browsing contexts</var> be the set of all <span data-x="top-level
browsing context">top-level browsing contexts</span> of all <span>fully active</span>
<code>Document</code>s in <var>docs</var>.</p></li>

<li><p><span>Report long tasks</span>, passing in <var>now</var> (repurposed as meaning the
beginning of the <span>update the rendering</span> step), <var>rendering end time</var>, and
<var>top-level browsing contexts</var>.</p></li>
</ol>
<p>then for each <code>Window</code> object whose whose <span>relevant agent</span>'s
<span>event loop</span> is this event loop, run the <span>start an idle period
algorithm</span>, passing the <code>Window</code>. <ref spec="REQUESTIDLECALLBACK"></p>
</li>

<li>
Expand Down

0 comments on commit edf19e2

Please sign in to comment.