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

Side by Side Diff: Source/devtools/front_end/ResourceScriptMapping.js

Issue 228863002: DevTools: remove setScriptFile from UISourceCode. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @implements {WebInspector.ScriptSourceMapping} 33 */
34 WebInspector.SourceMappingWithScriptFile = function()
35 {
36 }
37
38 WebInspector.SourceMappingWithScriptFile.prototype = {
39 /**
40 * @param {!WebInspector.UISourceCode} uiSourceCode
41 * @return {?WebInspector.ScriptFile}
42 */
43 scriptFile: function(uiSourceCode)
44 {
45 return null;
46 }
47 }
48
49 /**
50 * @constructor
51 * @extends {WebInspector.SourceMappingWithScriptFile}
52 * @implements {WebInspector.SourceMapping}
34 * @param {!WebInspector.DebuggerModel} debuggerModel 53 * @param {!WebInspector.DebuggerModel} debuggerModel
35 * @param {!WebInspector.Workspace} workspace 54 * @param {!WebInspector.Workspace} workspace
36 */ 55 */
37 WebInspector.ResourceScriptMapping = function(debuggerModel, workspace) 56 WebInspector.ResourceScriptMapping = function(debuggerModel, workspace)
38 { 57 {
58 WebInspector.SourceMappingWithScriptFile.call(this);
59
39 this._debuggerModel = debuggerModel; 60 this._debuggerModel = debuggerModel;
40 this._workspace = workspace; 61 this._workspace = workspace;
41 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAddedToWorkspace, this); 62 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAddedToWorkspace, this);
42 this._boundURLs = new StringSet(); 63 this._boundURLs = new StringSet();
64 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.ResourceScriptFil e>} */
65 this._scriptFiles = new Map();
43 66
44 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjec tCleared, this._debuggerReset, this); 67 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjec tCleared, this._debuggerReset, this);
45 } 68 }
46 69
47 WebInspector.ResourceScriptMapping.prototype = { 70 WebInspector.ResourceScriptMapping.prototype = {
48 /** 71 /**
49 * @param {!WebInspector.RawLocation} rawLocation 72 * @param {!WebInspector.RawLocation} rawLocation
50 * @return {?WebInspector.UILocation} 73 * @return {?WebInspector.UILocation}
51 */ 74 */
52 rawLocationToUILocation: function(rawLocation) 75 rawLocationToUILocation: function(rawLocation)
53 { 76 {
54 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Locat ion} */ (rawLocation); 77 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Locat ion} */ (rawLocation);
55 var script = debuggerModelLocation.script(); 78 var script = debuggerModelLocation.script();
56 var uiSourceCode = this._workspaceUISourceCodeForScript(script); 79 var uiSourceCode = this._workspaceUISourceCodeForScript(script);
57 if (!uiSourceCode) 80 if (!uiSourceCode)
58 return null; 81 return null;
59 var scriptFile = uiSourceCode.scriptFile(); 82 var scriptFile = /** @type {?WebInspector.ResourceScriptFile} */ (this._ scriptFiles.get(uiSourceCode));
60 if (scriptFile && ((scriptFile.hasDivergedFromVM() && !scriptFile.isMerg ingToVM()) || scriptFile.isDivergingFromVM())) 83 if (scriptFile && ((scriptFile.hasDivergedFromVM() && !scriptFile.isMerg ingToVM()) || scriptFile.isDivergingFromVM()))
61 return null; 84 return null;
62 return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.l ineNumber, debuggerModelLocation.columnNumber || 0); 85 return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.l ineNumber, debuggerModelLocation.columnNumber || 0);
63 }, 86 },
64 87
65 /** 88 /**
66 * @param {!WebInspector.UISourceCode} uiSourceCode 89 * @param {!WebInspector.UISourceCode} uiSourceCode
67 * @param {number} lineNumber 90 * @param {number} lineNumber
68 * @param {number} columnNumber 91 * @param {number} columnNumber
69 * @return {?WebInspector.DebuggerModel.Location} 92 * @return {?WebInspector.DebuggerModel.Location}
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return this._debuggerModel.scriptsForSourceURL(uiSourceCode.url); 183 return this._debuggerModel.scriptsForSourceURL(uiSourceCode.url);
161 }, 184 },
162 185
163 /** 186 /**
164 * @param {!WebInspector.UISourceCode} uiSourceCode 187 * @param {!WebInspector.UISourceCode} uiSourceCode
165 * @param {!Array.<!WebInspector.Script>} scripts 188 * @param {!Array.<!WebInspector.Script>} scripts
166 */ 189 */
167 _bindUISourceCodeToScripts: function(uiSourceCode, scripts) 190 _bindUISourceCodeToScripts: function(uiSourceCode, scripts)
168 { 191 {
169 console.assert(scripts.length); 192 console.assert(scripts.length);
170 var scriptFile = new WebInspector.ResourceScriptFile(this, uiSourceCode, scripts); 193 this._scriptFiles.put(uiSourceCode, new WebInspector.ResourceScriptFile( this, uiSourceCode, scripts));
171 uiSourceCode.setScriptFile(scriptFile);
172 for (var i = 0; i < scripts.length; ++i) 194 for (var i = 0; i < scripts.length; ++i)
173 scripts[i].updateLocations(); 195 scripts[i].updateLocations();
174 uiSourceCode.setSourceMapping(this); 196 uiSourceCode.setSourceMapping(this);
175 this._boundURLs.add(uiSourceCode.url); 197 this._boundURLs.add(uiSourceCode.url);
176 }, 198 },
177 199
178 /** 200 /**
179 * @param {!WebInspector.UISourceCode} uiSourceCode 201 * @param {!WebInspector.UISourceCode} uiSourceCode
180 */ 202 */
181 _unbindUISourceCode: function(uiSourceCode) 203 _unbindUISourceCode: function(uiSourceCode)
182 { 204 {
183 var scriptFile = /** @type {!WebInspector.ResourceScriptFile} */ (uiSour ceCode.scriptFile()); 205 var scriptFile = /** @type {?WebInspector.ResourceScriptFile} */ (this._ scriptFiles.get(uiSourceCode));
184 if (scriptFile) { 206 if (scriptFile) {
185 scriptFile.dispose(); 207 scriptFile.dispose();
186 uiSourceCode.setScriptFile(null); 208 this._scriptFiles.remove(uiSourceCode);
187 } 209 }
188 uiSourceCode.setSourceMapping(null); 210 uiSourceCode.setSourceMapping(null);
189 }, 211 },
190 212
191 _debuggerReset: function() 213 _debuggerReset: function()
192 { 214 {
193 var boundURLs = this._boundURLs.values(); 215 var boundURLs = this._boundURLs.values();
194 for (var i = 0; i < boundURLs.length; ++i) 216 for (var i = 0; i < boundURLs.length; ++i)
195 { 217 {
196 var uiSourceCode = this._workspace.uiSourceCodeForURL(boundURLs[i]); 218 var uiSourceCode = this._workspace.uiSourceCodeForURL(boundURLs[i]);
197 if (!uiSourceCode) 219 if (!uiSourceCode)
198 continue; 220 continue;
199 this._unbindUISourceCode(uiSourceCode); 221 this._unbindUISourceCode(uiSourceCode);
200 } 222 }
201 this._boundURLs.clear(); 223 this._boundURLs.clear();
224 this._scriptFiles.clear();
202 }, 225 },
226
227 /**
228 * @param {!WebInspector.UISourceCode} uiSourceCode
229 * @return {?WebInspector.ResourceScriptFile}
230 */
231 scriptFile: function(uiSourceCode)
232 {
233 return this._scriptFiles.get(uiSourceCode) || null;
vsevik 2014/04/09 10:39:42 || null is redundant
234 },
235
236 __proto__: WebInspector.SourceMappingWithScriptFile.prototype
203 } 237 }
204 238
205 /** 239 /**
206 * @interface 240 * @interface
207 * @extends {WebInspector.EventTarget} 241 * @extends {WebInspector.EventTarget}
208 */ 242 */
209 WebInspector.ScriptFile = function() 243 WebInspector.ScriptFile = function()
210 { 244 {
211 } 245 }
212 246
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 }, 409 },
376 410
377 dispose: function() 411 dispose: function()
378 { 412 {
379 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); 413 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this);
380 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); 414 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this);
381 }, 415 },
382 416
383 __proto__: WebInspector.Object.prototype 417 __proto__: WebInspector.Object.prototype
384 } 418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698