Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js b/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js |
| index 77696bb6f323c1895400ad717dc6d90d2ebb701e..ed3921f35ea96a14aa2b661d042f98b6317d07df 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js |
| @@ -28,6 +28,16 @@ WebInspector.CSSStyleSheetHeader = function(cssModel, payload) |
| WebInspector.CSSStyleSheetHeader.prototype = { |
| /** |
| + * @return {!WebInspector.ContentProvider} |
| + */ |
| + originalContentProvider: function() |
| + { |
| + if (!this._originalContentProvider) |
| + this._originalContentProvider = new WebInspector.CSSStyleSheetHeader.OriginalContentProvider(this); |
| + return this._originalContentProvider; |
| + }, |
| + |
| + /** |
| * @param {string=} sourceMapURL |
| */ |
| setSourceMapURL: function(sourceMapURL) |
| @@ -123,6 +133,10 @@ WebInspector.CSSStyleSheetHeader.prototype = { |
| /** |
| * @override |
| + * @param {string} query |
| + * @param {boolean} caseSensitive |
| + * @param {boolean} isRegex |
| + * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback |
| */ |
| searchInContent: function(query, caseSensitive, isRegex, callback) |
| { |
| @@ -144,3 +158,62 @@ WebInspector.CSSStyleSheetHeader.prototype = { |
| } |
| } |
| +/** |
| + * @constructor |
| + * @implements {WebInspector.ContentProvider} |
| + * @param {!WebInspector.CSSStyleSheetHeader} header |
| + */ |
| +WebInspector.CSSStyleSheetHeader.OriginalContentProvider = function(header) |
|
dgozman
2016/05/10 18:09:37
Let's modify StaticContentProvider to accept Promi
lushnikov
2016/05/10 20:16:39
Done.
|
| +{ |
| + this._header = header; |
| +} |
| + |
| +WebInspector.CSSStyleSheetHeader.OriginalContentProvider.prototype = { |
| + /** |
| + * @override |
| + * @return {string} |
| + */ |
| + contentURL: function() |
| + { |
| + return this._header.contentURL(); |
| + }, |
| + |
| + /** |
| + * @override |
| + * @return {!WebInspector.ResourceType} |
| + */ |
| + contentType: function() |
| + { |
| + return this._header.contentType(); |
| + }, |
| + |
| + /** |
| + * @override |
| + * @return {!Promise<?string>} |
| + */ |
| + requestContent: function() |
| + { |
| + return /** @type {!Promise<?string>} */(this._header.cssModel().originalStyleSheetText(this._header)); |
| + }, |
| + |
| + /** |
| + * @override |
| + * @param {string} query |
| + * @param {boolean} caseSensitive |
| + * @param {boolean} isRegex |
| + * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback |
| + */ |
| + searchInContent: function(query, caseSensitive, isRegex, callback) |
| + { |
| + /** |
| + * @param {?string} content |
| + */ |
| + function performSearch(content) |
| + { |
| + var searchResults = content ? WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex) : []; |
| + callback(searchResults); |
| + } |
| + |
| + this.requestContent().then(performSearch); |
| + } |
| +} |