Commit bceaccd3 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[DevTools] migrate CallStackSidebarPane to live locations

New CallStackSidebarPane tries to finally split model and view by using
live locations more.
With new implementation each item maintains own state based on live
location updates and schedule updates of correspond list item.

drive-by: removed BlackboxManager.isRawLocationBlackboxed method.

R=lushnikov@chromium.org

Bug: none
Change-Id: I19adde997652754e5f90869ee41ab41899bf8ec4
Reviewed-on: https://chromium-review.googlesource.com/1168384
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582044}
parent 606b90f2
......@@ -46,6 +46,9 @@ Bindings.BlackboxManager = class {
*/
modelAdded(debuggerModel) {
this._setBlackboxPatterns(debuggerModel);
const sourceMapManager = debuggerModel.sourceMapManager();
sourceMapManager.addEventListener(SDK.SourceMapManager.Events.SourceMapAttached, this._sourceMapAttached, this);
sourceMapManager.addEventListener(SDK.SourceMapManager.Events.SourceMapDetached, this._sourceMapDetached, this);
}
/**
......@@ -54,6 +57,9 @@ Bindings.BlackboxManager = class {
*/
modelRemoved(debuggerModel) {
this._clearCacheIfNeeded();
const sourceMapManager = debuggerModel.sourceMapManager();
sourceMapManager.removeEventListener(SDK.SourceMapManager.Events.SourceMapAttached, this._sourceMapAttached, this);
sourceMapManager.removeEventListener(SDK.SourceMapManager.Events.SourceMapDetached, this._sourceMapDetached, this);
}
_clearCacheIfNeeded() {
......@@ -75,32 +81,6 @@ Bindings.BlackboxManager = class {
return debuggerModel.setBlackboxPatterns(patterns);
}
/**
* @param {!SDK.DebuggerModel.Location} location
* @return {boolean}
*/
isBlackboxedRawLocation(location) {
const script = location.script();
if (!script)
return false;
const ranges = script[Bindings.BlackboxManager._blackboxedRanges];
if (!ranges)
return this.isBlackboxedURL(script.sourceURL, script.isContentScript());
const index = ranges.lowerBound(location, comparator);
return !!(index % 2);
/**
* @param {!SDK.DebuggerModel.Location} a
* @param {!Protocol.Debugger.ScriptPosition} b
* @return {number}
*/
function comparator(a, b) {
if (a.lineNumber !== b.lineNumber)
return a.lineNumber - b.lineNumber;
return a.columnNumber - b.columnNumber;
}
}
/**
* @param {!Workspace.UISourceCode} uiSourceCode
* @return {boolean}
......@@ -130,13 +110,32 @@ Bindings.BlackboxManager = class {
return isBlackboxed;
}
/**
* @param {!Common.Event} event
*/
_sourceMapAttached(event) {
const script = /** @type {!SDK.Script} */ (event.data.client);
const sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap);
this._updateScriptRanges(script, sourceMap);
}
/**
* @param {!Common.Event} event
*/
_sourceMapDetached(event) {
const script = /** @type {!SDK.Script} */ (event.data.client);
this._updateScriptRanges(script, null);
}
/**
* @param {!SDK.Script} script
* @param {?SDK.SourceMap} sourceMap
* @return {!Promise<undefined>}
*/
async sourceMapLoaded(script, sourceMap) {
const hasBlackboxedMappings = sourceMap ? sourceMap.sourceURLs().some(url => this.isBlackboxedURL(url)) : false;
async _updateScriptRanges(script, sourceMap) {
let hasBlackboxedMappings = false;
if (!Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isContentScript()))
hasBlackboxedMappings = sourceMap ? sourceMap.sourceURLs().some(url => this.isBlackboxedURL(url)) : false;
if (!hasBlackboxedMappings) {
if (script[Bindings.BlackboxManager._blackboxedRanges] && await script.setBlackboxedRanges([]))
delete script[Bindings.BlackboxManager._blackboxedRanges];
......@@ -274,8 +273,9 @@ Bindings.BlackboxManager = class {
const promises = [];
for (const debuggerModel of SDK.targetManager.models(SDK.DebuggerModel)) {
promises.push(this._setBlackboxPatterns(debuggerModel));
const sourceMapManager = debuggerModel.sourceMapManager();
for (const script of debuggerModel.scripts()) {
promises.push(this.sourceMapLoaded(script, this._debuggerWorkspaceBinding.sourceMapForScript(script))
promises.push(this._updateScriptRanges(script, sourceMapManager.sourceMapForClient(script))
.then(() => this._debuggerWorkspaceBinding.updateLocations(script)));
}
}
......
......@@ -213,7 +213,6 @@ Bindings.CompilerScriptMapping = class {
if (Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isContentScript()))
return;
Bindings.blackboxManager.sourceMapLoaded(script, sourceMap);
this._populateSourceMapSources(script, sourceMap);
this._sourceMapAttachedForTest(sourceMap);
......
......@@ -180,16 +180,6 @@ Bindings.DebuggerWorkspaceBinding = class {
return modelData._compilerMapping.sourceMapForScript(script);
}
/**
* @param {!SDK.Script} script
*/
maybeLoadSourceMap(script) {
const modelData = this._debuggerModelToData.get(script.debuggerModel);
if (!modelData)
return;
modelData._compilerMapping.maybeLoadSourceMap(script);
}
/**
* @param {!Common.Event} event
*/
......@@ -390,7 +380,8 @@ Bindings.DebuggerWorkspaceBinding.Location = class extends Bindings.LiveLocation
* @return {boolean}
*/
isBlackboxed() {
return Bindings.blackboxManager.isBlackboxedRawLocation(this._rawLocation);
const uiLocation = this.uiLocation();
return uiLocation ? Bindings.blackboxManager.isBlackboxedUISourceCode(uiLocation.uiSourceCode) : false;
}
};
......
......@@ -43,7 +43,6 @@ Components.JSPresentationUtils.buildStackTracePreviewContents = function(
element.style.display = 'inline-block';
const shadowRoot = UI.createShadowRootWithCoreStyles(element, 'components/jsUtils.css');
const contentElement = shadowRoot.createChild('table', 'stack-preview-container');
const debuggerModel = target ? target.model(SDK.DebuggerModel) : null;
let totalHiddenCallFramesCount = 0;
/**
......@@ -59,15 +58,11 @@ Components.JSPresentationUtils.buildStackTracePreviewContents = function(
const link = linkifier.maybeLinkifyConsoleCallFrame(target, stackFrame);
if (link) {
link.addEventListener('contextmenu', populateContextMenu.bind(null, link));
if (debuggerModel) {
const location = debuggerModel.createRawLocationByScriptId(
stackFrame.scriptId, stackFrame.lineNumber, stackFrame.columnNumber);
if (location && Bindings.blackboxManager.isBlackboxedRawLocation(location)) {
row.classList.add('blackboxed');
++hiddenCallFrames;
}
const uiLocation = Components.Linkifier.uiLocation(link);
if (uiLocation && Bindings.blackboxManager.isBlackboxedUISourceCode(uiLocation.uiSourceCode)) {
row.classList.add('blackboxed');
++hiddenCallFrames;
}
row.createChild('td').textContent = ' @ ';
row.createChild('td').appendChild(link);
}
......
......@@ -299,7 +299,8 @@ SourcesTestRunner.captureStackTraceIntoString = function(callFrames, asyncStackT
const location = locationFunction.call(frame);
const script = location.script();
const uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location);
const isFramework = Bindings.blackboxManager.isBlackboxedRawLocation(location);
const isFramework =
uiLocation ? Bindings.blackboxManager.isBlackboxedUISourceCode(uiLocation.uiSourceCode) : false;
if (options.dropFrameworkCallFrames && isFramework)
continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment