Bug 1779180 - [devtools] Replace usages of InspectorUtils.getRuleLine with InspectorUtils.getRelativeRuleLine. r=jdescottes.

For <style> elements, `getRelativeRuleLine` gives us the position of the rule
inside a stylesheet, when `getRuleLine` gives the position of the rule relatively
to the whole HTML source.
The former is more accurate for us when we want to display such line number in
DevTools UI (for example in the StyleEditor media query sidebar).

Test will be added in next patch of this queue.

Differential Revision: https://phabricator.services.mozilla.com/D151596
This commit is contained in:
Nicolas Chevobbe 2022-07-18 12:13:55 +00:00
parent 780d0666b4
commit 1e5e7186d7
4 changed files with 5 additions and 5 deletions

View File

@ -959,7 +959,7 @@ function CssRule(cssSheet, domRule, element) {
if (this._cssSheet) {
// parse domRule.selectorText on call to this.selectors
this._selectors = null;
this.line = InspectorUtils.getRuleLine(this.domRule);
this.line = InspectorUtils.getRelativeRuleLine(this.domRule);
this.column = InspectorUtils.getRuleColumn(this.domRule);
this.source = this._cssSheet.shortSource + ":" + this.line;
if (this.mediaText) {

View File

@ -35,7 +35,7 @@ var MediaRuleActor = protocol.ActorClassWithSpec(mediaRuleSpec, {
this._matchesChange = this._matchesChange.bind(this);
this.line = InspectorUtils.getRuleLine(mediaRule);
this.line = InspectorUtils.getRelativeRuleLine(mediaRule);
this.column = InspectorUtils.getRuleColumn(mediaRule);
try {

View File

@ -603,7 +603,7 @@ class StyleSheetsManager extends EventEmitter {
mediaText: rule.media.mediaText,
conditionText: rule.conditionText,
matches,
line: InspectorUtils.getRuleLine(rule),
line: InspectorUtils.getRelativeRuleLine(rule),
column: InspectorUtils.getRuleColumn(rule),
};
});

View File

@ -44,8 +44,8 @@ Test that css-logic handles media-queries correctly
const inline = _strings.GetStringFromName("rule.sourceInline");
const source1 = inline + ":12";
const source2 = inline + ":19 @media screen and (min-width: 1px)";
const source1 = inline + ":2";
const source2 = inline + ":9 @media screen and (min-width: 1px)";
is(cssLogic._matchedRules[0][0].source, source1,
"rule.source gives correct output for rule 1");
is(cssLogic._matchedRules[1][0].source, source2,