Bug 1530976 - Remove functionality to mark rules as selected in the Rules view. r=gl
authorRazvan Caliman <rcaliman@mozilla.com>
Wed, 27 Feb 2019 15:31:16 +0000
changeset 519360 f769684a0f39c3ddbba7ca56f3682b435be251eb
parent 519359 ecf106e36d6ff5c995aff9d344cb630f7e7f2822
child 519361 d209ceb7588c9060ac427ffc76abacce9cdffb02
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1530976
milestone67.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 1530976 - Remove functionality to mark rules as selected in the Rules view. r=gl Differential Revision: https://phabricator.services.mozilla.com/D21344
devtools/client/inspector/rules/rules.js
--- a/devtools/client/inspector/rules/rules.js
+++ b/devtools/client/inspector/rules/rules.js
@@ -103,19 +103,16 @@ const INSET_POINT_TYPES = ["top", "right
 function CssRuleView(inspector, document, store) {
   EventEmitter.decorate(this);
 
   this.inspector = inspector;
   this.cssProperties = inspector.cssProperties;
   this.styleDocument = document;
   this.styleWindow = this.styleDocument.defaultView;
   this.store = store || {};
-  // References to rules marked by various editors where they intend to write changes.
-  // @see selectRule(), unselectRule()
-  this.selectedRules = new Map();
   this.pageStyle = inspector.pageStyle;
 
   // Allow tests to override debouncing behavior, as this can cause intermittents.
   this.debounce = debounce;
 
   this._outputParser = new OutputParser(document, this.cssProperties);
 
   this._onAddRule = this._onAddRule.bind(this);
@@ -722,18 +719,16 @@ CssRuleView.prototype = {
 
     if (this._highlighters) {
       this._highlighters.removeFromView(this);
       this._highlighters = null;
     }
 
     this.tooltips.destroy();
 
-    this.unselectAllRules();
-
     // Remove bound listeners
     this.shortcuts.destroy();
     this.element.removeEventListener("copy", this._onCopy);
     this.element.removeEventListener("contextmenu", this._onContextMenu);
     this.addRuleButton.removeEventListener("click", this._onAddRule);
     this.searchField.removeEventListener("input", this._onFilterStyles);
     this.searchClearButton.removeEventListener("click", this._onClearSearch);
     this.pseudoClassToggle.removeEventListener("click", this._onTogglePseudoClassPanel);
@@ -806,17 +801,16 @@ CssRuleView.prototype = {
       this.popup.hidePopup();
     }
 
     this.clear(false);
     this._viewedElement = element;
 
     this.clearPseudoClassPanel();
     this.refreshAddRuleButtonState();
-    this.unselectAllRules();
 
     if (!this._viewedElement) {
       this._stopSelectingElement();
       this._clearRules();
       this._showEmpty();
       this.refreshPseudoClassPanel();
       return promise.resolve(undefined);
     }
@@ -1210,109 +1204,16 @@ CssRuleView.prototype = {
         isHighlighted = true;
       }
     }
 
     return isHighlighted;
   },
 
   /**
-  * Mark a rule as selected for the given editor id.
-  *
-  * Editing tools can mark one or more rules as selected for themselves so they have
-  * a reference of where to make changes, like add / remove properties.
-  * Each editor has an identifier string (aka editorId) which is used as a key in a map
-  * that holds references to Rule objects.
-  *
-  * Many editors may operate at the same time (ex: Font Editor and Shape Path Editor) so
-  * there are multiple possible selected rules at any given time. A rule can be selected
-  * by different editors at the same time, with each editor operating independently on it.
-  *
-  * @param {Rule} rule
-  *        Rule object for which to hold a reference.
-  * @param {String} editorId
-  *        Key to use for collecting references to selected rules.
-  * @param {Boolean} [unselectOthers=true]
-  *        Optional. Default: `true`. If true, unselect all other rules that were
-  *        selected for the given editor. Ensures only one rule at a time is selected for
-  *        a particular editor. Set to `false` if an editor may operate on multiple rules
-  *        at a time.
-  */
-  selectRule(rule, editorId, unselectOthers = true) {
-    const rules = this.getSelectedRules(editorId);
-    if (!rules.includes(rule)) {
-      this.selectedRules.set(editorId, [...rules, rule]);
-    }
-
-    // Mark other rules for this editorId as unselected.
-    if (unselectOthers) {
-      rules
-        .filter(item => item !== rule)
-        .map(item => this.unselectRule(item, editorId));
-    }
-
-    this.emit("ruleview-rule-selected", {editorId, rule});
-  },
-
-  /**
-   * Unmark a rule as selected for the given editor id.
-   *
-   * @param {Rule} rule
-   *        Rule object for which to remove the reference.
-   * @param {String} editorId
-   *        Key for which to mark the given rule as selected.
-   */
-  unselectRule(rule, editorId) {
-    const rules = this.selectedRules.get(editorId);
-    if (!Array.isArray(rules)) {
-      return;
-    }
-
-    const index = rules.findIndex(item => item === rule);
-    if (index === -1) {
-      return;
-    }
-
-    rules.splice(index, 1);
-    this.selectedRules.set(editorId, rules);
-    this.emit("ruleview-rule-unselected", {editorId, rule});
-  },
-
-  /**
-  * Unmark all selected rules for all editors. If an editor id is provided, unmark all
-  * selected rules just for that editor leaving others untouched.
-  *
-  * @param {String} editorId
-  *        Optional editor id for which to restrict unselect operation.
-  */
-  unselectAllRules(editorId) {
-    for (const [id, rules] of this.selectedRules) {
-      // If we're supposed to unselect rules from just one editorId but it did not match,
-      // skip this iteration.
-      if (editorId && id !== editorId) {
-        continue;
-      }
-      rules.map(rule => this.unselectRule(rule, id));
-    }
-  },
-
-  /**
-   * Return an array of selected rules for the given editor id.
-   * If no rules match, return an empty arrary;
-   *
-   * @param {String} editorId
-   *        Editor id for which to return selected rules.
-   * @return {Array}
-   */
-  getSelectedRules(editorId) {
-    const rules = this.selectedRules.get(editorId);
-    return Array.isArray(rules) ? rules : [];
-  },
-
-  /**
    * Highlights the rule selector that matches the filter search value and
    * returns a boolean indicating whether or not the selector was highlighted.
    *
    * @param  {Rule} rule
    *         The Rule object.
    * @return {Boolean} true if the rule selector was highlighted,
    *         false otherwise.
    */