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

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

Issue 1902993002: [DevTools] Introduce provisional blackboxing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/BlackboxManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxManager.js b/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxManager.js
index 16e11e30c9d95d0477445148f788cb53d98a46e5..fc03e73f64ace6755d698aa665f285611cc1c723 100644
--- a/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxManager.js
@@ -2,10 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+/** @typedef {!{line: number, column: number}} */
+var ScriptPosition;
+
/**
* @constructor
* @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding
* @param {!WebInspector.NetworkMapping} networkMapping
+ * @implements {WebInspector.TargetManager.Observer}
*/
WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping)
{
@@ -17,10 +21,12 @@ WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping
WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this._patternChanged.bind(this));
WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._patternChanged.bind(this));
- /** @type {!Map<!WebInspector.DebuggerModel, !Map<string, !Array<!DebuggerAgent.ScriptPosition>>>} */
+ /** @type {!Map<!WebInspector.DebuggerModel, !Map<string, !Array<!ScriptPosition>>>} */
this._debuggerModelData = new Map();
/** @type {!Map<string, boolean>} */
this._isBlackboxedURLCache = new Map();
+
+ WebInspector.targetManager.observeTargets(this);
}
WebInspector.BlackboxManager.prototype = {
@@ -43,6 +49,40 @@ WebInspector.BlackboxManager.prototype = {
},
/**
+ * @override
+ * @param {!WebInspector.Target} target
+ */
+ targetAdded: function(target)
+ {
+ var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
+ if (debuggerModel)
+ this._addBlackboxPatterns(debuggerModel);
+ },
+
+ /**
+ * @override
+ * @param {!WebInspector.Target} target
+ */
+ targetRemoved: function(target)
+ {
+ },
+
+ /**
+ * @param {!WebInspector.DebuggerModel} debuggerModel
+ * @return {!Promise<boolean>}
+ */
+ _addBlackboxPatterns: function(debuggerModel)
+ {
+ var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern").getAsArray();
+ var patterns = /** @type {!Array<string>} */([]);
+ for (var item of regexPatterns) {
+ if (!item.disabled && item.pattern)
+ patterns.push(item.pattern);
+ }
+ return debuggerModel.setBlackboxPatterns(patterns);
+ },
+
+ /**
* @param {!WebInspector.DebuggerModel.Location} location
* @return {boolean}
*/
@@ -56,7 +96,7 @@ WebInspector.BlackboxManager.prototype = {
/**
* @param {!WebInspector.DebuggerModel.Location} a
- * @param {!DebuggerAgent.ScriptPosition} b
+ * @param {!ScriptPosition} b
* @return {number}
*/
function comparator(a, b)
@@ -116,26 +156,24 @@ WebInspector.BlackboxManager.prototype = {
if (!mappings.length) {
if (previousScriptState.length > 0)
- return this._setScriptState(script, []);
+ return this._setScriptState(script, null);
return Promise.resolve();
}
- var currentBlackboxed = false;
- var isBlackboxed = false;
- var positions = [];
- // If content in script file begin is not mapped and one or more ranges are blackboxed then blackbox it.
- if (mappings[0].lineNumber !== 0 || mappings[0].columnNumber !== 0) {
- positions.push({ line: 0, column: 0});
- currentBlackboxed = true;
- }
+ var ranges = [];
+ var prevMapping = null;
for (var mapping of mappings) {
- if (mapping.sourceURL && currentBlackboxed !== this.isBlackboxedURL(mapping.sourceURL)) {
- positions.push({ line: mapping.lineNumber, column: mapping.columnNumber });
- currentBlackboxed = !currentBlackboxed;
+ if (mapping.sourceURL && !this.isBlackboxedURL(mapping.sourceURL)) {
+ prevMapping = mapping;
+ continue;
}
- isBlackboxed = currentBlackboxed || isBlackboxed;
+ if (prevMapping)
+ ranges.push({ startLine: prevMapping.lineNumber, startColumn: prevMapping.columnNumber, endLine: mapping.lineNumber, endColumn: mapping.columnNumber });
+ else
+ ranges.push({ startLine: 0, startColumn: 0, endLine: mapping.lineNumber, endColumn: mapping.columnNumber });
dgozman 2016/04/20 02:06:40 Let's send merged ranges.
+ prevMapping = mapping;
}
- return this._setScriptState(script, !isBlackboxed ? [] : positions);
+ return this._setScriptState(script, ranges);
/**
* @param {!WebInspector.SourceMapEntry} a
* @param {!WebInspector.SourceMapEntry} b
@@ -258,6 +296,7 @@ WebInspector.BlackboxManager.prototype = {
var promises = [];
for (var debuggerModel of WebInspector.DebuggerModel.instances()) {
+ promises.push(this._addBlackboxPatterns.bind(this, debuggerModel));
for (var scriptId in debuggerModel.scripts) {
var script = debuggerModel.scripts[scriptId];
promises.push(this._addScript(script)
@@ -308,7 +347,7 @@ WebInspector.BlackboxManager.prototype = {
_addScript: function(script)
{
var blackboxed = this._isBlackboxedScript(script);
- return this._setScriptState(script, blackboxed ? [ { line: 0, column: 0 } ] : []);
+ return this._setScriptState(script, blackboxed ? null : []);
},
/**
@@ -322,7 +361,7 @@ WebInspector.BlackboxManager.prototype = {
/**
* @param {!WebInspector.Script} script
- * @return {?Array<!DebuggerAgent.ScriptPosition>}
+ * @return {?Array<!ScriptPosition>}
*/
_scriptPositions: function(script)
{
@@ -333,7 +372,7 @@ WebInspector.BlackboxManager.prototype = {
/**
* @param {!WebInspector.Script} script
- * @param {!Array<!DebuggerAgent.ScriptPosition>} positions
+ * @param {!Array<!ScriptPosition>} positions
*/
_setScriptPositions: function(script, positions)
{
@@ -345,11 +384,21 @@ WebInspector.BlackboxManager.prototype = {
/**
* @param {!WebInspector.Script} script
- * @param {!Array<!DebuggerAgent.ScriptPosition>} positions
+ * @param {?Array<!RuntimeAgent.SourceRange>} ranges
* @return {!Promise<undefined>}
*/
- _setScriptState: function(script, positions)
+ _setScriptState: function(script, ranges)
{
+ var positions = [];
+ if (ranges) {
+ for (var range of ranges) {
+ positions.push({ line: range.startLine, column: range.startColumn });
+ positions.push({ line: range.endLine, column: range.endColumn });
+ }
+ } else {
+ positions.push({ line: 0, column: 0 });
+ }
+
var previousScriptState = this._scriptPositions(script);
if (previousScriptState) {
var hasChanged = false;
@@ -363,7 +412,7 @@ WebInspector.BlackboxManager.prototype = {
return Promise.resolve().then(updateState.bind(this, false));
}
- return script.setBlackboxedRanges(positions).then(updateState.bind(this));
+ return script.setBlackboxedRanges(ranges).then(updateState.bind(this));
/**
* @param {boolean} success

Powered by Google App Engine
This is Rietveld 408576698