Skip to content

[css-contain] contain: style does not seem useful. #3280

@emilio

Description

@emilio

This is about https://drafts.csswg.org/css-contain/#containment-style.

I wonder what's the use-case for this. In particular, the following optimization that the spec describes:

Whenever a property is changed on a descendant of the containing element, calculating what part of the DOM tree is "dirtied" and might need to have its style recalculated can stop at the containing element.

Is just not true, since you need to compute the style of ancestors in order to inherit from them.

It's also hard to envision any kind of style-recalc optimization, since any style change may make that element become or stop-being style-contained, and you need to handle stuff like contain: inherit.

Given:

  • contain: style is broken on Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=855798
  • The complexity of implementing it correctly in Firefox is high.
  • There's no potential optimization to be had out of this (if only, you could optimize counter updates, but that benefit is IMO overruled by the complexity of "unscoping" the counters when contain: style stops applying dynamically, and the fact that counters are uncommon).

I wonder what's the point of implementing it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions