Skip to content

Commit f9b425e

Browse files
authored
[css-navigation-1] Add definitions of @navigation (history: ...) queries. (#13187)
These are an initial attempt to address the feature request in #8685. This change also removes the @navigation (<route-location>) syntax that was an alternative for @navigation (at: <route-location>), since I think that syntax no longer makes sense with @navigation (rather than @route) as the name.
1 parent a830e4e commit f9b425e

File tree

1 file changed

+86
-7
lines changed

1 file changed

+86
-7
lines changed

css-navigation-1/Overview.bs

Lines changed: 86 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,15 @@ with <<navigation-condition>> defined as:
198198
| <<navigation-in-parens>> [ and <<navigation-in-parens>> ]*
199199
| <<navigation-in-parens>> [ or <<navigation-in-parens>> ]*
200200
<dfn><<navigation-in-parens>></dfn> = ( <<navigation-condition>> ) | ( <<navigation-test>> ) | <<general-enclosed>>
201-
<dfn><<navigation-test>></dfn> = <<navigation-location>> | <<navigation-keyword>> : <<navigation-location>>
202-
<dfn><<navigation-keyword>></dfn> = at | from | to
201+
<dfn><<navigation-test>></dfn> = <<navigation-location-test>> | <<navigation-type-test>>
202+
203+
<dfn><<navigation-location-test>></dfn> = <<navigation-location-keyword>> : <<navigation-location>>
204+
<dfn><<navigation-location-keyword>></dfn> = at | from | to
203205
<dfn><<navigation-location>></dfn> = <<route-name>> | <<url-pattern()>>
204206
<dfn><<route-name>></dfn> = <<dashed-ident>>
207+
208+
<dfn><<navigation-type-test>></dfn> = history : <<navigation-type-keyword>>
209+
<dfn><<navigation-type-keyword>></dfn> = traverse | back | forward | reload
205210
</pre>
206211

207212
The above grammar is purposely very loose for forwards-compatibility reasons,
@@ -234,9 +239,8 @@ as follows:
234239
: <<navigation-in-parens>>
235240
:: The result is the result of the child subexpression.
236241

237-
: <<navigation-test>>
238-
:: : <<navigation-location>>
239-
: at: <<navigation-location>>
242+
: <<navigation-location-test>>
243+
:: : at: <<navigation-location>>
240244
:: The result is whether the result of
241245
[=URL pattern/match|match a URL pattern=] is non-null
242246
given <var>urlPattern</var> as
@@ -259,6 +263,18 @@ as follows:
259263
the [=navigation location URL pattern=] of <<navigation-location>>
260264
and <var>input</var> as <var>to</var>.
261265

266+
: <<navigation-type-test>>
267+
:: : history: traverse
268+
:: True if the [=current navigation type=] is {{NavigationType/traverse}}.
269+
: history: back
270+
:: True if the [=current navigation type=] is {{NavigationType/traverse}} and
271+
the [=current navigation delta=] is less than 0.
272+
: history: forward
273+
:: True if the [=current navigation type=] is {{NavigationType/traverse}} and
274+
the [=current navigation delta=] is greater than 0.
275+
: history: reload
276+
:: True if the [=current navigation type=] is {{NavigationType/reload}}.
277+
262278
: <<general-enclosed>>
263279
::
264280
The result is false.
@@ -492,7 +508,7 @@ if the following steps return true:
492508
NOTE: Some of the design discussion for this feature has been in
493509
<a href="https://github.com/w3c/csswg-drafts/issues/13163">w3c/csswg-drafts#13163</a>.
494510

495-
<h2 id="current-nav-urls">Current navigation URLs</h2>
511+
<h2 id="current-nav-urls">Definitions of current navigation state</h2>
496512

497513
Both the ''@navigation'' rule and the '':link-to()'' pseudo-class
498514
rely on the following definitions of
@@ -508,8 +524,9 @@ It is defined as follows:
508524
NOTE: This part is for when the old document in the navigation
509525
is still the current document.
510526

511-
1. If the [=document's navigation API=] of the document is non-null and
527+
1. If the [=document's navigation API=] of the document is non-null,
512528
its [=activation=] is non-null,
529+
the activation's {{NavigationActivation/from}} is non-null, and
513530
the document's [=has been revealed=] is false or
514531
was false at the start of the current [=task=],
515532
the activation's {{NavigationActivation/from}}'s
@@ -574,6 +591,10 @@ It is defined as follows:
574591
NOTE: This part is for when the new document in the navigation
575592
has become the current document.
576593

594+
ISSUE: Does it make sense to expose this when
595+
the activation's {{NavigationActivation/from}} is null,
596+
and thus there is no [=current from URL=]?
597+
577598
1. Otherwise, null.
578599

579600
NOTE: The previous two branches can also produce null results.
@@ -582,12 +603,70 @@ ISSUE: The above definitions of from and to apparently don't work right
582603
if you start a same-document navigation (e.g., with {{History/pushState}})
583604
in the middle of a cross-document navigation.
584605

606+
The <dfn>current navigation type</dfn> of a [=/document=] is a {{NavigationType}} or null.
607+
It is defined as follows:
608+
609+
1. If the [=document's navigation API=] of the document is non-null and
610+
its [=transition=] is non-null,
611+
the transition's {{NavigationTransition/navigationType}}.
612+
613+
NOTE: This part is for when the old document in the navigation
614+
is still the current document.
615+
616+
1. If the [=document's navigation API=] of the document is non-null and
617+
its [=activation=] is non-null,
618+
the document's [=has been revealed=] is false or
619+
was false at the start of the current [=task=],
620+
the activation's {{NavigationActivation/navigationType}}.
621+
622+
NOTE: This part is for when the new document in the navigation
623+
has become the current document.
624+
625+
1. Otherwise, null.
626+
627+
The <dfn>current navigation delta</dfn> of a [=/document=] is a {{NavigationType}} or null.
628+
It is defined as follows:
629+
630+
1. If the [=document's navigation API=] of the document is non-null and
631+
its [=transition=] is non-null,
632+
633+
1. If the transition's {{NavigationTransition/navigationType}} is not {{NavigationType/traverse}}, null.
634+
635+
1. Otherwise,
636+
the transition's {{NavigationTransition/to}}'s {{NavigationDestination/index}}
637+
minus
638+
the transition's {{NavigationTransition/from}}'s {{NavigationHistoryEntry/index}}.
639+
640+
NOTE: This part is for when the old document in the navigation
641+
is still the current document.
642+
643+
1. If the [=document's navigation API=] of the document is non-null,
644+
its [=activation=] is non-null,
645+
the activation's {{NavigationActivation/from}} is non-null, and
646+
the document's [=has been revealed=] is false or
647+
was false at the start of the current [=task=],
648+
649+
1. If the activation's {{NavigationActivation/navigationType}} is not {{NavigationType/traverse}}, null.
650+
651+
1. Otherwise,
652+
the activation's {{NavigationActivation/entry}}'s {{NavigationHistoryEntry/index}}
653+
minus
654+
the activation's {{NavigationActivation/from}}'s {{NavigationHistoryEntry/index}}.
655+
656+
NOTE: This part is for when the new document in the navigation
657+
has become the current document.
658+
659+
1. Otherwise, null.
660+
585661
ISSUE: Generally improve integration with the HTML spec for these definitions,
586662
instead of monkeypatching.
587663
This includes the interaction with [=has been revealed=]
588664
and the interaction with the {{pageswap}} event,
589665
and other things where this section links to non-exported definitions.
590666

667+
ISSUE: Generally figure out if these definitions should care about
668+
the [=ongoing navigate event=] or the [=transition=].
669+
591670
<h2 id="url-pattern-function">The ''url-pattern()'' function</h2>
592671

593672
<!--

0 commit comments

Comments
 (0)