Skip to content

Commit a26b685

Browse files
authored
[css-view-transitions-2] Define the view-transition-group-children pseudo element (#12277)
* [css-view-transitions-2] Define the view-transition-group-children pseudo This new pseudo is an ancestor to the other nested groups, and is positioned after the group's view-transition-image-pair which contains the group's contents. Resolution: #11926 (comment) Closes #11926
1 parent c1ce2a8 commit a26b685

File tree

1 file changed

+77
-14
lines changed

1 file changed

+77
-14
lines changed

css-view-transitions-2/Overview.bs

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ spec:css-view-transitions-1;
4646
text: group styles rule; type: dfn;
4747
text: update pseudo-element styles rule; type: dfn;
4848
text: document-scoped view transition name; type: dfn;
49+
text: global view transition user agent style sheet; type: dfn;
4950
spec:dom; type:dfn; text:document
5051
spec:css22; type:dfn; text:element
5152
spec:selectors-4; type:dfn;
@@ -860,7 +861,7 @@ This example creates a transition where the [=view transition tree=] is nested i
860861
}
861862

862863
.container,
863-
::view-transition-group(container) {
864+
::view-transition-group-children(container) {
864865
clip-path: circle();
865866
}
866867

@@ -870,7 +871,22 @@ article {
870871
}
871872
```
872873

873-
By applying the ''clip-path'' to both the containing element and its generated pseudo-element, we preserve the clip during the transition,
874+
The pseudo-element tree for this would be as follows:
875+
```
876+
::view-transition
877+
├─ ::view-transition-group(container)
878+
│ ├─ ::view-transition-image-pair(container)
879+
│ | ├─ ::view-transition-old(container)
880+
│ | └─ ::view-transition-new(container)
881+
│ └─ ::view-transition-group-children(container)
882+
│ ├─ ::view-transition-group(article)
883+
│ | ├─ ::view-transition-old(article)
884+
│ | └─ ::view-transition-new(article)
885+
│ └─ ...other nested groups...
886+
└─ …other groups…
887+
```
888+
889+
By applying the ''clip-path'' to both the containing element and its generated ''::view-transition-group-children()'' pseudo-element, we preserve the clip during the transition,
874890
and by applying ''view-transition-group'' to the internal element referencing the container, we make the tree "nested" in a way that would apply this clipping.
875891
</main>
876892

@@ -889,7 +905,34 @@ and by applying ''view-transition-group'' to the internal element referencing th
889905
The 'view-transition-group' property can be used in conjuction with 'view-transition-name' to generate a hierarchy of [=named view transition pseudo-element=].
890906

891907
The [=used value=] for 'view-transition-group' resolves to a 'view-transition-name' in its ancestor chain, or to ''view-transition-name/none''. When generating the [=named view transition pseudo-element=], the ''::view-transition-group()'' with that name
892-
would be the parent of the ''::view-transition-group()'' generated for this element's 'view-transition-name'.
908+
would create a ''::view-transition-group-children()'' pseudo-element, which would be the parent of the ''::view-transition-group()'' generated for this element's 'view-transition-name'.
909+
910+
### View Transition Tree Root: the ''::view-transition-group-children'' pseudo-element ### {#view-transition-group-children-pseudo}
911+
912+
The <dfn>::view-transition-group-children()</dfn> [=pseudo-element=]
913+
is a [=named view transition pseudo-element=]
914+
that represents a matching named [=view transition=] capture.
915+
A ''::view-transition-group-children()'' [=pseudo-element=]
916+
is generated based on the 'view-transition-group' property,
917+
as a [=tree/child=] of the corresponding ''::view-transition-group()'' [=pseudo-element=],
918+
and contains one or more ''::view-transition-group()'' elements, corresponding to the nested groups.
919+
See the [=used group name=] and related algorithms.
920+
921+
The ''::view-transition-group-children()'' [=pseudo-element=] is positioned after its sibling ''view-transition-image-pair()''.
922+
It is used to control effects like clipping or masking of nested children.
923+
924+
## User Agent Stylesheet # {#ua-styles}
925+
926+
This specification extends the [=global view transition user agent style sheet=] by adding the following rule:
927+
928+
```css
929+
:root::view-transition-group-children(*) {
930+
position: absolute;
931+
inset: 0;
932+
border-style: solid;
933+
border-color: transparent;
934+
}
935+
```
893936

894937
# Algorithms # {#algorithms}
895938

@@ -953,7 +996,10 @@ The [=captured element=] struct should contain these fields, in addition to the
953996
:: Null or a string, initially null.
954997

955998
: <dfn for="captured element">transform from snapshot containing block</dfn>
956-
:: A [=matrix=], initially the identity matrix.
999+
:: A [=matrix=] or null, initially null.
1000+
1001+
: <dfn for="captured element">old border width</dfn>
1002+
:: 'border-width' [=used value=] (top, right, bottom and left pixel values) or null, initially null.
9571003
</dl>
9581004

9591005
## Resolving the ''@view-transition'' rule ## {#vt-rule-algo}
@@ -1219,6 +1265,8 @@ To resolve the <dfn>used group name</dfn> of an {{Element}} |element|, perform t
12191265
When [[css-view-transitions-1#capture-old-state-algorithm|capturing the old state for an element]], perform the following steps given a [=captured element=] |capturedElement|, a {{ViewTransition}} |transition|, and an [=element=] |element|:
12201266

12211267
1. Set |capturedElement|'s [=captured element/containing group name=] to |element|'s [=used group name=] given |transition|.
1268+
1269+
1. Set |capturedElement|'s [=captured element/old border width=] to |element|'s [=used value|used=] 'border-width'.
12221270
</div>
12231271

12241272
### Compute the new 'view-transition-group' ### {#vt-group-capture-new}
@@ -1233,19 +1281,23 @@ When [[css-view-transitions-1#capture-new-state-algorithm|capturing the new stat
12331281
When [[css-view-transitions-1#setup-transition-pseudo-elements-algorithm|setting up the transition pseudo-element]] for a [=captured element=] |capturedElement|, given a |transitionName| and a |transition|:
12341282

12351283
1. Let |containingGroupName| be |capturedElement|'s [=containing group name=].
1236-
1. If |containingGroupName| is not null, then:
12371284

1238-
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|containingGroupName|].
1285+
1. If |containingGroupName| is null, return.
1286+
1287+
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|containingGroupName|].
1288+
1289+
1. Let |group| be the ''::view-transition-group()'',
1290+
whose [=view transition name=] is set to |transitionName|.
12391291

1240-
1. Let |group| be the ''::view-transition-group()'',
1241-
whose [=view transition name=] is set to |transitionName|.
1292+
1. Let |childrenContainerGroup| be the ''::view-transition-group-children()'' whose [=view transition name=] is set to |containingGroupName|.
12421293

1243-
1. Let |parentGroup| be the ''::view-transition-group()'',
1244-
whose [=view transition name=] is set to |containingGroupName|.
1294+
1. If |childrenContainerGroup| does not exist:
1295+
Generate it and append to the ''::view-transition-group()'',
1296+
whose [=view transition name=] is set to |containingGroupName|.
12451297

1246-
1. Append |group| to |parentGroup|.
1298+
1. Append |group| to |childrenContainerGroup|.
12471299

1248-
1. When setting the animation keyframes given |transform|, [=multiply=] |transform| by the inverse matrix of |groupContainerElement|'s [=old transform=].
1300+
1. When setting the animation keyframes given |transform|, [=adjust nested view transition group transform|adjust=] |transform| given |groupContainerElement|.
12491301

12501302
Note: It is TBD how this is resolved when the old and new groups mismatch. See <a href="https://github.com/w3c/csswg-drafts/issues/10631">Issue 10631</a>.
12511303
</div>
@@ -1254,13 +1306,24 @@ When [[css-view-transitions-1#setup-transition-pseudo-elements-algorithm|setting
12541306
<div algorithm="additional pseudo-element style update steps (group)">
12551307
When [[css-view-transitions-1#style-transition-pseudo-elements-algorithm|updating the style of the transition pseudo-element]], perform the following steps before setting the [=captured element/group styles rule=], given a [=captured element=] |capturedElement|, given a |transform| and a {{ViewTransition}} |transition|:
12561308

1309+
1. Let |childrenTransform| be |transform|.
1310+
12571311
1. Set |capturedElement|'s [=transform from snapshot containing block=] to |transform|.
12581312

12591313
1. If |capturedElement|'s [=containing group name=] is not null, then:
12601314

1261-
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|capturedElement|'s [=containing group name=]].
1315+
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|capturedElement|'s [=containing group name=].
1316+
1317+
1. [=adjust nested view transition group transform|Adjust=] |transform| given |groupContainerElement|.
1318+
1319+
To <dfn>adjust nested view transition group transform</dfn> given a |transform| and a [=captured element=] |groupContainerElement|:
1320+
1. Let |childrenTransform| be |groupContainerElement|'s [=transform from snapshot containing block=].
1321+
1322+
1. If |childrenTransform| is null, set it to |groupContainerElement|'s [=captured element/old transform=].
1323+
1324+
1. Translate |childrenTransform| by |groupContainerElement|'s [=captured element/old border width=]'s left and top components.
12621325

1263-
1. [=Multiply=] |transform| by the inverse matrix of |groupContainerElement|'s [=transform from snapshot containing block=].
1326+
1. Multiply |transform| by the inverse matrix of |childrenTransform|.
12641327
</div>
12651328

12661329

0 commit comments

Comments
 (0)