| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 * Implements Source Map V3 model. See https://github.com/google/closure-compile
r/wiki/Source-Maps | 164 * Implements Source Map V3 model. See https://github.com/google/closure-compile
r/wiki/Source-Maps |
| 165 * for format description. | 165 * for format description. |
| 166 * @constructor | 166 * @constructor |
| 167 * @implements {WebInspector.SourceMap} | 167 * @implements {WebInspector.SourceMap} |
| 168 * @param {string} compiledURL | 168 * @param {string} compiledURL |
| 169 * @param {string} sourceMappingURL | 169 * @param {string} sourceMappingURL |
| 170 * @param {!SourceMapV3} payload | 170 * @param {!SourceMapV3} payload |
| 171 */ | 171 */ |
| 172 WebInspector.TextSourceMap = function(compiledURL, sourceMappingURL, payload) | 172 WebInspector.TextSourceMap = function(compiledURL, sourceMappingURL, payload) |
| 173 { | 173 { |
| 174 if (!WebInspector.TextSourceMap.prototype._base64Map) { | 174 if (!WebInspector.TextSourceMap._base64Map) { |
| 175 const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx
yz0123456789+/"; | 175 const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx
yz0123456789+/"; |
| 176 WebInspector.TextSourceMap.prototype._base64Map = {}; | 176 WebInspector.TextSourceMap._base64Map = {}; |
| 177 for (var i = 0; i < base64Digits.length; ++i) | 177 for (var i = 0; i < base64Digits.length; ++i) |
| 178 WebInspector.TextSourceMap.prototype._base64Map[base64Digits.charAt(
i)] = i; | 178 WebInspector.TextSourceMap._base64Map[base64Digits.charAt(i)] = i; |
| 179 } | 179 } |
| 180 | 180 |
| 181 this._json = payload; | 181 this._json = payload; |
| 182 this._compiledURL = compiledURL; | 182 this._compiledURL = compiledURL; |
| 183 this._sourceMappingURL = sourceMappingURL; | 183 this._sourceMappingURL = sourceMappingURL; |
| 184 /** @type {?Array<!WebInspector.SourceMapEntry>} */ | 184 /** @type {?Array<!WebInspector.SourceMapEntry>} */ |
| 185 this._mappings = null; | 185 this._mappings = null; |
| 186 /** @type {!Map<string, !WebInspector.TextSourceMap.SourceInfo>} */ | 186 /** @type {!Map<string, !WebInspector.TextSourceMap.SourceInfo>} */ |
| 187 this._sourceInfos = new Map(); | 187 this._sourceInfos = new Map(); |
| 188 this._eachSection(this._parseSources.bind(this)); | 188 this._eachSection(this._parseSources.bind(this)); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 WebInspector.TextSourceMap._VLQ_BASE_SHIFT = 5; |
| 192 WebInspector.TextSourceMap._VLQ_BASE_MASK = (1 << 5) - 1; |
| 193 WebInspector.TextSourceMap._VLQ_CONTINUATION_MASK = 1 << 5; |
| 194 |
| 191 /** | 195 /** |
| 192 * @param {string} sourceMapURL | 196 * @param {string} sourceMapURL |
| 193 * @param {string} compiledURL | 197 * @param {string} compiledURL |
| 194 * @return {!Promise<?WebInspector.TextSourceMap>} | 198 * @return {!Promise<?WebInspector.TextSourceMap>} |
| 195 * @this {WebInspector.TextSourceMap} | 199 * @this {WebInspector.TextSourceMap} |
| 196 */ | 200 */ |
| 197 WebInspector.TextSourceMap.load = function(sourceMapURL, compiledURL) | 201 WebInspector.TextSourceMap.load = function(sourceMapURL, compiledURL) |
| 198 { | 202 { |
| 199 var callback; | 203 var callback; |
| 200 var promise = new Promise(fulfill => callback = fulfill); | 204 var promise = new Promise(fulfill => callback = fulfill); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 /** | 500 /** |
| 497 * @param {!WebInspector.TextSourceMap.StringCharIterator} stringCharIterato
r | 501 * @param {!WebInspector.TextSourceMap.StringCharIterator} stringCharIterato
r |
| 498 * @return {number} | 502 * @return {number} |
| 499 */ | 503 */ |
| 500 _decodeVLQ: function(stringCharIterator) | 504 _decodeVLQ: function(stringCharIterator) |
| 501 { | 505 { |
| 502 // Read unsigned value. | 506 // Read unsigned value. |
| 503 var result = 0; | 507 var result = 0; |
| 504 var shift = 0; | 508 var shift = 0; |
| 505 do { | 509 do { |
| 506 var digit = this._base64Map[stringCharIterator.next()]; | 510 var digit = WebInspector.TextSourceMap._base64Map[stringCharIterator
.next()]; |
| 507 result += (digit & this._VLQ_BASE_MASK) << shift; | 511 result += (digit & WebInspector.TextSourceMap._VLQ_BASE_MASK) << shi
ft; |
| 508 shift += this._VLQ_BASE_SHIFT; | 512 shift += WebInspector.TextSourceMap._VLQ_BASE_SHIFT; |
| 509 } while (digit & this._VLQ_CONTINUATION_MASK); | 513 } while (digit & WebInspector.TextSourceMap._VLQ_CONTINUATION_MASK); |
| 510 | 514 |
| 511 // Fix the sign. | 515 // Fix the sign. |
| 512 var negative = result & 1; | 516 var negative = result & 1; |
| 513 result >>= 1; | 517 result >>= 1; |
| 514 return negative ? -result : result; | 518 return negative ? -result : result; |
| 515 }, | 519 }, |
| 516 | 520 |
| 517 /** | 521 /** |
| 518 * @param {string} url | 522 * @param {string} url |
| 519 * @param {!WebInspector.TextRange} textRange | 523 * @param {!WebInspector.TextRange} textRange |
| (...skipping 14 matching lines...) Expand all Loading... |
| 534 return position.columnNumber - mapping.sourceColumnNumber; | 538 return position.columnNumber - mapping.sourceColumnNumber; |
| 535 } | 539 } |
| 536 | 540 |
| 537 var mappings = this._reversedMappings(url); | 541 var mappings = this._reversedMappings(url); |
| 538 var startIndex = mappings.lowerBound({lineNumber: textRange.startLine, c
olumnNumber: textRange.startColumn}, comparator); | 542 var startIndex = mappings.lowerBound({lineNumber: textRange.startLine, c
olumnNumber: textRange.startColumn}, comparator); |
| 539 var endIndex = mappings.upperBound({lineNumber: textRange.endLine, colum
nNumber: textRange.endColumn}, comparator); | 543 var endIndex = mappings.upperBound({lineNumber: textRange.endLine, colum
nNumber: textRange.endColumn}, comparator); |
| 540 | 544 |
| 541 var startMapping = mappings[startIndex]; | 545 var startMapping = mappings[startIndex]; |
| 542 var endMapping = mappings[endIndex]; | 546 var endMapping = mappings[endIndex]; |
| 543 return new WebInspector.TextRange(startMapping.lineNumber, startMapping.
columnNumber, endMapping.lineNumber, endMapping.columnNumber); | 547 return new WebInspector.TextRange(startMapping.lineNumber, startMapping.
columnNumber, endMapping.lineNumber, endMapping.columnNumber); |
| 544 }, | 548 } |
| 545 | |
| 546 _VLQ_BASE_SHIFT: 5, | |
| 547 _VLQ_BASE_MASK: (1 << 5) - 1, | |
| 548 _VLQ_CONTINUATION_MASK: 1 << 5 | |
| 549 }; | 549 }; |
| 550 | 550 |
| 551 /** | 551 /** |
| 552 * @constructor | 552 * @constructor |
| 553 * @param {string} string | 553 * @param {string} string |
| 554 */ | 554 */ |
| 555 WebInspector.TextSourceMap.StringCharIterator = function(string) | 555 WebInspector.TextSourceMap.StringCharIterator = function(string) |
| 556 { | 556 { |
| 557 this._string = string; | 557 this._string = string; |
| 558 this._position = 0; | 558 this._position = 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 588 * @constructor | 588 * @constructor |
| 589 * @param {?string} content | 589 * @param {?string} content |
| 590 * @param {?Array<!WebInspector.SourceMapEntry>} reverseMappings | 590 * @param {?Array<!WebInspector.SourceMapEntry>} reverseMappings |
| 591 */ | 591 */ |
| 592 WebInspector.TextSourceMap.SourceInfo = function(content, reverseMappings) { | 592 WebInspector.TextSourceMap.SourceInfo = function(content, reverseMappings) { |
| 593 this.content = content; | 593 this.content = content; |
| 594 this.reverseMappings = reverseMappings; | 594 this.reverseMappings = reverseMappings; |
| 595 }; | 595 }; |
| 596 | 596 |
| 597 WebInspector.TextSourceMap._sourcesListSymbol = Symbol("sourcesList"); | 597 WebInspector.TextSourceMap._sourcesListSymbol = Symbol("sourcesList"); |
| OLD | NEW |