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
with [=this=]'s [=document element=] is its [=originating element=].
1159
1151
1160
1152
Note: The position of the [=ViewTransition/transition root pseudo-element=] within the [=document element=] does not matter, as the [=ViewTransition/transition root pseudo-element=]'s [=containing block=] is the [=snapshot containing block=].
If failure is returned, then [=skip the view transition=] for |transition| with an "{{InvalidStateError}}" {{DOMException}} in |transition|'s [=relevant Realm=],
1260
1249
and return.
1261
1250
1262
-
1. If |transition|'s [=ViewTransition/process old state captured=] is not null, then call [=ViewTransition/process old state captured=] and return.
1263
-
1264
1251
1. Set |document|'s [=document/rendering suppression for view transitions=] to true.
1265
1252
1266
1253
1. [=Queue a global task=] on the [=DOM manipulation task source=],
Note: Since the rejection of |transition|'s [=ViewTransition/update callback done promise=] isn't explicitly handled here,
1681
1668
if |transition|'s [=ViewTransition/update callback done promise=] rejects,
1682
1669
then |transition|'s [=ViewTransition/finished promise=] will reject with the same reason.
1683
-
1684
-
1. If |transition|'s [=ViewTransition/process old state captured=] is not null, then call |transition|'s [=ViewTransition/process old state captured=].
1685
1670
</div>
1686
1671
1687
1672
## [=Capture the image=] ## {#capture-the-image-algorithm}
@@ -1960,6 +1945,8 @@ Changes from <a href="https://www.w3.org/TR/2023/WD-css-view-transitions-1-20230
1960
1945
* Refactor algorithm to clarify timing, especially of `updateCallbackDone. See <a href="https://github.com/w3c/csswg-drafts/issues/9762">issue 9762</a>.
1961
1946
* Add animation-delay inherit to UA stylesheet rules for (::view-transition) -image-pair, -old, and -new. See <a href="https://github.com/w3c/csswg-drafts/issues/9817">issue 9817</a>.
1962
1947
* Auto-skip animation when document is hidden. See <a href="https://github.com/w3c/csswg-drafts/issues/9543">issue 9543</a>.
1948
+
* Remove references to cross-document view-transitions, to keep the L1 spec clean. See <a href="https://github.com/w3c/csswg-drafts/issues/9886">Issue 9886</a>.
1949
+
1963
1950
<h3 id="changes-since-2022-05-25">
1964
1951
Changes from <a href="https://www.w3.org/TR/2023/WD-css-view-transitions-1-20230525/">2022-05-25 Working Draft</a>
text: named view transition pseudo-element; type: dfn;
40
+
text: rendering suppression for view transitions; type: dfn;
36
41
spec:dom; type:dfn; text:document
37
42
spec:css22; type:dfn; text:element
38
43
spec:selectors-4; type:dfn;
@@ -446,13 +451,24 @@ Note: as per default behavior, the ''@view-transition'' rule can be nested insid
446
451
<div algorithm="start-vt-with-options">
447
452
The [=method steps=] for <dfn method for=Document>startViewTransition(|callbackOptions|)</dfn> are as follows:
448
453
449
-
1. If |callbackOptions| is not provided, then run the [=method steps=] for {{Document/startViewTransition()}} and return the result.
454
+
1. Let |updateCallback| be null.
450
455
451
-
1. If |callbackOptions| is an {{UpdateCallback}}, then run the [=method steps=] for {{Document/startViewTransition(updateCallback)}} given |callbackOptions| and return the result.
456
+
1. If |callbackOptions| is an an {{UpdateCallback}}, set |updateCallback| to |callbackOptions|.
452
457
453
-
1. Let |viewTransition| be the result of running [=method steps=] for {{Document/startViewTransition(updateCallback)}} given |callbackOptions|'s {{StartViewTransitionOptions/update}}.
458
+
1. Otherwise, if |callbackOptions| is a {{StartViewTransitionOptions}}, then set |updateCallback| to |callbackOptions|'s {{StartViewTransitionOptions/update}}.
454
459
455
-
1. Set |viewTransition|'s [=ViewTransition/active types=] to |callbackOptions|'s {{StartViewTransitionOptions/type}}.
460
+
1. If |this|'s [=active view transition=] is not null and its [=outbound post-capture steps=] is not null,
461
+
then:
462
+
463
+
1. Let |preSkippedTransition| be a new {{ViewTransition}} in |this|'s [=relevant realm=] whose [=ViewTransition/update callback=] is |updateCallback|.
464
+
465
+
1. [=Skip the view transition|Skip=] |preSkippedTransition| with an "{{InvalidStateError}}" {{DOMException}}.
466
+
467
+
1. Return |preSkippedTransition|.
468
+
469
+
1. Let |viewTransition| be the result of running the [=method steps=] for {{Document/startViewTransition(updateCallback)}} given |updateCallback|.
470
+
471
+
1. If |callbackOptions| is a {{StartViewTransitionOptions}}, then set |viewTransition|'s [=ViewTransition/active types=] to |callbackOptions|'s {{StartViewTransitionOptions/type}}.
456
472
457
473
1. Return |viewTransition|.
458
474
</div>
@@ -484,14 +500,34 @@ The {{CSSViewTransitionRule}} represents a ''@view-transition'' rule.
484
500
# Algorithms # {#algorithms}
485
501
## Data Structures ## {#concepts}
486
502
503
+
### Additions to {{Document}} ### {#additions-to-document}
504
+
A {{Document}} additionaly has:
505
+
506
+
<dl dfn-for=document>
507
+
: <dfn>inbound view transition params</dfn>
508
+
:: a [=view transition params=], or null.
509
+
Initially null.
510
+
</dl>
511
+
512
+
### The View transition params struct ### {#view-transition-params-struct}
513
+
514
+
A <dfn>view transition params</dfn> is a [=struct=] whose purpose is to serialize view transition information across documents.
515
+
It has the following [=struct/items=]:
516
+
517
+
<dl dfn-for="view transition params">
518
+
: <dfn>named elements</dfn>
519
+
:: a [=/map=], whose keys are strings and whose values are [=captured elements=].
### Additions to {{ViewTransition}} ### {#view-transitions-extension}
488
526
489
527
A {{ViewTransition}} additionally has:
490
528
<dl dfn-for=ViewTransition>
491
-
: <dfn>is inbound cross-document transition</dfn>
492
-
:: a boolean, initially false.
493
-
494
-
Issue: should a cross-document transition take precedent? See [#9512](https://github.com/w3c/csswg-drafts/issues/9512)
529
+
: <dfn>outbound post-capture steps</dfn>
530
+
:: Null or a set of steps, initially null.
495
531
496
532
: <dfn>active types</dfn>
497
533
:: Null or a [=list=] of strings, initially null.
@@ -506,7 +542,7 @@ The [=captured element=] struct should contain these fields, in addition to the
506
542
:: a [=/list=] of strings, initially empty.
507
543
</dl>
508
544
509
-
## Algorithms to capture 'view-transition-class': ## {#vt-class-algorithms}
545
+
## Algorithm to capture 'view-transition-class': ## {#vt-class-algorithms}
510
546
<div algorithm="additional capture steps">
511
547
When capturing the old or new state for an element, perform the following steps given a [=captured element=] |capture| and an [=element=] |element|:
512
548
@@ -515,6 +551,44 @@ When capturing the old or new state for an element, perform the following steps
515
551
Note: This is written in a monkey-patch manner, and will be merged into the algorithm once the L1 spec graduates.
516
552
</div>
517
553
554
+
## Additions to skip steps: ## {#additional-skip-steps}
555
+
<div algorithm="additional skip steps">
556
+
Append the following steps to [=skip the view transition=] given a {{ViewTransition}} |transition|:
557
+
1. If |transition|'s [=outbound post-capture steps=] is not null, then run |transition|'s [=outbound post-capture steps=] with null.
558
+
559
+
Note: This is written in a monkey-patch manner, and will be merged into the algorithm once the L1 spec graduates.
560
+
</div>
561
+
562
+
## Addition to pending transition operations ## {#additions-to-pending-transition-operation}
563
+
564
+
Prepend this to the [=Perform pending transition operations=] algorithm given a {{Document}} |document|:
565
+
1. If |document|'s [=active view transition=] is not null and its [=outbound post-capture steps=] is not null, then:
566
+
567
+
1. Assert: |document|'s [=active view transition=]'s [=ViewTransition/phase=] is "`pending-capture`".
568
+
569
+
1. Let |viewTransitionParams| be null;
570
+
571
+
1. Set |document|'s [=document/rendering suppression for view transitions=] to true.
572
+
573
+
Issue: though [=capture the old state=] appears here as a synchronous step, it is in fact an asynchronous step
574
+
as rendering an element into an image cannot be done synchronously. This should be more explicit in the L1 spec.
575
+
576
+
1. [=Capture the old state=] for |transition|.
577
+
578
+
1. Set |document|'s [=document/rendering suppression for view transitions=] to false.
579
+
580
+
1. If this succeeded, then set |viewTransitionParams| to a new [=view transition params=] whose
581
+
[=view transition params/named elements=] is a [=map/clone=] of |transition|'s [=ViewTransition/named elements=],
582
+
and whose [=view transition params/initial snapshot containing block size=] is |transition|'s [=ViewTransition/initial snapshot containing block size=].
583
+
584
+
1. [=Clear view transition=] |transition|.
585
+
586
+
Note: The ViewTransition object on the old Document should be destroyed after its state has been copied to the new Document below.
587
+
We explicitly clear it here since the old Document may be cached by the UA.
588
+
589
+
1. Call |transition|'s [=outbound post-capture steps=] given |viewTransitionParams|.
590
+
591
+
518
592
## Monkey patches to HTML ## {#monkey-patch-to-html}
519
593
520
594
<div algorithm="monkey patch to apply the history step">
@@ -558,7 +632,7 @@ When capturing the old or new state for an element, perform the following steps
558
632
559
633
<div algorithm>
560
634
To check if a <dfn export>navigation can trigger a cross-document view-transition?</dfn> given
561
-
an [=origin=] |oldOrigin|, an [=origin=] |newOrigin|, a boolean |navigationHasCrossOriginRedirects|, a {{NavigationType}} |navigationType|, and a boolean |isBrowserUINavigation|:
635
+
an [=/origin=] |oldOrigin|, an [=/origin=] |newOrigin|, a boolean |navigationHasCrossOriginRedirects|, a {{NavigationType}} |navigationType|, and a boolean |isBrowserUINavigation|:
562
636
563
637
Note: this is called during navigation, potentially [=in parallel=], for documents that have opted-in to view-transitions using the ''@view-transition'' rule.
564
638
@@ -577,7 +651,9 @@ When capturing the old or new state for an element, perform the following steps
577
651
</div>
578
652
<div algorithm>
579
653
To <dfn export>setup cross-document view-transition</dfn> given a {{Document}} |oldDocument|,
580
-
a {{Document}} |newDocument|, and |onReady|, which is an algorithm accepting nothing:
654
+
a {{Document}} |newDocument|, and |proceedWithNavigation|, which is an algorithm accepting nothing:
655
+
656
+
1. [=Assert=]: These steps are running as part of a [=task=] queued on |oldDocument|.
581
657
582
658
1. Let |resolvedRule| be the result of [=Resolve @view-transition rule|resolving the @view-transition rule=] for |oldDocument|.
583
659
@@ -593,54 +669,19 @@ When capturing the old or new state for an element, perform the following steps
593
669
Note: this means that any running transition would be skipped when the document is ready
594
670
to unload.
595
671
596
-
1. Set |oldDocument|'s [=auto-skip view transitions=] to true.
597
-
598
-
Note: this means that calling {{Document/startViewTransition()}} while capturing the old document for a cross-document view-transition would run the callback but skip the animation.
599
-
600
672
1. Let |outboundTransition| be a new {{ViewTransition}} object in |oldDocument|'s [=relevant Realm=],
601
-
whose [=ViewTransition/active types=] is |resolvedRule|, and whose [=ViewTransition/process old state captured=] is set to the following steps:
602
-
603
-
Issue: should we check for the opt-in again, in case there was a CSSOM change in a requestAnimationFrame callback?
604
-
605
-
1. If |outboundTransition|'s [=ViewTransition/phase=] is "`done`", then call |onReady| and return.
606
-
607
-
1. Assert: |outboundTransition|'s [=ViewTransition/phase=] is "`pending-capture`".
and whose [=ViewTransition/is inbound cross-document transition=] is true.
675
+
1. Set |outboundTransition|'s [=outbound post-capture steps=] to the following steps given a [=view transition params=]-or-null |params|:
676
+
1. Set |newDocument|'s [=inbound view transition params=] to |params|.
623
677
624
-
1. Set |newDocument|'s [=active view transition=]to |inboundTransition|.
678
+
Note: The inbound transition is activated after the dispatch of {{Window/pagereveal}}to ensure mutations made in this event apply to the captured new state.
625
679
626
-
1. [=Resolve=] |inboundTransition|’s [=ViewTransition/update callback done promise=] with undefined.
627
-
628
-
1. Set |inboundTransition|’s [=ViewTransition/phase=] to "`update-callback-called`".
629
-
630
-
1. Call |onReady|.
631
-
632
-
Note: The |inboundTransition| is activated after the dispatch of {{Window/pagereveal}} to ensure mutations made in this event apply to the captured new state.
633
-
634
-
1. At any given time, the UA may decide to skip |inboundTransition|, e.g. after an [=implementation-defined=] timeout.
635
-
To do so, the UA should [=queue a global task=] on the [=DOM manipulation task source=] given |newDocument|'s [=relevant global object=] to perform the following step:
636
-
If |transition|'s [=ViewTransition/phase=] is not "`done`", then [=skip the view transition=] |transition| with a "{{TimeoutError}}" {{DOMException}}.
637
-
638
-
Note: |outboundTransition| is not exposed to JavaScript, it is used only for capturing
639
-
the state of the old document.
680
+
1. Call |proceedWithNavigation|.
640
681
641
682
1. Set |oldDocument|'s [=active view transition=] to |outboundTransition|.
642
683
643
-
Note: The process continues in [=setup view transition=], via [=perform pending transition operations=].
684
+
Note: The process continues in [=perform pending transition operations=].
644
685
645
686
1. The user agent should display the currently displayed frame until either:
646
687
* The {{Window/pagereveal}} event is fired.
@@ -656,20 +697,38 @@ When capturing the old or new state for an element, perform the following steps
656
697
<div algorithm>
657
698
To <dfn export>resolve cross-document view-transition</dfn> for {{Document}} |document|:
658
699
659
-
1. Let |transition| be |document|'s [=active view transition=].
700
+
1. [=Assert=]: |document| is [=fully active=].
701
+
702
+
1. Let |inboundViewTransitionParams| be |document|'s [=inbound view transition params=].
703
+
704
+
1. If |inboundViewTransitionParams| is null, then return null.
705
+
706
+
1. Set |document|'s [=inbound view transition params=] to null.
660
707
661
-
1. If |transition| is null or |transition|'s [=ViewTransition/is inbound cross-document transition=] is false,
662
-
then return null.
708
+
1. If |document|'s [=active view transition=] is not null, then return null.
663
709
664
-
Note: |transition|'s [=ViewTransition/is inbound cross-document transition=] would be false if a same-document
665
-
transition was started before the {{Window/pagereveal}} event was fired.
710
+
Note: this means that starting a same-document transition before revealing the document would cancel a pending cross-document transition.
666
711
667
712
1. [=Resolve @view-transition rule=] for |document| and let |resolvedRule| be the result.
668
713
669
-
1. If |resolvedRule| is "<code>skip transition</code>", then [=skip the view transition|skip=] |transition| and return null.
714
+
1. If |resolvedRule| is "<code>skip transition</code>", then return null.
715
+
716
+
1. Let |transition| be a new {{ViewTransition}} in |document|'s [=relevant Realm=],
717
+
whose [=ViewTransition/named elements=] is |inboundViewTransitionParams|'s [=view transition params/named elements=],
718
+
and [=ViewTransition/initial snapshot containing block size=] is |inboundViewTransitionParams|'s [=view transition params/initial snapshot containing block size=].
719
+
720
+
1. Set |document|'s [=active view transition=] to |transition|.
721
+
722
+
1. [=Resolve=] |transition|’s [=ViewTransition/update callback done promise=] with undefined.
723
+
724
+
1. Set |transition|’s [=ViewTransition/phase=] to "`update-callback-called`".
670
725
671
726
1. Set |transition|'s [=ViewTransition/active types=] to |resolvedRule|.
672
727
728
+
1. At any given time, the UA may decide to skip the inbound transition, e.g. after an [=implementation-defined=] timeout.
729
+
To do so, the UA should [=queue a global task=] on the [=DOM manipulation task source=] given |document|'s [=relevant global object=] to perform the following step:
730
+
If |transition|'s [=ViewTransition/phase=] is not "`done`", then [=skip the view transition=] |transition| with a "{{TimeoutError}}" {{DOMException}}.
0 commit comments