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

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: 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 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 var originalContentPromise = this._cssModel.originalStyleSheetText(t his);
37 this._originalContentProvider = new WebInspector.StaticContentProvid er(this.contentURL(), this.contentType(), originalContentPromise);
38 }
39 return this._originalContentProvider;
40 },
41
42 /**
31 * @param {string=} sourceMapURL 43 * @param {string=} sourceMapURL
32 */ 44 */
33 setSourceMapURL: function(sourceMapURL) 45 setSourceMapURL: function(sourceMapURL)
34 { 46 {
35 var completeSourceMapURL = this.sourceURL && sourceMapURL ? WebInspector .ParsedURL.completeURL(this.sourceURL, sourceMapURL) : null; 47 var completeSourceMapURL = this.sourceURL && sourceMapURL ? WebInspector .ParsedURL.completeURL(this.sourceURL, sourceMapURL) : null;
36 this.sourceMapURL = completeSourceMapURL; 48 this.sourceMapURL = completeSourceMapURL;
37 }, 49 },
38 50
39 /** 51 /**
40 * @return {!WebInspector.Target} 52 * @return {!WebInspector.Target}
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 * @override 128 * @override
117 * @return {!Promise<?string>} 129 * @return {!Promise<?string>}
118 */ 130 */
119 requestContent: function() 131 requestContent: function()
120 { 132 {
121 return /** @type {!Promise<?string>} */(this._cssModel.getStyleSheetText (this.id)); 133 return /** @type {!Promise<?string>} */(this._cssModel.getStyleSheetText (this.id));
122 }, 134 },
123 135
124 /** 136 /**
125 * @override 137 * @override
138 * @param {string} query
139 * @param {boolean} caseSensitive
140 * @param {boolean} isRegex
141 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
126 */ 142 */
127 searchInContent: function(query, caseSensitive, isRegex, callback) 143 searchInContent: function(query, caseSensitive, isRegex, callback)
128 { 144 {
129 function performSearch(content) 145 function performSearch(content)
130 { 146 {
131 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex)); 147 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex));
132 } 148 }
133 149
134 // searchInContent should call back later. 150 // searchInContent should call back later.
135 this.requestContent().then(performSearch); 151 this.requestContent().then(performSearch);
136 }, 152 },
137 153
138 /** 154 /**
139 * @return {boolean} 155 * @return {boolean}
140 */ 156 */
141 isViaInspector: function() 157 isViaInspector: function()
142 { 158 {
143 return this.origin === "inspector"; 159 return this.origin === "inspector";
144 } 160 }
145 } 161 }
146 162
163 /**
164 * @constructor
165 * @implements {WebInspector.ContentProvider}
166 * @param {!WebInspector.CSSStyleSheetHeader} header
167 */
168 WebInspector.CSSStyleSheetHeader.OriginalContentProvider = function(header)
169 {
170 this._header = header;
171 }
172
173 WebInspector.CSSStyleSheetHeader.OriginalContentProvider.prototype = {
174 /**
175 * @override
176 * @return {string}
177 */
178 contentURL: function()
179 {
180 return this._header.contentURL();
181 },
182
183 /**
184 * @override
185 * @return {!WebInspector.ResourceType}
186 */
187 contentType: function()
188 {
189 return this._header.contentType();
190 },
191
192 /**
193 * @override
194 * @return {!Promise<?string>}
195 */
196 requestContent: function()
197 {
198 return /** @type {!Promise<?string>} */(this._header.cssModel().original StyleSheetText(this._header));
199 },
200
201 /**
202 * @override
203 * @param {string} query
204 * @param {boolean} caseSensitive
205 * @param {boolean} isRegex
206 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
207 */
208 searchInContent: function(query, caseSensitive, isRegex, callback)
209 {
210 /**
211 * @param {?string} content
212 */
213 function performSearch(content)
214 {
215 var searchResults = content ? WebInspector.ContentProvider.performSe archInContent(content, query, caseSensitive, isRegex) : [];
216 callback(searchResults);
217 }
218
219 this.requestContent().then(performSearch);
220 }
221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698