Skip to content

Commit

Permalink
Handle delegates focus in the focusing steps
Browse files Browse the repository at this point in the history
This is the last piece of #2013. Incoporating support for
delegates-focus shadow roots into the focusing steps impact the behavior
of programmatic and click focus. (Sequential focus navigation was
handled in d19d963.)

Tests: web-platform-tests/wpt#18035
  • Loading branch information
rakina authored and zcorpan committed Nov 6, 2019
1 parent 2af48f3 commit b2e07d1
Showing 1 changed file with 66 additions and 28 deletions.
94 changes: 66 additions & 28 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3918,6 +3918,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
algorithms for <code>DOMMatrix2DInit</code> or <code>DOMMatrixInit</code></li>
</ul>

<p>The following terms are defined in the <cite>CSS Scoping</cite>: <ref spec=CSSSCOPING></p>

<ul class="brief">
<li><dfn data-x-href="https://drafts.csswg.org/css-scoping/#flat-tree">flat tree</dfn></li>
</ul>

</dd>

<dt>Intersection Observer</dt>
Expand Down Expand Up @@ -73514,16 +73520,6 @@ END:VCARD</pre>
<p>One <span>focusable area</span> in each <code>Document</code> is designated the <dfn>focused
area of the document</dfn>. Which control is so designated changes over time, based on algorithms
in this specification.</p>
<!-- TODO(kochi): update "in a document tree" for shadow trees -->

<p><span data-x="focusable area">Focusable areas</span> in a <code>Document</code>
are ordered relative to the <span>tree order</span> of their <span data-x="DOM anchor">DOM
anchors</span>. <span data-x="focusable area">Focusable areas</span> with the same <span>DOM
anchor</span> in a <code>Document</code> are ordered relative to their <span data-x="CSS box">CSS
boxes</span>' relative positions in a pre-order, depth-first traversal of the box tree. <ref
spec=CSS></p>

<hr>

<p>The <dfn>currently focused area of a top-level browsing context</dfn> at any particular time is
the <span>focusable area</span> returned by this algorithm:</p>
Expand Down Expand Up @@ -73644,9 +73640,13 @@ END:VCARD</pre>
focusable via user interaction, only via programmatic APIs.</p>
</div>

<p>If the <span>activation behavior</span> of a <span>click focusable</span> <span>focusable
area</span> is triggered, the user agent must run the <span>focusing steps</span> on the
<span>focusable area</span>'s <span>DOM anchor</span>.</p>
<p>When a user <a href="#activation">activates</a> a <span>click focusable</span> <span>focusable
area</span>, the user agent must run the <span>focusing steps</span> on the <span>focusable
area</span> with <var>focus trigger</var> set to "<code data-x="">click</code>".</p>

<p class="note">Note that focusing is not an <span>activation behavior</span>, i.e. calling the
<code data-x="dom-click">click()</code> method on an element or dispatching a synthetic <code
data-x="event-click">click</code> event on it won't cause the element to get focused.</p>

<hr>

Expand Down Expand Up @@ -73958,8 +73958,8 @@ END:VCARD</pre>

<p>The <dfn data-export="">focusing steps</dfn> for an object <var>new focus target</var> that is
either a <span>focusable area</span>, or an element that is not a <span>focusable area</span>, or
a <span>browsing context</span>, are as follows. They can optionally be run with a <i>fallback
target</i>.</p>
a <span>browsing context</span>, are as follows. They can optionally be run with a <var>fallback
target</var> and a string <var>focus trigger</var>.</p>

<ol>

Expand All @@ -73978,8 +73978,8 @@ END:VCARD</pre>

<dd>

<p>Let <var>new focus target</var> be the shape corresponding to the first
<code>img</code> element in <span>tree order</span> that uses the image map to which the <code>area</code>
<p>Set <var>new focus target</var> to the shape corresponding to the first <code>img</code>
element in <span>tree order</span> that uses the image map to which the <code>area</code>
element belongs.</p>

</dd>
Expand All @@ -73990,8 +73990,8 @@ END:VCARD</pre>

<dd>

<p>Let <var>new focus target</var> be the element's first scrollable region,
according to a pre-order, depth-first traversal of the box tree. <ref spec=CSS></p>
<p>Set <var>new focus target</var> to the element's first scrollable region, according to a
pre-order, depth-first traversal of the <span>flat tree</span>. <ref spec=CSSSCOPING></p>

</dd>

Expand All @@ -74010,7 +74010,7 @@ END:VCARD</pre>

<dd>

<p>Let <var>new focus target</var> be the <span>browsing context</span>'s
<p>Set <var>new focus target</var> to the <span>browsing context</span>'s
<span>active document</span>.</p>

</dd>
Expand All @@ -74021,31 +74021,66 @@ END:VCARD</pre>

<dd>

<p>Let <var>new focus target</var> be the <span>browsing context container</span>'s <span>nested browsing context</span>'s
<span>active document</span>.</p>
<p>Set <var>new focus target</var> to the <span>browsing context container</span>'s
<span>nested browsing context</span>'s <span>active document</span>.</p>

</dd>


<dt>Otherwise</dt>
<dt>If <var>new focus target</var> is a <span>shadow host</span> whose <span
data-x="concept-element-shadow-root">shadow root</span>'s <span>delegates focus</span> is
true</dt>

<dd>

<p>If no <i>fallback target</i> was specified, abort the <span>focusing steps</span>.</p>
<p>If <var>focus trigger</var> is "<code data-x="">click</code>", then let <var>possible focus
delegates</var> be the list of all <span>click focusable</span> <span data-x="focusable
area">focusable areas</span> whose <span>DOM anchor</span> is a descendant of <var>new focus
target</var> in the <span>flat tree</span>.</p>

<p>Otherwise, let <var>new focus target</var> be the <i>fallback target</i>.</p>
<p>Otherwise, let <var>possible focus delegates</var> be the list of all <span
data-x="focusable area">focusable areas</span> whose <span>DOM anchor</span> is a descendant
of <var>new focus target</var> in the <span>flat tree</span>.</p>

<p>Set <var>new focus target</var> to the first <span>focusable area</span> in <span>tree
order</span> of their <span data-x="DOM anchor">DOM anchors</span> in <var>possible focus
delegates</var>, or null if <var>possible focus delegates</var> is empty.</p>

<p class="note">For <span data-x="sequentially focusable">sequential focusability</span>, the
handling of <span data-x="shadow host">shadow hosts</span> and <span>delegates focus</span> is
done when constructing the <span>sequential focus navigation order</span>. That is, the
<span>focusing steps</span> will never be called on such <span data-x="shadow host">shadow
hosts</span> as part of sequential focus navigation.</p>

</dd>

<dt>Otherwise</dt>

<dd>
<p>Set <var>new focus target</var> to null.</p>
</dd>

</dl>

</li>

<li>

<p>If <var>new focus target</var> is null, then:</p>

<ol>
<li><p>If no <var>fallback target</var> was specified, then return.</p></li>

<li><p>Otherwise, set <var>new focus target</var> to the <var>fallback
target</var>.</p></li>
</ol>

</li>

<li>

<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2818 -->
<p>If <var>new focus target</var> is a <span>browsing context container</span> with
non-null <span>nested browsing context</span>, then let <var>new focus target</var> be the
non-null <span>nested browsing context</span>, then set <var>new focus target</var> to the
<span>nested browsing context</span>'s <span>active document</span>, and redo this step.</p>

</li>
Expand Down Expand Up @@ -84713,7 +84748,7 @@ new PaymentRequest(&hellip;); // Allowed to use
set to "nearest". <ref spec=CSSOMVIEW></p></li>

<li><p>Run the <span>focusing steps</span> for <var>target</var>, with the
<code>Document</code>'s <span>viewport</span> as the <i>fallback target</i>.</p></li>
<code>Document</code>'s <span>viewport</span> as the <var>fallback target</var>.</p></li>

<li><p>Move the <span>sequential focus navigation starting point</span> to
<var>target</var>.</p></li>
Expand Down Expand Up @@ -123510,6 +123545,9 @@ INSERT INTERFACES HERE
<dt id="refsCSSRUBY">[CSSRUBY]</dt>
<dd><cite><a href="https://drafts.csswg.org/css-ruby/">CSS3 Ruby Module</a></cite>, R. Ishida. W3C.</dd>

<dt id="refsCSSSCOPING">[CSSSCOPING]</dt>
<dd><cite><a href="https://drafts.csswg.org/css-scoping/">CSS Scoping Module</a></cite>, T. Atkins. W3C.</dd>

<dt id="refsCSSSIZING">[CSSSIZING]</dt>
<dd><cite><a href="https://drafts.csswg.org/css-sizing/">CSS Intrinsic &amp; Extrinsic Sizing Module</a></cite>, T. Atkins, E. Etemad. W3C.</dd>

Expand Down

0 comments on commit b2e07d1

Please sign in to comment.