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

Document rules should be limited to rendered links #246

Closed
jeremyroman opened this issue Feb 10, 2023 · 3 comments · Fixed by #289
Closed

Document rules should be limited to rendered links #246

jeremyroman opened this issue Feb 10, 2023 · 3 comments · Fixed by #289
Assignees
Labels
bug Something isn't working speculation-rules Related to speculation rules (syntax, semantics) other than the requested action.

Comments

@jeremyroman
Copy link
Collaborator

see also https://chromium-review.googlesource.com/c/chromium/src/+/4226934

Users aren't likely to click on such links, and for selectors, Chromium's style engine (and likely others) avoid computing style for unrendered subtrees (due to display:none or shadow roots). So we should probably only consider links which are being rendered.

cc @a4sriniv

@jeremyroman jeremyroman added bug Something isn't working speculation-rules Related to speculation rules (syntax, semantics) other than the requested action. labels Feb 10, 2023
@jeremyroman jeremyroman self-assigned this Feb 10, 2023
@jeremyroman
Copy link
Collaborator Author

@a4sriniv Is display locking (content-visibility) covered by the "rendered" concept, or does it need separate spec wording?

@a4sriniv
Copy link
Contributor

I think it needs separate spec wording. From https://drafts.csswg.org/css-contain/#content-visibility, "The content-visibility property controls whether or not an element renders its contents at all". But I don't think rendered here corresponds to "being rendered".

The rest of the content-visibility spec uses the concept of skipping an element's contents. In particular it says: "The user agent should additionally avoid as much layout/rendering work as possible for skipped contents", and also "If rendering work is done at some point, the user-agent should retain the previously computed layout state if possible, to allow the skipped contents to be displayed quickly at a later moment." The wording seems to indicate that this is a different state from explicitly not being rendered, and some rendering work may be done even if the contents aren't painted on screen.

Right now, the document rules implementation only omits links in the contents of a display-locked element if their style is not up-to-date, which isn't always the case for skipped contents (wording from spec, "to a large extent do not update their styles at all unless explicitly requested by script"). But we could update the implementation to just omit links inside skipped contents all the time, and the behaviour could then be described as: "document rules do not apply to links that are flat-tree descendants of elements with skipped contents".

@jeremyroman
Copy link
Collaborator Author

I would prefer that this work in a way that will apply to other implementations if possible, rather than being contingent on when Blink (or another particular engine) calculates style. While we could say it may not detect "skipped" links, it seems more consistent and predictable to specify that it always ignores them -- or alternatively, specify what the conditions actually are.

jeremyroman added a commit to jeremyroman/nav-speculation that referenced this issue Nov 23, 2023
… contents

It's hard for the user to interact with these links, and the author may
not even intend them to be part of the document's palpable content.

In at least Chromium (and likely other implementations), these are also
elements where the author is trying to skip work related to selector
matching etc, which makes selector_matches applying to them particularly
problematic. Better to ignore them altogether.

Fixes WICG#246.
jeremyroman added a commit that referenced this issue Nov 23, 2023
… contents

It's hard for the user to interact with these links, and the author may
not even intend them to be part of the document's palpable content.

In at least Chromium (and likely other implementations), these are also
elements where the author is trying to skip work related to selector
matching etc, which makes selector_matches applying to them particularly
problematic. Better to ignore them altogether.

Fixes #246.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working speculation-rules Related to speculation rules (syntax, semantics) other than the requested action.
Projects
None yet
2 participants