Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire the pageswap event when navigating away from a document #10002

Merged
merged 29 commits into from
Feb 29, 2024
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 206 additions & 8 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -4030,6 +4030,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://drafts.csswg.org/css-view-transitions/#activate-view-transition">activate view transition</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-view-transitions/#viewtransition"><code>ViewTransition</code></dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-view-transitions-2/#resolve-cross-document-view-transition">resolving cross-document view-transition</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-view-transitions-2/#setup-cross-document-view-transition">setting up a cross-document view-transition</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-view-transitions-2/#should-navigation-trigger-a-cross-document-view-transition">should navigation trigger a cross-document view-transition?</dfn>
noamr marked this conversation as resolved.
Show resolved Hide resolved
<li><dfn data-x-href="https://drafts.csswg.org/css-view-transitions-2/#resolve-view-transition-rule">resolve <code>@view-transition</code> rule</dfn>
</ul>

noamr marked this conversation as resolved.
Show resolved Hide resolved
<p>The term <dfn data-x="css-styling-attribute"
Expand Down Expand Up @@ -17871,6 +17874,7 @@ console.log(style.disabled); // false</code></pre>
<dd><code data-x="handler-window-onmessageerror">onmessageerror</code></dd>
<dd><code data-x="handler-window-onoffline">onoffline</code></dd>
<dd><code data-x="handler-window-ononline">ononline</code></dd>
<dd><code data-x="handler-window-onpageconceal">onpageconceal</code></dd>
<dd><code data-x="handler-window-onpagehide">onpagehide</code></dd>
<dd><code data-x="handler-window-onpagereveal">onpagereveal</code></dd>
<dd><code data-x="handler-window-onpageshow">onpageshow</code></dd>
Expand Down Expand Up @@ -93281,7 +93285,7 @@ interface <dfn interface>NavigationTransition</dfn> {
<pre><code class="idl">[Exposed=Window]
interface <dfn interface>NavigationActivation</dfn> {
readonly attribute <span>NavigationHistoryEntry</span>? <span data-x="dom-NavigationActivation-from">from</span>;
readonly attribute <span>NavigationHistoryEntry</span> <span data-x="dom-NavigationActivation-entry">entry</span>;
readonly attribute <span>NavigationHistoryEntry</span>? <span data-x="dom-NavigationActivation-entry">entry</span>;
readonly attribute <span>NavigationType</span> <span data-x="dom-NavigationActivation-navigationType">navigationType</span>;
};</code></pre>

Expand All @@ -93302,7 +93306,10 @@ interface <dfn interface>NavigationActivation</dfn> {
<dt><code data-x=""><span data-x="dom-navigation">navigation</span>.<span data-x="dom-Navigation-activation">activation</span>.<span subdfn data-x="dom-NavigationActivation-entry">entry</span></code></dt>
<dd><p>A <code>NavigationHistoryEntry</code>, equivalent to the value of the <code
data-x="dom-Navigation-currentEntry">navigation.currentEntry</code> property at the moment the
<code>Document</code> was activated.</p></dd>
<code>Document</code> was activated. This can be null if accessed from a
noamr marked this conversation as resolved.
Show resolved Hide resolved
<code>PageConcealEvent</code>, but is guaranteed to be non-null if accessed from <code
data-x=""><span data-x="dom-navigation">navigation</span>.<span
data-x="dom-Navigation-activation">activation</span></code>.</p></dd>

domenic marked this conversation as resolved.
Show resolved Hide resolved
<dt><code data-x=""><span data-x="dom-navigation">navigation</span>.<span data-x="dom-Navigation-activation">activation</span>.<span subdfn data-x="dom-NavigationActivation-from">from</span></code></dt>
<dd>
Expand Down Expand Up @@ -93342,7 +93349,7 @@ interface <dfn interface>NavigationActivation</dfn> {
<li><p><dfn data-x="nav-activation-old-entry">old entry</dfn>, null or a
<code>NavigationHistoryEntry</code>.</p></li>

<li><p><dfn data-x="nav-activation-new-entry">new entry</dfn>, a
<li><p><dfn data-x="nav-activation-new-entry">new entry</dfn>, null or a
<code>NavigationHistoryEntry</code>.</p></li>

<li><p><dfn data-x="nav-activation-navigation-type">navigation type</dfn>, a
Expand Down Expand Up @@ -94755,6 +94762,51 @@ dictionary <dfn dictionary>HashChangeEventInit</dfn> : <span>EventInit</span> {
</div>


<h5>The <code>PageConcealEvent</code> interface</h5>

<pre><code class="idl">[Exposed=Window]
interface <dfn interface>PageConcealEvent</dfn> : <span>Event</span> {
constructor(DOMString type, optional <span>PageConcealEventInit</span> eventInitDict);
readonly attribute <code>NavigationActivation</code> <span data-x="dom-PageConcealEvent-activation">activation</span>;
noamr marked this conversation as resolved.
Show resolved Hide resolved
noamr marked this conversation as resolved.
Show resolved Hide resolved
readonly attribute <code>ViewTransition</code>? <span data-x="dom-PageConcealEvent-viewTransition">viewTransition</span>;
};

dictionary <dfn dictionary>PageConcealEventInit</dfn> : <span>EventInit</span> {
required <span>NavigationActivation</span> <dfn dict-member for="PageConcealEventInit" data-x="dom-PageConcealEventInit-activation">activation</dfn>;
<code>ViewTransition</code>? <dfn dict-member for="PageConcealEventInit" data-x="dom-PageConcealEventInit-viewTransition">viewTransition</dfn> = null;
noamr marked this conversation as resolved.
Show resolved Hide resolved
boolean <dfn dict-member for="PageConcealEventInit" data-x="dom-PageConcealEventInit-userInitiated ">userInitiated</dfn> = false;
noamr marked this conversation as resolved.
Show resolved Hide resolved
};</code></pre>

<dl class="domintro">
<dt><code data-x=""><var>event</var>.<span subdfn data-x="dom-PageConcealEvent-activation">activation</span></code></dt>
<dd><p>A <code>NavigationActivation</code> object representing the destination and type of the
committed navigation.</p></dd>

<dt><code data-x=""><var>event</var>.<span subdfn data-x="dom-PageConcealEvent-userInitiated">userInitiated</span></code></dt>
noamr marked this conversation as resolved.
Show resolved Hide resolved
<dd><p>True if this navigation was due to a user clicking on an <code>a</code> element,
submitting a <code>form</code> element, or using the <a href="#nav-traversal-ui">browser UI</a>
to navigate; false otherwise.</p></dd>

<dt><code data-x=""><var>event</var>.<span subdfn data-x="dom-PageConcealEvent-viewTransition">viewTransition</span></code></dt>
<dd>
<p>Returns the <code>ViewTransition</code> object that represents an outbound cross-document view
transition, if such transition is active when the event is fired. Otherwise, returns null.</p>
</dd>
</dl>

<div w-nodev>

noamr marked this conversation as resolved.
Show resolved Hide resolved
<p>The <dfn attribute for="PageConcealEvent"><code
data-x="dom-PageConcealEvent-activation">activation</code></dfn> attribute, <dfn attribute
for="PageConcealEvent"><code
data-x="dom-PageConcealEvent-userInitiated">userInitiated</code></dfn>, and <dfn attribute
noamr marked this conversation as resolved.
Show resolved Hide resolved
for="PageConcealEvent"><code
data-x="dom-PageConcealEvent-viewTransition">viewTransition</code></dfn> attributes must return
the value they were initialized to.</p>

</div>


<h5>The <code>PageRevealEvent</code> interface</h5>

<pre><code class="idl">[Exposed=Window]
Expand Down Expand Up @@ -97466,6 +97518,9 @@ location.href = '#foo';</code></pre>

<dt><dfn data-x="source-snapshot-params-policy-container">source policy container</dfn></dt>
<dd>a <span>policy container</span></dd>

<dt><dfn data-x="source-snapshot-params-view-transition">view transition enabled</dfn>
noamr marked this conversation as resolved.
Show resolved Hide resolved
<dd>a boolean</dd>
</dl>

<p>To <dfn data-x="snapshotting source snapshot params">snapshot source snapshot params</dfn>
Expand All @@ -97490,6 +97545,10 @@ location.href = '#foo';</code></pre>
<dt><span data-x="source-snapshot-params-policy-container">source policy container</span></dt>
noamr marked this conversation as resolved.
Show resolved Hide resolved
<dd><var>sourceDocument</var>'s <span data-x="concept-document-policy-container">policy
container</span></dd>

<dt><span data-x="source-snapshot-params-view-transition">view transition enabled</span></dt>
<dd>false if the result of calling <span>resolve <code>@view-transition</code> rule</span> given
<var>sourceDocument</var> returns "<code data-x="">skip transition</code>"; Otherwise true</dd>
</dl>

<hr>
Expand Down Expand Up @@ -101105,9 +101164,67 @@ location.href = '#foo';</code></pre>
<p>If <var>changingNavigableContinuation</var>'s <span
data-x="changing-nav-continuation-update-only">update-only</span> is false, and
<var>targetEntry</var>'s <span data-x="she-document">document</span> does not equal
<var>displayedDocument</var>, then <span>unload a document and its descendants</span> given
<var>displayedDocument</var>, <var>targetEntry</var>'s <span
data-x="she-document">document</span>, and <var>afterPotentialUnloads</var>.</p>
<var>displayedDocument</var>, then:</p>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<ol>
<li><p>Let <var>potentiallyTriggerViewTransition</var> be false.</p></li>

<li><p>Let <var>userInitiated</var> be false if <var>userInvolvementForNavigateEvent</var>
noamr marked this conversation as resolved.
Show resolved Hide resolved
is "<code data-x="uni-none">none</code>"; otherwise true.</p></li>

<li><p>If <var>sourceSnapshotParams</var> is not null and <var>sourceSnapshotParams</var>'s
noamr marked this conversation as resolved.
Show resolved Hide resolved
<span data-x="source-snapshot-params-view-transition">view transition enabled</span> is true,
then set <var>potentiallyTriggerViewTransition</var> to the result of calling
<span>should navigation trigger a cross-document view-transition?</span> given
<var>displayedDocument</var>'s <span data-x="concept-document-origin">origin</span>,
<var>targetEntry</var>'s <span data-x="she-document">document</span>'s <span
data-x="concept-document-origin">origin</span>, <var>targetEntry</var>'s <span
data-x="she-document">document</span>'s <span>was created via cross-origin redirects</span>,
<var>navigationType</var>, and <var>userInitiated</var>.

<li><p>Let <var>concealStepForNavigation</var> given a <code>ViewTransition</code>-or-null
<var>viewTransition</var> be to <span>conceal</span> <var>displayedDocument</var> given
<var>targetEntry</var>, <var>navigationType</var>, and <var>viewTransition</var>.</p></li>

<li>
<p>Let <var>unloadSteps</var> be the following steps given an optional boolean
<var>shouldFireConcealEventBeforeUnload</var> (default false):</p>

<ol>
<li><p>Let <var>concealStep</var> be an algorithm that does nothing.</p></li>

<li><p>If <var>shouldFireConcealEventBeforeUnload</var> is true, then set
<var>concealStep</var> to the following step: run
<var>concealStepForNavigation</var> given null.</p></li>

<li><p><span>Unload a document and its descendants</span> given
<var>displayedDocument</var>, <var>targetEntry</var>'s <span
data-x="she-document">document</span>, <var>afterPotentialUnloads</var>, and
<var>concealStep</var>.</p>
</ol>

<li><p>If <var>potentiallyTriggerViewTransition</var> is false, then run
<var>unloadSteps</var> given true.</p></li>

noamr marked this conversation as resolved.
Show resolved Hide resolved
<li>
<p>Otherwise, <span>queue a global task</span> on the
<span>navigation and traversal task source</span> given <var>navigable</var>'s <span
data-x="nav-window">active window</span> to run the steps:</p>
noamr marked this conversation as resolved.
Show resolved Hide resolved

noamr marked this conversation as resolved.
Show resolved Hide resolved
<ol>
<li><p>Let <var>viewTransition</var> be the result of
<span>setting up a cross-document view-transition</span> given
<var>displayedDocument</var>, <var>targetEntry</var>'s <span
data-x="she-document">document</span>, <var>navigationType</var>, and
<var>unloadSteps</var>.</p></li>

<li><p>Run <var>fireConcealEventForThisNavigation</var> given
<var>viewTransition</var>.</p></li>

<li><p>If <var>viewTransition</var> is null, then run <var>unloadSteps</var>.</p></li>
</ol>
noamr marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ol>

noamr marked this conversation as resolved.
Show resolved Hide resolved
<p>Otherwise, <span>queue a global task</span> on the <span>navigation and traversal task
source</span> given <var>navigable</var>'s <span data-x="nav-window">active window</span> to
Expand Down Expand Up @@ -101772,7 +101889,7 @@ location.href = '#foo';</code></pre>
</ol>


<h5>Revealing the document</h5>
<h5>Revealing and concealing the document</h5>

<p>A <code>Document</code> has a boolean <dfn>has been revealed</dfn>, initially false. It is used
to ensure that the <code data-x="event-pagereveal">pagereveal</code> event is fired once for each
Expand Down Expand Up @@ -101805,6 +101922,69 @@ location.href = '#foo';</code></pre>
the presence of a <code data-x="event-pagereveal">pagereveal</code> handler from delaying the
presentation of such cached frame.</p>

<p>To <dfn>conceal</dfn> a <code>Document</code> <var>document</var>, given a
<span>session history entry</span> <var>targetEntry</var>, a <code>NavigationType</code>
<var>navigationType</var>, and a <code>ViewTransition</code>-or-null
<var>viewTransition</var> (default null):

<ol>
<li><p>Let <var>navigation</var> be <var>document</var>'s
<span>relevant global object</span>'s <span
data-x="window-navigation-api">navigation API</span>.</p></li>

<li>
<p>Let <var>destinationEntry</var> be determined by switching on
<var>navigationType</var>:</p>

<dl class="switch">
<dt>"<code data-x="dom-NavigationType-reload">reload</code>"</dt>
<dd><p>The <span data-x="navigation-current-entry">current entry</span> of
<var>navigation</var></p></dd>

<dt>"<code data-x="dom-NavigationType-traverse">traverse</code>"</dt>
<dd><p>The <code>NavigationHistoryEntry</code> in <var>navigation</var>'s <span
data-x="navigation-entry-list">entry list</span> whose <span
data-x="nhe-she">session history entry</span> is <var>targetEntry</var></p></dd>

<dt>"<code data-x="dom-NavigationType-push">push</code>"</dt>
<dt>"<code data-x="dom-NavigationType-replace">replace</code>"</dt>
<dd><p>If <var>targetEntry</var>'s <span data-x="she-document">span</span>'s <span
data-x="concept-document-origin">origin</span> is <span>same origin</span> with
<var>document</var>'s <span data-x="concept-document-origin">origin</span>, a new
<code>NavigationHistoryEntry</code> in <var>document</var>'s <span
data-x="concept-relevant-realm">relevant realm</span> with its <span
data-x="nhe-she">session history entry</span> set to <var>targetEntry</var>; Otherwise
null.</p></dd>
</dl>
</li>

<li>
<p>Let <var>activation</var> be a <span>new</span> <code>NavigationActivation</code>
created in <var>document</var>'s <span data-x="concept-relevant-realm">relevant
realm</span>, with</p>

<dl class="props">
<dt><span data-x="nav-activation-old-entry">old entry</span></dt>
<dd>The <span data-x="navigation-current-entry">current entry</span> of
<var>navigation</var>.</dd>

<dt><span data-x="nav-activation-new-entry">new entry</span></dt>
<dd><var>destinationEntry</var></dd>

<dt><span data-x="nav-activation-navigation-type">navigationType</span></dt>
<dd><var>navigationType</var></dd>
</dl>
</li>

<li><p><span data-x="concept-event-fire">Fire an event</span> named
<code data-x="event-pageconceal">pageconceal</code> at <var>document</var>'s
<span>relevant global object</span>, using <code>PageConcealEvent</code> with its <code
data-x="dom-PageConcealEvent-activation">activation</code> set to <var>activation</var>,
and its <code data-x="dom-PageConcealEvent-viewTransition">viewTransition</code> set to
<var>viewTransition</var>.</p></li>
</ol>



<h5>Scrolling to a fragment</h5>
noamr marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -102979,7 +103159,8 @@ new PaymentRequest(&hellip;); // Allowed to use

<p>To <dfn>unload a document and its descendants</dfn>, given a <code>Document</code>
<var>document</var>, an optional <code>Document</code>-or-null <var>newDocument</var> (default
null), and an optional set of steps <var>afterAllUnloads</var>:</p>
null), an optional set of steps <var>afterAllUnloads</var>, and an optional set of steps
<var>concealSteps</var>:</p>

<ol>
<li><p><span>Assert</span>: this is running within <var>document</var>'s <span>node
Expand Down Expand Up @@ -103017,6 +103198,8 @@ new PaymentRequest(&hellip;); // Allowed to use
steps:</p>

<ol>
<li><p>If <var>concealSteps</var> is given, then run <var>concealSteps</var>.</p></li>

<li><p><span data-x="unload a document">Unload</span> <var>document</var>, passing along
<var>newDocument</var> if it is not null.</p></li>

Expand Down Expand Up @@ -110374,6 +110557,7 @@ typedef <span>OnBeforeUnloadEventHandlerNonNull</span>? <dfn typedef>OnBeforeUnl
<tr><td><dfn attribute for="WindowEventHandlers"><code data-x="handler-window-onmessageerror">onmessageerror</code></dfn> <td> <code data-x="event-messageerror">messageerror</code> <!-- new for SAB -->
<tr><td><dfn attribute for="WindowEventHandlers"><code data-x="handler-window-onoffline">onoffline</code></dfn> <td> <code data-x="event-offline">offline</code> <!-- new -->
<tr><td><dfn attribute for="WindowEventHandlers"><code data-x="handler-window-ononline">ononline</code></dfn> <td> <code data-x="event-online">online</code> <!-- new -->
<tr><td><dfn attribute for="WindowEventHandlers"><code data-x="handler-window-onpageconceal">onpageconceal</code></dfn> <td> <code data-x="event-pageconceal">pageconceal</code> <!-- new -->
<tr><td><dfn attribute for="WindowEventHandlers"><code data-x="handler-window-onpagehide">onpagehide</code></dfn> <td> <code data-x="event-pagehide">pagehide</code> <!-- new -->
<tr><td><dfn attribute for="WindowEventHandlers"><code data-x="handler-window-onpagereveal">onpagereveal</code></dfn> <td> <code data-x="event-pagereveal">pagereveal</code> <!-- new -->
<tr><td><dfn attribute for="WindowEventHandlers"><code data-x="handler-window-onpageshow">onpageshow</code></dfn> <td> <code data-x="event-pageshow">pageshow</code> <!-- new -->
Expand Down Expand Up @@ -136262,6 +136446,7 @@ interface <dfn interface>External</dfn> {
<code data-x="handler-window-onmessageerror">onmessageerror</code>;
<code data-x="handler-window-onoffline">onoffline</code>;
<code data-x="handler-window-ononline">ononline</code>;
<code data-x="handler-window-onpageconceal">onpageconceal</code>;
<code data-x="handler-window-onpagehide">onpagehide</code>;
<code data-x="handler-window-onpagereveal">onpagereveal</code>;
<code data-x="handler-window-onpageshow">onpageshow</code>;
Expand Down Expand Up @@ -139512,6 +139697,12 @@ interface <dfn interface>External</dfn> {
<td> <code data-x="event-online">online</code> event handler for <code>Window</code> object
<td> <span data-x="event handler content attributes">Event handler content attribute</span>

<tr>
<th id="ix-handler-window-onpageconceal"> <code data-x="">onpageconceal</code>
<td> <code data-x="handler-window-onpageconceal">body</code>
<td> <code data-x="event-pageconceal">pageconceal</code> event handler for <code>Window</code> object
<td> <span data-x="event handler content attributes">Event handler content attribute</span>

<tr>
<th id="ix-handler-window-onpagehide"> <code data-x="">onpagehide</code>
<td> <code data-x="handler-window-onpagehide">body</code>
Expand Down Expand Up @@ -140387,6 +140578,13 @@ INSERT INTERFACES HERE
<td> <code>EventSource</code>
<td> Fired at <code>EventSource</code> objects when a connection is established

<tr> <!-- pageconceal -->
<td> <dfn event for="Window"><code data-x="event-pageconceal">pageconceal</code></dfn>
<td> <code>PageConcealEvent</code>
<td> <code>Window</code>
<td>Fired at the <code>Window</code> right before a document is <span
data-x="unload a document">unloaded</span> as a result of a same-origin navigation.

<tr> <!-- pagehide -->
<td> <dfn event for="Window"><code data-x="event-pagehide">pagehide</code></dfn>
<td> <code>PageTransitionEvent</code>
Expand Down
Loading