Bug 1415940 Part 7: Change canSetRuleText() to test the sheet for modification by CSSOM. r=tromey

MozReview-Commit-ID: 2tCVgntiRHn

--HG--
extra : rebase_source : 99d17cfd55dd0819d8e7a8395a29fb854cd03e3b
This commit is contained in:
Brad Werth 2017-12-19 13:52:24 -08:00
Родитель 45a547d205
Коммит cfa8c06eab
2 изменённых файлов: 7 добавлений и 23 удалений

Просмотреть файл

@ -1002,10 +1002,10 @@ var StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
get canSetRuleText() {
return this.type === ELEMENT_STYLE ||
(this._parentSheet &&
// If a rule does not have source, then it has been modified via
// CSSOM; and we should fall back to non-authored editing.
// If a rule has been modified via CSSOM, then we should fall
// back to non-authored editing.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1224121
this.sheetActor.allRulesHaveSource() &&
!this.sheetActor.hasRulesModifiedByCSSOM() &&
// Special case about:PreferenceStyleSheet, as it is generated on
// the fly and the URI is not registered with the about:handler
// https://bugzilla.mozilla.org/show_bug.cgi?id=935803#c37

Просмотреть файл

@ -237,27 +237,11 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
},
/**
* Test whether all the rules in this sheet have associated source.
* @return {Boolean} true if all the rules have source; false if
* some rule was created via CSSOM.
* Test whether this sheet has been modified by CSSOM.
* @return {Boolean} true if changed by CSSOM.
*/
allRulesHaveSource: function () {
let rules;
try {
rules = this.rawSheet.cssRules;
} catch (e) {
// sheet isn't loaded yet
return true;
}
for (let i = 0; i < rules.length; i++) {
let rule = rules[i];
if (InspectorUtils.getRelativeRuleLine(rule) === 0) {
return false;
}
}
return true;
hasRulesModifiedByCSSOM: function () {
return InspectorUtils.hasRulesModifiedByCSSOM(this.rawSheet);
},
/**