OLD | NEW |
1 | 1 |
2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 /** | 6 /** |
7 * @constructor | 7 * @constructor |
8 * @implements {WebInspector.SourcesView.EditorAction} | 8 * @implements {WebInspector.SourcesView.EditorAction} |
9 */ | 9 */ |
10 WebInspector.InplaceFormatterEditorAction = function() | 10 WebInspector.InplaceFormatterEditorAction = function() |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 }, | 61 }, |
62 | 62 |
63 /** | 63 /** |
64 * @param {?WebInspector.UISourceCode} uiSourceCode | 64 * @param {?WebInspector.UISourceCode} uiSourceCode |
65 * @return {boolean} | 65 * @return {boolean} |
66 */ | 66 */ |
67 _isFormattable: function(uiSourceCode) | 67 _isFormattable: function(uiSourceCode) |
68 { | 68 { |
69 if (!uiSourceCode) | 69 if (!uiSourceCode) |
70 return false; | 70 return false; |
| 71 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) |
| 72 return true; |
71 return uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesh
eet | 73 return uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesh
eet |
72 || uiSourceCode.project().type() === WebInspector.projectTypes.Snipp
ets; | 74 || uiSourceCode.project().type() === WebInspector.projectTypes.Snipp
ets; |
73 }, | 75 }, |
74 | 76 |
75 _formatSourceInPlace: function() | 77 _formatSourceInPlace: function() |
76 { | 78 { |
77 var uiSourceCode = this._sourcesView.currentUISourceCode(); | 79 var uiSourceCode = this._sourcesView.currentUISourceCode(); |
78 if (!this._isFormattable(uiSourceCode)) | 80 if (!this._isFormattable(uiSourceCode)) |
79 return; | 81 return; |
80 | 82 |
(...skipping 26 matching lines...) Expand all Loading... |
107 var start = [0, 0]; | 109 var start = [0, 0]; |
108 if (sourceFrame) { | 110 if (sourceFrame) { |
109 var selection = sourceFrame.selection(); | 111 var selection = sourceFrame.selection(); |
110 start = formatterMapping.originalToFormatted(selection.startLine
, selection.startColumn); | 112 start = formatterMapping.originalToFormatted(selection.startLine
, selection.startColumn); |
111 } | 113 } |
112 uiSourceCode.setWorkingCopy(formattedContent); | 114 uiSourceCode.setWorkingCopy(formattedContent); |
113 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1
]); | 115 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1
]); |
114 } | 116 } |
115 }, | 117 }, |
116 } | 118 } |
OLD | NEW |