Skip to content
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

[css-scroll-anchoring-1] Anchor selection algorithm can lead to random results #4124

Open
bzbarsky opened this issue Jul 17, 2019 · 4 comments

Comments

@bzbarsky
Copy link

The way that https://drafts.csswg.org/css-scroll-anchoring/#anchoring-algorithm works is:

  1. Walk the child nodes of our scrollable thing.
  2. Stop when we find one that meets certain criteria.

The thing is, the algorithm doesn't say what order the child nodes are walked in. As far as I can tell, you can walk them forwards, backwards, or in any random order, and those would all be spec-compliant.

Note that just walking in DOM order from start to end may not be the right thing either; e.g. if the parent is a grid the earlier DOM kids may not be the thing you want to anchor at because they are further from the block start edge than later kids are.

@emilio @skobes

@emilio
Copy link
Collaborator

emilio commented Jul 17, 2019

Yeah, in practice #3480 was also about this, since DOM order doesn't include any shadow things. And in practice both implementations walk the layout tree. Yay?

@bzbarsky
Copy link
Author

Walking the layout tree actually makes sense, at least... ;) Now if only it were defined somewhere.

@zcorpan
Copy link
Member

zcorpan commented May 24, 2020

Is defining this in terms of the flat tree what we want? Or is layout tree what is really needed? Is it fully documented somewhere how these trees differ?

@emilio
Copy link
Collaborator

emilio commented May 24, 2020

Yes, the flat tree includes display: contents elements for example, which don't appear in the layout tree. The layout tree also contains all sorts of anonymous boxes and such, though those are excluded from the candidate examination algorithm in implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants