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

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

Issue 2865573003: DevTools: support live coverage (Closed)
Patch Set: minor polish on corner cases Created 3 years, 7 months 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 function innerCallback(formattedContent, formatterMapping) { 94 function innerCallback(formattedContent, formatterMapping) {
95 if (uiSourceCode.workingCopy() === formattedContent) 95 if (uiSourceCode.workingCopy() === formattedContent)
96 return; 96 return;
97 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode); 97 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode);
98 var start = [0, 0]; 98 var start = [0, 0];
99 if (sourceFrame) { 99 if (sourceFrame) {
100 var selection = sourceFrame.selection(); 100 var selection = sourceFrame.selection();
101 start = formatterMapping.originalToFormatted(selection.startLine, select ion.startColumn); 101 start = formatterMapping.originalToFormatted(selection.startLine, select ion.startColumn);
102 } 102 }
103 uiSourceCode.setWorkingCopy(formattedContent); 103 uiSourceCode.setWorkingCopy(formattedContent);
104 this._formatDecorations(uiSourceCode, formatterMapping);
105 104
106 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]); 105 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]);
107 } 106 }
108 } 107 }
109
110 /**
111 * @param {!Workspace.UISourceCode} uiSourceCode
112 * @param {!Sources.FormatterSourceMapping} sourceMapping
113 */
114 _formatDecorations(uiSourceCode, sourceMapping) {
115 var decorations = uiSourceCode.allDecorations();
116 if (!decorations.length)
117 return;
118
119 uiSourceCode.removeAllDecorations();
120
121 for (var decoration of decorations) {
122 var range = decoration.range();
123 var startLocation = sourceMapping.originalToFormatted(range.startLine, ran ge.startColumn);
124 var endLocation = sourceMapping.originalToFormatted(range.endLine, range.e ndColumn);
125
126 uiSourceCode.addDecoration(
127 new TextUtils.TextRange(startLocation[0], startLocation[1], endLocatio n[0], endLocation[1]),
128 /** @type {string} */ (decoration.type()), decoration.data());
129 }
130 }
131 }; 108 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698