w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.46k stars 657 forks source link

[css-scroll-anchoring-1] the candidate examination algorithm visits absolutely positioned elements twice #3465

Open dbaron opened 5 years ago

dbaron commented 5 years ago

The candidate examination algorithm visits absolutely positioned elements twice. First it does:

  1. For each DOM child C of N, perform the candidate examination algorithm for C in S, and terminate if it selects an anchor node.

This step, at some depth of traversal, will reach absolutely positioned elements, unless overflow-anchor on an intermediate element is used to block that traversal.

Then it says:

  1. For each absolutely-positioned element A whose containing block is N, but whose DOM parent is not N, perform the candidate examination algorithm for A in S, and terminate if it selects an anchor node.

This will find the same absolutely positioned elements already visited in (1). So the only case where it seems like it could return something is if there's an overflow-anchor: none somewhere on the DOM path between the containing block and the absolutely positioned element.

This seems like it's probably unintentional, and perhaps that absolutely positioned elements were intended to be excluded from the regular DOM traversal -- maybe in all cases, or maybe only if the containing block is different from the parent. (The results would be different, so it seems less weird to exclude them in all cases!)

It's also not clear to me why absolute positioning gets a different treatment from floating (where overflow-anchor: none on an intermediate inline, based on the spec, does apparently have an effect, although I didn't test in Chrome).

/cc @eqrion who is implementing this in Gecko.

eqrion commented 5 years ago

cc @dbaron @theres-waldo @skobes