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

Unified Diff: Source/devtools/front_end/sdk/Linkifier.js

Issue 404953004: DevTools: Refactor linkifyRawLocation to use fallback url (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address aandrey's comments Created 6 years, 5 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: Source/devtools/front_end/sdk/Linkifier.js
diff --git a/Source/devtools/front_end/sdk/Linkifier.js b/Source/devtools/front_end/sdk/Linkifier.js
index 5be06cfca6b96e3a44b22b1e5ed12f4dcd1e983f..42eaba6b1c3694a0255b5006a14e092b4f9b1215 100644
--- a/Source/devtools/front_end/sdk/Linkifier.js
+++ b/Source/devtools/front_end/sdk/Linkifier.js
@@ -142,57 +142,50 @@ WebInspector.Linkifier.prototype = {
/**
* @param {?WebInspector.Target} target
- * @param {string} scriptId
+ * @param {?string} scriptId
* @param {string} sourceURL
* @param {number} lineNumber
* @param {number=} columnNumber
* @param {string=} classes
- * @return {?Element}
+ * @return {!Element}
*/
- linkifyLocationByScriptId: function(target, scriptId, sourceURL, lineNumber, columnNumber, classes)
+ linkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, columnNumber, classes)
{
- var rawLocation = target ? target.debuggerModel.createRawLocationByScriptId(scriptId, sourceURL, lineNumber, columnNumber || 0) : null;
+ var rawLocation = target && !target.isDetached() ? target.debuggerModel.createRawLocationByScriptId(scriptId, sourceURL, lineNumber, columnNumber || 0) : null;
var fallbackAnchor = WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, classes);
if (!rawLocation)
return fallbackAnchor;
- var anchor = this.linkifyRawLocation(rawLocation, classes);
+ var anchor = this._createAnchor(classes);
+ var liveLocation = rawLocation.createLiveLocation(this._updateAnchor.bind(this, anchor));
+ this._liveLocationsByTarget.get(rawLocation.target()).push({anchor: anchor, location: liveLocation});
anchor.__fallbackAnchor = fallbackAnchor;
return anchor;
-
},
/**
- * @param {!WebInspector.Target} target
- * @param {string} sourceURL
- * @param {number} lineNumber
- * @param {number=} columnNumber
+ * @param {!WebInspector.DebuggerModel.Location} rawLocation
+ * @param {string} fallbackUrl
* @param {string=} classes
- * @return {?Element}
+ * @return {!Element}
*/
- linkifyLocation: function(target, sourceURL, lineNumber, columnNumber, classes)
+ linkifyRawLocation: function(rawLocation, fallbackUrl, classes)
{
- var rawLocation = target.debuggerModel.createRawLocationByURL(sourceURL, lineNumber, columnNumber || 0);
- if (!rawLocation)
- return WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, classes);
- return this.linkifyRawLocation(rawLocation, classes);
+ return this.linkifyScriptLocation(rawLocation.target(), rawLocation.scriptId, fallbackUrl, rawLocation.lineNumber, rawLocation.columnNumber, classes);
},
/**
- * @param {!WebInspector.DebuggerModel.Location} rawLocation
+ * @param {?WebInspector.Target} target
+ * @param {!ConsoleAgent.CallFrame} callFrame
* @param {string=} classes
- * @return {?Element}
+ * @return {!Element}
*/
- linkifyRawLocation: function(rawLocation, classes)
+ linkifyConsoleCallFrame: function(target, callFrame, classes)
{
- // FIXME: this check should not be here.
- var script = rawLocation.target().debuggerModel.scriptForId(rawLocation.scriptId);
- if (!script)
- return null;
- var anchor = this._createAnchor(classes);
- var liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor));
- this._liveLocationsByTarget.get(rawLocation.target()).push({anchor: anchor, location: liveLocation});
- return anchor;
+ // 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;
+ return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, callFrame.lineNumber, callFrame.columnNumber, classes);
},
/**

Powered by Google App Engine
This is Rietveld 408576698