From 8b68235ca2432808bba96c52ab3335eaac148a47 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 4 Dec 2023 20:47:05 +0000 Subject: [PATCH 1/4] [css-view-transitions-1] Defer restoring persisted state until after old doc capture --- css-view-transitions-1/Overview.bs | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/css-view-transitions-1/Overview.bs b/css-view-transitions-1/Overview.bs index e8470848f557..43dcaa1cabe9 100644 --- a/css-view-transitions-1/Overview.bs +++ b/css-view-transitions-1/Overview.bs @@ -47,6 +47,9 @@ spec:css-display-4; type: dfn; text:invisible; urlPrefix: https://wicg.github.io/navigation-api/; type: interface; text: NavigateEvent text: signal; for: NavigateEvent; url: #ref-for-dom-navigateevent-signalâ‘  +urlPrefix: https://html.spec.whatwg.org/multipage/; spec: html; type: dfn; + text: restore persisted state; url: #restore-persisted-state + text: latest entry; url: #latest-entry @@ -1094,6 +1097,18 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; Initially null. Note: this is used for cross-document view transitions. + + : persisted state restoration + :: One of the following, initially "`defer`": + + 1. "`defer`". + 1. "`pending`". + 1. "`immediate`". + + Note: this is used to defer automatic restoration of persisted state, e.g. scroll position, + to be performed after the old state is captured. When in the "`defer`" mode, persisted state + is not yet requested, but should be deferred if requested. When in the "`pending`" mode, + persisted state restoration is requested and should be performed once the old state is captured. A {{ViewTransition}} must never have both an [=ViewTransition/update callback=] and a [=ViewTransition/process old state captured=]. @@ -1252,10 +1267,16 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; If failure is returned, then [=skip the view transition=] for |transition| with an "{{InvalidStateError}}" {{DOMException}} in |transition|'s [=relevant Realm=], and return. + 1. [=Resolve persisted state restoration=] for |transition|. + 1. If |transition|'s [=ViewTransition/process old state captured=] is not null, then call [=ViewTransition/process old state captured=] and return. 1. Set |document|'s [=document/rendering suppression for view transitions=] to true. + 1. Set |transition|'s [=ViewTransition/persisted state restoration=] to "`immediate`". + + Note: Now that the old state is captured, synchronous restoring persisted state should behave as normal. + 1. [=Queue a global task=] on the [=DOM manipulation task source=], given |transition|'s [=relevant global object=], to execute the following steps: @@ -1912,6 +1933,23 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; 1. Set |document|'s [=document/active view transition=] to null. +## [=persisted state restoration=] ## {#persisted-state-restoration-algorithm} + +
+ To request persisted state restoration for a {{Document}} |document|: + + 1. Let |transition| be |document|'s [=active view transition=]. + 1. If |transition| is null or its [=ViewTransition/persisted state restoration=] is "`immediate`", then return true. + 1. Set |transition|'s [=ViewTransition/persisted state restoration=] to "`pending`". + 1. Return false. +
+ +
+ To resolve persisted state restoration for a {{ViewTransition}} |transition|: + 1. If |transition|'s [=ViewTransition/persisted state restoration=] is "`pending`", then + [=restore persisted state=] given |transition|'s [=associated document=]'s [=latest entry=]. + 1. Set |transition|'s [=ViewTransition/persisted state restoration=] to "`immediate`". +

Privacy Considerations

This specification introduces no new privacy considerations. From 49688151e823c91826b61e6839e1eb84e4eba822 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 4 Dec 2023 20:50:00 +0000 Subject: [PATCH 2/4] Add to change list --- css-view-transitions-1/Overview.bs | 1 + 1 file changed, 1 insertion(+) diff --git a/css-view-transitions-1/Overview.bs b/css-view-transitions-1/Overview.bs index 43dcaa1cabe9..ace6dcfca78a 100644 --- a/css-view-transitions-1/Overview.bs +++ b/css-view-transitions-1/Overview.bs @@ -1978,6 +1978,7 @@ Changes from issue 9276. * Expose [=auto-skip view transition=] for a {{Document}}, to allow having outbound cross-document transitions preceed programmatic view transiitons. see issue 9512. * Add a note about why 'view-transition-name' should be animatable. +* Export an algorithm and add mechanism to defer restoring scroll/persisted state.

Changes from 2022-05-25 Working Draft From 10474344ba1be67400332876e477f89c2fa816ae Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 13 Dec 2023 16:44:27 +0000 Subject: [PATCH 3/4] Rename algo --- css-view-transitions-1/Overview.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/css-view-transitions-1/Overview.bs b/css-view-transitions-1/Overview.bs index ace6dcfca78a..6382d15e3ef3 100644 --- a/css-view-transitions-1/Overview.bs +++ b/css-view-transitions-1/Overview.bs @@ -1936,12 +1936,12 @@ urlPrefix: https://html.spec.whatwg.org/multipage/; spec: html; type: dfn; ## [=persisted state restoration=] ## {#persisted-state-restoration-algorithm}
- To request persisted state restoration for a {{Document}} |document|: + To potentially defer persisted state restoration for a {{Document}} |document|: 1. Let |transition| be |document|'s [=active view transition=]. - 1. If |transition| is null or its [=ViewTransition/persisted state restoration=] is "`immediate`", then return true. + 1. If |transition| is null or its [=ViewTransition/persisted state restoration=] is "`immediate`", then return "`proceed`". 1. Set |transition|'s [=ViewTransition/persisted state restoration=] to "`pending`". - 1. Return false. + 1. Return "`defer`".
From 65a425a8211f86334942fb51c7dc32fd8cab4a2b Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 18 Dec 2023 10:31:54 +0000 Subject: [PATCH 4/4] Update ref --- css-view-transitions-1/Overview.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/css-view-transitions-1/Overview.bs b/css-view-transitions-1/Overview.bs index 6382d15e3ef3..813cc345337c 100644 --- a/css-view-transitions-1/Overview.bs +++ b/css-view-transitions-1/Overview.bs @@ -49,7 +49,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; text: signal; for: NavigateEvent; url: #ref-for-dom-navigateevent-signalâ‘  urlPrefix: https://html.spec.whatwg.org/multipage/; spec: html; type: dfn; text: restore persisted state; url: #restore-persisted-state - text: latest entry; url: #latest-entry + text: active session history entry; url: #nav-active-history-entry @@ -1947,7 +1947,7 @@ urlPrefix: https://html.spec.whatwg.org/multipage/; spec: html; type: dfn;
To resolve persisted state restoration for a {{ViewTransition}} |transition|: 1. If |transition|'s [=ViewTransition/persisted state restoration=] is "`pending`", then - [=restore persisted state=] given |transition|'s [=associated document=]'s [=latest entry=]. + [=restore persisted state=] given |transition|'s [=associated document=]'s [=node navigable=]'s [=active session history entry=]. 1. Set |transition|'s [=ViewTransition/persisted state restoration=] to "`immediate`".

Privacy Considerations