Bug 1289425 - Remove domUtils from the InplaceEditor; r?tromey draft
authorGreg Tatum <tatum.creative@gmail.com>
Fri, 05 Aug 2016 11:40:51 -0500
changeset 407404 41e95476f434f9cccef4e0d107222b5129ceeccb
parent 407403 e45acb4589a316f7d832686ba2b108372fff6a9d
child 407405 dd33e917ed113dcb191be4f1ac5a1ca19c50d5c9
push id27965
push userbmo:gtatum@mozilla.com
push dateTue, 30 Aug 2016 12:52:36 +0000
reviewerstromey
bugs1289425
milestone51.0a1
Bug 1289425 - Remove domUtils from the InplaceEditor; r?tromey MozReview-Commit-ID: D9thpWSNwKC
devtools/client/shared/inplace-editor.js
devtools/shared/fronts/css-properties.js
--- a/devtools/client/shared/inplace-editor.js
+++ b/devtools/client/shared/inplace-editor.js
@@ -18,17 +18,17 @@
  *   trigger: "dblclick"
  * });
  *
  * See editableField() for more options.
  */
 
 "use strict";
 
-const {Ci, Cc} = require("chrome");
+const {Ci} = require("chrome");
 const Services = require("Services");
 const focusManager = Services.focus;
 const {KeyCodes} = require("devtools/client/shared/keycodes");
 
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 const CONTENT_TYPES = {
   PLAIN_TEXT: 0,
   CSS_VALUE: 1,
@@ -38,17 +38,16 @@ const CONTENT_TYPES = {
 
 // The limit of 500 autocomplete suggestions should not be reached but is kept
 // for safety.
 const MAX_POPUP_ENTRIES = 500;
 
 const FOCUS_FORWARD = focusManager.MOVEFOCUS_FORWARD;
 const FOCUS_BACKWARD = focusManager.MOVEFOCUS_BACKWARD;
 
-const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
 const EventEmitter = require("devtools/shared/event-emitter");
 const { findMostRelevantCssPropertyIndex } = require("./suggestion-picker");
 
 /**
  * Helper to check if the provided key matches one of the expected keys.
  * Keys will be prefixed with DOM_VK_ and should match a key in KeyCodes.
  *
  * @param {String} key
@@ -1462,17 +1461,17 @@ InplaceEditor.prototype = {
 
   /**
    * Returns the list of CSS properties to use for the autocompletion. This
    * method is overridden by tests in order to use mocked suggestion lists.
    *
    * @return {Array} array of CSS property names (Strings)
    */
   _getCSSPropertyList: function () {
-    return CSSPropertyList;
+    return this.cssProperties.getNames().sort();
   },
 
   /**
    * Returns a list of CSS values valid for a provided property name to use for
    * the autocompletion. This method is overridden by tests in order to use
    * mocked suggestion lists.
    *
    * @param {String} propertyName
@@ -1551,16 +1550,8 @@ function copyBoxModelStyles(from, to) {
 }
 
 /**
  * Trigger a focus change similar to pressing tab/shift-tab.
  */
 function moveFocus(win, direction) {
   return focusManager.moveFocus(win, null, direction, 0);
 }
-
-XPCOMUtils.defineLazyGetter(this, "CSSPropertyList", function () {
-  return domUtils.getCSSPropertyNames(domUtils.INCLUDE_ALIASES).sort();
-});
-
-XPCOMUtils.defineLazyGetter(this, "domUtils", function () {
-  return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
-});
--- a/devtools/shared/fronts/css-properties.js
+++ b/devtools/shared/fronts/css-properties.js
@@ -104,16 +104,25 @@ CssProperties.prototype = {
   /**
    * Gets the CSS values for a given property name.
    *
    * @param {String} property The property to use.
    * @return {Array} An array of strings.
    */
   getValues(property) {
     return this.properties[property] ? this.properties[property].values : [];
+  },
+
+  /**
+   * Gets the CSS property names.
+   *
+   * @return {Array} An array of strings.
+   */
+  getNames(property) {
+    return Object.keys(this.properties);
   }
 };
 
 /**
  * Create a CssProperties object with a fully loaded CSS database. The
  * CssProperties interface can be queried synchronously, but the initialization
  * is potentially async and should be handled up-front when the tool is created.
  *