| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 * @interface | 32 * @interface |
| 33 */ | 33 */ |
| 34 WebInspector.LinkifierFormatter = function() | 34 WebInspector.LinkifierFormatter = function() |
| 35 { | 35 { |
| 36 } | 36 } |
| 37 | 37 |
| 38 WebInspector.LinkifierFormatter.prototype = { | 38 WebInspector.LinkifierFormatter.prototype = { |
| 39 /** | 39 /** |
| 40 * @param {!Element} anchor | 40 * @param {!Element} anchor |
| 41 * @param {!WebInspector.UILocation} uiLocation | 41 * @param {!WebInspector.UILocation} uiLocation |
| 42 * @param {boolean} isBlackboxed |
| 42 */ | 43 */ |
| 43 formatLiveAnchor: function(anchor, uiLocation) { } | 44 formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) { } |
| 44 } | 45 } |
| 45 | 46 |
| 46 /** | 47 /** |
| 47 * @constructor | 48 * @constructor |
| 48 * @implements {WebInspector.TargetManager.Observer} | 49 * @implements {WebInspector.TargetManager.Observer} |
| 49 * @param {!WebInspector.LinkifierFormatter=} formatter | 50 * @param {!WebInspector.LinkifierFormatter=} formatter |
| 50 */ | 51 */ |
| 51 WebInspector.Linkifier = function(formatter) | 52 WebInspector.Linkifier = function(formatter) |
| 52 { | 53 { |
| 53 this._formatter = formatter || new WebInspector.Linkifier.DefaultFormatter(W
ebInspector.Linkifier.MaxLengthForDisplayedURLs); | 54 this._formatter = formatter || new WebInspector.Linkifier.DefaultFormatter(W
ebInspector.Linkifier.MaxLengthForDisplayedURLs); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 * @param {?WebInspector.Target} target | 196 * @param {?WebInspector.Target} target |
| 196 * @param {!RuntimeAgent.CallFrame} callFrame | 197 * @param {!RuntimeAgent.CallFrame} callFrame |
| 197 * @param {string=} classes | 198 * @param {string=} classes |
| 198 * @return {!Element} | 199 * @return {!Element} |
| 199 */ | 200 */ |
| 200 linkifyConsoleCallFrame: function(target, callFrame, classes) | 201 linkifyConsoleCallFrame: function(target, callFrame, classes) |
| 201 { | 202 { |
| 202 // FIXME(62725): console stack trace line/column numbers are one-based. | 203 // FIXME(62725): console stack trace line/column numbers are one-based. |
| 203 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; | 204 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; |
| 204 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 :
0; | 205 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 :
0; |
| 205 var anchor = this.linkifyScriptLocation(target, callFrame.scriptId, call
Frame.url, lineNumber, columnNumber, classes); | 206 return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.
url, lineNumber, columnNumber, classes); |
| 206 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | |
| 207 var location = debuggerModel && debuggerModel.createRawLocationByScriptI
d(callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber); | |
| 208 var blackboxed = location ? | |
| 209 WebInspector.blackboxManager.isBlackboxedRawLocation(location) : | |
| 210 WebInspector.blackboxManager.isBlackboxedURL(callFrame.url); | |
| 211 if (blackboxed) | |
| 212 anchor.classList.add("webkit-html-blackbox-link"); | |
| 213 | |
| 214 return anchor; | |
| 215 }, | 207 }, |
| 216 | 208 |
| 217 /** | 209 /** |
| 218 * @param {!WebInspector.CSSLocation} rawLocation | 210 * @param {!WebInspector.CSSLocation} rawLocation |
| 219 * @param {string=} classes | 211 * @param {string=} classes |
| 220 * @return {!Element} | 212 * @return {!Element} |
| 221 */ | 213 */ |
| 222 linkifyCSSLocation: function(rawLocation, classes) | 214 linkifyCSSLocation: function(rawLocation, classes) |
| 223 { | 215 { |
| 224 var anchor = this._createAnchor(classes); | 216 var anchor = this._createAnchor(classes); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 275 |
| 284 dispose: function() | 276 dispose: function() |
| 285 { | 277 { |
| 286 this.reset(); | 278 this.reset(); |
| 287 WebInspector.targetManager.unobserveTargets(this); | 279 WebInspector.targetManager.unobserveTargets(this); |
| 288 this._liveLocationsByTarget.clear(); | 280 this._liveLocationsByTarget.clear(); |
| 289 }, | 281 }, |
| 290 | 282 |
| 291 /** | 283 /** |
| 292 * @param {!Element} anchor | 284 * @param {!Element} anchor |
| 293 * @param {!WebInspector.UILocation} uiLocation | 285 * @param {!WebInspector.LiveLocation} liveLocation |
| 294 */ | 286 */ |
| 295 _updateAnchor: function(anchor, uiLocation) | 287 _updateAnchor: function(anchor, liveLocation) |
| 296 { | 288 { |
| 289 var uiLocation = liveLocation.uiLocation(); |
| 290 if (!uiLocation) |
| 291 return; |
| 297 anchor[WebInspector.Linkifier._uiLocationSymbol] = uiLocation; | 292 anchor[WebInspector.Linkifier._uiLocationSymbol] = uiLocation; |
| 298 this._formatter.formatLiveAnchor(anchor, uiLocation); | 293 this._formatter.formatLiveAnchor(anchor, uiLocation, liveLocation.isBlac
kboxed()); |
| 299 } | 294 } |
| 300 } | 295 } |
| 301 | 296 |
| 302 /** | 297 /** |
| 303 * @param {!Element} anchor | 298 * @param {!Element} anchor |
| 304 * @return {?WebInspector.UILocation} uiLocation | 299 * @return {?WebInspector.UILocation} uiLocation |
| 305 */ | 300 */ |
| 306 WebInspector.Linkifier.uiLocationByAnchor = function(anchor) | 301 WebInspector.Linkifier.uiLocationByAnchor = function(anchor) |
| 307 { | 302 { |
| 308 return anchor[WebInspector.Linkifier._uiLocationSymbol]; | 303 return anchor[WebInspector.Linkifier._uiLocationSymbol]; |
| 309 } | 304 } |
| 310 | 305 |
| 311 /** | 306 /** |
| 312 * @constructor | 307 * @constructor |
| 313 * @implements {WebInspector.LinkifierFormatter} | 308 * @implements {WebInspector.LinkifierFormatter} |
| 314 * @param {number=} maxLength | 309 * @param {number=} maxLength |
| 315 */ | 310 */ |
| 316 WebInspector.Linkifier.DefaultFormatter = function(maxLength) | 311 WebInspector.Linkifier.DefaultFormatter = function(maxLength) |
| 317 { | 312 { |
| 318 this._maxLength = maxLength; | 313 this._maxLength = maxLength; |
| 319 } | 314 } |
| 320 | 315 |
| 321 WebInspector.Linkifier.DefaultFormatter.prototype = { | 316 WebInspector.Linkifier.DefaultFormatter.prototype = { |
| 322 /** | 317 /** |
| 323 * @override | 318 * @override |
| 324 * @param {!Element} anchor | 319 * @param {!Element} anchor |
| 325 * @param {!WebInspector.UILocation} uiLocation | 320 * @param {!WebInspector.UILocation} uiLocation |
| 321 * @param {boolean} isBlackboxed |
| 326 */ | 322 */ |
| 327 formatLiveAnchor: function(anchor, uiLocation) | 323 formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) |
| 328 { | 324 { |
| 329 var text = uiLocation.linkText(); | 325 var text = uiLocation.linkText(); |
| 330 text = text.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, "$1\u2026"); | 326 text = text.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, "$1\u2026"); |
| 331 if (this._maxLength) | 327 if (this._maxLength) |
| 332 text = text.trimMiddle(this._maxLength); | 328 text = text.trimMiddle(this._maxLength); |
| 333 anchor.textContent = text; | 329 anchor.textContent = text; |
| 334 | 330 |
| 335 var titleText = uiLocation.uiSourceCode.url(); | 331 var titleText = uiLocation.uiSourceCode.url(); |
| 336 if (typeof uiLocation.lineNumber === "number") | 332 if (typeof uiLocation.lineNumber === "number") |
| 337 titleText += ":" + (uiLocation.lineNumber + 1); | 333 titleText += ":" + (uiLocation.lineNumber + 1); |
| 338 anchor.title = titleText; | 334 anchor.title = titleText; |
| 335 |
| 336 anchor.classList.toggle("webkit-html-blackbox-link", isBlackboxed); |
| 339 } | 337 } |
| 340 } | 338 } |
| 341 | 339 |
| 342 /** | 340 /** |
| 343 * @constructor | 341 * @constructor |
| 344 * @extends {WebInspector.Linkifier.DefaultFormatter} | 342 * @extends {WebInspector.Linkifier.DefaultFormatter} |
| 345 */ | 343 */ |
| 346 WebInspector.Linkifier.DefaultCSSFormatter = function() | 344 WebInspector.Linkifier.DefaultCSSFormatter = function() |
| 347 { | 345 { |
| 348 WebInspector.Linkifier.DefaultFormatter.call(this, WebInspector.Linkifier.De
faultCSSFormatter.MaxLengthForDisplayedURLs); | 346 WebInspector.Linkifier.DefaultFormatter.call(this, WebInspector.Linkifier.De
faultCSSFormatter.MaxLengthForDisplayedURLs); |
| 349 } | 347 } |
| 350 | 348 |
| 351 WebInspector.Linkifier.DefaultCSSFormatter.MaxLengthForDisplayedURLs = 30; | 349 WebInspector.Linkifier.DefaultCSSFormatter.MaxLengthForDisplayedURLs = 30; |
| 352 | 350 |
| 353 WebInspector.Linkifier.DefaultCSSFormatter.prototype = { | 351 WebInspector.Linkifier.DefaultCSSFormatter.prototype = { |
| 354 /** | 352 /** |
| 355 * @override | 353 * @override |
| 356 * @param {!Element} anchor | 354 * @param {!Element} anchor |
| 357 * @param {!WebInspector.UILocation} uiLocation | 355 * @param {!WebInspector.UILocation} uiLocation |
| 356 * @param {boolean} isBlackboxed |
| 358 */ | 357 */ |
| 359 formatLiveAnchor: function(anchor, uiLocation) | 358 formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) |
| 360 { | 359 { |
| 361 WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor.call(
this, anchor, uiLocation); | 360 WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor.call(
this, anchor, uiLocation, isBlackboxed); |
| 362 anchor.classList.add("webkit-html-resource-link"); | 361 anchor.classList.add("webkit-html-resource-link"); |
| 363 anchor.setAttribute("data-uncopyable", anchor.textContent); | 362 anchor.setAttribute("data-uncopyable", anchor.textContent); |
| 364 anchor.textContent = ""; | 363 anchor.textContent = ""; |
| 365 }, | 364 }, |
| 366 __proto__: WebInspector.Linkifier.DefaultFormatter.prototype | 365 __proto__: WebInspector.Linkifier.DefaultFormatter.prototype |
| 367 } | 366 } |
| 368 | 367 |
| 369 /** | 368 /** |
| 370 * The maximum number of characters to display in a URL. | 369 * The maximum number of characters to display in a URL. |
| 371 * @const | 370 * @const |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 /** | 540 /** |
| 542 * @param {!WebInspector.NetworkRequest} request | 541 * @param {!WebInspector.NetworkRequest} request |
| 543 * @return {!Element} | 542 * @return {!Element} |
| 544 */ | 543 */ |
| 545 WebInspector.linkifyRequestAsNode = function(request) | 544 WebInspector.linkifyRequestAsNode = function(request) |
| 546 { | 545 { |
| 547 var anchor = WebInspector.linkifyURLAsNode(request.url); | 546 var anchor = WebInspector.linkifyURLAsNode(request.url); |
| 548 anchor.requestId = request.requestId; | 547 anchor.requestId = request.requestId; |
| 549 return anchor; | 548 return anchor; |
| 550 } | 549 } |
| OLD | NEW |