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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/Linkifier.js

Issue 2151653005: DevTools: Do not linkify to pseudo (program) node when there's no URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments. Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 }, 154 },
155 155
156 /** 156 /**
157 * @param {?WebInspector.Target} target 157 * @param {?WebInspector.Target} target
158 * @param {?string} scriptId 158 * @param {?string} scriptId
159 * @param {string} sourceURL 159 * @param {string} sourceURL
160 * @param {number} lineNumber 160 * @param {number} lineNumber
161 * @param {number=} columnNumber 161 * @param {number=} columnNumber
162 * @param {string=} classes 162 * @param {string=} classes
163 * @return {!Element} 163 * @return {?Element}
164 */ 164 */
165 linkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, col umnNumber, classes) 165 maybeLinkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber , columnNumber, classes)
166 { 166 {
167 var fallbackAnchor = WebInspector.linkifyResourceAsNode(sourceURL, lineN umber, columnNumber, classes); 167 var fallbackAnchor = sourceURL ? WebInspector.linkifyResourceAsNode(sour ceURL, lineNumber, columnNumber, classes) : null;
168 if (!target || target.isDetached()) 168 if (!target || target.isDetached())
169 return fallbackAnchor; 169 return fallbackAnchor;
170 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 170 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
171 if (!debuggerModel) 171 if (!debuggerModel)
172 return fallbackAnchor; 172 return fallbackAnchor;
173 173
174 var rawLocation = scriptId ? debuggerModel.createRawLocationByScriptId(s criptId, lineNumber, columnNumber || 0) : 174 var rawLocation = scriptId
175 debuggerModel.createRawLocationByURL(source URL, lineNumber, columnNumber || 0); 175 ? debuggerModel.createRawLocationByScriptId(scriptId, lineNumber, co lumnNumber || 0)
176 : debuggerModel.createRawLocationByURL(sourceURL, lineNumber, column Number || 0);
176 if (!rawLocation) 177 if (!rawLocation)
177 return fallbackAnchor; 178 return fallbackAnchor;
178 179
179 var anchor = this._createAnchor(classes); 180 var anchor = this._createAnchor(classes);
180 var liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocat ion(rawLocation, this._updateAnchor.bind(this, anchor), /** @type {!WebInspector .LiveLocationPool} */(this._locationPoolByTarget.get(rawLocation.target()))); 181 var liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocat ion(rawLocation, this._updateAnchor.bind(this, anchor), /** @type {!WebInspector .LiveLocationPool} */(this._locationPoolByTarget.get(rawLocation.target())));
181 var anchors = /** @type {!Array<!Element>} */(this._anchorsByTarget.get( rawLocation.target())); 182 var anchors = /** @type {!Array<!Element>} */(this._anchorsByTarget.get( rawLocation.target()));
182 anchors.push(anchor); 183 anchors.push(anchor);
183 anchor[WebInspector.Linkifier._liveLocationSymbol] = liveLocation; 184 anchor[WebInspector.Linkifier._liveLocationSymbol] = liveLocation;
184 anchor[WebInspector.Linkifier._fallbackAnchorSymbol] = fallbackAnchor; 185 anchor[WebInspector.Linkifier._fallbackAnchorSymbol] = fallbackAnchor;
185 return anchor; 186 return anchor;
186 }, 187 },
187 188
188 /** 189 /**
190 * @param {?WebInspector.Target} target
191 * @param {?string} scriptId
192 * @param {string} sourceURL
193 * @param {number} lineNumber
194 * @param {number=} columnNumber
195 * @param {string=} classes
196 * @return {!Element}
197 */
198 linkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, col umnNumber, classes)
199 {
200 return this.maybeLinkifyScriptLocation(target, scriptId, sourceURL, line Number, columnNumber, classes)
201 || WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, columnN umber, classes);
202 },
203
204 /**
189 * @param {!WebInspector.DebuggerModel.Location} rawLocation 205 * @param {!WebInspector.DebuggerModel.Location} rawLocation
190 * @param {string} fallbackUrl 206 * @param {string} fallbackUrl
191 * @param {string=} classes 207 * @param {string=} classes
192 * @return {!Element} 208 * @return {!Element}
193 */ 209 */
194 linkifyRawLocation: function(rawLocation, fallbackUrl, classes) 210 linkifyRawLocation: function(rawLocation, fallbackUrl, classes)
195 { 211 {
196 return this.linkifyScriptLocation(rawLocation.target(), rawLocation.scri ptId, fallbackUrl, rawLocation.lineNumber, rawLocation.columnNumber, classes); 212 return this.linkifyScriptLocation(rawLocation.target(), rawLocation.scri ptId, fallbackUrl, rawLocation.lineNumber, rawLocation.columnNumber, classes);
197 }, 213 },
198 214
199 /** 215 /**
200 * @param {?WebInspector.Target} target 216 * @param {?WebInspector.Target} target
201 * @param {!RuntimeAgent.CallFrame} callFrame 217 * @param {!RuntimeAgent.CallFrame} callFrame
202 * @param {string=} classes 218 * @param {string=} classes
203 * @return {!Element} 219 * @return {?Element}
204 */ 220 */
205 linkifyConsoleCallFrame: function(target, callFrame, classes) 221 linkifyConsoleCallFrame: function(target, callFrame, classes)
dgozman 2016/07/16 20:34:39 maybeLinkify...
alph 2016/07/18 19:28:53 Done.
206 { 222 {
207 return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame. url, callFrame.lineNumber, callFrame.columnNumber, classes); 223 return this.maybeLinkifyScriptLocation(target, callFrame.scriptId, callF rame.url, callFrame.lineNumber, callFrame.columnNumber, classes);
208 }, 224 },
209 225
210 /** 226 /**
211 * @param {?WebInspector.Target} target 227 * @param {?WebInspector.Target} target
212 * @param {!RuntimeAgent.CallFrame} callFrame 228 * @param {!RuntimeAgent.CallFrame} callFrame
213 * @param {string=} classes 229 * @param {string=} classes
214 * @return {!Element} 230 * @return {?Element}
215 */ 231 */
216 linkifyConsoleCallFrameForTimeline: function(target, callFrame, classes) 232 linkifyConsoleCallFrameForTimeline: function(target, callFrame, classes)
dgozman 2016/07/16 20:34:39 maybeLinkify...
alph 2016/07/18 19:28:54 Done.
217 { 233 {
218 // TODO(kozyatinskiy): remove this when Profilers will migrate to 0-base d lineNumber and columnNumber. 234 // TODO(kozyatinskiy): remove this when Profilers will migrate to 0-base d lineNumber and columnNumber.
219 return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame. url, callFrame.lineNumber - 1, callFrame.columnNumber - 1, classes); 235 return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame. url, callFrame.lineNumber - 1, callFrame.columnNumber - 1, classes);
220 }, 236 },
221 237
222 /** 238 /**
223 * @param {!WebInspector.Target} target 239 * @param {!WebInspector.Target} target
224 * @param {!RuntimeAgent.StackTrace} stackTrace 240 * @param {!RuntimeAgent.StackTrace} stackTrace
225 * @param {string=} classes 241 * @param {string=} classes
226 * @return {!Element} 242 * @return {!Element}
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 * @param {string} url 543 * @param {string} url
528 * @param {number=} lineNumber 544 * @param {number=} lineNumber
529 * @param {number=} columnNumber 545 * @param {number=} columnNumber
530 * @param {string=} classes 546 * @param {string=} classes
531 * @param {string=} tooltipText 547 * @param {string=} tooltipText
532 * @param {string=} urlDisplayName 548 * @param {string=} urlDisplayName
533 * @return {!Element} 549 * @return {!Element}
534 */ 550 */
535 WebInspector.linkifyResourceAsNode = function(url, lineNumber, columnNumber, cla sses, tooltipText, urlDisplayName) 551 WebInspector.linkifyResourceAsNode = function(url, lineNumber, columnNumber, cla sses, tooltipText, urlDisplayName)
536 { 552 {
537 var linkText = urlDisplayName ? urlDisplayName : url ? WebInspector.displayN ameForURL(url) : WebInspector.UIString("(program)"); 553 var linkText = urlDisplayName ? urlDisplayName : url ? WebInspector.displayN ameForURL(url) : WebInspector.UIString("(program)");
dgozman 2016/07/16 20:34:39 Let's return empty element instead of "(program)"?
alph 2016/07/18 19:28:53 Empty element would be weird, as some clients migh
538 if (typeof lineNumber === "number") 554 if (typeof lineNumber === "number")
539 linkText += ":" + (lineNumber + 1); 555 linkText += ":" + (lineNumber + 1);
540 var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, to oltipText); 556 var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, to oltipText);
541 anchor.lineNumber = lineNumber; 557 anchor.lineNumber = lineNumber;
542 anchor.columnNumber = columnNumber; 558 anchor.columnNumber = columnNumber;
543 return anchor; 559 return anchor;
544 } 560 }
545 561
546 /** 562 /**
547 * @param {!WebInspector.NetworkRequest} request 563 * @param {!WebInspector.NetworkRequest} request
548 * @return {!Element} 564 * @return {!Element}
549 */ 565 */
550 WebInspector.linkifyRequestAsNode = function(request) 566 WebInspector.linkifyRequestAsNode = function(request)
551 { 567 {
552 var anchor = WebInspector.linkifyURLAsNode(request.url); 568 var anchor = WebInspector.linkifyURLAsNode(request.url);
553 anchor.requestId = request.requestId; 569 anchor.requestId = request.requestId;
554 return anchor; 570 return anchor;
555 } 571 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698