Skip to content

Commit

Permalink
[DevTools] Blackboxing in LiveLocations is supported in Linkifier
Browse files Browse the repository at this point in the history
[email protected]
BUG=583193

Review URL: https://codereview.chromium.org/1688283002

Cr-Commit-Position: refs/heads/master@{#376278}
  • Loading branch information
alexkozy authored and Commit bot committed Feb 18, 2016
1 parent 44eeeb2 commit be5c866
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 43 deletions.
7 changes: 4 additions & 3 deletions front_end/bindings/BlackboxManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping
}

WebInspector.BlackboxManager.prototype = {

/**
* @param {function(!WebInspector.Event)} listener
* @param {!Object=} thisObject
Expand Down Expand Up @@ -308,10 +307,12 @@ WebInspector.BlackboxManager.prototype = {
*/
function updateState(success)
{
if (success)
if (success) {
this._scriptIdToPositions.set(script.scriptId, positions);
else if (!this._scriptIdToPositions.has(script.scriptId))
this._debuggerWorkspaceBinding.updateLocations(script);
} else if (!this._scriptIdToPositions.has(script.scriptId)) {
this._scriptIdToPositions.set(script.scriptId, []);
}
}
},

Expand Down
7 changes: 5 additions & 2 deletions front_end/bindings/BreakpointManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,13 @@ WebInspector.BreakpointManager.TargetBreakpoint.prototype = {

/**
* @param {!WebInspector.DebuggerModel.Location} location
* @param {!WebInspector.UILocation} uiLocation
* @param {!WebInspector.LiveLocation} liveLocation
*/
_locationUpdated: function(location, uiLocation)
_locationUpdated: function(location, liveLocation)
{
var uiLocation = liveLocation.uiLocation();
if (!uiLocation)
return;
var oldUILocation = this._uiLocations[location.id()] || null;
this._uiLocations[location.id()] = uiLocation;
this._breakpoint._replaceUILocation(oldUILocation, uiLocation);
Expand Down
13 changes: 11 additions & 2 deletions front_end/bindings/CSSWorkspaceBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ WebInspector.CSSWorkspaceBinding.prototype = {

/**
* @param {!WebInspector.CSSLocation} rawLocation
* @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
* @param {function(!WebInspector.LiveLocation)} updateDelegate
* @return {!WebInspector.CSSWorkspaceBinding.LiveLocation}
*/
createLiveLocation: function(rawLocation, updateDelegate)
Expand Down Expand Up @@ -314,7 +314,7 @@ WebInspector.CSSWorkspaceBinding.HeaderInfo.prototype = {
* @param {?WebInspector.CSSStyleSheetHeader} header
* @param {!WebInspector.CSSLocation} rawLocation
* @param {!WebInspector.CSSWorkspaceBinding} binding
* @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
* @param {function(!WebInspector.LiveLocation)} updateDelegate
*/
WebInspector.CSSWorkspaceBinding.LiveLocation = function(cssModel, header, rawLocation, binding, updateDelegate)
{
Expand Down Expand Up @@ -397,6 +397,15 @@ WebInspector.CSSWorkspaceBinding.LiveLocation.prototype = {
this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRemoved, this._styleSheetRemoved, this);
},

/**
* @override
* @return {boolean}
*/
isBlackboxed: function()
{
return false;
},

__proto__: WebInspector.LiveLocation.prototype
}

Expand Down
19 changes: 14 additions & 5 deletions front_end/bindings/DebuggerWorkspaceBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ WebInspector.DebuggerWorkspaceBinding.prototype = {

/**
* @param {!WebInspector.DebuggerModel.Location} rawLocation
* @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
* @param {function(!WebInspector.LiveLocation)} updateDelegate
* @return {!WebInspector.DebuggerWorkspaceBinding.Location}
*/
createLiveLocation: function(rawLocation, updateDelegate)
Expand All @@ -135,7 +135,7 @@ WebInspector.DebuggerWorkspaceBinding.prototype = {

/**
* @param {!WebInspector.DebuggerModel.CallFrame} callFrame
* @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
* @param {function(!WebInspector.LiveLocation)} updateDelegate
* @return {!WebInspector.DebuggerWorkspaceBinding.Location}
*/
createCallFrameLiveLocation: function(callFrame, updateDelegate)
Expand Down Expand Up @@ -469,7 +469,7 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = {
},

/**
* @param {!WebInspector.LiveLocation} location
* @param {!WebInspector.DebuggerWorkspaceBinding.Location} location
*/
_addLocation: function(location)
{
Expand All @@ -478,7 +478,7 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = {
},

/**
* @param {!WebInspector.LiveLocation} location
* @param {!WebInspector.DebuggerWorkspaceBinding.Location} location
*/
_removeLocation: function(location)
{
Expand Down Expand Up @@ -512,7 +512,7 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = {
* @param {!WebInspector.Script} script
* @param {!WebInspector.DebuggerModel.Location} rawLocation
* @param {!WebInspector.DebuggerWorkspaceBinding} binding
* @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
* @param {function(!WebInspector.LiveLocation)} updateDelegate
*/
WebInspector.DebuggerWorkspaceBinding.Location = function(script, rawLocation, binding, updateDelegate)
{
Expand All @@ -539,6 +539,15 @@ WebInspector.DebuggerWorkspaceBinding.Location.prototype = {
this._binding._removeLiveLocation(this);
},

/**
* @override
* @return {boolean}
*/
isBlackboxed: function()
{
return WebInspector.blackboxManager.isBlackboxedRawLocation(this._rawLocation);
},

__proto__: WebInspector.LiveLocation.prototype
}

Expand Down
16 changes: 10 additions & 6 deletions front_end/bindings/LiveLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* @constructor
* @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
* @param {function(!WebInspector.LiveLocation)} updateDelegate
*/
WebInspector.LiveLocation = function(updateDelegate)
{
Expand All @@ -14,11 +14,7 @@ WebInspector.LiveLocation = function(updateDelegate)
WebInspector.LiveLocation.prototype = {
update: function()
{
var uiLocation = this.uiLocation();
if (!uiLocation)
return;
if (this._updateDelegate(uiLocation))
this.dispose();
this._updateDelegate(this);
},

/**
Expand All @@ -32,5 +28,13 @@ WebInspector.LiveLocation.prototype = {
dispose: function()
{
// Overridden by subclasses.
},

/**
* @return {boolean}
*/
isBlackboxed: function()
{
throw "Not implemented";
}
}
7 changes: 5 additions & 2 deletions front_end/bindings/PresentationConsoleMessageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,15 @@ WebInspector.PresentationConsoleMessage = function(message, rawLocation)

WebInspector.PresentationConsoleMessage.prototype = {
/**
* @param {!WebInspector.UILocation} uiLocation
* @param {!WebInspector.LiveLocation} liveLocation
*/
_updateLocation: function(uiLocation)
_updateLocation: function(liveLocation)
{
if (this._uiMessage)
this._uiMessage.remove();
var uiLocation = liveLocation.uiLocation();
if (!uiLocation)
return;
this._uiMessage = uiLocation.uiSourceCode.addLineMessage(this._level, this._text, uiLocation.lineNumber, uiLocation.columnNumber);
},

Expand Down
33 changes: 16 additions & 17 deletions front_end/components/Linkifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ WebInspector.LinkifierFormatter.prototype = {
/**
* @param {!Element} anchor
* @param {!WebInspector.UILocation} uiLocation
* @param {boolean} isBlackboxed
*/
formatLiveAnchor: function(anchor, uiLocation) { }
formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) { }
}

/**
Expand Down Expand Up @@ -202,16 +203,7 @@ WebInspector.Linkifier.prototype = {
// FIXME(62725): console stack trace line/column numbers are one-based.
var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0;
var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0;
var anchor = this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, lineNumber, columnNumber, classes);
var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
var location = debuggerModel && debuggerModel.createRawLocationByScriptId(callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber);
var blackboxed = location ?
WebInspector.blackboxManager.isBlackboxedRawLocation(location) :
WebInspector.blackboxManager.isBlackboxedURL(callFrame.url);
if (blackboxed)
anchor.classList.add("webkit-html-blackbox-link");

return anchor;
return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, lineNumber, columnNumber, classes);
},

/**
Expand Down Expand Up @@ -290,12 +282,15 @@ WebInspector.Linkifier.prototype = {

/**
* @param {!Element} anchor
* @param {!WebInspector.UILocation} uiLocation
* @param {!WebInspector.LiveLocation} liveLocation
*/
_updateAnchor: function(anchor, uiLocation)
_updateAnchor: function(anchor, liveLocation)
{
var uiLocation = liveLocation.uiLocation();
if (!uiLocation)
return;
anchor[WebInspector.Linkifier._uiLocationSymbol] = uiLocation;
this._formatter.formatLiveAnchor(anchor, uiLocation);
this._formatter.formatLiveAnchor(anchor, uiLocation, liveLocation.isBlackboxed());
}
}

Expand Down Expand Up @@ -323,8 +318,9 @@ WebInspector.Linkifier.DefaultFormatter.prototype = {
* @override
* @param {!Element} anchor
* @param {!WebInspector.UILocation} uiLocation
* @param {boolean} isBlackboxed
*/
formatLiveAnchor: function(anchor, uiLocation)
formatLiveAnchor: function(anchor, uiLocation, isBlackboxed)
{
var text = uiLocation.linkText();
text = text.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, "$1\u2026");
Expand All @@ -336,6 +332,8 @@ WebInspector.Linkifier.DefaultFormatter.prototype = {
if (typeof uiLocation.lineNumber === "number")
titleText += ":" + (uiLocation.lineNumber + 1);
anchor.title = titleText;

anchor.classList.toggle("webkit-html-blackbox-link", isBlackboxed);
}
}

Expand All @@ -355,10 +353,11 @@ WebInspector.Linkifier.DefaultCSSFormatter.prototype = {
* @override
* @param {!Element} anchor
* @param {!WebInspector.UILocation} uiLocation
* @param {boolean} isBlackboxed
*/
formatLiveAnchor: function(anchor, uiLocation)
formatLiveAnchor: function(anchor, uiLocation, isBlackboxed)
{
WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor.call(this, anchor, uiLocation);
WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor.call(this, anchor, uiLocation, isBlackboxed);
anchor.classList.add("webkit-html-resource-link");
anchor.setAttribute("data-uncopyable", anchor.textContent);
anchor.textContent = "";
Expand Down
7 changes: 5 additions & 2 deletions front_end/sources/CallStackSidebarPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,13 @@ WebInspector.CallStackSidebarPane.CallFrame = function(callFrame, asyncCallFrame

WebInspector.CallStackSidebarPane.CallFrame.prototype = {
/**
* @param {!WebInspector.UILocation} uiLocation
* @param {!WebInspector.LiveLocation} liveLocation
*/
_update: function(uiLocation)
_update: function(liveLocation)
{
var uiLocation = liveLocation.uiLocation();
if (!uiLocation)
return;
var text = uiLocation.linkText();
this.setSubtitle(text.trimMiddle(30));
this.subtitleElement.title = text;
Expand Down
14 changes: 10 additions & 4 deletions front_end/sources/SourcesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,14 @@ WebInspector.SourcesPanel.prototype = {
}

/**
* @param {!WebInspector.UILocation} uiLocation
* @param {!WebInspector.LiveLocation} liveLocation
* @this {WebInspector.SourcesPanel}
*/
function didGetUILocation(uiLocation)
function didGetUILocation(liveLocation)
{
var uiLocation = liveLocation.uiLocation();
if (!uiLocation)
return;
var breakpoint = WebInspector.breakpointManager.findBreakpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
if (!breakpoint)
return;
Expand Down Expand Up @@ -388,10 +391,13 @@ WebInspector.SourcesPanel.prototype = {
},

/**
* @param {!WebInspector.UILocation} uiLocation
* @param {!WebInspector.LiveLocation} liveLocation
*/
_executionLineChanged: function(uiLocation)
_executionLineChanged: function(liveLocation)
{
var uiLocation = liveLocation.uiLocation();
if (!uiLocation)
return;
this._sourcesView.clearCurrentExecutionLine();
this._sourcesView.setExecutionLocation(uiLocation);
if (window.performance.now() - this._lastModificationTime < WebInspector.SourcesPanel._lastModificationTimeout)
Expand Down

0 comments on commit be5c866

Please sign in to comment.