Skip to content

Commit 06f88e1

Browse files
domfarolinodizhang168
authored andcommitted
Editorial: clean up small parts of sequential focus navigation (whatwg#10632)
1 parent f380ac5 commit 06f88e1

File tree

1 file changed

+81
-66
lines changed

1 file changed

+81
-66
lines changed

source

Lines changed: 81 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -80292,10 +80292,10 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {
8029280292

8029380293
<h4><dfn>Sequential focus navigation</dfn></h4>
8029480294

80295-
<p>Each <code>Document</code> has a <dfn>sequential focus navigation order</dfn>, which orders some
80296-
or all of the <span data-x="focusable area">focusable areas</span> in the <code>Document</code>
80297-
relative to each other. Its contents and ordering are given by the <span>flattened
80298-
tabindex-ordered focus navigation scope</span> of the <code>Document</code>.</p>
80295+
<p>Each <code>Document</code> has a <dfn>sequential focus navigation order</dfn>, which orders
80296+
some or all of the <span data-x="focusable area">focusable areas</span> in the
80297+
<code>Document</code> relative to each other. Its contents and ordering are given by the
80298+
<span>flattened tabindex-ordered focus navigation scope</span> of the <code>Document</code>.</p>
8029980299

8030080300
<p class="note">Per the rules defining the <span>flattened tabindex-ordered focus navigation
8030180301
scope</span>, the ordering is not necessarily related to the <span>tree order</span> of the
@@ -80315,10 +80315,21 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {
8031580315
point</span> to the <span>target element</span> when <span data-x="navigate-fragid">navigating
8031680316
to a fragment</span>.</p>
8031780317

80318+
<p>A <dfn>sequential focus direction</dfn> is one of two possible values: "<dfn><code
80319+
data-x="sequential-focus-forward">forward</code></dfn>", or "<dfn><code
80320+
data-x="sequential-focus-backward">backward</code></dfn>". They are used in the below algorithms
80321+
to describe the direction in which sequential focus travels at the user's request.</p>
80322+
80323+
<p>A <dfn>selection mechanism</dfn> is one of two possible values: "<dfn><code
80324+
data-x="selection-mechanism-DOM">DOM</code></dfn>", or
80325+
"<dfn><code data-x="selection-mechanism-sequential">sequential</code></dfn>". They are used to
80326+
describe how the <span>sequential navigation search algorithm</span> finds the <span>focusable
80327+
area</span> it returns.</p>
80328+
8031880329
<p>When the user requests that focus move from the <span>currently focused area of a top-level
80319-
traversable</span> to the next or previous <span>focusable area</span> (e.g. as the default
80330+
traversable</span> to the next or previous <span>focusable area</span> (e.g., as the default
8032080331
action of pressing the <kbd><kbd>tab</kbd></kbd> key), or when the user requests that focus
80321-
sequentially move to a <span>top-level traversable</span> in the first place (e.g. from the
80332+
sequentially move to a <span>top-level traversable</span> in the first place (e.g., from the
8032280333
browser's location bar), the user agent must use the following algorithm:</p>
8032380334

8032480335
<ol>
@@ -80332,26 +80343,29 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {
8033280343
focus navigation starting point</span> instead.</p></li>
8033380344

8033480345
<li>
80335-
<p>Let <var>direction</var> be <i>forward</i> if the user requested the <em>next</em>
80336-
control, and <i>backward</i> if the user requested the previous control.</p>
80346+
<p>Let <var>direction</var> be "<code data-x="sequential-focus-forward">forward</code>" if the
80347+
user requested the next control, and "<code
80348+
data-x="sequential-focus-backward">backward</code>" if the user requested the previous
80349+
control.</p>
8033780350

80338-
<p class="note">Typically, pressing <kbd><kbd>tab</kbd></kbd> requests the next control, and pressing
80339-
<kbd><kbd>shift</kbd> + <kbd>tab</kbd></kbd> requests the previous control.</p>
80351+
<p class="note">Typically, pressing <kbd><kbd>tab</kbd></kbd> requests the next control, and
80352+
pressing <kbd><kbd>shift</kbd> + <kbd>tab</kbd></kbd> requests the previous control.</p>
8034080353
</li>
8034180354

8034280355
<li>
80343-
<p><i>Loop</i>: Let <var>selection mechanism</var> be <i>sequential</i> if the <var>starting
80344-
point</var> is a <span>navigable</span> or if <var>starting point</var> is in its
80345-
<code>Document</code>'s <span>sequential focus navigation order</span>.</p>
80356+
<p><i>Loop</i>: Let <var>selection mechanism</var> be "<code
80357+
data-x="selection-mechanism-sequential">sequential</code>" if <var>starting point</var> is a
80358+
<span>navigable</span> or if <var>starting point</var> is in its <code>Document</code>'s
80359+
<span>sequential focus navigation order</span>.</p>
8034680360

80347-
<p>Otherwise, <var>starting point</var> is not in its <code>Document</code>'s
80348-
<span>sequential focus navigation order</span>; let <var>selection mechanism</var> be
80349-
<i>DOM</i>.</p>
80361+
<p>Otherwise, <var>starting point</var> is not in its <code>Document</code>'s <span>sequential
80362+
focus navigation order</span>; let <var>selection mechanism</var> be "<code
80363+
data-x="selection-mechanism-DOM">DOM</code>".</p>
8035080364
</li>
8035180365

8035280366
<li><p>Let <var>candidate</var> be the result of running the <span>sequential navigation search
8035380367
algorithm</span> with <var>starting point</var>, <var>direction</var>, and <var>selection
80354-
mechanism</var> as the arguments.</p></li>
80368+
mechanism</var>.</p></li>
8035580369

8035680370
<li><p>If <var>candidate</var> is not null, then run the <span>focusing steps</span> for
8035780371
<var>candidate</var> and return.</p></li>
@@ -80389,23 +80403,26 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {
8038980403
</ol>
8039080404

8039180405

80392-
<p>The <dfn>sequential navigation search algorithm</dfn> consists of the following steps. This
80393-
algorithm takes three arguments: <var>starting point</var>, <var>direction</var>,
80394-
and <var>selection mechanism</var>.</p>
80406+
<p>The <dfn>sequential navigation search algorithm</dfn>, given a <span>focusable area</span>
80407+
<var>starting point</var>, <span>sequential focus direction</span> <var>direction</var>, and
80408+
<span>selection mechanism</span> <var>selection mechanism</var>, consists of the following steps.
80409+
They return a <span>focusable area</span>-or-null.</p>
8039580410

8039680411
<ol>
8039780412
<li>
8039880413
<p>Pick the appropriate cell from the following table, and follow the instructions in that
8039980414
cell.</p>
8040080415

80401-
<p>The appropriate cell is the one that is from the column whose header describes <var>direction</var> and from the first row whose header describes <var>starting point</var> and <var>selection mechanism</var>.</p>
80416+
<p>The appropriate cell is the one that is from the column whose header describes
80417+
<var>direction</var> and from the first row whose header describes <var>starting point</var> and
80418+
<var>selection mechanism</var>.</p>
8040280419

8040380420
<table>
8040480421
<thead>
8040580422
<tr>
8040680423
<th>
80407-
<th> <var>direction</var> is <i>forward</i>
80408-
<th> <var>direction</var> is <i>backward</i>
80424+
<th><var>direction</var> is "<code data-x="sequential-focus-forward">forward</code>"
80425+
<th><var>direction</var> is "<code data-x="sequential-focus-backward">backward</code>"
8040980426
<tbody>
8041080427
<tr>
8041180428
<th><var>starting point</var> is a <span>navigable</span>
@@ -80416,57 +80433,55 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {
8041680433
in <var>starting point</var>'s <span data-x="nav-document">active document</span>, if any; or
8041780434
else null
8041880435
<tr>
80419-
<th><var>selection mechanism</var> is <i>DOM</i>
80436+
<th><var>selection mechanism</var> is "<code data-x="selection-mechanism-DOM">DOM</code>"
80437+
<td>
80438+
<p>Let <var>candidate</var> be the <span>suitable sequentially focusable area</span>, that
80439+
appears nearest after <var>starting point</var> in <var>starting point</var>'s
80440+
<code>Document</code>, in <span>shadow-including tree order</span>, if any; or else null</p>
80441+
80442+
<p class="note">In this case, <var>starting point</var> does not necessarily belong to its
80443+
<code>Document</code>'s <span>sequential focus navigation order</span>, so we'll select the
80444+
<span data-x="suitable sequentially focusable area">suitable</span> <span data-x="list
80445+
item">item</span> from that list that comes <em>after</em> <var>starting point</var> in
80446+
<span>shadow-including tree order</span>.</p>
80447+
</td>
80448+
<td>Let <var>candidate</var> be the <span>suitable sequentially focusable area</span>, that
80449+
appears nearest before <var>starting point</var> in <var>starting point</var>'s
80450+
<code>Document</code>, in <span>shadow-including tree order</span>, if any; or else null
80451+
<tr>
80452+
<th><var>selection mechanism</var> is "<code
80453+
data-x="selection-mechanism-sequential">sequential</code>"
8042080454
<td>Let <var>candidate</var> be the first <span>suitable sequentially focusable area</span>
80421-
in the <span>home document</span> following <var>starting point</var>, if any; or else null
80455+
after <var>starting point</var>, in <var>starting point</var>'s <code>Document</code>'s
80456+
<span>sequential focus navigation order</span>, if any; or else null
8042280457
<td>Let <var>candidate</var> be the last <span>suitable sequentially focusable area</span>
80423-
in the <span>home document</span> preceding <var>starting point</var>, if any; or else null
80424-
<tr>
80425-
<th><var>selection mechanism</var> is <i>sequential</i>
80426-
<td>Let <var>candidate</var> be the first <span>suitable sequentially focusable area</span> in the <span>home sequential focus navigation order</span> following <var>starting point</var>, if any; or else null
80427-
<td>Let <var>candidate</var> be the last <span>suitable sequentially focusable area</span> in the <span>home sequential focus navigation order</span> preceding <var>starting point</var>, if any; or else null
80428-
80458+
before <var>starting point</var>, in <var>starting point</var>'s <code>Document</code>'s
80459+
<span>sequential focus navigation order</span>, if any; or else null
8042980460
</table>
8043080461

8043180462
<p>A <dfn>suitable sequentially focusable area</dfn> is a <span>focusable area</span> whose
8043280463
<span>DOM anchor</span> is not <span>inert</span> and is <span>sequentially
8043380464
focusable</span>.</p>
80465+
</li>
8043480466

80435-
<p>The <dfn>home document</dfn> is the <code>Document</code> to which <var>starting point</var>
80436-
belongs.</p>
80437-
80438-
<p>The <dfn>home sequential focus navigation order</dfn> is the <span>sequential focus
80439-
navigation order</span> to which <var>starting point</var> belongs.</p>
80440-
80441-
<p class="note">The <span>home sequential focus navigation order</span> is the <span>home
80442-
document</span>'s <span>sequential focus navigation order</span>, but is only used when the
80443-
<var>starting point</var> is in that <span>sequential focus navigation order</span>
80444-
(when it's not, <var>selection mechanism</var> will be <i>DOM</i>).</p>
80445-
</li>
80446-
80447-
<li><p>If <var>candidate</var> is a <span data-x="reading-flow-item">reading flow item</span> or
80448-
null, <var>direction</var> is <i>forward</i>, and <var>starting point</var> is in a
80449-
<span>reading-flow focus navigation scope</span> <var>scope</var>, then let <var>new
80450-
candidate</var> be the result of running the <span>reading flow sequential navigation search
80451-
algorithm</span> given <var>candidate</var>, <var>direction</var>, and <var>starting
80452-
point</var>'s focus navigation <var>scope</var>.</p></li>
80453-
80454-
<li><p>If <var>starting point</var> is a <span data-x="reading-flow-item">reading flow
80455-
item</span>, <var>direction</var> is <i>backward</i>, and <var>starting point</var> is in a
80456-
<span>reading-flow focus navigation scope</span> <var>scope</var>, then let <var>new
80457-
candidate</var> be the result of running the <span>reading flow sequential navigation search
80458-
algorithm</span> given <var>starting point</var>, <var>direction</var>, and <var>starting
80459-
point</var>'s focus navigation <var>scope</var>.</p></li>
80460-
80461-
<li><p>If <var>candidate</var> is a <span>navigable container</span> with a non-null
80462-
<span>content navigable</span>, then let <var>new candidate</var> be the result of running the
80463-
<span>sequential navigation search algorithm</span> given <var>candidate</var>'s <span>content
80464-
navigable</span>, <var>direction</var>, and <i>sequential</i> <!-- shift-tab from the end in
80465-
https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2855 -->.</p></li>
80466-
80467-
<li><p>If <var>new candidate</var> is null, then let <var>starting point</var> be
80468-
<var>candidate</var>, and return to the top of this algorithm. Otherwise, let
80469-
<var>candidate</var> be <var>new candidate</var>.</p></li>
80467+
<li>
80468+
<p>If <var>candidate</var> is a <span>navigable container</span> with a non-null <span>content
80469+
navigable</span>, then:</p>
80470+
80471+
<ol>
80472+
<li><p>Let <var>recursive candidate</var> be the result of running the <span>sequential
80473+
navigation search algorithm</span> with <var>candidate</var>'s <span>content navigable</span>,
80474+
<var>direction</var>, and "<code
80475+
data-x="selection-mechanism-sequential">sequential</code>".<!-- shift-tab from the end in
80476+
https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2855 --></p></li>
80477+
80478+
<li><p>If <var>recursive candidate</var> is null, then return the result of running the
80479+
<span>sequential navigation search algorithm</span> with <var>candidate</var>,
80480+
<var>direction</var>, and <var>selection mechanism</var>.</p></li>
80481+
80482+
<li><p>Otherwise, set <var>candidate</var> to <var>recursive candidate</var>.</p></li>
80483+
</ol>
80484+
</li>
8047080485

8047180486
<li><p>Return <var>candidate</var>.</p></li>
8047280487
</ol>

0 commit comments

Comments
 (0)