зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1148893 - Replace .then handlers with yields to catch 'Unknown sheet source' rejections in Style Editor onShow task. r=ejpbruel
This commit is contained in:
Родитель
63f9ca53ff
Коммит
cd332ecd32
|
@ -550,30 +550,29 @@ StyleEditorUI.prototype = {
|
|||
this.emit("editor-selected", editor);
|
||||
|
||||
// Is there any CSS coverage markup to include?
|
||||
csscoverage.getUsage(this._target).then(usage => {
|
||||
if (usage == null) {
|
||||
return;
|
||||
let usage = yield csscoverage.getUsage(this._target);
|
||||
if (usage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
let href = csscoverage.sheetToUrl(editor.styleSheet);
|
||||
let data = yield usage.createEditorReport(href)
|
||||
|
||||
editor.removeAllUnusedRegions();
|
||||
|
||||
if (data.reports.length > 0) {
|
||||
// Only apply if this file isn't compressed. We detect a
|
||||
// compressed file if there are more rules than lines.
|
||||
let text = editor.sourceEditor.getText();
|
||||
let lineCount = text.split("\n").length;
|
||||
let ruleCount = editor.styleSheet.ruleCount;
|
||||
if (lineCount >= ruleCount) {
|
||||
editor.addUnusedRegions(data.reports);
|
||||
}
|
||||
|
||||
let href = csscoverage.sheetToUrl(editor.styleSheet);
|
||||
usage.createEditorReport(href).then(data => {
|
||||
editor.removeAllUnusedRegions();
|
||||
|
||||
if (data.reports.length > 0) {
|
||||
// Only apply if this file isn't compressed. We detect a
|
||||
// compressed file if there are more rules than lines.
|
||||
let text = editor.sourceEditor.getText();
|
||||
let lineCount = text.split("\n").length;
|
||||
let ruleCount = editor.styleSheet.ruleCount;
|
||||
if (lineCount >= ruleCount) {
|
||||
editor.addUnusedRegions(data.reports);
|
||||
}
|
||||
else {
|
||||
this.emit("error", { key: "error-compressed", level: "info" });
|
||||
}
|
||||
}
|
||||
}, Cu.reportError);
|
||||
}, Cu.reportError);
|
||||
else {
|
||||
this.emit("error", { key: "error-compressed", level: "info" });
|
||||
}
|
||||
}
|
||||
}.bind(this)).then(null, Cu.reportError);
|
||||
}.bind(this)
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче