Use a builder for local CascadeLayers [chromium/src : main]

0 views
Skip to first unread message

Anders Hartvoll Ruud (Gerrit)

unread,
Nov 21, 2025, 4:13:41 AM (10 days ago) Nov 21
to Steinar H Gunderson, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org
Attention needed from Steinar H Gunderson

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Steinar H Gunderson
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I4c71a45273bf042dbd6a7ff76c24d57bf58c43dc
Gerrit-Change-Number: 7177241
Gerrit-PatchSet: 2
Gerrit-Owner: Anders Hartvoll Ruud <and...@chromium.org>
Gerrit-Reviewer: Anders Hartvoll Ruud <and...@chromium.org>
Gerrit-Reviewer: Steinar H Gunderson <se...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-Attention: Steinar H Gunderson <se...@chromium.org>
Gerrit-Comment-Date: Fri, 21 Nov 2025 09:13:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Steinar H Gunderson (Gerrit)

unread,
Nov 21, 2025, 9:13:16 AM (10 days ago) Nov 21
to Anders Hartvoll Ruud, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org
Attention needed from Anders Hartvoll Ruud

Steinar H Gunderson added 3 comments

Commit Message
Line 32, Patchset 2 (Latest):The plan is to keep the system we have now as much as possible (with
Steinar H Gunderson . unresolved

Before I go too deeply into this CL: What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

A related question is: Why do we want the local CascadeLayer tree at all in the future? What is it good for?

(I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

File third_party/blink/renderer/core/css/cascade_layer_builder.h
Line 84, Patchset 2 (Latest): HeapVector<wtf_size_t> stack_sizes_;
Steinar H Gunderson . unresolved

Is there some reason why you do this instead of HeapVector<HeapVector<Member<CascadeLayer>, 1>>> or similar?

It also feels more natural to store e.g. 1 here instead of having to subtract the number of elements?

Line 81, Patchset 2 (Latest): HeapVector<Member<CascadeLayer>> stack_;
Steinar H Gunderson . unresolved

Where's the root stored?

Open in Gerrit

Related details

Attention is currently required from:
  • Anders Hartvoll Ruud
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c71a45273bf042dbd6a7ff76c24d57bf58c43dc
    Gerrit-Change-Number: 7177241
    Gerrit-PatchSet: 2
    Gerrit-Owner: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Steinar H Gunderson <se...@chromium.org>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-Attention: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Comment-Date: Fri, 21 Nov 2025 14:12:59 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Anders Hartvoll Ruud (Gerrit)

    unread,
    Nov 23, 2025, 2:43:55 PM (8 days ago) Nov 23
    to Steinar H Gunderson, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org
    Attention needed from Steinar H Gunderson

    Anders Hartvoll Ruud added 3 comments

    Commit Message
    Line 32, Patchset 2:The plan is to keep the system we have now as much as possible (with
    Steinar H Gunderson . unresolved

    Before I go too deeply into this CL: What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    A related question is: Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Anders Hartvoll Ruud

    What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    No, but it means the canonical layer tree (and layer->order map) needs to be rebuilt. (Like today.)

    Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    To maintain the incrementality you're talking about. If we store canonical layers directly, we would have to rebuild all subsequent RuleSets when a sheet is inserted.

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Yeah. The plan is to make `CascadeLayerBuilder` capable of duplicating its push/pops onto a second builder (for the canonical tree and layer map). This second builder is instantiated in `StyleSheetCollection::FinishUpdateActiveStyleSheets`, and either receives push/pops via a local builder when building a `RuleSet`, or, if the cached `RuleSet` held on `StyleSheetContents` is still valid, we basically "replay" the push/pops from the local layer tree stored on the `RuleSet`. As long as we're not doing any layered lookups during `RuleSet` building (custom media, mixins, etc), then it's really very similar to how it works today. We do roughly the same work, just earlier.

    File third_party/blink/renderer/core/css/cascade_layer_builder.h
    Line 84, Patchset 2: HeapVector<wtf_size_t> stack_sizes_;
    Steinar H Gunderson . unresolved

    Is there some reason why you do this instead of HeapVector<HeapVector<Member<CascadeLayer>, 1>>> or similar?

    It also feels more natural to store e.g. 1 here instead of having to subtract the number of elements?

    Anders Hartvoll Ruud

    HeapVector<HeapVector<Member<CascadeLayer>, 1>>>

    Do you think that's better? I just flattened it out instinctively. (Another version of this traversed the ancestor chain, which is more annoying with a nested structure.)

    Also, I think it's more annoying to map the `foo` part of `foo.bar` from local to canonical if we don't flatten.

    Let's come back to this point when the next CL in the chain is ready to look at.

    It also feels more natural to store e.g. 1 here instead of having to subtract the number of elements?

    Yeah, sure. I'll do that.

    Line 81, Patchset 2: HeapVector<Member<CascadeLayer>> stack_;
    Steinar H Gunderson . unresolved

    Where's the root stored?

    Anders Hartvoll Ruud

    At `stack_[0]`, created lazily. I'll mention it here.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Steinar H Gunderson
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c71a45273bf042dbd6a7ff76c24d57bf58c43dc
    Gerrit-Change-Number: 7177241
    Gerrit-PatchSet: 3
    Gerrit-Owner: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Steinar H Gunderson <se...@chromium.org>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-Attention: Steinar H Gunderson <se...@chromium.org>
    Gerrit-Comment-Date: Sun, 23 Nov 2025 19:43:28 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Steinar H Gunderson <se...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Steinar H Gunderson (Gerrit)

    unread,
    Nov 24, 2025, 5:08:13 AM (7 days ago) Nov 24
    to Anders Hartvoll Ruud, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org
    Attention needed from Anders Hartvoll Ruud

    Steinar H Gunderson added 3 comments

    Commit Message
    Line 32, Patchset 2:The plan is to keep the system we have now as much as possible (with
    Steinar H Gunderson . unresolved

    Before I go too deeply into this CL: What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    A related question is: Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Anders Hartvoll Ruud

    What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    No, but it means the canonical layer tree (and layer->order map) needs to be rebuilt. (Like today.)

    Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    To maintain the incrementality you're talking about. If we store canonical layers directly, we would have to rebuild all subsequent RuleSets when a sheet is inserted.

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Yeah. The plan is to make `CascadeLayerBuilder` capable of duplicating its push/pops onto a second builder (for the canonical tree and layer map). This second builder is instantiated in `StyleSheetCollection::FinishUpdateActiveStyleSheets`, and either receives push/pops via a local builder when building a `RuleSet`, or, if the cached `RuleSet` held on `StyleSheetContents` is still valid, we basically "replay" the push/pops from the local layer tree stored on the `RuleSet`. As long as we're not doing any layered lookups during `RuleSet` building (custom media, mixins, etc), then it's really very similar to how it works today. We do roughly the same work, just earlier.

    Steinar H Gunderson

    Hm. But we _are_ going to do layered lookups during RuleSet building for mixins, right?

    I'm fine with not solving that here if it isn't intended to be solved yet, I just want to understand to what degree the path is clear for us.

    File third_party/blink/renderer/core/css/cascade_layer_builder.h
    Line 84, Patchset 2: HeapVector<wtf_size_t> stack_sizes_;
    Steinar H Gunderson . resolved

    Is there some reason why you do this instead of HeapVector<HeapVector<Member<CascadeLayer>, 1>>> or similar?

    It also feels more natural to store e.g. 1 here instead of having to subtract the number of elements?

    Anders Hartvoll Ruud

    HeapVector<HeapVector<Member<CascadeLayer>, 1>>>

    Do you think that's better? I just flattened it out instinctively. (Another version of this traversed the ancestor chain, which is more annoying with a nested structure.)

    Also, I think it's more annoying to map the `foo` part of `foo.bar` from local to canonical if we don't flatten.

    Let's come back to this point when the next CL in the chain is ready to look at.

    It also feels more natural to store e.g. 1 here instead of having to subtract the number of elements?

    Yeah, sure. I'll do that.

    Steinar H Gunderson

    Acknowledged

    Line 81, Patchset 2: HeapVector<Member<CascadeLayer>> stack_;
    Steinar H Gunderson . unresolved

    Where's the root stored?

    Anders Hartvoll Ruud

    At `stack_[0]`, created lazily. I'll mention it here.

    Steinar H Gunderson

    OK. But why do we create it lazily? Isn't eagerly easier?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Anders Hartvoll Ruud
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c71a45273bf042dbd6a7ff76c24d57bf58c43dc
    Gerrit-Change-Number: 7177241
    Gerrit-PatchSet: 3
    Gerrit-Owner: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Steinar H Gunderson <se...@chromium.org>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-Attention: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Comment-Date: Mon, 24 Nov 2025 10:08:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Anders Hartvoll Ruud <and...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Anders Hartvoll Ruud (Gerrit)

    unread,
    Nov 24, 2025, 8:56:53 AM (7 days ago) Nov 24
    to Steinar H Gunderson, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org
    Attention needed from Steinar H Gunderson

    Anders Hartvoll Ruud added 2 comments

    Commit Message
    Line 32, Patchset 2:The plan is to keep the system we have now as much as possible (with
    Steinar H Gunderson . unresolved

    Before I go too deeply into this CL: What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    A related question is: Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Anders Hartvoll Ruud

    What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    No, but it means the canonical layer tree (and layer->order map) needs to be rebuilt. (Like today.)

    Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    To maintain the incrementality you're talking about. If we store canonical layers directly, we would have to rebuild all subsequent RuleSets when a sheet is inserted.

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Yeah. The plan is to make `CascadeLayerBuilder` capable of duplicating its push/pops onto a second builder (for the canonical tree and layer map). This second builder is instantiated in `StyleSheetCollection::FinishUpdateActiveStyleSheets`, and either receives push/pops via a local builder when building a `RuleSet`, or, if the cached `RuleSet` held on `StyleSheetContents` is still valid, we basically "replay" the push/pops from the local layer tree stored on the `RuleSet`. As long as we're not doing any layered lookups during `RuleSet` building (custom media, mixins, etc), then it's really very similar to how it works today. We do roughly the same work, just earlier.

    Steinar H Gunderson

    Hm. But we _are_ going to do layered lookups during RuleSet building for mixins, right?

    I'm fine with not solving that here if it isn't intended to be solved yet, I just want to understand to what degree the path is clear for us.

    Anders Hartvoll Ruud

    Hm. But we are going to do layered lookups during RuleSet building for mixins, right?

    Yeah. Those RuleSets must be marked as "I care about preceding layers", and do need to be rebuilt when something changes earlier. Within the "local+canonical layer" class of solutions, I've considered a few different options for this:

     1. Storing the "input" canonical layer tree as of a given RuleSet's creation on StyleSheetContents, and comparing the old tree vs. the new tree when considering a cache RuleSet for reuse later. This requires a copy-on-write layer tree unless we want to copy of a lot full trees. I started on this, but having multiple snapshots of the "canonical" layer tree made things even harder to understand, and requires very annoying "remapping" of the local->canonical map.
    2. Similar to (1), but instead store the "input" canonical layer tree as a _serialized string_. It's a caveman approach, but it probably would have worked well enough.

    However, I think the most promising idea is:
     3. During `RuleSet` building, when we need to answer the question "is this mixin in layer `foo` stronger than the existing mixin in layer `bar`?", we consult the canonical layer map and get the answer. We record this answer (as well as the competing layers) in a vector (or set) of "layer comparisons that matter", similar to how `RuleSet::media_query_set_results_` store media query evaluations that matter. During `EnsureRuleSet`, we then need to check if any of the layer comparisons changed, exactly like we do with `DidMediaQueryResultsChange`. This approach should ensure that we don't rebuild layer-order-dependent RuleSets just because the layer tree changed before us; it would have to be changed in a way that matters for the layers that were actually compared.
    File third_party/blink/renderer/core/css/cascade_layer_builder.h
    Line 81, Patchset 2: HeapVector<Member<CascadeLayer>> stack_;
    Steinar H Gunderson . unresolved

    Where's the root stored?

    Anders Hartvoll Ruud

    At `stack_[0]`, created lazily. I'll mention it here.

    Steinar H Gunderson

    OK. But why do we create it lazily? Isn't eagerly easier?

    Anders Hartvoll Ruud

    I was just maintaining the existing laziness of the root layer (see `EnsureImplicitOuterLayer()`), without deeply considering what is easier.

    We can do it eagerly, but then `CascadeLayerBuilder::TakeRoot()` should probably still return `nullptr` if we're just holding on to an empty root layer? (To not persist more stuff than we need.)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Steinar H Gunderson
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c71a45273bf042dbd6a7ff76c24d57bf58c43dc
    Gerrit-Change-Number: 7177241
    Gerrit-PatchSet: 3
    Gerrit-Owner: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Steinar H Gunderson <se...@chromium.org>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-Attention: Steinar H Gunderson <se...@chromium.org>
    Gerrit-Comment-Date: Mon, 24 Nov 2025 13:56:38 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Steinar H Gunderson (Gerrit)

    unread,
    Nov 24, 2025, 10:16:59 AM (7 days ago) Nov 24
    to Anders Hartvoll Ruud, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org
    Attention needed from Anders Hartvoll Ruud

    Steinar H Gunderson added 8 comments

    Commit Message
    Line 32, Patchset 2:The plan is to keep the system we have now as much as possible (with
    Steinar H Gunderson . unresolved

    Before I go too deeply into this CL: What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    A related question is: Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Anders Hartvoll Ruud

    What does this mean for incrementality? If I add another stylesheet somewhere that's not the end, does it mean all RuleSets need to be recreated?

    No, but it means the canonical layer tree (and layer->order map) needs to be rebuilt. (Like today.)

    Why do we want the local CascadeLayer tree at all in the future? What is it good for?

    To maintain the incrementality you're talking about. If we store canonical layers directly, we would have to rebuild all subsequent RuleSets when a sheet is inserted.

    (I'm sort of suspecting there is an “incremental merge” plan here somehow, but I can't quite grasp it)

    Yeah. The plan is to make `CascadeLayerBuilder` capable of duplicating its push/pops onto a second builder (for the canonical tree and layer map). This second builder is instantiated in `StyleSheetCollection::FinishUpdateActiveStyleSheets`, and either receives push/pops via a local builder when building a `RuleSet`, or, if the cached `RuleSet` held on `StyleSheetContents` is still valid, we basically "replay" the push/pops from the local layer tree stored on the `RuleSet`. As long as we're not doing any layered lookups during `RuleSet` building (custom media, mixins, etc), then it's really very similar to how it works today. We do roughly the same work, just earlier.

    Steinar H Gunderson

    Hm. But we _are_ going to do layered lookups during RuleSet building for mixins, right?

    I'm fine with not solving that here if it isn't intended to be solved yet, I just want to understand to what degree the path is clear for us.

    Anders Hartvoll Ruud

    Hm. But we are going to do layered lookups during RuleSet building for mixins, right?

    Yeah. Those RuleSets must be marked as "I care about preceding layers", and do need to be rebuilt when something changes earlier. Within the "local+canonical layer" class of solutions, I've considered a few different options for this:

     1. Storing the "input" canonical layer tree as of a given RuleSet's creation on StyleSheetContents, and comparing the old tree vs. the new tree when considering a cache RuleSet for reuse later. This requires a copy-on-write layer tree unless we want to copy of a lot full trees. I started on this, but having multiple snapshots of the "canonical" layer tree made things even harder to understand, and requires very annoying "remapping" of the local->canonical map.
    2. Similar to (1), but instead store the "input" canonical layer tree as a _serialized string_. It's a caveman approach, but it probably would have worked well enough.

    However, I think the most promising idea is:
     3. During `RuleSet` building, when we need to answer the question "is this mixin in layer `foo` stronger than the existing mixin in layer `bar`?", we consult the canonical layer map and get the answer. We record this answer (as well as the competing layers) in a vector (or set) of "layer comparisons that matter", similar to how `RuleSet::media_query_set_results_` store media query evaluations that matter. During `EnsureRuleSet`, we then need to check if any of the layer comparisons changed, exactly like we do with `DidMediaQueryResultsChange`. This approach should ensure that we don't rebuild layer-order-dependent RuleSets just because the layer tree changed before us; it would have to be changed in a way that matters for the layers that were actually compared.
    Steinar H Gunderson

    I assume you are aware that with #3, you can support circular references by importing a SAT solver. :-)

    File third_party/blink/renderer/core/css/cascade_layer_builder.h
    Line 83, Patchset 3 (Latest): // This exists two know how many items to pop from `stack_` during Pop().
    Steinar H Gunderson . unresolved

    two -> to

    Line 81, Patchset 2: HeapVector<Member<CascadeLayer>> stack_;
    Steinar H Gunderson . unresolved

    Where's the root stored?

    Anders Hartvoll Ruud

    At `stack_[0]`, created lazily. I'll mention it here.

    Steinar H Gunderson

    OK. But why do we create it lazily? Isn't eagerly easier?

    Anders Hartvoll Ruud

    I was just maintaining the existing laziness of the root layer (see `EnsureImplicitOuterLayer()`), without deeply considering what is easier.

    We can do it eagerly, but then `CascadeLayerBuilder::TakeRoot()` should probably still return `nullptr` if we're just holding on to an empty root layer? (To not persist more stuff than we need.)

    Steinar H Gunderson

    That's fine by me. I don't feel very strongly about this detail, it just feels simpler to me without having thought deeply about it. But I _do_ think the current CurrentLayer() behavior is weird. CurrentLayer on the root should _either_ be consistent, _or_ CHECK-fail. Or is there some deep reason here?

    File third_party/blink/renderer/core/css/cascade_layer_map.cc
    Line 35, Patchset 3 (Latest): // Add the current layer *after* its children. If CurrentLayer() is (or would
    Steinar H Gunderson . unresolved

    Perhaps slightly more deliberate line breaking here would make it easier to read.

    File third_party/blink/renderer/core/css/css_global_rule_set.cc
    Line 35, Patchset 3 (Latest): for (unsigned i = 0; i < watched_selectors.size(); ++i) {
    Steinar H Gunderson . unresolved

    Since you're in this function now anyway, consider:

    Please fix this WARNING reported by ClangTidy: check: modernize-loop-convert

    use range-based for loop instead (https://clang.l...

    check: modernize-loop-convert

    use range-based for loop instead (https://clang.llvm.org/extra/clang-tidy/checks/modernize/loop-convert.html)

    (Note: You can add `Skip-Clang-Tidy-Checks: modernize-loop-convert` footer to the CL description to skip the check)

    (Lint observed on `android-clang-tidy-rel`, but not on `linux-clang-tidy-rel`)

    File third_party/blink/renderer/core/css/rule_set.h
    Line 409, Patchset 3 (Latest): CascadeLayerBuilder& layer_builder,
    Steinar H Gunderson . unresolved

    Is this now an in/out parameter? If so, I believe it should be moved later in the argument list.

    File third_party/blink/renderer/core/css/rule_set.cc
    Line 1245, Patchset 3 (Latest): layer_builder.Push(import_rule->GetLayerName());
    Steinar H Gunderson . unresolved

    Should this be some kind of RAII helper? Or is that overkill?

    File third_party/blink/renderer/core/css/rule_set_test.cc
    Line 1016, Patchset 3 (Latest): layer = layer ? layer->FindDirectSubLayer(name_part) : nullptr;
    Steinar H Gunderson . unresolved

    Do you need the ternary operator here, or can you just break once layer is nullptr?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Anders Hartvoll Ruud
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c71a45273bf042dbd6a7ff76c24d57bf58c43dc
    Gerrit-Change-Number: 7177241
    Gerrit-PatchSet: 3
    Gerrit-Owner: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Reviewer: Steinar H Gunderson <se...@chromium.org>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-Attention: Anders Hartvoll Ruud <and...@chromium.org>
    Gerrit-Comment-Date: Mon, 24 Nov 2025 15:16:46 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Anders Hartvoll Ruud (Gerrit)

    unread,
    5:12 AM (9 hours ago) 5:12 AM
    to Steinar H Gunderson, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org

    Anders Hartvoll Ruud abandoned this change

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: abandon
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4c71a45273bf042dbd6a7ff76c24d57bf58c43dc
    Gerrit-Change-Number: 7177241
    Gerrit-PatchSet: 4
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages