Skip to content

Commit b7fc74a

Browse files
[css-view-transitions-1] Define pseudo-nesting and naming (#8126)
* Define pseudo-nesting and naming * Language tweak * Specify tree-abiding * Tidy up pseudo-parent definition * Define :only-child behaviour * Nit * Clarify snapshot viewport as containing block * Define adding the ::view-transition * Move iew-transition root pseudo-element to document * Base on tree terminology * Change issue to note * Make "show view-transition root pseudo-element" a boolean Also clean up the use of phases, and put the note in the correct place * Set show pseudo to false
1 parent f2752d6 commit b7fc74a

File tree

1 file changed

+95
-72
lines changed

1 file changed

+95
-72
lines changed

css-view-transitions-1/Overview.bs

+95-72
Original file line numberDiff line numberDiff line change
@@ -197,40 +197,55 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
197197

198198
# Pseudo-elements # {#pseudo}
199199

200-
The following <dfn export>view-transition pseudo-elements</dfn> represent the various items being animated.
200+
## Pseudo-element root ## {#pseudo-root}
201201

202-
The ''::view-transition'' pseudo-element acts as a grouping element for other [=view-transition pseudo-elements=]
203-
and has the document's [=document element=] as its [=originating element=].
202+
Note: This is a general definition for trees of pseudo-elements. If other features need this behavior, these definitions will be moved to [[css-pseudo-4]].
204203

205-
Note: For example, '':root::view-transition'' selector matches this pseudo-element,
206-
but ''div::view-transition'' does not.
204+
A <dfn>pseudo-element root</dfn> is a type of [=tree-abiding pseudo-element=] that is the [=tree/root=] in a [=tree=] of [=tree-abiding pseudo-elements=],
205+
known as the <dfn>pseudo-element tree</dfn>.
207206

208-
Other [=view-transition pseudo-elements=] take a <<pt-name-selector>> argument
209-
to specify which elements named with 'view-transition-name' are affected.
207+
The [=pseudo-element tree=] defines the document order of its [=tree/descendant=] [=tree-abiding pseudo-elements=].
210208

211-
There can be multiple pseudo-elements of the same type,
212-
one for each 'view-transition-name' participating in a transition.
209+
When a [=pseudo-element=] [=tree/participates=] in a [=pseudo-element tree=],
210+
its [=originating pseudo-element=] is its [=tree/parent=].
213211

214-
The <<pt-name-selector>> is defined as follows:
212+
If a [=tree/descendant=] |pseudo| of a [=pseudo-element root=] has no other [=tree/siblings=],
213+
then '':only-child'' matches that |pseudo|.
214+
215+
Note: This means that `::view-transition-new(ident):only-child` will only select `::view-transition-new(ident)` if the parent `::view-transitions-image-pair(ident)` contains a single [=tree/child=].
216+
As in, there is no [=tree/sibling=] `::view-transition-old(ident)`.
217+
218+
## Named view-transition pseudo-elements ## {#named-view-transition-pseudo}
219+
220+
A <dfn>named view-transition pseudo-element</dfn> is a type of [=tree-abiding pseudo-elements=].
221+
222+
It has a <dfn for="named view-transition pseudo-element">view-transition name</dfn>,
223+
a string.
224+
225+
Their selector takes a <<pt-name-selector>> argument.
215226

216227
<pre class=prod>
217228
<dfn>&lt;pt-name-selector></dfn> = '*' | <<custom-ident>>
218229
</pre>
219230

220-
A value of ''*'' makes the corresponding selector apply to all pseudo elements of the specified type.
221-
The specificity of a view-transition selector with a ''*'' argument is zero.
231+
The selector matches if the <<pt-name-selector>> is `*` or matches the [=named view-transition pseudo-element=]'s [=named view-transition pseudo-element/view-transition name=].
222232

223-
The <<custom-ident>> value makes the corresponding selector apply to exactly one pseudo element of the specified type,
224-
namely the pseudo-element that is created as a result of the 'view-transition-name' property on an element with the same <<custom-ident>> value.
225233
The specificity of a view-transition selector with a <<custom-ident>> argument is the same as for other pseudo-elements,
226234
and is equivalent to a [=type selector=].
227235

228-
The following describes all of the [=view-transition pseudo-elements=] and their function:
236+
The specificity of a view-transition selector with a `*` argument is zero.
237+
238+
Note: The [=named view-transition pseudo-element/view-transition name=] is set to the 'view-transition-name' that triggered its creation.
239+
240+
## View transition pseudo-elements ## {#view-transition-pseudos}
229241

230242
: <dfn>::view-transition</dfn>
231-
:: This pseudo-element is the grouping container of all the other [=view-transition pseudo-elements=].
243+
:: A [=tree-abiding pseudo-element=] that is also
244+
a [=pseudo-element root=].
232245
Its [=originating element=] is the document's [=document element=].
233246

247+
Its [=containing block=] is the [=snapshot viewport=].
248+
234249
The following is added to the [=HTML user agent style sheet=]:
235250

236251
```css
@@ -240,15 +255,18 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
240255
}
241256
```
242257

243-
Note: This pseudo-element provides a containing block for all ''::view-transition-group()'' pseudo-elements.
244-
The aim of the style is to size the pseudo-element to cover the [=snapshot viewport=]
245-
and position all ''::view-transition-group()'' pseudo-elements relative to the [=snapshot viewport origin=].
258+
<div class="note">
259+
This pseudo-element provides a containing block for all ''::view-transition-group()'' pseudo-elements.
260+
The aim of the style is to size the pseudo-element to cover the [=snapshot viewport=]
261+
and position all ''::view-transition-group()'' pseudo-elements relative to the [=snapshot viewport origin=].
262+
</div>
246263

247264
: <dfn>::view-transition-group( <<pt-name-selector>> )</dfn>
248-
:: One of these pseudo-elements exists for each 'view-transition-name' in a view transition,
249-
and holds the rest of the pseudo-elements corresponding to this 'view-transition-name'.
265+
:: A [=tree-abiding pseudo-element=]
266+
that is also a [=named view-transition pseudo-element=],
267+
and [=tree/participates=] in a [=pseudo-element tree=].
250268

251-
Its [=originating element=] is the ''::view-transition'' pseudo-element.
269+
It is selected from its [=ultimate originating element=], the [=document element=].
252270

253271
The following is added to the [=HTML user agent style sheet=]:
254272

@@ -270,15 +288,16 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
270288
from the size of the old element's [=border box=] to that of the new element's [=border box=].
271289
Also the element's 'transform' is animated from the old element's screen space transform to the new element's screen space transform.
272290
This style is generated dynamically since the values of animated properties are determined at the time that the transition begins.
273-
</div>
274291

275-
Issue: The selector for this and subsequently defined pseudo-elements is likely to change to indicate position in the pseudo-tree hierarchy.
292+
This is only ever a [=tree/child=] of a ''::view-transition''.
293+
</div>
276294

277295
: <dfn>::view-transition-image-pair( <<pt-name-selector>> )</dfn>
278-
:: One of these pseudo-elements exists for each view-transition-name being in a view transition,
279-
and holds the images of the old and new elements.
296+
:: A [=tree-abiding pseudo-element=]
297+
that is also a [=named view-transition pseudo-element=],
298+
and [=tree/participates=] in a [=pseudo-element tree=].
280299

281-
Its [=originating element=] is the ''::view-transition-group()'' pseudo-element with the same transition-name.
300+
It is selected from its [=ultimate originating element=], the [=document element=].
282301

283302
The following is added to the [=HTML user agent style sheet=]:
284303

@@ -292,14 +311,17 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
292311
}
293312
```
294313

295-
Note: The aim of the style is to position the element to occupy the same space as its ''::view-transition-group()'' element.
314+
Note: This is only ever a [=tree/child=] of a ''::view-transition-group()''.
296315

297316
: <dfn>::view-transition-old( <<pt-name-selector>> )</dfn>
298-
:: One of these pseudo-elements exists for each element in the old DOM being animated by the view transition,
299-
and is a [=replaced element=] displaying the old element's snapshot image.
300-
It has [=natural dimensions=] equal to the snapshot's size.
317+
:: A [=tree-abiding pseudo-element=]
318+
that is also a [=named view-transition pseudo-element=],
319+
and [=tree/participates=] in a [=pseudo-element tree=].
301320

302-
Its [=originating element=] is the ''::view-transition-image-pair()'' pseudo-element with the same transition-name.
321+
It is selected from its [=ultimate originating element=], the [=document element=].
322+
323+
It is a [=replaced element=] displaying the old element's snapshot image.
324+
It has [=natural dimensions=] equal to the snapshot's size.
303325

304326
The following is added to the [=HTML user agent style sheet=]:
305327

@@ -320,27 +342,25 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
320342

321343
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=].
322344

345+
Note: This is only ever a [=tree/child=] of a ''::view-transition-image-pair()'', and never has any [=tree/children=].
346+
323347
: <dfn>::view-transition-new( <<pt-name-selector>> )</dfn>
324348
:: Identical to ''::view-transition-old()'',
325349
except it deals with the new element instead.
326350

327-
The precise tree structure, and in particular the order of sibling pseudo-elements,
351+
Note: The precise tree structure, and in particular the order of sibling pseudo-elements,
328352
is defined in the [=setup transition pseudo-elements=] algorithm.
329353

330354
# Concepts # {#concepts}
331355

332356
## Phases ## {#phases-concept}
333357

334358
<dfn>Phases</dfn> represent an ordered sequence of states.
335-
Since [=phases=] are ordered, prose can refer to phases <dfn for="phases">before</dfn> a particular phase, meaning they appear earlier in the sequence,
336-
or <dfn for="phases">after</dfn> a particular phase, meaning they appear later in the sequence.
359+
Since [=phases=] are ordered, prose can refer to phases <dfn for="phases">before</dfn> a particular phase, meaning they appear earlier in the sequence.
360+
<!-- or <dfn for="phases">after</dfn> a particular phase, meaning they appear later in the sequence. -->
337361

338362
The initial phase is the first item in the sequence.
339363

340-
Note: For the most part, a developer using this API does not need to worry about the different phases, since they progress automatically.
341-
It is, however, important to understand what steps happen in each of the phases: when the snapshots are captured, when pseudo-element DOM is created, etc.
342-
The description of the phases below tries to be as precise as possible, with an intent to provide an unambiguous set of steps for implementors to follow in order to produce a spec-compliant implementation.
343-
344364
## The snapshot viewport ## {#snapshot-viewport-concept}
345365

346366
The <dfn>snapshot viewport</dfn> covers all areas of the window that could potentially display web content.
@@ -388,10 +408,6 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
388408

389409
- The [=view-transition layer=] paints after the stacking context for the [=document element=] and [=top layer=].
390410

391-
- The [=view-transition layer=] is positioned at the [=snapshot viewport origin=],
392-
and is the same size as the [=snapshot viewport=].
393-
As in, it covers the [=snapshot viewport=].
394-
395411
Note: The intent of the feature is to be able to capture the contents of the page, which includes the top layer elements.
396412
In order to accomplish that, the [=view-transition layer=] cannot be a part of the captured top layer context,
397413
since that results in a circular dependency.
@@ -466,6 +482,14 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
466482
Initially a new [=style sheet=] in the [=user-agent origin=], ordered after the [=HTML user agent style sheet=].
467483

468484
Note: This is used to hold dynamic styles relating to transitions.
485+
486+
: <dfn>show view-transition root pseudo-element</dfn>
487+
:: A boolean. Initially false.
488+
489+
When this is true, [=this=]'s [=active DOM transition=]'s [=ViewTransition/transition root pseudo-element=] renders as a child of [=this=]'s [=document element=],
490+
and [=this=]'s [=document element=] is its [=originating element=].
491+
492+
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 viewport=].
469493
</dl>
470494

471495
# API # {#api}
@@ -591,6 +615,10 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
591615
1. "`animating`".
592616
1. "`done`".
593617

618+
Note: For the most part, a developer using this API does not need to worry about the different phases, since they progress automatically.
619+
It is, however, important to understand what steps happen in each of the phases: when the snapshots are captured, when pseudo-element DOM is created, etc.
620+
The description of the phases below tries to be as precise as possible, with an intent to provide an unambiguous set of steps for implementors to follow in order to produce a spec-compliant implementation.
621+
594622
: <dfn>DOM update callback</dfn>
595623
:: an {{UpdateDOMCallback}} or null. Initially null.
596624

@@ -605,6 +633,10 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
605633
: <dfn>finished promise</dfn>
606634
:: a {{Promise}}.
607635
Initially [=a new promise=] in [=this's=] [=relevant Realm=].
636+
637+
: <dfn>transition root pseudo-element</dfn>
638+
:: a ''::view-transition''.
639+
Initially a new ''::view-transition''.
608640
</dl>
609641

610642
The {{ViewTransition/finished}} [=getter steps=] are to return [=this's=] [=ViewTransition/finished promise=].
@@ -849,13 +881,10 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
849881

850882
1. Set [=document/transition suppressing rendering=] to false.
851883

852-
1. If |transition|'s [=ViewTransition/phase=] is equal to or [=phases/after=] "`animating`",
853-
then [=clear view transition=] |transition|.
884+
1. [=Clear view transition=] |transition|.
854885

855886
1. Set |transition|'s [=ViewTransition/phase=] to "`done`".
856887

857-
1. Set |document|'s [=document/active DOM transition=] to null.
858-
859888
1. If |transition|'s [=ViewTransition/ready promise=] has not yet been resolved, [=reject=] it with |reason|.
860889

861890
Note: The ready promise would've been resolved if {{ViewTransition/skipTransition()}} is called after we start animating.
@@ -912,7 +941,7 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
912941

913942
1. Otherwise:
914943

915-
1. Render |element| and its descendants,
944+
1. Render |element| and its [=tree/descendants=],
916945
at the same size it appears in its [=node document=],
917946
over an infinite transparent canvas,
918947
following the [=capture rendering characteristics=].
@@ -959,9 +988,7 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
959988

960989
1. Let |hasActiveAnimations| be a boolean, initially false.
961990

962-
1. For each [=view-transition pseudo-elements=] associated with |transition|:
963-
964-
1. Let |element| be the [=view-transition pseudo-element=].
991+
1. [=list/For each=] |element| of |transition|'s [=ViewTransition/transition root pseudo-element=]'s [=tree/inclusive descendants=]:
965992

966993
1. For each |animation| whose [=timeline=] is a [=document timeline=] associated with |document|,
967994
and contains at least one [=animation/associated effect=] whose [=effect target=] is |element|,
@@ -981,8 +1008,6 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
9811008

9821009
1. [=Clear view transition=] |transition|.
9831010

984-
1. Set |document|'s [=document/active DOM transition=] to null.
985-
9861011
1. [=Resolve=] |transition|'s [=ViewTransition/finished promise=].
9871012

9881013
1. Return.
@@ -1020,27 +1045,24 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
10201045

10211046
1. Let |document| be [=this's=] [=relevant global object's=] [=associated document=].
10221047

1023-
1. Let |transitionRoot| be the result of creating a new ''::view-transition'' pseudo-element in |document|'s [=snapshot viewport=].
1048+
1. Set |document|'s [=show view-transition root pseudo-element=] to true.
10241049

10251050
1. [=map/For each=] |transitionName| → |capturedElement| of |transition|'s [=ViewTransition/named elements=]:
10261051

1027-
1. Let |group| be the result of creating a new ''::view-transition-group()'' pseudo-element with the name |transitionName|.
1028-
1029-
Issue: "name" should be defined/linked.
1052+
1. Let |group| be a new ''::view-transition-group()'',
1053+
with its [=named view-transition pseudo-element/view-transition name=] set to |transitionName|.
10301054

1031-
1. Append |group| to |transitionRoot|.
1055+
1. Append |group| to |transition|'s [=ViewTransition/transition root pseudo-element=].
10321056

1033-
Issue: This should be better defined.
1034-
I'm not sure if pseudo-elements have defined ways to modify their DOM.
1035-
1036-
1. Let |imagePair| be a new ''::view-transition-image-pair()'' pseudo-element with the name |transitionName|.
1057+
1. Let |imagePair| be a new ''::view-transition-image-pair()'',
1058+
with its [=named view-transition pseudo-element/view-transition name=] set to |transitionName|.
10371059

10381060
1. Append |imagePair| to |group|.
10391061

10401062
1. If |capturedElement|'s [=captured element/old image=] is not null, then:
10411063

1042-
1. Let |old| be a new ''::view-transition-old()'' [=replaced element=] pseudo-element,
1043-
with the name |transitionName|,
1064+
1. Let |old| be a new ''::view-transition-old()'',
1065+
with its [=named view-transition pseudo-element/view-transition name=] set to |transitionName|,
10441066
displaying |capturedElement|'s [=captured element/old image=].
10451067

10461068
1. Append |old| to |imagePair|.
@@ -1061,15 +1083,15 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
10611083

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

1064-
1. Let |new| be a new ''::view-transition-new()'' [=replaced element=] pseudo-element,
1065-
with the name |transitionName|,
1086+
1. Let |new| be a new ''::view-transition-new()'',
1087+
with its [=named view-transition pseudo-element/view-transition name=] set to |transitionName|,
10661088
displaying the [=capture the image=] of |capturedElement|'s [=new element=].
10671089

10681090
1. Append |new| to |imagePair|.
10691091

10701092
The [=new element=] and its contents
10711093
(the flat tree descendants of the element, including both text and elements, or the replaced content of a replaced element),
1072-
except the [=view-transition pseudo-elements=],
1094+
except the |transition|'s [=ViewTransition/transition root pseudo-element=]'s [=tree/inclusive descendants=],
10731095
are not painted (as if they had visibility: hidden)
10741096
and do not respond to hit-testing (as if they had pointer-events: none) until |new| exists.
10751097

@@ -1250,18 +1272,19 @@ urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html; type: dfn;
12501272

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

1253-
1. Remove all associated [=view-transition pseudo-elements=] from |document|.
1254-
1255-
Issue: There needs to be a definition/link for "remove".
1256-
1257-
Issue: There needs to be a definition/link for "associated".
1275+
1. [=Assert=]: |document|'s [=document/active DOM transition=] is |transition|.
12581276

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

12611279
1. [=list/For each=] |style| of |capturedElement|'s [=captured element/style definitions=]:
12621280

12631281
1. If |style| is not null,
1282+
and |style| is in |document|'s [=document/view transition style sheet=],
12641283
then remove |style| from |document|'s [=document/view transition style sheet=].
1284+
1285+
1. Set |document|'s [=document/show view-transition root pseudo-element=] to false.
1286+
1287+
1. Set |document|'s [=document/active DOM transition=] to null.
12651288
</div>
12661289

12671290
<h2 id="priv" class="no-num">Privacy Considerations</h2>

0 commit comments

Comments
 (0)