Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 } | 44 } |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * @constructor | 47 * @constructor |
| 48 * @implements {WebInspector.TargetManager.Observer} | 48 * @implements {WebInspector.TargetManager.Observer} |
| 49 * @param {!WebInspector.LinkifierFormatter=} formatter | 49 * @param {!WebInspector.LinkifierFormatter=} formatter |
| 50 */ | 50 */ |
| 51 WebInspector.Linkifier = function(formatter) | 51 WebInspector.Linkifier = function(formatter) |
| 52 { | 52 { |
| 53 this._formatter = formatter || new WebInspector.Linkifier.DefaultFormatter(W ebInspector.Linkifier.MaxLengthForDisplayedURLs); | 53 this._formatter = formatter || new WebInspector.Linkifier.DefaultFormatter(W ebInspector.Linkifier.MaxLengthForDisplayedURLs); |
| 54 this._liveLocationsByTarget = new Map(); | 54 this._liveLocationsByTarget = new Map(); |
|
aandrey
2014/07/30 10:01:23
jsdoc plz
sergeyv
2014/07/30 13:43:01
Done.
| |
| 55 WebInspector.targetManager.observeTargets(this); | 55 WebInspector.targetManager.observeTargets(this); |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * @param {!WebInspector.Linkifier.LinkHandler} handler | 59 * @param {!WebInspector.Linkifier.LinkHandler} handler |
| 60 */ | 60 */ |
| 61 WebInspector.Linkifier.setLinkHandler = function(handler) | 61 WebInspector.Linkifier.setLinkHandler = function(handler) |
| 62 { | 62 { |
| 63 WebInspector.Linkifier._linkHandler = handler; | 63 WebInspector.Linkifier._linkHandler = handler; |
| 64 } | 64 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 anchor.title = anchor.__fallbackAnchor.title; | 135 anchor.title = anchor.__fallbackAnchor.title; |
| 136 anchor.className = anchor.__fallbackAnchor.className; | 136 anchor.className = anchor.__fallbackAnchor.className; |
| 137 anchor.textContent = anchor.__fallbackAnchor.textContent; | 137 anchor.textContent = anchor.__fallbackAnchor.textContent; |
| 138 } | 138 } |
| 139 liveLocations[i].location.dispose(); | 139 liveLocations[i].location.dispose(); |
| 140 } | 140 } |
| 141 }, | 141 }, |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * @param {?WebInspector.Target} target | 144 * @param {?WebInspector.Target} target |
| 145 * @param {string} scriptId | 145 * @param {?string} scriptId |
| 146 * @param {string} sourceURL | 146 * @param {string} sourceURL |
| 147 * @param {number} lineNumber | 147 * @param {number} lineNumber |
| 148 * @param {number=} columnNumber | 148 * @param {number=} columnNumber |
| 149 * @param {string=} classes | 149 * @param {string=} classes |
| 150 * @return {?Element} | 150 * @return {!Element} |
| 151 */ | 151 */ |
| 152 linkifyLocationByScriptId: function(target, scriptId, sourceURL, lineNumber, columnNumber, classes) | 152 linkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, col umnNumber, classes) |
| 153 { | 153 { |
| 154 var rawLocation = target ? target.debuggerModel.createRawLocationByScrip tId(scriptId, sourceURL, lineNumber, columnNumber || 0) : null; | 154 var rawLocation = target && !target.isDetached() ? target.debuggerModel. createRawLocationByScriptId(scriptId, sourceURL, lineNumber, columnNumber || 0) : null; |
| 155 var fallbackAnchor = WebInspector.linkifyResourceAsNode(sourceURL, lineN umber, classes); | 155 var fallbackAnchor = WebInspector.linkifyResourceAsNode(sourceURL, lineN umber, classes); |
| 156 if (!rawLocation) | 156 if (!rawLocation) |
| 157 return fallbackAnchor; | 157 return fallbackAnchor; |
| 158 | 158 |
| 159 var anchor = this.linkifyRawLocation(rawLocation, classes); | 159 var anchor = this._createAnchor(classes); |
| 160 var liveLocation = rawLocation.createLiveLocation(this._updateAnchor.bin d(this, anchor)); | |
| 161 this._liveLocationsByTarget.get(rawLocation.target()).push({anchor: anch or, location: liveLocation}); | |
| 160 anchor.__fallbackAnchor = fallbackAnchor; | 162 anchor.__fallbackAnchor = fallbackAnchor; |
| 161 return anchor; | 163 return anchor; |
| 162 | |
| 163 }, | |
| 164 | |
| 165 /** | |
| 166 * @param {!WebInspector.Target} target | |
| 167 * @param {string} sourceURL | |
| 168 * @param {number} lineNumber | |
| 169 * @param {number=} columnNumber | |
| 170 * @param {string=} classes | |
| 171 * @return {?Element} | |
| 172 */ | |
| 173 linkifyLocation: function(target, sourceURL, lineNumber, columnNumber, class es) | |
| 174 { | |
| 175 var rawLocation = target.debuggerModel.createRawLocationByURL(sourceURL, lineNumber, columnNumber || 0); | |
| 176 if (!rawLocation) | |
| 177 return WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, cla sses); | |
| 178 return this.linkifyRawLocation(rawLocation, classes); | |
| 179 }, | 164 }, |
| 180 | 165 |
| 181 /** | 166 /** |
| 182 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 167 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 168 * @param {string} fallbackUrl | |
| 183 * @param {string=} classes | 169 * @param {string=} classes |
| 184 * @return {?Element} | 170 * @return {!Element} |
| 185 */ | 171 */ |
| 186 linkifyRawLocation: function(rawLocation, classes) | 172 linkifyRawLocation: function(rawLocation, fallbackUrl, classes) |
| 187 { | 173 { |
| 188 // FIXME: this check should not be here. | 174 return this.linkifyScriptLocation(rawLocation.target(), rawLocation.scri ptId, fallbackUrl, rawLocation.lineNumber, rawLocation.columnNumber, classes); |
| 189 var script = rawLocation.target().debuggerModel.scriptForId(rawLocation. scriptId); | |
| 190 if (!script) | |
| 191 return null; | |
| 192 var anchor = this._createAnchor(classes); | |
| 193 var liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocat ion(rawLocation, this._updateAnchor.bind(this, anchor)); | |
| 194 this._liveLocationsByTarget.get(rawLocation.target()).push({anchor: anch or, location: liveLocation}); | |
| 195 return anchor; | |
| 196 }, | 175 }, |
| 197 | 176 |
| 198 /** | 177 /** |
| 178 * @param {?WebInspector.Target} target | |
| 179 * @param {!ConsoleAgent.CallFrame} callFrame | |
| 180 * @param {string=} classes | |
| 181 * @return {!Element} | |
| 182 */ | |
| 183 linkifyConsoleCallFrame: function(target, callFrame, classes) | |
| 184 { | |
| 185 // FIXME(62725): console stack trace line/column numbers are one-based. | |
| 186 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; | |
| 187 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; | |
| 188 return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame. url, callFrame.lineNumber, callFrame.columnNumber, classes); | |
| 189 }, | |
| 190 | |
| 191 /** | |
| 199 * @param {!WebInspector.CSSLocation} rawLocation | 192 * @param {!WebInspector.CSSLocation} rawLocation |
| 200 * @param {string=} classes | 193 * @param {string=} classes |
| 201 * @return {?Element} | 194 * @return {?Element} |
| 202 */ | 195 */ |
| 203 linkifyCSSLocation: function(rawLocation, classes) | 196 linkifyCSSLocation: function(rawLocation, classes) |
| 204 { | 197 { |
| 205 var anchor = this._createAnchor(classes); | 198 var anchor = this._createAnchor(classes); |
| 206 var liveLocation = WebInspector.cssWorkspaceBinding.createLiveLocation(r awLocation, this._updateAnchor.bind(this, anchor)); | 199 var liveLocation = WebInspector.cssWorkspaceBinding.createLiveLocation(r awLocation, this._updateAnchor.bind(this, anchor)); |
| 207 if (!liveLocation) | 200 if (!liveLocation) |
| 208 return null; | 201 return null; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 */ | 351 */ |
| 359 WebInspector.Linkifier.liveLocationText = function(target, scriptId, lineNumber, columnNumber) | 352 WebInspector.Linkifier.liveLocationText = function(target, scriptId, lineNumber, columnNumber) |
| 360 { | 353 { |
| 361 var script = target.debuggerModel.scriptForId(scriptId); | 354 var script = target.debuggerModel.scriptForId(scriptId); |
| 362 if (!script) | 355 if (!script) |
| 363 return ""; | 356 return ""; |
| 364 var location = /** @type {!WebInspector.DebuggerModel.Location} */ (target.d ebuggerModel.createRawLocation(script, lineNumber, columnNumber || 0)); | 357 var location = /** @type {!WebInspector.DebuggerModel.Location} */ (target.d ebuggerModel.createRawLocation(script, lineNumber, columnNumber || 0)); |
| 365 var uiLocation = /** @type {!WebInspector.UILocation} */ (WebInspector.debug gerWorkspaceBinding.rawLocationToUILocation(location)); | 358 var uiLocation = /** @type {!WebInspector.UILocation} */ (WebInspector.debug gerWorkspaceBinding.rawLocationToUILocation(location)); |
| 366 return uiLocation.linkText(); | 359 return uiLocation.linkText(); |
| 367 } | 360 } |
| OLD | NEW |