зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1384789 - Check ancestor URLs to avoid sheet cycles. r=bgrins
With Stylo, an import rule from a cycle _will_ have a `styleSheet` object, so we need to also check the sheet's ancestors to see if the URL is unique. MozReview-Commit-ID: B33REaSGGYU --HG-- extra : rebase_source : d6113d802d5197c73510ac3fa3b6cfb31d29c609
This commit is contained in:
Родитель
edcbffb572
Коммит
965f38d565
|
@ -931,9 +931,14 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
|||
for (let i = 0; i < rules.length; i++) {
|
||||
let rule = rules[i];
|
||||
if (rule.type == Ci.nsIDOMCSSRule.IMPORT_RULE) {
|
||||
// Associated styleSheet may be null if it has already been seen due
|
||||
// to duplicate @imports for the same URL.
|
||||
if (!rule.styleSheet || !this._shouldListSheet(doc, rule.styleSheet)) {
|
||||
// With the Gecko style system, the associated styleSheet may be null
|
||||
// if it has already been seen because an import cycle for the same
|
||||
// URL. With Stylo, the styleSheet will exist (which is correct per
|
||||
// the latest CSSOM spec), so we also need to check ancestors for the
|
||||
// same URL to avoid cycles.
|
||||
let sheet = rule.styleSheet;
|
||||
if (!sheet || this._haveAncestorWithSameURL(sheet) ||
|
||||
!this._shouldListSheet(doc, sheet)) {
|
||||
continue;
|
||||
}
|
||||
let actor = this.parentActor.createStyleSheetActor(rule.styleSheet);
|
||||
|
@ -952,6 +957,23 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
|||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Check all ancestors to see if this sheet's URL matches theirs as a way to
|
||||
* detect an import cycle.
|
||||
*
|
||||
* @param {DOMStyleSheet} sheet
|
||||
*/
|
||||
_haveAncestorWithSameURL(sheet) {
|
||||
let sheetHref = sheet.href;
|
||||
while (sheet.parentStyleSheet) {
|
||||
if (sheet.parentStyleSheet.href == sheetHref) {
|
||||
return true;
|
||||
}
|
||||
sheet = sheet.parentStyleSheet;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a new style sheet in the document with the given text.
|
||||
* Return an actor for it.
|
||||
|
|
Загрузка…
Ссылка в новой задаче