Skip to content

Commit 50a8573

Browse files
committed
Rebase more on top of session history rewrite
Similar to the previous commit, this attempts to tackle a specific area, not the whole rebase project (which is tracked in #221). It focuses on traversal, in particular integration with the new versions of "apply the history step" and "traverse the history by a delta". This removes a TODO in the former definition of "perform a navigation API traversal".
1 parent d1996d8 commit 50a8573

File tree

1 file changed

+33
-42
lines changed

1 file changed

+33
-42
lines changed

spec.bs

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ spec: html; urlPrefix: https://whatpr.org/html/6315/
6767
text: reactivate; url: history.html#reactivate-a-document
6868
text: navigate to a fragment; url: history.html#navigate-fragid
6969
text: navigation and traversal task source; url: webappapis.html#navigation-and-traversal-task-source
70+
text: node navigable; url: browsers.html#node-navigable
71+
text: append the following session history traversal steps; url: history.html#tn-append-session-history-traversal-steps
72+
text: snapshot source snapshot params; url: history.html#snapshotting-target-snapshot-params
73+
text: traverse the history by a delta; url: browsers.html#traverse-the-history-by-a-delta
74+
text: top-level traversable; url: history.html#top-level-traversable
75+
for: apply the history step
76+
text: checkForUserCancellation; url: history.html#apply-history-step-check
77+
text: unsafeNavigationStartTime; url: history.html#apply-history-step-start-time
78+
text: sourceSnapshotParams; url: history.html#apply-history-step-source-snapshot
79+
text: initiatorToCheck; url: history.html#apply-history-step-initiator
7080
for: URL and history update steps
7181
text: serializedData; url: history.html#uhus-serializeddata
7282
text: historyHandling; url: history.html#uhus-historyhandling
@@ -988,9 +998,11 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
988998

989999
To <dfn>perform a navigation API traversal</dfn> given a {{Navigation}} object |navigation|, a string |key|, and a {{NavigationOptions}} |options|:
9901000

991-
1. If |navigation|'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
1001+
1. Let |sourceDocument| be |navigation|'s [=relevant global object=]'s [=associated Document=].
9921002

993-
1. If |navigation|'s [=relevant global object=]'s [=associated Document=]'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
1003+
1. If |sourceDocument| is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
1004+
1005+
1. If |sourceDocument|'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
9941006

9951007
1. If |navigation|'s [=Navigation/current entry=]'s [=NavigationHistoryEntry/session history entry=]'s [=session history entry/navigation API key=] equals |key|, then return «[ "{{NavigationResult/committed}}" → [=a promise resolved with=] |navigation|'s [=Navigation/current entry=], "{{NavigationResult/finished}}" → [=a promise resolved with=] |navigation|'s [=Navigation/current entry=]
9961008

@@ -1000,23 +1012,25 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
10001012

10011013
1. Return «[ "{{NavigationResult/committed}}" → |navigation|'s [=navigation API method navigation/committed promise=], "{{NavigationResult/finished}}" → |navigation|'s [=navigation API method navigation/finished promise=] ]».
10021014

1003-
1. Let |navigable| be |navigation|'s [=relevant global object=]'s [=Window/browsing context=]'s [=browsing context/containing navigable=].
1015+
1. Let |info| be |options|["{{NavigationOptions/info}}"] if it [=map/exists=], or undefined otherwise.
10041016

1005-
1. Let |traversable| be |navigable|'s [=navigable/traversable navigable=].
1017+
1. Let |ongoingNavigation| be the result of [=Navigation/setting an upcoming traverse navigation=] for |navigation| given |key| and |info|.
10061018

1007-
1. Let |initiatorBC| be |navigation|'s [=relevant global object=]'s [=Window/browsing context=].
1019+
1. Let |navigable| be |sourceDocument|'s [=node navigable=].
10081020

1009-
1. Let |info| be |options|["{{NavigationOptions/info}}"] if it [=map/exists=], or undefined otherwise.
1021+
1. Let |traversable| be |navigable|'s [=navigable/traversable navigable=].
10101022

1011-
1. Let |ongoingNavigation| be the result of [=Navigation/setting an upcoming traverse navigation=] for |navigation| given |key| and |info|.
1023+
1. Let |unsafeNavigationStartTime| be the [=unsafe shared current time=].
1024+
1025+
1. Let |sourceSnapshotParams| be the result of [=snapshotting source snapshot params=] given |sourceDocument|.
10121026

1013-
1. [=parallel queue/Enqueue the following steps=] on |traversable|'s [=traversable navigable/session history traversal queue=]:
1027+
1. [=Append the following session history traversal steps=] to |traversable|:
10141028

10151029
1. Let |navigableEntries| be the result of [=navigable/getting the session history entries=] given |navigable|.
10161030

10171031
1. Let |targetEntry| be the [=session history entry=] in |navigableEntries| whose [=session history entry/navigation API key=] equals |key|. If no such entry exists, then:
10181032

1019-
1. [=navigation API method navigation/Reject the finished promise=] for |ongoingNavigation| with an "{{InvalidStateError}}" {{DOMException}}.
1033+
1. [=Queue a global task=] on the [=navigation and traversal task source=] given |sourceDocument|'s [=relevant global object=] to [=navigation API method navigation/reject the finished promise=] for |ongoingNavigation| with an "{{InvalidStateError}}" {{DOMException}}.
10201034

10211035
1. Abort these steps.
10221036

@@ -1026,25 +1040,13 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
10261040

10271041
<p class="note">This can occur if a previously-queued-up traversal already took us to this session history entry. In that case that previous traversal will have dealt with |ongoingNavigation| already.
10281042

1029-
1. Let |targetStep| be null.
1043+
1. [=Apply the history step=] given by |targetEntry|'s [=session history entry/step=] to |traversable|, with <i>[=apply the history step/checkForUserCancellation=]</i> set to true, <i>[=apply the history step/unsafeNavigationStartTime=]</i> set to |unsafeNavigationStartTime|, <i>[=apply the history step/sourceSnapshotParams=]</i> set to |sourceSnapshotParams|, and <i>[=apply the history step/initiatorToCheck=]</i> set to |navigable|.
10301044

1031-
1. If |targetEntry|'s [=session history entry/step=] is greater than |traversable|'s [=traversable navigable/current session history step=], then set |targetStep| to |targetEntry|'s [=session history entry/step=].
1045+
- If this aborts due to user-canceled unloading <!-- or, in the future if we allow it to be cancelable, due to the {{Navigation/navigate}} event being canceled, --> then [=queue a global task=] on the [=navigation and traversal task source=] given |sourceDocument|'s [=relevant global object=] to [=finalize with an aborted navigation error=] given |navigation| and |ongoingNavigation|.
10321046

1033-
1. Otherwise:
1034-
1035-
1. Let |afterTarget| be the [=session history entry=] after |targetEntry| in |navigableEntries|.
1036-
1037-
1. Let |allSteps| be the result of [=traversable navigable/getting all history steps=] that are part of the target session TODO.
1038-
1039-
1. Set |targetStep| to the greatest number in |allSteps| that is less than |afterTarget|'s [=session history entry/step=].
1040-
1041-
1. [=Apply the history step=] |targetStep| to |traversable|, with true, |initiatorBC|, and "<code>[=user navigation involvement/none=]</code>".
1047+
- If this aborts due to the initiator allowed-to-navigate check, then [=queue a global task=] on the [=navigation and traversal task source=] given |sourceDocument|'s [=relevant global object=] to [=finalize with an aborted navigation error=] given |navigation|, |ongoingNavigation|, and a [=new=] "{{SecurityError}}" {{DOMException}} created in |navigation|'s [=relevant Realm=].
10421048

1043-
- If this aborts due to user-canceled unloading or due to the {{Navigation/navigate}} event being canceled, then [=finalize with an aborted navigation error=] given |navigation| and |ongoingNavigation|.
1044-
1045-
- If this aborts due to the initiator allowed-to-navigate check, then [=finalize with an aborted navigation error=] given |navigation|, |ongoingNavigation|, and a [=new=] "{{SecurityError}}" {{DOMException}} created in |navigation|'s [=relevant Realm=].
1046-
1047-
<p class="advisement">Eventually [=apply the history step=] will have well-specified hooks for communicating these conditions back to its caller.</p>
1049+
<p class="advisement">As part of merging this spec into HTML, we would modify [=apply the history step=] to have well-specified hooks for communicating these conditions back to its caller.</p>
10481050

10491051
1. Return «[ "{{NavigationResult/committed}}" → |ongoingNavigation|'s [=navigation API method navigation/committed promise=], "{{NavigationResult/finished}}" → |ongoingNavigation|'s [=navigation API method navigation/finished promise=] ]».
10501052
</div>
@@ -1722,10 +1724,10 @@ Modify the <a spec="HTML">navigate</a> algorithm to take an optional named argum
17221724

17231725
Modify the [=navigate to a fragment=] algorithm to take a new <var ignore>userInvolvement</var> argument. Then, update the call to it from <a spec="HTML">navigate</a> to set <i>[=navigate/userInvolvement=]</i> to this <var ignore>userInvolvement</var> value.
17241726

1725-
Modify the <a spec="HTML">traverse the history by a delta</a> argument to take an optional named argument <dfn for="traverse the history by a delta"><var ignore>userInvolvement</var></dfn> (default "<code>[=user navigation involvement/none=]</code>"). Then, update the paragraph talking about user-initiated navigation as follows:
1727+
Modify the [=traverse the history by a delta=] algorithm to take an optional named argument <dfn for="traverse the history by a delta"><var ignore>userInvolvement</var></dfn> (default "<code>[=user navigation involvement/none=]</code>"). Pass it along when calling [=apply the history step=], which also needs to be modified to take such a argument. Then, update the paragraph talking about user-initiated navigation as follows:
17261728

17271729
<blockquote>
1728-
When the user navigates through a [=browsing context=], e.g. using a browser's back and forward buttons, the user agent must <a spec="HTML">traverse the history by a delta</a> with a delta equivalent to the action specified by the user<del> and</del><ins>,</ins> the browsing context being operated on<ins>, and <i>[=traverse the history by a delta/userInvolvement=]</i> set to "<code>[=user navigation involvement/browser UI=]</code>"</ins>.
1730+
When the user navigates through a [=browsing context=], e.g. using a browser's back and forward buttons, the user agent must <a spec="HTML">traverse the history by a delta</a> with the [=top-level traversable=] being operated on, a delta equivalent to the action specified by the user<ins>, and <i>[=traverse the history by a delta/userInvolvement=]</i> set to "<code>[=user navigation involvement/browser UI=]</code>"</ins>.
17291731
</blockquote>
17301732

17311733
<hr>
@@ -1833,23 +1835,12 @@ Expand the section of the navigation/traversal response handling which deals wit
18331835

18341836
<h3 id="navigate-event-traversal-patches">History traversal updates</h3>
18351837

1836-
<div algorithm="traverse the history by a delta">
1837-
The <a spec="HTML">traverse the history by a delta</a> algorithm will be totally re-written as part of <a href="https://github.com/whatwg/html/pull/6315">the session history rewrite</a>. Here we reproduce the final version of the algorithm, after both that rewrite and with appropriate navigation API updates. Recall that per [[#user-initiated-patches]] we have introduced a |userInvolvement| argument, so the arguments are now |delta|, |source browsing context|, and |userInvolvement|.
1838-
1839-
1. Let |traversable| be |source browsing context|'s [=browsing context/containing navigable=]'s [=navigable/traversable navigable=].
1840-
1. Let |initiatorOrigin| be |source browsing context|'s [=active document=]'s [=Document/origin=].
1841-
1. [=parallel queue/enqueue steps|Enqueue the following steps=] to |traversable|'s [=traversable navigable/session history traversal queue=]:
1842-
1. Let |allSteps| be the result of [=traversable navigable/getting all history steps=] for |traversable|.
1843-
1. Let |currentStepIndex| be the index of the [=traversable navigable/current session history step=] within |allSteps|.
1844-
1. Let |targetStepIndex| be |currentStepIndex| plus |delta|.
1845-
1. If |allSteps|[|targetStepIndex|] does not [=set/exist=], then return.
1846-
1. [=Apply the history step=] |allSteps|[|targetStepIndex|] to |traversable| with true, <var ignore>step</var>, |initiatorOrigin|, and |userInvolvement|.
1847-
</div>
1848-
18491838
<div algorithm="apply the history step">
1850-
Modify the <a spec="HTML">apply the history step</a> algorithm as follows. Inside the loop over each <var ignore>navigable</var> of <var ignore>toTraverse</var>, inside the task that is posted, after the check if |targetEntry|'s document is |previousDocument| that might abort the algorithm, add the following steps:
1839+
Modify the [=apply the history step=] algorithm as follows. Near the end of the algorithm, inside the queued task over each global (currently step 14.10), before potentially unloading or activating the history entry, add the following step:
1840+
1841+
1. [=Fire a traversal navigate event=] at <var ignore>displayedDocument</var>'s [=relevant global object=]'s [=Window/navigation API=] with <i>[=fire a traversal navigate event/destinationEntry=]</i> set to <var ignore>targetEntry</var> and <i>[=fire a traversal navigate event/userInvolvement=]</i> set to <var ignore>userInvolvement</var>.
18511842

1852-
1. [=Fire a traversal navigate event=] at |previousDocument|'s [=relevant global object=]'s [=Window/navigation API=] with <i>[=fire a traversal navigate event/destinationEntry=]</i> set to |targetEntry| and <i>[=fire a traversal navigate event/userInvolvement=]</i> set to <var ignore>userInvolvement</var>.
1843+
(Recall that we introduced the <var ignore>userInvolvement</var> parameter as part of [[#user-initiated-patches]].)
18531844
</div>
18541845

18551846
<h3 id="navigate-event-download-patches">Download a hyperlink updates</h3>

0 commit comments

Comments
 (0)