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

Add CSS containment features #1126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

foolip
Copy link
Collaborator

@foolip foolip commented May 22, 2024

No description provided.

@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label May 22, 2024
@foolip
Copy link
Collaborator Author

foolip commented May 22, 2024

The situation seems to be this:

  • Size, layout and paint containment shipped together in all browsers
  • Style containment came later in Firefox. It didn't work with quotes in Chrome initially, and still doesn't in Safari.
  • Inline-size containment is a later addition in all browsers

https://caniuse.com/css-containment seems to cover initial support for the contain property, which means size/layout/paint containment.

The way I've split it in this PR is like the above bullet points. Another way of splitting it would be to have the 5 types of containment as individual features, and later do a composite feature for them.

I need some expert feedback to decide on how to best represent this to web developers. @vmpstr how do you think this is best structured so that web developer can understand it?

@foolip foolip mentioned this pull request May 22, 2024
32 tasks
@vmpstr
Copy link

vmpstr commented May 22, 2024

FWIW, I think style containment was marked as at-risk for a while, which is why it came later.

I have a slight preference for splitting all of the features separately. But if that's too verbose, then the structure you have seems fine: we have a "base initial set", which is size layout and paint, and then we have individual things that were added later

Copy link
Collaborator

@ddbeck ddbeck left a comment

Choose a reason for hiding this comment

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

I had a go at describing these features.

features/contain.yml Outdated Show resolved Hide resolved
@@ -0,0 +1,6 @@
name: Style containment
description: "The `contain: style` CSS declaration TODO."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: "The `contain: style` CSS declaration TODO."
description: "The `contain: style` CSS declaration prevents counter (`counter-increment` and `counter-set`) and quotation styles (`content` property quote values) from applying beyond the element's descendants. This permits the browser to avoid slower rendering calculations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@danielsakhapov I think you know about this, can you say if the description of this feature is accurate?

Choose a reason for hiding this comment

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

I'd say it prevents modifying counters and quotes values outside the element's descendants, but doesn't prevent accessing the value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a little bit hard to understand. Do web developers use style containment because they care about counters and quotes, or do they really use it because it makes stuff faster without them knowing why? If so, maybe we should say that it makes stuff faster, and that the side effect is on counters and quotes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How about this, to shift the emphasis to something like "go faster, at a specific expense"?

Suggested change
description: "The `contain: style` CSS declaration TODO."
description: "The `contain: style` CSS declaration permits the browser to avoid slower layout calculations by preventing modification to counter (`counter-increment` and `counter-set`) and quotation styles (`content` property quote values) beyond the element's descendants.

@@ -0,0 +1,6 @@
name: Inline-size containment
description: "The `contain: inline-size` CSS declaration TODO."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: "The `contain: inline-size` CSS declaration TODO."
description: "The `contain: inline-size` CSS declaration prevents the element's inline size from being set by the element's contents. This permits the browser to avoid slower rendering calculations."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think "layout calculations" would work just as well? To me, rendering is a larger process that also includes painting pixels.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Precision is good! Though I suspect for developers it's a case of "divs go brrr."

Suggested change
description: "The `contain: inline-size` CSS declaration TODO."
description: "The `contain: inline-size` CSS declaration prevents the element's inline size from being set by the element's contents. This permits the browser to avoid slower layout calculations."

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another take on this, to avoid the circular description:

Suggested change
description: "The `contain: inline-size` CSS declaration TODO."
description: "The `contain: inline-size` CSS declaration prevents the element's inline dimension from being set by the element's contents. This permits the browser to avoid slower layout calculations."

@foolip
Copy link
Collaborator Author

foolip commented May 28, 2024

I have a slight preference for splitting all of the features separately.

I think we should go with that. We could later consider a composite feature for the whole contain CSS property if it stops getting new functionality.

Copy link
Collaborator

@ddbeck ddbeck left a comment

Choose a reason for hiding this comment

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

Had another go at descriptions.

@@ -0,0 +1,6 @@
name: Layout containment
description: "The `contain: layout` CSS declaration TODO."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: "The `contain: layout` CSS declaration TODO."
description: "The `contain: layout` CSS declaration isolates the inside of an element such that it cannot affect the layout of the rest of the page or be affected by the rest of the page. This permits the browser to avoid slower layout calculations."

@@ -0,0 +1,6 @@
name: Paint containment
description: "The `contain: paint` CSS declaration TODO."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: "The `contain: paint` CSS declaration TODO."
description: "The `contain: paint` CSS declaration prevents an element's descendants from being drawn outside the boundaries of the containing element, with any overflow clipped. This permits the browser to avoid slower painting calculations."

@@ -0,0 +1,6 @@
name: Size containment
description: "The `contain: size` CSS declaration TODO."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: "The `contain: size` CSS declaration TODO."
description: "The `contain: size` CSS declaration sets an element's dimensions exclusively by its `height` and `width` properties, ignoring its contents and descendants. This permits the browser to avoid slower layout calculations."

@@ -0,0 +1,6 @@
name: Inline-size containment
description: "The `contain: inline-size` CSS declaration TODO."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another take on this, to avoid the circular description:

Suggested change
description: "The `contain: inline-size` CSS declaration TODO."
description: "The `contain: inline-size` CSS declaration prevents the element's inline dimension from being set by the element's contents. This permits the browser to avoid slower layout calculations."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature definition Creating or defining new features or groups of features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants