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 {!Sources.FormatterSourceMapping} mapping | 9 * @param {!Sources.FormatterSourceMapping} mapping |
10 */ | 10 */ |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 var styleHeader = rawLocation.header(); | 250 var styleHeader = rawLocation.header(); |
251 var formatData = styleHeader && Sources.SourceFormatData._for(styleHeader); | 251 var formatData = styleHeader && Sources.SourceFormatData._for(styleHeader); |
252 if (!formatData) | 252 if (!formatData) |
253 return null; | 253 return null; |
254 var formattedLocation = | 254 var formattedLocation = |
255 formatData.mapping.originalToFormatted(rawLocation.lineNumber, rawLocati
on.columnNumber || 0); | 255 formatData.mapping.originalToFormatted(rawLocation.lineNumber, rawLocati
on.columnNumber || 0); |
256 return formatData.formattedSourceCode.uiLocation(formattedLocation[0], forma
ttedLocation[1]); | 256 return formatData.formattedSourceCode.uiLocation(formattedLocation[0], forma
ttedLocation[1]); |
257 } | 257 } |
258 | 258 |
259 /** | 259 /** |
| 260 * @override |
| 261 * @param {!Workspace.UILocation} uiLocation |
| 262 * @return {!Array<!SDK.CSSLocation>} |
| 263 */ |
| 264 uiLocationToRawLocations(uiLocation) { |
| 265 var formatData = Sources.SourceFormatData._for(uiLocation.uiSourceCode); |
| 266 if (!formatData) |
| 267 return []; |
| 268 var originalLocation = formatData.mapping.formattedToOriginal(uiLocation.lin
eNumber, uiLocation.columnNumber); |
| 269 var header = Bindings.NetworkProject.styleHeaderForUISourceCode(formatData.o
riginalSourceCode); |
| 270 if (!header) |
| 271 return []; |
| 272 return [new SDK.CSSLocation(header, originalLocation[0], originalLocation[1]
)]; |
| 273 } |
| 274 |
| 275 /** |
260 * @param {!Sources.SourceFormatData} formatData | 276 * @param {!Sources.SourceFormatData} formatData |
261 * @param {boolean} enable | 277 * @param {boolean} enable |
262 */ | 278 */ |
263 _setSourceMappingEnabled(formatData, enable) { | 279 _setSourceMappingEnabled(formatData, enable) { |
264 var original = formatData.originalSourceCode; | 280 var original = formatData.originalSourceCode; |
265 var styleHeader = Bindings.NetworkProject.styleHeaderForUISourceCode(origina
l); | 281 var styleHeader = Bindings.NetworkProject.styleHeaderForUISourceCode(origina
l); |
266 if (!styleHeader) | 282 if (!styleHeader) |
267 return; | 283 return; |
268 if (enable) | 284 if (enable) |
269 styleHeader[Sources.SourceFormatData._formatDataSymbol] = formatData; | 285 styleHeader[Sources.SourceFormatData._formatDataSymbol] = formatData; |
270 else | 286 else |
271 delete styleHeader[Sources.SourceFormatData._formatDataSymbol]; | 287 delete styleHeader[Sources.SourceFormatData._formatDataSymbol]; |
272 Bindings.cssWorkspaceBinding.updateLocations(styleHeader); | 288 Bindings.cssWorkspaceBinding.updateLocations(styleHeader); |
273 } | 289 } |
274 }; | 290 }; |
275 | 291 |
276 Sources.sourceFormatter = new Sources.SourceFormatter(); | 292 Sources.sourceFormatter = new Sources.SourceFormatter(); |
OLD | NEW |