Bug 896103 - NodeListActor's items() response has unnecessary nesting. r=harth
authorDave Camp <dcamp@mozilla.com>
Sun, 21 Jul 2013 07:40:43 -0700
changeset 151785 05ff12c00114de0b595cab891fb42336753b8462
parent 151612 2268ff80683a5fbdfbda4219b55af2a112c9f71b
child 151786 ae533570671023e238c9d21df033034060999935
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersharth
bugs896103
milestone25.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 896103 - NodeListActor's items() response has unnecessary nesting. r=harth
toolkit/devtools/server/actors/inspector.js
--- a/toolkit/devtools/server/actors/inspector.js
+++ b/toolkit/devtools/server/actors/inspector.js
@@ -34,16 +34,25 @@
  * attributes, etc.  Other questions (like a text node's full nodeValue)
  * might require another round trip.
  *
  * The protocol guarantees that the client will always know the parent of
  * any node that is returned by the server.  This means that some requests
  * (like querySelector) will include the extra nodes needed to satisfy this
  * requirement.  The client keeps track of this parent relationship, so the
  * node fronts form a tree that is a subset of the actual DOM tree.
+ *
+ *
+ * We maintain this guarantee to support the ability to release subtrees on
+ * the client - when a node is disconnected from the DOM tree we want to be
+ * able to free the client objects for all the children nodes.
+ *
+ * So to be able to answer "all the children of a given node that we have
+ * seen on the client side", we guarantee that every time we've seen a node,
+ * we connect it up through its parents.
  */
 
 const {Cc, Ci, Cu} = require("chrome");
 
 const protocol = require("devtools/server/protocol");
 const {Arg, Option, method, RetVal, types} = protocol;
 const {LongStringActor, ShortLongString} = require("devtools/server/actors/string");
 const promise = require("sdk/core/promise");
@@ -500,25 +509,25 @@ let NodeFront = protocol.FrontClass(Node
  * Returned from any call that might return a node that isn't connected to root by
  * nodes the child has seen, such as querySelector.
  */
 types.addDictType("disconnectedNode", {
   // The actual node to return
   node: "domnode",
 
   // Nodes that are needed to connect the node to a node the client has already seen
-  newNodes: "array:domnode"
+  newParents: "array:domnode"
 });
 
 types.addDictType("disconnectedNodeArray", {
   // The actual node list to return
   nodes: "array:domnode",
 
   // Nodes that are needed to connect those nodes to the root.
-  newNodes: "array:domnode"
+  newParents: "array:domnode"
 });
 
 types.addDictType("dommutation", {});
 
 /**
  * Server side of a node list as returned by querySelectorAll()
  */
 var NodeListActor = exports.NodeListActor = protocol.ActorClass({
@@ -557,45 +566,45 @@ var NodeListActor = exports.NodeListActo
     }
   },
 
   /**
    * Get a single node from the node list.
    */
   item: method(function(index) {
     let node = this.walker._ref(this.nodeList[index]);
-    let newNodes = [node for (node of this.walker.ensurePathToRoot(node))];
+    let newParents = [node for (node of this.walker.ensurePathToRoot(node))];
     return {
       node: node,
-      newNodes: newNodes
+      newParents: newParents
     }
   }, {
     request: { item: Arg(0) },
     response: RetVal("disconnectedNode")
   }),
 
   /**
    * Get a range of the items from the node list.
    */
   items: method(function(start=0, end=this.nodeList.length) {
     let items = [this.walker._ref(item) for (item of Array.prototype.slice.call(this.nodeList, start, end))];
-    let newNodes = new Set();
+    let newParents = new Set();
     for (let item of items) {
-      this.walker.ensurePathToRoot(item, newNodes);
+      this.walker.ensurePathToRoot(item, newParents);
     }
     return {
       nodes: items,
-      newNodes: [node for (node of newNodes)]
+      newParents: [node for (node of newParents)]
     }
   }, {
     request: {
       start: Arg(0, "number", { optional: true }),
       end: Arg(1, "number", { optional: true })
     },
-    response: { nodes: RetVal("disconnectedNodeArray") }
+    response: RetVal("disconnectedNodeArray")
   }),
 
   release: method(function() {}, { release: true })
 });
 
 /**
  * Client side of a node list as returned by querySelectorAll()
  */
@@ -1194,17 +1203,17 @@ var WalkerActor = protocol.ActorClass({
       return {
       }
     };
 
     let node = this._ref(node);
     let newParents = this.ensurePathToRoot(node);
     return {
       node: node,
-      newNodes: [parent for (parent of newParents)]
+      newParents: [parent for (parent of newParents)]
     }
   }, {
     request: {
       node: Arg(0, "domnode"),
       selector: Arg(1)
     },
     response: RetVal("disconnectedNode")
   }),