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

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

Issue 2695123004: DevTools: Only provide static script content to UISourceCode (Closed)
Patch Set: another try Created 3 years, 9 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 * @implements {Common.ContentProvider} 5 * @implements {Common.ContentProvider}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 SDK.CSSStyleSheetHeader = class { 8 SDK.CSSStyleSheetHeader = class {
9 /** 9 /**
10 * @param {!SDK.CSSModel} cssModel 10 * @param {!SDK.CSSModel} cssModel
(...skipping 15 matching lines...) Expand all
26 this.ownerNode = new SDK.DeferredDOMNode(cssModel.target(), payload.ownerN ode); 26 this.ownerNode = new SDK.DeferredDOMNode(cssModel.target(), payload.ownerN ode);
27 this.setSourceMapURL(payload.sourceMapURL); 27 this.setSourceMapURL(payload.sourceMapURL);
28 } 28 }
29 29
30 /** 30 /**
31 * @return {!Common.ContentProvider} 31 * @return {!Common.ContentProvider}
32 */ 32 */
33 originalContentProvider() { 33 originalContentProvider() {
34 if (!this._originalContentProvider) { 34 if (!this._originalContentProvider) {
35 var lazyContent = this._cssModel.originalStyleSheetText.bind(this._cssMode l, this); 35 var lazyContent = this._cssModel.originalStyleSheetText.bind(this._cssMode l, this);
36 this._originalContentProvider = 36 this._originalContentProvider = new Common.StaticContentProvider(
37 new Common.StaticContentProvider(this.contentURL(), this.contentType() , lazyContent); 37 this.contentURL(), this.contentType(), /** @type {function():!Promise< ?string>} */ (lazyContent));
38 } 38 }
39 return this._originalContentProvider; 39 return this._originalContentProvider;
40 } 40 }
41 41
42 /** 42 /**
43 * @param {string=} sourceMapURL 43 * @param {string=} sourceMapURL
44 */ 44 */
45 setSourceMapURL(sourceMapURL) { 45 setSourceMapURL(sourceMapURL) {
46 var completeSourceMapURL = 46 var completeSourceMapURL =
47 this.sourceURL && sourceMapURL ? Common.ParsedURL.completeURL(this.sourc eURL, sourceMapURL) : sourceMapURL; 47 this.sourceURL && sourceMapURL ? Common.ParsedURL.completeURL(this.sourc eURL, sourceMapURL) : sourceMapURL;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 this.requestContent().then(performSearch); 148 this.requestContent().then(performSearch);
149 } 149 }
150 150
151 /** 151 /**
152 * @return {boolean} 152 * @return {boolean}
153 */ 153 */
154 isViaInspector() { 154 isViaInspector() {
155 return this.origin === 'inspector'; 155 return this.origin === 'inspector';
156 } 156 }
157 }; 157 };
158
159 /**
160 * @implements {Common.ContentProvider}
161 * @unrestricted
162 */
163 SDK.CSSStyleSheetHeader.OriginalContentProvider = class {
164 /**
165 * @param {!SDK.CSSStyleSheetHeader} header
166 */
167 constructor(header) {
168 this._header = header;
169 }
170
171 /**
172 * @override
173 * @return {string}
174 */
175 contentURL() {
176 return this._header.contentURL();
177 }
178
179 /**
180 * @override
181 * @return {!Common.ResourceType}
182 */
183 contentType() {
184 return this._header.contentType();
185 }
186
187 /**
188 * @override
189 * @return {!Promise<?string>}
190 */
191 requestContent() {
192 return /** @type {!Promise<?string>} */ (this._header.cssModel().originalSty leSheetText(this._header));
193 }
194
195 /**
196 * @override
197 * @param {string} query
198 * @param {boolean} caseSensitive
199 * @param {boolean} isRegex
200 * @param {function(!Array.<!Common.ContentProvider.SearchMatch>)} callback
201 */
202 searchInContent(query, caseSensitive, isRegex, callback) {
203 /**
204 * @param {?string} content
205 */
206 function performSearch(content) {
207 var searchResults =
208 content ? Common.ContentProvider.performSearchInContent(content, query , caseSensitive, isRegex) : [];
209 callback(searchResults);
210 }
211
212 this.requestContent().then(performSearch);
213 }
214 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698