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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/CompilerScriptMapping.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 /* 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
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 * @implements {WebInspector.DebuggerSourceMapping} 31 * @implements {Bindings.DebuggerSourceMapping}
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.CompilerScriptMapping = class { 34 Bindings.CompilerScriptMapping = class {
35 /** 35 /**
36 * @param {!WebInspector.DebuggerModel} debuggerModel 36 * @param {!SDK.DebuggerModel} debuggerModel
37 * @param {!WebInspector.Workspace} workspace 37 * @param {!Workspace.Workspace} workspace
38 * @param {!WebInspector.NetworkMapping} networkMapping 38 * @param {!Bindings.NetworkMapping} networkMapping
39 * @param {!WebInspector.NetworkProject} networkProject 39 * @param {!Bindings.NetworkProject} networkProject
40 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding 40 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding
41 */ 41 */
42 constructor(debuggerModel, workspace, networkMapping, networkProject, debugger WorkspaceBinding) { 42 constructor(debuggerModel, workspace, networkMapping, networkProject, debugger WorkspaceBinding) {
43 this._target = debuggerModel.target(); 43 this._target = debuggerModel.target();
44 this._debuggerModel = debuggerModel; 44 this._debuggerModel = debuggerModel;
45 this._networkMapping = networkMapping; 45 this._networkMapping = networkMapping;
46 this._networkProject = networkProject; 46 this._networkProject = networkProject;
47 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; 47 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding;
48 48
49 /** @type {!Map<string, !Promise<?WebInspector.TextSourceMap>>} */ 49 /** @type {!Map<string, !Promise<?SDK.TextSourceMap>>} */
50 this._sourceMapLoadingPromises = new Map(); 50 this._sourceMapLoadingPromises = new Map();
51 /** @type {!Map<string, !WebInspector.TextSourceMap>} */ 51 /** @type {!Map<string, !SDK.TextSourceMap>} */
52 this._sourceMapForScriptId = new Map(); 52 this._sourceMapForScriptId = new Map();
53 /** @type {!Map.<!WebInspector.TextSourceMap, !WebInspector.Script>} */ 53 /** @type {!Map.<!SDK.TextSourceMap, !SDK.Script>} */
54 this._scriptForSourceMap = new Map(); 54 this._scriptForSourceMap = new Map();
55 /** @type {!Map.<string, !WebInspector.TextSourceMap>} */ 55 /** @type {!Map.<string, !SDK.TextSourceMap>} */
56 this._sourceMapForURL = new Map(); 56 this._sourceMapForURL = new Map();
57 /** @type {!Map.<string, !WebInspector.UISourceCode>} */ 57 /** @type {!Map.<string, !Workspace.UISourceCode>} */
58 this._stubUISourceCodes = new Map(); 58 this._stubUISourceCodes = new Map();
59 59
60 var projectId = WebInspector.CompilerScriptMapping.projectIdForTarget(this._ target); 60 var projectId = Bindings.CompilerScriptMapping.projectIdForTarget(this._targ et);
61 this._stubProject = 61 this._stubProject =
62 new WebInspector.ContentProviderBasedProject(workspace, projectId, WebIn spector.projectTypes.Service, ''); 62 new Bindings.ContentProviderBasedProject(workspace, projectId, Workspace .projectTypes.Service, '');
63 this._eventListeners = [ 63 this._eventListeners = [
64 workspace.addEventListener( 64 workspace.addEventListener(
65 WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdd edToWorkspace, this), 65 Workspace.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAddedT oWorkspace, this),
66 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObj ectCleared, this._debuggerReset, this) 66 debuggerModel.addEventListener(SDK.DebuggerModel.Events.GlobalObjectCleare d, this._debuggerReset, this)
67 ]; 67 ];
68 } 68 }
69 69
70 /** 70 /**
71 * @param {!WebInspector.UISourceCode} uiSourceCode 71 * @param {!Workspace.UISourceCode} uiSourceCode
72 * @return {?string} 72 * @return {?string}
73 */ 73 */
74 static uiSourceCodeOrigin(uiSourceCode) { 74 static uiSourceCodeOrigin(uiSourceCode) {
75 return uiSourceCode[WebInspector.CompilerScriptMapping._originSymbol] || nul l; 75 return uiSourceCode[Bindings.CompilerScriptMapping._originSymbol] || null;
76 } 76 }
77 77
78 /** 78 /**
79 * @param {!WebInspector.Target} target 79 * @param {!SDK.Target} target
80 * @return {string} 80 * @return {string}
81 */ 81 */
82 static projectIdForTarget(target) { 82 static projectIdForTarget(target) {
83 return 'compiler-script-project:' + target.id(); 83 return 'compiler-script-project:' + target.id();
84 } 84 }
85 85
86 /** 86 /**
87 * @param {!WebInspector.DebuggerModel.Location} rawLocation 87 * @param {!SDK.DebuggerModel.Location} rawLocation
88 * @return {boolean} 88 * @return {boolean}
89 */ 89 */
90 mapsToSourceCode(rawLocation) { 90 mapsToSourceCode(rawLocation) {
91 var sourceMap = this._sourceMapForScriptId.get(rawLocation.scriptId); 91 var sourceMap = this._sourceMapForScriptId.get(rawLocation.scriptId);
92 if (!sourceMap) { 92 if (!sourceMap) {
93 return true; 93 return true;
94 } 94 }
95 return !!sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNumbe r); 95 return !!sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNumbe r);
96 } 96 }
97 97
98 /** 98 /**
99 * @override 99 * @override
100 * @param {!WebInspector.DebuggerModel.Location} rawLocation 100 * @param {!SDK.DebuggerModel.Location} rawLocation
101 * @return {?WebInspector.UILocation} 101 * @return {?Workspace.UILocation}
102 */ 102 */
103 rawLocationToUILocation(rawLocation) { 103 rawLocationToUILocation(rawLocation) {
104 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (rawLocation); 104 var debuggerModelLocation = /** @type {!SDK.DebuggerModel.Location} */ (rawL ocation);
105 105
106 var stubUISourceCode = this._stubUISourceCodes.get(debuggerModelLocation.scr iptId); 106 var stubUISourceCode = this._stubUISourceCodes.get(debuggerModelLocation.scr iptId);
107 if (stubUISourceCode) 107 if (stubUISourceCode)
108 return new WebInspector.UILocation(stubUISourceCode, rawLocation.lineNumbe r, rawLocation.columnNumber); 108 return new Workspace.UILocation(stubUISourceCode, rawLocation.lineNumber, rawLocation.columnNumber);
109 109
110 var sourceMap = this._sourceMapForScriptId.get(debuggerModelLocation.scriptI d); 110 var sourceMap = this._sourceMapForScriptId.get(debuggerModelLocation.scriptI d);
111 if (!sourceMap) 111 if (!sourceMap)
112 return null; 112 return null;
113 var lineNumber = debuggerModelLocation.lineNumber; 113 var lineNumber = debuggerModelLocation.lineNumber;
114 var columnNumber = debuggerModelLocation.columnNumber || 0; 114 var columnNumber = debuggerModelLocation.columnNumber || 0;
115 var entry = sourceMap.findEntry(lineNumber, columnNumber); 115 var entry = sourceMap.findEntry(lineNumber, columnNumber);
116 if (!entry || !entry.sourceURL) 116 if (!entry || !entry.sourceURL)
117 return null; 117 return null;
118 var script = rawLocation.script(); 118 var script = rawLocation.script();
119 if (!script) 119 if (!script)
120 return null; 120 return null;
121 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(/** @type { string} */ (entry.sourceURL), script); 121 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(/** @type { string} */ (entry.sourceURL), script);
122 if (!uiSourceCode) 122 if (!uiSourceCode)
123 return null; 123 return null;
124 return uiSourceCode.uiLocation( 124 return uiSourceCode.uiLocation(
125 /** @type {number} */ (entry.sourceLineNumber), /** @type {number} */ (e ntry.sourceColumnNumber)); 125 /** @type {number} */ (entry.sourceLineNumber), /** @type {number} */ (e ntry.sourceColumnNumber));
126 } 126 }
127 127
128 /** 128 /**
129 * @override 129 * @override
130 * @param {!WebInspector.UISourceCode} uiSourceCode 130 * @param {!Workspace.UISourceCode} uiSourceCode
131 * @param {number} lineNumber 131 * @param {number} lineNumber
132 * @param {number} columnNumber 132 * @param {number} columnNumber
133 * @return {?WebInspector.DebuggerModel.Location} 133 * @return {?SDK.DebuggerModel.Location}
134 */ 134 */
135 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { 135 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
136 if (uiSourceCode.project().type() === WebInspector.projectTypes.Service) 136 if (uiSourceCode.project().type() === Workspace.projectTypes.Service)
137 return null; 137 return null;
138 var sourceMap = this._sourceMapForURL.get(uiSourceCode.url()); 138 var sourceMap = this._sourceMapForURL.get(uiSourceCode.url());
139 if (!sourceMap) 139 if (!sourceMap)
140 return null; 140 return null;
141 var script = /** @type {!WebInspector.Script} */ (this._scriptForSourceMap.g et(sourceMap)); 141 var script = /** @type {!SDK.Script} */ (this._scriptForSourceMap.get(source Map));
142 console.assert(script); 142 console.assert(script);
143 var entry = sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber) ; 143 var entry = sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber) ;
144 if (!entry) 144 if (!entry)
145 return null; 145 return null;
146 return this._debuggerModel.createRawLocation(script, entry.lineNumber, entry .columnNumber); 146 return this._debuggerModel.createRawLocation(script, entry.lineNumber, entry .columnNumber);
147 } 147 }
148 148
149 /** 149 /**
150 * @param {!WebInspector.Script} script 150 * @param {!SDK.Script} script
151 */ 151 */
152 addScript(script) { 152 addScript(script) {
153 if (!script.sourceMapURL) { 153 if (!script.sourceMapURL) {
154 script.addEventListener(WebInspector.Script.Events.SourceMapURLAdded, this ._sourceMapURLAdded.bind(this)); 154 script.addEventListener(SDK.Script.Events.SourceMapURLAdded, this._sourceM apURLAdded.bind(this));
155 return; 155 return;
156 } 156 }
157 157
158 this._processScript(script); 158 this._processScript(script);
159 } 159 }
160 160
161 /** 161 /**
162 * @param {!WebInspector.Script} script 162 * @param {!SDK.Script} script
163 * @return {?WebInspector.TextSourceMap} 163 * @return {?SDK.TextSourceMap}
164 */ 164 */
165 sourceMapForScript(script) { 165 sourceMapForScript(script) {
166 return this._sourceMapForScriptId.get(script.scriptId) || null; 166 return this._sourceMapForScriptId.get(script.scriptId) || null;
167 } 167 }
168 168
169 /** 169 /**
170 * @param {!WebInspector.Script} script 170 * @param {!SDK.Script} script
171 */ 171 */
172 maybeLoadSourceMap(script) { 172 maybeLoadSourceMap(script) {
173 if (!script.sourceMapURL) 173 if (!script.sourceMapURL)
174 return; 174 return;
175 if (this._sourceMapLoadingPromises.has(script.sourceMapURL)) 175 if (this._sourceMapLoadingPromises.has(script.sourceMapURL))
176 return; 176 return;
177 if (this._sourceMapForScriptId.has(script.scriptId)) 177 if (this._sourceMapForScriptId.has(script.scriptId))
178 return; 178 return;
179 this._processScript(script); 179 this._processScript(script);
180 } 180 }
181 181
182 /** 182 /**
183 * @param {!WebInspector.Event} event 183 * @param {!Common.Event} event
184 */ 184 */
185 _sourceMapURLAdded(event) { 185 _sourceMapURLAdded(event) {
186 var script = /** @type {!WebInspector.Script} */ (event.target); 186 var script = /** @type {!SDK.Script} */ (event.target);
187 if (!script.sourceMapURL) 187 if (!script.sourceMapURL)
188 return; 188 return;
189 this._processScript(script); 189 this._processScript(script);
190 } 190 }
191 191
192 /** 192 /**
193 * @param {!WebInspector.Script} script 193 * @param {!SDK.Script} script
194 */ 194 */
195 _processScript(script) { 195 _processScript(script) {
196 if (WebInspector.blackboxManager.isBlackboxedURL(script.sourceURL, script.is ContentScript())) 196 if (Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isCont entScript()))
197 return; 197 return;
198 // Create stub UISourceCode for the time source mapping is being loaded. 198 // Create stub UISourceCode for the time source mapping is being loaded.
199 var stubUISourceCode = this._stubProject.addContentProvider( 199 var stubUISourceCode = this._stubProject.addContentProvider(
200 script.sourceURL, 200 script.sourceURL,
201 WebInspector.StaticContentProvider.fromString( 201 Common.StaticContentProvider.fromString(
202 script.sourceURL, WebInspector.resourceTypes.Script, 202 script.sourceURL, Common.resourceTypes.Script,
203 '\n\n\n\n\n// Please wait a bit.\n// Compiled script is not shown wh ile source map is being loaded!')); 203 '\n\n\n\n\n// Please wait a bit.\n// Compiled script is not shown wh ile source map is being loaded!'));
204 this._stubUISourceCodes.set(script.scriptId, stubUISourceCode); 204 this._stubUISourceCodes.set(script.scriptId, stubUISourceCode);
205 205
206 this._debuggerWorkspaceBinding.pushSourceMapping(script, this); 206 this._debuggerWorkspaceBinding.pushSourceMapping(script, this);
207 this._loadSourceMapForScript(script).then(this._sourceMapLoaded.bind(this, s cript, stubUISourceCode.url())); 207 this._loadSourceMapForScript(script).then(this._sourceMapLoaded.bind(this, s cript, stubUISourceCode.url()));
208 } 208 }
209 209
210 /** 210 /**
211 * @param {!WebInspector.Script} script 211 * @param {!SDK.Script} script
212 * @param {string} uiSourceCodePath 212 * @param {string} uiSourceCodePath
213 * @param {?WebInspector.TextSourceMap} sourceMap 213 * @param {?SDK.TextSourceMap} sourceMap
214 */ 214 */
215 _sourceMapLoaded(script, uiSourceCodePath, sourceMap) { 215 _sourceMapLoaded(script, uiSourceCodePath, sourceMap) {
216 WebInspector.blackboxManager.sourceMapLoaded(script, sourceMap); 216 Bindings.blackboxManager.sourceMapLoaded(script, sourceMap);
217 217
218 this._stubUISourceCodes.delete(script.scriptId); 218 this._stubUISourceCodes.delete(script.scriptId);
219 this._stubProject.removeFile(uiSourceCodePath); 219 this._stubProject.removeFile(uiSourceCodePath);
220 220
221 if (!sourceMap) { 221 if (!sourceMap) {
222 this._debuggerWorkspaceBinding.updateLocations(script); 222 this._debuggerWorkspaceBinding.updateLocations(script);
223 return; 223 return;
224 } 224 }
225 225
226 if (this._scriptForSourceMap.get(sourceMap)) { 226 if (this._scriptForSourceMap.get(sourceMap)) {
227 this._sourceMapForScriptId.set(script.scriptId, sourceMap); 227 this._sourceMapForScriptId.set(script.scriptId, sourceMap);
228 this._debuggerWorkspaceBinding.updateLocations(script); 228 this._debuggerWorkspaceBinding.updateLocations(script);
229 return; 229 return;
230 } 230 }
231 231
232 this._sourceMapForScriptId.set(script.scriptId, sourceMap); 232 this._sourceMapForScriptId.set(script.scriptId, sourceMap);
233 this._scriptForSourceMap.set(sourceMap, script); 233 this._scriptForSourceMap.set(sourceMap, script);
234 234
235 // Report sources. 235 // Report sources.
236 var missingSources = []; 236 var missingSources = [];
237 for (var sourceURL of sourceMap.sourceURLs()) { 237 for (var sourceURL of sourceMap.sourceURLs()) {
238 if (this._sourceMapForURL.get(sourceURL)) 238 if (this._sourceMapForURL.get(sourceURL))
239 continue; 239 continue;
240 this._sourceMapForURL.set(sourceURL, sourceMap); 240 this._sourceMapForURL.set(sourceURL, sourceMap);
241 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(sourceURL , script); 241 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(sourceURL , script);
242 if (!uiSourceCode) { 242 if (!uiSourceCode) {
243 var contentProvider = sourceMap.sourceContentProvider(sourceURL, WebInsp ector.resourceTypes.SourceMapScript); 243 var contentProvider = sourceMap.sourceContentProvider(sourceURL, Common. resourceTypes.SourceMapScript);
244 var embeddedContent = sourceMap.embeddedContentByURL(sourceURL); 244 var embeddedContent = sourceMap.embeddedContentByURL(sourceURL);
245 var embeddedContentLength = typeof embeddedContent === 'string' ? embedd edContent.length : null; 245 var embeddedContentLength = typeof embeddedContent === 'string' ? embedd edContent.length : null;
246 uiSourceCode = this._networkProject.addFile( 246 uiSourceCode = this._networkProject.addFile(
247 contentProvider, WebInspector.ResourceTreeFrame.fromScript(script), script.isContentScript(), 247 contentProvider, SDK.ResourceTreeFrame.fromScript(script), script.is ContentScript(),
248 embeddedContentLength); 248 embeddedContentLength);
249 uiSourceCode[WebInspector.CompilerScriptMapping._originSymbol] = script. sourceURL; 249 uiSourceCode[Bindings.CompilerScriptMapping._originSymbol] = script.sour ceURL;
250 } 250 }
251 if (uiSourceCode) { 251 if (uiSourceCode) {
252 this._bindUISourceCode(uiSourceCode); 252 this._bindUISourceCode(uiSourceCode);
253 } else { 253 } else {
254 if (missingSources.length < 3) 254 if (missingSources.length < 3)
255 missingSources.push(sourceURL); 255 missingSources.push(sourceURL);
256 else if (missingSources.peekLast() !== '\u2026') 256 else if (missingSources.peekLast() !== '\u2026')
257 missingSources.push('\u2026'); 257 missingSources.push('\u2026');
258 } 258 }
259 } 259 }
260 if (missingSources.length) { 260 if (missingSources.length) {
261 WebInspector.console.warn(WebInspector.UIString( 261 Common.console.warn(Common.UIString(
262 'Source map %s points to the files missing from the workspace: [%s]', sourceMap.url(), 262 'Source map %s points to the files missing from the workspace: [%s]', sourceMap.url(),
263 missingSources.join(', '))); 263 missingSources.join(', ')));
264 } 264 }
265 265
266 this._debuggerWorkspaceBinding.updateLocations(script); 266 this._debuggerWorkspaceBinding.updateLocations(script);
267 } 267 }
268 268
269 /** 269 /**
270 * @override 270 * @override
271 * @return {boolean} 271 * @return {boolean}
272 */ 272 */
273 isIdentity() { 273 isIdentity() {
274 return false; 274 return false;
275 } 275 }
276 276
277 /** 277 /**
278 * @override 278 * @override
279 * @param {!WebInspector.UISourceCode} uiSourceCode 279 * @param {!Workspace.UISourceCode} uiSourceCode
280 * @param {number} lineNumber 280 * @param {number} lineNumber
281 * @return {boolean} 281 * @return {boolean}
282 */ 282 */
283 uiLineHasMapping(uiSourceCode, lineNumber) { 283 uiLineHasMapping(uiSourceCode, lineNumber) {
284 var sourceMap = this._sourceMapForURL.get(uiSourceCode.url()); 284 var sourceMap = this._sourceMapForURL.get(uiSourceCode.url());
285 if (!sourceMap) 285 if (!sourceMap)
286 return true; 286 return true;
287 return !!sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber); 287 return !!sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber);
288 } 288 }
289 289
290 /** 290 /**
291 * @param {!WebInspector.UISourceCode} uiSourceCode 291 * @param {!Workspace.UISourceCode} uiSourceCode
292 */ 292 */
293 _bindUISourceCode(uiSourceCode) { 293 _bindUISourceCode(uiSourceCode) {
294 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCode, this); 294 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCode, this);
295 } 295 }
296 296
297 /** 297 /**
298 * @param {!WebInspector.UISourceCode} uiSourceCode 298 * @param {!Workspace.UISourceCode} uiSourceCode
299 */ 299 */
300 _unbindUISourceCode(uiSourceCode) { 300 _unbindUISourceCode(uiSourceCode) {
301 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCode, null); 301 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCode, null);
302 } 302 }
303 303
304 /** 304 /**
305 * @param {!WebInspector.Event} event 305 * @param {!Common.Event} event
306 */ 306 */
307 _uiSourceCodeAddedToWorkspace(event) { 307 _uiSourceCodeAddedToWorkspace(event) {
308 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); 308 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
309 if (!this._sourceMapForURL.get(uiSourceCode.url())) 309 if (!this._sourceMapForURL.get(uiSourceCode.url()))
310 return; 310 return;
311 this._bindUISourceCode(uiSourceCode); 311 this._bindUISourceCode(uiSourceCode);
312 } 312 }
313 313
314 /** 314 /**
315 * @param {!WebInspector.Script} script 315 * @param {!SDK.Script} script
316 * @return {!Promise<?WebInspector.TextSourceMap>} 316 * @return {!Promise<?SDK.TextSourceMap>}
317 */ 317 */
318 _loadSourceMapForScript(script) { 318 _loadSourceMapForScript(script) {
319 // script.sourceURL can be a random string, but is generally an absolute pat h -> complete it to inspected page url for 319 // script.sourceURL can be a random string, but is generally an absolute pat h -> complete it to inspected page url for
320 // relative links. 320 // relative links.
321 var scriptURL = WebInspector.ParsedURL.completeURL(this._target.inspectedURL (), script.sourceURL); 321 var scriptURL = Common.ParsedURL.completeURL(this._target.inspectedURL(), sc ript.sourceURL);
322 if (!scriptURL) 322 if (!scriptURL)
323 return Promise.resolve(/** @type {?WebInspector.TextSourceMap} */ (null)); 323 return Promise.resolve(/** @type {?SDK.TextSourceMap} */ (null));
324 324
325 console.assert(script.sourceMapURL); 325 console.assert(script.sourceMapURL);
326 var scriptSourceMapURL = /** @type {string} */ (script.sourceMapURL); 326 var scriptSourceMapURL = /** @type {string} */ (script.sourceMapURL);
327 327
328 var sourceMapURL = WebInspector.ParsedURL.completeURL(scriptURL, scriptSourc eMapURL); 328 var sourceMapURL = Common.ParsedURL.completeURL(scriptURL, scriptSourceMapUR L);
329 if (!sourceMapURL) 329 if (!sourceMapURL)
330 return Promise.resolve(/** @type {?WebInspector.TextSourceMap} */ (null)); 330 return Promise.resolve(/** @type {?SDK.TextSourceMap} */ (null));
331 331
332 var loadingPromise = this._sourceMapLoadingPromises.get(sourceMapURL); 332 var loadingPromise = this._sourceMapLoadingPromises.get(sourceMapURL);
333 if (!loadingPromise) { 333 if (!loadingPromise) {
334 loadingPromise = 334 loadingPromise =
335 WebInspector.TextSourceMap.load(sourceMapURL, scriptURL).then(sourceMa pLoaded.bind(this, sourceMapURL)); 335 SDK.TextSourceMap.load(sourceMapURL, scriptURL).then(sourceMapLoaded.b ind(this, sourceMapURL));
336 this._sourceMapLoadingPromises.set(sourceMapURL, loadingPromise); 336 this._sourceMapLoadingPromises.set(sourceMapURL, loadingPromise);
337 } 337 }
338 return loadingPromise; 338 return loadingPromise;
339 339
340 /** 340 /**
341 * @param {string} url 341 * @param {string} url
342 * @param {?WebInspector.TextSourceMap} sourceMap 342 * @param {?SDK.TextSourceMap} sourceMap
343 * @this {WebInspector.CompilerScriptMapping} 343 * @this {Bindings.CompilerScriptMapping}
344 */ 344 */
345 function sourceMapLoaded(url, sourceMap) { 345 function sourceMapLoaded(url, sourceMap) {
346 if (!sourceMap) { 346 if (!sourceMap) {
347 this._sourceMapLoadingPromises.delete(url); 347 this._sourceMapLoadingPromises.delete(url);
348 return null; 348 return null;
349 } 349 }
350 350
351 return sourceMap; 351 return sourceMap;
352 } 352 }
353 } 353 }
354 354
355 _debuggerReset() { 355 _debuggerReset() {
356 /** 356 /**
357 * @param {!WebInspector.TextSourceMap} sourceMap 357 * @param {!SDK.TextSourceMap} sourceMap
358 * @this {WebInspector.CompilerScriptMapping} 358 * @this {Bindings.CompilerScriptMapping}
359 */ 359 */
360 function unbindSourceMapSources(sourceMap) { 360 function unbindSourceMapSources(sourceMap) {
361 var script = this._scriptForSourceMap.get(sourceMap); 361 var script = this._scriptForSourceMap.get(sourceMap);
362 if (!script) 362 if (!script)
363 return; 363 return;
364 for (var sourceURL of sourceMap.sourceURLs()) { 364 for (var sourceURL of sourceMap.sourceURLs()) {
365 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(sourceU RL, script); 365 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(sourceU RL, script);
366 if (uiSourceCode) 366 if (uiSourceCode)
367 this._unbindUISourceCode(uiSourceCode); 367 this._unbindUISourceCode(uiSourceCode);
368 } 368 }
369 } 369 }
370 370
371 this._sourceMapForURL.valuesArray().forEach(unbindSourceMapSources.bind(this )); 371 this._sourceMapForURL.valuesArray().forEach(unbindSourceMapSources.bind(this ));
372 372
373 this._sourceMapLoadingPromises.clear(); 373 this._sourceMapLoadingPromises.clear();
374 this._sourceMapForScriptId.clear(); 374 this._sourceMapForScriptId.clear();
375 this._scriptForSourceMap.clear(); 375 this._scriptForSourceMap.clear();
376 this._sourceMapForURL.clear(); 376 this._sourceMapForURL.clear();
377 } 377 }
378 378
379 dispose() { 379 dispose() {
380 WebInspector.EventTarget.removeEventListeners(this._eventListeners); 380 Common.EventTarget.removeEventListeners(this._eventListeners);
381 this._debuggerReset(); 381 this._debuggerReset();
382 this._stubProject.dispose(); 382 this._stubProject.dispose();
383 } 383 }
384 }; 384 };
385 385
386 WebInspector.CompilerScriptMapping._originSymbol = Symbol('origin'); 386 Bindings.CompilerScriptMapping._originSymbol = Symbol('origin');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698