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

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

Issue 2769843003: DevTools: split text_utils out of common module (Closed)
Patch Set: rebaseline 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 /* 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 * @return {?SDK.SourceMapEntry} 136 * @return {?SDK.SourceMapEntry}
137 */ 137 */
138 findEntry(lineNumber, columnNumber) {}, 138 findEntry(lineNumber, columnNumber) {},
139 139
140 /** 140 /**
141 * @return {boolean} 141 * @return {boolean}
142 */ 142 */
143 editable() {}, 143 editable() {},
144 144
145 /** 145 /**
146 * @param {!Array<!Common.TextRange>} ranges 146 * @param {!Array<!TextUtils.TextRange>} ranges
147 * @param {!Array<string>} texts 147 * @param {!Array<string>} texts
148 * @return {!Promise<?SDK.SourceMap.EditResult>} 148 * @return {!Promise<?SDK.SourceMap.EditResult>}
149 */ 149 */
150 editCompiled(ranges, texts) {}, 150 editCompiled(ranges, texts) {},
151 }; 151 };
152 152
153 /** 153 /**
154 * @unrestricted 154 * @unrestricted
155 */ 155 */
156 SDK.SourceMap.EditResult = class { 156 SDK.SourceMap.EditResult = class {
157 /** 157 /**
158 * @param {!SDK.SourceMap} map 158 * @param {!SDK.SourceMap} map
159 * @param {!Array<!Common.SourceEdit>} compiledEdits 159 * @param {!Array<!TextUtils.SourceEdit>} compiledEdits
160 * @param {!Map<string, string>} newSources 160 * @param {!Map<string, string>} newSources
161 */ 161 */
162 constructor(map, compiledEdits, newSources) { 162 constructor(map, compiledEdits, newSources) {
163 this.map = map; 163 this.map = map;
164 this.compiledEdits = compiledEdits; 164 this.compiledEdits = compiledEdits;
165 this.newSources = newSources; 165 this.newSources = newSources;
166 } 166 }
167 }; 167 };
168 168
169 /** 169 /**
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 /** 298 /**
299 * @override 299 * @override
300 * @return {boolean} 300 * @return {boolean}
301 */ 301 */
302 editable() { 302 editable() {
303 return false; 303 return false;
304 } 304 }
305 305
306 /** 306 /**
307 * @override 307 * @override
308 * @param {!Array<!Common.TextRange>} ranges 308 * @param {!Array<!TextUtils.TextRange>} ranges
309 * @param {!Array<string>} texts 309 * @param {!Array<string>} texts
310 * @return {!Promise<?SDK.SourceMap.EditResult>} 310 * @return {!Promise<?SDK.SourceMap.EditResult>}
311 */ 311 */
312 editCompiled(ranges, texts) { 312 editCompiled(ranges, texts) {
313 return Promise.resolve(/** @type {?SDK.SourceMap.EditResult} */ (null)); 313 return Promise.resolve(/** @type {?SDK.SourceMap.EditResult} */ (null));
314 } 314 }
315 315
316 /** 316 /**
317 * @override 317 * @override
318 * @param {number} lineNumber in compiled resource 318 * @param {number} lineNumber in compiled resource
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } while (digit & SDK.TextSourceMap._VLQ_CONTINUATION_MASK); 520 } while (digit & SDK.TextSourceMap._VLQ_CONTINUATION_MASK);
521 521
522 // Fix the sign. 522 // Fix the sign.
523 var negative = result & 1; 523 var negative = result & 1;
524 result >>= 1; 524 result >>= 1;
525 return negative ? -result : result; 525 return negative ? -result : result;
526 } 526 }
527 527
528 /** 528 /**
529 * @param {string} url 529 * @param {string} url
530 * @param {!Common.TextRange} textRange 530 * @param {!TextUtils.TextRange} textRange
531 * @return {!Common.TextRange} 531 * @return {!TextUtils.TextRange}
532 */ 532 */
533 reverseMapTextRange(url, textRange) { 533 reverseMapTextRange(url, textRange) {
534 /** 534 /**
535 * @param {!{lineNumber: number, columnNumber: number}} position 535 * @param {!{lineNumber: number, columnNumber: number}} position
536 * @param {!SDK.SourceMapEntry} mapping 536 * @param {!SDK.SourceMapEntry} mapping
537 * @return {number} 537 * @return {number}
538 */ 538 */
539 function comparator(position, mapping) { 539 function comparator(position, mapping) {
540 if (position.lineNumber !== mapping.sourceLineNumber) 540 if (position.lineNumber !== mapping.sourceLineNumber)
541 return position.lineNumber - mapping.sourceLineNumber; 541 return position.lineNumber - mapping.sourceLineNumber;
542 542
543 return position.columnNumber - mapping.sourceColumnNumber; 543 return position.columnNumber - mapping.sourceColumnNumber;
544 } 544 }
545 545
546 var mappings = this._reversedMappings(url); 546 var mappings = this._reversedMappings(url);
547 var startIndex = 547 var startIndex =
548 mappings.lowerBound({lineNumber: textRange.startLine, columnNumber: text Range.startColumn}, comparator); 548 mappings.lowerBound({lineNumber: textRange.startLine, columnNumber: text Range.startColumn}, comparator);
549 var endIndex = mappings.upperBound({lineNumber: textRange.endLine, columnNum ber: textRange.endColumn}, comparator); 549 var endIndex = mappings.upperBound({lineNumber: textRange.endLine, columnNum ber: textRange.endColumn}, comparator);
550 550
551 var startMapping = mappings[startIndex]; 551 var startMapping = mappings[startIndex];
552 var endMapping = mappings[endIndex]; 552 var endMapping = mappings[endIndex];
553 return new Common.TextRange( 553 return new TextUtils.TextRange(
554 startMapping.lineNumber, startMapping.columnNumber, endMapping.lineNumbe r, endMapping.columnNumber); 554 startMapping.lineNumber, startMapping.columnNumber, endMapping.lineNumbe r, endMapping.columnNumber);
555 } 555 }
556 }; 556 };
557 557
558 SDK.TextSourceMap._VLQ_BASE_SHIFT = 5; 558 SDK.TextSourceMap._VLQ_BASE_SHIFT = 5;
559 SDK.TextSourceMap._VLQ_BASE_MASK = (1 << 5) - 1; 559 SDK.TextSourceMap._VLQ_BASE_MASK = (1 << 5) - 1;
560 SDK.TextSourceMap._VLQ_CONTINUATION_MASK = 1 << 5; 560 SDK.TextSourceMap._VLQ_CONTINUATION_MASK = 1 << 5;
561 561
562 562
563 /** 563 /**
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 * @param {?string} content 602 * @param {?string} content
603 * @param {?Array<!SDK.SourceMapEntry>} reverseMappings 603 * @param {?Array<!SDK.SourceMapEntry>} reverseMappings
604 */ 604 */
605 constructor(content, reverseMappings) { 605 constructor(content, reverseMappings) {
606 this.content = content; 606 this.content = content;
607 this.reverseMappings = reverseMappings; 607 this.reverseMappings = reverseMappings;
608 } 608 }
609 }; 609 };
610 610
611 SDK.TextSourceMap._sourcesListSymbol = Symbol('sourcesList'); 611 SDK.TextSourceMap._sourcesListSymbol = Symbol('sourcesList');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698