Closed Bug 1946445 Opened 7 months ago Closed 7 months ago

Declaration after nested rule appears in its parent rule

Categories

(DevTools :: Inspector: Rules, defect)

defect

Tracking

(firefox-esr128 unaffected, firefox135 wontfix, firefox136 fixed, firefox137 fixed)

RESOLVED FIXED
137 Branch
Tracking Status
firefox-esr128 --- unaffected
firefox135 --- wontfix
firefox136 --- fixed
firefox137 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Regression)

Details

(Keywords: perf-alert, regression)

Attachments

(2 files, 1 obsolete file)

Steps to reproduce

  1. Navigate to data:text/html,<meta charset=utf8><style>body { color: red; span {} color: green; }</style>Hello
  2. Open the inspector

In the rules view, we're getting:

body {
  {
    color: green;
  }
}

body {
  color: red;
  color: green;
}

but we should have

body {
  {
    color: green;
  }
}

body {
  color: red;
}
Keywords: regression
Regressed by: 1919853

parseDeclarationsInternal handling of nested rules predate changes made to the spec and additions of CSSNesstedDeclarations:

https://searchfox.org/mozilla-release/rev/21df1ac521242be96e0c070aa713ccff03e1b2d3/devtools/shared/css/parsing-utils.js#364-392

if (
  // If we're not already in a nested rule
  !isInNested &&
  // and there's an opening curly bracket
  token.tokenType === "CurlyBracketBlock" &&
  // and we're not inside a function or an attribute
  !currentBlocks.length
) {
  // Assume we're encountering a nested rule.
  isInNested = true;
  nestingLevel = 1;

  continue;
} else if (isInNested) {
  if (token.tokenType == "CurlyBracketBlock") {
    nestingLevel++;
  } else if (token.tokenType == "CloseCurlyBracket") {
    nestingLevel--;
  }

  // If we were in a nested rule, and we saw the last closing curly bracket,
  // reset the state to parse possible declarations declared after the nested rule.
  if (nestingLevel === 0) {
    isInNested = false;
    // We need to remove the previous pending declaration and reset the state
    declarations.pop();
    resetStateForNextDeclaration();
  }
  continue;

which means we still retrieve the declarations after nested block, although we shouldn't now, since they're now in a different rule that we do retrieve as well

Set release status flags based on info from the regressing bug 1919853

:emilio, since you are the author of the regressor, bug 1919853, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

You're definitely more familiar than me with this code, do you plan to look at this? Otherwise I could but I'm honestly a bit swamped with other things so...

Flags: needinfo?(emilio) → needinfo?(nchevobbe)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #3)

You're definitely more familiar than me with this code, do you plan to look at this? Otherwise I could but I'm honestly a bit swamped with other things so...

yeah yeah, don't worry, I'm having a look

Flags: needinfo?(nchevobbe)
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

Stop collecting declarations as soon as we detect a nested rule.
Any declaration that come after the nested rules are now put in a
separate CSSNestedDeclaration rule.
We still need to handle the nesting logic for commented declarations,
as highlighted by a test case in test_parseDeclarations.js.
Other test cases there for nested rules are updated, and we add
a CSSNestedDeclaration in a Rules view mochitest to make sure we
don't get the declaration in the "top level" rule anymore.

Comment on attachment 9465079 [details]
Bug 1946445 - [devtools] Turn RuleRewriter into a proper ES6 class. r=#devtools.

Revision D237519 was moved to bug 1946442. Setting attachment 9465079 [details] to obsolete.

Attachment #9465079 - Attachment is obsolete: true
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a08727399a37 [devtools] Fix parseDeclarationsInternal for nested declarations. r=devtools-reviewers,jdescottes.
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch

The patch landed in nightly and beta is affected.
:nchevobbe, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox136 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(nchevobbe)

Stop collecting declarations as soon as we detect a nested rule.
Any declaration that come after the nested rules are now put in a
separate CSSNestedDeclaration rule.
We still need to handle the nesting logic for commented declarations,
as highlighted by a test case in test_parseDeclarations.js.
Other test cases there for nested rules are updated, and we add
a CSSNestedDeclaration in a Rules view mochitest to make sure we
don't get the declaration in the "top level" rule anymore.

Original Revision: https://phabricator.services.mozilla.com/D237520

Attachment #9465873 - Flags: approval-mozilla-beta?
Flags: needinfo?(nchevobbe)

beta Uplift Approval Request

  • User impact if declined: duplicated declaration in Inspector Rules view, might confuse users
  • Code covered by automated testing: yes
  • Fix verified in Nightly: no
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: -
  • Risk associated with taking this patch: low
  • Explanation of risk level: devtools only fix, covered by unit test and mochitest
  • String changes made/needed: -
  • Is Android affected?: yes
Attachment #9465873 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

For more information on performance sheriffing please see our FAQ.
(In reply to Cristian Tuns from comment #9)

https://hg.mozilla.org/mozilla-central/rev/a08727399a37

Perfherder has detected a devtools performance change from push a08727399a3753b89c1270329ebd0f0499c3740d.

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
8% damp browser-toolbox.webconsole-ready.DAMP linux1804-64-shippable-qr e10s fission stylo webrender 698.31 -> 644.43
6% damp browser-toolbox.webconsole-ready.DAMP windows11-64-shippable-qr e10s fission stylo webrender 427.31 -> 400.16

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a sheriff to do that for you.

You can run these tests on try with ./mach try perf --alert 43855

Keywords: perf-alert
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: