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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/ActionRegistry.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/ActionRegistry.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/ActionRegistry.js b/third_party/WebKit/Source/devtools/front_end/ui/ActionRegistry.js
index a3e270b9dbf849629f41918ba0be399677c665b5..b37cff6e91760972af11451a9e23364a2e7849ac 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/ActionRegistry.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/ActionRegistry.js
@@ -1,224 +1,201 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
/**
- * @constructor
+ * @unrestricted
*/
-WebInspector.ActionRegistry = function()
-{
+WebInspector.ActionRegistry = class {
+ constructor() {
/** @type {!Map.<string, !WebInspector.Action>} */
this._actionsById = new Map();
this._registerActions();
-};
-
-WebInspector.ActionRegistry.prototype = {
- _registerActions: function()
- {
- self.runtime.extensions(WebInspector.ActionDelegate).forEach(registerExtension, this);
-
- /**
- * @param {!Runtime.Extension} extension
- * @this {WebInspector.ActionRegistry}
- */
- function registerExtension(extension)
- {
- var actionId = extension.descriptor()["actionId"];
- console.assert(actionId);
- console.assert(!this._actionsById.get(actionId));
- this._actionsById.set(actionId, new WebInspector.Action(extension));
- }
- },
+ }
- /**
- * @return {!Array.<!WebInspector.Action>}
- */
- availableActions: function()
- {
- return this.applicableActions(this._actionsById.keysArray(), WebInspector.context);
- },
+ _registerActions() {
+ self.runtime.extensions(WebInspector.ActionDelegate).forEach(registerExtension, this);
/**
- * @param {!Array.<string>} actionIds
- * @param {!WebInspector.Context} context
- * @return {!Array.<!WebInspector.Action>}
+ * @param {!Runtime.Extension} extension
+ * @this {WebInspector.ActionRegistry}
*/
- applicableActions: function(actionIds, context)
- {
- var extensions = [];
- actionIds.forEach(function(actionId) {
- var action = this._actionsById.get(actionId);
- if (action)
- extensions.push(action._extension);
- }, this);
- return context.applicableExtensions(extensions).valuesArray().map(extensionToAction.bind(this));
-
- /**
- * @param {!Runtime.Extension} extension
- * @return {!WebInspector.Action}
- * @this {WebInspector.ActionRegistry}
- */
- function extensionToAction(extension)
- {
- return /** @type {!WebInspector.Action} */(this.action(extension.descriptor()["actionId"]));
- }
- },
+ function registerExtension(extension) {
+ var actionId = extension.descriptor()['actionId'];
+ console.assert(actionId);
+ console.assert(!this._actionsById.get(actionId));
+ this._actionsById.set(actionId, new WebInspector.Action(extension));
+ }
+ }
+
+ /**
+ * @return {!Array.<!WebInspector.Action>}
+ */
+ availableActions() {
+ return this.applicableActions(this._actionsById.keysArray(), WebInspector.context);
+ }
+
+ /**
+ * @param {!Array.<string>} actionIds
+ * @param {!WebInspector.Context} context
+ * @return {!Array.<!WebInspector.Action>}
+ */
+ applicableActions(actionIds, context) {
+ var extensions = [];
+ actionIds.forEach(function(actionId) {
+ var action = this._actionsById.get(actionId);
+ if (action)
+ extensions.push(action._extension);
+ }, this);
+ return context.applicableExtensions(extensions).valuesArray().map(extensionToAction.bind(this));
/**
- * @param {string} actionId
- * @return {?WebInspector.Action}
+ * @param {!Runtime.Extension} extension
+ * @return {!WebInspector.Action}
+ * @this {WebInspector.ActionRegistry}
*/
- action: function(actionId)
- {
- return this._actionsById.get(actionId) || null;
+ function extensionToAction(extension) {
+ return /** @type {!WebInspector.Action} */ (this.action(extension.descriptor()['actionId']));
}
+ }
+
+ /**
+ * @param {string} actionId
+ * @return {?WebInspector.Action}
+ */
+ action(actionId) {
+ return this._actionsById.get(actionId) || null;
+ }
};
/**
- * @constructor
- * @extends {WebInspector.Object}
- * @param {!Runtime.Extension} extension
+ * @unrestricted
*/
-WebInspector.Action = function(extension)
-{
- WebInspector.Object.call(this);
+WebInspector.Action = class extends WebInspector.Object {
+ /**
+ * @param {!Runtime.Extension} extension
+ */
+ constructor(extension) {
+ super();
this._extension = extension;
this._enabled = true;
this._toggled = false;
-};
-
-/** @enum {symbol} */
-WebInspector.Action.Events = {
- Enabled: Symbol("Enabled"),
- Toggled: Symbol("Toggled")
-};
-
-WebInspector.Action.prototype = {
- /**
- * @return {string}
- */
- id: function()
- {
- return this._extension.descriptor()["actionId"];
- },
-
- /**
- * @return {!Promise.<boolean>}
- */
- execute: function()
- {
- return this._extension.instance().then(handleAction.bind(this));
-
- /**
- * @param {!Object} actionDelegate
- * @return {boolean}
- * @this {WebInspector.Action}
- */
- function handleAction(actionDelegate)
- {
- var actionId = this._extension.descriptor()["actionId"];
- var delegate = /** @type {!WebInspector.ActionDelegate} */(actionDelegate);
- return delegate.handleAction(WebInspector.context, actionId);
- }
- },
-
- /**
- * @return {string}
- */
- icon: function()
- {
- return this._extension.descriptor()["iconClass"] || "";
- },
-
- /**
- * @param {boolean} enabled
- */
- setEnabled: function(enabled)
- {
- if (this._enabled === enabled)
- return;
-
- this._enabled = enabled;
- this.dispatchEventToListeners(WebInspector.Action.Events.Enabled, enabled);
- },
+ }
- /**
- * @return {boolean}
- */
- enabled: function()
- {
- return this._enabled;
- },
-
- /**
- * @return {string}
- */
- category: function()
- {
- return this._extension.descriptor()["category"] || "";
- },
+ /**
+ * @return {string}
+ */
+ id() {
+ return this._extension.descriptor()['actionId'];
+ }
- /**
- * @return {string}
- */
- tags: function()
- {
- return this._extension.descriptor()["tags"] || "";
- },
-
- /**
- * @return {string}
- */
- title: function()
- {
- var title = this._extension.title();
- var options = this._extension.descriptor()["options"];
- if (options) {
- for (var pair of options) {
- if (pair["value"] !== this._toggled)
- title = pair["title"];
- }
- }
- return title;
- },
+ /**
+ * @return {!Promise.<boolean>}
+ */
+ execute() {
+ return this._extension.instance().then(handleAction.bind(this));
/**
+ * @param {!Object} actionDelegate
* @return {boolean}
+ * @this {WebInspector.Action}
*/
- toggled: function()
- {
- return this._toggled;
- },
-
- /**
- * @param {boolean} toggled
- */
- setToggled: function(toggled)
- {
- if (this._toggled === toggled)
- return;
-
- this._toggled = toggled;
- this.dispatchEventToListeners(WebInspector.Action.Events.Toggled, toggled);
- },
+ function handleAction(actionDelegate) {
+ var actionId = this._extension.descriptor()['actionId'];
+ var delegate = /** @type {!WebInspector.ActionDelegate} */ (actionDelegate);
+ return delegate.handleAction(WebInspector.context, actionId);
+ }
+ }
+
+ /**
+ * @return {string}
+ */
+ icon() {
+ return this._extension.descriptor()['iconClass'] || '';
+ }
+
+ /**
+ * @param {boolean} enabled
+ */
+ setEnabled(enabled) {
+ if (this._enabled === enabled)
+ return;
+
+ this._enabled = enabled;
+ this.dispatchEventToListeners(WebInspector.Action.Events.Enabled, enabled);
+ }
+
+ /**
+ * @return {boolean}
+ */
+ enabled() {
+ return this._enabled;
+ }
+
+ /**
+ * @return {string}
+ */
+ category() {
+ return this._extension.descriptor()['category'] || '';
+ }
+
+ /**
+ * @return {string}
+ */
+ tags() {
+ return this._extension.descriptor()['tags'] || '';
+ }
+
+ /**
+ * @return {string}
+ */
+ title() {
+ var title = this._extension.title();
+ var options = this._extension.descriptor()['options'];
+ if (options) {
+ for (var pair of options) {
+ if (pair['value'] !== this._toggled)
+ title = pair['title'];
+ }
+ }
+ return title;
+ }
+
+ /**
+ * @return {boolean}
+ */
+ toggled() {
+ return this._toggled;
+ }
+
+ /**
+ * @param {boolean} toggled
+ */
+ setToggled(toggled) {
+ if (this._toggled === toggled)
+ return;
+
+ this._toggled = toggled;
+ this.dispatchEventToListeners(WebInspector.Action.Events.Toggled, toggled);
+ }
+};
- __proto__: WebInspector.Object.prototype
+/** @enum {symbol} */
+WebInspector.Action.Events = {
+ Enabled: Symbol('Enabled'),
+ Toggled: Symbol('Toggled')
};
/**
* @interface
*/
-WebInspector.ActionDelegate = function()
-{
-};
+WebInspector.ActionDelegate = function() {};
WebInspector.ActionDelegate.prototype = {
- /**
- * @param {!WebInspector.Context} context
- * @param {string} actionId
- * @return {boolean}
- */
- handleAction: function(context, actionId) {}
+ /**
+ * @param {!WebInspector.Context} context
+ * @param {string} actionId
+ * @return {boolean}
+ */
+ handleAction: function(context, actionId) {}
};
/** @type {!WebInspector.ActionRegistry} */

Powered by Google App Engine
This is Rietveld 408576698