Skip to content

Commit

Permalink
Add "regaining document full activity steps"
Browse files Browse the repository at this point in the history
These steps will be run when a document regains full activity after restoring it from BFCache. This does not currently introduce any behavior changes within the HTML spec, but allows other specs to define the steps they will take when a document becomes fully active again, e.g. send updates to the renderer about the current Geolocation state, etc.

Fixes whatwg#8872.
  • Loading branch information
rakina committed Feb 16, 2023
1 parent eaceee9 commit 2b6b43d
Showing 1 changed file with 47 additions and 36 deletions.
83 changes: 47 additions & 36 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -94260,39 +94260,43 @@ location.href = '#foo';</code></pre>
data-x="concept-environment-execution-ready-flag">execution ready flag</span>.</p></li>
</ol>

<p>To <dfn data-x="reactivate a document">reactivate</dfn> a <code>Document</code>
<var>document</var>:</p>

<p class="note">This algorithm updates <var>document</var> after it has come out of <a
href="#note-bfcache">bfcache</a>, i.e., after it has been made <span>fully active</span>
again.</p>
<p>To <dfn>try to scroll to the fragment</dfn> for a <code>Document</code> <var>document</var>,
perform the following steps <span>in parallel</span>:</p>

<ol>
<li id="history-autocomplete"><p><span data-x="list iterate">For each</span>
<var>formControl</var> of form controls in <var>document</var> with an <span>autofill field
name</span> of "<code data-x="attr-fe-autocomplete-off">off</code>", invoke the <span
data-x="concept-form-reset-control">reset algorithm</span> for <var>formControl</var>.</p></li>
<li><p>Wait for an <span>implementation-defined</span> amount of time. (This is intended to allow
the user agent to optimize the user experience in the face of performance concerns.)</p></li>

<li>
<p>If <var>document</var>'s <span>suspended timer handles</span> is not <span data-x="list
empty">empty</span>:</p>
<p><span>Queue a global task</span> on the <span>navigation and traversal task source</span>
given <var>document</var>'s <span>relevant global object</span> to run these steps:</p>

<ol>
<li><p><span>Assert</span>: <var>document</var>'s <span>suspension time</span> is not
zero.</p></li>

<li><p>Let <var>suspendDuration</var> be the <span>current high resolution time</span> minus
<var>document</var>'s <span>suspension time</span>.</p></li>
<li><p>If <var>document</var> has no parser, or its parser has <span data-x="stop
parsing">stopped parsing</span>, or the user agent has reason to believe the user is no longer
interested in scrolling to the <span data-x="concept-url-fragment">fragment</span>, then abort
these steps.</p></li>

<li><p>Let <var>activeTimers</var> be <var>document</var>'s <span>relevant global
object</span>'s <span>map of active timers</span>.</p></li>
<li><p><span>Scroll to the fragment</span> given <var>document</var>.</p></li>

<li><p>For each <var>handle</var> in <var>document</var>'s <span>suspended timer
handles</span>, if <var>activeTimers</var>[<var>handle</var>] <span data-x="map
exists">exists</span>, then increase <var>activeTimers</var>[<var>handle</var>] by
<var>suspendDuration</var>.</p></li>
<li><p>If <var>document</var>'s <span>indicated part</span> is still null, then <span>try to
scroll to the fragment</span> for <var>document</var>.</p></li>
</ol>
</li>
</ol>

<p>To <dfn data-x="reactivate a document">reactivate</dfn> a <code>Document</code>
<var>document</var>:</p>

<p class="note">This algorithm updates <var>document</var> after it has come out of <a
href="#note-bfcache">bfcache</a>, i.e., after it has been made <span>fully active</span>
again.</p>

<ol>
<li>
<p>Run any <span>regaining document full activity steps</span> for <var>document</var> that are
defined by this specification and <span>other applicable specifications</span>.</p>
</li>

<li>
<p>If <var>document</var>'s <span>current document readiness</span> is "<code
Expand All @@ -94317,27 +94321,34 @@ location.href = '#foo';</code></pre>
</li>
</ol>

<p>To <dfn>try to scroll to the fragment</dfn> for a <code>Document</code> <var>document</var>,
perform the following steps <span>in parallel</span>:</p>
<p>This specification defines the following <dfn export>regaining document full activity steps</dfn>.
Other specifications can define more. Note that these steps must not run script.<br>
Given a <code>Document</code> <var>document</var>:</p>

<ol>
<li><p>Wait for an <span>implementation-defined</span> amount of time. (This is intended to allow
the user agent to optimize the user experience in the face of performance concerns.)</p></li>
<li id="history-autocomplete"><p><span data-x="list iterate">For each</span>
<var>formControl</var> of form controls in <var>document</var> with an <span>autofill field
name</span> of "<code data-x="attr-fe-autocomplete-off">off</code>", invoke the <span
data-x="concept-form-reset-control">reset algorithm</span> for <var>formControl</var>.</p></li>

<li>
<p><span>Queue a global task</span> on the <span>navigation and traversal task source</span>
given <var>document</var>'s <span>relevant global object</span> to run these steps:</p>
<p>If <var>document</var>'s <span>suspended timer handles</span> is not <span data-x="list
empty">empty</span>:</p>

<ol>
<li><p>If <var>document</var> has no parser, or its parser has <span data-x="stop
parsing">stopped parsing</span>, or the user agent has reason to believe the user is no longer
interested in scrolling to the <span data-x="concept-url-fragment">fragment</span>, then abort
these steps.</p></li>
<li><p><span>Assert</span>: <var>document</var>'s <span>suspension time</span> is not
zero.</p></li>

<li><p><span>Scroll to the fragment</span> given <var>document</var>.</p></li>
<li><p>Let <var>suspendDuration</var> be the <span>current high resolution time</span> minus
<var>document</var>'s <span>suspension time</span>.</p></li>

<li><p>If <var>document</var>'s <span>indicated part</span> is still null, then <span>try to
scroll to the fragment</span> for <var>document</var>.</p></li>
<li><p>Let <var>activeTimers</var> be <var>document</var>'s <span>relevant global
object</span>'s <span>map of active timers</span>.</p></li>

<li><p>For each <var>handle</var> in <var>document</var>'s <span>suspended timer
handles</span>, if <var>activeTimers</var>[<var>handle</var>] <span data-x="map
exists">exists</span>, then increase <var>activeTimers</var>[<var>handle</var>] by
<var>suspendDuration</var>.</p></li>
</ol>
</li>
</ol>
Expand Down

0 comments on commit 2b6b43d

Please sign in to comment.