Bug 1292253 - replace some Ci uses in view-helpers and TableWidget; r=gregtatum

MozReview-Commit-ID: JIs4wxNA3Eg
This commit is contained in:
Tom Tromey
2016-08-09 09:43:58 -06:00
parent 7466eebd31
commit 6bb49c290c
4 changed files with 20 additions and 16 deletions

View File

@@ -11,13 +11,16 @@
"clearTimeout": true,
"console": true,
"CSS": true,
"DocumentFragment": true,
"DOMParser": true,
"dump": true,
"Element": true,
"exports": true,
"isWorker": true,
"indexedDB": true,
"loader": true,
"module": true,
"Node": true,
"reportError": true,
"require": true,
"setInterval": true,

View File

@@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {Ci} = require("chrome");
const EventEmitter = require("devtools/shared/event-emitter");
loader.lazyRequireGetter(this, "setNamedTimeout",
"devtools/client/shared/widgets/view-helpers", true);
@@ -1350,17 +1349,17 @@ Column.prototype = {
// Only sort the array if we are sorting based on this column
if (this.sorted == 1) {
items.sort((a, b) => {
let val1 = (a[this.id] instanceof Ci.nsIDOMNode) ?
let val1 = (a[this.id] instanceof Node) ?
a[this.id].textContent : a[this.id];
let val2 = (b[this.id] instanceof Ci.nsIDOMNode) ?
let val2 = (b[this.id] instanceof Node) ?
b[this.id].textContent : b[this.id];
return val1 > val2;
});
} else if (this.sorted > 1) {
items.sort((a, b) => {
let val1 = (a[this.id] instanceof Ci.nsIDOMNode) ?
let val1 = (a[this.id] instanceof Node) ?
a[this.id].textContent : a[this.id];
let val2 = (b[this.id] instanceof Ci.nsIDOMNode) ?
let val2 = (b[this.id] instanceof Node) ?
b[this.id].textContent : b[this.id];
return val2 > val1;
});
@@ -1504,18 +1503,18 @@ Cell.prototype = {
return;
}
if (this.wrapTextInElements && !(value instanceof Ci.nsIDOMNode)) {
if (this.wrapTextInElements && !(value instanceof Node)) {
let span = this.label.ownerDocument.createElementNS(HTML_NS, "span");
span.textContent = value;
value = span;
}
if (!(value instanceof Ci.nsIDOMNode) &&
if (!(value instanceof Node) &&
value.length > MAX_VISIBLE_STRING_SIZE) {
value = value .substr(0, MAX_VISIBLE_STRING_SIZE) + "\u2026";
}
if (value instanceof Ci.nsIDOMNode) {
if (value instanceof Node) {
this.label.removeAttribute("value");
while (this.label.firstChild) {

View File

@@ -5,8 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { Ci } = require("chrome");
const PANE_APPEARANCE_DELAY = 50;
const PAGE_SIZE_ITEM_COUNT_RATIO = 5;
const WIDGET_FOCUSABLE_NODES = new Set(["vbox", "hbox"]);
@@ -128,7 +126,7 @@ const ViewHelpers = exports.ViewHelpers = {
* called preventDefault.
*/
dispatchEvent: function (target, type, detail) {
if (!(target instanceof Ci.nsIDOMNode)) {
if (!(target instanceof Node)) {
// Event cancelled.
return true;
}
@@ -190,9 +188,9 @@ const ViewHelpers = exports.ViewHelpers = {
* True if it's a node, false otherwise.
*/
isNode: function (object) {
return object instanceof Ci.nsIDOMNode ||
object instanceof Ci.nsIDOMElement ||
object instanceof Ci.nsIDOMDocumentFragment;
return object instanceof Node ||
object instanceof Element ||
object instanceof DocumentFragment;
},
/**
@@ -792,12 +790,12 @@ const WidgetMethods = exports.WidgetMethods = {
// If the two items were constructed with prebuilt nodes as
// DocumentFragments, then those DocumentFragments are now
// empty and need to be reassembled.
if (firstPrebuiltTarget instanceof Ci.nsIDOMDocumentFragment) {
if (firstPrebuiltTarget instanceof DocumentFragment) {
for (let node of firstTarget.childNodes) {
firstPrebuiltTarget.appendChild(node.cloneNode(true));
}
}
if (secondPrebuiltTarget instanceof Ci.nsIDOMDocumentFragment) {
if (secondPrebuiltTarget instanceof DocumentFragment) {
for (let node of secondTarget.childNodes) {
secondPrebuiltTarget.appendChild(node.cloneNode(true));
}

View File

@@ -234,6 +234,10 @@ const globals = exports.globals = {
.createInstance(Ci.nsIXMLHttpRequest);
},
Node: Ci.nsIDOMNode,
Element: Ci.nsIDOMElement,
DocumentFragment: Ci.nsIDOMDocumentFragment,
// Make sure `define` function exists. This allows defining some modules
// in AMD format while retaining CommonJS compatibility through this hook.
// JSON Viewer needs modules in AMD format, as it currently uses RequireJS