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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/DebuggerWorkspaceBinding.js

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

Powered by Google App Engine
This is Rietveld 408576698