Skip to content

Commit 2d23825

Browse files
committed
[css-view-transitions-1] Consolidate global UA style rules #8891
1 parent 9f39808 commit 2d23825

File tree

1 file changed

+82
-97
lines changed

1 file changed

+82
-97
lines changed

css-view-transitions-1/Overview.bs

Lines changed: 82 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -559,33 +559,6 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
559559

560560
Note: This does not effect pointers that are [=pointer capture|captured=].
561561

562-
# User-agent styles # {#ua-styles}
563-
564-
The <dfn>global view transition user agent style sheet</dfn> is a style sheet in the [=user-agent origin=], used in all namespaces.
565-
566-
Issue: [CSS needs a central place for an "all namespaces" style sheet](https://github.com/w3c/csswg-drafts/issues/8573).
567-
568-
It contains the following:
569-
570-
```css
571-
@keyframes -ua-view-transition-fade-out {
572-
to { opacity: 0; }
573-
}
574-
575-
@keyframes -ua-view-transition-fade-in {
576-
from { opacity: 0; }
577-
}
578-
579-
:root {
580-
view-transition-name: root;
581-
}
582-
```
583-
584-
<div class=note>
585-
There are further additions to the [=global view transition user agent style sheet=] defined in [[#view-transition-pseudos]] for each pseudo-element,
586-
and other styles are added at runtime via the [=document=]'s [=document/view transition style sheet=].
587-
</div>
588-
589562
# Pseudo-elements # {#pseudo}
590563

591564
## Pseudo-element Trees ## {#pseudo-root}
@@ -694,20 +667,6 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
694667

695668
Note: This element serves as the [=tree/parent=] of all ''::view-transition-group()'' pseudo-elements.
696669

697-
The following is added to the [=global view transition user agent style sheet=]:
698-
699-
```css
700-
:root::view-transition {
701-
position: fixed;
702-
inset: 0;
703-
}
704-
```
705-
706-
<div class="note">
707-
The aim of the style is to size the pseudo-element to cover the [=snapshot containing block=]
708-
and position all ''::view-transition-group()'' pseudo-elements relative to the [=snapshot containing block origin=].
709-
</div>
710-
711670
### View Transition Named Subtree Root: the ''::view-transition-group()'' pseudo-element ### {#::view-transition-group}
712671

713672
The <dfn>::view-transition-group()</dfn> [=pseudo-element=]
@@ -723,26 +682,14 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
723682
or the “new” element if there isn't an “old” element.
724683

725684
If there's both an “old” and “new” state,
726-
styles in the [=document/view transition style sheet=] animate this pseudo-element's 'width' and 'height'
685+
styles in the [=document/dynamic view transition style sheet=] animate this pseudo-element's 'width' and 'height'
727686
from the size of the old element's [=border box=] to that of the new element's [=border box=].
728687

729688
Also the element's 'transform' is animated from the old element's screen space transform to the new element's screen space transform.
730689

731690
This style is generated dynamically since the values of animated properties are determined at the time that the transition begins.
732691
</div>
733692

734-
The following is added to the [=global view transition user agent style sheet=]:
735-
736-
```css
737-
:root::view-transition-group(*) {
738-
position: absolute;
739-
top: 0;
740-
left: 0;
741-
742-
animation-duration: 0.25s;
743-
animation-fill-mode: both;
744-
}
745-
```
746693

747694
### View Transition Image Pair Isolation: the ''::view-transition-image-pair()'' pseudo-element ### {#::view-transition-image-pair}
748695

@@ -763,18 +710,6 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
763710
without affecting other visual outputs.
764711
</div>
765712

766-
The following is added to the [=global view transition user agent style sheet=]:
767-
768-
```css
769-
:root::view-transition-image-pair(*) {
770-
position: absolute;
771-
inset: 0;
772-
773-
animation-duration: inherit;
774-
animation-fill-mode: inherit;
775-
}
776-
```
777-
778713
### View Transition Old State Image: the ''::view-transition-old()'' pseudo-element ### {#::view-transition-old}
779714

780715
The <dfn>::view-transition-old()</dfn> [=pseudo-element=]
@@ -793,25 +728,8 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
793728
Note: The content and [=natural dimensions=] of the image are captured in [=capture the image=],
794729
and set in [=setup transition pseudo-elements=].
795730

796-
The following is added to the [=global view transition user agent style sheet=]:
797-
798-
```css
799-
:root::view-transition-old(*) {
800-
position: absolute;
801-
inset-block-start: 0;
802-
inline-size: 100%;
803-
block-size: auto;
804-
805-
animation-name: -ua-view-transition-fade-out;
806-
animation-duration: inherit;
807-
animation-fill-mode: inherit;
808-
}
809-
```
810-
811-
Note: The aim of the style is to match the element's inline size while retaining the aspect ratio.
812-
It is also placed at the block start.
813-
814-
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=].
731+
Note: Additional styles in the [=document/dynamic view transition style sheet=] added to animate these pseudo-elements
732+
are detailed in [=setup transition pseudo-elements=] and [=update pseudo-element styles=].
815733

816734
### View Transition New State Image: the ''::view-transition-new()'' pseudo-element ### {#::view-transition-new}
817735

@@ -826,21 +744,88 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
826744
Note: The content and [=natural dimensions=] of the image are captured in [=capture the image=],
827745
then set and updated in [=setup transition pseudo-elements=] and [=update pseudo-element styles=].
828746

829-
The following is added to the [=global view transition user agent style sheet=]:
747+
# User Agent Stylesheet # {#ua-styles}
748+
749+
The <dfn>global view transition user agent style sheet</dfn> is
750+
a [=user-agent origin=] style sheet containing the following rules:
830751

831752
```css
753+
:root {
754+
view-transition-name: root;
755+
}
756+
757+
:root::view-transition {
758+
position: fixed;
759+
inset: 0;
760+
}
761+
762+
:root::view-transition-group(*) {
763+
position: absolute;
764+
top: 0;
765+
left: 0;
766+
767+
animation-duration: 0.25s;
768+
animation-fill-mode: both;
769+
}
770+
771+
:root::view-transition-image-pair(*) {
772+
position: absolute;
773+
inset: 0;
774+
775+
animation-duration: inherit;
776+
animation-fill-mode: inherit;
777+
}
778+
779+
:root::view-transition-old(*),
832780
:root::view-transition-new(*) {
833781
position: absolute;
834782
inset-block-start: 0;
835783
inline-size: 100%;
836784
block-size: auto;
837785

838-
animation-name: -ua-view-transition-fade-in;
839786
animation-duration: inherit;
840787
animation-fill-mode: inherit;
841788
}
789+
790+
/* Default cross-fade transition */
791+
@keyframes -ua-view-transition-fade-out {
792+
to { opacity: 0; }
793+
}
794+
@keyframes -ua-view-transition-fade-in {
795+
from { opacity: 0; }
796+
}
797+
:root::view-transition-old(*) {
798+
animation-name: -ua-view-transition-fade-out;
799+
}
800+
:root::view-transition-new(*) {
801+
animation-name: -ua-view-transition-fade-in;
802+
}
842803
```
843804

805+
<details class="note">
806+
<summary>Explanatory Summary</summary>
807+
This UA style sheet does several things:
808+
* Lay out ''::view-transition'' to cover the entire [=snapshot containing block=]
809+
so that each '':view-transition-group()'' child can lay out relative to it.
810+
* Give the [=root element=] a default [=view transition name=],
811+
to allow it to be independently selected.
812+
* Reduce layout interference from the ''::view-transition-image-pair()'' pseudo-element
813+
so that authors can essentially treat ''::view-transition-old()'' and ''::view-transition-new()''
814+
as direct children of ''::view-transition-group()'' for most purposes.
815+
* Inherit animation timing through the tree so that by default,
816+
the animation timing set on a ''::view-transition-group()''
817+
will dictate the animation timing of all its descendants.
818+
* Style the element captures (''::view-transition-old()'' and ''::view-transition-new()'')
819+
to match the size and position set on ''::view-transition-group()''
820+
as it interpolates between them
821+
(see [=document/dynamic view transition style sheet=]).
822+
* Set up a default quarter-second cross-fade animation
823+
for each ''::view-transition-group()''.
824+
</details>
825+
826+
Additional styles are dynamically added to the [=user-agent origin=] during a [=view transition=]
827+
through the [=document/dynamic view transition style sheet=].
828+
844829
# Concepts # {#concepts}
845830

846831
## Phases ## {#phases-concept}
@@ -951,7 +936,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
951936
</dl>
952937

953938
Note: These are used to update, and later remove styles
954-
from a [=/document=]'s [=document/view transition style sheet=].
939+
from a [=/document=]'s [=document/dynamic view transition style sheet=].
955940

956941
## Additions to {{Document}} ## {#additions-to-document}
957942

@@ -964,7 +949,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
964949
: <dfn>transition suppressing rendering</dfn>
965950
:: a boolean. Initially false.
966951

967-
: <dfn>view transition style sheet</dfn>
952+
: <dfn>dynamic view transition style sheet</dfn>
968953
:: a [=/style sheet=].
969954
Initially a new [=/style sheet=] in the [=user-agent origin=], ordered after the [=global view transition user agent style sheet=].
970955

@@ -1444,7 +1429,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
14441429
1. Let |height| be |capturedElement|'s [=captured element/old height=].
14451430

14461431
1. Set |capturedElement|'s [=captured element/group keyframes=] to a new {{CSSKeyframesRule}} representing the following CSS,
1447-
and append it to |document|'s [=document/view transition style sheet=]:
1432+
and append it to |document|'s [=document/dynamic view transition style sheet=]:
14481433

14491434
<!-- deliberately using <pre> so the example can contain <var> references -->
14501435
<pre highlight="css">
@@ -1460,7 +1445,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
14601445
Note: The above code example contains variables to be replaced.
14611446

14621447
1. Set |capturedElement|'s [=captured element/group animation name rule=] to a new {{CSSStyleRule}} representing the following CSS,
1463-
and append it to |document|'s [=document/view transition style sheet=]:
1448+
and append it to |document|'s [=document/dynamic view transition style sheet=]:
14641449

14651450
<!-- deliberately using <pre> so the example can contain <var> references -->
14661451
<pre highlight="css">
@@ -1472,7 +1457,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
14721457
Note: The above code example contains variables to be replaced.
14731458

14741459
1. Set |capturedElement|'s [=captured element/image pair isolation rule=] to a new {{CSSStyleRule}} representing the following CSS,
1475-
and append it to |document|'s [=document/view transition style sheet=]:
1460+
and append it to |document|'s [=document/dynamic view transition style sheet=]:
14761461

14771462
<!-- deliberately using <pre> so the example can contain <var> references -->
14781463
<pre highlight="css">
@@ -1484,7 +1469,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
14841469
Note: The above code example contains variables to be replaced.
14851470

14861471
1. Set |capturedElement|'s [=captured element/view blend mode rule=] to a new {{CSSStyleRule}} representing the following CSS,
1487-
and append it to |document|'s [=document/view transition style sheet=]:
1472+
and append it to |document|'s [=document/dynamic view transition style sheet=]:
14881473

14891474
<!-- deliberately using <pre> so the example can contain <var> references -->
14901475
<pre highlight="css">
@@ -1738,7 +1723,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
17381723

17391724
1. If |capturedElement|'s [=captured element/group styles rule=] is null,
17401725
then set |capturedElement|'s [=captured element/group styles rule=] to a new {{CSSStyleRule}} representing the following CSS,
1741-
and append it to |document|'s [=document/view transition style sheet=].
1726+
and append it to |document|'s [=document/dynamic view transition style sheet=].
17421727

17431728
Otherwise, update |capturedElement|'s [=captured element/group styles rule=] to match the following CSS:
17441729

@@ -1783,8 +1768,8 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
17831768
1. [=list/For each=] |style| of |capturedElement|'s [=captured element/style definitions=]:
17841769

17851770
1. If |style| is not null,
1786-
and |style| is in |document|'s [=document/view transition style sheet=],
1787-
then remove |style| from |document|'s [=document/view transition style sheet=].
1771+
and |style| is in |document|'s [=document/dynamic view transition style sheet=],
1772+
then remove |style| from |document|'s [=document/dynamic view transition style sheet=].
17881773

17891774
1. Set |document|'s [=document/show view-transition root pseudo-element=] to false.
17901775

@@ -1832,7 +1817,7 @@ Changes from <a href="https://www.w3.org/TR/2022/WD-css-view-transitions-1-20221
18321817
Changes from <a href="https://www.w3.org/TR/2022/WD-css-view-transitions-1-20221025/">2022-10-25 Working Draft (FPWD)</a>
18331818
</h3>
18341819

1835-
* Add [=document/view transition style sheet=] concept for dynamically generated UA styles scoped to the current Document.
1820+
* Add [=document/dynamic view transition style sheet=] concept for dynamically generated UA styles scoped to the current Document.
18361821
* Add snapshot viewport concept. See <a href="https://github.com/w3c/csswg-drafts/issues/7859">issue 7859</a>.
18371822
* Clarify timimg for resolving/rejecting promises when skipping the transition. See <a href="https://github.com/w3c/csswg-drafts/issues/7956">issue 7956</a>.
18381823
* Elements under a content-visiblity:auto element that skips its contents are ignored. See <a href="https://github.com/w3c/csswg-drafts/issues/7874">issue 7874</a>.

0 commit comments

Comments
 (0)