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

Unified Diff: third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js

Issue 1663723002: [DevTools] Add sourceMap support for blackboxing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@call-set-blackboxed-ranges-on-script-parsed
Patch Set: Created 4 years, 11 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/bindings/BlackboxSupport.js
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js b/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js
index e86856063748d4198d5a0c74a1ed5da855ecf3c9..f80a35fa8f6e22fe6ced328be8f65fd89693275d 100644
--- a/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js
@@ -10,6 +10,9 @@ WebInspector.BlackboxManager = function()
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this._patternChanged.bind(this));
WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._patternChanged.bind(this));
+
+ /** @type {!Map<string, !WebInspector.SourceMap>} */
+ this._sourceMapForScriptId = new Map();
dgozman 2016/02/03 18:24:10 Ask CompilerScriptMapping instead of keeping a sep
kozy 2016/02/09 23:10:09 Done.
}
WebInspector.BlackboxManager.prototype = {
@@ -19,6 +22,7 @@ WebInspector.BlackboxManager.prototype = {
_parsedScriptSource: function(event)
{
var script = /** @type {!WebInspector.Script} */ (event.data);
+ script.addEventListener(WebInspector.Script.Events.SourceMapLoaded, this._sourceMapLoaded.bind(this, script));
this._blackboxScriptIfNeeded(script);
},
@@ -35,10 +39,64 @@ WebInspector.BlackboxManager.prototype = {
*/
_blackboxScriptIfNeeded: function(script)
{
- if (WebInspector.BlackboxSupport.isBlackboxed(script.sourceURL, script.isContentScript()))
+ if (WebInspector.BlackboxSupport.isBlackboxed(script.sourceURL, script.isContentScript())) {
script.setBlackboxedRanges([ { line: 0, column: 0 } ]);
- else
+ return;
+ }
+
+ if (!this._sourceMapForScriptId.has(script.scriptId)) {
+ script.setBlackboxedRanges([]);
+ return;
+ }
+
+ var sourceMap = this._sourceMapForScriptId.get(script.scriptId);
+ var mappings = sourceMap.mappings().slice();
+ mappings.sort(mappingComparator);
+
+ if (!mappings.length) {
script.setBlackboxedRanges([]);
+ return;
+ }
+
+ var currentBlackboxed = false;
+ var positions = [];
+ if (mappings[0].lineNumber !== 0 || mappings[0].columnNumber !== 0) {
+ positions.push({ line: 0, column: 0});
+ currentBlackboxed = true;
+ }
+ for (var mapping of sourceMap.mappings()) {
+ if (currentBlackboxed !== WebInspector.BlackboxSupport.isBlackboxedURL(mapping.sourceURL)) {
dgozman 2016/02/03 18:24:10 Ain't this slow? Should we cache instead of regexp
kozy 2016/02/09 23:10:09 Done.
+ positions.push({ line: mapping.lineNumber, column: mapping.columnNumber });
+ currentBlackboxed = !currentBlackboxed;
+ }
+ }
+
+ script.setBlackboxedRanges(positions);
+
+ /**
+ * @param {!WebInspector.SourceMap.Entry} a
+ * @param {!WebInspector.SourceMap.Entry} b
+ */
+ function mappingComparator(a, b)
+ {
+ if (a.lineNumber !== b.lineNumber)
+ return a.lineNumber - b.lineNumber;
+ return a.columnNumber - b.columnNumber;
+ }
+ },
+
+ /**
+ * @param {!WebInspector.Script} script
+ * @param {!WebInspector.Event} event
+ */
+ _sourceMapLoaded: function(script, event)
+ {
+ var sourceMap = /** @type {?WebInspector.SourceMap} */ (event.data);
+ if (!sourceMap)
+ return;
+
+ this._sourceMapForScriptId.set(script.scriptId, sourceMap);
+ this._blackboxScriptIfNeeded(script);
}
}

Powered by Google App Engine
This is Rietveld 408576698