Bug 838518 part 1. Fix treewalker callers per the API change that was made. r=smaug

This commit is contained in:
Boris Zbarsky 2013-02-06 14:22:33 +00:00
Родитель 78c8ab0d60
Коммит 1ee4c73471
29 изменённых файлов: 46 добавлений и 59 удалений

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

@ -3080,7 +3080,7 @@ Accessible::GetFirstAvailableAccessible(nsINode *aStartNode) const
nsCOMPtr<nsIDOMTreeWalker> walker;
domDoc->CreateTreeWalker(rootNode,
nsIDOMNodeFilter::SHOW_ELEMENT | nsIDOMNodeFilter::SHOW_TEXT,
nullptr, false, getter_AddRefs(walker));
nullptr, 1, getter_AddRefs(walker));
NS_ENSURE_TRUE(walker, nullptr);
walker->SetCurrentNode(currentNode);

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

@ -271,7 +271,7 @@ function testNameForElmRule(aElm, aRule)
var treeWalker = document.createTreeWalker(document.body,
NodeFilter.SHOW_ELEMENT,
filter, false);
filter);
labelElm = treeWalker.nextNode();
} else {

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

@ -575,7 +575,7 @@ function processFrames()
if (gFrameList.length) {
var doc = gFrameList[0];
onProcessFrame.forEach(function(func) { func(doc); });
var iterator = doc.createTreeWalker(doc, NodeFilter.SHOW_ELEMENT, grabAll, true);
var iterator = doc.createTreeWalker(doc, NodeFilter.SHOW_ELEMENT, grabAll);
gFrameList.shift();
setTimeout(doGrab, 10, iterator);
onFinished.push(selectImage);

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

@ -121,8 +121,7 @@ MarkupView.prototype = {
return Ci.nsIDOMNodeFilter.FILTER_ACCEPT;
}
return Ci.nsIDOMNodeFilter.FILTER_SKIP;
},
false
}
);
walker.currentNode = this._selectedContainer.elt;
return walker;
@ -1316,7 +1315,7 @@ RootContainer.prototype = {
};
function documentWalker(node) {
return new DocumentWalker(node, Ci.nsIDOMNodeFilter.SHOW_ALL, whitespaceTextFilter, false);
return new DocumentWalker(node, Ci.nsIDOMNodeFilter.SHOW_ALL, whitespaceTextFilter);
}
function nodeDocument(node) {
@ -1329,11 +1328,10 @@ function nodeDocument(node) {
*
* See TreeWalker documentation for explanations of the methods.
*/
function DocumentWalker(aNode, aShow, aFilter, aExpandEntityReferences)
function DocumentWalker(aNode, aShow, aFilter)
{
let doc = nodeDocument(aNode);
this.walker = doc.createTreeWalker(nodeDocument(aNode),
aShow, aFilter, aExpandEntityReferences);
this.walker = doc.createTreeWalker(nodeDocument(aNode), aShow, aFilter);
this.walker.currentNode = aNode;
this.filter = aFilter;
}

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

@ -96,7 +96,7 @@ DOMHelpers.prototype = {
{
let SHOW_ALL = Components.interfaces.nsIDOMNodeFilter.SHOW_ALL;
this.treeWalker = node.ownerDocument.createTreeWalker(node,
SHOW_ALL, null, false);
SHOW_ALL, null);
return this.treeWalker.firstChild();
},

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

@ -1,7 +1,7 @@
<html>
<head>
<script type="text/javascript">
document.createTreeWalker(null, NodeFilter.SHOW_ALL, null, false);
document.createTreeWalker(null, NodeFilter.SHOW_ALL, null);
</script>
</head>
<body>

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

@ -22,7 +22,7 @@ SimpleTest.waitForExplicitFinish();
const SHOW_ALL = Components.interfaces.nsIDOMNodeFilter.SHOW_ALL;
addLoadEvent(function() {
var walker = document.createTreeWalker(document, SHOW_ALL, null, true);
var walker = document.createTreeWalker(document, SHOW_ALL, null);
try {
walker.currentNode = {};
walker.nextNode();

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

@ -457,7 +457,7 @@
}
function check( type, root, expect, fragment ){
var walker = document.createTreeWalker( root, NodeFilter.SHOW_ELEMENT, { acceptNode: function(){ return 1; } }, false );
var walker = document.createTreeWalker( root, NodeFilter.SHOW_ELEMENT, { acceptNode: function(){ return 1; } } );
while ( walker.nextNode() ) {
var div = walker.currentNode;

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

@ -21,7 +21,7 @@ function getName(aNode, f)
function walkDOM()
{
var walker = document.createTreeWalker($('content'), NodeFilter.SHOW_ELEMENT, null, true);
var walker = document.createTreeWalker($('content'), NodeFilter.SHOW_ELEMENT, null);
var output = "";
while (walker.nextNode())
{

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

@ -28,7 +28,7 @@ function do_test()
var body = doc.getElementsByTagName("body")[0];
var filter = NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT;
var walker = doc.createTreeWalker(body, filter, null, false);
var walker = doc.createTreeWalker(body, filter, null);
walker.currentNode = body.firstChild;
walker.nextNode();

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

@ -65,16 +65,14 @@ function filter(node) {
it = document.createTreeWalker(
document.getElementById("nodes"),
NodeFilter.SHOW_ELEMENT,
filter,
false
filter
);
while(it.nextNode());
it = document.createTreeWalker(
document.getElementById("nodes"),
NodeFilter.SHOW_ELEMENT,
filter,
false
filter
);
it.firstChild();
while(it.nextSibling());
@ -82,8 +80,7 @@ function filter(node) {
it = document.createTreeWalker(
document.getElementById("nodes"),
NodeFilter.SHOW_ELEMENT,
filter,
false
filter
);
it.lastChild();
while(it.previousSibling());

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

@ -27,7 +27,7 @@ function testNodeFilter(n) {
tw = document.createTreeWalker(document.getElementById("root"),
NodeFilter.SHOW_ELEMENT,
testNodeFilter, false);
testNodeFilter);
node = tw.firstChild();
is(node.id, 'B', "First accepted child of root not B");

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

@ -87,7 +87,7 @@ function regularWalk()
[ false, "\n" ],
];
var walker = document.createTreeWalker(document.getElementById('content'),
NodeFilter.SHOW_ALL, null, true);
NodeFilter.SHOW_ALL, null);
walkTree(walker);
@ -125,7 +125,7 @@ function noWhiteSpaceWalk()
return NodeFilter.FILTER_REJECT;
return NodeFilter.FILTER_ACCEPT;
}
}, true);
});
walkTree(walker);
@ -148,7 +148,7 @@ function onlyElementsWalk()
[ true, "DIV" ],
];
var walker = document.createTreeWalker(document.getElementById('content'),
NodeFilter.SHOW_ELEMENT, null, true);
NodeFilter.SHOW_ELEMENT, null);
walkTree(walker);
@ -187,7 +187,7 @@ function onlyDivSubTreeWalk()
}
return NodeFilter.FILTER_SKIP;
}
}, true);
});
walkTree(walker);
@ -220,7 +220,7 @@ function onlyDivDataWalk()
return NodeFilter.FILTER_ACCEPT;
return NodeFilter.FILTER_SKIP;
}
}, true);
});
walkTree(walker);

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

@ -80,7 +80,7 @@ testContent();
tw = document.createTreeWalker(document.documentElement,
NodeFilter.SHOW_ELEMENT,
null, false);
null);
e = document.documentElement;
elemsTested = 0;

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

@ -23,8 +23,7 @@ window.addEventListener("load", function() {
var walker = document.createTreeWalker(
document,
nsIDOMNodeFilter.SHOW_TEXT | nsIDOMNodeFilter.SHOW_DOCUMENT,
null,
true
null
);
setPass(walker.firstChild());
while (walker.nextSibling()) {
@ -43,7 +42,7 @@ appear as direct children of the root node, no matter how deeply nested the
structure of the original document.
*/
walker2 = document.createTreeWalker(document, nsIDOMNodeFilter.SHOW_TEXT, null, true);
walker2 = document.createTreeWalker(document, nsIDOMNodeFilter.SHOW_TEXT, null);
while (walker2.nextNode()) {
var cNode = walker2.currentNode;
ok(cNode.getUserData("pass"), "Every text node should appear: " + walker2.currentNode.nodeValue);

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

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650493
<script class="testbody" type="text/javascript">
function getNodes() {
var walker = document.createTreeWalker($('content'), NodeFilter.SHOW_ALL, null, false);
var walker = document.createTreeWalker($('content'), NodeFilter.SHOW_ALL, null);
var nodes = [];
do {
nodes.push(walker.currentNode);
@ -46,7 +46,7 @@ root = $('content');
root.addEventListener("DOMNodeInserted", function(e) {
mutateCount++;
is(e.isTrusted, true, "untrusted mutation event");
var w = document.createTreeWalker(e.target, NodeFilter.SHOW_ALL, null, false);
var w = document.createTreeWalker(e.target, NodeFilter.SHOW_ALL, null);
do {
is(nodes.indexOf(w.currentNode), -1, "already have inserted node (" + w.currentNode + ") when " + testName);
nodes.push(w.currentNode);
@ -55,7 +55,7 @@ root.addEventListener("DOMNodeInserted", function(e) {
root.addEventListener("DOMNodeRemoved", function(e) {
mutateCount++;
is(e.isTrusted, true, "untrusted mutation event");
var w = document.createTreeWalker(e.target, NodeFilter.SHOW_ALL, null, false);
var w = document.createTreeWalker(e.target, NodeFilter.SHOW_ALL, null);
do {
var index = nodes.indexOf(w.currentNode);
ok(index != -1, "missing removed node (" + w.currentNode + ") when " + testName);

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

@ -374,10 +374,10 @@ function test_isEqualNode_wholeDoc()
var doc2 = ParseFile("isequalnode_data.xml");
var tw1 =
doc.createTreeWalker(doc, Components.interfaces.nsIDOMNodeFilter.SHOW_ALL,
null, false);
null);
var tw2 =
doc2.createTreeWalker(doc2, Components.interfaces.nsIDOMNodeFilter.SHOW_ALL,
null, false);
null);
do {
check_eq_nodes(tw1.currentNode, tw2.currentNode);
tw1.nextNode();

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

@ -133,8 +133,7 @@ function evalXPathInDocumentFragment(aContextNode, aPath) {
var walker = aContextNode.ownerDocument.createTreeWalker(
aContextNode,
targetType,
filter,
true);
filter);
var targetNode = walker.nextNode();
do_check_neq(targetNode, null);
@ -187,8 +186,7 @@ function getParsedDocument(aPath) {
var walker = doc.createTreeWalker(doc,
C_i.nsIDOMNodeFilter.SHOW_TEXT |
C_i.nsIDOMNodeFilter.SHOW_CDATA_SECTION,
isWhitespace,
false);
isWhitespace);
while (walker.nextNode()) {
var parent = walker.currentNode.parentNode;
parent.removeChild(walker.currentNode);
@ -279,8 +277,7 @@ function run_extract_test() {
dump("Ensure the original nodes weren't extracted - test " + i + "\n\n");
var walker = doc.createTreeWalker(baseFrag,
C_i.nsIDOMNodeFilter.SHOW_ALL,
null,
false);
null);
var foundStart = false;
var foundEnd = false;
do {
@ -313,8 +310,7 @@ function run_extract_test() {
dump("Ensure the original nodes weren't deleted - test " + i + "\n\n");
walker = doc.createTreeWalker(baseFrag,
C_i.nsIDOMNodeFilter.SHOW_ALL,
null,
false);
null);
foundStart = false;
foundEnd = false;
do {

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

@ -19,7 +19,7 @@ function test_treeWalker_currentNode()
var body = doc.getElementsByTagName("body")[0];
var filter = I.nsIDOMNodeFilter.SHOW_ELEMENT | I.nsIDOMNodeFilter.SHOW_TEXT;
var walker = doc.createTreeWalker(body, filter, null, false);
var walker = doc.createTreeWalker(body, filter, null);
walker.currentNode = body.firstChild;
walker.nextNode();
}

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

@ -147,7 +147,7 @@
"TreeWalker interface: attribute whatToShow": true,
"TreeWalker interface: attribute filter": true,
"TreeWalker interface: attribute currentNode": true,
"Stringification of document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null, false)": "debug",
"Stringification of document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null)": "debug",
"NodeFilter interface: existence and properties of interface object": true,
"NodeFilter interface: existence and properties of interface prototype object": true,
"NodeFilter interface: existence and properties of interface prototype object's \"constructor\" property": true,

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

@ -510,7 +510,7 @@ idlArray.add_objects({
Comment: ['document.createComment("abc")'],
Range: ['document.createRange()', 'detachedRange'],
NodeIterator: ['document.createNodeIterator(document.body, NodeFilter.SHOW_ALL, null, false)'],
TreeWalker: ['document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null, false)'],
TreeWalker: ['document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null)'],
NodeList: ['document.querySelectorAll("script")'],
HTMLCollection: ['document.body.children'],
DOMTokenList: ['document.body.classList'],

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

@ -32,8 +32,7 @@ function test()
if ("foo" + window == "fooPIRATES!")
return NodeFilter.FILTER_ACCEPT;
return NodeFilter.FILTER_REJECT;
},
true);
});
// That should have been enough to create a leak, but we should do at least
// a couple tests while we're here so that this document doesn't show up as

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

@ -1627,7 +1627,7 @@ nsresult nsWebBrowserPersist::SaveDocumentInternal(
nsIDOMNodeFilter::SHOW_ELEMENT |
nsIDOMNodeFilter::SHOW_DOCUMENT |
nsIDOMNodeFilter::SHOW_PROCESSING_INSTRUCTION,
nullptr, true, getter_AddRefs(walker));
nullptr, 1, getter_AddRefs(walker));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMNode> currentNode;

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

@ -23,7 +23,7 @@ window.addEventListener("message", function () { gen.next() }, false);
function go() {
var ifr = $('ifr');
try {
document.createTreeWalker(ifr.contentDocument, 0, null, false);
document.createTreeWalker(ifr.contentDocument, 0, null);
ok(false, "should have thrown a security exception");
} catch (e) {
ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e) ||

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

@ -100,7 +100,7 @@ function test_parser(testlist) {
* @param the DOM document
*/
function docToTestOutput(doc) {
var walker = doc.createTreeWalker(doc, NodeFilter.SHOW_ALL, null, true);
var walker = doc.createTreeWalker(doc, NodeFilter.SHOW_ALL, null);
return addLevels(walker, "", "| ").slice(0,-1); // remove the last newline
}
@ -114,7 +114,7 @@ function fragmentToTestOutput(elt) {
var walker = elt.ownerDocument.createTreeWalker(elt, NodeFilter.SHOW_ALL,
function (node) { return elt == node ?
NodeFilter.FILTER_SKIP :
NodeFilter.FILTER_ACCEPT; }, true);
NodeFilter.FILTER_ACCEPT; });
return addLevels(walker, "", "| ").slice(0,-1); // remove the last newline
}

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

@ -546,7 +546,7 @@ function findLocation(pre, line, node, offset, interlinePosition, result)
// Walk through each of the text nodes and count newlines.
var treewalker = window.content.document
.createTreeWalker(pre, NodeFilter.SHOW_TEXT, null, false);
.createTreeWalker(pre, NodeFilter.SHOW_TEXT, null);
// The column number of the first character in the current text node.
var firstCol = 1;

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

@ -113,7 +113,7 @@
<![CDATA[
var iterator = aSubtree.ownerDocument.createTreeWalker(aSubtree,
NodeFilter.SHOW_ELEMENT,
this.filterButtons, false);
this.filterButtons);
while (iterator.nextNode()) {
var test = iterator.currentNode;
if (test.accessKey.toLowerCase() == aAccessKeyLower &&

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

@ -260,8 +260,7 @@
const nsIDOMNodeFilter = Components.interfaces.nsIDOMNodeFilter;
var iterator = doc.createTreeWalker(this,
nsIDOMNodeFilter.SHOW_ELEMENT,
this._filterRadioGroup,
true);
this._filterRadioGroup);
while (iterator.nextNode())
radioChildren.push(iterator.currentNode);
return this._radioChildren = radioChildren;

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

@ -189,8 +189,7 @@
<![CDATA[
var treeWalker = document.createTreeWalker(this,
NodeFilter.SHOW_TEXT,
null,
true);
null);
var node = treeWalker.nextNode();
while (index >= node.length) {
index -= node.length;