Skip to content

[css-scroll-anchoring-1] Add priority candidates for scroll anchor selection #5018 #5050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions css-scroll-anchoring-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ spec:css22;
text:width
type:dfn; text:line box
</pre>
<pre class="anchors">
spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/;
urlPrefix: interaction.html
type: dfn;
text:DOM anchor
text:focused area of the document
</pre>

<h2 id=intro>
Introduction</h2>
Expand Down Expand Up @@ -76,7 +83,8 @@ Anchor Node Selection</h3>

Each <a>scrolling box</a> aims to select an <a>anchor node</a>
that is deep in the DOM
and close to the block start edge of its <a>optimal viewing region</a>.
and either should be prioritized as an important DOM node or is close to the
block start edge of its <a>optimal viewing region</a>.

Note: If the user agent does not support the 'scroll-padding' property,
the optimal viewing region of the scrolling box is equivalent to its <a>content area</a>.
Expand All @@ -85,16 +93,40 @@ An anchor node can be any <a>box</a> except one for a non-<a>atomic inline</a>.
The anchor node is always a <a>descendant</a> of the <a>scrolling box</a>.
In some cases, a scrolling box may not select any anchor node.

An element |C| is a <dfn id="anchor-viable-candidate">viable candidate</dfn>
for becoming a scroll anchor for a scrolling box |S| if it meets all of the
following criteria:
* |C| is an element that is not a non-<a>atomic inline</a>.
* |C| is <a>partially visible</a> or <a>fully visible</a> in |S|
* |C| is a descendant of |S|
* |C| is not in an <a>excluded subtree</a>
* None of the ancestors of |C| up to |S| are in an <a>excluded subtree</a>

Some elements are considered to be <dfn
id="anchor-priority-candidates">priority candidates</dfn> for anchor selection:
1. The [=DOM anchor=] of the [=focused area of the document=].
2. An element containing the current active selected match of the
find-in-page user-agent algorithm. If the match spans multiple elements, then
consider only the first such element.

Note that if the <a>priority candidate</a> is a non-<a>atomic inline</a>
element, then instead consider its nearest ancestor element that is not a
non-atomic inline element as the priority candidate.

<div algorithm>
The <dfn id="anchoring-algorithm">anchor node selection algorithm</dfn>
for a scrolling box |S| is as follows:

1. If |S| is associated with an element
whose computed value of the 'overflow-anchor' property is ''overflow-anchor/none'',
then do not select an anchor node for |S|.
2. Otherwise, for each DOM child |N| of the element or document associated with |S|,
2. Otherwise, for each <a>priority candidate</a> |PC| in order specified,
check if |PC| is a <a>viable candidate</a> in |S|. If so, select it as an
anchor node and terminate.
3. Otherwise, for each DOM child |N| of the element or document associated with |S|,
perform the <a>candidate examination algorithm</a> for |N| in |S|,
and terminate if it selects an anchor node.

</div>

<div algorithm>
Expand Down