Closed Bug 1888079 Opened 1 year ago Closed 1 year ago

Don't call getStyleSheetRuleCountAndAtRules when modifying a Rule from the Inspector

Categories

(DevTools :: Inspector: Rules, task)

task

Tracking

(firefox126 fixed)

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

setStyleSheetText always calls getStyleSheetRuleCountAndAtRules and triggers an at-rules-changed stylesheet update:

https://searchfox.org/mozilla-central/rev/7bbc54b70e348a11f9cd12071ada2cb47c8a14e3/devtools/server/actors/utils/stylesheets-manager.js#425-426,439-440,444,449-454,468-474

/**
 * Update the style sheet in place with new text.
...
 */
async setStyleSheetText(
...
) {
...
  const { atRules, ruleCount } =
    this.getStyleSheetRuleCountAndAtRules(styleSheet);

  if (kind !== UPDATE_PRESERVING_RULES) {
    this.#notifyPropertyChanged(resourceId, "ruleCount", ruleCount);
  }
...
  this.#onStyleSheetUpdated({
    resourceId,
    updateKind: "at-rules-changed",
    updates: {
      resourceUpdates: { atRules },
    },
  });

But when modifying a property from the inspector, the rule count and the at-rules can't be modified, so we could avoid computing those information that can be costly on large stylesheets.

When we modify a rule from the inspector, the number of rules and the at-rules
data can't be impacted, so avoid computing this costly information.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/76f2f82eefe2 [devtools] Don't call getStyleSheetRuleCountAndAtRules in setStyleSheetText when it's not needed. r=devtools-reviewers,ochameau.
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
Blocks: 1606641
Duplicate of this bug: 1815389
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: