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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatterEditorAction.js

Issue 2492343002: Devtools: Pretty print fix for CSS coverage decorations. (Closed)
Patch Set: Pretty print fix for CSS coverage decorations. 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * @implements {Bindings.DebuggerSourceMapping} 5 * @implements {Bindings.DebuggerSourceMapping}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 Sources.FormatterScriptMapping = class { 8 Sources.FormatterScriptMapping = class {
9 /** 9 /**
10 * @param {!SDK.DebuggerModel} debuggerModel 10 * @param {!SDK.DebuggerModel} debuggerModel
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 }; 78 };
79 79
80 /** 80 /**
81 * @unrestricted 81 * @unrestricted
82 */ 82 */
83 Sources.FormatterScriptMapping.FormatData = class { 83 Sources.FormatterScriptMapping.FormatData = class {
84 /** 84 /**
85 * @param {string} projectId 85 * @param {string} projectId
86 * @param {string} path 86 * @param {string} path
87 * @param {!Sources.FormatterSourceMapping} mapping 87 * @param {!Workspace.UISourceCode.SourceMapping} mapping
88 * @param {!Array.<!SDK.Script>} scripts 88 * @param {!Array.<!SDK.Script>} scripts
89 */ 89 */
90 constructor(projectId, path, mapping, scripts) { 90 constructor(projectId, path, mapping, scripts) {
91 this.projectId = projectId; 91 this.projectId = projectId;
92 this.path = path; 92 this.path = path;
93 this.mapping = mapping; 93 this.mapping = mapping;
94 this.scripts = scripts; 94 this.scripts = scripts;
95 } 95 }
96 }; 96 };
97 97
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 _toggleFormatScriptSource() { 219 _toggleFormatScriptSource() {
220 var uiSourceCode = this._sourcesView.currentUISourceCode(); 220 var uiSourceCode = this._sourcesView.currentUISourceCode();
221 if (this._isFormatableScript(uiSourceCode)) 221 if (this._isFormatableScript(uiSourceCode))
222 this._formatUISourceCodeScript(uiSourceCode); 222 this._formatUISourceCodeScript(uiSourceCode);
223 } 223 }
224 224
225 /** 225 /**
226 * @param {!Workspace.UISourceCode} uiSourceCode 226 * @param {!Workspace.UISourceCode} uiSourceCode
227 * @param {!Workspace.UISourceCode} formattedUISourceCode 227 * @param {!Workspace.UISourceCode} formattedUISourceCode
228 * @param {!Sources.FormatterSourceMapping} mapping 228 * @param {!Workspace.UISourceCode.SourceMapping} mapping
229 * @private 229 * @private
230 */ 230 */
231 _showIfNeeded(uiSourceCode, formattedUISourceCode, mapping) { 231 _showIfNeeded(uiSourceCode, formattedUISourceCode, mapping) {
232 if (uiSourceCode !== this._sourcesView.currentUISourceCode()) 232 if (uiSourceCode !== this._sourcesView.currentUISourceCode())
233 return; 233 return;
234 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode); 234 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode);
235 var start = [0, 0]; 235 var start = [0, 0];
236 if (sourceFrame) { 236 if (sourceFrame) {
237 var selection = sourceFrame.selection(); 237 var selection = sourceFrame.selection();
238 start = mapping.originalToFormatted(selection.startLine, selection.startCo lumn); 238 start = mapping.originalToFormatted(selection.startLine, selection.startCo lumn);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 */ 346 */
347 function contentLoaded(content) { 347 function contentLoaded(content) {
348 var highlighterType = Bindings.NetworkProject.uiSourceCodeMimeType(uiSourc eCode); 348 var highlighterType = Bindings.NetworkProject.uiSourceCodeMimeType(uiSourc eCode);
349 Sources.Formatter.format( 349 Sources.Formatter.format(
350 uiSourceCode.contentType(), highlighterType, content || '', innerCallb ack.bind(this)); 350 uiSourceCode.contentType(), highlighterType, content || '', innerCallb ack.bind(this));
351 } 351 }
352 352
353 /** 353 /**
354 * @this {Sources.ScriptFormatterEditorAction} 354 * @this {Sources.ScriptFormatterEditorAction}
355 * @param {string} formattedContent 355 * @param {string} formattedContent
356 * @param {!Sources.FormatterSourceMapping} formatterMapping 356 * @param {!Workspace.UISourceCode.SourceMapping} formatterMapping
357 */ 357 */
358 function innerCallback(formattedContent, formatterMapping) { 358 function innerCallback(formattedContent, formatterMapping) {
359 var scripts = this._scriptsForUISourceCode(uiSourceCode); 359 var scripts = this._scriptsForUISourceCode(uiSourceCode);
360 var formattedURL = uiSourceCode.url() + ':formatted'; 360 var formattedURL = uiSourceCode.url() + ':formatted';
361 var contentProvider = 361 var contentProvider =
362 Common.StaticContentProvider.fromString(formattedURL, uiSourceCode.con tentType(), formattedContent); 362 Common.StaticContentProvider.fromString(formattedURL, uiSourceCode.con tentType(), formattedContent);
363 var formattedUISourceCode = this._project.addContentProvider(formattedURL, contentProvider); 363 var formattedUISourceCode = this._project.addContentProvider(formattedURL, contentProvider);
364 var formattedPath = formattedUISourceCode.url(); 364 var formattedPath = formattedUISourceCode.url();
365 var formatData = new Sources.FormatterScriptMapping.FormatData( 365 var formatData = new Sources.FormatterScriptMapping.FormatData(
366 uiSourceCode.project().id(), uiSourceCode.url(), formatterMapping, scr ipts); 366 uiSourceCode.project().id(), uiSourceCode.url(), formatterMapping, scr ipts);
(...skipping 11 matching lines...) Expand all
378 var targets = SDK.targetManager.targets(); 378 var targets = SDK.targetManager.targets();
379 for (var i = 0; i < targets.length; ++i) { 379 for (var i = 0; i < targets.length; ++i) {
380 var scriptMapping = 380 var scriptMapping =
381 /** @type {!Sources.FormatterScriptMapping} */ (this._scriptMappingB yTarget.get(targets[i])); 381 /** @type {!Sources.FormatterScriptMapping} */ (this._scriptMappingB yTarget.get(targets[i]));
382 Bindings.debuggerWorkspaceBinding.setSourceMapping(targets[i], formatted UISourceCode, scriptMapping); 382 Bindings.debuggerWorkspaceBinding.setSourceMapping(targets[i], formatted UISourceCode, scriptMapping);
383 } 383 }
384 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMapping); 384 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMapping);
385 } 385 }
386 } 386 }
387 }; 387 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698