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

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

Issue 2889013002: DevTools: introduce uiSourceCode.mimeType() method (Closed)
Patch Set: address comments 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 if (uiSourceCode.isDirty()) 75 if (uiSourceCode.isDirty())
76 contentLoaded.call(this, uiSourceCode.workingCopy()); 76 contentLoaded.call(this, uiSourceCode.workingCopy());
77 else 77 else
78 uiSourceCode.requestContent().then(contentLoaded.bind(this)); 78 uiSourceCode.requestContent().then(contentLoaded.bind(this));
79 79
80 /** 80 /**
81 * @this {Sources.InplaceFormatterEditorAction} 81 * @this {Sources.InplaceFormatterEditorAction}
82 * @param {?string} content 82 * @param {?string} content
83 */ 83 */
84 function contentLoaded(content) { 84 function contentLoaded(content) {
85 var highlighterType = Bindings.NetworkProject.uiSourceCodeMimeType(uiSourc eCode); 85 var highlighterType = uiSourceCode.mimeType();
86 Sources.Formatter.format(uiSourceCode.contentType(), highlighterType, cont ent || '', innerCallback.bind(this)); 86 Sources.Formatter.format(uiSourceCode.contentType(), highlighterType, cont ent || '', innerCallback.bind(this));
87 } 87 }
88 88
89 /** 89 /**
90 * @this {Sources.InplaceFormatterEditorAction} 90 * @this {Sources.InplaceFormatterEditorAction}
91 * @param {string} formattedContent 91 * @param {string} formattedContent
92 * @param {!Sources.FormatterSourceMapping} formatterMapping 92 * @param {!Sources.FormatterSourceMapping} formatterMapping
93 */ 93 */
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 104
105 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]); 105 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]);
106 } 106 }
107 } 107 }
108 }; 108 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698