Bug 896103 - NodeListActor's items() response has unnecessary nesting. r=harth

--HG--
extra : rebase_source : b589da834403503959b357f91e989b77e47a2d32
This commit is contained in:
Dave Camp 2013-07-21 07:40:43 -07:00
Родитель 9fe8f2876f
Коммит c40cec3d74
1 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -39,6 +39,15 @@
* (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");
@ -505,7 +514,7 @@ types.addDictType("disconnectedNode", {
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", {
@ -513,7 +522,7 @@ types.addDictType("disconnectedNodeArray", {
nodes: "array:domnode",
// Nodes that are needed to connect those nodes to the root.
newNodes: "array:domnode"
newParents: "array:domnode"
});
types.addDictType("dommutation", {});
@ -562,10 +571,10 @@ var NodeListActor = exports.NodeListActor = protocol.ActorClass({
*/
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) },
@ -577,20 +586,20 @@ var NodeListActor = exports.NodeListActor = protocol.ActorClass({
*/
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 })
@ -1199,7 +1208,7 @@ var WalkerActor = protocol.ActorClass({
let newParents = this.ensurePathToRoot(node);
return {
node: node,
newNodes: [parent for (parent of newParents)]
newParents: [parent for (parent of newParents)]
}
}, {
request: {