-
Notifications
You must be signed in to change notification settings - Fork 715
[css-contain][css-sizing] content-visibility: auto
kinda broken by not using last remembered size with contain: size
#7807
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
Comments
I like either one of your proposals to have a better experience in this particular case. I'm slightly leaning towards the latter proposal to update the last remembered size when we're not skipping contents. That does tie the features even closer together, but since contain-intrinsic-size auto already only has an effect on content-visibility auto elements, I don't think that's a problem. |
A possible concern with the latter proposal is that at the time that the browser needs to decide whether to observe the element with a ResizeObserver, it may not be known yet whether the element skips its contents (in case of |
Typically we deliver resize observations after we have decided whether the element skips its contents. Funny enough I have a Blink patch that I'm working on for an unrelated reason that ensures this https://chromium-review.googlesource.com/c/chromium/src/+/3926103. I don't think the content-visibility spec says either way when we should decide that the element skips the contents, other than when it should synchronously do so and when it should be asynchronous This could cause an element to be observed briefly but it shouldn't get to the point of actually dispatching the callback since it would be unregistered in the subsequent iteration when we determine the element is not locked. Also you're right that even if we can't guarantee that, then we can always have a callback check this, although I'd prefer to avoid it. Did you have a case in mind where we wouldn't know at style time (or whenever we register for resize observation) whether or not the element skips its contents? |
whatwg/html#8277 seems relevant.
In Gecko the code for observing or unobserving the size of |
The way this should work is that when a content-visibility: auto lock is first created, we assume (in Blink) that it is skipping contents. It doesn't really matter what we assume at that time tbh, because the spec says
This means that whether or not we register for ResizeObservation at this point can only cause some churn, but no signals yet. Specifically in Blink, after the patch that I referenced above, we wait until style & layout is done, then determine the true state of the content-visibility. If our initial assumption was wrong, i.e. we should not be skipping contents, then we change the state and synchronously rerun style & layout. This would then unregister from resize observation. All this happens before we issue resize observer callbacks. I think this is what you mean by this can cause extra work, which I think is ok. In the non-initial determination case, the spec says
With a non-normative explanation:
This means that if we, for example, registered for the resize observation and later determine that the state should be skipping the contents, that state change doesn't take effect until the next frame so the resize observation should be correct, and we will unregister from the observation on the next frame. So all in all, using "skips its content" as a condition to whether to do resize observations seems fine to me |
Yes, thinking better about it I guess it's fine, since with the current spec when an element stops skipping the contents then it can lose size containment so it may need to be observed to record its size anyways. So it shouldn't be adding complexity, it's just that I didn't implement this part since |
The CSS Working Group just discussed
The full IRC log of that discussion<astearns> topic: [css-contain][css-sizing] content-visibility: auto kinda broken by not using last remembered size with contain: size<astearns> github: https://github.com//issues/7807 <dandclark> oriol: content visibility: author, elements either enter screen or get out of the screren, can loose size containment, which chagnes size <dandclark> oriol: Problem if you have scrollbar <dandclark> oriol: Changing size of elements can change scrollbar thumb size. Added ???-auto. Stabilizeds content-visibility: auto <dandclark> oriol: ...is triggering non-stable behaior. Have example in issue. <describes example in the issue>. Basically as elements gets in or out of the screen, is switching between 100-115 pixels. Getting instabilitty when shouold be stable. <dandclark> oriol: So 2 possible solutions. 1st is changing requirement for using last remembered size. Now checking element is skipping contents. Instead check content visibility but still check size containment. <dandclark> oriol: If content-visibility: auto ??? would still be able to use last remembered size. 2nd possibility is changing requirement for using last remembered size. <dandclark> oriol: ???? So if the element is skipping contents, use last rememberd size. If not skipping contents, update last remembered size. <dandclark> oriol: Vlad likes both but leans towards second. <dandclark> oriol: I don't have strong opinion between the 2. <dandclark> oriol: Anyone else have 3rd possibility to propose? <dandclark> florian: I agree 2nd is the better one. But thinking longer may have different opinion. <dandclark> astearns: proposed resolution: take second solution for this case. Update last remembered size if element doesn't skip its contents. <dandclark> RESOLVED: Take second solution for this case. Update the last remembered size if element doesn't skip its contents. |
WPT: |
#5668 added
contain-intrinsic-size: auto
, whose purpose was addressing this problem:contain-intrinsic-size: auto
remembers the non-contained size, bringing stability.Then #6308 restricted using the last remembered size to when the element skips its contents, so basic
contain: size
doesn't use the last remembered size. The reasoning was that the last remembered size can be out of date, so it can be bad to use it for elements which are visible in the screen.So main cases have stability:
content-visibility: auto
will remember its non-contained size when visible, then if it goes off the screen it will skip its contents and get containment, using that last remembered size. If it comes back into the screen, it will lose containment and its size will be updated, but in common cases this will be the same as the last remembered size.contain: size
never uses the last remembered size, so it keeps a consistent size regardless of whether it goes off or into the screen.But imagine this corner case:
contain-intrinsic-size: auto 100px; content-visibility: auto
contain: size
. It's still not skipping its contents, so it's resized to 100px.So the behavior is not stable at all! Here you have a testcase, try scrolling from the top to the bottom and viceversa using the mouse wheel. The scrollbar thumb behaves strangely.
It's an edge case since mixing
content-visibility: auto
andcontain: size
is maybe a weird combination, andcontain: size
needs to be delayed in order to have a last remembered size. But should we try to improve it? Some ideas:content-visibility
is notvisible
. Size containment will still be needed of course, so the basic case with justcontent-visibility: auto
will not be affected.CC @vmpstr, @hamishwillee
The text was updated successfully, but these errors were encountered: