Skip to content

Commit bd11f28

Browse files
noamrkhushalsagar
andauthored
[css-view-transitions-2] Apply resolutions for view-transition types (#10072)
* [css-view-transitions-2] Apply resolutions for view-transition types - Make types mutable using ViewTransition.typeList #9542 (comment) - Separate `:active-view-transition` and `:active-view-transition-type` See #9972 (comment) - Add notes about types being bound to one document See #9526 (comment) Closes #9972 Closes #9542 Closes #9526 Closes #9626 Co-authored-by: Khushal Sagar <63884798+khushalsagar@users.noreply.github.com> --------- Co-authored-by: Khushal Sagar <63884798+khushalsagar@users.noreply.github.com>
1 parent b02ed87 commit bd11f28

File tree

1 file changed

+56
-26
lines changed

1 file changed

+56
-26
lines changed

css-view-transitions-2/Overview.bs

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -290,39 +290,51 @@ for multiple view transition pseudo elements without having to replicate the cor
290290

291291
# Pseudo-classes # {#pseudo-classes}
292292

293-
## Active View Transition Pseudo-class '':active-view-transition()''' ## {#the-active-view-transition-pseudo}
293+
## Active View Transition Pseudo-class '':active-view-transition()'' ## {#the-active-view-transition-pseudo}
294294

295-
The <dfn id='active-view-transition-pseudo'>:active-view-transition(<<vt-type-selector>>)</dfn> pseudo-class applies to the root element of the document, if it has a matching [=active view transition=].
295+
The <dfn id='active-view-transition-pseudo'>:active-view-transition</dfn> pseudo-class applies to the root element of the document, if it has an [=active view transition=].
296296
It has the following syntax definition:
297297

298298
<pre class=prod>
299-
:active-view-transition(<<vt-type-selector>>)
300-
<dfn>&lt;vt-type-selector></dfn> = '*' | <<custom-ident>>#
299+
:active-view-transition
301300
</pre>
302301

303-
The [=specificity=] of an '':active-view-transition()'' is one pseudo-class selector if it has value is ''*'', and two if it has any other value.
302+
The [=specificity=] of an '':active-view-transition'' is one pseudo-class selector.
304303

305-
An '':active-view-transition()'' pseudo-class matches the [=document element=] when it has an non-null [=active view transition=] |viewTransition|, for which any of the following are true:
304+
An '':active-view-transition'' pseudo-class matches the [=document element=] when its [=node document=] has an non-null [=active view transition=].
306305

307-
* The <<vt-type-selector>> is ''*''
308-
* |viewTransition|'s [=ViewTransition/active types=] [=list/contains=] at least one of the <<custom-ident>> values of the <<vt-type-selector>>.
306+
## Active View Transition Type Pseudo-class '':active-view-transition-type()'' ## {#the-active-view-transition-type-pseudo}
307+
308+
The <dfn id='active-view-transition-type-pseudo'>:active-view-transition-type()</dfn> pseudo-class applies to the root element of the document, if it has a matching [=active view transition=].
309+
It has the following syntax definition:
310+
311+
<pre class=prod>
312+
:active-view-transition-type(<<custom-ident>>#)
313+
</pre>
314+
315+
The [=specificity=] of an '':active-view-transition-type()'' is two pseudo-class selectors.
316+
317+
An '':active-view-transition-type()'' pseudo-class matches the [=document element=] when its [=node document=] has an non-null [=active view transition=],
318+
whose [=ViewTransition/active types=] [=list/contains=] at least one of the <<custom-ident>> arguments.
319+
320+
## Examples ## {#active-view-transition-pseudo-examples}
309321

310322
<div class=example>
311323
For example, the developer might start a transition in the following manner:
312324
```js
313-
document.startViewTransition({update: updateTheDOMSomehow, types: ["slide-in", "reverse"]});
325+
document.startViewTransition({update: updateTheDOMSomehow, type: ["slide-in", "reverse"]});
314326
```
315327

316-
This will activate any of the following ':active-view-transition()'' selectors:
328+
This will activate any of the following ':active-view-transition-type()'' selectors:
317329
```css
318-
:root:active-view-transition(slide-in) {}
319-
:root:active-view-transition(reverse) {}
320-
:root:active-view-transition(slide-in, reverse) {}
321-
:root:active-view-transition(slide-in, something-else) {}
322-
:root:active-view-transition(*) {}
330+
:root:active-view-transition-type(slide-in) {}
331+
:root:active-view-transition-type(reverse) {}
332+
:root:active-view-transition-type(slide-in, reverse) {}
333+
:root:active-view-transition-type(slide-in, something-else) {}
334+
:root:active-view-transition {}
323335
```
324336

325-
While starting a transition without selecting transition types, would only activate ':active-view-transition()'' with ''*'':
337+
While starting a transition without providing transition types, would only activate ':active-view-transition'':
326338

327339
```js
328340
document.startViewTransition(updateTheDOMSomehow);
@@ -333,11 +345,11 @@ document.startViewTransition({update: updateTheDOMSomehow});
333345
```css
334346
/* This would be active */
335347
:root { }
336-
:root:active-view-transition(*) {}
348+
:root:active-view-transition {}
337349

338350
/* This would not be active */
339-
:root:active-view-transition(slide-in) {}
340-
:root:active-view-transition(any-type-at-all-except-star) {}
351+
:root:active-view-transition-type(slide-in) {}
352+
:root:active-view-transition-type(any-type-at-all-except-star) {}
341353
```
342354
</div>
343355

@@ -435,6 +447,9 @@ Note: as per default behavior, the ''@view-transition'' rule can be nested insid
435447
The '<dfn for="@view-transition">type</dfn>' descriptor sets the [=ViewTransition/active types=] for the transition
436448
when capturing and performing the transition, equivalent to calling {{Document/startViewTransition(callbackOptions)}} with that {{StartViewTransitionOptions/type}}.
437449

450+
Note: the [=@view-transition/type=] descriptor only applies to the {{Document}} in which it is defined.
451+
The author is responsible for using their chosen set of types in both documents.
452+
438453
# API # {#api}
439454

440455
## Additions to {{Document}} ## {#additions-to-document-api}
@@ -473,7 +488,7 @@ Note: as per default behavior, the ''@view-transition'' rule can be nested insid
473488

474489
1. Let |viewTransition| be the result of running the [=method steps=] for {{Document/startViewTransition(updateCallback)}} given |updateCallback|.
475490

476-
1. If |callbackOptions| is a {{StartViewTransitionOptions}}, then set |viewTransition|'s [=ViewTransition/active types=] to |callbackOptions|'s {{StartViewTransitionOptions/type}}.
491+
1. If |callbackOptions| is a {{StartViewTransitionOptions}}, set |viewTransition|'s [=ViewTransition/active types=]'s [=DOMTokenList/token set=] to a [=list/clone=] of {{StartViewTransitionOptions/type}} as a [=/set=].
477492

478493
1. Return |viewTransition|.
479494
</div>
@@ -529,13 +544,23 @@ The {{CSSViewTransitionRule}} represents a ''@view-transition'' rule.
529544

530545
### Additions to {{ViewTransition}} ### {#view-transitions-extension}
531546

547+
The {{ViewTransition}} interface is extended as follows:
548+
549+
<pre class='idl'>
550+
partial interface ViewTransition {
551+
readonly attribute DOMTokenList typeList;
552+
};
553+
</pre>
554+
555+
The {{ViewTransition/typeList}} [=getter steps=] are to return [=this=]'s [=ViewTransition/active types=].
556+
532557
A {{ViewTransition}} additionally has:
533558
<dl dfn-for=ViewTransition>
534559
: <dfn>outbound post-capture steps</dfn>
535560
:: Null or a set of steps, initially null.
536561

537562
: <dfn>active types</dfn>
538-
:: Null or a [=list=] of strings, initially null.
563+
:: A {{DOMTokenList}}, initially a new {{DOMTokenList}}.
539564
</dl>
540565

541566
### Additions to [=captured element=] struct ### {#additions-to-captured-element-struct}
@@ -626,9 +651,9 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
626651

627652
1. Let |typesDescriptor| be |matchingRule|'s [=@view-transition/type=] descriptor.
628653

629-
1. If |typesDescriptor|'s [=computed value=] is ''@view-transition/type/none'', then return a [=/list=] « ».
654+
1. If |typesDescriptor|'s [=computed value=] is ''@view-transition/type/none'', then return a [=/set=] « ».
630655

631-
1. Return a [=list=] of strings corresponding to |typesDescriptor|'s [=computed value=].
656+
1. Return a [=/set=] of strings corresponding to |typesDescriptor|'s [=computed value=].
632657
</div>
633658

634659
### Setting up the view-transition in the old {{Document}} ### {#setup-old-document-vt}
@@ -674,8 +699,13 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
674699
Note: this means that any running transition would be skipped when the document is ready
675700
to unload.
676701

677-
1. Let |outboundTransition| be a new {{ViewTransition}} object in |oldDocument|'s [=relevant Realm=],
678-
whose [=ViewTransition/active types=] is |resolvedRule|.
702+
1. Let |outboundTransition| be a new {{ViewTransition}} object in |oldDocument|'s [=relevant Realm=].
703+
704+
1. Set |outboundTransition|'s [=ViewTransition/active types=]'s [=DOMTokenList/token set=] to |resolvedRule|.
705+
706+
Note: the [=ViewTransition/active types=] are not shared between documents.
707+
Manipulating the {{ViewTransition/typeList}} in the new document does not affect the types in the new document,
708+
which would be read from the [=@view-transition/type=] descriptor once the document is revealed.
679709

680710
Note: the {{ViewTransition}} is skipped once the old document is hidden.
681711

@@ -730,7 +760,7 @@ Prepend this to the [=Perform pending transition operations=] algorithm given a
730760

731761
1. Set |transition|’s [=ViewTransition/phase=] to "`update-callback-called`".
732762

733-
1. Set |transition|'s [=ViewTransition/active types=] to |resolvedRule|.
763+
1. Set |transition|'s [=ViewTransition/active types=]'s [=DOMTokenList/token set=] to |resolvedRule|.
734764

735765
1. At any given time, the UA may decide to skip the inbound transition, e.g. after an [=implementation-defined=] timeout.
736766
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:

0 commit comments

Comments
 (0)