[css-sizing-4][css-contain-2] Revisiting auto-sizing when size-containment applies · Issue #5668 · w3c/csswg-drafts · GitHub
Skip to content

[css-sizing-4][css-contain-2] Revisiting auto-sizing when size-containment applies #5668

Closed
@vmpstr

Description

The content-visibility: auto value causes the user agent to apply size-containment under certain conditions (generally, when content is outside of the viewport)

There is also another property that was added, contain-intrinsic-size, which helps with adoption of content-visibility: auto. It allows the developer to specify a "placeholder" size when size-containment is present.

One undesired effect of content-visibility: auto is that the scrollbar thumb tends to jump around when content enters and exits the visibility region. This is due to the fact that we keep adding and removing size containment in order for us to optimize rendering of skipped content. The contain-intrinsic-size property helps, but the size still keeps changing between the "real" intrinsic size and contain-intrinsic-size placeholder. The two sizes are frequently different.

My proposal is that we consider adding another value for contain-intrinsic-size, which would use known intrinsic size at the time size containment was last added, with a fallback value if size containment was present before the initial layout of the contents. It would basically freeze the intrinsic size when containment is added and use that.

The syntax would be something like the following:
contain-intrinsic-size: auto 0 auto 100px
which would mean:

  • If size containment was present before the initial layout of the contents, then this is the same as contain-intrinsic-size: 0 100px
  • If size containment was added after the initial layout of contents, then this is the same as the intrinsic size of contents at the time that size containment was last added

For context, this is similar to a previous proposal, which was rejected: #1043.
I think this proposal is sufficiently different in that we already have the "use this (intrinsic) size when size containment is present" property. The addition is just to prefer using the real intrinsic size if it is available at the time size containment applies.

One con of the approach is that the timing of when to measure intrinsic size isn't clear. When size containment applies, we should read off the last computed intrinsic size. However, this value could be different depending on when the UA decides to update the intrinsic size. So this may cause some observable implementation differences.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions