Closed Bug 1890775 Opened 2 years ago Closed 2 years ago

Disabling property in a rule empties out the stylesheet if the rule is not on the first line of the stylesheet, and right after another rule declaration (without whitespace)

Categories

(DevTools :: Inspector: Rules, defect, P1)

defect

Tracking

(firefox-esr115 unaffected, firefox124 unaffected, firefox125 unaffected, firefox126 verified, firefox127 verified)

VERIFIED FIXED
126 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox124 --- unaffected
firefox125 --- unaffected
firefox126 --- verified
firefox127 --- verified

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Steps to reproduce

  1. Navigate to data:text/html,<meta charset=utf8><style>%0Ahtml{}body{color:red;background:gold;}</style>Hello
  2. Open the inspector and select the body node
  3. In the body rule, unselect the color property

Expected results

The Hello text gets black, the background color stays gold

Actual results

The Hello text gets black, the background color gets white, and if you navigate to the style editor, you can see that the stylesheet is empty


The stylesheet has the following content:


html{}body{color:red;background:gold;}

When InspectorUtils.replaceBlockRuleBodyTextInStylesheet is called to replace the content of the second rule, get_byte_index_from_line_and_column (glue.rs) returns an erroneous index as it doesn't account for the line break character.
This means that Servo_ReplaceBlockRuleBodyTextInStylesheetText (glue.rs) includes the closing curly bracket of the previous rule when building the string it should parse (i.e. }body{color:red;background:gold;}).
This is a parsing error as the parser didn't encountered any opening bracket before, and the function will return null.

So we should fix the index computation, but also maybe avoid emptying the stylesheet when the function returns null.

We were getting a line byte index for the
actual char matching the line we want, but
we actually need the index after that
new line char.
A test case is added to cover this fix.

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

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/215c06cd23e0 [devtools] Fix get_byte_index_from_line_and_column line index computation. r=layout-reviewers,devtools-reviewers,emilio.
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch

Reproducible on a 2024-04-10 Nightly build on Windows 10.
Verified as fixed on Firefox Nightly 127.0a1 and Firefox 126.0b7 on Windows 10, Ubuntu 22, macOS 12.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: