Skip to content

[css-contain-2] WIP: Stop monkey-patching the HTML spec. #12105

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

emilio
Copy link
Collaborator

@emilio emilio commented Apr 21, 2025

This exports an "update content relevancy for a document" algorithm that HTML can call at the right time.

@emilio emilio requested review from noamr and vmpstr April 21, 2025 11:38
2. Set <var>element</var>'s [=currently relevant to the user=] flag to true.
1. If <var>isFirstIteration</var> is false, then [=continue=].
1. If <var>element</var> is [=relevant to the user=], then:
1. If <var>element</var>'s [=currently relevant to the user=] flag is false, set <var>changed</var> to true.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition seems to be the same as the second condition above

If element is not [=currently relevant to the user=] and element is [=relevant to the user=], then

in fact I don't think it would hit since we update currently relevant to the user on line 2009. Or am I missing a subtlety here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this branch is dead effectively, but just because of the mistake you pointed out above.

1. If <var>element</var> is not [=currently relevant to the user=] and <var>element</var> is [=relevant to the user=], then:
2. Set <var>changed</var> to true.
2. Set <var>element</var>'s [=currently relevant to the user=] flag to true.
1. If <var>isFirstIteration</var> is false, then [=continue=].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the comment below, it's unclear to me the role isFirstIteration is playing here. changed is set in either case

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important bit is that if isFirstIteration is false, then non-initial determination is not supposed to happen (this is what implements the semantics you were talking about in your other comments). I think I just botched the condition in line 2007 (it's supposed to deal only with the initial proximity determination).

I'll fix, thanks for the review.

@@ -2308,14 +2339,7 @@ Restrictions and Clarifications {#cv-notes}
</wpt>

3. If an element starts or stops [=skipped contents|skipping its contents=],
this change happens
after the requestAnimationFrame callbacks
of the frame that renders the effects of the change
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's a bit of a subtlety here. What this is saying is that if we have frames 1 and 2 (separate update the rendering steps), and we determine that an element is relevant in step 1, then the effect of that relevance (ie it allows rendering, doesn't have strict containment etc) happen on frame 2. The difference is that if you try and observe the size of the element between rAFs in a timeout, then between frame 1 and 2 it should act as if it's still not relevant wrt size containment. See the note in this spec below which tries to explain that.

I don't mind if we change this behavior, but we need a larger discussion for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what the intention of the currently relevant to the user flag is (maybe I botched the language).

"currently relevant to the user" is meant to be the thing that has effect on the rendering. But you're right I might have messed up my prose ;)

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

Successfully merging this pull request may close these issues.

2 participants