Bug 1378860 - Use an ES class instead of an SDK class for RuleModificationList; r=gl
authorPatrick Brosset <pbrosset@mozilla.com>
Fri, 21 Jul 2017 14:36:10 +0200
changeset 419300 b8d5c1d7bf82ad052da3e846f8882f04b53a40c9
parent 419299 57164b11328641c6ad9f89ca6a941418b474d99a
child 419301 51f2cc05efdea472ec78f2c93aae9491a910559c
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1378860
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1378860 - Use an ES class instead of an SDK class for RuleModificationList; r=gl MozReview-Commit-ID: CFXcLPFbi0U
devtools/shared/fronts/styles.js
--- a/devtools/shared/fronts/styles.js
+++ b/devtools/shared/fronts/styles.js
@@ -11,17 +11,16 @@ const {
   preEvent
 } = require("devtools/shared/protocol");
 const {
   pageStyleSpec,
   styleRuleSpec
 } = require("devtools/shared/specs/styles");
 const promise = require("promise");
 const { Task } = require("devtools/shared/task");
-const { Class } = require("sdk/core/heritage");
 const { RuleRewriter } = require("devtools/shared/css/parsing-utils");
 
 /**
  * PageStyleFront, the front object for the PageStyleActor
  */
 const PageStyleFront = FrontClassWithSpec(pageStyleSpec, {
   initialize: function (conn, form, ctx, detail) {
     Front.prototype.initialize.call(this, conn, form, ctx, detail);
@@ -290,74 +289,74 @@ exports.StyleRuleFront = StyleRuleFront;
  * list of modifications that will be applied to a StyleRuleActor.
  * The modifications are processed in the order in which they are
  * added to the RuleModificationList.
  *
  * Objects of this type expose the same API as @see RuleRewriter.
  * This lets the inspector use (mostly) the same code, regardless of
  * whether the server implements setRuleText.
  */
-var RuleModificationList = Class({
+class RuleModificationList {
   /**
    * Initialize a RuleModificationList.
    * @param {StyleRuleFront} rule the associated rule
    */
-  initialize: function (rule) {
+  constructor(rule) {
     this.rule = rule;
     this.modifications = [];
-  },
+  }
 
   /**
    * Apply the modifications in this object to the associated rule.
    *
    * @return {Promise} A promise which will be resolved when the modifications
    *         are complete; @see StyleRuleActor.modifyProperties.
    */
-  apply: function () {
+  apply() {
     return this.rule.modifyProperties(this.modifications);
-  },
+  }
 
   /**
    * Add a "set" entry to the modification list.
    *
    * @param {Number} index index of the property in the rule.
    *                       This can be -1 in the case where
    *                       the rule does not support setRuleText;
    *                       generally for setting properties
    *                       on an element's style.
    * @param {String} name the property's name
    * @param {String} value the property's value
    * @param {String} priority the property's priority, either the empty
    *                          string or "important"
    */
-  setProperty: function (index, name, value, priority) {
+  setProperty(index, name, value, priority) {
     this.modifications.push({
       type: "set",
       name: name,
       value: value,
       priority: priority
     });
-  },
+  }
 
   /**
    * Add a "remove" entry to the modification list.
    *
    * @param {Number} index index of the property in the rule.
    *                       This can be -1 in the case where
    *                       the rule does not support setRuleText;
    *                       generally for setting properties
    *                       on an element's style.
    * @param {String} name the name of the property to remove
    */
-  removeProperty: function (index, name) {
+  removeProperty(index, name) {
     this.modifications.push({
       type: "remove",
       name: name
     });
-  },
+  }
 
   /**
    * Rename a property.  This implementation acts like
    * |removeProperty|, because |setRuleText| is not available.
    *
    * @param {Number} index index of the property in the rule.
    *                       This can be -1 in the case where
    *                       the rule does not support setRuleText;
@@ -365,39 +364,39 @@ var RuleModificationList = Class({
    *                       on an element's style.
    * @param {String} name current name of the property
    *
    * This parameter is also passed, but as it is not used in this
    * implementation, it is omitted.  It is documented here as this
    * code also defined the interface implemented by @see RuleRewriter.
    * @param {String} newName new name of the property
    */
-  renameProperty: function (index, name) {
+  renameProperty(index, name) {
     this.removeProperty(index, name);
-  },
+  }
 
   /**
    * Enable or disable a property.  This implementation acts like
    * |removeProperty| when disabling, or a no-op when enabling,
    * because |setRuleText| is not available.
    *
    * @param {Number} index index of the property in the rule.
    *                       This can be -1 in the case where
    *                       the rule does not support setRuleText;
    *                       generally for setting properties
    *                       on an element's style.
    * @param {String} name current name of the property
    * @param {Boolean} isEnabled true if the property should be enabled;
    *                        false if it should be disabled
    */
-  setPropertyEnabled: function (index, name, isEnabled) {
+  setPropertyEnabled(index, name, isEnabled) {
     if (!isEnabled) {
       this.removeProperty(index, name);
     }
-  },
+  }
 
   /**
    * Create a new property.  This implementation does nothing, because
    * |setRuleText| is not available.
    *
    * These parameters are passed, but as they are not used in this
    * implementation, they are omitted.  They are documented here as
    * this code also defined the interface implemented by @see
@@ -410,12 +409,12 @@ var RuleModificationList = Class({
    *                       on an element's style.
    * @param {String} name name of the new property
    * @param {String} value value of the new property
    * @param {String} priority priority of the new property; either
    *                          the empty string or "important"
    * @param {Boolean} enabled True if the new property should be
    *                          enabled, false if disabled
    */
-  createProperty: function () {
+  createProperty() {
     // Nothing.
-  },
-});
+  }
+}