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

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

Issue 1770263002: Devtools: resolve expressions in minified scripts with sourcemaps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js b/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js
index 2b76cbabd63ce62f2aebdbe4fbb9462cd2439ed5..92041e5151b15aecd4ea1211f2e07b44f255a4d2 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js
@@ -277,7 +277,13 @@ WebInspector.SourceMap.prototype = {
{
if (a.sourceLineNumber !== b.sourceLineNumber)
return a.sourceLineNumber - b.sourceLineNumber;
- return a.sourceColumnNumber - b.sourceColumnNumber;
+ if (a.sourceColumnNumber !== b.sourceColumnNumber)
+ return a.sourceColumnNumber - b.sourceColumnNumber;
+
+ if (a.lineNumber !== b.lineNumber)
+ return a.lineNumber - b.lineNumber;
+
+ return a.columnNumber - b.columnNumber;
}
},
@@ -388,6 +394,35 @@ WebInspector.SourceMap.prototype = {
return negative ? -result : result;
},
+ /**
+ * @param {string} url
+ * @param {!WebInspector.TextRange} textRange
+ * @return {!WebInspector.TextRange}
+ */
+ reverseMapTextRange: function(url, textRange)
+ {
+ /**
+ * @param {!{lineNumber: number, columnNumber: number}} position
+ * @param {!WebInspector.SourceMap.Entry} mapping
+ * @return {number}
+ */
+ function comparator(position, mapping)
+ {
+ if (position.lineNumber !== mapping.sourceLineNumber)
+ return position.lineNumber - mapping.sourceLineNumber;
+
+ return position.columnNumber - mapping.sourceColumnNumber;
+ }
+
+ var mappings = this._reversedMappings(url);
+ var startIndex = mappings.lowerBound({lineNumber: textRange.startLine, columnNumber: textRange.startColumn}, comparator);
+ var endIndex = mappings.upperBound({lineNumber: textRange.endLine, columnNumber: textRange.endColumn}, comparator);
+
+ var startMapping = mappings[startIndex];
+ var endMapping = mappings[endIndex];
+ return new WebInspector.TextRange(startMapping.lineNumber, startMapping.columnNumber, endMapping.lineNumber, endMapping.columnNumber);
+ },
+
_VLQ_BASE_SHIFT: 5,
_VLQ_BASE_MASK: (1 << 5) - 1,
_VLQ_CONTINUATION_MASK: 1 << 5

Powered by Google App Engine
This is Rietveld 408576698