| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 this._reverseMappingsBySourceURL = new Map(); | 81 this._reverseMappingsBySourceURL = new Map(); |
| 82 this._mappings = []; | 82 this._mappings = []; |
| 83 this._sources = {}; | 83 this._sources = {}; |
| 84 this._sourceContentByURL = {}; | 84 this._sourceContentByURL = {}; |
| 85 this._parseMappingPayload(payload); | 85 this._parseMappingPayload(payload); |
| 86 } | 86 } |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {string} sourceMapURL | 89 * @param {string} sourceMapURL |
| 90 * @param {string} compiledURL | 90 * @param {string} compiledURL |
| 91 * @param {function(?WebInspector.SourceMap)} callback | 91 * @param {function(?WebInspector.SourceMap, string=)} callback |
| 92 * @this {WebInspector.SourceMap} | 92 * @this {WebInspector.SourceMap} |
| 93 */ | 93 */ |
| 94 WebInspector.SourceMap.load = function(sourceMapURL, compiledURL, callback) | 94 WebInspector.SourceMap.load = function(sourceMapURL, compiledURL, callback) |
| 95 { | 95 { |
| 96 WebInspector.multitargetNetworkManager.loadResource(sourceMapURL, contentLoa
ded); | 96 WebInspector.multitargetNetworkManager.loadResource(sourceMapURL, contentLoa
ded); |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @param {number} statusCode | 99 * @param {number} statusCode |
| 100 * @param {!Object.<string, string>} headers | 100 * @param {!Object.<string, string>} headers |
| 101 * @param {string} content | 101 * @param {string} content |
| 102 */ | 102 */ |
| 103 function contentLoaded(statusCode, headers, content) | 103 function contentLoaded(statusCode, headers, content) |
| 104 { | 104 { |
| 105 if (!content || statusCode >= 400) { | 105 if (!content || statusCode >= 400) { |
| 106 callback(null); | 106 callback(null); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 | 109 |
| 110 if (content.slice(0, 3) === ")]}") | 110 if (content.slice(0, 3) === ")]}") |
| 111 content = content.substring(content.indexOf('\n')); | 111 content = content.substring(content.indexOf('\n')); |
| 112 try { | 112 try { |
| 113 var payload = /** @type {!SourceMapV3} */ (JSON.parse(content)); | 113 var payload = /** @type {!SourceMapV3} */ (JSON.parse(content)); |
| 114 var baseURL = sourceMapURL.startsWith("data:") ? compiledURL : sourc
eMapURL; | 114 var baseURL = sourceMapURL.startsWith("data:") ? compiledURL : sourc
eMapURL; |
| 115 callback(new WebInspector.SourceMap(compiledURL, baseURL, payload)); | 115 callback(new WebInspector.SourceMap(compiledURL, baseURL, payload),
content); |
| 116 } catch(e) { | 116 } catch(e) { |
| 117 console.error(e.message); | 117 console.error(e.message); |
| 118 WebInspector.console.error("Failed to parse SourceMap: " + sourceMap
URL); | 118 WebInspector.console.error("Failed to parse SourceMap: " + sourceMap
URL); |
| 119 callback(null); | 119 callback(null); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 WebInspector.SourceMap.prototype = { | 124 WebInspector.SourceMap.prototype = { |
| 125 /** | 125 /** |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 * @param {number=} sourceColumnNumber | 416 * @param {number=} sourceColumnNumber |
| 417 */ | 417 */ |
| 418 WebInspector.SourceMap.Entry = function(lineNumber, columnNumber, sourceURL, sou
rceLineNumber, sourceColumnNumber) | 418 WebInspector.SourceMap.Entry = function(lineNumber, columnNumber, sourceURL, sou
rceLineNumber, sourceColumnNumber) |
| 419 { | 419 { |
| 420 this.lineNumber = lineNumber; | 420 this.lineNumber = lineNumber; |
| 421 this.columnNumber = columnNumber; | 421 this.columnNumber = columnNumber; |
| 422 this.sourceURL = sourceURL; | 422 this.sourceURL = sourceURL; |
| 423 this.sourceLineNumber = sourceLineNumber; | 423 this.sourceLineNumber = sourceLineNumber; |
| 424 this.sourceColumnNumber = sourceColumnNumber; | 424 this.sourceColumnNumber = sourceColumnNumber; |
| 425 } | 425 } |
| OLD | NEW |