You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[css-view-transitions-2] Update the algorithm to check opt-in on outbound transition (#10078)
* [css-view-transitions-2] Update the algorithm to check opt-in on outbound transition
Instead of relying on the source snapshot params in HTML, we update a flag
every time something relevant changes, and HTML can read that flag.
* Refactor outbound algo into vt
Note: this value can be read [=in parallel=] while navigating.
530
541
</dl>
531
542
532
543
### The View transition params struct ### {#view-transition-params-struct}
@@ -660,20 +671,24 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
660
671
661
672
<div algorithm>
662
673
To check if a <dfn export>navigation can trigger a cross-document view-transition?</dfn> given
663
-
an [=/origin=] |oldOrigin|, an [=/origin=] |newOrigin|, a boolean |navigationHasCrossOriginRedirects|, a {{NavigationType}} |navigationType|, and a boolean |isBrowserUINavigation|:
674
+
a {{Document}} |oldDocument|, a {{Document}} |newDocument|, a {{NavigationType}} |navigationType|, and a boolean |isBrowserUINavigation|:
664
675
665
-
Note: this is called during navigation, potentially [=in parallel=], for documents that have opted-in to view-transitions using the ''@view-transition'' rule.
676
+
Note: this is called during navigation, potentially [=in parallel=].
666
677
667
678
1. If the user agent decides to display an [=implementation-defined=] navigation experience, e.g. a gesture-based transition for a back navigation,
668
679
the user agent may ignore the author-defined view transition. If that is the case, return false.
669
680
681
+
1. If |oldDocument|'s [=can initiate outbound view transition=] is false, then return false.
682
+
670
683
1. If |navigationType| is {{NavigationType/reload}}, then return false.
671
684
672
-
1. If |isBrowserUINavigation| is true, and |navigationType| is {{NavigationType/push}} or {{NavigationType/replace}}, then return false.
685
+
1. If |oldDocument|'s [=Document/origin=] is not [=same origin=] as |newDocument|'s [=Document/origin=], then return false.
673
686
674
-
1. If |oldOrigin| is not [=same origin=] as |newOrigin| then return false.
687
+
1. If |navigationType| is {{NavigationType/traverse}}, then return true.
675
688
676
-
1. If |navigationHasCrossOriginRedirects| is true, then return false.
689
+
1. If |isBrowserUINavigation| is true, then return false.
690
+
691
+
1. If |newDocument| [=was created via cross-origin redirects=], then return false.
677
692
678
693
1. Return true.
679
694
</div>
@@ -683,11 +698,11 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
683
698
684
699
1. [=Assert=]: These steps are running as part of a [=task=] queued on |oldDocument|.
685
700
686
-
1. If |oldDocument|'s [=has been revealed=] is false, then return null.
701
+
1. If |oldDocument|'s [=can initiate outbound view transition=] is false, then return null.
687
702
688
-
1. Let |resolvedRule| be the result of [=Resolve @view-transition rule|resolving the @view-transition rule=] for |oldDocument|.
703
+
1. Let |transitionTypesFromRule| be the result of [=Resolve @view-transition rule|resolving the @view-transition rule=] for |oldDocument|.
689
704
690
-
1. If |resolvedRule| is "<code>skip transition</code>", then return null.
705
+
1. [=Assert=]: |transitionTypesFromRule| is not "<code>skip transition</code>".
691
706
692
707
Note: We don't know yet if |newDocument| has opted in, as it might not be parsed yet.
693
708
We check the opt-in for |newDocument| when we fire the {{Window/pagereveal}} event.
@@ -701,7 +716,7 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
701
716
702
717
1. Let |outboundTransition| be a new {{ViewTransition}} object in |oldDocument|'s [=relevant Realm=].
703
718
704
-
1. Set |outboundTransition|'s [=ViewTransition/active types=]'s [=DOMTokenList/token set=] to |resolvedRule|.
719
+
1. Set |outboundTransition|'s [=ViewTransition/active types=]'s [=DOMTokenList/token set=] to |transitionTypesFromRule|.
705
720
706
721
Note: the [=ViewTransition/active types=] are not shared between documents.
707
722
Manipulating the {{ViewTransition/typeList}} in the new document does not affect the types in the new document,
@@ -732,10 +747,14 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
732
747
### Accessing the view-transition in the new {{Document}} ### {#access-view-transition-in-new-doc}
733
748
734
749
<div algorithm>
735
-
To <dfn export>resolve cross-document view-transition</dfn> for {{Document}} |document|:
750
+
To <dfn export>resolve inbound cross-document view-transition</dfn> for {{Document}} |document|:
736
751
737
752
1. [=Assert=]: |document| is [=fully active=].
738
753
754
+
1. [=Assert=]: |document| [=has been revealed=] is true.
755
+
756
+
1. [=Update the opt-in state for outbound transitions=] for |document|.
757
+
739
758
1. Let |inboundViewTransitionParams| be |document|'s [=inbound view transition params=].
740
759
741
760
1. If |inboundViewTransitionParams| is null, then return null.
@@ -769,6 +788,14 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
769
788
1. Return |transition|.
770
789
</div>
771
790
791
+
### Updating the opt-in state for outbound view transitions ### {#update-opt-in-state-for-outbound}
792
+
793
+
<div algorithm="update-opt-in-for-outbound">
794
+
To <dfn>update the opt-in state for outbound transitions</dfn> for a {{Document}} |document|:
795
+
1. If |document| [=has been revealed=], and the result of [=resolve @view-transition rule|resolving the @view-transition rule=] is not "<code>skip transition</code>",
796
+
then set |document|'s [=can initiate outbound view transition=] to true.
797
+
1. Otherwise, set |document|'s [=can initiate outbound view transition=] to false.
0 commit comments