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 { ...@@ -46,6 +46,9 @@ Bindings.BlackboxManager = class {
*/ */
modelAdded(debuggerModel) { modelAdded(debuggerModel) {
this._setBlackboxPatterns(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 { ...@@ -54,6 +57,9 @@ Bindings.BlackboxManager = class {
*/ */
modelRemoved(debuggerModel) { modelRemoved(debuggerModel) {
this._clearCacheIfNeeded(); 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() { _clearCacheIfNeeded() {
...@@ -75,32 +81,6 @@ Bindings.BlackboxManager = class { ...@@ -75,32 +81,6 @@ Bindings.BlackboxManager = class {
return debuggerModel.setBlackboxPatterns(patterns); 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 * @param {!Workspace.UISourceCode} uiSourceCode
* @return {boolean} * @return {boolean}
...@@ -130,13 +110,32 @@ Bindings.BlackboxManager = class { ...@@ -130,13 +110,32 @@ Bindings.BlackboxManager = class {
return isBlackboxed; 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.Script} script
* @param {?SDK.SourceMap} sourceMap * @param {?SDK.SourceMap} sourceMap
* @return {!Promise<undefined>} * @return {!Promise<undefined>}
*/ */
async sourceMapLoaded(script, sourceMap) { async _updateScriptRanges(script, sourceMap) {
const hasBlackboxedMappings = sourceMap ? sourceMap.sourceURLs().some(url => this.isBlackboxedURL(url)) : false; let hasBlackboxedMappings = false;
if (!Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isContentScript()))
hasBlackboxedMappings = sourceMap ? sourceMap.sourceURLs().some(url => this.isBlackboxedURL(url)) : false;
if (!hasBlackboxedMappings) { if (!hasBlackboxedMappings) {
if (script[Bindings.BlackboxManager._blackboxedRanges] && await script.setBlackboxedRanges([])) if (script[Bindings.BlackboxManager._blackboxedRanges] && await script.setBlackboxedRanges([]))
delete script[Bindings.BlackboxManager._blackboxedRanges]; delete script[Bindings.BlackboxManager._blackboxedRanges];
...@@ -274,8 +273,9 @@ Bindings.BlackboxManager = class { ...@@ -274,8 +273,9 @@ Bindings.BlackboxManager = class {
const promises = []; const promises = [];
for (const debuggerModel of SDK.targetManager.models(SDK.DebuggerModel)) { for (const debuggerModel of SDK.targetManager.models(SDK.DebuggerModel)) {
promises.push(this._setBlackboxPatterns(debuggerModel)); promises.push(this._setBlackboxPatterns(debuggerModel));
const sourceMapManager = debuggerModel.sourceMapManager();
for (const script of debuggerModel.scripts()) { 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))); .then(() => this._debuggerWorkspaceBinding.updateLocations(script)));
} }
} }
......
...@@ -213,7 +213,6 @@ Bindings.CompilerScriptMapping = class { ...@@ -213,7 +213,6 @@ Bindings.CompilerScriptMapping = class {
if (Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isContentScript())) if (Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isContentScript()))
return; return;
Bindings.blackboxManager.sourceMapLoaded(script, sourceMap);
this._populateSourceMapSources(script, sourceMap); this._populateSourceMapSources(script, sourceMap);
this._sourceMapAttachedForTest(sourceMap); this._sourceMapAttachedForTest(sourceMap);
......
...@@ -180,16 +180,6 @@ Bindings.DebuggerWorkspaceBinding = class { ...@@ -180,16 +180,6 @@ Bindings.DebuggerWorkspaceBinding = class {
return modelData._compilerMapping.sourceMapForScript(script); 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 * @param {!Common.Event} event
*/ */
...@@ -390,7 +380,8 @@ Bindings.DebuggerWorkspaceBinding.Location = class extends Bindings.LiveLocation ...@@ -390,7 +380,8 @@ Bindings.DebuggerWorkspaceBinding.Location = class extends Bindings.LiveLocation
* @return {boolean} * @return {boolean}
*/ */
isBlackboxed() { 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( ...@@ -43,7 +43,6 @@ Components.JSPresentationUtils.buildStackTracePreviewContents = function(
element.style.display = 'inline-block'; element.style.display = 'inline-block';
const shadowRoot = UI.createShadowRootWithCoreStyles(element, 'components/jsUtils.css'); const shadowRoot = UI.createShadowRootWithCoreStyles(element, 'components/jsUtils.css');
const contentElement = shadowRoot.createChild('table', 'stack-preview-container'); const contentElement = shadowRoot.createChild('table', 'stack-preview-container');
const debuggerModel = target ? target.model(SDK.DebuggerModel) : null;
let totalHiddenCallFramesCount = 0; let totalHiddenCallFramesCount = 0;
/** /**
...@@ -59,15 +58,11 @@ Components.JSPresentationUtils.buildStackTracePreviewContents = function( ...@@ -59,15 +58,11 @@ Components.JSPresentationUtils.buildStackTracePreviewContents = function(
const link = linkifier.maybeLinkifyConsoleCallFrame(target, stackFrame); const link = linkifier.maybeLinkifyConsoleCallFrame(target, stackFrame);
if (link) { if (link) {
link.addEventListener('contextmenu', populateContextMenu.bind(null, link)); link.addEventListener('contextmenu', populateContextMenu.bind(null, link));
if (debuggerModel) { const uiLocation = Components.Linkifier.uiLocation(link);
const location = debuggerModel.createRawLocationByScriptId( if (uiLocation && Bindings.blackboxManager.isBlackboxedUISourceCode(uiLocation.uiSourceCode)) {
stackFrame.scriptId, stackFrame.lineNumber, stackFrame.columnNumber); row.classList.add('blackboxed');
if (location && Bindings.blackboxManager.isBlackboxedRawLocation(location)) { ++hiddenCallFrames;
row.classList.add('blackboxed');
++hiddenCallFrames;
}
} }
row.createChild('td').textContent = ' @ '; row.createChild('td').textContent = ' @ ';
row.createChild('td').appendChild(link); row.createChild('td').appendChild(link);
} }
......
...@@ -299,7 +299,8 @@ SourcesTestRunner.captureStackTraceIntoString = function(callFrames, asyncStackT ...@@ -299,7 +299,8 @@ SourcesTestRunner.captureStackTraceIntoString = function(callFrames, asyncStackT
const location = locationFunction.call(frame); const location = locationFunction.call(frame);
const script = location.script(); const script = location.script();
const uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location); 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) if (options.dropFrameworkCallFrames && isFramework)
continue; 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