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.SourcesPanel.EditorAction} | 8 * @implements {WebInspector.SourcesPanel.EditorAction} |
9 */ | 9 */ |
10 WebInspector.InplaceFormatterEditorAction = function() | 10 WebInspector.InplaceFormatterEditorAction = function() |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 | 59 |
60 return this._button.element; | 60 return this._button.element; |
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 return !!uiSourceCode && uiSourceCode.contentType() === WebInspector.res ourceTypes.Stylesheet; | 69 if (!uiSourceCode) |
70 return false; | |
71 return uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesh eet || | |
72 uiSourceCode.project().type() === WebInspector.projectTypes.Snip pets; | |
pfeldman
2014/03/03 14:44:55
weird indent.
| |
70 }, | 73 }, |
71 | 74 |
72 _formatSourceInPlace: function() | 75 _formatSourceInPlace: function() |
73 { | 76 { |
74 var uiSourceCode = this._panel.selectedUISourceCode(); | 77 var uiSourceCode = this._panel.selectedUISourceCode(); |
75 if (!this._isFormattable(uiSourceCode)) | 78 if (!this._isFormattable(uiSourceCode)) |
76 return; | 79 return; |
77 | 80 |
78 if (uiSourceCode.isDirty()) | 81 if (uiSourceCode.isDirty()) |
79 contentLoaded.call(this, uiSourceCode.workingCopy()); | 82 contentLoaded.call(this, uiSourceCode.workingCopy()); |
(...skipping 23 matching lines...) Expand all Loading... | |
103 var start = [0, 0]; | 106 var start = [0, 0]; |
104 if (sourceFrame) { | 107 if (sourceFrame) { |
105 var selection = sourceFrame.selection(); | 108 var selection = sourceFrame.selection(); |
106 start = formatterMapping.originalToFormatted(selection.startLine , selection.startColumn); | 109 start = formatterMapping.originalToFormatted(selection.startLine , selection.startColumn); |
107 } | 110 } |
108 uiSourceCode.setWorkingCopy(formattedContent); | 111 uiSourceCode.setWorkingCopy(formattedContent); |
109 this._panel.showUISourceCode(uiSourceCode, start[0], start[1]); | 112 this._panel.showUISourceCode(uiSourceCode, start[0], start[1]); |
110 } | 113 } |
111 }, | 114 }, |
112 } | 115 } |
OLD | NEW |