| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | |
| 5 /** | 4 /** |
| 6 * @constructor | |
| 7 * @implements {WebInspector.TargetManager.Observer} | 5 * @implements {WebInspector.TargetManager.Observer} |
| 8 * @param {!WebInspector.TargetManager} targetManager | 6 * @unrestricted |
| 9 * @param {!WebInspector.Workspace} workspace | |
| 10 * @param {!WebInspector.NetworkMapping} networkMapping | |
| 11 */ | 7 */ |
| 12 WebInspector.DebuggerWorkspaceBinding = function(targetManager, workspace, netwo
rkMapping) | 8 WebInspector.DebuggerWorkspaceBinding = class { |
| 13 { | 9 /** |
| 10 * @param {!WebInspector.TargetManager} targetManager |
| 11 * @param {!WebInspector.Workspace} workspace |
| 12 * @param {!WebInspector.NetworkMapping} networkMapping |
| 13 */ |
| 14 constructor(targetManager, workspace, networkMapping) { |
| 14 this._workspace = workspace; | 15 this._workspace = workspace; |
| 15 this._networkMapping = networkMapping; | 16 this._networkMapping = networkMapping; |
| 16 | 17 |
| 17 // FIXME: Migrate from _targetToData to _debuggerModelToData. | 18 // FIXME: Migrate from _targetToData to _debuggerModelToData. |
| 18 /** @type {!Map.<!WebInspector.Target, !WebInspector.DebuggerWorkspaceBindin
g.TargetData>} */ | 19 /** @type {!Map.<!WebInspector.Target, !WebInspector.DebuggerWorkspaceBindin
g.TargetData>} */ |
| 19 this._targetToData = new Map(); | 20 this._targetToData = new Map(); |
| 20 targetManager.observeTargets(this); | 21 targetManager.observeTargets(this); |
| 21 | 22 |
| 22 targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.Debu
ggerModel.Events.GlobalObjectCleared, this._globalObjectCleared, this); | 23 targetManager.addModelListener( |
| 23 targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.Debu
ggerModel.Events.BeforeDebuggerPaused, this._beforeDebuggerPaused, this); | 24 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObje
ctCleared, this._globalObjectCleared, |
| 24 targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.Debu
ggerModel.Events.DebuggerResumed, this._debuggerResumed, this); | 25 this); |
| 26 targetManager.addModelListener( |
| 27 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.BeforeDebu
ggerPaused, this._beforeDebuggerPaused, |
| 28 this); |
| 29 targetManager.addModelListener( |
| 30 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerRe
sumed, this._debuggerResumed, this); |
| 25 workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved
, this._uiSourceCodeRemoved, this); | 31 workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved
, this._uiSourceCodeRemoved, this); |
| 26 workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemoved, thi
s._projectRemoved, this); | 32 workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemoved, thi
s._projectRemoved, this); |
| 33 } |
| 34 |
| 35 /** |
| 36 * @override |
| 37 * @param {!WebInspector.Target} target |
| 38 */ |
| 39 targetAdded(target) { |
| 40 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
| 41 if (debuggerModel) |
| 42 this._targetToData.set(target, new WebInspector.DebuggerWorkspaceBinding.T
argetData(debuggerModel, this)); |
| 43 } |
| 44 |
| 45 /** |
| 46 * @override |
| 47 * @param {!WebInspector.Target} target |
| 48 */ |
| 49 targetRemoved(target) { |
| 50 if (!WebInspector.DebuggerModel.fromTarget(target)) |
| 51 return; |
| 52 var targetData = this._targetToData.get(target); |
| 53 targetData._dispose(); |
| 54 this._targetToData.remove(target); |
| 55 } |
| 56 |
| 57 /** |
| 58 * @param {!WebInspector.Event} event |
| 59 */ |
| 60 _uiSourceCodeRemoved(event) { |
| 61 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); |
| 62 var targetDatas = this._targetToData.valuesArray(); |
| 63 for (var i = 0; i < targetDatas.length; ++i) |
| 64 targetDatas[i]._uiSourceCodeRemoved(uiSourceCode); |
| 65 } |
| 66 |
| 67 /** |
| 68 * @param {!WebInspector.Event} event |
| 69 */ |
| 70 _projectRemoved(event) { |
| 71 var project = /** @type {!WebInspector.Project} */ (event.data); |
| 72 var targetDatas = this._targetToData.valuesArray(); |
| 73 var uiSourceCodes = project.uiSourceCodes(); |
| 74 for (var i = 0; i < targetDatas.length; ++i) { |
| 75 for (var j = 0; j < uiSourceCodes.length; ++j) |
| 76 targetDatas[i]._uiSourceCodeRemoved(uiSourceCodes[j]); |
| 77 } |
| 78 } |
| 79 |
| 80 /** |
| 81 * @param {!WebInspector.Script} script |
| 82 * @param {!WebInspector.DebuggerSourceMapping} sourceMapping |
| 83 */ |
| 84 pushSourceMapping(script, sourceMapping) { |
| 85 var info = this._ensureInfoForScript(script); |
| 86 info._pushSourceMapping(sourceMapping); |
| 87 } |
| 88 |
| 89 /** |
| 90 * @param {!WebInspector.Script} script |
| 91 * @return {!WebInspector.DebuggerSourceMapping} |
| 92 */ |
| 93 popSourceMapping(script) { |
| 94 var info = this._infoForScript(script.target(), script.scriptId); |
| 95 console.assert(info); |
| 96 return info._popSourceMapping(); |
| 97 } |
| 98 |
| 99 /** |
| 100 * @param {!WebInspector.Target} target |
| 101 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 102 * @param {?WebInspector.DebuggerSourceMapping} sourceMapping |
| 103 */ |
| 104 setSourceMapping(target, uiSourceCode, sourceMapping) { |
| 105 var data = this._targetToData.get(target); |
| 106 if (data) |
| 107 data._setSourceMapping(uiSourceCode, sourceMapping); |
| 108 } |
| 109 |
| 110 /** |
| 111 * @param {!WebInspector.Script} script |
| 112 */ |
| 113 updateLocations(script) { |
| 114 var info = this._infoForScript(script.target(), script.scriptId); |
| 115 if (info) |
| 116 info._updateLocations(); |
| 117 } |
| 118 |
| 119 /** |
| 120 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 121 * @param {function(!WebInspector.LiveLocation)} updateDelegate |
| 122 * @param {!WebInspector.LiveLocationPool} locationPool |
| 123 * @return {!WebInspector.DebuggerWorkspaceBinding.Location} |
| 124 */ |
| 125 createLiveLocation(rawLocation, updateDelegate, locationPool) { |
| 126 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptId); |
| 127 console.assert(info); |
| 128 var location = new WebInspector.DebuggerWorkspaceBinding.Location( |
| 129 info._script, rawLocation, this, updateDelegate, locationPool); |
| 130 info._addLocation(location); |
| 131 return location; |
| 132 } |
| 133 |
| 134 /** |
| 135 * @param {!Array<!WebInspector.DebuggerModel.Location>} rawLocations |
| 136 * @param {function(!WebInspector.LiveLocation)} updateDelegate |
| 137 * @param {!WebInspector.LiveLocationPool} locationPool |
| 138 * @return {!WebInspector.LiveLocation} |
| 139 */ |
| 140 createStackTraceTopFrameLiveLocation(rawLocations, updateDelegate, locationPoo
l) { |
| 141 console.assert(rawLocations.length); |
| 142 var location = new WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameL
ocation( |
| 143 rawLocations, this, updateDelegate, locationPool); |
| 144 location.update(); |
| 145 return location; |
| 146 } |
| 147 |
| 148 /** |
| 149 * @param {!WebInspector.DebuggerModel.Location} location |
| 150 * @param {function(!WebInspector.LiveLocation)} updateDelegate |
| 151 * @param {!WebInspector.LiveLocationPool} locationPool |
| 152 * @return {?WebInspector.DebuggerWorkspaceBinding.Location} |
| 153 */ |
| 154 createCallFrameLiveLocation(location, updateDelegate, locationPool) { |
| 155 var script = location.script(); |
| 156 if (!script) |
| 157 return null; |
| 158 var target = location.target(); |
| 159 this._ensureInfoForScript(script); |
| 160 var liveLocation = this.createLiveLocation(location, updateDelegate, locatio
nPool); |
| 161 this._registerCallFrameLiveLocation(target, liveLocation); |
| 162 return liveLocation; |
| 163 } |
| 164 |
| 165 /** |
| 166 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 167 * @return {!WebInspector.UILocation} |
| 168 */ |
| 169 rawLocationToUILocation(rawLocation) { |
| 170 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptId); |
| 171 console.assert(info); |
| 172 return info._rawLocationToUILocation(rawLocation); |
| 173 } |
| 174 |
| 175 /** |
| 176 * @param {!WebInspector.Target} target |
| 177 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 178 * @param {number} lineNumber |
| 179 * @param {number} columnNumber |
| 180 * @return {?WebInspector.DebuggerModel.Location} |
| 181 */ |
| 182 uiLocationToRawLocation(target, uiSourceCode, lineNumber, columnNumber) { |
| 183 var targetData = this._targetToData.get(target); |
| 184 return targetData ? /** @type {?WebInspector.DebuggerModel.Location} */ ( |
| 185 targetData._uiLocationToRawLocation(uiSourceCode, li
neNumber, columnNumber)) : |
| 186 null; |
| 187 } |
| 188 |
| 189 /** |
| 190 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 191 * @param {number} lineNumber |
| 192 * @param {number} columnNumber |
| 193 * @return {!Array.<!WebInspector.DebuggerModel.Location>} |
| 194 */ |
| 195 uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) { |
| 196 var result = []; |
| 197 var targetDatas = this._targetToData.valuesArray(); |
| 198 for (var i = 0; i < targetDatas.length; ++i) { |
| 199 var rawLocation = targetDatas[i]._uiLocationToRawLocation(uiSourceCode, li
neNumber, columnNumber); |
| 200 if (rawLocation) |
| 201 result.push(rawLocation); |
| 202 } |
| 203 return result; |
| 204 } |
| 205 |
| 206 /** |
| 207 * @param {!WebInspector.UILocation} uiLocation |
| 208 * @return {!WebInspector.UILocation} |
| 209 */ |
| 210 normalizeUILocation(uiLocation) { |
| 211 var target = WebInspector.NetworkProject.targetForUISourceCode(uiLocation.ui
SourceCode); |
| 212 if (target) { |
| 213 var rawLocation = |
| 214 this.uiLocationToRawLocation(target, uiLocation.uiSourceCode, uiLocati
on.lineNumber, uiLocation.columnNumber); |
| 215 if (rawLocation) |
| 216 return this.rawLocationToUILocation(rawLocation); |
| 217 } |
| 218 return uiLocation; |
| 219 } |
| 220 |
| 221 /** |
| 222 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 223 * @param {number} lineNumber |
| 224 * @return {boolean} |
| 225 */ |
| 226 uiLineHasMapping(uiSourceCode, lineNumber) { |
| 227 var targetDatas = this._targetToData.valuesArray(); |
| 228 for (var i = 0; i < targetDatas.length; ++i) { |
| 229 if (!targetDatas[i]._uiLineHasMapping(uiSourceCode, lineNumber)) |
| 230 return false; |
| 231 } |
| 232 return true; |
| 233 } |
| 234 |
| 235 /** |
| 236 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 237 * @param {!WebInspector.Target} target |
| 238 * @return {?WebInspector.ResourceScriptFile} |
| 239 */ |
| 240 scriptFile(uiSourceCode, target) { |
| 241 var targetData = this._targetToData.get(target); |
| 242 return targetData ? targetData._resourceMapping.scriptFile(uiSourceCode) : n
ull; |
| 243 } |
| 244 |
| 245 /** |
| 246 * @param {!WebInspector.Script} script |
| 247 * @return {?WebInspector.TextSourceMap} |
| 248 */ |
| 249 sourceMapForScript(script) { |
| 250 var targetData = this._targetToData.get(script.target()); |
| 251 if (!targetData) |
| 252 return null; |
| 253 return targetData._compilerMapping.sourceMapForScript(script); |
| 254 } |
| 255 |
| 256 /** |
| 257 * @param {!WebInspector.Script} script |
| 258 */ |
| 259 maybeLoadSourceMap(script) { |
| 260 var targetData = this._targetToData.get(script.target()); |
| 261 if (!targetData) |
| 262 return; |
| 263 targetData._compilerMapping.maybeLoadSourceMap(script); |
| 264 } |
| 265 |
| 266 /** |
| 267 * @param {!WebInspector.Event} event |
| 268 */ |
| 269 _globalObjectCleared(event) { |
| 270 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target
); |
| 271 this._reset(debuggerModel.target()); |
| 272 } |
| 273 |
| 274 /** |
| 275 * @param {!WebInspector.Target} target |
| 276 */ |
| 277 _reset(target) { |
| 278 var targetData = this._targetToData.get(target); |
| 279 targetData.callFrameLocations.valuesArray().forEach((location) => this._remo
veLiveLocation(location)); |
| 280 targetData.callFrameLocations.clear(); |
| 281 } |
| 282 |
| 283 /** |
| 284 * @param {!WebInspector.Script} script |
| 285 * @return {!WebInspector.DebuggerWorkspaceBinding.ScriptInfo} |
| 286 */ |
| 287 _ensureInfoForScript(script) { |
| 288 var scriptDataMap = this._targetToData.get(script.target()).scriptDataMap; |
| 289 var info = scriptDataMap.get(script.scriptId); |
| 290 if (!info) { |
| 291 info = new WebInspector.DebuggerWorkspaceBinding.ScriptInfo(script); |
| 292 scriptDataMap.set(script.scriptId, info); |
| 293 } |
| 294 return info; |
| 295 } |
| 296 |
| 297 /** |
| 298 * @param {!WebInspector.Target} target |
| 299 * @param {string} scriptId |
| 300 * @return {?WebInspector.DebuggerWorkspaceBinding.ScriptInfo} |
| 301 */ |
| 302 _infoForScript(target, scriptId) { |
| 303 var data = this._targetToData.get(target); |
| 304 if (!data) |
| 305 return null; |
| 306 return data.scriptDataMap.get(scriptId) || null; |
| 307 } |
| 308 |
| 309 /** |
| 310 * @param {!WebInspector.Target} target |
| 311 * @param {!WebInspector.DebuggerWorkspaceBinding.Location} location |
| 312 */ |
| 313 _registerCallFrameLiveLocation(target, location) { |
| 314 var locations = this._targetToData.get(target).callFrameLocations; |
| 315 locations.add(location); |
| 316 } |
| 317 |
| 318 /** |
| 319 * @param {!WebInspector.DebuggerWorkspaceBinding.Location} location |
| 320 */ |
| 321 _removeLiveLocation(location) { |
| 322 var info = this._infoForScript(location._script.target(), location._script.s
criptId); |
| 323 if (info) |
| 324 info._removeLocation(location); |
| 325 } |
| 326 |
| 327 /** |
| 328 * @param {!WebInspector.Event} event |
| 329 */ |
| 330 _debuggerResumed(event) { |
| 331 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target
); |
| 332 this._reset(debuggerModel.target()); |
| 333 } |
| 334 |
| 335 /** |
| 336 * @param {!WebInspector.Event} event |
| 337 */ |
| 338 _beforeDebuggerPaused(event) { |
| 339 var rawLocation = event.data.callFrames[0].location(); |
| 340 var targetData = this._targetToData.get(rawLocation.target()); |
| 341 if (!targetData._compilerMapping.mapsToSourceCode(rawLocation)) { |
| 342 event.stopPropagation(); |
| 343 event.preventDefault(); |
| 344 } |
| 345 } |
| 27 }; | 346 }; |
| 28 | 347 |
| 29 WebInspector.DebuggerWorkspaceBinding.prototype = { | |
| 30 /** | |
| 31 * @override | |
| 32 * @param {!WebInspector.Target} target | |
| 33 */ | |
| 34 targetAdded: function(target) | |
| 35 { | |
| 36 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | |
| 37 if (debuggerModel) | |
| 38 this._targetToData.set(target, new WebInspector.DebuggerWorkspaceBin
ding.TargetData(debuggerModel, this)); | |
| 39 }, | |
| 40 | |
| 41 /** | |
| 42 * @override | |
| 43 * @param {!WebInspector.Target} target | |
| 44 */ | |
| 45 targetRemoved: function(target) | |
| 46 { | |
| 47 if (!WebInspector.DebuggerModel.fromTarget(target)) | |
| 48 return; | |
| 49 var targetData = this._targetToData.get(target); | |
| 50 targetData._dispose(); | |
| 51 this._targetToData.remove(target); | |
| 52 }, | |
| 53 | |
| 54 /** | |
| 55 * @param {!WebInspector.Event} event | |
| 56 */ | |
| 57 _uiSourceCodeRemoved: function(event) | |
| 58 { | |
| 59 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | |
| 60 var targetDatas = this._targetToData.valuesArray(); | |
| 61 for (var i = 0; i < targetDatas.length; ++i) | |
| 62 targetDatas[i]._uiSourceCodeRemoved(uiSourceCode); | |
| 63 }, | |
| 64 | |
| 65 /** | |
| 66 * @param {!WebInspector.Event} event | |
| 67 */ | |
| 68 _projectRemoved: function(event) | |
| 69 { | |
| 70 var project = /** @type {!WebInspector.Project} */ (event.data); | |
| 71 var targetDatas = this._targetToData.valuesArray(); | |
| 72 var uiSourceCodes = project.uiSourceCodes(); | |
| 73 for (var i = 0; i < targetDatas.length; ++i) { | |
| 74 for (var j = 0; j < uiSourceCodes.length; ++j) | |
| 75 targetDatas[i]._uiSourceCodeRemoved(uiSourceCodes[j]); | |
| 76 } | |
| 77 }, | |
| 78 | |
| 79 /** | |
| 80 * @param {!WebInspector.Script} script | |
| 81 * @param {!WebInspector.DebuggerSourceMapping} sourceMapping | |
| 82 */ | |
| 83 pushSourceMapping: function(script, sourceMapping) | |
| 84 { | |
| 85 var info = this._ensureInfoForScript(script); | |
| 86 info._pushSourceMapping(sourceMapping); | |
| 87 }, | |
| 88 | |
| 89 /** | |
| 90 * @param {!WebInspector.Script} script | |
| 91 * @return {!WebInspector.DebuggerSourceMapping} | |
| 92 */ | |
| 93 popSourceMapping: function(script) | |
| 94 { | |
| 95 var info = this._infoForScript(script.target(), script.scriptId); | |
| 96 console.assert(info); | |
| 97 return info._popSourceMapping(); | |
| 98 }, | |
| 99 | |
| 100 /** | |
| 101 * @param {!WebInspector.Target} target | |
| 102 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 103 * @param {?WebInspector.DebuggerSourceMapping} sourceMapping | |
| 104 */ | |
| 105 setSourceMapping: function(target, uiSourceCode, sourceMapping) | |
| 106 { | |
| 107 var data = this._targetToData.get(target); | |
| 108 if (data) | |
| 109 data._setSourceMapping(uiSourceCode, sourceMapping); | |
| 110 }, | |
| 111 | |
| 112 /** | |
| 113 * @param {!WebInspector.Script} script | |
| 114 */ | |
| 115 updateLocations: function(script) | |
| 116 { | |
| 117 var info = this._infoForScript(script.target(), script.scriptId); | |
| 118 if (info) | |
| 119 info._updateLocations(); | |
| 120 }, | |
| 121 | |
| 122 /** | |
| 123 * @param {!WebInspector.DebuggerModel.Location} rawLocation | |
| 124 * @param {function(!WebInspector.LiveLocation)} updateDelegate | |
| 125 * @param {!WebInspector.LiveLocationPool} locationPool | |
| 126 * @return {!WebInspector.DebuggerWorkspaceBinding.Location} | |
| 127 */ | |
| 128 createLiveLocation: function(rawLocation, updateDelegate, locationPool) | |
| 129 { | |
| 130 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptI
d); | |
| 131 console.assert(info); | |
| 132 var location = new WebInspector.DebuggerWorkspaceBinding.Location(info._
script, rawLocation, this, updateDelegate, locationPool); | |
| 133 info._addLocation(location); | |
| 134 return location; | |
| 135 }, | |
| 136 | |
| 137 /** | |
| 138 * @param {!Array<!WebInspector.DebuggerModel.Location>} rawLocations | |
| 139 * @param {function(!WebInspector.LiveLocation)} updateDelegate | |
| 140 * @param {!WebInspector.LiveLocationPool} locationPool | |
| 141 * @return {!WebInspector.LiveLocation} | |
| 142 */ | |
| 143 createStackTraceTopFrameLiveLocation: function(rawLocations, updateDelegate,
locationPool) | |
| 144 { | |
| 145 console.assert(rawLocations.length); | |
| 146 var location = new WebInspector.DebuggerWorkspaceBinding.StackTraceTopFr
ameLocation(rawLocations, this, updateDelegate, locationPool); | |
| 147 location.update(); | |
| 148 return location; | |
| 149 }, | |
| 150 | |
| 151 /** | |
| 152 * @param {!WebInspector.DebuggerModel.Location} location | |
| 153 * @param {function(!WebInspector.LiveLocation)} updateDelegate | |
| 154 * @param {!WebInspector.LiveLocationPool} locationPool | |
| 155 * @return {?WebInspector.DebuggerWorkspaceBinding.Location} | |
| 156 */ | |
| 157 createCallFrameLiveLocation: function(location, updateDelegate, locationPool
) | |
| 158 { | |
| 159 var script = location.script(); | |
| 160 if (!script) | |
| 161 return null; | |
| 162 var target = location.target(); | |
| 163 this._ensureInfoForScript(script); | |
| 164 var liveLocation = this.createLiveLocation(location, updateDelegate, loc
ationPool); | |
| 165 this._registerCallFrameLiveLocation(target, liveLocation); | |
| 166 return liveLocation; | |
| 167 }, | |
| 168 | |
| 169 /** | |
| 170 * @param {!WebInspector.DebuggerModel.Location} rawLocation | |
| 171 * @return {!WebInspector.UILocation} | |
| 172 */ | |
| 173 rawLocationToUILocation: function(rawLocation) | |
| 174 { | |
| 175 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptI
d); | |
| 176 console.assert(info); | |
| 177 return info._rawLocationToUILocation(rawLocation); | |
| 178 }, | |
| 179 | |
| 180 /** | |
| 181 * @param {!WebInspector.Target} target | |
| 182 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 183 * @param {number} lineNumber | |
| 184 * @param {number} columnNumber | |
| 185 * @return {?WebInspector.DebuggerModel.Location} | |
| 186 */ | |
| 187 uiLocationToRawLocation: function(target, uiSourceCode, lineNumber, columnNu
mber) | |
| 188 { | |
| 189 var targetData = this._targetToData.get(target); | |
| 190 return targetData ? /** @type {?WebInspector.DebuggerModel.Location} */
(targetData._uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber)) :
null; | |
| 191 }, | |
| 192 | |
| 193 /** | |
| 194 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 195 * @param {number} lineNumber | |
| 196 * @param {number} columnNumber | |
| 197 * @return {!Array.<!WebInspector.DebuggerModel.Location>} | |
| 198 */ | |
| 199 uiLocationToRawLocations: function(uiSourceCode, lineNumber, columnNumber) | |
| 200 { | |
| 201 var result = []; | |
| 202 var targetDatas = this._targetToData.valuesArray(); | |
| 203 for (var i = 0; i < targetDatas.length; ++i) { | |
| 204 var rawLocation = targetDatas[i]._uiLocationToRawLocation(uiSourceCo
de, lineNumber, columnNumber); | |
| 205 if (rawLocation) | |
| 206 result.push(rawLocation); | |
| 207 } | |
| 208 return result; | |
| 209 }, | |
| 210 | |
| 211 /** | |
| 212 * @param {!WebInspector.UILocation} uiLocation | |
| 213 * @return {!WebInspector.UILocation} | |
| 214 */ | |
| 215 normalizeUILocation: function(uiLocation) | |
| 216 { | |
| 217 var target = WebInspector.NetworkProject.targetForUISourceCode(uiLocatio
n.uiSourceCode); | |
| 218 if (target) { | |
| 219 var rawLocation = this.uiLocationToRawLocation(target, uiLocation.ui
SourceCode, uiLocation.lineNumber, uiLocation.columnNumber); | |
| 220 if (rawLocation) | |
| 221 return this.rawLocationToUILocation(rawLocation); | |
| 222 } | |
| 223 return uiLocation; | |
| 224 }, | |
| 225 | |
| 226 /** | |
| 227 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 228 * @param {number} lineNumber | |
| 229 * @return {boolean} | |
| 230 */ | |
| 231 uiLineHasMapping: function(uiSourceCode, lineNumber) | |
| 232 { | |
| 233 var targetDatas = this._targetToData.valuesArray(); | |
| 234 for (var i = 0; i < targetDatas.length; ++i) { | |
| 235 if (!targetDatas[i]._uiLineHasMapping(uiSourceCode, lineNumber)) | |
| 236 return false; | |
| 237 } | |
| 238 return true; | |
| 239 }, | |
| 240 | |
| 241 /** | |
| 242 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 243 * @param {!WebInspector.Target} target | |
| 244 * @return {?WebInspector.ResourceScriptFile} | |
| 245 */ | |
| 246 scriptFile: function(uiSourceCode, target) | |
| 247 { | |
| 248 var targetData = this._targetToData.get(target); | |
| 249 return targetData ? targetData._resourceMapping.scriptFile(uiSourceCode)
: null; | |
| 250 }, | |
| 251 | |
| 252 /** | |
| 253 * @param {!WebInspector.Script} script | |
| 254 * @return {?WebInspector.TextSourceMap} | |
| 255 */ | |
| 256 sourceMapForScript: function(script) | |
| 257 { | |
| 258 var targetData = this._targetToData.get(script.target()); | |
| 259 if (!targetData) | |
| 260 return null; | |
| 261 return targetData._compilerMapping.sourceMapForScript(script); | |
| 262 }, | |
| 263 | |
| 264 /** | |
| 265 * @param {!WebInspector.Script} script | |
| 266 */ | |
| 267 maybeLoadSourceMap: function(script) | |
| 268 { | |
| 269 var targetData = this._targetToData.get(script.target()); | |
| 270 if (!targetData) | |
| 271 return; | |
| 272 targetData._compilerMapping.maybeLoadSourceMap(script); | |
| 273 }, | |
| 274 | |
| 275 /** | |
| 276 * @param {!WebInspector.Event} event | |
| 277 */ | |
| 278 _globalObjectCleared: function(event) | |
| 279 { | |
| 280 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta
rget); | |
| 281 this._reset(debuggerModel.target()); | |
| 282 }, | |
| 283 | |
| 284 /** | |
| 285 * @param {!WebInspector.Target} target | |
| 286 */ | |
| 287 _reset: function(target) | |
| 288 { | |
| 289 var targetData = this._targetToData.get(target); | |
| 290 targetData.callFrameLocations.valuesArray().forEach((location) => this._
removeLiveLocation(location)); | |
| 291 targetData.callFrameLocations.clear(); | |
| 292 }, | |
| 293 | |
| 294 /** | |
| 295 * @param {!WebInspector.Script} script | |
| 296 * @return {!WebInspector.DebuggerWorkspaceBinding.ScriptInfo} | |
| 297 */ | |
| 298 _ensureInfoForScript: function(script) | |
| 299 { | |
| 300 var scriptDataMap = this._targetToData.get(script.target()).scriptDataMa
p; | |
| 301 var info = scriptDataMap.get(script.scriptId); | |
| 302 if (!info) { | |
| 303 info = new WebInspector.DebuggerWorkspaceBinding.ScriptInfo(script); | |
| 304 scriptDataMap.set(script.scriptId, info); | |
| 305 } | |
| 306 return info; | |
| 307 }, | |
| 308 | |
| 309 | |
| 310 /** | |
| 311 * @param {!WebInspector.Target} target | |
| 312 * @param {string} scriptId | |
| 313 * @return {?WebInspector.DebuggerWorkspaceBinding.ScriptInfo} | |
| 314 */ | |
| 315 _infoForScript: function(target, scriptId) | |
| 316 { | |
| 317 var data = this._targetToData.get(target); | |
| 318 if (!data) | |
| 319 return null; | |
| 320 return data.scriptDataMap.get(scriptId) || null; | |
| 321 }, | |
| 322 | |
| 323 /** | |
| 324 * @param {!WebInspector.Target} target | |
| 325 * @param {!WebInspector.DebuggerWorkspaceBinding.Location} location | |
| 326 */ | |
| 327 _registerCallFrameLiveLocation: function(target, location) | |
| 328 { | |
| 329 var locations = this._targetToData.get(target).callFrameLocations; | |
| 330 locations.add(location); | |
| 331 }, | |
| 332 | |
| 333 /** | |
| 334 * @param {!WebInspector.DebuggerWorkspaceBinding.Location} location | |
| 335 */ | |
| 336 _removeLiveLocation: function(location) | |
| 337 { | |
| 338 var info = this._infoForScript(location._script.target(), location._scri
pt.scriptId); | |
| 339 if (info) | |
| 340 info._removeLocation(location); | |
| 341 }, | |
| 342 | |
| 343 /** | |
| 344 * @param {!WebInspector.Event} event | |
| 345 */ | |
| 346 _debuggerResumed: function(event) | |
| 347 { | |
| 348 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta
rget); | |
| 349 this._reset(debuggerModel.target()); | |
| 350 }, | |
| 351 | |
| 352 /** | |
| 353 * @param {!WebInspector.Event} event | |
| 354 */ | |
| 355 _beforeDebuggerPaused: function(event) | |
| 356 { | |
| 357 var rawLocation = event.data.callFrames[0].location(); | |
| 358 var targetData = this._targetToData.get(rawLocation.target()); | |
| 359 if (!targetData._compilerMapping.mapsToSourceCode(rawLocation)) { | |
| 360 event.stopPropagation(); | |
| 361 event.preventDefault(); | |
| 362 } | |
| 363 } | |
| 364 }; | |
| 365 | |
| 366 /** | 348 /** |
| 367 * @constructor | 349 * @unrestricted |
| 368 * @param {!WebInspector.DebuggerModel} debuggerModel | |
| 369 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | |
| 370 */ | 350 */ |
| 371 WebInspector.DebuggerWorkspaceBinding.TargetData = function(debuggerModel, debug
gerWorkspaceBinding) | 351 WebInspector.DebuggerWorkspaceBinding.TargetData = class { |
| 372 { | 352 /** |
| 353 * @param {!WebInspector.DebuggerModel} debuggerModel |
| 354 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 355 */ |
| 356 constructor(debuggerModel, debuggerWorkspaceBinding) { |
| 373 this._target = debuggerModel.target(); | 357 this._target = debuggerModel.target(); |
| 374 | 358 |
| 375 /** @type {!Map.<string, !WebInspector.DebuggerWorkspaceBinding.ScriptInfo>}
*/ | 359 /** @type {!Map.<string, !WebInspector.DebuggerWorkspaceBinding.ScriptInfo>}
*/ |
| 376 this.scriptDataMap = new Map(); | 360 this.scriptDataMap = new Map(); |
| 377 | 361 |
| 378 /** @type {!Set.<!WebInspector.DebuggerWorkspaceBinding.Location>} */ | 362 /** @type {!Set.<!WebInspector.DebuggerWorkspaceBinding.Location>} */ |
| 379 this.callFrameLocations = new Set(); | 363 this.callFrameLocations = new Set(); |
| 380 | 364 |
| 381 var workspace = debuggerWorkspaceBinding._workspace; | 365 var workspace = debuggerWorkspaceBinding._workspace; |
| 382 var networkMapping = debuggerWorkspaceBinding._networkMapping; | 366 var networkMapping = debuggerWorkspaceBinding._networkMapping; |
| 383 | 367 |
| 384 this._defaultMapping = new WebInspector.DefaultScriptMapping(debuggerModel,
workspace, debuggerWorkspaceBinding); | 368 this._defaultMapping = new WebInspector.DefaultScriptMapping(debuggerModel,
workspace, debuggerWorkspaceBinding); |
| 385 this._resourceMapping = new WebInspector.ResourceScriptMapping(debuggerModel
, workspace, networkMapping, debuggerWorkspaceBinding); | 369 this._resourceMapping = |
| 386 this._compilerMapping = new WebInspector.CompilerScriptMapping(debuggerModel
, workspace, networkMapping, WebInspector.NetworkProject.forTarget(this._target)
, debuggerWorkspaceBinding); | 370 new WebInspector.ResourceScriptMapping(debuggerModel, workspace, network
Mapping, debuggerWorkspaceBinding); |
| 371 this._compilerMapping = new WebInspector.CompilerScriptMapping( |
| 372 debuggerModel, workspace, networkMapping, WebInspector.NetworkProject.fo
rTarget(this._target), |
| 373 debuggerWorkspaceBinding); |
| 387 | 374 |
| 388 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.DebuggerSourceMap
ping>} */ | 375 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.DebuggerSourceMap
ping>} */ |
| 389 this._uiSourceCodeToSourceMapping = new Map(); | 376 this._uiSourceCodeToSourceMapping = new Map(); |
| 390 | 377 |
| 391 this._eventListeners = [ | 378 this._eventListeners = [ |
| 392 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedS
criptSource, this._parsedScriptSource, this), | 379 debuggerModel.addEventListener( |
| 393 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedT
oParseScriptSource, this._parsedScriptSource, this) | 380 WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScri
ptSource, this), |
| 381 debuggerModel.addEventListener( |
| 382 WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._par
sedScriptSource, this) |
| 394 ]; | 383 ]; |
| 395 }; | 384 } |
| 396 | 385 |
| 397 WebInspector.DebuggerWorkspaceBinding.TargetData.prototype = { | 386 /** |
| 398 /** | 387 * @param {!WebInspector.Event} event |
| 399 * @param {!WebInspector.Event} event | 388 */ |
| 400 */ | 389 _parsedScriptSource(event) { |
| 401 _parsedScriptSource: function(event) | 390 var script = /** @type {!WebInspector.Script} */ (event.data); |
| 402 { | 391 this._defaultMapping.addScript(script); |
| 403 var script = /** @type {!WebInspector.Script} */ (event.data); | 392 this._resourceMapping.addScript(script); |
| 404 this._defaultMapping.addScript(script); | |
| 405 this._resourceMapping.addScript(script); | |
| 406 | 393 |
| 407 if (WebInspector.moduleSetting("jsSourceMapsEnabled").get()) | 394 if (WebInspector.moduleSetting('jsSourceMapsEnabled').get()) |
| 408 this._compilerMapping.addScript(script); | 395 this._compilerMapping.addScript(script); |
| 409 }, | 396 } |
| 410 | 397 |
| 411 /** | 398 /** |
| 412 * @param {!WebInspector.UISourceCode} uiSourceCode | 399 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 413 * @param {?WebInspector.DebuggerSourceMapping} sourceMapping | 400 * @param {?WebInspector.DebuggerSourceMapping} sourceMapping |
| 414 */ | 401 */ |
| 415 _setSourceMapping: function(uiSourceCode, sourceMapping) | 402 _setSourceMapping(uiSourceCode, sourceMapping) { |
| 416 { | 403 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMapping) |
| 417 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMappin
g) | 404 return; |
| 418 return; | |
| 419 | 405 |
| 420 if (sourceMapping) | 406 if (sourceMapping) |
| 421 this._uiSourceCodeToSourceMapping.set(uiSourceCode, sourceMapping); | 407 this._uiSourceCodeToSourceMapping.set(uiSourceCode, sourceMapping); |
| 422 else | 408 else |
| 423 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); | 409 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); |
| 424 | 410 |
| 425 uiSourceCode.dispatchEventToListeners(WebInspector.UISourceCode.Events.S
ourceMappingChanged, {target: this._target, isIdentity: sourceMapping ? sourceMa
pping.isIdentity() : false}); | 411 uiSourceCode.dispatchEventToListeners( |
| 426 }, | 412 WebInspector.UISourceCode.Events.SourceMappingChanged, |
| 413 {target: this._target, isIdentity: sourceMapping ? sourceMapping.isIdent
ity() : false}); |
| 414 } |
| 427 | 415 |
| 428 /** | 416 /** |
| 429 * @param {!WebInspector.UISourceCode} uiSourceCode | 417 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 430 * @param {number} lineNumber | 418 * @param {number} lineNumber |
| 431 * @param {number} columnNumber | 419 * @param {number} columnNumber |
| 432 * @return {?WebInspector.DebuggerModel.Location} | 420 * @return {?WebInspector.DebuggerModel.Location} |
| 433 */ | 421 */ |
| 434 _uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) | 422 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { |
| 435 { | 423 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); |
| 436 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); | 424 return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCode, l
ineNumber, columnNumber) : null; |
| 437 return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCod
e, lineNumber, columnNumber) : null; | 425 } |
| 438 }, | |
| 439 | 426 |
| 440 /** | 427 /** |
| 441 * @param {!WebInspector.UISourceCode} uiSourceCode | 428 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 442 * @param {number} lineNumber | 429 * @param {number} lineNumber |
| 443 * @return {boolean} | 430 * @return {boolean} |
| 444 */ | 431 */ |
| 445 _uiLineHasMapping: function(uiSourceCode, lineNumber) | 432 _uiLineHasMapping(uiSourceCode, lineNumber) { |
| 446 { | 433 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); |
| 447 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); | 434 return sourceMapping ? sourceMapping.uiLineHasMapping(uiSourceCode, lineNumb
er) : true; |
| 448 return sourceMapping ? sourceMapping.uiLineHasMapping(uiSourceCode, line
Number) : true; | 435 } |
| 449 }, | |
| 450 | 436 |
| 451 /** | 437 /** |
| 452 * @param {!WebInspector.UISourceCode} uiSourceCode | 438 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 453 */ | 439 */ |
| 454 _uiSourceCodeRemoved: function(uiSourceCode) | 440 _uiSourceCodeRemoved(uiSourceCode) { |
| 455 { | 441 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); |
| 456 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); | 442 } |
| 457 }, | |
| 458 | 443 |
| 459 _dispose: function() | 444 _dispose() { |
| 460 { | 445 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
| 461 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 446 this._compilerMapping.dispose(); |
| 462 this._compilerMapping.dispose(); | 447 this._resourceMapping.dispose(); |
| 463 this._resourceMapping.dispose(); | 448 this._defaultMapping.dispose(); |
| 464 this._defaultMapping.dispose(); | 449 this._uiSourceCodeToSourceMapping.clear(); |
| 465 this._uiSourceCodeToSourceMapping.clear(); | 450 } |
| 466 } | |
| 467 }; | 451 }; |
| 468 | 452 |
| 469 /** | 453 /** |
| 470 * @constructor | 454 * @unrestricted |
| 471 * @param {!WebInspector.Script} script | |
| 472 */ | 455 */ |
| 473 WebInspector.DebuggerWorkspaceBinding.ScriptInfo = function(script) | 456 WebInspector.DebuggerWorkspaceBinding.ScriptInfo = class { |
| 474 { | 457 /** |
| 458 * @param {!WebInspector.Script} script |
| 459 */ |
| 460 constructor(script) { |
| 475 this._script = script; | 461 this._script = script; |
| 476 | 462 |
| 477 /** @type {!Array.<!WebInspector.DebuggerSourceMapping>} */ | 463 /** @type {!Array.<!WebInspector.DebuggerSourceMapping>} */ |
| 478 this._sourceMappings = []; | 464 this._sourceMappings = []; |
| 479 | 465 |
| 480 /** @type {!Set<!WebInspector.LiveLocation>} */ | 466 /** @type {!Set<!WebInspector.LiveLocation>} */ |
| 481 this._locations = new Set(); | 467 this._locations = new Set(); |
| 468 } |
| 469 |
| 470 /** |
| 471 * @param {!WebInspector.DebuggerSourceMapping} sourceMapping |
| 472 */ |
| 473 _pushSourceMapping(sourceMapping) { |
| 474 this._sourceMappings.push(sourceMapping); |
| 475 this._updateLocations(); |
| 476 } |
| 477 |
| 478 /** |
| 479 * @return {!WebInspector.DebuggerSourceMapping} |
| 480 */ |
| 481 _popSourceMapping() { |
| 482 var sourceMapping = this._sourceMappings.pop(); |
| 483 this._updateLocations(); |
| 484 return sourceMapping; |
| 485 } |
| 486 |
| 487 /** |
| 488 * @param {!WebInspector.LiveLocation} location |
| 489 */ |
| 490 _addLocation(location) { |
| 491 this._locations.add(location); |
| 492 location.update(); |
| 493 } |
| 494 |
| 495 /** |
| 496 * @param {!WebInspector.LiveLocation} location |
| 497 */ |
| 498 _removeLocation(location) { |
| 499 this._locations.delete(location); |
| 500 } |
| 501 |
| 502 _updateLocations() { |
| 503 for (var location of this._locations) |
| 504 location.update(); |
| 505 } |
| 506 |
| 507 /** |
| 508 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 509 * @return {!WebInspector.UILocation} |
| 510 */ |
| 511 _rawLocationToUILocation(rawLocation) { |
| 512 var uiLocation; |
| 513 for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i) |
| 514 uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLocation); |
| 515 console.assert(uiLocation, 'Script raw location cannot be mapped to any UI l
ocation.'); |
| 516 return /** @type {!WebInspector.UILocation} */ (uiLocation); |
| 517 } |
| 482 }; | 518 }; |
| 483 | 519 |
| 484 WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = { | |
| 485 /** | |
| 486 * @param {!WebInspector.DebuggerSourceMapping} sourceMapping | |
| 487 */ | |
| 488 _pushSourceMapping: function(sourceMapping) | |
| 489 { | |
| 490 this._sourceMappings.push(sourceMapping); | |
| 491 this._updateLocations(); | |
| 492 }, | |
| 493 | |
| 494 /** | |
| 495 * @return {!WebInspector.DebuggerSourceMapping} | |
| 496 */ | |
| 497 _popSourceMapping: function() | |
| 498 { | |
| 499 var sourceMapping = this._sourceMappings.pop(); | |
| 500 this._updateLocations(); | |
| 501 return sourceMapping; | |
| 502 }, | |
| 503 | |
| 504 /** | |
| 505 * @param {!WebInspector.LiveLocation} location | |
| 506 */ | |
| 507 _addLocation: function(location) | |
| 508 { | |
| 509 this._locations.add(location); | |
| 510 location.update(); | |
| 511 }, | |
| 512 | |
| 513 /** | |
| 514 * @param {!WebInspector.LiveLocation} location | |
| 515 */ | |
| 516 _removeLocation: function(location) | |
| 517 { | |
| 518 this._locations.delete(location); | |
| 519 }, | |
| 520 | |
| 521 _updateLocations: function() | |
| 522 { | |
| 523 for (var location of this._locations) | |
| 524 location.update(); | |
| 525 }, | |
| 526 | |
| 527 /** | |
| 528 * @param {!WebInspector.DebuggerModel.Location} rawLocation | |
| 529 * @return {!WebInspector.UILocation} | |
| 530 */ | |
| 531 _rawLocationToUILocation: function(rawLocation) | |
| 532 { | |
| 533 var uiLocation; | |
| 534 for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i
) | |
| 535 uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLoca
tion); | |
| 536 console.assert(uiLocation, "Script raw location cannot be mapped to any
UI location."); | |
| 537 return /** @type {!WebInspector.UILocation} */ (uiLocation); | |
| 538 } | |
| 539 }; | |
| 540 | |
| 541 | |
| 542 /** | 520 /** |
| 543 * @constructor | 521 * @unrestricted |
| 544 * @extends {WebInspector.LiveLocationWithPool} | |
| 545 * @param {!WebInspector.Script} script | |
| 546 * @param {!WebInspector.DebuggerModel.Location} rawLocation | |
| 547 * @param {!WebInspector.DebuggerWorkspaceBinding} binding | |
| 548 * @param {function(!WebInspector.LiveLocation)} updateDelegate | |
| 549 * @param {!WebInspector.LiveLocationPool} locationPool | |
| 550 */ | 522 */ |
| 551 WebInspector.DebuggerWorkspaceBinding.Location = function(script, rawLocation, b
inding, updateDelegate, locationPool) | 523 WebInspector.DebuggerWorkspaceBinding.Location = class extends WebInspector.Live
LocationWithPool { |
| 552 { | 524 /** |
| 553 WebInspector.LiveLocationWithPool.call(this, updateDelegate, locationPool); | 525 * @param {!WebInspector.Script} script |
| 526 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 527 * @param {!WebInspector.DebuggerWorkspaceBinding} binding |
| 528 * @param {function(!WebInspector.LiveLocation)} updateDelegate |
| 529 * @param {!WebInspector.LiveLocationPool} locationPool |
| 530 */ |
| 531 constructor(script, rawLocation, binding, updateDelegate, locationPool) { |
| 532 super(updateDelegate, locationPool); |
| 554 this._script = script; | 533 this._script = script; |
| 555 this._rawLocation = rawLocation; | 534 this._rawLocation = rawLocation; |
| 556 this._binding = binding; | 535 this._binding = binding; |
| 557 }; | 536 } |
| 558 | 537 |
| 559 WebInspector.DebuggerWorkspaceBinding.Location.prototype = { | 538 /** |
| 560 /** | 539 * @override |
| 561 * @override | 540 * @return {!WebInspector.UILocation} |
| 562 * @return {!WebInspector.UILocation} | 541 */ |
| 563 */ | 542 uiLocation() { |
| 564 uiLocation: function() | 543 var debuggerModelLocation = this._rawLocation; |
| 565 { | 544 return this._binding.rawLocationToUILocation(debuggerModelLocation); |
| 566 var debuggerModelLocation = this._rawLocation; | 545 } |
| 567 return this._binding.rawLocationToUILocation(debuggerModelLocation); | |
| 568 }, | |
| 569 | 546 |
| 570 /** | 547 /** |
| 571 * @override | 548 * @override |
| 572 */ | 549 */ |
| 573 dispose: function() | 550 dispose() { |
| 574 { | 551 super.dispose(); |
| 575 WebInspector.LiveLocationWithPool.prototype.dispose.call(this); | 552 this._binding._removeLiveLocation(this); |
| 576 this._binding._removeLiveLocation(this); | 553 } |
| 577 }, | |
| 578 | 554 |
| 579 /** | 555 /** |
| 580 * @override | 556 * @override |
| 581 * @return {boolean} | 557 * @return {boolean} |
| 582 */ | 558 */ |
| 583 isBlackboxed: function() | 559 isBlackboxed() { |
| 584 { | 560 return WebInspector.blackboxManager.isBlackboxedRawLocation(this._rawLocatio
n); |
| 585 return WebInspector.blackboxManager.isBlackboxedRawLocation(this._rawLoc
ation); | 561 } |
| 586 }, | |
| 587 | |
| 588 __proto__: WebInspector.LiveLocationWithPool.prototype | |
| 589 }; | 562 }; |
| 590 | 563 |
| 591 /** | 564 /** |
| 592 * @constructor | 565 * @unrestricted |
| 593 * @extends {WebInspector.LiveLocationWithPool} | |
| 594 * @param {!Array<!WebInspector.DebuggerModel.Location>} rawLocations | |
| 595 * @param {!WebInspector.DebuggerWorkspaceBinding} binding | |
| 596 * @param {function(!WebInspector.LiveLocation)} updateDelegate | |
| 597 * @param {!WebInspector.LiveLocationPool} locationPool | |
| 598 */ | 566 */ |
| 599 WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation = function(rawL
ocations, binding, updateDelegate, locationPool) | 567 WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation = class extends
WebInspector.LiveLocationWithPool { |
| 600 { | 568 /** |
| 601 WebInspector.LiveLocationWithPool.call(this, updateDelegate, locationPool); | 569 * @param {!Array<!WebInspector.DebuggerModel.Location>} rawLocations |
| 570 * @param {!WebInspector.DebuggerWorkspaceBinding} binding |
| 571 * @param {function(!WebInspector.LiveLocation)} updateDelegate |
| 572 * @param {!WebInspector.LiveLocationPool} locationPool |
| 573 */ |
| 574 constructor(rawLocations, binding, updateDelegate, locationPool) { |
| 575 super(updateDelegate, locationPool); |
| 602 | 576 |
| 603 this._updateScheduled = true; | 577 this._updateScheduled = true; |
| 604 /** @type {!Set<!WebInspector.LiveLocation>} */ | 578 /** @type {!Set<!WebInspector.LiveLocation>} */ |
| 605 this._locations = new Set(); | 579 this._locations = new Set(); |
| 606 for (var location of rawLocations) | 580 for (var location of rawLocations) |
| 607 this._locations.add(binding.createLiveLocation(location, this._scheduleU
pdate.bind(this), locationPool)); | 581 this._locations.add(binding.createLiveLocation(location, this._scheduleUpd
ate.bind(this), locationPool)); |
| 608 this._updateLocation(); | 582 this._updateLocation(); |
| 609 }; | 583 } |
| 610 | 584 |
| 611 WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation.prototype = { | 585 /** |
| 612 /** | 586 * @override |
| 613 * @override | 587 * @return {!WebInspector.UILocation} |
| 614 * @return {!WebInspector.UILocation} | 588 */ |
| 615 */ | 589 uiLocation() { |
| 616 uiLocation: function() | 590 return this._current.uiLocation(); |
| 617 { | 591 } |
| 618 return this._current.uiLocation(); | |
| 619 }, | |
| 620 | 592 |
| 621 /** | 593 /** |
| 622 * @override | 594 * @override |
| 623 * @return {boolean} | 595 * @return {boolean} |
| 624 */ | 596 */ |
| 625 isBlackboxed: function() | 597 isBlackboxed() { |
| 626 { | 598 return this._current.isBlackboxed(); |
| 627 return this._current.isBlackboxed(); | 599 } |
| 628 }, | |
| 629 | 600 |
| 630 /** | 601 /** |
| 631 * @override | 602 * @override |
| 632 */ | 603 */ |
| 633 dispose: function() | 604 dispose() { |
| 634 { | 605 super.dispose(); |
| 635 WebInspector.LiveLocationWithPool.prototype.dispose.call(this); | 606 for (var location of this._locations) |
| 636 for (var location of this._locations) | 607 location.dispose(); |
| 637 location.dispose(); | 608 } |
| 638 }, | |
| 639 | 609 |
| 640 _scheduleUpdate: function() | 610 _scheduleUpdate() { |
| 641 { | 611 if (!this._updateScheduled) { |
| 642 if (!this._updateScheduled) { | 612 this._updateScheduled = true; |
| 643 this._updateScheduled = true; | 613 setImmediate(this._updateLocation.bind(this)); |
| 644 setImmediate(this._updateLocation.bind(this)); | 614 } |
| 645 } | 615 } |
| 646 }, | |
| 647 | 616 |
| 648 _updateLocation: function() | 617 _updateLocation() { |
| 649 { | 618 this._updateScheduled = false; |
| 650 this._updateScheduled = false; | 619 this._current = this._locations.values().next().value; |
| 651 this._current = this._locations.values().next().value; | 620 for (var current of this._locations) { |
| 652 for (var current of this._locations) { | 621 if (!current.isBlackboxed()) { |
| 653 if (!current.isBlackboxed()) { | 622 this._current = current; |
| 654 this._current = current; | 623 break; |
| 655 break; | 624 } |
| 656 } | 625 } |
| 657 } | 626 this.update(); |
| 658 this.update(); | 627 } |
| 659 }, | |
| 660 | |
| 661 __proto__: WebInspector.LiveLocationWithPool.prototype | |
| 662 }; | 628 }; |
| 663 | 629 |
| 664 /** | 630 /** |
| 665 * @interface | 631 * @interface |
| 666 */ | 632 */ |
| 667 WebInspector.DebuggerSourceMapping = function() | 633 WebInspector.DebuggerSourceMapping = function() {}; |
| 668 { | |
| 669 }; | |
| 670 | 634 |
| 671 WebInspector.DebuggerSourceMapping.prototype = { | 635 WebInspector.DebuggerSourceMapping.prototype = { |
| 672 /** | 636 /** |
| 673 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 637 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 674 * @return {?WebInspector.UILocation} | 638 * @return {?WebInspector.UILocation} |
| 675 */ | 639 */ |
| 676 rawLocationToUILocation: function(rawLocation) { }, | 640 rawLocationToUILocation: function(rawLocation) {}, |
| 677 | 641 |
| 678 /** | 642 /** |
| 679 * @param {!WebInspector.UISourceCode} uiSourceCode | 643 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 680 * @param {number} lineNumber | 644 * @param {number} lineNumber |
| 681 * @param {number} columnNumber | 645 * @param {number} columnNumber |
| 682 * @return {?WebInspector.DebuggerModel.Location} | 646 * @return {?WebInspector.DebuggerModel.Location} |
| 683 */ | 647 */ |
| 684 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) {
}, | 648 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) {}, |
| 685 | 649 |
| 686 /** | 650 /** |
| 687 * @return {boolean} | 651 * @return {boolean} |
| 688 */ | 652 */ |
| 689 isIdentity: function() { }, | 653 isIdentity: function() {}, |
| 690 | 654 |
| 691 /** | 655 /** |
| 692 * @param {!WebInspector.UISourceCode} uiSourceCode | 656 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 693 * @param {number} lineNumber | 657 * @param {number} lineNumber |
| 694 * @return {boolean} | 658 * @return {boolean} |
| 695 */ | 659 */ |
| 696 uiLineHasMapping: function(uiSourceCode, lineNumber) { } | 660 uiLineHasMapping: function(uiSourceCode, lineNumber) {} |
| 697 }; | 661 }; |
| 698 | 662 |
| 699 /** | 663 /** |
| 700 * @type {!WebInspector.DebuggerWorkspaceBinding} | 664 * @type {!WebInspector.DebuggerWorkspaceBinding} |
| 701 */ | 665 */ |
| 702 WebInspector.debuggerWorkspaceBinding; | 666 WebInspector.debuggerWorkspaceBinding; |
| OLD | NEW |