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

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

Issue 2573323002: Revert of [DevTools] Remove methods on Common.Event. (Closed)
Patch Set: Created 4 years 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 {Bindings.DebuggerSourceMapping} 5 * @implements {Bindings.DebuggerSourceMapping}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 Sources.FormatterScriptMapping = class { 8 Sources.FormatterScriptMapping = class {
9 /** 9 /**
10 * @param {!SDK.DebuggerModel} debuggerModel 10 * @param {!SDK.DebuggerModel} debuggerModel
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 */ 187 */
188 button(sourcesView) { 188 button(sourcesView) {
189 if (this._button) 189 if (this._button)
190 return this._button; 190 return this._button;
191 191
192 this._sourcesView = sourcesView; 192 this._sourcesView = sourcesView;
193 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorSelected , this._editorSelected.bind(this)); 193 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorSelected , this._editorSelected.bind(this));
194 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorClosed, this._editorClosed.bind(this)); 194 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorClosed, this._editorClosed.bind(this));
195 195
196 this._button = new UI.ToolbarButton(Common.UIString('Pretty print'), 'largei con-pretty-print'); 196 this._button = new UI.ToolbarButton(Common.UIString('Pretty print'), 'largei con-pretty-print');
197 this._button.addEventListener(UI.ToolbarButton.Events.Click, this._toggleFor matScriptSource, this); 197 this._button.addEventListener('click', this._toggleFormatScriptSource, this) ;
198 this._updateButton(sourcesView.currentUISourceCode()); 198 this._updateButton(sourcesView.currentUISourceCode());
199 199
200 return this._button; 200 return this._button;
201 } 201 }
202 202
203 /** 203 /**
204 * @param {?Workspace.UISourceCode} uiSourceCode 204 * @param {?Workspace.UISourceCode} uiSourceCode
205 * @return {boolean} 205 * @return {boolean}
206 */ 206 */
207 _isFormatableScript(uiSourceCode) { 207 _isFormatableScript(uiSourceCode) {
208 if (!uiSourceCode) 208 if (!uiSourceCode)
209 return false; 209 return false;
210 if (uiSourceCode.project().canSetFileContent()) 210 if (uiSourceCode.project().canSetFileContent())
211 return false; 211 return false;
212 if (uiSourceCode.project().type() === Workspace.projectTypes.Formatter) 212 if (uiSourceCode.project().type() === Workspace.projectTypes.Formatter)
213 return false; 213 return false;
214 if (Persistence.persistence.binding(uiSourceCode)) 214 if (Persistence.persistence.binding(uiSourceCode))
215 return false; 215 return false;
216 return uiSourceCode.contentType().hasScripts(); 216 return uiSourceCode.contentType().hasScripts();
217 } 217 }
218 218
219 /** 219 _toggleFormatScriptSource() {
220 * @param {!Common.Event} event
221 */
222 _toggleFormatScriptSource(event) {
223 var uiSourceCode = this._sourcesView.currentUISourceCode(); 220 var uiSourceCode = this._sourcesView.currentUISourceCode();
224 if (this._isFormatableScript(uiSourceCode)) 221 if (this._isFormatableScript(uiSourceCode))
225 this._formatUISourceCodeScript(uiSourceCode); 222 this._formatUISourceCodeScript(uiSourceCode);
226 } 223 }
227 224
228 /** 225 /**
229 * @param {!Workspace.UISourceCode} uiSourceCode 226 * @param {!Workspace.UISourceCode} uiSourceCode
230 * @param {!Workspace.UISourceCode} formattedUISourceCode 227 * @param {!Workspace.UISourceCode} formattedUISourceCode
231 * @param {!Sources.FormatterSourceMapping} mapping 228 * @param {!Sources.FormatterSourceMapping} mapping
232 * @private 229 * @private
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 var targets = SDK.targetManager.targets(); 378 var targets = SDK.targetManager.targets();
382 for (var i = 0; i < targets.length; ++i) { 379 for (var i = 0; i < targets.length; ++i) {
383 var scriptMapping = 380 var scriptMapping =
384 /** @type {!Sources.FormatterScriptMapping} */ (this._scriptMappingB yTarget.get(targets[i])); 381 /** @type {!Sources.FormatterScriptMapping} */ (this._scriptMappingB yTarget.get(targets[i]));
385 Bindings.debuggerWorkspaceBinding.setSourceMapping(targets[i], formatted UISourceCode, scriptMapping); 382 Bindings.debuggerWorkspaceBinding.setSourceMapping(targets[i], formatted UISourceCode, scriptMapping);
386 } 383 }
387 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMapping); 384 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMapping);
388 } 385 }
389 } 386 }
390 }; 387 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698