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

Side by Side Diff: Source/devtools/front_end/sdk/DebuggerWorkspaceBinding.js

Issue 464963002: DevTools: Make UISourceCode Target-agnostic (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TargetManager.Observer} 7 * @implements {WebInspector.TargetManager.Observer}
8 * @param {!WebInspector.TargetManager} targetManager 8 * @param {!WebInspector.TargetManager} targetManager
9 * @param {!WebInspector.Workspace} workspace 9 * @param {!WebInspector.Workspace} workspace
10 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding 10 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 * @return {!WebInspector.SourceMapping} 54 * @return {!WebInspector.SourceMapping}
55 */ 55 */
56 popSourceMapping: function(script) 56 popSourceMapping: function(script)
57 { 57 {
58 var info = this._infoForScript(script.target(), script.scriptId); 58 var info = this._infoForScript(script.target(), script.scriptId);
59 console.assert(info); 59 console.assert(info);
60 return info._popSourceMapping(); 60 return info._popSourceMapping();
61 }, 61 },
62 62
63 /** 63 /**
64 * @param {!WebInspector.Target} target
65 * @param {!WebInspector.UISourceCode} uiSourceCode
66 * @param {?WebInspector.SourceMapping} sourceMapping
67 */
68 setSourceMapping: function(target, uiSourceCode, sourceMapping)
69 {
70 var data = this._targetToData.get(target);
71 if (data)
72 data._setSourceMapping(uiSourceCode, sourceMapping);
73 },
74
75 /**
64 * @param {!WebInspector.Script} script 76 * @param {!WebInspector.Script} script
65 */ 77 */
66 updateLocations: function(script) 78 updateLocations: function(script)
67 { 79 {
68 var info = this._infoForScript(script.target(), script.scriptId); 80 var info = this._infoForScript(script.target(), script.scriptId);
69 if (info) 81 if (info)
70 info._updateLocations(); 82 info._updateLocations();
71 }, 83 },
72 84
73 /** 85 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptI d); 119 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptI d);
108 console.assert(info); 120 console.assert(info);
109 return info._rawLocationToUILocation(rawLocation); 121 return info._rawLocationToUILocation(rawLocation);
110 }, 122 },
111 123
112 /** 124 /**
113 * @param {!WebInspector.Target} target 125 * @param {!WebInspector.Target} target
114 * @param {!WebInspector.UISourceCode} uiSourceCode 126 * @param {!WebInspector.UISourceCode} uiSourceCode
115 * @param {number} lineNumber 127 * @param {number} lineNumber
116 * @param {number} columnNumber 128 * @param {number} columnNumber
117 * @return {!WebInspector.DebuggerModel.Location} 129 * @return {?WebInspector.DebuggerModel.Location}
118 */ 130 */
119 uiLocationToRawLocation: function(target, uiSourceCode, lineNumber, columnNu mber) 131 uiLocationToRawLocation: function(target, uiSourceCode, lineNumber, columnNu mber)
120 { 132 {
121 return /** @type {!WebInspector.DebuggerModel.Location} */ (uiSourceCode .uiLocationToRawLocation(target, lineNumber, columnNumber)); 133 var targetData = this._targetToData.get(target);
134 return targetData ? /** @type {?WebInspector.DebuggerModel.Location} */ (targetData._uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber)) : null;
122 }, 135 },
123 136
124 /** 137 /**
138 * @param {!WebInspector.UISourceCode} uiSourceCode
139 * @param {number} lineNumber
140 * @param {number} columnNumber
141 * @return {!Array.<!WebInspector.RawLocation>}
142 */
143 uiLocationToRawLocations: function(uiSourceCode, lineNumber, columnNumber)
144 {
145 var result = [];
146 var targetDatas = this._targetToData.values();
147 for (var i = 0; i < targetDatas.length; ++i) {
148 var rawLocation = targetDatas[i]._uiLocationToRawLocation(uiSourceCo de, lineNumber, columnNumber);
149 if (rawLocation)
150 result.push(rawLocation);
151 }
152 return result;
153 },
154
155 /**
156 * @param {!WebInspector.UISourceCode} uiSourceCode
157 * @param {number} lineNumber
158 * @return {boolean}
159 */
160 uiLineHasMapping: function(uiSourceCode, lineNumber)
161 {
162 var targetDatas = this._targetToData.values();
163 for (var i = 0; i < targetDatas.length; ++i) {
164 if (!targetDatas[i]._uiLineHasMapping(uiSourceCode, lineNumber))
165 return false;
166 }
167 return true;
168 },
169
170 /**
125 * @param {!WebInspector.Target} target 171 * @param {!WebInspector.Target} target
126 * @return {?WebInspector.LiveEditSupport} 172 * @return {?WebInspector.LiveEditSupport}
127 */ 173 */
128 liveEditSupport: function(target) 174 liveEditSupport: function(target)
129 { 175 {
130 var targetData = this._targetToData.get(target); 176 var targetData = this._targetToData.get(target);
131 return targetData ? targetData._liveEditSupport : null; 177 return targetData ? targetData._liveEditSupport : null;
132 }, 178 },
133 179
134 /** 180 /**
181 * @param {!WebInspector.UISourceCode} uiSourceCode
182 * @param {!WebInspector.Target} target
183 * @return {?WebInspector.ResourceScriptFile}
184 */
185 scriptFile: function(uiSourceCode, target)
186 {
187 var targetData = this._targetToData.get(target);
188 return targetData ? targetData._resourceMapping.scriptFile(uiSourceCode) : null;
189 },
190
191 /**
135 * @param {!WebInspector.Event} event 192 * @param {!WebInspector.Event} event
136 */ 193 */
137 _globalObjectCleared: function(event) 194 _globalObjectCleared: function(event)
138 { 195 {
139 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta rget); 196 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta rget);
140 this._reset(debuggerModel.target()); 197 this._reset(debuggerModel.target());
141 }, 198 },
142 199
143 /** 200 /**
144 * @param {!WebInspector.Target} target 201 * @param {!WebInspector.Target} target
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 266 }
210 } 267 }
211 268
212 /** 269 /**
213 * @constructor 270 * @constructor
214 * @param {!WebInspector.Target} target 271 * @param {!WebInspector.Target} target
215 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding 272 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding
216 */ 273 */
217 WebInspector.DebuggerWorkspaceBinding.TargetData = function(target, debuggerWork spaceBinding) 274 WebInspector.DebuggerWorkspaceBinding.TargetData = function(target, debuggerWork spaceBinding)
218 { 275 {
276 this._target = target;
277
219 /** @type {!StringMap.<!WebInspector.DebuggerWorkspaceBinding.ScriptInfo>} * / 278 /** @type {!StringMap.<!WebInspector.DebuggerWorkspaceBinding.ScriptInfo>} * /
220 this.scriptDataMap = new StringMap(); 279 this.scriptDataMap = new StringMap();
221 280
222 /** @type {!Set.<!WebInspector.DebuggerWorkspaceBinding.Location>} */ 281 /** @type {!Set.<!WebInspector.DebuggerWorkspaceBinding.Location>} */
223 this.callFrameLocations = new Set(); 282 this.callFrameLocations = new Set();
224 283
225 var debuggerModel = target.debuggerModel; 284 var debuggerModel = target.debuggerModel;
226 var workspace = debuggerWorkspaceBinding._workspace; 285 var workspace = debuggerWorkspaceBinding._workspace;
227 286
228 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace, debuggerWorkspaceBinding); 287 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace, debuggerWorkspaceBinding);
229 this._defaultMapping = new WebInspector.DefaultScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding); 288 this._defaultMapping = new WebInspector.DefaultScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding);
230 this._resourceMapping = new WebInspector.ResourceScriptMapping(debuggerModel , workspace, debuggerWorkspaceBinding); 289 this._resourceMapping = new WebInspector.ResourceScriptMapping(debuggerModel , workspace, debuggerWorkspaceBinding);
231 this._compilerMapping = new WebInspector.CompilerScriptMapping(debuggerModel , workspace, debuggerWorkspaceBinding._networkWorkspaceBinding, debuggerWorkspac eBinding); 290 this._compilerMapping = new WebInspector.CompilerScriptMapping(debuggerModel , workspace, debuggerWorkspaceBinding._networkWorkspaceBinding, debuggerWorkspac eBinding);
232 291
233 /** @type {!WebInspector.LiveEditSupport} */ 292 /** @type {!WebInspector.LiveEditSupport} */
234 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace, debuggerWorkspaceBinding); 293 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace, debuggerWorkspaceBinding);
235 294
295 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SourceMapping>} * /
296 this._uiSourceCodeToSourceMapping = new Map();
vsevik 2014/08/13 07:02:04 This map is never cleared.
apavlov 2014/08/13 07:20:43 Done.
297
236 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScrip tSource, this._parsedScriptSource, this); 298 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScrip tSource, this._parsedScriptSource, this);
237 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToPar seScriptSource, this._parsedScriptSource, this); 299 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToPar seScriptSource, this._parsedScriptSource, this);
238 } 300 }
239 301
240 WebInspector.DebuggerWorkspaceBinding.TargetData.prototype = { 302 WebInspector.DebuggerWorkspaceBinding.TargetData.prototype = {
241 /** 303 /**
242 * @param {!WebInspector.Event} event 304 * @param {!WebInspector.Event} event
243 */ 305 */
244 _parsedScriptSource: function(event) 306 _parsedScriptSource: function(event)
245 { 307 {
246 var script = /** @type {!WebInspector.Script} */ (event.data); 308 var script = /** @type {!WebInspector.Script} */ (event.data);
247 this._defaultMapping.addScript(script); 309 this._defaultMapping.addScript(script);
248 310
249 if (script.isSnippet()) { 311 if (script.isSnippet()) {
250 WebInspector.scriptSnippetModel.addScript(script); 312 WebInspector.scriptSnippetModel.addScript(script);
251 return; 313 return;
252 } 314 }
253 315
254 this._resourceMapping.addScript(script); 316 this._resourceMapping.addScript(script);
255 317
256 if (WebInspector.settings.jsSourceMapsEnabled.get()) 318 if (WebInspector.settings.jsSourceMapsEnabled.get())
257 this._compilerMapping.addScript(script); 319 this._compilerMapping.addScript(script);
258 }, 320 },
259 321
322 /**
323 * @param {!WebInspector.UISourceCode} uiSourceCode
324 * @param {?WebInspector.SourceMapping} sourceMapping
325 */
326 _setSourceMapping: function(uiSourceCode, sourceMapping)
327 {
328 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMappin g)
329 return;
330
331 if (sourceMapping)
332 this._uiSourceCodeToSourceMapping.put(uiSourceCode, sourceMapping);
333 else
334 this._uiSourceCodeToSourceMapping.remove(uiSourceCode);
335
336 uiSourceCode.dispatchEventToListeners(WebInspector.UISourceCode.Events.S ourceMappingChanged, {target: this._target, isIdentity: sourceMapping ? sourceMa pping.isIdentity() : false});
vsevik 2014/08/13 07:02:04 SourceMappingChanged event is definitely not somet
337 },
338
339 /**
340 * @param {!WebInspector.UISourceCode} uiSourceCode
341 * @param {number} lineNumber
342 * @param {number} columnNumber
343 * @return {?WebInspector.RawLocation}
344 */
345 _uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
346 {
347 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode);
348 return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCod e, lineNumber, columnNumber) : null;
349 },
350
351 /**
352 * @param {!WebInspector.UISourceCode} uiSourceCode
353 * @param {number} lineNumber
354 * @return {boolean}
355 */
356 _uiLineHasMapping: function(uiSourceCode, lineNumber)
357 {
358 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode);
359 return sourceMapping ? sourceMapping.uiLineHasMapping(uiSourceCode, line Number) : true;
360 },
361
260 _dispose: function() 362 _dispose: function()
261 { 363 {
262 this._compilerMapping.dispose(); 364 this._compilerMapping.dispose();
263 this._resourceMapping.dispose(); 365 this._resourceMapping.dispose();
264 this._defaultMapping.dispose(); 366 this._defaultMapping.dispose();
265 } 367 }
266 } 368 }
267 369
268 /** 370 /**
269 * @constructor 371 * @constructor
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 this._binding._removeLiveLocation(this); 472 this._binding._removeLiveLocation(this);
371 }, 473 },
372 474
373 __proto__: WebInspector.LiveLocation.prototype 475 __proto__: WebInspector.LiveLocation.prototype
374 } 476 }
375 477
376 /** 478 /**
377 * @type {!WebInspector.DebuggerWorkspaceBinding} 479 * @type {!WebInspector.DebuggerWorkspaceBinding}
378 */ 480 */
379 WebInspector.debuggerWorkspaceBinding; 481 WebInspector.debuggerWorkspaceBinding;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698