Commit bcbc44a6 authored by alph's avatar alph Committed by Commit bot

DevTools: Do not linkify to pseudo (program) node when there's no URL

Just omit the link instead.

NOTRY=true

Review-Url: https://codereview.chromium.org/2151653005
Cr-Commit-Position: refs/heads/master@{#406140}
parent 623ad061
...@@ -5,6 +5,6 @@ Set timer for test function. ...@@ -5,6 +5,6 @@ Set timer for test function.
Script execution paused. Script execution paused.
Script execution resumed. Script execution resumed.
console.error(42) console.error(42)
VM:1 42(anonymous function) @ VM:1evaluate @ (program)testFunction @ console-error-on-call-frame.html:10 VM:1 42(anonymous function) @ VM:1evaluatetestFunction @ console-error-on-call-frame.html:10
undefined undefined
...@@ -236,8 +236,11 @@ WebInspector.DOMPresentationUtils.buildStackTracePreviewContents = function(targ ...@@ -236,8 +236,11 @@ WebInspector.DOMPresentationUtils.buildStackTracePreviewContents = function(targ
for (var stackFrame of stackTrace.callFrames) { for (var stackFrame of stackTrace.callFrames) {
var row = createElement("tr"); var row = createElement("tr");
row.createChild("td", "function-name").textContent = WebInspector.beautifyFunctionName(stackFrame.functionName); row.createChild("td", "function-name").textContent = WebInspector.beautifyFunctionName(stackFrame.functionName);
row.createChild("td").textContent = " @ "; var link = linkifier.maybeLinkifyConsoleCallFrame(target, stackFrame);
row.createChild("td").appendChild(linkifier.linkifyConsoleCallFrame(target, stackFrame)); if (link) {
row.createChild("td").textContent = " @ ";
row.createChild("td").appendChild(link);
}
contentElement.appendChild(row); contentElement.appendChild(row);
} }
} }
......
...@@ -160,19 +160,20 @@ WebInspector.Linkifier.prototype = { ...@@ -160,19 +160,20 @@ WebInspector.Linkifier.prototype = {
* @param {number} lineNumber * @param {number} lineNumber
* @param {number=} columnNumber * @param {number=} columnNumber
* @param {string=} classes * @param {string=} classes
* @return {!Element} * @return {?Element}
*/ */
linkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, columnNumber, classes) maybeLinkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, columnNumber, classes)
{ {
var fallbackAnchor = WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, columnNumber, classes); var fallbackAnchor = sourceURL ? WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, columnNumber, classes) : null;
if (!target || target.isDetached()) if (!target || target.isDetached())
return fallbackAnchor; return fallbackAnchor;
var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
if (!debuggerModel) if (!debuggerModel)
return fallbackAnchor; return fallbackAnchor;
var rawLocation = scriptId ? debuggerModel.createRawLocationByScriptId(scriptId, lineNumber, columnNumber || 0) : var rawLocation =
debuggerModel.createRawLocationByURL(sourceURL, lineNumber, columnNumber || 0); debuggerModel.createRawLocationByScriptId(scriptId, lineNumber, columnNumber || 0) ||
debuggerModel.createRawLocationByURL(sourceURL, lineNumber, columnNumber || 0);
if (!rawLocation) if (!rawLocation)
return fallbackAnchor; return fallbackAnchor;
...@@ -185,6 +186,21 @@ WebInspector.Linkifier.prototype = { ...@@ -185,6 +186,21 @@ WebInspector.Linkifier.prototype = {
return anchor; return anchor;
}, },
/**
* @param {?WebInspector.Target} target
* @param {?string} scriptId
* @param {string} sourceURL
* @param {number} lineNumber
* @param {number=} columnNumber
* @param {string=} classes
* @return {!Element}
*/
linkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, columnNumber, classes)
{
return this.maybeLinkifyScriptLocation(target, scriptId, sourceURL, lineNumber, columnNumber, classes)
|| WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, columnNumber, classes);
},
/** /**
* @param {!WebInspector.DebuggerModel.Location} rawLocation * @param {!WebInspector.DebuggerModel.Location} rawLocation
* @param {string} fallbackUrl * @param {string} fallbackUrl
...@@ -200,20 +216,20 @@ WebInspector.Linkifier.prototype = { ...@@ -200,20 +216,20 @@ WebInspector.Linkifier.prototype = {
* @param {?WebInspector.Target} target * @param {?WebInspector.Target} target
* @param {!RuntimeAgent.CallFrame} callFrame * @param {!RuntimeAgent.CallFrame} callFrame
* @param {string=} classes * @param {string=} classes
* @return {!Element} * @return {?Element}
*/ */
linkifyConsoleCallFrame: function(target, callFrame, classes) maybeLinkifyConsoleCallFrame: function(target, callFrame, classes)
{ {
return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, callFrame.lineNumber, callFrame.columnNumber, classes); return this.maybeLinkifyScriptLocation(target, callFrame.scriptId, callFrame.url, callFrame.lineNumber, callFrame.columnNumber, classes);
}, },
/** /**
* @param {?WebInspector.Target} target * @param {?WebInspector.Target} target
* @param {!RuntimeAgent.CallFrame} callFrame * @param {!RuntimeAgent.CallFrame} callFrame
* @param {string=} classes * @param {string=} classes
* @return {!Element} * @return {?Element}
*/ */
linkifyConsoleCallFrameForTimeline: function(target, callFrame, classes) maybeLinkifyConsoleCallFrameForTimeline: function(target, callFrame, classes)
{ {
// TODO(kozyatinskiy): remove this when Profilers will migrate to 0-based lineNumber and columnNumber. // TODO(kozyatinskiy): remove this when Profilers will migrate to 0-based lineNumber and columnNumber.
return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, callFrame.lineNumber - 1, callFrame.columnNumber - 1, classes); return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, callFrame.lineNumber - 1, callFrame.columnNumber - 1, classes);
...@@ -534,7 +550,12 @@ WebInspector.linkifyStringAsFragment = function(string) ...@@ -534,7 +550,12 @@ WebInspector.linkifyStringAsFragment = function(string)
*/ */
WebInspector.linkifyResourceAsNode = function(url, lineNumber, columnNumber, classes, tooltipText, urlDisplayName) WebInspector.linkifyResourceAsNode = function(url, lineNumber, columnNumber, classes, tooltipText, urlDisplayName)
{ {
var linkText = urlDisplayName ? urlDisplayName : url ? WebInspector.displayNameForURL(url) : WebInspector.UIString("(program)"); if (!url) {
var element = createElementWithClass("span", classes);
element.textContent = urlDisplayName || WebInspector.UIString("(unknown)");
return element;
}
var linkText = urlDisplayName || WebInspector.displayNameForURL(url);
if (typeof lineNumber === "number") if (typeof lineNumber === "number")
linkText += ":" + (lineNumber + 1); linkText += ":" + (lineNumber + 1);
var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText); var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText);
......
...@@ -103,10 +103,8 @@ WebInspector.ObjectPopoverHelper.prototype = { ...@@ -103,10 +103,8 @@ WebInspector.ObjectPopoverHelper.prototype = {
sectionToolbar.appendToolbarItem(stepInto); sectionToolbar.appendToolbarItem(stepInto);
} }
var sourceURL = rawLocation && rawLocation.script() ? rawLocation.script().sourceURL : null; var sourceURL = rawLocation && rawLocation.script() ? rawLocation.script().sourceURL : null;
if (rawLocation && sourceURL) { if (rawLocation && sourceURL)
var link = this._lazyLinkifier().linkifyRawLocation(rawLocation, sourceURL); linkContainer.appendChild(this._lazyLinkifier().linkifyRawLocation(rawLocation, sourceURL));
linkContainer.appendChild(link);
}
container.appendChild(popoverContentElement); container.appendChild(popoverContentElement);
popover.showForAnchor(container, anchorElement); popover.showForAnchor(container, anchorElement);
} }
......
...@@ -1068,8 +1068,7 @@ WebInspector.ObjectPropertiesSection.createValueElement = function(value, wasThr ...@@ -1068,8 +1068,7 @@ WebInspector.ObjectPropertiesSection.createValueElement = function(value, wasThr
var rawLocation = value.debuggerModel().createRawLocationByScriptId(value.value.scriptId, value.value.lineNumber, value.value.columnNumber); var rawLocation = value.debuggerModel().createRawLocationByScriptId(value.value.scriptId, value.value.lineNumber, value.value.columnNumber);
if (rawLocation && linkifier) if (rawLocation && linkifier)
return linkifier.linkifyRawLocation(rawLocation, ""); return linkifier.linkifyRawLocation(rawLocation, "");
else valueElement.textContent = "<unknown>";
valueElement.textContent = "<unknown>";
} }
function mouseMove() function mouseMove()
......
...@@ -345,11 +345,11 @@ WebInspector.CPUProfileView.NodeFormatter.prototype = { ...@@ -345,11 +345,11 @@ WebInspector.CPUProfileView.NodeFormatter.prototype = {
/** /**
* @override * @override
* @param {!WebInspector.ProfileDataGridNode} node * @param {!WebInspector.ProfileDataGridNode} node
* @return {!Element} * @return {?Element}
*/ */
linkifyNode: function(node) linkifyNode: function(node)
{ {
return this._profileView.linkifier().linkifyConsoleCallFrame(this._profileView.target(), node.profileNode.callFrame, "profile-node-file"); return this._profileView.linkifier().maybeLinkifyConsoleCallFrame(this._profileView.target(), node.profileNode.callFrame, "profile-node-file");
} }
} }
...@@ -485,9 +485,10 @@ WebInspector.CPUFlameChartDataProvider.prototype = { ...@@ -485,9 +485,10 @@ WebInspector.CPUFlameChartDataProvider.prototype = {
pushEntryInfoRow(WebInspector.UIString("Self time"), selfTime); pushEntryInfoRow(WebInspector.UIString("Self time"), selfTime);
pushEntryInfoRow(WebInspector.UIString("Total time"), totalTime); pushEntryInfoRow(WebInspector.UIString("Total time"), totalTime);
var linkifier = new WebInspector.Linkifier(); var linkifier = new WebInspector.Linkifier();
var text = linkifier.linkifyConsoleCallFrame(this._target, node.callFrame).textContent; var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.callFrame);
if (link)
pushEntryInfoRow(WebInspector.UIString("URL"), link.textContent);
linkifier.dispose(); linkifier.dispose();
pushEntryInfoRow(WebInspector.UIString("URL"), text);
pushEntryInfoRow(WebInspector.UIString("Aggregated self time"), Number.secondsToString(node.self / 1000, true)); pushEntryInfoRow(WebInspector.UIString("Aggregated self time"), Number.secondsToString(node.self / 1000, true));
pushEntryInfoRow(WebInspector.UIString("Aggregated total time"), Number.secondsToString(node.total / 1000, true)); pushEntryInfoRow(WebInspector.UIString("Aggregated total time"), Number.secondsToString(node.total / 1000, true));
if (node.deoptReason && node.deoptReason !== "no reason") if (node.deoptReason && node.deoptReason !== "no reason")
......
...@@ -308,11 +308,11 @@ WebInspector.HeapProfileView.NodeFormatter.prototype = { ...@@ -308,11 +308,11 @@ WebInspector.HeapProfileView.NodeFormatter.prototype = {
/** /**
* @override * @override
* @param {!WebInspector.ProfileDataGridNode} node * @param {!WebInspector.ProfileDataGridNode} node
* @return {!Element} * @return {?Element}
*/ */
linkifyNode: function(node) linkifyNode: function(node)
{ {
return this._profileView.linkifier().linkifyConsoleCallFrame(this._profileView.target(), node.profileNode.callFrame, "profile-node-file"); return this._profileView.linkifier().maybeLinkifyConsoleCallFrame(this._profileView.target(), node.profileNode.callFrame, "profile-node-file");
} }
} }
...@@ -432,9 +432,10 @@ WebInspector.HeapFlameChartDataProvider.prototype = { ...@@ -432,9 +432,10 @@ WebInspector.HeapFlameChartDataProvider.prototype = {
pushEntryInfoRow(WebInspector.UIString("Self size"), Number.bytesToString(node.self)); pushEntryInfoRow(WebInspector.UIString("Self size"), Number.bytesToString(node.self));
pushEntryInfoRow(WebInspector.UIString("Total size"), Number.bytesToString(node.total)); pushEntryInfoRow(WebInspector.UIString("Total size"), Number.bytesToString(node.total));
var linkifier = new WebInspector.Linkifier(); var linkifier = new WebInspector.Linkifier();
var text = (new WebInspector.Linkifier()).linkifyConsoleCallFrame(this._target, node.callFrame).textContent; var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.callFrame);
if (link)
pushEntryInfoRow(WebInspector.UIString("URL"), link.textContent);
linkifier.dispose(); linkifier.dispose();
pushEntryInfoRow(WebInspector.UIString("URL"), text);
return entryInfo; return entryInfo;
}, },
......
...@@ -80,6 +80,8 @@ WebInspector.ProfileDataGridNode.prototype = { ...@@ -80,6 +80,8 @@ WebInspector.ProfileDataGridNode.prototype = {
if (this.profileNode.scriptId === "0") if (this.profileNode.scriptId === "0")
break; break;
var urlElement = this.tree._formatter.linkifyNode(this); var urlElement = this.tree._formatter.linkifyNode(this);
if (!urlElement)
break;
urlElement.style.maxWidth = "75%"; urlElement.style.maxWidth = "75%";
cell.appendChild(urlElement); cell.appendChild(urlElement);
break; break;
...@@ -648,7 +650,7 @@ WebInspector.ProfileDataGridNode.Formatter.prototype = { ...@@ -648,7 +650,7 @@ WebInspector.ProfileDataGridNode.Formatter.prototype = {
/** /**
* @param {!WebInspector.ProfileDataGridNode} node * @param {!WebInspector.ProfileDataGridNode} node
* @return {!Element} * @return {?Element}
*/ */
linkifyNode: function(node) { } linkifyNode: function(node) { }
} }
...@@ -82,11 +82,11 @@ WebInspector.TimelineTreeView.prototype = { ...@@ -82,11 +82,11 @@ WebInspector.TimelineTreeView.prototype = {
/** /**
* @param {!RuntimeAgent.CallFrame} frame * @param {!RuntimeAgent.CallFrame} frame
* @return {!Element} * @return {?Element}
*/ */
linkifyLocation: function(frame) linkifyLocation: function(frame)
{ {
return this._linkifier.linkifyConsoleCallFrameForTimeline(this._model.target(), frame); return this._linkifier.maybeLinkifyConsoleCallFrameForTimeline(this._model.target(), frame);
}, },
/** /**
...@@ -347,7 +347,9 @@ WebInspector.TimelineTreeView.GridNode.prototype = { ...@@ -347,7 +347,9 @@ WebInspector.TimelineTreeView.GridNode.prototype = {
var frame = WebInspector.TimelineProfileTree.eventStackFrame(event); var frame = WebInspector.TimelineProfileTree.eventStackFrame(event);
if (frame && frame["url"]) { if (frame && frame["url"]) {
var callFrame = /** @type {!RuntimeAgent.CallFrame} */ (frame); var callFrame = /** @type {!RuntimeAgent.CallFrame} */ (frame);
container.createChild("div", "activity-link").appendChild(this._treeView.linkifyLocation(callFrame)); var link = this._treeView.linkifyLocation(callFrame);
if (link)
container.createChild("div", "activity-link").appendChild(link);
} }
icon.style.backgroundColor = WebInspector.TimelineUIUtils.eventColor(event); icon.style.backgroundColor = WebInspector.TimelineUIUtils.eventColor(event);
} }
......
...@@ -530,7 +530,7 @@ WebInspector.TimelineUIUtils.buildDetailsTextForTraceEvent = function(event, tar ...@@ -530,7 +530,7 @@ WebInspector.TimelineUIUtils.buildDetailsTextForTraceEvent = function(event, tar
WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, target, linkifier) WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, target, linkifier)
{ {
var recordType = WebInspector.TimelineModel.RecordType; var recordType = WebInspector.TimelineModel.RecordType;
var details; var details = null;
var detailsText; var detailsText;
var eventData = event.args["data"]; var eventData = event.args["data"];
switch (event.name) { switch (event.name) {
...@@ -604,6 +604,7 @@ WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, tar ...@@ -604,6 +604,7 @@ WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, tar
* @param {string} url * @param {string} url
* @param {number} lineNumber * @param {number} lineNumber
* @param {number=} columnNumber * @param {number=} columnNumber
* @return {?Element}
*/ */
function linkifyLocation(scriptId, url, lineNumber, columnNumber) function linkifyLocation(scriptId, url, lineNumber, columnNumber)
{ {
...@@ -619,7 +620,7 @@ WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, tar ...@@ -619,7 +620,7 @@ WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, tar
function linkifyTopCallFrame() function linkifyTopCallFrame()
{ {
var frame = WebInspector.TimelineUIUtils.topStackFrame(event); var frame = WebInspector.TimelineUIUtils.topStackFrame(event);
return frame ? linkifier.linkifyConsoleCallFrameForTimeline(target, frame, "timeline-details") : null; return frame ? linkifier.maybeLinkifyConsoleCallFrameForTimeline(target, frame, "timeline-details") : null;
} }
} }
...@@ -996,11 +997,16 @@ WebInspector.TimelineUIUtils.buildNetworkRequestDetails = function(request, mode ...@@ -996,11 +997,16 @@ WebInspector.TimelineUIUtils.buildNetworkRequestDetails = function(request, mode
var sendRequest = request.children[0]; var sendRequest = request.children[0];
var topFrame = WebInspector.TimelineUIUtils.topStackFrame(sendRequest); var topFrame = WebInspector.TimelineUIUtils.topStackFrame(sendRequest);
if (topFrame) { if (topFrame) {
contentHelper.appendElementRow(title, linkifier.linkifyConsoleCallFrameForTimeline(target, topFrame)); var link = linkifier.maybeLinkifyConsoleCallFrameForTimeline(target, topFrame);
if (link)
contentHelper.appendElementRow(title, link);
} else if (sendRequest.initiator) { } else if (sendRequest.initiator) {
var initiatorURL = WebInspector.TimelineUIUtils.eventURL(sendRequest.initiator); var initiatorURL = WebInspector.TimelineUIUtils.eventURL(sendRequest.initiator);
if (initiatorURL) if (initiatorURL) {
contentHelper.appendElementRow(title, linkifier.linkifyScriptLocation(target, null, initiatorURL, 0)); var link = linkifier.maybeLinkifyScriptLocation(target, null, initiatorURL, 0);
if (link)
contentHelper.appendElementRow(title, link);
}
} }
/** /**
...@@ -1240,8 +1246,11 @@ WebInspector.TimelineUIUtils.InvalidationsGroupElement.prototype = { ...@@ -1240,8 +1246,11 @@ WebInspector.TimelineUIUtils.InvalidationsGroupElement.prototype = {
title.createTextChild(WebInspector.UIString(". ")); title.createTextChild(WebInspector.UIString(". "));
var stack = title.createChild("span", "monospace"); var stack = title.createChild("span", "monospace");
stack.createChild("span").textContent = WebInspector.beautifyFunctionName(topFrame.functionName); stack.createChild("span").textContent = WebInspector.beautifyFunctionName(topFrame.functionName);
stack.createChild("span").textContent = " @ "; var link = this._contentHelper.linkifier().maybeLinkifyConsoleCallFrameForTimeline(target, topFrame);
stack.createChild("span").appendChild(this._contentHelper.linkifier().linkifyConsoleCallFrameForTimeline(target, topFrame)); if (link) {
stack.createChild("span").textContent = " @ ";
stack.createChild("span").appendChild(link);
}
} }
return title; return title;
...@@ -2051,7 +2060,10 @@ WebInspector.TimelineDetailsContentHelper.prototype = { ...@@ -2051,7 +2060,10 @@ WebInspector.TimelineDetailsContentHelper.prototype = {
return; return;
if (startColumn) if (startColumn)
--startColumn; --startColumn;
this.appendElementRow(title, this._linkifier.linkifyScriptLocation(this._target, null, url, startLine - 1, startColumn)); var link = this._linkifier.maybeLinkifyScriptLocation(this._target, null, url, startLine - 1, startColumn);
if (!link)
return;
this.appendElementRow(title, link);
}, },
/** /**
...@@ -2065,7 +2077,10 @@ WebInspector.TimelineDetailsContentHelper.prototype = { ...@@ -2065,7 +2077,10 @@ WebInspector.TimelineDetailsContentHelper.prototype = {
if (!this._linkifier || !this._target) if (!this._linkifier || !this._target)
return; return;
var locationContent = createElement("span"); var locationContent = createElement("span");
locationContent.appendChild(this._linkifier.linkifyScriptLocation(this._target, null, url, startLine - 1)); var link = this._linkifier.maybeLinkifyScriptLocation(this._target, null, url, startLine - 1);
if (!link)
return;
locationContent.appendChild(link);
locationContent.createTextChild(String.sprintf(" [%s\u2026%s]", startLine, endLine || "")); locationContent.createTextChild(String.sprintf(" [%s\u2026%s]", startLine, endLine || ""));
this.appendElementRow(title, locationContent); this.appendElementRow(title, locationContent);
}, },
......
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