-
Notifications
You must be signed in to change notification settings - Fork 636
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
[css-view-transitions-1] Defer restoring persisted state until after capturing old state #9676
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: active session history entry; url: #nav-active-history-entry | ||
</pre> | ||
|
||
<script async type="module" src="diagrams/resources/scaler.js"></script> | ||
|
@@ -1094,6 +1097,18 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; | |
Initially null. | ||
|
||
Note: this is used for cross-document view transitions. | ||
|
||
: <dfn>persisted state restoration</dfn> | ||
:: 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add what immediate implies as well? |
||
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. | ||
</dl> | ||
|
||
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|. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should do this in the skip case as well. |
||
|
||
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. | ||
</div> | ||
|
||
## [=persisted state restoration=] ## {#persisted-state-restoration-algorithm} | ||
|
||
<div algorithm> | ||
To <dfn export>potentially defer persisted state restoration</dfn> 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 "`proceed`". | ||
1. Set |transition|'s [=ViewTransition/persisted state restoration=] to "`pending`". | ||
1. Return "`defer`". | ||
</div> | ||
|
||
<div algorithm> | ||
To <dfn>resolve persisted state restoration</dfn> for a {{ViewTransition}} |transition|: | ||
1. If |transition|'s [=ViewTransition/persisted state restoration=] is "`pending`", then | ||
[=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`". | ||
</div> | ||
<h2 id="priv" class="no-num">Privacy Considerations</h2> | ||
|
||
This specification introduces no new privacy considerations. | ||
|
@@ -1940,6 +1978,7 @@ Changes from <a href="https://www.w3.org/TR/2023/WD-css-view-transitions-1-20230 | |
* Copy `color-scheme` from DOM element to ''::view-transition-group()''. See <a href="https://github.com/w3c/csswg-drafts/issues/9276">issue 9276</a>. | ||
* Expose [=auto-skip view transition=] for a {{Document}}, to allow having outbound cross-document transitions preceed programmatic view transiitons. see <a href="https://github.com/w3c/csswg-drafts/issues/9512">issue 9512</a>. | ||
* Add a note about why 'view-transition-name' should be animatable. | ||
* Export an algorithm and add mechanism to defer restoring scroll/persisted state. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a link to an html or csswg issue where this was discussed? |
||
|
||
<h3 id="changes-since-2022-05-25"> | ||
Changes from <a href="https://www.w3.org/TR/2023/WD-css-view-transitions-1-20230525/">2022-05-25 Working Draft</a> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have scroll restoration in the spec for cross-document navigations?