Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 this.columnOffset = startColumn; | 64 this.columnOffset = startColumn; |
| 65 this.endLine = endLine; | 65 this.endLine = endLine; |
| 66 this.endColumn = endColumn; | 66 this.endColumn = endColumn; |
| 67 | 67 |
| 68 this._executionContextId = executionContextId; | 68 this._executionContextId = executionContextId; |
| 69 this.hash = hash; | 69 this.hash = hash; |
| 70 this._isContentScript = isContentScript; | 70 this._isContentScript = isContentScript; |
| 71 this._isLiveEdit = isLiveEdit; | 71 this._isLiveEdit = isLiveEdit; |
| 72 this.sourceMapURL = sourceMapURL; | 72 this.sourceMapURL = sourceMapURL; |
| 73 this.hasSourceURL = hasSourceURL; | 73 this.hasSourceURL = hasSourceURL; |
| 74 this._originalContentProvider = null; | |
| 75 this._originalSource = null; | |
| 74 } | 76 } |
| 75 | 77 |
| 76 /** | 78 /** |
| 77 * @param {string} source | 79 * @param {string} source |
| 78 * @return {string} | 80 * @return {string} |
| 79 */ | 81 */ |
| 80 static _trimSourceURLComment(source) { | 82 static _trimSourceURLComment(source) { |
| 81 var sourceURLIndex = source.lastIndexOf('//# sourceURL='); | 83 var sourceURLIndex = source.lastIndexOf('//# sourceURL='); |
| 82 if (sourceURLIndex === -1) { | 84 if (sourceURLIndex === -1) { |
| 83 sourceURLIndex = source.lastIndexOf('//@ sourceURL='); | 85 sourceURLIndex = source.lastIndexOf('//@ sourceURL='); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 * @param {?Protocol.Error} error | 181 * @param {?Protocol.Error} error |
| 180 * @param {string} source | 182 * @param {string} source |
| 181 */ | 183 */ |
| 182 function didGetScriptSource(error, source) { | 184 function didGetScriptSource(error, source) { |
| 183 if (!error) { | 185 if (!error) { |
| 184 SDK.Script._reportDeprecatedCommentIfNeeded(this, source); | 186 SDK.Script._reportDeprecatedCommentIfNeeded(this, source); |
| 185 this._source = SDK.Script._trimSourceURLComment(source); | 187 this._source = SDK.Script._trimSourceURLComment(source); |
| 186 } else { | 188 } else { |
| 187 this._source = ''; | 189 this._source = ''; |
| 188 } | 190 } |
| 191 if (this._originalSource === null) | |
| 192 this._originalSource = this._source; | |
| 189 callback(this._source); | 193 callback(this._source); |
| 190 } | 194 } |
| 191 } | 195 } |
| 192 | 196 |
| 193 /** | 197 /** |
| 198 * @return {!Common.ContentProvider} | |
| 199 */ | |
| 200 originalContentProvider() { | |
| 201 if (!this._originalContentProvider) { | |
|
pfeldman
2017/02/27 22:56:09
return this.requestContent().then(() => this._orig
einbinder
2017/02/28 00:51:22
() => this.requestContent().then(() => this._origi
| |
| 202 var lazyContent = this._requestOriginalContent.bind(this); | |
| 203 this._originalContentProvider = | |
| 204 new Common.StaticContentProvider(this.contentURL(), this.contentType() , lazyContent); | |
| 205 } | |
| 206 return this._originalContentProvider; | |
| 207 } | |
| 208 | |
| 209 /** | |
| 210 * @return {!Promise<?string>} | |
| 211 */ | |
| 212 _requestOriginalContent() { | |
| 213 if (this._originalSource === null) | |
| 214 return this.requestContent(); | |
| 215 return Promise.resolve(/** @type {?string} */ (this._originalSource)); | |
| 216 } | |
| 217 | |
| 218 /** | |
| 194 * @override | 219 * @override |
| 195 * @param {string} query | 220 * @param {string} query |
| 196 * @param {boolean} caseSensitive | 221 * @param {boolean} caseSensitive |
| 197 * @param {boolean} isRegex | 222 * @param {boolean} isRegex |
| 198 * @param {function(!Array.<!Protocol.Debugger.SearchMatch>)} callback | 223 * @param {function(!Array.<!Protocol.Debugger.SearchMatch>)} callback |
| 199 */ | 224 */ |
| 200 searchInContent(query, caseSensitive, isRegex, callback) { | 225 searchInContent(query, caseSensitive, isRegex, callback) { |
| 201 /** | 226 /** |
| 202 * @param {?Protocol.Error} error | 227 * @param {?Protocol.Error} error |
| 203 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches | 228 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 this._source = newSource; | 279 this._source = newSource; |
| 255 var needsStepIn = !!stackChanged; | 280 var needsStepIn = !!stackChanged; |
| 256 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn ); | 281 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn ); |
| 257 } | 282 } |
| 258 | 283 |
| 259 newSource = SDK.Script._trimSourceURLComment(newSource); | 284 newSource = SDK.Script._trimSourceURLComment(newSource); |
| 260 // We append correct sourceURL to script for consistency only. It's not actu ally needed for things to work correctly. | 285 // We append correct sourceURL to script for consistency only. It's not actu ally needed for things to work correctly. |
| 261 newSource = this._appendSourceURLCommentIfNeeded(newSource); | 286 newSource = this._appendSourceURLCommentIfNeeded(newSource); |
| 262 | 287 |
| 263 if (this.scriptId) { | 288 if (this.scriptId) { |
| 264 this.debuggerModel.target().debuggerAgent().setScriptSource( | 289 this._requestOriginalContent().then( |
| 265 this.scriptId, newSource, undefined, didEditScriptSource.bind(this)); | 290 () => this.debuggerModel.target().debuggerAgent().setScriptSource( |
| 291 this.scriptId, newSource, undefined, didEditScriptSource.bind(this ))); | |
| 266 } else { | 292 } else { |
| 267 callback('Script failed to parse'); | 293 callback('Script failed to parse'); |
| 268 } | 294 } |
| 269 } | 295 } |
| 270 | 296 |
| 271 /** | 297 /** |
| 272 * @param {number} lineNumber | 298 * @param {number} lineNumber |
| 273 * @param {number=} columnNumber | 299 * @param {number=} columnNumber |
| 274 * @return {!SDK.DebuggerModel.Location} | 300 * @return {!SDK.DebuggerModel.Location} |
| 275 */ | 301 */ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 function callback(error) { | 355 function callback(error) { |
| 330 if (error) | 356 if (error) |
| 331 console.error(error); | 357 console.error(error); |
| 332 fulfill(!error); | 358 fulfill(!error); |
| 333 } | 359 } |
| 334 } | 360 } |
| 335 } | 361 } |
| 336 }; | 362 }; |
| 337 | 363 |
| 338 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; | 364 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; |
| OLD | NEW |