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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.ContentProvider} 7 * @implements {WebInspector.ContentProvider}
8 * @param {!WebInspector.CSSModel} cssModel 8 * @param {!WebInspector.CSSModel} cssModel
9 * @param {!CSSAgent.CSSStyleSheetHeader} payload 9 * @param {!CSSAgent.CSSStyleSheetHeader} payload
10 */ 10 */
(...skipping 10 matching lines...) Expand all
21 this.isInline = payload.isInline; 21 this.isInline = payload.isInline;
22 this.startLine = payload.startLine; 22 this.startLine = payload.startLine;
23 this.startColumn = payload.startColumn; 23 this.startColumn = payload.startColumn;
24 if (payload.ownerNode) 24 if (payload.ownerNode)
25 this.ownerNode = new WebInspector.DeferredDOMNode(cssModel.target(), pay load.ownerNode); 25 this.ownerNode = new WebInspector.DeferredDOMNode(cssModel.target(), pay load.ownerNode);
26 this.setSourceMapURL(payload.sourceMapURL); 26 this.setSourceMapURL(payload.sourceMapURL);
27 } 27 }
28 28
29 WebInspector.CSSStyleSheetHeader.prototype = { 29 WebInspector.CSSStyleSheetHeader.prototype = {
30 /** 30 /**
31 * @return {!WebInspector.ContentProvider}
32 */
33 originalContentProvider: function()
34 {
35 if (!this._originalContentProvider)
36 this._originalContentProvider = new WebInspector.CSSStyleSheetHeader .OriginalContentProvider(this);
37 return this._originalContentProvider;
38 },
39
40 /**
31 * @param {string=} sourceMapURL 41 * @param {string=} sourceMapURL
32 */ 42 */
33 setSourceMapURL: function(sourceMapURL) 43 setSourceMapURL: function(sourceMapURL)
34 { 44 {
35 var completeSourceMapURL = this.sourceURL && sourceMapURL ? WebInspector .ParsedURL.completeURL(this.sourceURL, sourceMapURL) : null; 45 var completeSourceMapURL = this.sourceURL && sourceMapURL ? WebInspector .ParsedURL.completeURL(this.sourceURL, sourceMapURL) : null;
36 this.sourceMapURL = completeSourceMapURL; 46 this.sourceMapURL = completeSourceMapURL;
37 }, 47 },
38 48
39 /** 49 /**
40 * @return {!WebInspector.Target} 50 * @return {!WebInspector.Target}
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 * @override 126 * @override
117 * @return {!Promise<?string>} 127 * @return {!Promise<?string>}
118 */ 128 */
119 requestContent: function() 129 requestContent: function()
120 { 130 {
121 return /** @type {!Promise<?string>} */(this._cssModel.getStyleSheetText (this.id)); 131 return /** @type {!Promise<?string>} */(this._cssModel.getStyleSheetText (this.id));
122 }, 132 },
123 133
124 /** 134 /**
125 * @override 135 * @override
136 * @param {string} query
137 * @param {boolean} caseSensitive
138 * @param {boolean} isRegex
139 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
126 */ 140 */
127 searchInContent: function(query, caseSensitive, isRegex, callback) 141 searchInContent: function(query, caseSensitive, isRegex, callback)
128 { 142 {
129 function performSearch(content) 143 function performSearch(content)
130 { 144 {
131 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex)); 145 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex));
132 } 146 }
133 147
134 // searchInContent should call back later. 148 // searchInContent should call back later.
135 this.requestContent().then(performSearch); 149 this.requestContent().then(performSearch);
136 }, 150 },
137 151
138 /** 152 /**
139 * @return {boolean} 153 * @return {boolean}
140 */ 154 */
141 isViaInspector: function() 155 isViaInspector: function()
142 { 156 {
143 return this.origin === "inspector"; 157 return this.origin === "inspector";
144 } 158 }
145 } 159 }
146 160
161 /**
162 * @constructor
163 * @implements {WebInspector.ContentProvider}
164 * @param {!WebInspector.CSSStyleSheetHeader} header
165 */
166 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.
167 {
168 this._header = header;
169 }
170
171 WebInspector.CSSStyleSheetHeader.OriginalContentProvider.prototype = {
172 /**
173 * @override
174 * @return {string}
175 */
176 contentURL: function()
177 {
178 return this._header.contentURL();
179 },
180
181 /**
182 * @override
183 * @return {!WebInspector.ResourceType}
184 */
185 contentType: function()
186 {
187 return this._header.contentType();
188 },
189
190 /**
191 * @override
192 * @return {!Promise<?string>}
193 */
194 requestContent: function()
195 {
196 return /** @type {!Promise<?string>} */(this._header.cssModel().original StyleSheetText(this._header));
197 },
198
199 /**
200 * @override
201 * @param {string} query
202 * @param {boolean} caseSensitive
203 * @param {boolean} isRegex
204 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
205 */
206 searchInContent: function(query, caseSensitive, isRegex, callback)
207 {
208 /**
209 * @param {?string} content
210 */
211 function performSearch(content)
212 {
213 var searchResults = content ? WebInspector.ContentProvider.performSe archInContent(content, query, caseSensitive, isRegex) : [];
214 callback(searchResults);
215 }
216
217 this.requestContent().then(performSearch);
218 }
219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698