| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 Sources.SourceFormatData = class { | 5 Sources.SourceFormatData = class { |
| 6 /** | 6 /** |
| 7 * @param {!Workspace.UISourceCode} originalSourceCode | 7 * @param {!Workspace.UISourceCode} originalSourceCode |
| 8 * @param {!Workspace.UISourceCode} formattedSourceCode | 8 * @param {!Workspace.UISourceCode} formattedSourceCode |
| 9 * @param {!Formatter.FormatterSourceMapping} mapping | 9 * @param {!Formatter.FormatterSourceMapping} mapping |
| 10 */ | 10 */ |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 fulfillFormatPromise(formatData); | 145 fulfillFormatPromise(formatData); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * @implements {Bindings.DebuggerSourceMapping} | 151 * @implements {Bindings.DebuggerSourceMapping} |
| 152 */ | 152 */ |
| 153 Sources.SourceFormatter.ScriptMapping = class { | 153 Sources.SourceFormatter.ScriptMapping = class { |
| 154 constructor() { |
| 155 Bindings.debuggerWorkspaceBinding.addSourceMapping(this); |
| 156 } |
| 157 |
| 154 /** | 158 /** |
| 155 * @override | 159 * @override |
| 156 * @param {!SDK.DebuggerModel.Location} rawLocation | 160 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 157 * @return {?Workspace.UILocation} | 161 * @return {?Workspace.UILocation} |
| 158 */ | 162 */ |
| 159 rawLocationToUILocation(rawLocation) { | 163 rawLocationToUILocation(rawLocation) { |
| 160 var script = rawLocation.script(); | 164 var script = rawLocation.script(); |
| 161 var formatData = script && Sources.SourceFormatData._for(script); | 165 var formatData = script && Sources.SourceFormatData._for(script); |
| 162 if (!formatData) | 166 if (!formatData) |
| 163 return null; | 167 return null; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 179 if (!formatData) | 183 if (!formatData) |
| 180 return null; | 184 return null; |
| 181 var originalLocation = formatData.mapping.formattedToOriginal(lineNumber, co
lumnNumber); | 185 var originalLocation = formatData.mapping.formattedToOriginal(lineNumber, co
lumnNumber); |
| 182 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode); | 186 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode); |
| 183 if (!scripts.length) | 187 if (!scripts.length) |
| 184 return null; | 188 return null; |
| 185 return scripts[0].debuggerModel.createRawLocation(scripts[0], originalLocati
on[0], originalLocation[1]); | 189 return scripts[0].debuggerModel.createRawLocation(scripts[0], originalLocati
on[0], originalLocation[1]); |
| 186 } | 190 } |
| 187 | 191 |
| 188 /** | 192 /** |
| 189 * @override | |
| 190 * @return {boolean} | |
| 191 */ | |
| 192 isIdentity() { | |
| 193 return false; | |
| 194 } | |
| 195 | |
| 196 /** | |
| 197 * @override | |
| 198 * @param {!Workspace.UISourceCode} uiSourceCode | |
| 199 * @param {number} lineNumber | |
| 200 * @return {boolean} | |
| 201 */ | |
| 202 uiLineHasMapping(uiSourceCode, lineNumber) { | |
| 203 return true; | |
| 204 } | |
| 205 | |
| 206 /** | |
| 207 * @param {!Sources.SourceFormatData} formatData | 193 * @param {!Sources.SourceFormatData} formatData |
| 208 * @param {boolean} enabled | 194 * @param {boolean} enabled |
| 209 */ | 195 */ |
| 210 _setSourceMappingEnabled(formatData, enabled) { | 196 _setSourceMappingEnabled(formatData, enabled) { |
| 211 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode); | 197 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode); |
| 212 if (!scripts.length) | 198 if (!scripts.length) |
| 213 return; | 199 return; |
| 214 if (enabled) { | 200 if (enabled) { |
| 215 for (var script of scripts) { | 201 for (var script of scripts) |
| 216 script[Sources.SourceFormatData._formatDataSymbol] = formatData; | 202 script[Sources.SourceFormatData._formatDataSymbol] = formatData; |
| 217 Bindings.debuggerWorkspaceBinding.pushSourceMapping(script, this); | |
| 218 } | |
| 219 } else { | 203 } else { |
| 220 for (var script of scripts) { | 204 for (var script of scripts) |
| 221 delete script[Sources.SourceFormatData._formatDataSymbol]; | 205 delete script[Sources.SourceFormatData._formatDataSymbol]; |
| 222 Bindings.debuggerWorkspaceBinding.popSourceMapping(script); | |
| 223 } | |
| 224 } | 206 } |
| 225 | 207 for (var script of scripts) |
| 226 Bindings.debuggerWorkspaceBinding.setSourceMapping( | 208 Bindings.debuggerWorkspaceBinding.updateLocations(script); |
| 227 scripts[0].debuggerModel, formatData.formattedSourceCode, enabled ? this
: null); | |
| 228 } | 209 } |
| 229 | 210 |
| 230 /** | 211 /** |
| 231 * @param {!Workspace.UISourceCode} uiSourceCode | 212 * @param {!Workspace.UISourceCode} uiSourceCode |
| 232 * @return {!Array<!SDK.Script>} | 213 * @return {!Array<!SDK.Script>} |
| 233 */ | 214 */ |
| 234 _scriptsForUISourceCode(uiSourceCode) { | 215 _scriptsForUISourceCode(uiSourceCode) { |
| 235 if (uiSourceCode.contentType() === Common.resourceTypes.Document) { | 216 if (uiSourceCode.contentType() === Common.resourceTypes.Document) { |
| 236 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 217 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 237 var debuggerModel = target && target.model(SDK.DebuggerModel); | 218 var debuggerModel = target && target.model(SDK.DebuggerModel); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 headers.forEach(header => header[Sources.SourceFormatData._formatDataSymbo
l] = formatData); | 284 headers.forEach(header => header[Sources.SourceFormatData._formatDataSymbo
l] = formatData); |
| 304 } else { | 285 } else { |
| 305 original[this._headersSymbol] = null; | 286 original[this._headersSymbol] = null; |
| 306 headers.forEach(header => delete header[Sources.SourceFormatData._formatDa
taSymbol]); | 287 headers.forEach(header => delete header[Sources.SourceFormatData._formatDa
taSymbol]); |
| 307 } | 288 } |
| 308 headers.forEach(header => Bindings.cssWorkspaceBinding.updateLocations(heade
r)); | 289 headers.forEach(header => Bindings.cssWorkspaceBinding.updateLocations(heade
r)); |
| 309 } | 290 } |
| 310 }; | 291 }; |
| 311 | 292 |
| 312 Sources.sourceFormatter = new Sources.SourceFormatter(); | 293 Sources.sourceFormatter = new Sources.SourceFormatter(); |
| OLD | NEW |