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

Side by Side Diff: Source/devtools/front_end/sdk/ResourceScriptMapping.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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 22 matching lines...) Expand all
33 * @implements {WebInspector.ScriptSourceMapping} 33 * @implements {WebInspector.ScriptSourceMapping}
34 * @param {!WebInspector.DebuggerModel} debuggerModel 34 * @param {!WebInspector.DebuggerModel} debuggerModel
35 * @param {!WebInspector.Workspace} workspace 35 * @param {!WebInspector.Workspace} workspace
36 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding 36 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding
37 */ 37 */
38 WebInspector.ResourceScriptMapping = function(debuggerModel, workspace, debugger WorkspaceBinding) 38 WebInspector.ResourceScriptMapping = function(debuggerModel, workspace, debugger WorkspaceBinding)
39 { 39 {
40 this._target = debuggerModel.target(); 40 this._target = debuggerModel.target();
41 this._debuggerModel = debuggerModel; 41 this._debuggerModel = debuggerModel;
42 this._workspace = workspace; 42 this._workspace = workspace;
43 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAddedToWorkspace, this); 43 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAdded, this);
44 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; 44 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding;
45 this._boundURLs = new StringSet(); 45 this._boundURLs = new StringSet();
46 46
47 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.ResourceScriptFil e>} */
48 this._uiSourceCodeToScriptFile = new Map();
vsevik 2014/08/13 07:02:04 this map is never cleared.
apavlov 2014/08/13 07:20:43 Done.
49
47 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjec tCleared, this._debuggerReset, this); 50 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjec tCleared, this._debuggerReset, this);
48 } 51 }
49 52
50 WebInspector.ResourceScriptMapping.prototype = { 53 WebInspector.ResourceScriptMapping.prototype = {
51 /** 54 /**
52 * @param {!WebInspector.RawLocation} rawLocation 55 * @param {!WebInspector.RawLocation} rawLocation
53 * @return {?WebInspector.UILocation} 56 * @return {?WebInspector.UILocation}
54 */ 57 */
55 rawLocationToUILocation: function(rawLocation) 58 rawLocationToUILocation: function(rawLocation)
56 { 59 {
57 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Locat ion} */ (rawLocation); 60 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Locat ion} */ (rawLocation);
58 var script = debuggerModelLocation.script(); 61 var script = debuggerModelLocation.script();
59 var uiSourceCode = this._workspaceUISourceCodeForScript(script); 62 var uiSourceCode = this._workspaceUISourceCodeForScript(script);
60 if (!uiSourceCode) 63 if (!uiSourceCode)
61 return null; 64 return null;
62 var scriptFile = uiSourceCode.scriptFileForTarget(this._target); 65 var scriptFile = this.scriptFile(uiSourceCode);
63 if (scriptFile && ((scriptFile.hasDivergedFromVM() && !scriptFile.isMerg ingToVM()) || scriptFile.isDivergingFromVM())) 66 if (scriptFile && ((scriptFile.hasDivergedFromVM() && !scriptFile.isMerg ingToVM()) || scriptFile.isDivergingFromVM()))
64 return null; 67 return null;
65 return uiSourceCode.uiLocation(debuggerModelLocation.lineNumber, debugge rModelLocation.columnNumber || 0); 68 return uiSourceCode.uiLocation(debuggerModelLocation.lineNumber, debugge rModelLocation.columnNumber || 0);
66 }, 69 },
67 70
68 /** 71 /**
69 * @param {!WebInspector.UISourceCode} uiSourceCode 72 * @param {!WebInspector.UISourceCode} uiSourceCode
70 * @param {number} lineNumber 73 * @param {number} lineNumber
71 * @param {number} columnNumber 74 * @param {number} columnNumber
72 * @return {?WebInspector.DebuggerModel.Location} 75 * @return {?WebInspector.DebuggerModel.Location}
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /** 108 /**
106 * @param {!WebInspector.UISourceCode} uiSourceCode 109 * @param {!WebInspector.UISourceCode} uiSourceCode
107 * @param {number} lineNumber 110 * @param {number} lineNumber
108 * @return {boolean} 111 * @return {boolean}
109 */ 112 */
110 uiLineHasMapping: function(uiSourceCode, lineNumber) 113 uiLineHasMapping: function(uiSourceCode, lineNumber)
111 { 114 {
112 return true; 115 return true;
113 }, 116 },
114 117
115 _uiSourceCodeAddedToWorkspace: function(event) 118 /**
119 * @param {!WebInspector.UISourceCode} uiSourceCode
120 * @return {?WebInspector.ResourceScriptFile}
121 */
122 scriptFile: function(uiSourceCode)
123 {
124 return this._uiSourceCodeToScriptFile.get(uiSourceCode) || null;
125 },
126
127 /**
128 * @param {!WebInspector.UISourceCode} uiSourceCode
129 * @param {?WebInspector.ResourceScriptFile} scriptFile
130 */
131 _setScriptFile: function(uiSourceCode, scriptFile)
132 {
133 if (scriptFile)
134 this._uiSourceCodeToScriptFile.put(uiSourceCode, scriptFile);
135 else
136 this._uiSourceCodeToScriptFile.remove(uiSourceCode);
137 },
138
139 /**
140 * @param {!WebInspector.Event} event
141 */
142 _uiSourceCodeAdded: function(event)
116 { 143 {
117 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data ); 144 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
118 if (uiSourceCode.project().isServiceProject()) 145 if (uiSourceCode.project().isServiceProject())
119 return; 146 return;
120 if (!uiSourceCode.url) 147 if (!uiSourceCode.url)
121 return; 148 return;
122 149
123 var scripts = this._scriptsForUISourceCode(uiSourceCode); 150 var scripts = this._scriptsForUISourceCode(uiSourceCode);
124 if (!scripts.length) 151 if (!scripts.length)
125 return; 152 return;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 }, 201 },
175 202
176 /** 203 /**
177 * @param {!WebInspector.UISourceCode} uiSourceCode 204 * @param {!WebInspector.UISourceCode} uiSourceCode
178 * @param {!Array.<!WebInspector.Script>} scripts 205 * @param {!Array.<!WebInspector.Script>} scripts
179 */ 206 */
180 _bindUISourceCodeToScripts: function(uiSourceCode, scripts) 207 _bindUISourceCodeToScripts: function(uiSourceCode, scripts)
181 { 208 {
182 console.assert(scripts.length); 209 console.assert(scripts.length);
183 var scriptFile = new WebInspector.ResourceScriptFile(this, uiSourceCode, scripts); 210 var scriptFile = new WebInspector.ResourceScriptFile(this, uiSourceCode, scripts);
184 uiSourceCode.setScriptFileForTarget(this._target, scriptFile); 211 this._setScriptFile(uiSourceCode, scriptFile);
185 for (var i = 0; i < scripts.length; ++i) 212 for (var i = 0; i < scripts.length; ++i)
186 this._debuggerWorkspaceBinding.updateLocations(scripts[i]); 213 this._debuggerWorkspaceBinding.updateLocations(scripts[i]);
187 uiSourceCode.setSourceMappingForTarget(this._target, this); 214 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCo de, this);
188 this._boundURLs.add(uiSourceCode.url); 215 this._boundURLs.add(uiSourceCode.url);
189 }, 216 },
190 217
191 /** 218 /**
192 * @param {!WebInspector.UISourceCode} uiSourceCode 219 * @param {!WebInspector.UISourceCode} uiSourceCode
193 */ 220 */
194 _unbindUISourceCode: function(uiSourceCode) 221 _unbindUISourceCode: function(uiSourceCode)
195 { 222 {
196 var scriptFile = /** @type {!WebInspector.ResourceScriptFile} */ (uiSour ceCode.scriptFileForTarget(this._target)); 223 var scriptFile = this.scriptFile(uiSourceCode);
197 if (scriptFile) { 224 if (scriptFile) {
198 scriptFile.dispose(); 225 scriptFile.dispose();
199 uiSourceCode.setScriptFileForTarget(this._target, null); 226 this._setScriptFile(uiSourceCode, null);
200 } 227 }
201 uiSourceCode.setSourceMappingForTarget(this._target, null); 228 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCo de, null);
202 }, 229 },
203 230
204 _debuggerReset: function() 231 _debuggerReset: function()
205 { 232 {
206 var boundURLs = this._boundURLs.values(); 233 var boundURLs = this._boundURLs.values();
207 for (var i = 0; i < boundURLs.length; ++i) 234 for (var i = 0; i < boundURLs.length; ++i)
208 { 235 {
209 var uiSourceCode = this._workspace.uiSourceCodeForURL(boundURLs[i]); 236 var uiSourceCode = this._workspace.uiSourceCodeForURL(boundURLs[i]);
210 if (!uiSourceCode) 237 if (!uiSourceCode)
211 continue; 238 continue;
212 this._unbindUISourceCode(uiSourceCode); 239 this._unbindUISourceCode(uiSourceCode);
213 } 240 }
214 this._boundURLs.clear(); 241 this._boundURLs.clear();
215 }, 242 },
216 243
217 dispose: function() 244 dispose: function()
218 { 245 {
219 this._debuggerReset(); 246 this._debuggerReset();
220 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); 247 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAdded, this);
221 } 248 }
222 249
223 } 250 }
224 251
225 /** 252 /**
226 * @constructor 253 * @constructor
227 * @extends {WebInspector.Object} 254 * @extends {WebInspector.Object}
228 * @param {!WebInspector.ResourceScriptMapping} resourceScriptMapping 255 * @param {!WebInspector.ResourceScriptMapping} resourceScriptMapping
229 * @param {!WebInspector.UISourceCode} uiSourceCode 256 * @param {!WebInspector.UISourceCode} uiSourceCode
230 * @param {!Array.<!WebInspector.Script>} scripts 257 * @param {!Array.<!WebInspector.Script>} scripts
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 */ 415 */
389 addSourceMapURL: function(sourceMapURL) 416 addSourceMapURL: function(sourceMapURL)
390 { 417 {
391 if (!this._script) 418 if (!this._script)
392 return; 419 return;
393 this._script.addSourceMapURL(sourceMapURL); 420 this._script.addSourceMapURL(sourceMapURL);
394 }, 421 },
395 422
396 __proto__: WebInspector.Object.prototype 423 __proto__: WebInspector.Object.prototype
397 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698