Skip to content

Commit d74719a

Browse files
[css-view-transitions-1] Handling rendering constaints (#8540)
* Layout impact of view-transition-name Fixes #8139 * Handle cases where constraints are broken mid-transition Fixes #7882 --------- Co-authored-by: Tab Atkins Jr. <jackalmage@gmail.com>
1 parent da4695a commit d74719a

File tree

1 file changed

+62
-36
lines changed

1 file changed

+62
-36
lines changed

css-view-transitions-1/Overview.bs

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Shortname: css-view-transitions
44
Level: 1
55
Status: WD
66
Group: csswg
7-
Date: 2023-03-07
7+
Date: 2023-04-18
88
Prepare for TR: yes
99
ED: https://drafts.csswg.org/css-view-transitions-1/
1010
TR: https://www.w3.org/TR/css-view-transitions-1/
@@ -32,6 +32,7 @@ spec:css-display-3; type:dfn;
3232
text:containing block
3333
text:replaced element
3434
spec:css-cascade-5; type:dfn; text:computed value
35+
spec:css22; type:dfn; text:element
3536
</pre>
3637

3738
<pre class=anchors>
@@ -479,11 +480,11 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
479480

480481
<dl dfn-type=value dfn-for=view-transition-name>
481482
: <dfn>none</dfn>
482-
:: The element will not participate in a view transition.
483+
:: The [=/element=] will not participate in a view transition.
483484

484485
: <dfn><<custom-ident>></dfn>
485-
:: The element can participate in a view transition,
486-
as either an old or new element,
486+
:: The [=/element=] can participate in a view transition,
487+
as either an old or new [=/element=],
487488
with a <dfn dfn for>view transition name</dfn> equal to the <<custom-ident>>'s value.
488489

489490
Note: The value <css>none</css> is invalid as a <<custom-ident>>.
@@ -497,6 +498,21 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
497498
This may be confusing, since the elements themselves are not necessarily referring to the same object,
498499
but it is a useful model to consider them to be visual states of the same conceptual page entity, that we happen to call "element".
499500

501+
# Layout and rendering changes # {#layout-rendering-changes}
502+
503+
[=/Elements=] have an <dfn>involved in a view transition</dfn> boolean, initially false.
504+
505+
[=/Elements=] that either have a 'view-transition-name' [=computed value=] that is not ''view-transition-name/none'',
506+
or are [=involved in a view transition=], form:
507+
508+
- a [=stacking context=].
509+
510+
- a [[css-transforms-2#grouping-property-values|group]].
511+
512+
- a [=backdrop root=].
513+
514+
Note: This spec uses CSS's definition of [=element=], which includes [=pseudo-elements=].
515+
500516
# User-agent styles # {#ua-styles}
501517

502518
The <dfn>global view transition user agent style sheet</dfn> is a style sheet in the [=user-agent origin=], used in all namespaces.
@@ -593,7 +609,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
593609
This enables full customization of the transition.
594610
</div>
595611

596-
### <dfn>::view-transition</dfn>
612+
### <dfn>::view-transition</dfn> ### {#::view-transition}
597613

598614
<div class=note>This element provides a containing block for all ''::view-transition-group()'' pseudo-elements.</div>
599615

@@ -617,7 +633,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
617633
and position all ''::view-transition-group()'' pseudo-elements relative to the [=snapshot root origin=].
618634
</div>
619635

620-
### <dfn>::view-transition-group( <<pt-name-selector>> )</dfn>
636+
### <dfn>::view-transition-group( <<pt-name-selector>> )</dfn> ### {#::view-transition-group}
621637

622638
<div class=note>
623639
This element initially mirrors the size and position of the "old" element,
@@ -652,7 +668,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
652668
}
653669
```
654670

655-
### <dfn>::view-transition-image-pair( <<pt-name-selector>> )</dfn>
671+
### <dfn>::view-transition-image-pair( <<pt-name-selector>> )</dfn> ### {#::view-transition-image-pair}
656672

657673
<div class=note>
658674
This element is a child of the group element and provides ''isolation: isolate'' for its children.
@@ -679,7 +695,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
679695
}
680696
```
681697

682-
### <dfn>::view-transition-old( <<pt-name-selector>> )</dfn>
698+
### <dfn>::view-transition-old( <<pt-name-selector>> )</dfn> ### {#::view-transition-old}
683699

684700
<div class=note>
685701

@@ -726,7 +742,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
726742

727743
Note: Additional styles in the [=document/view transition style sheet=] added to animate these pseudo-elements are detailed in [=setup transition pseudo-elements=] and [=update pseudo-element styles=].
728744

729-
### <dfn>::view-transition-new( <<pt-name-selector>> )</dfn>
745+
### <dfn>::view-transition-new( <<pt-name-selector>> )</dfn> ### {#::view-transition-new}
730746

731747
Identical to ''::view-transition-old()'',
732748
except the following styles added to the [=global view transition user agent style sheet=]:
@@ -828,9 +844,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
828844
Issue: The type of "a set of styles" needs to be linked or defined.
829845

830846
: <dfn>new element</dfn>
831-
:: an element or null. Initially null.
832-
833-
Issue: The type of "element" needs to be linked or defined.
847+
:: an [=/element=] or null. Initially null.
834848
</dl>
835849

836850
In addition, a [=captured element=] has the following <dfn for="captured element">style definitions</dfn>:
@@ -1175,10 +1189,18 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
11751189
If failure is returned, then [=skip the view transition=] for |transition| with an "{{InvalidStateError}}" {{DOMException}} in |transition|'s [=relevant Realm=],
11761190
and return.
11771191

1192+
1. [=list/For each=] |capturedElement| of |transition|'s [=ViewTransition/named elements=]' [=map/values=]:
1193+
1194+
1. If |capturedElement|'s [=captured element/new element=] is not null,
1195+
then set |capturedElement|'s [=captured element/new element=]'s [=involved in a view transition=] to true.
1196+
11781197
1. [=Setup transition pseudo-elements=] for |transition|.
11791198

11801199
1. [=Update pseudo-element styles=] for |transition|.
11811200

1201+
If failure is returned, then [=skip the view transition=] for |transition| with an "{{InvalidStateError}}" {{DOMException}} in |transition|'s [=relevant Realm=],
1202+
and return.
1203+
11821204
Note: The above steps will require running document lifecycle phases,
11831205
to compute information calculated during style/layout.
11841206

@@ -1202,7 +1224,8 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
12021224

12031225
1. Set |transition|'s [=ViewTransition/initial snapshot root size=] to the [=snapshot root size=].
12041226

1205-
1. [=list/For each=] |element| of every {{Element}} and [=pseudo-element=] connected to |document|,
1227+
1. [=list/For each=] |element| of every [=/element=] that is [=/connected=],
1228+
and has a [=node document=] equal to to |document|,
12061229
in [paint order](https://drafts.csswg.org/css2/#painting-order):
12071230

12081231
Issue: The link for "paint order" doesn't seem right.
@@ -1220,8 +1243,6 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
12201243

12211244
* |usedTransitionNames| [=list/contains=] |transitionName|.
12221245

1223-
* |element| is not |element|'s [=tree/root=] and |element| does not have [=layout containment=].
1224-
12251246
* |element| is not |element|'s [=tree/root=] and |element| allows [=fragmentation=].
12261247

12271248
Then return failure.
@@ -1268,9 +1289,12 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
12681289

12691290
1. Let |document| be |transition|'s [=relevant global object's=] [=associated document=].
12701291

1292+
1. Let |namedElements| be |transition|'s [=ViewTransition/named elements=].
1293+
12711294
1. Let |usedTransitionNames| be a new [=/set=] of strings.
12721295

1273-
1. [=list/For each=] |element| of every {{Element}} and [=pseudo-element=] connected to |document|,
1296+
1. [=list/For each=] |element| of every [=/element=] that is [=/connected=],
1297+
and has a [=node document=] equal to to |document|,
12741298
in [paint order](https://drafts.csswg.org/css2/#painting-order):
12751299

12761300
Issue: The link for "paint order" doesn't seem right.
@@ -1284,26 +1308,15 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
12841308
or |element| is [=element-not-rendered|not rendered=],
12851309
then [=continue=].
12861310

1287-
1. If any of the following is true:
1288-
1289-
* |usedTransitionNames| [=list/contains=] |transitionName|.
1290-
1291-
* |element| is not |element|'s [=tree/root=]
1292-
and |element| does not have [=layout containment=].
1293-
1294-
* |element| is not |element|'s [=tree/root=]
1295-
and |element| allows [=fragmentation=].
1296-
1297-
Then return failure.
1311+
1. If |usedTransitionNames| [=list/contains=] |transitionName|,
1312+
then return failure.
12981313

12991314
1. [=set/Append=] |transitionName| to |usedTransitionNames|.
13001315

13011316
1. If |namedElements|[|transitionName|] does not [=map/exist=],
13021317
then set |namedElements|[|transitionName|] to a new [=captured element=] struct.
13031318

1304-
1. Let |capture| be |namedElements|[|transitionName|].
1305-
1306-
1. Let |capture|'s [=new element=] item be |element|.
1319+
1. Set |namedElements|[|transitionName|]'s [=new element=] to |element|.
13071320
</div>
13081321

13091322
### [=Setup transition pseudo-elements=] ### {#setup-transition-pseudo-elements-algorithm}
@@ -1356,8 +1369,9 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
13561369
1. If |capturedElement|'s [=new element=] is not null, then:
13571370

13581371
1. Let |new| be a new ''::view-transition-new()'',
1359-
with its [=named view-transition pseudo-element/view-transition name=] set to |transitionName|,
1360-
displaying the [=capture the image=] of |capturedElement|'s [=new element=].
1372+
with its [=named view-transition pseudo-element/view-transition name=] set to |transitionName|.
1373+
1374+
Note: The styling of this pseudo is handled in [=update pseudo-element styles=].
13611375

13621376
1. Append |new| to |imagePair|.
13631377

@@ -1502,7 +1516,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
15021516
## [=Capture the image=] ## {#capture-the-image-algorithm}
15031517

15041518
<div algorithm>
1505-
To <dfn lt="capture the image|capturing the image">capture the image</dfn> given an {{Element}} |element|, perform the following steps.
1519+
To <dfn lt="capture the image|capturing the image">capture the image</dfn> given an [=/element=] |element|, perform the following steps.
15061520
They return an image.
15071521

15081522
1. If |element| is the [=document element=], then:
@@ -1636,6 +1650,9 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
16361650

16371651
1. [=Update pseudo-element styles=] for |transition|.
16381652

1653+
If failure is returned, then [=skip the view transition=] for |transition| with an "{{InvalidStateError}}" {{DOMException}} in |transition|'s [=relevant Realm=],
1654+
and return.
1655+
16391656
Note: The above implies that a change in incoming element's size or position will cause a new keyframe to be generated.
16401657
This can cause a visual jump.
16411658
We could retarget smoothly but don't have a use-case to justify the complexity.
@@ -1665,6 +1682,12 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
16651682

16661683
1. Otherwise:
16671684

1685+
1. If any [=flat tree=] ancestor of |capturedElement|'s [=new element=] [=skips its contents=],
1686+
or |capturedElement|'s [=new element=] is [=element-not-rendered|not rendered=],
1687+
then return failure.
1688+
1689+
Note: Other rendering constraints are enforced via |capturedElement|'s [=new element=] being [=involved in a view transition=].
1690+
16681691
1. Set |width| to the current width of |capturedElement|'s [=new element=]'s [=border box=].
16691692

16701693
1. Set |height| to the current height of |capturedElement|'s [=new element=]'s [=border box=].
@@ -1696,9 +1719,9 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
16961719

16971720
1. If |capturedElement|'s [=new element=] is not null, then:
16981721

1699-
1. Let |new| be the ''::view-transition-new()'' [=replaced element=] pseudo-element,
1700-
with the name |transitionName|,
1701-
displaying the [=capture the image=] of |capturedElement|'s [=new element=].
1722+
1. Let |new| be the ''::view-transition-new()'' with the [=view-transition name=] |transitionName|.
1723+
1724+
1. Set |new|'s [=replaced element=] content to the result of [=capturing the image=] of |capturedElement|'s [=new element=].
17021725

17031726
1. Let |newViewBox| be an ''object-view-box'' value that when applied to |new|,
17041727
will cause the view box to coincide with |capturedElement|'s [=new element=]'s [=border box=] in the image.
@@ -1735,6 +1758,9 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
17351758

17361759
1. [=list/For each=] |capturedElement| of |transition|'s [=ViewTransition/named elements=]' [=map/values=]:
17371760

1761+
1. If |capturedElement|'s [=captured element/new element=] is not null,
1762+
then set |capturedElement|'s [=captured element/new element=]'s [=involved in a view transition=] to false.
1763+
17381764
1. [=list/For each=] |style| of |capturedElement|'s [=captured element/style definitions=]:
17391765

17401766
1. If |style| is not null,

0 commit comments

Comments
 (0)