Skip to content

Commit 16a9725

Browse files
eqriontabatkins
andauthored
[css-scroll-anchoring-1] Add more details to anchor node selection (#3476)
* [css-scroll-anchoring-1] Fix link-defaults for content-area and css2 properties * [css-scroll-anchoring-1] Make `position: sticky` an excluded subtree `position: sticky` nodes aren't suitable anchor candidates as they may become stuck in the future, which causes them to behave similarly to `position: fixed`. * [css-scroll-anchoring-1] Add condition to not select scroll anchor when not scrolled from origin * [css-scroll-anchoring-1] Move and expand section on anchor node invalidation This commit moves the existing paragraph about anchor node invalidation into a subsection, and adds precise conditions upon when an anchor node is considered invalidated. * Apply suggestion from @tabatkins --------- Co-authored-by: Tab Atkins Jr. <jackalmage@gmail.com>
1 parent ba5946a commit 16a9725

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

css-scroll-anchoring-1/Overview.bs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Abstract: This spec also proposes an API for web developers to opt-out of this b
2121

2222
<pre class=link-defaults>
2323
spec:css-box; type:dfn; text:content area
24+
spec:cssom-view-1; type:dfn; text:scrolling area
2425
spec:css2;
2526
type:dfn; text:line box
2627
spec:css-sizing-3;
@@ -139,17 +140,19 @@ non-atomic inline element as the priority candidate.
139140
The <dfn id="anchoring-algorithm">anchor node selection algorithm</dfn>
140141
for a scrolling box |S| is as follows:
141142

142-
1. If |S| is associated with an element
143+
1. If |S| is generated by an element
143144
whose computed value of the 'overflow-anchor' property is ''overflow-anchor/none'',
144145
then do not select an anchor node for |S|.
145-
2. Otherwise, for each <a>priority candidate</a> |PC| in order specified,
146+
2. If |S| is not scrolled away from the origin of its <a>scrolling area</a> in its
147+
<a>block flow direction</a>, then do not select an anchor node for |S|.
148+
3. Otherwise, for each <a>priority candidate</a> |PC| in order specified,
146149
check if |PC| is a <a>viable candidate</a> in |S|.
147150
If so, perform the <a>candidate examination algorithm</a> for |PC| in |S| and terminate.
148151

149152
Note: Since the priority candidate itself is checked to be viable, the <a>candidate examination algorithm</a>
150153
is guaranteed to select at least the candidate node itself.
151154

152-
3. Otherwise, for each DOM child |N| of the element or document associated with |S|,
155+
4. Otherwise, for each DOM child |N| of the element or document associated with |S|,
153156
perform the <a>candidate examination algorithm</a> for |N| in |S|,
154157
and terminate if it selects an anchor node.
155158

@@ -182,17 +185,13 @@ non-atomic inline element as the priority candidate.
182185
content to shift without triggering any scroll anchoring adjustment.
183186
</div>
184187

185-
Conceptually, a new anchor node is computed for every scrolling box
186-
whenever the scroll position of any scrolling box changes.
187-
(As a performance optimization,
188-
the implementation may wait until the anchor node is needed before computing it.)
189-
190188
<div algorithm>
191189
A DOM node |N| is an <dfn>excluded subtree</dfn>
192190
if it is an element and any of the following conditions holds:
193191

194192
* |N|’s computed value of the 'display' property is ''display/none''.
195193
* |N|’s computed value of the 'position' property is ''position/fixed''.
194+
* |N|’s computed value of the 'position' property is ''position/sticky''.
196195
* |N|’s computed value of the 'position' property is ''position/absolute''
197196
and |N|’s <a>containing block</a> is an ancestor of the scrolling box.
198197
* |N|’s computed value of the 'overflow-anchor' property is ''overflow-anchor/none''.
@@ -218,6 +217,18 @@ the implementation may wait until the anchor node is needed before computing it.
218217
is |N|’s <a>scrollable overflow rectangle</a>.
219218
</div>
220219

220+
<h4 id='anchor-node-invalidation'>
221+
Invalidation</h3>
222+
223+
An anchor node is considered valid for a <a>scrolling box</a> until any of the following occur:
224+
* The scroll position of the <a>scrolling box</a> changes (excluding adjustments originating from scroll anchoring).
225+
* A <a>suppression trigger</a> suppresses a scroll adjustment.
226+
* The <a>anchor node</a> is removed from the DOM.
227+
228+
Once an anchor node has become invalid, the <a>anchor node selection algorithm</a> must be run again to compute the anchor node
229+
230+
As a performance optimization, implementations may wait until the <a>anchor node</a> is needed before computing it.
231+
221232
<h3 id="scroll-adjustment">
222233
Scroll Adjustment</h3>
223234

0 commit comments

Comments
 (0)