Closed Bug 2014403 Opened 10 months ago Closed 3 months ago

Handle invalidation for @container style() queries

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jfkthame, Assigned: descalante)

References

(Blocks 1 open bug)

Details

Attachments

(1 obsolete file)

Depends on: 2014404
No longer depends on: 2014404

(ni? me to elaborate on what the MVP of this would look like)

Flags: needinfo?(emilio)

So what needs to happen here is:

  • We need to keep track of whether a style is affected by style queries somehow. We should use a mechanism similar to this flag.
  • When custom properties differ (we diff them around here) we need to keep that information.
  • Right now, when inherited properties change, we just re-cascade the children. We need to make that ChildRestyleRequirement a bit more subtle, since now that needs to not only re-cascade, but re-selector-match if those properties are queried by the child.

My suggestion would be to make ChildRestyleRequirement a bitfield, something along the lines:

const EMPTY = 0;
const CASCADE_CHILDREN_IF_INHERITS_RESET = 1 << 0;
const CASCADE_CHILDREN = 1 << 1;
const MATCH_CHILDREN_IF_AFFECTED_BY_STYLE_QUERIES = 1 << 2;
const CASCADE_SUBTREE = 1 << 3;
const MATCH_SUBTREE = 1 << 4;

In fact, I think we can just use RestyleHint directly (and we need to add a new bit there for style queries).

Then around here, we'd need to deal with the bits instead of a match statement, something like:

propagated_hint |= child_restyle_requirement;

(we could rename child_restyle_requirement actually).

And finally we'd need to tweak this condition to check whether the new bit is set, and whether the old style is affected by container queries.

I think that's the MVP for this. Further improvements could include keeping track of the changed properties or something, but we haven't needed that so far for explicit inheritance of reset properties which is a pretty similar mechanism, so hopefully we don't need that here either.

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez [:emilio] from comment #2)

  • When custom properties differ (we diff them around here) we need to keep that information.

Note that it's not only changes to custom properties that are relevant to style queries; at least changes to CSS units can also affect style queries, even in the absence of any custom props (e.g. @container style(15px < 1em < 25px) would require that we re-selector-match if the container's font-size changes). I don't think there's currently much (any?) test coverage for things like that, though.

Assignee: nobody → descalante

(In reply to Emilio Cobos Álvarez [:emilio] from comment #2)

const MATCH_CHILDREN_IF_AFFECTED_BY_STYLE_QUERIES = 1 << 2;

Would this only re-do selector matching for the element's immediate children? IIUC, that may not be sufficient; we probably need it to be MATCH_SUBTREE_IF_AFFECTED_BY_STYLE_QUERIES, at least in the case where the element has a container-name, because arbitrarily distant descendants may be querying an ancestor container other than their immediate parent.

Depends on: 2019549
Depends on: 2019551
Depends on: 2019553
Pushed by descalante@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8aceb3039998 https://hg.mozilla.org/integration/autoland/rev/d669b0133e0e Convert ChildRestyleRequirement from enum to bitflags. r=emilio,firefox-style-system-reviewers
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

FTR, it looks like the patch that landed here should really have been attached to bug 2019553.

(In reply to Jonathan Kew [:jfkthame] from comment #8)

FTR, it looks like the patch that landed here should really have been attached to bug 2019553.

Yes it was, sorry about that

Comment on attachment 9551399 [details]
Bug 2014403 - Convert ChildRestyleRequirement from enum to bitflags. r=emilio,jfkthame

Revision D286879 was moved to bug 2019553. Setting attachment 9551399 [details] to obsolete.

Attachment #9551399 - Attachment is obsolete: true
Depends on: 2024047
Depends on: 2024049
Status: REOPENED → ASSIGNED
Target Milestone: 150 Branch → ---
Depends on: 2033060
Status: ASSIGNED → RESOLVED
Closed: 8 months ago → 3 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: