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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.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 {Sources.SourcesView.EditorAction} 5 * @implements {Sources.SourcesView.EditorAction}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 Sources.InplaceFormatterEditorAction = class { 8 Sources.InplaceFormatterEditorAction = class {
9 /** 9 /**
10 * @param {!Common.Event} event 10 * @param {!Common.Event} event
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 function innerCallback(formattedContent, formatterMapping) { 93 function innerCallback(formattedContent, formatterMapping) {
94 if (uiSourceCode.workingCopy() === formattedContent) 94 if (uiSourceCode.workingCopy() === formattedContent)
95 return; 95 return;
96 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode); 96 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode);
97 var start = [0, 0]; 97 var start = [0, 0];
98 if (sourceFrame) { 98 if (sourceFrame) {
99 var selection = sourceFrame.selection(); 99 var selection = sourceFrame.selection();
100 start = formatterMapping.originalToFormatted(selection.startLine, select ion.startColumn); 100 start = formatterMapping.originalToFormatted(selection.startLine, select ion.startColumn);
101 } 101 }
102 uiSourceCode.setWorkingCopy(formattedContent); 102 uiSourceCode.setWorkingCopy(formattedContent);
103 this._formatDecorations(uiSourceCode, formatterMapping);
104
103 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]); 105 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]);
104 } 106 }
105 } 107 }
108
109 /**
110 * @param {!Workspace.UISourceCode} uiSourceCode
111 * @param {!Sources.FormatterSourceMapping} sourceMapping
112 */
113 _formatDecorations(uiSourceCode, sourceMapping) {
114 var oldDecorations = new Map(uiSourceCode.getAllDecorations());
115 uiSourceCode.removeAllDecorations();
116
117 if (!oldDecorations.size)
118 return;
119
120 for (var decorationList of oldDecorations.entries()) {
121 var type = decorationList[0];
122 var list = decorationList[1];
123 if (!list.size)
caseq 2016/11/15 22:07:05 drop the check?
124 continue;
125
126 for (var decoration of list.entries()) {
127 var range = decoration[0];
128 var data = decoration[1];
129 var newRange = range;
caseq 2016/11/15 22:07:05 This is rather confusing, we've not got one object
130
131 [newRange.startLine, newRange.startColumn] = sourceMapping.originalToFor matted(
132 range. startLine, range.startColumn);
133
134 [newRange.endLine, newRange.endColumn] = sourceMapping.originalToFormatt ed(
135 range. endLine, range.endColumn);
136
137 uiSourceCode.addDecoration(newRange, /** @type {string} */ (type), data) ;
138 }
139 }
140 }
106 }; 141 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698