Skip to content

Commit 7ebecab

Browse files
authored
[css-view-transitions-2] Apply renames based on TPAC discussion (#9382)
* [css-view-transitions-2] Rename reveal to readytorender, and auto-view-transition to navigation-behavior * Add CSSOM definitions * Rename to what was decided temporarily at TPAC * PR nits
1 parent 35e2d5e commit 7ebecab

File tree

1 file changed

+72
-41
lines changed

1 file changed

+72
-41
lines changed

css-view-transitions-2/Overview.bs

Lines changed: 72 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
118118
1. Once it's time to [=unload=] the old document, if the navigation is [=same origin=]
119119
and the old {{Document}} has opted in to cross-document view-transitions, the old state is captured.
120120

121-
1. An event named {{PageRevealEvent|reveal}} is fired on the new {{Document}}, with a `viewTransition` property,
121+
1. An event named {{RevealEvent|reveal}} is fired on the new {{Document}}, with a `viewTransition` property,
122122
which is a {{ViewTransition}} object. This {{ViewTransition}}'s <code>{{ViewTransition/updateCallbackDone}}</code> is already resolved,
123123
and its [=captured elements=] are populated from the old {{Document}}.
124124

@@ -133,12 +133,12 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
133133
To generate the same cross-fade as in the first example [[css-view-transitions-1#examples]],
134134
but across documents, we don't need JavaScript.
135135

136-
Instead, we opt in to auto-view-transitions in both page 1 and page 2:
136+
Instead, we opt in to triggering view-transitions on navigation in both page 1 and page 2:
137137

138138
```css
139139
// in both documents:
140-
@auto-view-transitions {
141-
same-origin: enable;
140+
@view-transition same-origin {
141+
trigger: navigation;
142142
}
143143
```
144144

@@ -151,14 +151,14 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
151151
To achieve the effect in [[css-view-transitions-1#examples|example 5]], we have to do several
152152
things:
153153

154-
- Opt-in to auto-view-transitions in both pages.
154+
- Opt-in to navigation-triggered view-transitions in both pages.
155155
- Pass the click location to the new document, e.g. via {{WindowSessionStorage/sessionStorage}}.
156-
- Intercept the {{ViewTransition}} object in the new document, using the {{PageRevealEvent|reveal event}}.
156+
- Intercept the {{ViewTransition}} object in the new document, using the {{RevealEvent}}.
157157

158158
In both pages:
159159
```css
160-
@auto-view-transitions {
161-
same-origin: enable;
160+
@view-transition same-origin {
161+
trigger: navigation;
162162
}
163163

164164
```
@@ -259,59 +259,68 @@ document.startViewTransition({update: updateTheDOMSomehow});
259259

260260
# CSS rules # {#css-rules}
261261

262-
## The <dfn id="at-auto-view-transition-rule">''@auto-view-transition''</dfn> rule ## {#auto-view-transition-rule}
262+
## The <dfn id="at-view-transition-rule">''@view-transition''</dfn> rule ## {#view-transition-rule}
263263

264-
The ''@auto-view-transition'' rule is used by a document to indicate that cross-document navigations
264+
The ''@view-transition'' rule is used by a document to indicate that cross-document navigations
265265
should setup and activate a {{ViewTransition}}. To take effect, it must be present in the old document
266-
when unloading, and in the new document when it is being [=reveal document|revealed=].
266+
when unloading, and in the new document when it is [=ready to render=].
267267

268268

269-
## @auto-view-transition rule grammar ## {#auto-view-transition-grammer}
269+
## @view-transition rule grammar ## {#view-transition-grammar}
270270

271-
''@auto-view-transition'' rules are [=CSS/parsed=] according to the following grammar,
272-
plus the additional rules noted below:
271+
The ''@view-transition'' rule has the following syntax:
273272

274273
<pre class=prod>
275-
@auto-view-transition = @auto-view-transition { <<declaration-rule-list>> }
274+
@view-transition same-origin {
275+
<<declaration-rule-list>>
276+
}
276277
</pre>
277278

278-
## The [=@auto-view-transition/same-origin=] property ## {#view-transition-name-prop}
279+
Note: currently <code>same-origin</code> has to be present, as a future placeholder for customizing
280+
the navigation behavior based on the URL.
281+
282+
Note: as per default behavior, the ''@view-transition'' rule can be nested inside a
283+
[=conditional group rule=] such as ''@media'' or ''@supports''.
284+
285+
## The [=@view-transition/view-transition=] property ## {#view-transition-name-prop}
279286

280287
<pre class='descdef'>
281-
Name: same-origin
282-
For: @auto-view-transition
283-
Value: enabled | disabled
284-
Initial: disabled
288+
Name: trigger
289+
For: @view-transition
290+
Value: navigation | none
291+
Initial: none
285292
</pre>
286293

287-
The '<dfn for="@auto-view-transition">same-origin</dfn>' property opts in to automatically performing a view transition when performing a [=same origin=] navigation.
294+
The '<dfn for="@view-transition">trigger</dfn>' property opts in to automatically starting a view transition when performing a navigation.
288295
It needs to be enabled both in the old document (when unloading) and in the new document (when ready to render).
289296

290-
<dl dfn-type=value dfn-for="same-origin">
291-
: <dfn>disabled</dfn>
297+
<dl dfn-type=value dfn-for="trigger">
298+
: <dfn>none</dfn>
292299
:: There will be no transition.
293300

294-
: <dfn>enabled</dfn>
301+
: <dfn>navigation</dfn>
295302
:: The transition will be enabled if the navigation is same-origin, without cross-origin
296303
redirects.
297304
</dl>
298305

306+
307+
299308
# API # {#api}
300309

301-
## The <dfn interface>PageRevealEvent</dfn> ## {#reveal-event}
310+
## The <dfn interface>RevealEvent</dfn> ## {#ready-to-render-event}
302311

303312
Note: this should go in the HTML spec. See [Issue 9315](https://github.com/whatwg/html/issues/9315).
304313

305314
<xmp class=idl>
306315
[Exposed=Window]
307-
interface PageRevealEvent : Event {
316+
interface RevealEvent : Event {
308317
readonly attribute ViewTransition? viewTransition;
309318
};
310319
</xmp>
311320

312-
Note: this event is fired when [=reveal document|revealing a document=].
321+
Note: this event is fired when the document is [=ready to render=].
313322

314-
The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are to return the
323+
The <dfn attribute for=RevealEvent>viewTransition</dfn> [=getter steps=] are to return the
315324
[=inbound cross-document view-transition=] for [=this's=] [=relevant global object's=] [=associated document=].
316325

317326
## Additions to {{Document}} ## {#additions-to-document-api}
@@ -342,6 +351,28 @@ The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are
342351
1. Return |viewTransition|.
343352
</div>
344353

354+
## Extensions to the <code>CSSRule</code> interface</h3> ## {#extensions-to-cssrule-interface}
355+
356+
The <code>CSSRule</code> interface is extended as follows:
357+
358+
<pre class='idl'>
359+
partial interface CSSRule {
360+
const unsigned short VIEW_TRANSITION_RULE = 15;
361+
};
362+
</pre>
363+
364+
## The <code>CSSViewTransitionRule</code> interface</h3> ## {#navgation-behavior-rule-interface}
365+
366+
The {{CSSViewTransitionRule}} represents a ''@view-transition'' rule.
367+
368+
<xmp class=idl>
369+
enum ViewTransitionTrigger { "navigation", "none" };
370+
[Exposed=Window]
371+
interface CSSViewTransitionRule : CSSRule {
372+
readonly attribute CSSOMString navigationConditionText;
373+
attribute ViewTransitionTrigger trigger;
374+
};
375+
</xmp>
345376

346377

347378
# Algorithms # {#algorithms}
@@ -352,10 +383,10 @@ The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are
352383
A {{Document}} additionally has:
353384

354385
<dl dfn-for=document>
355-
: <dfn>is revealed</dfn>
386+
: <dfn>ready to render fired</dfn>
356387
:: a boolean, initially false.
357388

358-
### Additions to {{ViewTransition}} ## {#view-transitions-extension}
389+
### Additions to {{ViewTransition}} ### {#view-transitions-extension}
359390

360391
A {{ViewTransition}} additionally has:
361392
<dl dfn-for=ViewTransition>
@@ -380,29 +411,29 @@ The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are
380411
<div algorithm="monkey patch to rendering">
381412
Run the following step in [=update the rendering|updating the renedering=], before [=running the animation frame callbacks=]:
382413

383-
1. For each [=fully active=] {{Document}} |doc| in |docs|, [=reveal document|reveal=] |doc|.
414+
1. For each [=fully active=] {{Document}} |doc| in |docs|, run the [=ready to render=] steps for |doc|.
384415
</div>
385416

386417
<div algorithm="monkey patch to reactivation">
387418
Run the following step at the end of [=Document/reactivate=]:
388419

389-
1. Set |document|'s [=is revealed=] to false.
420+
1. Set |document|'s [=ready to render fired=] to false.
390421
</div>
391422

392-
<div algorithm="page reveal">
393-
To <dfn>reveal {{Document}}</dfn> |document|:
394-
1. If |document|'s [=document/is revealed=] is true, then return.
423+
<div algorithm="page ready to render">
424+
When {{Document}} |document| is <dfn>ready to render</dfn>:
425+
1. If |document|'s [=document/ready to render fired=] is true, then return.
395426

396427
1. Let |transition| be the result of getting the [=inbound cross-document view-transition=] for |document|.
397428

398429
1. If |transition| is not null and |document| does not [=opt in to cross-document view transitions=], then [=skip the view transition|skip=] |transition| and set |transition| to null.
399430

400431
1. Fire a new event named <code>reveal</code> on |document|'s [=relevant global object=],
401-
using {{PageRevealEvent}}.
432+
using {{RevealEvent}}.
402433

403434
1. If |transition| is not null, then [=activate view transition|activate=] |transition|.
404435

405-
1. Set |document|'s [=document/is revealed=] to true.
436+
1. Set |document|'s [=document/ready to render fired=] to true.
406437
</div>
407438

408439
## Setting up and activating the cross-document view transition ## {#setting-up-and-activating-the-cross-document-view-transition}
@@ -423,7 +454,7 @@ The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are
423454
1. If |oldDocument| does not [=opt in to cross-document view transitions=], then call |onReady| and return.
424455

425456
Note: We don't know yet if |newDocument| has opted in, as it might not be parsed yet.
426-
We check the opt-in for |newDocument| when it is [=reveal document|revealed=].
457+
We check the opt-in for |newDocument| when it is [=ready to render=].
427458

428459
1. If |oldDocument|'s [=active view transition=] is not null,
429460
then [=skip the view transition|skip=] |oldDocument|'s [=active view transition=]
@@ -475,15 +506,15 @@ The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are
475506
then return null.
476507

477508
Note: |transition|'s [=ViewTransition/is inbound cross-document transition=] would be false if a same-document
478-
transition was started before the page was revealed.
509+
transition was started before the page was [=ready to render=].
479510

480511
1. Return |transition|.
481512
</div>
482513

483514
<div algorithm>
484515
A {{Document}} |document| is said to <dfn>opt in to cross-document view transitions</dfn>
485-
if the [=computed value=] of <a data-xref-type="css-descriptor" data-xref-for="@auto-view-transition">same-origin</a>
486-
is <code>enabled</code>.
516+
if the [=computed value=] of <a data-xref-type="css-descriptor" data-xref-for="@view-transition">trigger</a>
517+
for |document| is <code>navigation</code>.
487518
</div>
488519

489520

0 commit comments

Comments
 (0)