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

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

Issue 2727383002: DevTools: sort sourceMap mappings since they might not be ordered. (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/inspector/text-source-map-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 * @param {string=} name 76 * @param {string=} name
77 */ 77 */
78 constructor(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColum nNumber, name) { 78 constructor(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColum nNumber, name) {
79 this.lineNumber = lineNumber; 79 this.lineNumber = lineNumber;
80 this.columnNumber = columnNumber; 80 this.columnNumber = columnNumber;
81 this.sourceURL = sourceURL; 81 this.sourceURL = sourceURL;
82 this.sourceLineNumber = sourceLineNumber; 82 this.sourceLineNumber = sourceLineNumber;
83 this.sourceColumnNumber = sourceColumnNumber; 83 this.sourceColumnNumber = sourceColumnNumber;
84 this.name = name; 84 this.name = name;
85 } 85 }
86
87 /**
88 * @param {!SDK.SourceMapEntry} entry1
89 * @param {!SDK.SourceMapEntry} entry2
90 * @return {number}
91 */
92 static compare(entry1, entry2) {
93 if (entry1.lineNumber !== entry2.lineNumber)
94 return entry1.lineNumber - entry2.lineNumber;
95 return entry1.columnNumber - entry2.columnNumber;
96 }
86 }; 97 };
87 98
88 /** 99 /**
89 * @interface 100 * @interface
90 */ 101 */
91 SDK.SourceMap = function() {}; 102 SDK.SourceMap = function() {};
92 103
93 SDK.SourceMap.prototype = { 104 SDK.SourceMap.prototype = {
94 /** 105 /**
95 * @return {string} 106 * @return {string}
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (!stringCharIterator.hasNext() || this._isSeparator(stringCharIterator. peek())) { 485 if (!stringCharIterator.hasNext() || this._isSeparator(stringCharIterator. peek())) {
475 this._mappings.push( 486 this._mappings.push(
476 new SDK.SourceMapEntry(lineNumber, columnNumber, sourceURL, sourceLi neNumber, sourceColumnNumber)); 487 new SDK.SourceMapEntry(lineNumber, columnNumber, sourceURL, sourceLi neNumber, sourceColumnNumber));
477 continue; 488 continue;
478 } 489 }
479 490
480 nameIndex += this._decodeVLQ(stringCharIterator); 491 nameIndex += this._decodeVLQ(stringCharIterator);
481 this._mappings.push(new SDK.SourceMapEntry( 492 this._mappings.push(new SDK.SourceMapEntry(
482 lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNum ber, names[nameIndex])); 493 lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNum ber, names[nameIndex]));
483 } 494 }
495
496 // As per spec, mappings are not necessarily sorted.
497 this._mappings.stableSort(SDK.SourceMapEntry.compare);
484 } 498 }
485 499
486 /** 500 /**
487 * @param {string} char 501 * @param {string} char
488 * @return {boolean} 502 * @return {boolean}
489 */ 503 */
490 _isSeparator(char) { 504 _isSeparator(char) {
491 return char === ',' || char === ';'; 505 return char === ',' || char === ';';
492 } 506 }
493 507
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 * @param {?string} content 602 * @param {?string} content
589 * @param {?Array<!SDK.SourceMapEntry>} reverseMappings 603 * @param {?Array<!SDK.SourceMapEntry>} reverseMappings
590 */ 604 */
591 constructor(content, reverseMappings) { 605 constructor(content, reverseMappings) {
592 this.content = content; 606 this.content = content;
593 this.reverseMappings = reverseMappings; 607 this.reverseMappings = reverseMappings;
594 } 608 }
595 }; 609 };
596 610
597 SDK.TextSourceMap._sourcesListSymbol = Symbol('sourcesList'); 611 SDK.TextSourceMap._sourcesListSymbol = Symbol('sourcesList');
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/inspector/text-source-map-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698