Chromium Code Reviews| Index: Source/devtools/front_end/bindings/StylesSourceMapping.js |
| diff --git a/Source/devtools/front_end/bindings/StylesSourceMapping.js b/Source/devtools/front_end/bindings/StylesSourceMapping.js |
| index 4d24f1f002469c611b709e3ffd1fa8573cb83e0d..dd69d55eb8bd965ab8df1c5d390ebdc85ab6da54 100644 |
| --- a/Source/devtools/front_end/bindings/StylesSourceMapping.js |
| +++ b/Source/devtools/front_end/bindings/StylesSourceMapping.js |
| @@ -247,32 +247,31 @@ WebInspector.StylesSourceMapping.prototype = { |
| * @param {!WebInspector.UISourceCode} uiSourceCode |
| * @param {string} content |
| * @param {boolean} majorChange |
| - * @param {function(?string)} userCallback |
| + * @return {!Promise<?string>} |
| */ |
| - _setStyleContent: function(uiSourceCode, content, majorChange, userCallback) |
| + _setStyleContent: function(uiSourceCode, content, majorChange) |
| { |
| var networkURL = this._networkMapping.networkURL(uiSourceCode); |
| var styleSheetIds = this._cssModel.styleSheetIdsForURL(networkURL); |
| - if (!styleSheetIds.length) { |
| - userCallback("No stylesheet found: " + networkURL); |
| - return; |
| - } |
| + if (!styleSheetIds.length) |
| + return Promise.resolve(/** @type {?string} */("No stylesheet found: " + networkURL)); |
| this._isSettingContent = true; |
| /** |
| - * @param {?Protocol.Error} error |
| * @this {WebInspector.StylesSourceMapping} |
| + * @return {?string} |
| */ |
| - function callback(error) |
| + function callback() |
| { |
| - userCallback(error); |
|
pfeldman
2015/06/26 09:13:42
If there was one stylesheet, a very common case, w
lushnikov
2015/06/26 12:33:28
Done.
|
| delete this._isSettingContent; |
| + return null; |
| } |
| - |
| + var promises = []; |
| for (var i = 0; i < styleSheetIds.length; ++i) |
| - this._cssModel.setStyleSheetText(styleSheetIds[i], content, majorChange, i === styleSheetIds.length - 1 ? callback.bind(this) : null); |
| + promises.push(this._cssModel.setStyleSheetText(styleSheetIds[i], content, majorChange)); |
| + return Promise.all(promises).then(callback.bind(this)); |
| }, |
| /** |
| @@ -382,19 +381,20 @@ WebInspector.StyleFile.prototype = { |
| */ |
| _commitIncrementalEdit: function(finishCallback) |
|
pfeldman
2015/06/26 09:13:42
Add fixme to make it a promise?
lushnikov
2015/06/26 12:33:28
Acknowledged.
|
| { |
| - this._mapping._setStyleContent(this._uiSourceCode, this._uiSourceCode.workingCopy(), this._isMajorChangePending, this._styleContentSet.bind(this, finishCallback)); |
| + this._mapping._setStyleContent(this._uiSourceCode, this._uiSourceCode.workingCopy(), this._isMajorChangePending) |
| + .then(this._styleContentSet.bind(this)) |
| + .then(finishCallback) |
| + .catch(/** @type {function()} */(finishCallback)); |
| this._isMajorChangePending = false; |
| }, |
| /** |
| - * @param {!WebInspector.Throttler.FinishCallback} finishCallback |
| * @param {?string} error |
| */ |
| - _styleContentSet: function(finishCallback, error) |
| + _styleContentSet: function(error) |
| { |
| if (error) |
| WebInspector.console.error(error); |
| - finishCallback(); |
| }, |
| /** |