OLD | NEW |
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 16 matching lines...) Expand all Loading... |
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 * @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.NetworkWorkspaceBinding} networkWorkspaceBinding | 36 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding |
| 37 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
37 */ | 38 */ |
38 WebInspector.CompilerScriptMapping = function(debuggerModel, workspace, networkW
orkspaceBinding) | 39 WebInspector.CompilerScriptMapping = function(debuggerModel, workspace, networkW
orkspaceBinding, debuggerWorkspaceBinding) |
39 { | 40 { |
40 this._target = debuggerModel.target(); | 41 this._target = debuggerModel.target(); |
41 this._debuggerModel = debuggerModel; | 42 this._debuggerModel = debuggerModel; |
42 this._workspace = workspace; | 43 this._workspace = workspace; |
43 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAddedToWorkspace, this); | 44 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAddedToWorkspace, this); |
44 this._networkWorkspaceBinding = networkWorkspaceBinding; | 45 this._networkWorkspaceBinding = networkWorkspaceBinding; |
| 46 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
| 47 |
45 /** @type {!Object.<string, !WebInspector.SourceMap>} */ | 48 /** @type {!Object.<string, !WebInspector.SourceMap>} */ |
46 this._sourceMapForSourceMapURL = {}; | 49 this._sourceMapForSourceMapURL = {}; |
47 /** @type {!Object.<string, !Array.<function(?WebInspector.SourceMap)>>} */ | 50 /** @type {!Object.<string, !Array.<function(?WebInspector.SourceMap)>>} */ |
48 this._pendingSourceMapLoadingCallbacks = {}; | 51 this._pendingSourceMapLoadingCallbacks = {}; |
49 /** @type {!Object.<string, !WebInspector.SourceMap>} */ | 52 /** @type {!Object.<string, !WebInspector.SourceMap>} */ |
50 this._sourceMapForScriptId = {}; | 53 this._sourceMapForScriptId = {}; |
51 /** @type {!Map.<!WebInspector.SourceMap, !WebInspector.Script>} */ | 54 /** @type {!Map.<!WebInspector.SourceMap, !WebInspector.Script>} */ |
52 this._scriptForSourceMap = new Map(); | 55 this._scriptForSourceMap = new Map(); |
53 /** @type {!StringMap.<!WebInspector.SourceMap>} */ | 56 /** @type {!StringMap.<!WebInspector.SourceMap>} */ |
54 this._sourceMapForURL = new StringMap(); | 57 this._sourceMapForURL = new StringMap(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 if (!entry) | 102 if (!entry) |
100 return null; | 103 return null; |
101 return this._debuggerModel.createRawLocation(script, /** @type {number}
*/ (entry[0]), /** @type {number} */ (entry[1])); | 104 return this._debuggerModel.createRawLocation(script, /** @type {number}
*/ (entry[0]), /** @type {number} */ (entry[1])); |
102 }, | 105 }, |
103 | 106 |
104 /** | 107 /** |
105 * @param {!WebInspector.Script} script | 108 * @param {!WebInspector.Script} script |
106 */ | 109 */ |
107 addScript: function(script) | 110 addScript: function(script) |
108 { | 111 { |
109 script.pushSourceMapping(this); | 112 this._debuggerWorkspaceBinding.pushSourceMapping(script, this); |
110 script.addEventListener(WebInspector.Script.Events.SourceMapURLAdded, th
is._sourceMapURLAdded.bind(this)); | 113 script.addEventListener(WebInspector.Script.Events.SourceMapURLAdded, th
is._sourceMapURLAdded.bind(this)); |
111 this._processScript(script); | 114 this._processScript(script); |
112 }, | 115 }, |
113 | 116 |
114 /** | 117 /** |
115 * @param {!WebInspector.Event} event | 118 * @param {!WebInspector.Event} event |
116 */ | 119 */ |
117 _sourceMapURLAdded: function(event) | 120 _sourceMapURLAdded: function(event) |
118 { | 121 { |
119 var script = /** @type {!WebInspector.Script} */ (event.target); | 122 var script = /** @type {!WebInspector.Script} */ (event.target); |
(...skipping 11 matching lines...) Expand all Loading... |
131 * @param {?WebInspector.SourceMap} sourceMap | 134 * @param {?WebInspector.SourceMap} sourceMap |
132 * @this {WebInspector.CompilerScriptMapping} | 135 * @this {WebInspector.CompilerScriptMapping} |
133 */ | 136 */ |
134 function sourceMapLoaded(sourceMap) | 137 function sourceMapLoaded(sourceMap) |
135 { | 138 { |
136 if (!sourceMap) | 139 if (!sourceMap) |
137 return; | 140 return; |
138 | 141 |
139 if (this._scriptForSourceMap.get(sourceMap)) { | 142 if (this._scriptForSourceMap.get(sourceMap)) { |
140 this._sourceMapForScriptId[script.scriptId] = sourceMap; | 143 this._sourceMapForScriptId[script.scriptId] = sourceMap; |
141 script.updateLocations(); | 144 this._debuggerWorkspaceBinding.updateLocations(script); |
142 return; | 145 return; |
143 } | 146 } |
144 | 147 |
145 this._sourceMapForScriptId[script.scriptId] = sourceMap; | 148 this._sourceMapForScriptId[script.scriptId] = sourceMap; |
146 this._scriptForSourceMap.put(sourceMap, script); | 149 this._scriptForSourceMap.put(sourceMap, script); |
147 | 150 |
148 var sourceURLs = sourceMap.sources(); | 151 var sourceURLs = sourceMap.sources(); |
149 for (var i = 0; i < sourceURLs.length; ++i) { | 152 for (var i = 0; i < sourceURLs.length; ++i) { |
150 var sourceURL = sourceURLs[i]; | 153 var sourceURL = sourceURLs[i]; |
151 if (this._sourceMapForURL.get(sourceURL)) | 154 if (this._sourceMapForURL.get(sourceURL)) |
152 continue; | 155 continue; |
153 this._sourceMapForURL.put(sourceURL, sourceMap); | 156 this._sourceMapForURL.put(sourceURL, sourceMap); |
154 if (!this._workspace.hasMappingForURL(sourceURL) && !this._works
pace.uiSourceCodeForURL(sourceURL)) { | 157 if (!this._workspace.hasMappingForURL(sourceURL) && !this._works
pace.uiSourceCodeForURL(sourceURL)) { |
155 var contentProvider = sourceMap.sourceContentProvider(source
URL, WebInspector.resourceTypes.Script); | 158 var contentProvider = sourceMap.sourceContentProvider(source
URL, WebInspector.resourceTypes.Script); |
156 this._networkWorkspaceBinding.addFileForURL(sourceURL, conte
ntProvider, script.isContentScript()); | 159 this._networkWorkspaceBinding.addFileForURL(sourceURL, conte
ntProvider, script.isContentScript()); |
157 } | 160 } |
158 var uiSourceCode = this._workspace.uiSourceCodeForURL(sourceURL)
; | 161 var uiSourceCode = this._workspace.uiSourceCodeForURL(sourceURL)
; |
159 if (uiSourceCode) | 162 if (uiSourceCode) |
160 this._bindUISourceCode(uiSourceCode); | 163 this._bindUISourceCode(uiSourceCode); |
161 else | 164 else |
162 WebInspector.console.error(WebInspector.UIString("Failed to
locate workspace file mapped to URL %s from source map %s", sourceURL, sourceMap
.url())); | 165 WebInspector.console.error(WebInspector.UIString("Failed to
locate workspace file mapped to URL %s from source map %s", sourceURL, sourceMap
.url())); |
163 } | 166 } |
164 script.updateLocations(); | 167 this._debuggerWorkspaceBinding.updateLocations(script); |
165 } | 168 } |
166 }, | 169 }, |
167 | 170 |
168 /** | 171 /** |
169 * @return {boolean} | 172 * @return {boolean} |
170 */ | 173 */ |
171 isIdentity: function() | 174 isIdentity: function() |
172 { | 175 { |
173 return false; | 176 return false; |
174 }, | 177 }, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 this._sourceMapForScriptId = {}; | 297 this._sourceMapForScriptId = {}; |
295 this._scriptForSourceMap.clear(); | 298 this._scriptForSourceMap.clear(); |
296 this._sourceMapForURL.clear(); | 299 this._sourceMapForURL.clear(); |
297 }, | 300 }, |
298 | 301 |
299 dispose: function() | 302 dispose: function() |
300 { | 303 { |
301 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour
ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); | 304 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour
ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); |
302 } | 305 } |
303 } | 306 } |
OLD | NEW |