Skip to content

Commit c1b7835

Browse files
authored
Merge pull request w3c#2 from jihyerish/first-draft
Add the description about focus navigation heuristic
2 parents 7e0f5ee + bc862f1 commit c1b7835

File tree

2 files changed

+157
-17
lines changed

2 files changed

+157
-17
lines changed

index.bs

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Activating Spatial Navigation: the 'arrow-key-behavior' property</h2>
3636

3737
Historically, most browsers have not offered features to let users move the focus directionally.
3838
Some, such as TV browsers, have controlled spatial navigation using the arrow keys out of necessity,
39-
since no other input mechanism is available on a typical TV remove control.
39+
since no other input mechanism is available on a typical TV remote control.
4040

4141
Others, have enabled different key combinations to control spatial navigation,
4242
such as pressing the <code class=key>SHIFT</code> key together with arrow keys.
@@ -49,7 +49,7 @@ such as scrolling.
4949
The 'arrow-key-behavior' property enables an author to declare
5050
that their document, or part of their document,
5151
has been authored with spatial navigation in mind,
52-
and the UA can bind the arrow keys to spatial navigation
52+
and the User Agent can bind the arrow keys to spatial navigation
5353
without risk of interfering with other behavior.
5454

5555
<pre class='propdef'>
@@ -74,11 +74,11 @@ Does that depend on whether the selection is collapsed or not?
7474
<dl dfn-for=arrow-key-behavior>
7575
<dt><dfn>auto</dfn>
7676
<dd>The User Agent defines which keys,
77-
if any,
78-
control spatial navigation.
77+
if any, control spatial navigation.
7978

8079
On devices such as TVs which do not have any pointing input device
81-
and which also lack a <code class=key>Tab</code> key to control sequential navigation,
80+
and which also lack a <code class=key>Tab</code> key to control
81+
<a herf="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation">sequential focus navigation</a>,
8282
it is recommended that arrow keys be used for that purpose without any modifier key.
8383
On devices with a full keyboard,
8484
the User Agent may use a combination of arrow keys with a modifier key.
@@ -159,10 +159,71 @@ the sequence is as follows:
159159
<h3 id=heuristic>
160160
Focus Navigation Heuristic</h3>
161161

162-
The <dfn>focus navigation heuristic</dfn> determines which element should be focused next
162+
The <dfn>focus navigation heuristic</dfn> runs these steps:
163+
164+
1. Select the initially focused element.
165+
166+
1. If there is a previously focused element, it is the initially focused element.
167+
2. Otherwise, among all the focusable areas, the element on the topmost and the leftmost in the
168+
current level of browsing context is the initially focused element.
169+
170+
2. Let the initially focused element be the currently focused element.
171+
172+
3. Move focus to the currently focused element.
173+
174+
4. Get the direction of the spatial navigation.
175+
176+
5. Find the candidate elements.
177+
178+
Note: The element which is overlapped by the focused element is also the candidate element.
179+
180+
1. If the up arrow key or the down arrow key is pressed, <var>axis A</var> is Y. Otherwise, the left
181+
arrow key or the right arrow key is pressed, <var>axis A</var> is X.
182+
2. If the right arrow key or the down arrow key is pressed, <var>direction D</var> is positive.
183+
Otherwise, the left arrow key or the up arrow key is pressed, <var>direction D</var> is negative.
184+
3. Find the candidate elements which satisfy the conditions below:
185+
* The element should be focusable.
186+
* The element should be visible within the viewport.
187+
* The position of the center point of the element should be greater than that of the currently focused
188+
element in <var>direction D</var> on <var>axis A</var>.
189+
* The position value of the edge in the navigation direction of the element should be greater than
190+
that of the currently focused element in <var>direction D</var> on <var>axis A</var>.
191+
192+
6. Find the next focused element.
193+
194+
1. Find the combination of the vertex on the currently focused element and the vertex on the
195+
candidate element which makes the shortest distance between two vertices.
196+
197+
* Select <var>vertex V1</var> from the currently focused element.
198+
* Select <var>vertex V2</var> from the candidate element.
199+
200+
201+
2. Calculate the distance between <var>vertex V1</var> and <var>vertex V2</var> for each candidate
202+
element.
203+
The Distance function is:
204+
205+
<dfn>distance</dfn> = <var>A</var> + <var>B</var> + <var>C</var> - <var>D</var></code>
206+
207+
Note: This refers to the <a href="https://www.w3.org/TR/WICD/#focus-handling">old WICD Spec</a>
208+
209+
<var>A</var> : The euclidian distance between <var>vertex V1</var> and <var>vertex V2</var>.
210+
211+
<var>B</var> : The absolute distance in the navigation direction between <var>vertex V1</var> and
212+
<var>vertex V2</var>.
213+
214+
<var>C</var> : The absolute distance in the direction which is orthogonal to the navigation
215+
direction between <var>vertex V1</var> and <var>vertex V2</var>.
216+
217+
<var>D</var> : The square root of the overlapped area between the candidate element and the
218+
currently focused element.
219+
220+
3. Select the element which distance is the least among the candidate elements.
221+
222+
7. Move focus to the next focused element.
223+
224+
The <a>focus navigation heuristic</a> determines which element should be focused next
163225
when the user invokes either spatial or sequential navigation.
164226

165227
Issue: Add the details. Link to HTML for the logic on sequential navigation.
166228

167229
</div>
168-

index.html

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,9 +1176,8 @@
11761176
}
11771177
}
11781178
</style>
1179-
<meta content="Bikeshed version b43bcf8d18510de03d8b56c5e878eea93e955427" name="generator">
1179+
<meta content="Bikeshed version bbd6a9c4064dd454886bb3e0c74f0a19865c3c74" name="generator">
11801180
<link href="http://wicg.github.io/spatial-navigation" rel="canonical">
1181-
<meta content="2654c96167fa9d0e5432f1b722d6d4d9a934a5ed" name="document-revision">
11821181
<style>/* style-md-lists */
11831182

11841183
/* This is a weird hack for me not yet following the commonmark spec
@@ -1425,13 +1424,12 @@
14251424
<div class="head">
14261425
<p data-fill-with="logo"></p>
14271426
<h1 class="p-name no-ref" id="title">Spatial Navigation</h1>
1428-
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2017-12-21">21 December 2017</time></span></h2>
1427+
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2017-12-25">25 December 2017</time></span></h2>
14291428
<div data-fill-with="spec-metadata">
14301429
<dl>
14311430
<dt>This version:
14321431
<dd><a class="u-url" href="http://wicg.github.io/spatial-navigation">http://wicg.github.io/spatial-navigation</a>
14331432
<dt>Issue Tracking:
1434-
<dd><a href="https://github.com/frivoal/spatial-navigation/issues/">GitHub</a>
14351433
<dd><a href="#issues-index">Inline In Spec</a>
14361434
<dt class="editor">Editors:
14371435
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:jh.hong@lge.com">Jihye Hong</a> (<span class="p-org org">LG Electronics</span>)
@@ -1510,7 +1508,7 @@ <h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </s
15101508
<h2 class="heading settled" data-level="2" id="activation"><span class="secno">2. </span><span class="content"> Activating Spatial Navigation: the <a class="property" data-link-type="propdesc" href="#propdef-arrow-key-behavior" id="ref-for-propdef-arrow-key-behavior">arrow-key-behavior</a> property</span><a class="self-link" href="#activation"></a></h2>
15111509
<p>Historically, most browsers have not offered features to let users move the focus directionally.
15121510
Some, such as TV browsers, have controlled spatial navigation using the arrow keys out of necessity,
1513-
since no other input mechanism is available on a typical TV remove control.</p>
1511+
since no other input mechanism is available on a typical TV remote control.</p>
15141512
<p>Others, have enabled different key combinations to control spatial navigation,
15151513
such as pressing the <code class="key">SHIFT</code> key together with arrow keys.</p>
15161514
<p>While arrow keys are well suited for this,
@@ -1520,7 +1518,7 @@ <h2 class="heading settled" data-level="2" id="activation"><span class="secno">2
15201518
<p>The <a class="property" data-link-type="propdesc" href="#propdef-arrow-key-behavior" id="ref-for-propdef-arrow-key-behavior①">arrow-key-behavior</a> property enables an author to declare
15211519
that their document, or part of their document,
15221520
has been authored with spatial navigation in mind,
1523-
and the UA can bind the arrow keys to spatial navigation
1521+
and the User Agent can bind the arrow keys to spatial navigation
15241522
without risk of interfering with other behavior.</p>
15251523
<table class="def propdef" data-link-for-hint="arrow-key-behavior">
15261524
<tbody>
@@ -1567,10 +1565,9 @@ <h2 class="heading settled" data-level="2" id="activation"><span class="secno">2
15671565
<dt><dfn data-dfn-for="arrow-key-behavior" data-dfn-type="dfn" data-noexport="" id="arrow-key-behavior-auto">auto<a class="self-link" href="#arrow-key-behavior-auto"></a></dfn>
15681566
<dd>
15691567
The User Agent defines which keys,
1570-
if any,
1571-
control spatial navigation.
1568+
if any, control spatial navigation.
15721569
<p>On devices such as TVs which do not have any pointing input device
1573-
and which also lack a <code class="key">Tab</code> key to control sequential navigation,
1570+
and which also lack a <code class="key">Tab</code> key to control <a data-link-type="dfn" herf="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation" href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation" id="ref-for-sequential-focus-navigation">sequential focus navigation</a>,
15741571
it is recommended that arrow keys be used for that purpose without any modifier key.
15751572
On devices with a full keyboard,
15761573
the User Agent may use a combination of arrow keys with a modifier key.</p>
@@ -1641,7 +1638,79 @@ <h3 class="heading settled" data-level="4.1" id="events"><span class="secno">4.1
16411638
</ul>
16421639
</ul>
16431640
<h3 class="heading settled" data-level="4.2" id="heuristic"><span class="secno">4.2. </span><span class="content"> Focus Navigation Heuristic</span><a class="self-link" href="#heuristic"></a></h3>
1644-
<p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="focus-navigation-heuristic">focus navigation heuristic</dfn> determines which element should be focused next
1641+
<p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="focus-navigation-heuristic">focus navigation heuristic</dfn> runs these steps:</p>
1642+
<ol>
1643+
<li data-md="">
1644+
<p>Select the initially focused element.</p>
1645+
<ol>
1646+
<li data-md="">
1647+
<p>If there is a previously focused element, it is the initially focused element.</p>
1648+
<li data-md="">
1649+
<p>Otherwise, among all the focusable areas, the element on the topmost and the leftmost in the
1650+
current level of browsing context is the initially focused element.</p>
1651+
</ol>
1652+
<li data-md="">
1653+
<p>Let the initially focused element be the currently focused element.</p>
1654+
<li data-md="">
1655+
<p>Move focus to the currently focused element.</p>
1656+
<li data-md="">
1657+
<p>Get the direction of the spatial navigation.</p>
1658+
<li data-md="">
1659+
<p>Find the candidate elements.</p>
1660+
<p class="note" role="note"><span>Note:</span> The element which is overlapped by the focused element is also the candidate element.</p>
1661+
<ol>
1662+
<li data-md="">
1663+
<p>If the up arrow key or the down arrow key is pressed, <var>axis A</var> is Y. Otherwise, the left
1664+
arrow key or the right arrow key is pressed, <var>axis A</var> is X.</p>
1665+
<li data-md="">
1666+
<p>If the right arrow key or the down arrow key is pressed, <var>direction D</var> is positive.
1667+
Otherwise, the left arrow key or the up arrow key is pressed, <var>direction D</var> is negative.</p>
1668+
<li data-md="">
1669+
<p>Find the candidate elements which satisfy the conditions below:</p>
1670+
<ul>
1671+
<li data-md="">
1672+
<p>The element should be focusable.</p>
1673+
<li data-md="">
1674+
<p>The element should be visible within the viewport.</p>
1675+
<li data-md="">
1676+
<p>The position of the center point of the element should be greater than that of the currently focused
1677+
element in <var>direction D</var> on <var>axis A</var>.</p>
1678+
<li data-md="">
1679+
<p>The position value of the edge in the navigation direction of the element should be greater than
1680+
that of the currently focused element in <var>direction D</var> on <var>axis A</var>.</p>
1681+
</ul>
1682+
</ol>
1683+
<li data-md="">
1684+
<p>Find the next focused element.</p>
1685+
<ol>
1686+
<li data-md="">
1687+
<p>Find the combination of the vertex on the currently focused element and the vertex on the
1688+
candidate element which makes the shortest distance between two vertices.</p>
1689+
<ul>
1690+
<li data-md="">
1691+
<p>Select <var>vertex V1</var> from the currently focused element.</p>
1692+
<li data-md="">
1693+
<p>Select <var>vertex V2</var> from the candidate element.</p>
1694+
</ul>
1695+
<li data-md="">
1696+
<p>Calculate the distance between <var>vertex V1</var> and <var>vertex V2</var> for each candidate
1697+
element.
1698+
The Distance function is:</p>
1699+
<p><dfn data-dfn-type="dfn" data-noexport="" id="distance">distance<a class="self-link" href="#distance"></a></dfn> = <var>A</var> + <var>B</var> + <var>C</var> - <var>D</var></p>
1700+
<p class="note" role="note"><span>Note:</span> This refers to the <a href="https://www.w3.org/TR/WICD/#focus-handling">old WICD Spec</a></p>
1701+
<p><var>A</var> : The euclidian distance between <var>vertex V1</var> and <var>vertex V2</var>.</p>
1702+
<p><var>B</var> : The absolute distance in the navigation direction between <var>vertex V1</var> and <var>vertex V2</var>.</p>
1703+
<p><var>C</var> : The absolute distance in the direction which is orthogonal to the navigation
1704+
direction between <var>vertex V1</var> and <var>vertex V2</var>.</p>
1705+
<p><var>D</var> : The square root of the overlapped area between the candidate element and the
1706+
currently focused element.</p>
1707+
<li data-md="">
1708+
<p>Select the element which distance is the least among the candidate elements.</p>
1709+
</ol>
1710+
<li data-md="">
1711+
<p>Move focus to the next focused element.</p>
1712+
</ol>
1713+
<p>The <a data-link-type="dfn" href="#focus-navigation-heuristic" id="ref-for-focus-navigation-heuristic②">focus navigation heuristic</a> determines which element should be focused next
16451714
when the user invokes either spatial or sequential navigation.</p>
16461715
<p class="issue" id="issue-3eba2d0c"><a class="self-link" href="#issue-3eba2d0c"></a> Add the details. Link to HTML for the logic on sequential navigation.</p>
16471716
</main>
@@ -1803,6 +1872,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
18031872
<li><a href="#dom-focusnavigationevent-dir">attribute for FocusNavigationEvent</a><span>, in §3</span>
18041873
<li><a href="#dom-focusnavigationeventinit-dir">dict-member for FocusNavigationEventInit</a><span>, in §3</span>
18051874
</ul>
1875+
<li><a href="#distance">distance</a><span>, in §4.2</span>
18061876
<li><a href="#dom-navigationdirection-down">down</a><span>, in §3</span>
18071877
<li><a href="#dom-navigationdirection-down">"down"</a><span>, in §3</span>
18081878
<li><a href="#dom-element-findfocusable">findFocusable(arg)</a><span>, in §3</span>
@@ -1844,6 +1914,11 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
18441914
<li><a href="https://dom.spec.whatwg.org/#element">Element</a>
18451915
<li><a href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a>
18461916
</ul>
1917+
<li>
1918+
<a data-link-type="biblio">[HTML]</a> defines the following terms:
1919+
<ul>
1920+
<li><a href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation">sequential focus navigation</a>
1921+
</ul>
18471922
<li>
18481923
<a data-link-type="biblio">[uievents]</a> defines the following terms:
18491924
<ul>
@@ -1863,6 +1938,8 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N
18631938
<dd>Tab Atkins Jr.; Elika Etemad. <a href="https://www.w3.org/TR/css-values-3/">CSS Values and Units Module Level 3</a>. 29 September 2016. CR. URL: <a href="https://www.w3.org/TR/css-values-3/">https://www.w3.org/TR/css-values-3/</a>
18641939
<dt id="biblio-dom">[DOM]
18651940
<dd>Anne van Kesteren. <a href="https://dom.spec.whatwg.org/">DOM Standard</a>. Living Standard. URL: <a href="https://dom.spec.whatwg.org/">https://dom.spec.whatwg.org/</a>
1941+
<dt id="biblio-html">[HTML]
1942+
<dd>Anne van Kesteren; et al. <a href="https://html.spec.whatwg.org/multipage/">HTML Standard</a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a>
18661943
<dt id="biblio-rfc2119">[RFC2119]
18671944
<dd>S. Bradner. <a href="https://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>. March 1997. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc2119">https://tools.ietf.org/html/rfc2119</a>
18681945
<dt id="biblio-uievents">[UIEVENTS]
@@ -2039,6 +2116,8 @@ <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content
20392116
Controlling Spatial Navigation in JavaScript</a>
20402117
<li><a href="#ref-for-focus-navigation-heuristic①">4.1.
20412118
Event Sequence</a>
2119+
<li><a href="#ref-for-focus-navigation-heuristic②">4.2.
2120+
Focus Navigation Heuristic</a>
20422121
</ul>
20432122
</aside>
20442123
<script>/* script-dfn-panel */

0 commit comments

Comments
 (0)