Skip to content

Commit 74f5d44

Browse files
author
Jihye Hong
committed
Add more detailed description about the intersecting area
1 parent c020908 commit 74f5d44

File tree

1 file changed

+60
-30
lines changed

1 file changed

+60
-30
lines changed

css-nav-1/Overview.bs

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,11 +1154,11 @@ Issue(w3c/csswg-drafts#2324): CSS should have a term for “border box taking in
11541154

11551155
To <dfn lt="find focusable areas | finding focusable areas">find focusable areas</dfn> within a containing element <var>C</var>,
11561156
with an optional <var>visibleOnly</var> argument that defaults to <code>true</code>,
1157-
follow the following steps:
1157+
run the following steps:
11581158

11591159
1. Let <var>focusables</var> be the <a spec=infra for="/">set</a> of all the <a>focusable areas</a> whose [=DOM anchor=] are descendants of <var>C</var>.
11601160
In the case of [=boxes=] with several [=box fragments=], each [=box fragment=] is considered separately.
1161-
2. The UA should <a spec=infra for=set>remove</a> from <var>focusables</var> items that have a [=DOM anchor=] whose <a element-attr spec=html><code>tabindex</code></a> attribute is set to a negative value.
1161+
2. The User Agent should <a spec=infra for=set>remove</a> from <var>focusables</var> items that have a [=DOM anchor=] whose <a element-attr spec=html><code>tabindex</code></a> attribute is set to a negative value.
11621162

11631163
Note: This is a "SHOULD" in order to mirror the exclusion of elements with negative tabindex
11641164
from the <a>sequential focus navigation order</a> as defined in [[HTML#the-tabindex-attribute]].
@@ -1200,7 +1200,7 @@ To <dfn lt="select the best candidate | selecting the best candidate">select the
12001200
within a <a spec=infra for="/">set</a> of <var>candidates</var>
12011201
in a direction <var>dir</var>,
12021202
starting from <var>searchOrigin</var>,
1203-
follow the following steps:
1203+
run the following steps:
12041204

12051205
1. If <var>candidates</var> is <a spec=infra for=set>empty</a>, return <code>null</code>
12061206
2. If <var>candidates</var> contains a single item, return that item
@@ -1211,19 +1211,19 @@ follow the following steps:
12111211
4. Let <var>insiders</var> be the subset of <var>candidates</var> items
12121212
whose [=DOM anchor=] are descendants of <var>searchOrigin</var>
12131213
and whose <a>boundary box</a>'s
1214-
* top edge is below the top edge of <var>insideArea</var> if <var>dir</var> is <code>down</code>
1215-
* bottom edge is above the bottom edge of <var>insideArea</var> if <var>dir</var> is <code>up</code>
1216-
* right edge is left of the right edge of <var>insideArea</var> if <var>dir</var> is <code>left</code>
1217-
* left edge is right of the left edge of <var>insideArea</var> if <var>dir</var> is <code>right</code>
1214+
* top edge is below the top edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/down}}
1215+
* bottom edge is above the bottom edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/up}}
1216+
* right edge is left of the right edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/left}}
1217+
* left edge is right of the left edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/right}}
12181218

12191219
Note: this sub-setting is necessary to avoid going in the opposite direction than the one requested.
12201220
5.
12211221
* If <var>insiders</var> is non empty
12221222
1. Let <var>closest subset</var> be the subset of <var>insiders</var> whose <a>boundary box</a>'s
1223-
* top edge is closest to the top edge of <var>insideArea</var> if <var>dir</var> is <code>down</code>
1224-
* bottom edge is closest to the bottom edge of <var>insideArea</var> if <var>dir</var> is <code>up</code>
1225-
* right edge is closest to the right edge of <var>insideArea</var> if <var>dir</var> is <code>left</code>
1226-
* left edge is closest to the left edge of <var>insideArea</var> if <var>dir</var> is <code>right</code>
1223+
* top edge is closest to the top edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/down}}
1224+
* bottom edge is closest to the bottom edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/up}}
1225+
* right edge is closest to the right edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/left}}
1226+
* left edge is closest to the left edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/right}}
12271227
2. If <var>closest subset</var> contains a single item,
12281228
return that item,
12291229
else return the first item of <var>closest subset</var> in document order,
@@ -1242,7 +1242,7 @@ follow the following steps:
12421242
of <var>searchOrigin</var> and P2 inside the boundary box of <var>candidate</var>.
12431243
2. Else if the <var>searchOrigin</var> is a point, then let the point <var>P1</var> be the <var>searchOrigin</var>
12441244
and find the point <var>P2</var> inside the <a>boundary box</a>.
1245-
3. Let <var>intersectRect</var> is intersected area between a candidate and the search origin.
1245+
3. Let <var>intersectRect</var> be an <dfn>intersecting area</dfn> between the search origin and a candidate.
12461246
4. Select the <var>P1</var> and <var>P2</var> that make the smallest <var>distance</var> between those two points by
12471247
<a>calculating the distance</a>.
12481248
5. Return the item of the <var>candidates</var> set that has the smallest <var>distance</var>.
@@ -1258,7 +1258,7 @@ follow the following steps:
12581258
To <dfn lt="calculating the distance | to calculate the distance">calculate the <var>distance</var></dfn>, the function is defined as below:
12591259

12601260
<pre class="prod">
1261-
<var>distance</var> = <var>euclidian</var> - <var>alignment</var> + <var>displacement</var> - <var>sqrt(Overlap)</var>
1261+
<var>distance</var> = <var>euclidian</var> + <var>displacement</var> - <var>alignment</var> - <var>sqrt(Overlap)</var>
12621262
</pre>
12631263

12641264
The meaning of each factor in the function is as follows:
@@ -1267,39 +1267,69 @@ The meaning of each factor in the function is as follows:
12671267
<dt><var>euclidian</var>
12681268
<dd>The euclidian distance between <var>P1</var> and <var>P2</var>
12691269

1270+
<dt><var>displacement</var>
1271+
<dd>The degree of displacement in <var>dir</var> between <var>searchOrigin</var> and <var>candidate</var>
1272+
<dd>Defined as <pre class="prod">(absolute distance on the axis orthogonal to <var>dir</var> + <var>orthogonalBias</var>) * <var>orthogonalWeight</var></pre>
1273+
1274+
* <var>orthogonalBias</var>
1275+
* If the <var>dir</var> is {{SpatialNavigationDirection/left}} or {{SpatialNavigationDirection/right}},
1276+
height of <var>searchOrigin</var> / 2
1277+
* Else if the <var>dir</var> is {{SpatialNavigationDirection/up}} or {{SpatialNavigationDirection/down}},
1278+
width of <var>searchOrigin</var> / 2
1279+
1280+
* <var>orthogonalWeight</var>:
1281+
* If the <var>dir</var> is {{SpatialNavigationDirection/left}} or {{SpatialNavigationDirection/right}}, 30
1282+
* Else if the <var>dir</var> is {{SpatialNavigationDirection/up}} or {{SpatialNavigationDirection/down}}, 2
1283+
12701284
<dt><var>alignment</var>
12711285
<dd>The degree of alignment in <var>dir</var> between <var>searchOrigin</var> and <var>candidate</var>
12721286
<dd>Defined as <pre class="prod"><var>alignBias</var> * <var>alignWeight</var></pre>
12731287

12741288
* <var>alignBias</var>
12751289

1276-
* If the <var>dir</var> is left or right, height of <var>intersectRect</var> / the height of <var>candidate</var>
1277-
* Else if the <var>dir</var> is up or down, width of <var>intersectRect</var> / the width of <var>candidate</var>
1290+
* If the <var>dir</var> is {{SpatialNavigationDirection/left}} or {{SpatialNavigationDirection/right}},
1291+
height of <var>intersectRect</var> / height of <var>candidate</var>
1292+
* Else if the <var>dir</var> is {{SpatialNavigationDirection/up}} or {{SpatialNavigationDirection/down}},
1293+
width of <var>intersectRect</var> / width of <var>candidate</var>
12781294

12791295
* <var>alignWeight</var> is 5
12801296

1281-
<dt><var>displacement</var>
1282-
<dd>The degree of displacement in <var>dir</var> between <var>searchOrigin</var> and <var>candidate</var>
1283-
<dd>Defined as <pre class="prod">(absolute distance on the axis orthogonal to <var>dir</var> + <var>orthogonalBias</var>) * <var>orthogonalWeight</var></pre>
1284-
1285-
* <var>orthogonalBias</var>
1286-
* If the <var>dir</var> is left or right, height of <var>searchOrigin</var> / 2
1287-
* Else if the <var>dir</var> is up or down, width of <var>searchOrigin</var> / 2
1288-
1289-
* <var>orthogonalWeight</var>:
1290-
* If the <var>dir</var> is left or right, 30
1291-
* Else if the <var>dir</var> is up or down, 2
1292-
12931297
<dt><var>sqrt(Overlap)</var>
1294-
<dd>The square root of the <var>intersectRect</var>(overlapped area) between the <a>boundary boxes</a> of <var>candidate</var> and <var>searchOrigin</var>
1295-
<dd>Defined as <pre class="prod">sqrt(height of <var>intersectRect</var> * width of <var>intersectRect</var>)</pre>
1298+
<dd>The square root of an <a>overlapping area</a> between the <a>boundary boxes</a> of <var>searchOrigin</var> and <var>candidate</var>
1299+
<dd>Let <var>overlapRect</var> be
1300+
<var>intersectRect</var> if the <a>overlapping area</a> exists,
1301+
and 0 otherwise.
1302+
<dd>Defined as <pre class="prod">sqrt(height of <var>overlapRect</var> * width of <var>overlapRect</var>)</pre>
12961303
</dl>
12971304

12981305
NOTE: The values of <var>alignWeight</var> and <var>orthogonalWeight</var> in the function are decided based on
12991306
the collected <a href="https://wicg.github.io/spatial-navigation/tests/ux/list.html">UX test cases</a>.
1300-
It aims to show the general expected result in the real pages.
1307+
It aims to show the generally expected result in the real pages.
13011308
Everyone is welcome to contribute to the test cases!
13021309

1310+
<div class='example'>
1311+
This example shows how the <a>intersecting area</a>(<var>intersectRect</var>) is defined.
1312+
1313+
<figure>
1314+
<img alt="" src="images/intersecting-area-1.png" style="height: 200px;"/>
1315+
<figcaption>The <a>intersecting area</a> when there is the <a>overlapping area</a>.</figcaption>
1316+
</figure>
1317+
1318+
The figure above is the simplest case to define the <a>intersecting area</a>.
1319+
The <dfn>overlapping area</dfn> is the geometric overlap region between the two elements.
1320+
In this case, the <a>intersecting area</a> is the same as the <a>overlapping area</a> without reference to the direction of the navigation.
1321+
1322+
<figure>
1323+
<img alt="" src="images/intersecting-area-2.png" style="height: 200px;"/>
1324+
<figcaption>The <a>intersecting area</a> when the elements are aligned.</figcaption>
1325+
</figure>
1326+
1327+
In the case above, the search origin element and the candidate element are aligned and the requested direction is {{SpatialNavigationDirection/right}}.
1328+
The <a>intersecting area</a> is created with
1329+
(1) The gap between two elements.
1330+
(2) The parts of the edges from each element which are overlapped
1331+
when the right edge of the search origin element and the left edge of the candidate are projected to each other.
1332+
</div>
13031333
</div>
13041334

13051335
<div class=cssapi>

0 commit comments

Comments
 (0)