Bug 682366 - Remove nsINode::ChildIterator r=smaug

This commit is contained in:
David Zbarsky 2011-08-27 00:23:02 +01:00
parent 942d20b453
commit 3cba444615
3 changed files with 7 additions and 40 deletions

View File

@ -933,42 +933,6 @@ public:
*/
nsIDocument* GetOwnerDocument() const;
/**
* Iterator that can be used to easily iterate over the children. This has
* the same restrictions on its use as GetChildArray does.
*/
class ChildIterator {
public:
ChildIterator(const nsINode* aNode) { Init(aNode); }
ChildIterator(const nsINode* aNode, PRUint32 aOffset) {
Init(aNode);
Advance(aOffset);
}
~ChildIterator() {
NS_ASSERTION(!mGuard.Mutated(0), "Unexpected mutations happened");
}
PRBool IsDone() const { return mCur == mEnd; }
operator nsIContent*() const { return *mCur; }
void Next() { NS_PRECONDITION(mCur != mEnd, "Check IsDone"); ++mCur; }
void Advance(PRUint32 aOffset) {
NS_ASSERTION(mCur + aOffset <= mEnd, "Unexpected offset");
mCur += aOffset;
}
private:
void Init(const nsINode* aNode) {
NS_PRECONDITION(aNode, "Must have node here!");
PRUint32 childCount;
mCur = aNode->GetChildArray(&childCount);
mEnd = mCur + childCount;
}
#ifdef DEBUG
nsMutationGuard mGuard;
#endif
nsIContent* const * mCur;
nsIContent* const * mEnd;
};
/**
* The default script type (language) ID for this node.
* All nodes must support fetching the default script language.

View File

@ -733,8 +733,10 @@ nsGenericHTMLElement::FireMutationEventsForDirectParsing(nsIDocument* aDoc,
NS_ASSERTION(newChildCount - aOldChildCount >= 0,
"What, some unexpected dom mutation has happened?");
childNodes.SetCapacity(newChildCount - aOldChildCount);
for (nsINode::ChildIterator iter(aDest); !iter.IsDone(); iter.Next()) {
childNodes.AppendElement(iter);
for (nsIContent* child = aDest->GetFirstChild();
child;
child = child->GetNextSibling()) {
childNodes.AppendElement(child);
}
nsGenericElement::FireNodeInserted(aDoc, aDest, childNodes);
}

View File

@ -2127,9 +2127,10 @@ nsXULTemplateBuilder::DetermineMemberVariable(nsIContent* aElement)
{
// recursively iterate over the children looking for an element
// with uri="?..."
for (nsINode::ChildIterator iter(aElement); !iter.IsDone(); iter.Next()) {
for (nsIContent* child = aElement->GetFirstChild();
child;
child = child->GetNextSibling()) {
nsAutoString uri;
nsIContent *child = iter;
child->GetAttr(kNameSpaceID_None, nsGkAtoms::uri, uri);
if (!uri.IsEmpty() && uri[0] == PRUnichar('?')) {
return NS_NewAtom(uri);