Bug 1265854 - replace uses of nsiDOMNode constants in devtools frontend r=tromey
authorJames Long <longster@gmail.com>
Fri, 03 Jun 2016 09:47:58 -0400
changeset 341355 be6fddfc1390a14cd560eb843162f0cccd804e63
parent 341354 f4fbac42bc5e86aeb36fb2d4157fa6dbcf4e441e
child 341356 00ee1688f8a29667b941be32f4b94b407926b022
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1265854
milestone49.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 1265854 - replace uses of nsiDOMNode constants in devtools frontend r=tromey
devtools/client/framework/selection.js
devtools/client/inspector/inspector-panel.js
devtools/client/inspector/markup/markup.js
devtools/client/shared/developer-toolbar.js
devtools/client/shared/widgets/VariablesView.jsm
devtools/client/webconsole/console-output.js
devtools/shared/dom-node-constants.js
devtools/shared/fronts/inspector.js
devtools/shared/inspector/css-logic.js
devtools/shared/moz.build
--- a/devtools/client/framework/selection.js
+++ b/devtools/client/framework/selection.js
@@ -1,17 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const { Cu, Ci } = require("chrome");
+const { Cu } = require("chrome");
+const nodeConstants = require("devtools/shared/dom-node-constants.js")
 const { getRootBindingParent } = require("devtools/shared/layout/utils");
 var EventEmitter = require("devtools/shared/event-emitter");
 
 /**
  * API
  *
  *   new Selection(walker=null, node=null, track={attributes,detached});
  *   destroy()
@@ -257,58 +258,58 @@ Selection.prototype = {
 
   isHTMLNode: function () {
     let xhtml_ns = "http://www.w3.org/1999/xhtml";
     return this.isNode() && this.nodeFront.namespaceURI == xhtml_ns;
   },
 
   // Node type
 
-  isElementNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ELEMENT_NODE;
+  isElementNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.ELEMENT_NODE;
   },
 
   isPseudoElementNode: function () {
     return this.isNode() && this.nodeFront.isPseudoElement;
   },
 
   isAnonymousNode: function () {
     return this.isNode() && this.nodeFront.isAnonymous;
   },
 
-  isAttributeNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ATTRIBUTE_NODE;
+  isAttributeNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.ATTRIBUTE_NODE;
   },
 
-  isTextNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.TEXT_NODE;
+  isTextNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.TEXT_NODE;
   },
 
-  isCDATANode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.CDATA_SECTION_NODE;
+  isCDATANode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.CDATA_SECTION_NODE;
   },
 
-  isEntityRefNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ENTITY_REFERENCE_NODE;
+  isEntityRefNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.ENTITY_REFERENCE_NODE;
   },
 
-  isEntityNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ENTITY_NODE;
+  isEntityNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.ENTITY_NODE;
   },
 
-  isProcessingInstructionNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.PROCESSING_INSTRUCTION_NODE;
+  isProcessingInstructionNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.PROCESSING_INSTRUCTION_NODE;
   },
 
-  isCommentNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.PROCESSING_INSTRUCTION_NODE;
+  isCommentNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.PROCESSING_INSTRUCTION_NODE;
   },
 
-  isDocumentNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.DOCUMENT_NODE;
+  isDocumentNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.DOCUMENT_NODE;
   },
 
   /**
    * @returns true if the selection is the <body> HTML element.
    */
   isBodyNode: function () {
     return this.isHTMLNode() &&
            this.isConnected() &&
@@ -319,20 +320,20 @@ Selection.prototype = {
    * @returns true if the selection is the <head> HTML element.
    */
   isHeadNode: function () {
     return this.isHTMLNode() &&
            this.isConnected() &&
            this.nodeFront.nodeName === "HEAD";
   },
 
-  isDocumentTypeNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.DOCUMENT_TYPE_NODE;
+  isDocumentTypeNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.DOCUMENT_TYPE_NODE;
   },
 
-  isDocumentFragmentNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE;
+  isDocumentFragmentNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.DOCUMENT_FRAGMENT_NODE;
   },
 
-  isNotationNode: function () {
-    return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.NOTATION_NODE;
+  isNotationNode: function() {
+    return this.isNode() && this.nodeFront.nodeType == nodeConstants.NOTATION_NODE;
   },
 };
--- a/devtools/client/inspector/inspector-panel.js
+++ b/devtools/client/inspector/inspector-panel.js
@@ -13,16 +13,17 @@ const {Cc, Ci} = require("chrome");
 var Services = require("Services");
 var promise = require("promise");
 var EventEmitter = require("devtools/shared/event-emitter");
 var clipboard = require("sdk/clipboard");
 const {executeSoon} = require("devtools/shared/DevToolsUtils");
 var {KeyShortcuts} = require("devtools/client/shared/key-shortcuts");
 var {Task} = require("devtools/shared/task");
 const {initCssProperties} = require("devtools/shared/fronts/css-properties");
+const nodeConstants = require("devtools/shared/dom-node-constants");
 
 loader.lazyRequireGetter(this, "CSS", "CSS");
 
 loader.lazyRequireGetter(this, "CommandUtils", "devtools/client/shared/developer-toolbar", true);
 loader.lazyRequireGetter(this, "ComputedViewTool", "devtools/client/inspector/computed/computed", true);
 loader.lazyRequireGetter(this, "FontInspector", "devtools/client/inspector/fonts/fonts", true);
 loader.lazyRequireGetter(this, "HTMLBreadcrumbs", "devtools/client/inspector/breadcrumbs", true);
 loader.lazyRequireGetter(this, "InspectorSearch", "devtools/client/inspector/inspector-search", true);
@@ -1249,25 +1250,25 @@ InspectorPanel.prototype = {
    */
   copyOuterHTML: function () {
     if (!this.selection.isNode()) {
       return;
     }
     let node = this.selection.nodeFront;
 
     switch (node.nodeType) {
-      case Ci.nsIDOMNode.ELEMENT_NODE :
+      case nodeConstants.ELEMENT_NODE :
         this._copyLongString(this.walker.outerHTML(node));
         break;
-      case Ci.nsIDOMNode.COMMENT_NODE :
+      case nodeConstants.COMMENT_NODE :
         this._getLongString(node.getNodeValue()).then(comment => {
           clipboardHelper.copyString("<!--" + comment + "-->");
         });
         break;
-      case Ci.nsIDOMNode.DOCUMENT_TYPE_NODE :
+      case nodeConstants.DOCUMENT_TYPE_NODE :
         clipboardHelper.copyString(node.doctypeString);
         break;
     }
   },
 
   /**
    * Copy the data-uri for the currently selected image in the clipboard.
    */
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -46,16 +46,17 @@ const {parseAttribute} =
       require("devtools/client/shared/node-attribute-parser");
 const ELLIPSIS = Services.prefs.getComplexValue("intl.ellipsis",
       Ci.nsIPrefLocalizedString).data;
 const {Task} = require("devtools/shared/task");
 const {scrollIntoViewIfNeeded} = require("devtools/shared/layout/utils");
 const {PrefObserver} = require("devtools/client/styleeditor/utils");
 const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts");
 const {template} = require("devtools/shared/gcli/templater");
+const nodeConstants = require("devtools/shared/dom-node-constants");
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 loader.lazyRequireGetter(this, "CSS", "CSS");
 loader.lazyGetter(this, "DOMParser", () => {
   return Cc["@mozilla.org/xmlextras/domparser;1"]
     .createInstance(Ci.nsIDOMParser);
 });
@@ -214,17 +215,17 @@ MarkupView.prototype = {
       if (target.tagName.toLowerCase() === "body") {
         return;
       }
       target = target.parentNode;
     }
 
     let container = target.container;
     if (this._hoveredNode !== container.node) {
-      if (container.node.nodeType !== Ci.nsIDOMNode.TEXT_NODE) {
+      if (container.node.nodeType !== nodeConstants.TEXT_NODE) {
         this._showBoxModel(container.node);
       } else {
         this._hideBoxModel();
       }
     }
     this._showContainerAsHovered(container.node);
 
     this.emit("node-hover");
@@ -838,17 +839,17 @@ MarkupView.prototype = {
    *
    * @param  {NodeFront} node
    *         The node to remove.
    * @param  {Boolean} moveBackward
    *         If set to true, focus the previous sibling, otherwise the next one.
    */
   deleteNode: function (node, moveBackward) {
     if (node.isDocumentElement ||
-        node.nodeType == Ci.nsIDOMNode.DOCUMENT_TYPE_NODE ||
+        node.nodeType == nodeConstants.DOCUMENT_TYPE_NODE ||
         node.isAnonymous) {
       return;
     }
 
     let container = this.getContainer(node);
 
     // Retain the node so we can undo this...
     this.walker.retainNode(node).then(() => {
@@ -923,20 +924,20 @@ MarkupView.prototype = {
     }
 
     let container;
     let {nodeType, isPseudoElement} = node;
     if (node === this.walker.rootNode) {
       container = new RootContainer(this, node);
       this._elt.appendChild(container.elt);
       this._rootNode = node;
-    } else if (nodeType == Ci.nsIDOMNode.ELEMENT_NODE && !isPseudoElement) {
+    } else if (nodeType == nodeConstants.ELEMENT_NODE && !isPseudoElement) {
       container = new MarkupElementContainer(this, node, this._inspector);
-    } else if (nodeType == Ci.nsIDOMNode.COMMENT_NODE ||
-               nodeType == Ci.nsIDOMNode.TEXT_NODE) {
+    } else if (nodeType == nodeConstants.COMMENT_NODE ||
+               nodeType == nodeConstants.TEXT_NODE) {
       container = new MarkupTextContainer(this, node, this._inspector);
     } else {
       container = new MarkupReadOnlyContainer(this, node, this._inspector);
     }
 
     if (flashNode) {
       container.flashMutation();
     }
@@ -1819,17 +1820,17 @@ MarkupView.prototype = {
     if (nextSibling && nextSibling.isBeforePseudoElement) {
       nextSibling = target.parentNode.parentNode.children[1].container.node;
     }
     if (nextSibling && nextSibling.isAfterPseudoElement) {
       parent = target.parentNode.container.node.parentNode();
       nextSibling = null;
     }
 
-    if (parent.nodeType !== Ci.nsIDOMNode.ELEMENT_NODE) {
+    if (parent.nodeType !== nodeConstants.ELEMENT_NODE) {
       return null;
     }
 
     return {parent, nextSibling};
   }
 };
 
 /**
@@ -2563,19 +2564,19 @@ MarkupReadOnlyContainer.prototype =
  *         The node to display.
  * @param  {Inspector} inspector
  *         The inspector tool container the markup-view
  */
 function MarkupTextContainer(markupView, node) {
   MarkupContainer.prototype.initialize.call(this, markupView, node,
     "textcontainer");
 
-  if (node.nodeType == Ci.nsIDOMNode.TEXT_NODE) {
+  if (node.nodeType == nodeConstants.TEXT_NODE) {
     this.editor = new TextEditor(this, node, "text");
-  } else if (node.nodeType == Ci.nsIDOMNode.COMMENT_NODE) {
+  } else if (node.nodeType == nodeConstants.COMMENT_NODE) {
     this.editor = new TextEditor(this, node, "comment");
   } else {
     throw new Error("Invalid node for MarkupTextContainer");
   }
 
   this.tagLine.appendChild(this.editor.elt);
 }
 
@@ -2590,17 +2591,17 @@ MarkupTextContainer.prototype = Heritage
  *         The markup view that owns this container.
  * @param  {NodeFront} node
  *         The node to display.
  */
 function MarkupElementContainer(markupView, node) {
   MarkupContainer.prototype.initialize.call(this, markupView, node,
     "elementcontainer");
 
-  if (node.nodeType === Ci.nsIDOMNode.ELEMENT_NODE) {
+  if (node.nodeType === nodeConstants.ELEMENT_NODE) {
     this.editor = new ElementEditor(this, node);
   } else {
     throw new Error("Invalid node for MarkupElementContainer");
   }
 
   this.tagLine.appendChild(this.editor.elt);
 }
 
@@ -2813,17 +2814,17 @@ function GenericEditor(container, node) 
   this.markup = this.container.markup;
   this.template = this.markup.template.bind(this.markup);
   this.elt = null;
   this.template("generic", this);
 
   if (node.isPseudoElement) {
     this.tag.classList.add("theme-fg-color5");
     this.tag.textContent = node.isBeforePseudoElement ? "::before" : "::after";
-  } else if (node.nodeType == Ci.nsIDOMNode.DOCUMENT_TYPE_NODE) {
+  } else if (node.nodeType == nodeConstants.DOCUMENT_TYPE_NODE) {
     this.elt.classList.add("comment");
     this.tag.textContent = node.doctypeString;
   } else {
     this.tag.textContent = node.nodeName;
   }
 }
 
 GenericEditor.prototype = {
--- a/devtools/client/shared/developer-toolbar.js
+++ b/devtools/client/shared/developer-toolbar.js
@@ -7,17 +7,16 @@
 const { Cc, Ci, Cu } = require("chrome");
 const promise = require("promise");
 const Services = require("Services");
 const { TargetFactory } = require("devtools/client/framework/target");
 const Telemetry = require("devtools/client/shared/telemetry");
 
 const NS_XHTML = "http://www.w3.org/1999/xhtml";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-const Node = Ci.nsIDOMNode;
 
 loader.lazyImporter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm");
 loader.lazyImporter(this, "EventEmitter", "resource://devtools/shared/event-emitter.js");
 
 loader.lazyGetter(this, "prefBranch", function () {
   return Services.prefs.getBranch(null)
                     .QueryInterface(Ci.nsIPrefBranch2);
 });
@@ -25,16 +24,17 @@ loader.lazyGetter(this, "toolboxStrings"
   return Services.strings.createBundle("chrome://devtools/locale/toolbox.properties");
 });
 
 loader.lazyRequireGetter(this, "gcliInit", "devtools/shared/gcli/commands/index");
 loader.lazyRequireGetter(this, "util", "gcli/util/util");
 loader.lazyRequireGetter(this, "ConsoleServiceListener", "devtools/shared/webconsole/utils", true);
 loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
 loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
+loader.lazyRequireGetter(this, "nodeConstants", "devtools/shared/dom-node-constants", true);
 
 /**
  * A collection of utilities to help working with commands
  */
 var CommandUtils = {
   /**
    * Utility to ensure that things are loaded in the correct order
    */
@@ -387,17 +387,17 @@ DeveloperToolbar.prototype.focus = funct
  * toggle the toolbar
  */
 DeveloperToolbar.prototype.focusToggle = function () {
   if (this.visible) {
     // If we have focus then the active element is the HTML input contained
     // inside the xul input element
     let active = this._chromeWindow.document.activeElement;
     let position = this._input.compareDocumentPosition(active);
-    if (position & Node.DOCUMENT_POSITION_CONTAINED_BY) {
+    if (position & nodeConstants.DOCUMENT_POSITION_CONTAINED_BY) {
       this.hide();
     }
     else {
       this._input.focus();
     }
   } else {
     this.show(true);
   }
--- a/devtools/client/shared/widgets/VariablesView.jsm
+++ b/devtools/client/shared/widgets/VariablesView.jsm
@@ -22,16 +22,17 @@ Cu.import("resource://devtools/shared/ev
 const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const Services = require("Services");
 const { getSourceNames } = require("devtools/client/shared/source-utils");
 const promise = require("promise");
 const { Heritage, ViewHelpers, setNamedTimeout } =
   require("devtools/client/shared/widgets/view-helpers");
 const { Task } = require("devtools/shared/task");
+const nodeConstants = require("devtools/shared/dom-node-constants");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
   "resource://gre/modules/PluralForm.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
   "@mozilla.org/widget/clipboardhelper;1",
   "nsIClipboardHelper");
 
@@ -3753,56 +3754,56 @@ VariablesView.stringifiers.byObjectKind 
 
     return result + " {" + props.join(", ") + "}";
   }, // DOMEvent
 
   DOMNode: function (aGrip, {concise}) {
     let {preview} = aGrip;
 
     switch (preview.nodeType) {
-      case Ci.nsIDOMNode.DOCUMENT_NODE: {
+      case nodeConstants.DOCUMENT_NODE: {
         let result = aGrip.class;
         if (preview.location) {
           result += ` \u2192 ${getSourceNames(preview.location)[concise ? "short" : "long"]}`;
         }
 
         return result;
       }
 
-      case Ci.nsIDOMNode.ATTRIBUTE_NODE: {
+      case nodeConstants.ATTRIBUTE_NODE: {
         let value = VariablesView.getString(preview.value, { noStringQuotes: true });
         return preview.nodeName + '="' + escapeHTML(value) + '"';
       }
 
-      case Ci.nsIDOMNode.TEXT_NODE:
+      case nodeConstants.TEXT_NODE:
         return preview.nodeName + " " +
                VariablesView.getString(preview.textContent);
 
-      case Ci.nsIDOMNode.COMMENT_NODE: {
+      case nodeConstants.COMMENT_NODE: {
         let comment = VariablesView.getString(preview.textContent,
                                               { noStringQuotes: true });
         return "<!--" + comment + "-->";
       }
 
-      case Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE: {
+      case nodeConstants.DOCUMENT_FRAGMENT_NODE: {
         if (concise || !preview.childNodes) {
           return aGrip.class + "[" + preview.childNodesLength + "]";
         }
         let nodes = [];
         for (let node of preview.childNodes) {
           nodes.push(VariablesView.getString(node));
         }
         if (nodes.length < preview.childNodesLength) {
           let n = preview.childNodesLength - nodes.length;
           nodes.push(VariablesView.stringifiers._getNMoreString(n));
         }
         return aGrip.class + " [" + nodes.join(", ") + "]";
       }
 
-      case Ci.nsIDOMNode.ELEMENT_NODE: {
+      case nodeConstants.ELEMENT_NODE: {
         let attrs = preview.attributes;
         if (!concise) {
           let n = 0, result = "<" + preview.nodeName;
           for (let name in attrs) {
             let value = VariablesView.getString(attrs[name],
                                                 { noStringQuotes: true });
             result += " " + name + '="' + escapeHTML(value) + '"';
             n++;
--- a/devtools/client/webconsole/console-output.js
+++ b/devtools/client/webconsole/console-output.js
@@ -23,16 +23,17 @@ const { extend } = require("sdk/core/her
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 const STRINGS_URI = "chrome://devtools/locale/webconsole.properties";
 
 const WebConsoleUtils = require("devtools/shared/webconsole/utils").Utils;
 const { getSourceNames } = require("devtools/client/shared/source-utils");
 const {Task} = require("devtools/shared/task");
 const l10n = new WebConsoleUtils.L10n(STRINGS_URI);
+const nodeConstants = require("devtools/shared/dom-node-constants");
 
 const MAX_STRING_GRIP_LENGTH = 36;
 const ELLIPSIS = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
 
 // Constants for compatibility with the Web Console output implementation before
 // bug 778766.
 // TODO: remove these once bug 778766 is fixed.
 const COMPAT = {
@@ -1501,17 +1502,17 @@ Messages.ConsoleGeneric.prototype = exte
   _renderBodyPiece: function (piece, style)
   {
     // Skip quotes for top-level strings.
     let options = { noStringQuotes: true };
     let elem = Messages.Extended.prototype._renderBodyPiece.call(this, piece, options);
     let result = elem;
 
     if (style) {
-      if (elem.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) {
+      if (elem.nodeType == nodeConstants.ELEMENT_NODE) {
         elem.style = style;
       } else {
         let span = this.document.createElementNS(XHTML_NS, "span");
         span.style = style;
         span.appendChild(elem);
         result = span;
       }
     }
@@ -3049,51 +3050,51 @@ Widgets.ObjectRenderers.add({
 
   canRender: function (objectActor) {
     let {preview} = objectActor;
     if (!preview) {
       return false;
     }
 
     switch (preview.nodeType) {
-      case Ci.nsIDOMNode.DOCUMENT_NODE:
-      case Ci.nsIDOMNode.ATTRIBUTE_NODE:
-      case Ci.nsIDOMNode.TEXT_NODE:
-      case Ci.nsIDOMNode.COMMENT_NODE:
-      case Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE:
-      case Ci.nsIDOMNode.ELEMENT_NODE:
+      case nodeConstants.DOCUMENT_NODE:
+      case nodeConstants.ATTRIBUTE_NODE:
+      case nodeConstants.TEXT_NODE:
+      case nodeConstants.COMMENT_NODE:
+      case nodeConstants.DOCUMENT_FRAGMENT_NODE:
+      case nodeConstants.ELEMENT_NODE:
         return true;
       default:
         return false;
     }
   },
 
   render: function ()
   {
     switch (this.objectActor.preview.nodeType) {
-      case Ci.nsIDOMNode.DOCUMENT_NODE:
+      case nodeConstants.DOCUMENT_NODE:
         this._renderDocumentNode();
         break;
-      case Ci.nsIDOMNode.ATTRIBUTE_NODE: {
+      case nodeConstants.ATTRIBUTE_NODE: {
         let {preview} = this.objectActor;
         this.element = this.el("span.attributeNode.kind-" + preview.kind);
         let attr = this._renderAttributeNode(preview.nodeName, preview.value, true);
         this.element.appendChild(attr);
         break;
       }
-      case Ci.nsIDOMNode.TEXT_NODE:
+      case nodeConstants.TEXT_NODE:
         this._renderTextNode();
         break;
-      case Ci.nsIDOMNode.COMMENT_NODE:
+      case nodeConstants.COMMENT_NODE:
         this._renderCommentNode();
         break;
-      case Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE:
+      case nodeConstants.DOCUMENT_FRAGMENT_NODE:
         this._renderDocumentFragmentNode();
         break;
-      case Ci.nsIDOMNode.ELEMENT_NODE:
+      case nodeConstants.ELEMENT_NODE:
         this._renderElementNode();
         break;
       default:
         throw new Error("Unsupported nodeType: " + preview.nodeType);
     }
   },
 
   _renderDocumentNode: function ()
@@ -3229,26 +3230,26 @@ Widgets.ObjectRenderers.add({
   /**
    * If the DOMNode being rendered can be highlit in the page, this function
    * will attach mouseover/out event listeners to do so, and the inspector icon
    * to open the node in the inspector.
    * @return a promise that resolves when the node has been linked to the
    * inspector, or rejects if it wasn't (either if no toolbox could be found to
    * access the inspector, or if the node isn't present in the inspector, i.e.
    * if the node is in a DocumentFragment or not part of the tree, or not of
-   * type Ci.nsIDOMNode.ELEMENT_NODE).
+   * type nodeConstants.ELEMENT_NODE).
    */
   linkToInspector: Task.async(function* ()
   {
     if (this._linkedToInspector) {
       return;
     }
 
     // Checking the node type
-    if (this.objectActor.preview.nodeType !== Ci.nsIDOMNode.ELEMENT_NODE) {
+    if (this.objectActor.preview.nodeType !== nodeConstants.ELEMENT_NODE) {
       throw new Error("The object cannot be linked to the inspector as it " +
         "isn't an element node");
     }
 
     // Checking the presence of a toolbox
     let target = this.message.output.toolboxTarget;
     this.toolbox = gDevTools.getToolbox(target);
     if (!this.toolbox) {
new file mode 100644
--- /dev/null
+++ b/devtools/shared/dom-node-constants.js
@@ -0,0 +1,24 @@
+"use strict";
+
+module.exports = {
+  ELEMENT_NODE: 1,
+  ATTRIBUTE_NODE: 2,
+  TEXT_NODE: 3,
+  CDATA_SECTION_NODE: 4,
+  ENTITY_REFERENCE_NODE: 5,
+  ENTITY_NODE: 6,
+  PROCESSING_INSTRUCTION_NODE: 7,
+  COMMENT_NODE: 8,
+  DOCUMENT_NODE: 9,
+  DOCUMENT_TYPE_NODE: 10,
+  DOCUMENT_FRAGMENT_NODE: 11,
+  NOTATION_NODE: 12,
+
+  // DocumentPosition
+  DOCUMENT_POSITION_DISCONNECTED: 0x01,
+  DOCUMENT_POSITION_PRECEDING: 0x02,
+  DOCUMENT_POSITION_FOLLOWING: 0x04,
+  DOCUMENT_POSITION_CONTAINS: 0x08,
+  DOCUMENT_POSITION_CONTAINED_BY: 0x10,
+  DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20
+}
--- a/devtools/shared/fronts/inspector.js
+++ b/devtools/shared/fronts/inspector.js
@@ -1,15 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 const Services = require("Services");
-const { Ci } = require("chrome");
 require("devtools/shared/fronts/styles");
 require("devtools/shared/fronts/highlighters");
 const { ShortLongString } = require("devtools/server/actors/string");
 const {
   Front,
   FrontClassWithSpec,
   custom,
   preEvent,
@@ -22,16 +21,17 @@ const {
   nodeListSpec,
   walkerSpec
 } = require("devtools/shared/specs/inspector");
 const promise = require("promise");
 const { Task } = require("devtools/shared/task");
 const { Class } = require("sdk/core/heritage");
 const events = require("sdk/event/core");
 const object = require("sdk/util/object");
+const nodeConstants = require("devtools/shared/dom-node-constants.js");
 
 const HIDDEN_CLASS = "__fx-devtools-hide-shortcut__";
 
 /**
  * Convenience API for building a list of attribute modifications
  * for the `modifyAttributes` request.
  */
 const AttributeModificationList = Class({
@@ -252,17 +252,17 @@ const NodeFront = FrontClassWithSpec(nod
   },
   get isAnonymous() {
     return this._form.isAnonymous;
   },
   get isInHTMLDocument() {
     return this._form.isInHTMLDocument;
   },
   get tagName() {
-    return this.nodeType === Ci.nsIDOMNode.ELEMENT_NODE ? this.nodeName : null;
+    return this.nodeType === nodeConstants.ELEMENT_NODE ? this.nodeName : null;
   },
   get shortValue() {
     return this._form.shortValue;
   },
   get incompleteValue() {
     return !!this._form.incompleteValue;
   },
 
@@ -824,17 +824,17 @@ const WalkerFront = FrontClassWithSpec(w
           if ("numChildren" in change) {
             targetFront._form.numChildren = change.numChildren;
           }
         } else if (change.type === "frameLoad") {
           // Nothing we need to do here, except verify that we don't have any
           // document children, because we should have gotten a documentUnload
           // first.
           for (let child of targetFront.treeChildren()) {
-            if (child.nodeType === Ci.nsIDOMNode.DOCUMENT_NODE) {
+            if (child.nodeType === nodeConstants.DOCUMENT_NODE) {
               console.trace("Got an unexpected frameLoad in the inspector, " +
                 "please file a bug on bugzilla.mozilla.org!");
             }
           }
         } else if (change.type === "documentUnload") {
           if (targetFront === this.rootNode) {
             this._createRootNodePromise();
           }
--- a/devtools/shared/inspector/css-logic.js
+++ b/devtools/shared/inspector/css-logic.js
@@ -39,16 +39,17 @@
  * - how browsers process CSS
  * @constructor
  */
 
 const { Cc, Ci, Cu } = require("chrome");
 const Services = require("Services");
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const { getRootBindingParent } = require("devtools/shared/layout/utils");
+const nodeConstants = require("devtools/shared/dom-node-constants");
 
 // This should be ok because none of the functions that use this should be used
 // on the worker thread, where Cu is not available.
 loader.lazyRequireGetter(this, "CSS", "CSS");
 
 loader.lazyRequireGetter(this, "CSSLexer", "devtools/shared/css-lexer");
 
 function CssLogic() {
@@ -534,17 +535,17 @@ CssLogic.prototype = {
    */
   selectorMatchesElement: function (domRule, idx) {
     let element = this.viewedElement;
     do {
       if (domUtils.selectorMatchesElement(element, domRule, idx)) {
         return true;
       }
     } while ((element = element.parentNode) &&
-             element.nodeType === Ci.nsIDOMNode.ELEMENT_NODE);
+             element.nodeType === nodeConstants.ELEMENT_NODE);
 
     return false;
   },
 
   /**
    * Check if the highlighted element or it's parents have matched selectors.
    *
    * @param {array} aProperties The list of properties you want to check if they
@@ -647,17 +648,17 @@ CssLogic.prototype = {
       // Add element.style information.
       if (element.style && element.style.length > 0) {
         let rule = new CssRule(null, { style: element.style }, element);
         rule._matchId = this._matchId;
         rule._passId = this._passId;
         this._matchedRules.push([rule, status]);
       }
     } while ((element = element.parentNode) &&
-              element.nodeType === Ci.nsIDOMNode.ELEMENT_NODE);
+              element.nodeType === nodeConstants.ELEMENT_NODE);
   },
 
   /**
    * Tells if the given DOM CSS object matches the current view media.
    *
    * @param {object} domObject The DOM CSS object to check.
    * @return {boolean} True if the DOM CSS object matches the current view
    * media, or false otherwise.
@@ -779,17 +780,17 @@ CssLogic.getBindingElementAndPseudo = fu
  * parent node with the proper pseudo argument.
  *
  * @param {Node}
  * @returns {CSSStyleDeclaration}
  */
 CssLogic.getComputedStyle = function (node) {
   if (!node ||
       Cu.isDeadWrapper(node) ||
-      node.nodeType !== Ci.nsIDOMNode.ELEMENT_NODE ||
+      node.nodeType !== nodeConstants.ELEMENT_NODE ||
       !node.ownerDocument ||
       !node.ownerDocument.defaultView) {
     return null;
   }
 
   let {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node);
   return node.ownerDocument.defaultView.getComputedStyle(bindingElement,
                                                          pseudo);
--- a/devtools/shared/moz.build
+++ b/devtools/shared/moz.build
@@ -42,16 +42,17 @@ DevToolsModules(
     'async-utils.js',
     'builtin-modules.js',
     'content-observer.js',
     'css-lexer.js',
     'css-parsing-utils.js',
     'defer.js',
     'deprecated-sync-thenables.js',
     'DevToolsUtils.js',
+    'dom-node-constants.js',
     'event-emitter.js',
     'event-parsers.js',
     'indentation.js',
     'Loader.jsm',
     'Parser.jsm',
     'path.js',
     'protocol.js',
     'system.js',