-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: main
Are you sure you want to change the base?
Conversation
The situation seems to be this:
https://caniuse.com/css-containment seems to cover initial support for the 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? |
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 |
There was a problem hiding this 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.
@@ -0,0 +1,6 @@ | |||
name: Style containment | |||
description: "The `contain: style` CSS declaration TODO." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"?
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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."
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." |
There was a problem hiding this comment.
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:
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." |
I think we should go with that. We could later consider a composite feature for the whole |
There was a problem hiding this 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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
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:
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." |
No description provided.