You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css-nav-1/Overview.bs
+97-35Lines changed: 97 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -1041,11 +1041,11 @@ Issue(w3c/csswg-drafts#2324): CSS should have a term for “border box taking in
1041
1041
1042
1042
To <dfn lt="find focusable areas | finding focusable areas">find focusable areas</dfn> within a containing element <var>C</var>,
1043
1043
with an optional <var>visibleOnly</var> argument that defaults to <code>true</code>,
1044
-
follow the following steps:
1044
+
run the following steps:
1045
1045
1046
1046
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>.
1047
1047
In the case of [=boxes=] with several [=box fragments=], each [=box fragment=] is considered separately.
1048
-
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.
1048
+
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.
1049
1049
1050
1050
Note: This is a "SHOULD" in order to mirror the exclusion of elements with negative tabindex
1051
1051
from the <a>sequential focus navigation order</a> as defined in [[HTML#the-tabindex-attribute]].
@@ -1087,7 +1087,7 @@ To <dfn lt="select the best candidate | selecting the best candidate">select the
1087
1087
within a <a spec=infra for="/">set</a> of <var>candidates</var>
1088
1088
in a direction <var>dir</var>,
1089
1089
starting from <var>searchOrigin</var>,
1090
-
follow the following steps:
1090
+
run the following steps:
1091
1091
1092
1092
1. If <var>candidates</var> is <a spec=infra for=set>empty</a>, return <code>null</code>
1093
1093
2. If <var>candidates</var> contains a single item, return that item
@@ -1098,19 +1098,19 @@ follow the following steps:
1098
1098
4. Let <var>insiders</var> be the subset of <var>candidates</var> items
1099
1099
whose [=DOM anchor=] are descendants of <var>searchOrigin</var>
1100
1100
and whose <a>boundary box</a>'s
1101
-
* top edge is below the top edge of <var>insideArea</var> if <var>D</var> is <code>down</code>
1102
-
* bottom edge is above the bottom edge of <var>insideArea</var> if <var>D</var> is <code>up</code>
1103
-
* right edge is left of the right edge of <var>insideArea</var> if <var>D</var> is <code>left</code>
1104
-
* left edge is right of the left edge of <var>insideArea</var> if <var>D</var> is <code>right</code>
1101
+
* top edge is below the top edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/down}}
1102
+
* bottom edge is above the bottom edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/up}}
1103
+
* right edge is left of the right edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/left}}
1104
+
* left edge is right of the left edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/right}}
1105
1105
1106
1106
Note: this sub-setting is necessary to avoid going in the opposite direction than the one requested.
1107
1107
5.
1108
1108
* If <var>insiders</var> is non empty
1109
1109
1. Let <var>closest subset</var> be the subset of <var>insiders</var> whose <a>boundary box</a>'s
1110
-
* top edge is closest to the top edge of <var>insideArea</var> if <var>D</var> is <code>down</code>
1111
-
* bottom edge is closest to the bottom edge of <var>insideArea</var> if <var>D</var> is <code>up</code>
1112
-
* right edge is closest to the right edge of <var>insideArea</var> if <var>D</var> is <code>left</code>
1113
-
* left edge is closest to the left edge of <var>insideArea</var> if <var>D</var> is <code>right</code>
1110
+
* top edge is closest to the top edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/down}}
1111
+
* bottom edge is closest to the bottom edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/up}}
1112
+
* right edge is closest to the right edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/left}}
1113
+
* left edge is closest to the left edge of <var>insideArea</var> if <var>dir</var> is {{SpatialNavigationDirection/right}}
1114
1114
2. If <var>closest subset</var> contains a single item,
1115
1115
return that item,
1116
1116
else return the first item of <var>closest subset</var> in document order,
@@ -1123,38 +1123,100 @@ follow the following steps:
1123
1123
1. Set <var>candidates</var> be the subset of its items
1124
1124
whose <a>boundary box</a>'s geometric center is within the closed half plane
1125
1125
whose boundary goes through the geometric center of the <var>searchOrigin</var>
1126
-
and is perpendicular to <var>D</var>.
1126
+
and is perpendicular to <var>dir</var>.
1127
1127
2. For each <var>candidate</var> in <var>candidates</var>,
1128
-
find the points <var>P1</var> inside the <a>boundary box</a> of <var>searchOrigin</var>
1129
-
and <var>P2</var> inside the <a>boundary box</a> of <var>candidate</var>
1130
-
that minimize the <var>distance</var> between these two points,
<dd>The euclidian distance between <var>P1</var> and <var>P2</var>
1156
+
1157
+
<dt><var>displacement</var>
1158
+
<dd>The degree of displacement in <var>dir</var> between <var>searchOrigin</var> and <var>candidate</var>
1159
+
<dd>Defined as <pre class="prod">(absolute distance on the axis orthogonal to <var>dir</var> + <var>orthogonalBias</var>) * <var>orthogonalWeight</var></pre>
1160
+
1161
+
* <var>orthogonalBias</var>
1162
+
* If the <var>dir</var> is {{SpatialNavigationDirection/left}} or {{SpatialNavigationDirection/right}},
1163
+
height of <var>searchOrigin</var> / 2
1164
+
* Else if the <var>dir</var> is {{SpatialNavigationDirection/up}} or {{SpatialNavigationDirection/down}},
1165
+
width of <var>searchOrigin</var> / 2
1166
+
1167
+
* <var>orthogonalWeight</var>:
1168
+
* If the <var>dir</var> is {{SpatialNavigationDirection/left}} or {{SpatialNavigationDirection/right}}, 30
1169
+
* Else if the <var>dir</var> is {{SpatialNavigationDirection/up}} or {{SpatialNavigationDirection/down}}, 2
1170
+
1171
+
<dt><var>alignment</var>
1172
+
<dd>The degree of alignment in <var>dir</var> between <var>searchOrigin</var> and <var>candidate</var>
1173
+
<dd>Defined as <pre class="prod"><var>alignBias</var> * <var>alignWeight</var></pre>
1156
1174
1175
+
* <var>alignBias</var>
1157
1176
1177
+
* If the <var>dir</var> is {{SpatialNavigationDirection/left}} or {{SpatialNavigationDirection/right}},
1178
+
height of <var>intersectRect</var> / height of <var>candidate</var>
1179
+
* Else if the <var>dir</var> is {{SpatialNavigationDirection/up}} or {{SpatialNavigationDirection/down}},
1180
+
width of <var>intersectRect</var> / width of <var>candidate</var>
1181
+
1182
+
* <var>alignWeight</var> is 5
1183
+
1184
+
<dt><var>sqrt(Overlap)</var>
1185
+
<dd>The square root of an <a>overlapping area</a> between the <a>boundary boxes</a> of <var>searchOrigin</var> and <var>candidate</var>
1186
+
<dd>Let <var>overlapRect</var> be
1187
+
<var>intersectRect</var> if the <a>overlapping area</a> exists,
1188
+
and 0 otherwise.
1189
+
<dd>Defined as <pre class="prod">sqrt(height of <var>overlapRect</var> * width of <var>overlapRect</var>)</pre>
1190
+
</dl>
1191
+
1192
+
NOTE: The values of <var>alignWeight</var> and <var>orthogonalWeight</var> in the function are decided based on
1193
+
the collected <a href="https://wicg.github.io/spatial-navigation/tests/ux/list.html">UX test cases</a>.
1194
+
It aims to show the generally expected result in the real pages.
1195
+
Everyone is welcome to contribute to the test cases!
1196
+
1197
+
<div class='example'>
1198
+
This example shows how the <a>intersecting area</a>(<var>intersectRect</var>) is defined.
<figcaption>The <a>intersecting area</a> when the elements are aligned.</figcaption>
1212
+
</figure>
1213
+
1214
+
In the case above, the search origin element and the candidate element are aligned and the requested direction is {{SpatialNavigationDirection/right}}.
1215
+
The <a>intersecting area</a> is created with
1216
+
(1) The gap between two elements.
1217
+
(2) The parts of the edges from each element which are overlapped
1218
+
when the right edge of the search origin element and the left edge of the candidate are projected to each other.
0 commit comments