Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js

Issue 1954423002: DevTools: introduce CSSStyleSheetHeader.originalContentProvider() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify-network-project
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3ca043e94455d814e7afeccb06c0a6791b773aaf 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,18 @@ WebInspector.CSSStyleSheetHeader = function(cssModel, payload)
WebInspector.CSSStyleSheetHeader.prototype = {
/**
+ * @return {!WebInspector.ContentProvider}
+ */
+ originalContentProvider: function()
+ {
+ if (!this._originalContentProvider) {
+ var originalContentPromise = this._cssModel.originalStyleSheetText(this);
+ this._originalContentProvider = new WebInspector.StaticContentProvider(this.contentURL(), this.contentType(), originalContentPromise);
+ }
+ return this._originalContentProvider;
+ },
+
+ /**
* @param {string=} sourceMapURL
*/
setSourceMapURL: function(sourceMapURL)
@@ -123,6 +135,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 +160,62 @@ WebInspector.CSSStyleSheetHeader.prototype = {
}
}
+/**
+ * @constructor
+ * @implements {WebInspector.ContentProvider}
+ * @param {!WebInspector.CSSStyleSheetHeader} header
+ */
+WebInspector.CSSStyleSheetHeader.OriginalContentProvider = function(header)
+{
+ 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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698