Bug 1027246 - replaced function with function* for generators. r=fitzgen
--- a/browser/devtools/projecteditor/lib/stores/local.js
+++ b/browser/devtools/projecteditor/lib/stores/local.js
@@ -103,17 +103,17 @@ var LocalStore = Class({
if (this.resources.has(path)) {
return promise.resolve(this.resources.get(path));
}
if (!this.contains(path)) {
return promise.reject(new Error(path + " does not belong to " + this.path));
}
- return Task.spawn(function() {
+ return Task.spawn(function*() {
let parent = yield this.resourceFor(OS.Path.dirname(path));
let info;
try {
info = yield OS.File.stat(path);
} catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
if (!options.create) {
throw ex;
--- a/browser/devtools/shadereditor/shadereditor.js
+++ b/browser/devtools/shadereditor/shadereditor.js
@@ -118,17 +118,17 @@ let EventsHandler = {
},
/**
* Called for each location change in the debugged tab.
*/
_onTabNavigated: function(event, {isFrameSwitching}) {
switch (event) {
case "will-navigate": {
- Task.spawn(function() {
+ Task.spawn(function*() {
// Make sure the backend is prepared to handle WebGL contexts.
if (!isFrameSwitching) {
gFront.setup({ reload: false });
}
// Reset UI.
ShadersListView.empty();
// When switching to an iframe, ensure displaying the reload button.
@@ -389,17 +389,17 @@ let ShadersEditorsView = {
*/
setText: function(sources) {
let view = this;
function setTextAndClearHistory(editor, text) {
editor.setText(text);
editor.clearHistory();
}
- return Task.spawn(function() {
+ return Task.spawn(function*() {
yield view._toggleListeners("off");
yield promise.all([
view._getEditor("vs").then(e => setTextAndClearHistory(e, sources.vs)),
view._getEditor("fs").then(e => setTextAndClearHistory(e, sources.fs))
]);
yield view._toggleListeners("on");
}).then(() => window.emit(EVENTS.SOURCES_SHOWN, sources));
},
@@ -485,17 +485,17 @@ let ShadersEditorsView = {
/**
* Recompiles the source code for the shader being edited.
* This function is fired at a certain delay after the user stops typing.
*
* @param string type
* The corresponding shader type for the focused editor (e.g. "vs").
*/
_doCompile: function(type) {
- Task.spawn(function() {
+ Task.spawn(function*() {
let editor = yield this._getEditor(type);
let shaderActor = yield ShadersListView.selectedAttachment[type];
try {
yield shaderActor.compile(editor.getText());
this._onSuccessfulCompilation();
} catch (e) {
this._onFailedCompilation(type, editor, e);
--- a/toolkit/devtools/server/actors/stylesheets.js
+++ b/toolkit/devtools/server/actors/stylesheets.js
@@ -94,17 +94,17 @@ let StyleSheetsActor = exports.StyleShee
/**
* Add all the stylesheets in this document and its subframes.
* Assumes the document is loaded.
*
* @return {Promise}
* Promise that resolves with an array of StyleSheetActors
*/
_addAllStyleSheets: function() {
- return Task.spawn(function() {
+ return Task.spawn(function*() {
let documents = [this.document];
let actors = [];
for (let doc of documents) {
let sheets = yield this._addStyleSheets(doc.styleSheets);
actors = actors.concat(sheets);
// Recursively handle style sheets of the documents in iframes.
@@ -127,17 +127,17 @@ let StyleSheetsActor = exports.StyleShee
* @param {[DOMStyleSheet]} styleSheets
* Stylesheets to add
*
* @return {Promise}
* Promise that resolves to an array of StyleSheetActors
*/
_addStyleSheets: function(styleSheets)
{
- return Task.spawn(function() {
+ return Task.spawn(function*() {
let actors = [];
for (let i = 0; i < styleSheets.length; i++) {
let actor = this.parentActor.createStyleSheetActor(styleSheets[i]);
actors.push(actor);
// Get all sheets, including imported ones
let imports = yield this._getImported(actor);
actors = actors.concat(imports);
@@ -150,17 +150,17 @@ let StyleSheetsActor = exports.StyleShee
* Get all the stylesheets @imported from a stylesheet.
*
* @param {DOMStyleSheet} styleSheet
* Style sheet to search
* @return {Promise}
* A promise that resolves with an array of StyleSheetActors
*/
_getImported: function(styleSheet) {
- return Task.spawn(function() {
+ return Task.spawn(function*() {
let rules = yield styleSheet.getCSSRules();
let imported = [];
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.