Bug 1281931 - remove some unused Selection methods; r?gregtatum
MozReview-Commit-ID: 9CHYLyH30fp
--- a/devtools/client/framework/selection.js
+++ b/devtools/client/framework/selection.js
@@ -38,20 +38,20 @@ var EventEmitter = require("devtools/sha
* isProcessingInstructionNode()
* isCommentNode()
* isDocumentNode()
* isDocumentTypeNode()
* isDocumentFragmentNode()
* isNotationNode()
*
* Events:
- * "new-node" when the inner node changed
- * "before-new-node" when the inner node is set to change
+ * "new-node-front" when the inner node changed
+ * "before-new-node-front" when the inner node is set to change
* "attribute-changed" when an attribute is changed
- * "detached" when the node (or one of its parents) is removed from
+ * "detached-front" when the node (or one of its parents) is removed from
* the document
* "reparented" when the node (or one of its parents) is moved under
* a different node
*/
/**
* A Selection object. Hold a reference to a node.
* Includes some helpers, fire some helpful events.
@@ -96,22 +96,16 @@ Selection.prototype = {
// Fire our events depending on what changed in the mutations array
if (attributeChange) {
this.emit("attribute-changed");
}
if (pseudoChange) {
this.emit("pseudoclass");
}
if (detached) {
- let rawNode = null;
- if (parentNode && parentNode.isLocalToBeDeprecated()) {
- rawNode = parentNode.rawNode();
- }
-
- this.emit("detached", rawNode, null);
this.emit("detached-front", parentNode);
}
},
destroy: function () {
this.setNode(null);
this.setWalker(null);
},
@@ -135,24 +129,16 @@ Selection.prototype = {
},
// Not remote-safe
get node() {
return this._node;
},
// Not remote-safe
- get window() {
- if (this.isNode()) {
- return this.node.ownerDocument.defaultView;
- }
- return null;
- },
-
- // Not remote-safe
get document() {
if (this.isNode()) {
return this.node.ownerDocument;
}
return null;
},
setNodeFront: function (value, reason = "unknown") {
@@ -166,22 +152,19 @@ Selection.prototype = {
// We used to return here if the node had not changed but we now need to
// set the node even if it is already set otherwise it is not possible to
// e.g. highlight the same node twice.
let rawValue = null;
if (value && value.isLocalToBeDeprecated()) {
rawValue = value.rawNode();
}
- this.emit("before-new-node", rawValue, reason);
this.emit("before-new-node-front", value, reason);
- let previousNode = this._node;
this._node = rawValue;
this._nodeFront = value;
- this.emit("new-node", previousNode, this.reason);
this.emit("new-node-front", value, this.reason);
},
get documentFront() {
return this._walker.document(this._nodeFront);
},
get nodeFront() {
--- a/devtools/client/inspector/computed/computed.js
+++ b/devtools/client/inspector/computed/computed.js
@@ -1414,17 +1414,17 @@ function ComputedViewTool(inspector, win
this.layoutView = new LayoutView(this.inspector, this.document);
this.onSelected = this.onSelected.bind(this);
this.refresh = this.refresh.bind(this);
this.onPanelSelected = this.onPanelSelected.bind(this);
this.onMutations = this.onMutations.bind(this);
this.onResized = this.onResized.bind(this);
- this.inspector.selection.on("detached", this.onSelected);
+ this.inspector.selection.on("detached-front", this.onSelected);
this.inspector.selection.on("new-node-front", this.onSelected);
this.inspector.selection.on("pseudoclass", this.refresh);
this.inspector.sidebar.on("computedview-selected", this.onPanelSelected);
this.inspector.pageStyle.on("stylesheet-updated", this.refresh);
this.inspector.walker.on("mutations", this.onMutations);
this.inspector.walker.on("resize", this.onResized);
this.computedView.selectElement(null);
@@ -1508,17 +1508,17 @@ ComputedViewTool.prototype = {
},
destroy: function () {
this.inspector.walker.off("mutations", this.onMutations);
this.inspector.walker.off("resize", this.onResized);
this.inspector.sidebar.off("computedview-selected", this.refresh);
this.inspector.selection.off("pseudoclass", this.refresh);
this.inspector.selection.off("new-node-front", this.onSelected);
- this.inspector.selection.off("detached", this.onSelected);
+ this.inspector.selection.off("detached-front", this.onSelected);
this.inspector.sidebar.off("computedview-selected", this.onPanelSelected);
if (this.inspector.pageStyle) {
this.inspector.pageStyle.off("stylesheet-updated", this.refresh);
}
this.computedView.destroy();
this.layoutView.destroy();
--- a/devtools/client/inspector/fonts/fonts.js
+++ b/devtools/client/inspector/fonts/fonts.js
@@ -21,17 +21,17 @@ function FontInspector(inspector, window
this.init();
}
FontInspector.prototype = {
init: function () {
this.update = this.update.bind(this);
this.onNewNode = this.onNewNode.bind(this);
this.onThemeChanged = this.onThemeChanged.bind(this);
- this.inspector.selection.on("new-node", this.onNewNode);
+ this.inspector.selection.on("new-node-front", this.onNewNode);
this.inspector.sidebar.on("fontinspector-selected", this.onNewNode);
this.showAll = this.showAll.bind(this);
this.showAllLink = this.chromeDoc.getElementById("font-showall");
this.showAllLink.addEventListener("click", this.showAll);
this.previewTextChanged = this.previewTextChanged.bind(this);
this.previewInput =
this.chromeDoc.getElementById("font-preview-text-input");
this.previewInput.addEventListener("input", this.previewTextChanged);
@@ -51,17 +51,17 @@ FontInspector.prototype = {
},
/**
* Remove listeners.
*/
destroy: function () {
this.chromeDoc = null;
this.inspector.sidebar.off("fontinspector-selected", this.onNewNode);
- this.inspector.selection.off("new-node", this.onNewNode);
+ this.inspector.selection.off("new-node-front", this.onNewNode);
this.showAllLink.removeEventListener("click", this.showAll);
this.previewInput.removeEventListener("input", this.previewTextChanged);
gDevTools.off("theme-switched", this.onThemeChanged);
if (this._previewUpdateTimeout) {
clearTimeout(this._previewUpdateTimeout);
}
--- a/devtools/client/inspector/inspector-panel.js
+++ b/devtools/client/inspector/inspector-panel.js
@@ -791,17 +791,16 @@ InspectorPanel.prototype = {
this.sidebar.off("select", this._setDefaultSidebar);
let sidebarDestroyer = this.sidebar.destroy();
this.sidebar = null;
this.teardownToolbar();
this.breadcrumbs.destroy();
this.selection.off("new-node-front", this.onNewSelection);
- this.selection.off("before-new-node", this.onBeforeNewSelection);
this.selection.off("before-new-node-front", this.onBeforeNewSelection);
this.selection.off("detached-front", this.onDetached);
let markupDestroyer = this._destroyMarkup();
this.panelWin.inspector = null;
this.target = null;
this.panelDoc = null;
this.panelWin = null;
this.breadcrumbs = null;
--- a/devtools/client/inspector/rules/rules.js
+++ b/devtools/client/inspector/rules/rules.js
@@ -1586,17 +1586,17 @@ function RuleViewTool(inspector, window)
this.onPanelSelected = this.onPanelSelected.bind(this);
this.onMutations = this.onMutations.bind(this);
this.onResized = this.onResized.bind(this);
this.view.on("ruleview-changed", this.onPropertyChanged);
this.view.on("ruleview-refreshed", this.onViewRefreshed);
this.view.on("ruleview-linked-clicked", this.onLinkClicked);
- this.inspector.selection.on("detached", this.onSelected);
+ this.inspector.selection.on("detached-front", this.onSelected);
this.inspector.selection.on("new-node-front", this.onSelected);
this.inspector.selection.on("pseudoclass", this.refresh);
this.inspector.target.on("navigate", this.clearUserProperties);
this.inspector.sidebar.on("ruleview-selected", this.onPanelSelected);
this.inspector.pageStyle.on("stylesheet-updated", this.refresh);
this.inspector.walker.on("mutations", this.onMutations);
this.inspector.walker.on("resize", this.onResized);
@@ -1717,17 +1717,17 @@ RuleViewTool.prototype = {
*/
onResized: function () {
this.refresh();
},
destroy: function () {
this.inspector.walker.off("mutations", this.onMutations);
this.inspector.walker.off("resize", this.onResized);
- this.inspector.selection.off("detached", this.onSelected);
+ this.inspector.selection.off("detached-front", this.onSelected);
this.inspector.selection.off("pseudoclass", this.refresh);
this.inspector.selection.off("new-node-front", this.onSelected);
this.inspector.target.off("navigate", this.clearUserProperties);
this.inspector.sidebar.off("ruleview-selected", this.onPanelSelected);
if (this.inspector.pageStyle) {
this.inspector.pageStyle.off("stylesheet-updated", this.refresh);
}