Bug 474369 - get rid of nsVoidArray, content part; r=jwatt, sr=sicking

This commit is contained in:
Arpad Borsos 2009-03-20 09:15:35 +01:00
parent 90ab2fa166
commit 8dc04b2fe9
69 changed files with 464 additions and 505 deletions

View File

@ -99,7 +99,6 @@ class nsIRunnable;
class nsIInterfaceRequestor;
template<class E> class nsCOMArray;
class nsIPref;
class nsVoidArray;
struct JSRuntime;
class nsICaseConversion;
class nsIUGenCategory;
@ -212,12 +211,9 @@ public:
/*
* This method fills the |aArray| with all ancestor nodes of |aNode|
* including |aNode| at the zero index.
*
* These elements were |nsIDOMNode*|s before casting to |void*| and must
* be cast back to |nsIDOMNode*| on usage, or bad things will happen.
*/
static nsresult GetAncestors(nsIDOMNode* aNode,
nsVoidArray* aArray);
nsTArray<nsIDOMNode*>* aArray);
/*
* This method fills |aAncestorNodes| with all ancestor nodes of |aNode|
@ -225,16 +221,12 @@ public:
* For each ancestor, there is a corresponding element in |aAncestorOffsets|
* which is the IndexOf the child in relation to its parent.
*
* The elements of |aAncestorNodes| were |nsIContent*|s before casting to
* |void*| and must be cast back to |nsIContent*| on usage, or bad things
* will happen.
*
* This method just sucks.
*/
static nsresult GetAncestorsAndOffsets(nsIDOMNode* aNode,
PRInt32 aOffset,
nsVoidArray* aAncestorNodes,
nsVoidArray* aAncestorOffsets);
nsTArray<nsIContent*>* aAncestorNodes,
nsTArray<PRInt32>* aAncestorOffsets);
/*
* The out parameter, |aCommonAncestor| will be the closest node, if any,
@ -837,7 +829,7 @@ public:
static nsresult ReleasePtrOnShutdown(nsISupports** aSupportsPtr) {
NS_ASSERTION(aSupportsPtr, "Expect to crash!");
NS_ASSERTION(*aSupportsPtr, "Expect to crash!");
return sPtrsToPtrsToRelease->AppendElement(aSupportsPtr) ? NS_OK :
return sPtrsToPtrsToRelease->AppendElement(aSupportsPtr) != nsnull ? NS_OK :
NS_ERROR_OUT_OF_MEMORY;
}
@ -1463,7 +1455,7 @@ private:
static nsIUGenCategory* sGenCat;
// Holds pointers to nsISupports* that should be released at shutdown
static nsVoidArray* sPtrsToPtrsToRelease;
static nsTArray<nsISupports**>* sPtrsToPtrsToRelease;
static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND];
static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND];

View File

@ -48,7 +48,6 @@
class nsIAtom;
class nsIDocument;
class nsPresContext;
class nsVoidArray;
class nsIDOMEvent;
class nsIContent;
class nsIEventListenerManager;

View File

@ -59,7 +59,6 @@ class nsEventChainPreVisitor;
class nsEventChainPostVisitor;
class nsIEventListenerManager;
class nsIPrincipal;
class nsVoidArray;
class nsIMutationObserver;
class nsChildContentList;
class nsNodeWeakReference;

View File

@ -39,9 +39,11 @@
#ifndef nsXMLNameSpaceMap_h_
#define nsXMLNameSpaceMap_h_
#include "nsVoidArray.h"
#include "nsString.h"
#include "nsTArray.h"
class nsIAtom;
class nsNameSpaceEntry;
/**
* nsXMLNameSpaceMap contains a set of prefixes which are mapped onto
@ -94,7 +96,7 @@ public:
private:
nsXMLNameSpaceMap() NS_HIDDEN; // use Create() to create new instances
nsVoidArray mNameSpaces;
nsTArray<nsNameSpaceEntry*> mNameSpaces;
};
#endif

View File

@ -47,7 +47,7 @@
#include "nsIComponentManager.h"
#include "nsContentCID.h"
#include "nsLayoutCID.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsContentUtils.h"
#include "nsINode.h"
@ -155,19 +155,19 @@ public:
protected:
nsINode* GetDeepFirstChild(nsINode *aRoot, nsVoidArray *aIndexes);
nsINode* GetDeepLastChild(nsINode *aRoot, nsVoidArray *aIndexes);
nsINode* GetDeepFirstChild(nsINode *aRoot, nsTArray<PRInt32> *aIndexes);
nsINode* GetDeepLastChild(nsINode *aRoot, nsTArray<PRInt32> *aIndexes);
// Get the next sibling of aNode. Note that this will generally return null
// if aNode happens not to be a content node. That's OK.
nsINode* GetNextSibling(nsINode *aNode, nsVoidArray *aIndexes);
nsINode* GetNextSibling(nsINode *aNode, nsTArray<PRInt32> *aIndexes);
// Get the prev sibling of aNode. Note that this will generally return null
// if aNode happens not to be a content node. That's OK.
nsINode* GetPrevSibling(nsINode *aNode, nsVoidArray *aIndexes);
nsINode* GetPrevSibling(nsINode *aNode, nsTArray<PRInt32> *aIndexes);
nsINode* NextNode(nsINode *aNode, nsVoidArray *aIndexes);
nsINode* PrevNode(nsINode *aNode, nsVoidArray *aIndexes);
nsINode* NextNode(nsINode *aNode, nsTArray<PRInt32> *aIndexes);
nsINode* PrevNode(nsINode *aNode, nsTArray<PRInt32> *aIndexes);
// WARNING: This function is expensive
nsresult RebuildIndexStack();
@ -180,7 +180,7 @@ protected:
nsCOMPtr<nsINode> mCommonParent;
// used by nsContentIterator to cache indices
nsAutoVoidArray mIndexes;
nsAutoTArray<PRInt32, 8> mIndexes;
// used by nsSubtreeIterator to cache indices. Why put them in the base class?
// Because otherwise I have to duplicate the routines GetNextSibling etc across both classes,
@ -539,7 +539,7 @@ nsresult nsContentIterator::RebuildIndexStack()
if (!parent)
return NS_ERROR_FAILURE;
mIndexes.InsertElementAt(NS_INT32_TO_PTR(parent->IndexOf(current)), 0);
mIndexes.InsertElementAt(0, parent->IndexOf(current));
current = parent;
}
@ -558,7 +558,8 @@ nsContentIterator::MakeEmpty()
}
nsINode*
nsContentIterator::GetDeepFirstChild(nsINode *aRoot, nsVoidArray *aIndexes)
nsContentIterator::GetDeepFirstChild(nsINode *aRoot,
nsTArray<PRInt32> *aIndexes)
{
if (!aRoot) {
return nsnull;
@ -572,7 +573,7 @@ nsContentIterator::GetDeepFirstChild(nsINode *aRoot, nsVoidArray *aIndexes)
if (aIndexes)
{
// Add this node to the stack of indexes
aIndexes->AppendElement(NS_INT32_TO_PTR(0));
aIndexes->AppendElement(0);
}
n = nChild;
nChild = n->GetChildAt(0);
@ -582,7 +583,7 @@ nsContentIterator::GetDeepFirstChild(nsINode *aRoot, nsVoidArray *aIndexes)
}
nsINode*
nsContentIterator::GetDeepLastChild(nsINode *aRoot, nsVoidArray *aIndexes)
nsContentIterator::GetDeepLastChild(nsINode *aRoot, nsTArray<PRInt32> *aIndexes)
{
if (!aRoot) {
return nsnull;
@ -600,7 +601,7 @@ nsContentIterator::GetDeepLastChild(nsINode *aRoot, nsVoidArray *aIndexes)
if (aIndexes)
{
// Add this node to the stack of indexes
aIndexes->AppendElement(NS_INT32_TO_PTR(numChildren));
aIndexes->AppendElement(numChildren);
}
numChildren = nChild->GetChildCount();
n = nChild;
@ -614,7 +615,7 @@ nsContentIterator::GetDeepLastChild(nsINode *aRoot, nsVoidArray *aIndexes)
// Get the next sibling, or parents next sibling, or grandpa's next sibling...
nsINode *
nsContentIterator::GetNextSibling(nsINode *aNode,
nsVoidArray *aIndexes)
nsTArray<PRInt32> *aIndexes)
{
if (!aNode)
return nsnull;
@ -623,13 +624,14 @@ nsContentIterator::GetNextSibling(nsINode *aNode,
if (!parent)
return nsnull;
PRInt32 indx;
PRInt32 indx = 0;
if (aIndexes)
NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
"ContentIterator stack underflow");
if (aIndexes && !aIndexes->IsEmpty())
{
NS_ASSERTION(aIndexes->Count() > 0, "ContentIterator stack underflow");
// use the last entry on the Indexes array for the current index
indx = NS_PTR_TO_INT32((*aIndexes)[aIndexes->Count()-1]);
indx = (*aIndexes)[aIndexes->Length()-1];
}
else
indx = mCachedIndex;
@ -648,9 +650,9 @@ nsContentIterator::GetNextSibling(nsINode *aNode,
if ((sib = parent->GetChildAt(++indx)))
{
// update index cache
if (aIndexes)
if (aIndexes && !aIndexes->IsEmpty())
{
aIndexes->ReplaceElementAt(NS_INT32_TO_PTR(indx),aIndexes->Count()-1);
aIndexes->ElementAt(aIndexes->Length()-1) = indx;
}
else mCachedIndex = indx;
}
@ -663,8 +665,8 @@ nsContentIterator::GetNextSibling(nsINode *aNode,
// pop node off the stack, go up one level and return parent or fail.
// Don't leave the index empty, especially if we're
// returning NULL. This confuses other parts of the code.
if (aIndexes->Count() > 1)
aIndexes->RemoveElementAt(aIndexes->Count()-1);
if (aIndexes->Length() > 1)
aIndexes->RemoveElementAt(aIndexes->Length()-1);
}
}
@ -678,7 +680,7 @@ nsContentIterator::GetNextSibling(nsINode *aNode,
// Get the prev sibling, or parents prev sibling, or grandpa's prev sibling...
nsINode*
nsContentIterator::GetPrevSibling(nsINode *aNode,
nsVoidArray *aIndexes)
nsTArray<PRInt32> *aIndexes)
{
if (!aNode)
return nsnull;
@ -687,13 +689,14 @@ nsContentIterator::GetPrevSibling(nsINode *aNode,
if (!parent)
return nsnull;
PRInt32 indx;
PRInt32 indx = 0;
if (aIndexes)
NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
"ContentIterator stack underflow");
if (aIndexes && !aIndexes->IsEmpty())
{
NS_ASSERTION(aIndexes->Count() > 0, "ContentIterator stack underflow");
// use the last entry on the Indexes array for the current index
indx = NS_PTR_TO_INT32((*aIndexes)[aIndexes->Count()-1]);
indx = (*aIndexes)[aIndexes->Length()-1];
}
else
indx = mCachedIndex;
@ -711,18 +714,18 @@ nsContentIterator::GetPrevSibling(nsINode *aNode,
if (indx > 0 && (sib = parent->GetChildAt(--indx)))
{
// update index cache
if (aIndexes)
if (aIndexes && !aIndexes->IsEmpty())
{
aIndexes->ReplaceElementAt(NS_INT32_TO_PTR(indx),aIndexes->Count()-1);
aIndexes->ElementAt(aIndexes->Length()-1) = indx;
}
else mCachedIndex = indx;
}
else if (parent != mCommonParent)
{
if (aIndexes)
if (aIndexes && !aIndexes->IsEmpty())
{
// pop node off the stack, go up one level and try again.
aIndexes->RemoveElementAt(aIndexes->Count()-1);
aIndexes->RemoveElementAt(aIndexes->Length()-1);
}
return GetPrevSibling(parent, aIndexes);
}
@ -731,7 +734,7 @@ nsContentIterator::GetPrevSibling(nsINode *aNode,
}
nsINode*
nsContentIterator::NextNode(nsINode *aNode, nsVoidArray *aIndexes)
nsContentIterator::NextNode(nsINode *aNode, nsTArray<PRInt32> *aIndexes)
{
nsINode *n = aNode;
nsINode *nextNode = nsnull;
@ -747,7 +750,7 @@ nsContentIterator::NextNode(nsINode *aNode, nsVoidArray *aIndexes)
if (aIndexes)
{
// push an entry on the index stack
aIndexes->AppendElement(NS_INT32_TO_PTR(0));
aIndexes->AppendElement(0);
}
else mCachedIndex = 0;
@ -761,14 +764,15 @@ nsContentIterator::NextNode(nsINode *aNode, nsVoidArray *aIndexes)
{
nsINode *parent = n->GetNodeParent();
nsINode *nSibling = nsnull;
PRInt32 indx;
PRInt32 indx = 0;
// get the cached index
if (aIndexes)
NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
"ContentIterator stack underflow");
if (aIndexes && !aIndexes->IsEmpty())
{
NS_ASSERTION(aIndexes->Count() > 0, "ContentIterator stack underflow");
// use the last entry on the Indexes array for the current index
indx = NS_PTR_TO_INT32((*aIndexes)[aIndexes->Count()-1]);
indx = (*aIndexes)[aIndexes->Length()-1];
}
else indx = mCachedIndex;
@ -788,10 +792,10 @@ nsContentIterator::NextNode(nsINode *aNode, nsVoidArray *aIndexes)
if (nSibling)
{
// update cache
if (aIndexes)
if (aIndexes && !aIndexes->IsEmpty())
{
// replace an entry on the index stack
aIndexes->ReplaceElementAt(NS_INT32_TO_PTR(indx),aIndexes->Count()-1);
aIndexes->ElementAt(aIndexes->Length()-1) = indx;
}
else mCachedIndex = indx;
@ -806,8 +810,8 @@ nsContentIterator::NextNode(nsINode *aNode, nsVoidArray *aIndexes)
// pop an entry off the index stack
// Don't leave the index empty, especially if we're
// returning NULL. This confuses other parts of the code.
if (aIndexes->Count() > 1)
aIndexes->RemoveElementAt(aIndexes->Count()-1);
if (aIndexes->Length() > 1)
aIndexes->RemoveElementAt(aIndexes->Length()-1);
}
else mCachedIndex = 0; // this might be wrong, but we are better off guessing
nextNode = parent;
@ -817,7 +821,7 @@ nsContentIterator::NextNode(nsINode *aNode, nsVoidArray *aIndexes)
}
nsINode*
nsContentIterator::PrevNode(nsINode *aNode, nsVoidArray *aIndexes)
nsContentIterator::PrevNode(nsINode *aNode, nsTArray<PRInt32> *aIndexes)
{
nsINode *prevNode = nsnull;
nsINode *n = aNode;
@ -826,14 +830,15 @@ nsContentIterator::PrevNode(nsINode *aNode, nsVoidArray *aIndexes)
{
nsINode *parent = n->GetNodeParent();
nsINode *nSibling = nsnull;
PRInt32 indx;
PRInt32 indx = 0;
// get the cached index
if (aIndexes)
NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
"ContentIterator stack underflow");
if (aIndexes && !aIndexes->IsEmpty())
{
NS_ASSERTION(aIndexes->Count() > 0, "ContentIterator stack underflow");
// use the last entry on the Indexes array for the current index
indx = NS_PTR_TO_INT32((*aIndexes)[aIndexes->Count()-1]);
indx = (*aIndexes)[aIndexes->Length()-1];
}
else indx = mCachedIndex;
@ -853,10 +858,10 @@ nsContentIterator::PrevNode(nsINode *aNode, nsVoidArray *aIndexes)
if (indx && (nSibling = parent->GetChildAt(--indx)))
{
// update cache
if (aIndexes)
if (aIndexes && !aIndexes->IsEmpty())
{
// replace an entry on the index stack
aIndexes->ReplaceElementAt(NS_INT32_TO_PTR(indx),aIndexes->Count()-1);
aIndexes->ElementAt(aIndexes->Length()-1) = indx;
}
else mCachedIndex = indx;
@ -866,10 +871,10 @@ nsContentIterator::PrevNode(nsINode *aNode, nsVoidArray *aIndexes)
// else it's the parent
// update cache
if (aIndexes)
if (aIndexes && !aIndexes->IsEmpty())
{
// pop an entry off the index stack
aIndexes->RemoveElementAt(aIndexes->Count()-1);
aIndexes->RemoveElementAt(aIndexes->Length()-1);
}
else mCachedIndex = 0; // this might be wrong, but we are better off guessing
prevNode = parent;
@ -887,7 +892,7 @@ nsContentIterator::PrevNode(nsINode *aNode, nsVoidArray *aIndexes)
if (aIndexes)
{
// push an entry on the index stack
aIndexes->AppendElement(NS_INT32_TO_PTR(numChildren));
aIndexes->AppendElement(numChildren);
}
else mCachedIndex = numChildren;
@ -1043,8 +1048,8 @@ nsContentIterator::PositionAt(nsINode* aCurNode)
// We can be at ANY node in the sequence.
// Need to regenerate the array of indexes back to the root or common parent!
nsAutoVoidArray oldParentStack;
nsAutoVoidArray newIndexes;
nsAutoTArray<nsINode*, 8> oldParentStack;
nsAutoTArray<PRInt32, 8> newIndexes;
// Get a list of the parents up to the root, then compare the new node
// with entries in that array until we find a match (lowest common
@ -1055,17 +1060,17 @@ nsContentIterator::PositionAt(nsINode* aCurNode)
// we know the depth we're down (though we may not have started at the
// top).
if (!oldParentStack.SizeTo(mIndexes.Count()+1))
if (!oldParentStack.SetCapacity(mIndexes.Length()+1))
return NS_ERROR_FAILURE;
// We want to loop mIndexes.Count() + 1 times here, because we want to make
// We want to loop mIndexes.Length() + 1 times here, because we want to make
// sure we include mCommonParent in the oldParentStack, for use in the next
// for loop, and mIndexes only has entries for nodes from tempNode up through
// an ancestor of tempNode that's a child of mCommonParent.
for (PRInt32 i = mIndexes.Count()+1; i > 0 && tempNode; i--)
for (PRInt32 i = mIndexes.Length()+1; i > 0 && tempNode; i--)
{
// Insert at head since we're walking up
oldParentStack.InsertElementAt(tempNode,0);
oldParentStack.InsertElementAt(0, tempNode);
nsINode *parent = tempNode->GetNodeParent();
@ -1076,8 +1081,8 @@ nsContentIterator::PositionAt(nsINode* aCurNode)
{
// The position was moved to a parent of the current position.
// All we need to do is drop some indexes. Shortcut here.
mIndexes.RemoveElementsAt(mIndexes.Count() - oldParentStack.Count(),
oldParentStack.Count());
mIndexes.RemoveElementsAt(mIndexes.Length() - oldParentStack.Length(),
oldParentStack.Length());
mIsDone = PR_FALSE;
return NS_OK;
}
@ -1095,7 +1100,7 @@ nsContentIterator::PositionAt(nsINode* aCurNode)
PRInt32 indx = parent->IndexOf(newCurNode);
// insert at the head!
newIndexes.InsertElementAt(NS_INT32_TO_PTR(indx),0);
newIndexes.InsertElementAt(0, indx);
// look to see if the parent is in the stack
indx = oldParentStack.IndexOf(parent);
@ -1103,12 +1108,12 @@ nsContentIterator::PositionAt(nsINode* aCurNode)
{
// ok, the parent IS on the old stack! Rework things.
// we want newIndexes to replace all nodes equal to or below the match
// Note that index oldParentStack.Count()-1 is the last node, which is
// Note that index oldParentStack.Length()-1 is the last node, which is
// one BELOW the last index in the mIndexes stack. In other words, we
// want to remove elements starting at index (indx+1).
PRInt32 numToDrop = oldParentStack.Count()-(1+indx);
PRInt32 numToDrop = oldParentStack.Length()-(1+indx);
if (numToDrop > 0)
mIndexes.RemoveElementsAt(mIndexes.Count() - numToDrop,numToDrop);
mIndexes.RemoveElementsAt(mIndexes.Length() - numToDrop, numToDrop);
mIndexes.AppendElements(newIndexes);
break;
@ -1190,12 +1195,12 @@ protected:
nsCOMPtr<nsIDOMRange> mRange;
// these arrays all typically are used and have elements
#if 0
nsAutoVoidArray mStartNodes;
nsAutoVoidArray mStartOffsets;
nsAutoTArray<nsIContent*, 8> mStartNodes;
nsAutoTArray<PRInt32, 8> mStartOffsets;
#endif
nsAutoVoidArray mEndNodes;
nsAutoVoidArray mEndOffsets;
nsAutoTArray<nsIContent*, 8> mEndNodes;
nsAutoTArray<PRInt32, 8> mEndOffsets;
};
nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aInstancePtrResult);

View File

@ -204,7 +204,7 @@ nsILineBreaker *nsContentUtils::sLineBreaker;
nsIWordBreaker *nsContentUtils::sWordBreaker;
nsICaseConversion *nsContentUtils::sCaseConv;
nsIUGenCategory *nsContentUtils::sGenCat;
nsVoidArray *nsContentUtils::sPtrsToPtrsToRelease;
nsTArray<nsISupports**> *nsContentUtils::sPtrsToPtrsToRelease;
nsIScriptRuntime *nsContentUtils::sScriptRuntimes[NS_STID_ARRAY_UBOUND];
PRInt32 nsContentUtils::sScriptRootCount[NS_STID_ARRAY_UBOUND];
PRUint32 nsContentUtils::sJSGCThingRootCount;
@ -328,7 +328,7 @@ nsContentUtils::Init()
sImgLoader = nsnull;
}
sPtrsToPtrsToRelease = new nsVoidArray();
sPtrsToPtrsToRelease = new nsTArray<nsISupports**>();
if (!sPtrsToPtrsToRelease) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -865,8 +865,8 @@ nsContentUtils::Shutdown()
NS_IF_RELEASE(sContentPolicyService);
sTriedToGetContentPolicy = PR_FALSE;
PRInt32 i;
for (i = 0; i < PRInt32(PropertiesFile_COUNT); ++i)
PRUint32 i;
for (i = 0; i < PropertiesFile_COUNT; ++i)
NS_IF_RELEASE(sStringBundles[i]);
NS_IF_RELEASE(sStringBundleService);
NS_IF_RELEASE(sConsoleService);
@ -896,9 +896,8 @@ nsContentUtils::Shutdown()
sEventTable = nsnull;
if (sPtrsToPtrsToRelease) {
for (i = 0; i < sPtrsToPtrsToRelease->Count(); ++i) {
nsISupports** ptrToPtr =
static_cast<nsISupports**>(sPtrsToPtrsToRelease->ElementAt(i));
for (i = 0; i < sPtrsToPtrsToRelease->Length(); ++i) {
nsISupports** ptrToPtr = sPtrsToPtrsToRelease->ElementAt(i);
NS_RELEASE(*ptrToPtr);
}
delete sPtrsToPtrsToRelease;
@ -1400,7 +1399,7 @@ nsContentUtils::ContentIsDescendantOf(nsINode* aPossibleDescendant,
// static
nsresult
nsContentUtils::GetAncestors(nsIDOMNode* aNode,
nsVoidArray* aArray)
nsTArray<nsIDOMNode*>* aArray)
{
NS_ENSURE_ARG_POINTER(aNode);
@ -1420,8 +1419,8 @@ nsContentUtils::GetAncestors(nsIDOMNode* aNode,
nsresult
nsContentUtils::GetAncestorsAndOffsets(nsIDOMNode* aNode,
PRInt32 aOffset,
nsVoidArray* aAncestorNodes,
nsVoidArray* aAncestorOffsets)
nsTArray<nsIContent*>* aAncestorNodes,
nsTArray<PRInt32>* aAncestorOffsets)
{
NS_ENSURE_ARG_POINTER(aNode);
@ -1431,26 +1430,26 @@ nsContentUtils::GetAncestorsAndOffsets(nsIDOMNode* aNode,
return NS_ERROR_FAILURE;
}
if (aAncestorNodes->Count() != 0) {
if (!aAncestorNodes->IsEmpty()) {
NS_WARNING("aAncestorNodes is not empty");
aAncestorNodes->Clear();
}
if (aAncestorOffsets->Count() != 0) {
if (!aAncestorOffsets->IsEmpty()) {
NS_WARNING("aAncestorOffsets is not empty");
aAncestorOffsets->Clear();
}
// insert the node itself
aAncestorNodes->AppendElement(content.get());
aAncestorOffsets->AppendElement(NS_INT32_TO_PTR(aOffset));
aAncestorOffsets->AppendElement(aOffset);
// insert all the ancestors
nsIContent* child = content;
nsIContent* parent = child->GetParent();
while (parent) {
aAncestorNodes->AppendElement(parent);
aAncestorOffsets->AppendElement(NS_INT32_TO_PTR(parent->IndexOf(child)));
aAncestorOffsets->AppendElement(parent->IndexOf(child));
child = parent;
parent = parent->GetParent();
}

View File

@ -47,7 +47,6 @@
#include "nsIDOMDOMStringList.h"
#include "nsIDOMNameList.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsString.h"

View File

@ -2821,11 +2821,10 @@ nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
}
#endif
PRInt32 n = mCharSetObservers.Count();
PRInt32 n = mCharSetObservers.Length();
for (PRInt32 i = 0; i < n; i++) {
nsIObserver* observer =
static_cast<nsIObserver *>(mCharSetObservers.ElementAt(i));
nsIObserver* observer = mCharSetObservers.ElementAt(i);
observer->Observe(static_cast<nsIDocument *>(this), "charset",
NS_ConvertASCIItoUTF16(aCharSetID).get());

View File

@ -49,6 +49,7 @@
#include "nsWeakReference.h"
#include "nsWeakPtr.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsHashSets.h"
#include "nsIDOMXMLDocument.h"
#include "nsIDOM3Document.h"
@ -1099,7 +1100,7 @@ protected:
nsCString mReferrer;
nsString mLastModified;
nsVoidArray mCharSetObservers;
nsTArray<nsIObserver*> mCharSetObservers;
PLDHashTable *mSubDocuments;

View File

@ -76,6 +76,7 @@
#include "nsContentUtils.h"
#include "nsUnicharUtils.h"
#include "nsReadableUtils.h"
#include "nsTArray.h"
nsresult NS_NewDomSelection(nsISelection **aDomSelection);
@ -109,9 +110,9 @@ protected:
nsIDOMNode* aNode,
nsAString& aString,
PRInt32 aDepth);
nsresult SerializeRangeContextStart(const nsVoidArray& aAncestorArray,
nsresult SerializeRangeContextStart(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsAString& aString);
nsresult SerializeRangeContextEnd(const nsVoidArray& aAncestorArray,
nsresult SerializeRangeContextEnd(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsAString& aString);
nsresult FlushText(nsAString& aString, PRBool aForce);
@ -139,11 +140,11 @@ protected:
PRUint32 mEndDepth;
PRInt32 mStartRootIndex;
PRInt32 mEndRootIndex;
nsAutoVoidArray mCommonAncestors;
nsAutoVoidArray mStartNodes;
nsAutoVoidArray mStartOffsets;
nsAutoVoidArray mEndNodes;
nsAutoVoidArray mEndOffsets;
nsAutoTArray<nsIDOMNode*, 8> mCommonAncestors;
nsAutoTArray<nsIContent*, 8> mStartNodes;
nsAutoTArray<PRInt32, 8> mStartOffsets;
nsAutoTArray<nsIContent*, 8> mEndNodes;
nsAutoTArray<PRInt32, 8> mEndOffsets;
PRPackedBool mHaltRangeHint;
PRPackedBool mIsCopying; // Set to PR_TRUE only while copying
PRPackedBool mNodeIsContainer;
@ -542,18 +543,18 @@ static PRInt32 IndexOf(nsIDOMNode* aParent, nsIDOMNode* aChild)
return parent->IndexOf(child);
}
static inline PRInt32 GetIndex(nsVoidArray& aIndexArray)
static inline PRInt32 GetIndex(nsTArray<PRInt32>& aIndexArray)
{
PRInt32 count = aIndexArray.Count();
PRInt32 count = aIndexArray.Length();
if (count) {
return (PRInt32)aIndexArray.ElementAt(count - 1);
return aIndexArray.ElementAt(count - 1);
}
return 0;
}
static nsresult GetNextNode(nsIDOMNode* aNode, nsVoidArray& aIndexArray,
static nsresult GetNextNode(nsIDOMNode* aNode, nsTArray<PRInt32>& aIndexArray,
nsIDOMNode*& aNextNode,
nsRangeIterationDirection& aDirection)
{
@ -567,7 +568,7 @@ static nsresult GetNextNode(nsIDOMNode* aNode, nsVoidArray& aIndexArray,
ChildAt(aNode, 0, aNextNode);
NS_ENSURE_TRUE(aNextNode, NS_ERROR_FAILURE);
aIndexArray.AppendElement((void *)0);
aIndexArray.AppendElement(0);
aDirection = kDirectionIn;
} else if (aDirection == kDirectionIn) {
@ -582,15 +583,15 @@ static nsresult GetNextNode(nsIDOMNode* aNode, nsVoidArray& aIndexArray,
aNode->GetParentNode(getter_AddRefs(parent));
NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
PRInt32 count = aIndexArray.Count();
PRInt32 count = aIndexArray.Length();
if (count) {
PRInt32 indx = (PRInt32)aIndexArray.ElementAt(count - 1);
PRInt32 indx = aIndexArray.ElementAt(count - 1);
ChildAt(parent, indx + 1, aNextNode);
if (aNextNode)
aIndexArray.ReplaceElementAt((void *)(indx + 1), count - 1);
aIndexArray.ElementAt(count - 1) = indx + 1;
else
aIndexArray.RemoveElementAt(count - 1);
} else {
@ -600,7 +601,7 @@ static nsresult GetNextNode(nsIDOMNode* aNode, nsVoidArray& aIndexArray,
ChildAt(parent, indx + 1, aNextNode);
if (aNextNode)
aIndexArray.AppendElement((void *)(indx + 1));
aIndexArray.AppendElement(indx + 1);
}
}
@ -670,12 +671,12 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
// get start and end nodes for this recursion level
nsCOMPtr<nsIContent> startNode, endNode;
PRInt32 start = mStartRootIndex - aDepth;
if (start >= 0 && start <= mStartNodes.Count())
startNode = static_cast<nsIContent *>(mStartNodes[start]);
if (start >= 0 && start <= mStartNodes.Length())
startNode = mStartNodes[start];
PRInt32 end = mEndRootIndex - aDepth;
if (end >= 0 && end <= mEndNodes.Count())
endNode = static_cast<nsIContent *>(mEndNodes[end]);
if (end >= 0 && end <= mEndNodes.Length())
endNode = mEndNodes[end];
if ((startNode != content) && (endNode != content))
{
@ -728,9 +729,9 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
nsCOMPtr<nsIDOMNode> childAsNode;
PRInt32 startOffset = 0, endOffset = -1;
if (startNode == content && mStartRootIndex >= aDepth)
startOffset = NS_PTR_TO_INT32(mStartOffsets[mStartRootIndex - aDepth]);
startOffset = mStartOffsets[mStartRootIndex - aDepth];
if (endNode == content && mEndRootIndex >= aDepth)
endOffset = NS_PTR_TO_INT32(mEndOffsets[mEndRootIndex - aDepth]) ;
endOffset = mEndOffsets[mEndRootIndex - aDepth];
// generated content will cause offset values of -1 to be returned.
PRInt32 j;
PRUint32 childCount = content->GetChildCount();
@ -777,14 +778,14 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
}
nsresult
nsDocumentEncoder::SerializeRangeContextStart(const nsVoidArray& aAncestorArray,
nsDocumentEncoder::SerializeRangeContextStart(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsAString& aString)
{
PRInt32 i = aAncestorArray.Count();
PRInt32 i = aAncestorArray.Length();
nsresult rv = NS_OK;
while (i > 0) {
nsIDOMNode *node = (nsIDOMNode *)aAncestorArray.ElementAt(--i);
nsIDOMNode *node = aAncestorArray.ElementAt(--i);
if (!node)
break;
@ -801,15 +802,15 @@ nsDocumentEncoder::SerializeRangeContextStart(const nsVoidArray& aAncestorArray,
}
nsresult
nsDocumentEncoder::SerializeRangeContextEnd(const nsVoidArray& aAncestorArray,
nsDocumentEncoder::SerializeRangeContextEnd(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsAString& aString)
{
PRInt32 i = 0;
PRInt32 count = aAncestorArray.Count();
PRInt32 count = aAncestorArray.Length();
nsresult rv = NS_OK;
while (i < count) {
nsIDOMNode *node = (nsIDOMNode *)aAncestorArray.ElementAt(i++);
nsIDOMNode *node = aAncestorArray.ElementAt(i++);
if (!node)
break;
@ -1256,11 +1257,11 @@ nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aContextString,
// where all the cells are in the same table.
// leaf of ancestors might be text node. If so discard it.
PRInt32 count = mCommonAncestors.Count();
PRInt32 count = mCommonAncestors.Length();
PRInt32 i;
nsCOMPtr<nsIDOMNode> node;
if (count > 0)
node = static_cast<nsIDOMNode *>(mCommonAncestors.ElementAt(0));
node = mCommonAncestors.ElementAt(0);
if (node && IsTextNode(node))
{
@ -1275,13 +1276,13 @@ nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aContextString,
i = count;
while (i > 0)
{
node = static_cast<nsIDOMNode *>(mCommonAncestors.ElementAt(--i));
node = mCommonAncestors.ElementAt(--i);
SerializeNodeStart(node, 0, -1, aContextString);
}
//i = 0; guaranteed by above
while (i < count)
{
node = static_cast<nsIDOMNode *>(mCommonAncestors.ElementAt(i++));
node = mCommonAncestors.ElementAt(i++);
SerializeNodeEnd(node, aContextString);
}

View File

@ -47,7 +47,6 @@
#include "nsIDOMEventTarget.h"
#include "nsIDOM3Text.h"
#include "nsTextFragment.h"
#include "nsVoidArray.h"
#include "nsDOMError.h"
#include "nsIEventListenerManager.h"
#include "nsGenericElement.h"

View File

@ -76,7 +76,6 @@ class nsIDOMNamedNodeMap;
class nsDOMCSSDeclaration;
class nsIDOMCSSStyleDeclaration;
class nsIURI;
class nsVoidArray;
class nsINodeInfo;
class nsIControllers;
class nsIDOMNSFeatureFactory;

View File

@ -101,12 +101,10 @@ nsHTMLContentSerializer::nsHTMLContentSerializer()
nsHTMLContentSerializer::~nsHTMLContentSerializer()
{
NS_ASSERTION(mOLStateStack.Count() == 0, "Expected OL State stack to be empty");
if (mOLStateStack.Count() > 0){
for (PRInt32 i = 0; i < mOLStateStack.Count(); i++){
olState* state = (olState*)mOLStateStack[i];
delete state;
mOLStateStack.RemoveElementAt(i);
NS_ASSERTION(mOLStateStack.IsEmpty(), "Expected OL State stack to be empty");
if (!mOLStateStack.IsEmpty()){
for (PRUint32 i = 0; i < mOLStateStack.Length(); i++){
delete mOLStateStack[i];
}
}
}
@ -788,12 +786,12 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
}
if (mIsCopying && (name == nsGkAtoms::ol)){
NS_ASSERTION((mOLStateStack.Count() > 0), "Cannot have an empty OL Stack");
NS_ASSERTION(!mOLStateStack.IsEmpty(), "Cannot have an empty OL Stack");
/* Though at this point we must always have an state to be deleted as all
the OL opening tags are supposed to push an olState object to the stack*/
if (mOLStateStack.Count() > 0) {
olState* state = (olState*)mOLStateStack.ElementAt(mOLStateStack.Count() -1);
mOLStateStack.RemoveElementAt(mOLStateStack.Count() -1);
if (!mOLStateStack.IsEmpty()) {
olState* state = mOLStateStack.ElementAt(mOLStateStack.Length() -1);
mOLStateStack.RemoveElementAt(mOLStateStack.Length() -1);
delete state;
}
}
@ -1243,12 +1241,12 @@ nsHTMLContentSerializer::SerializeLIValueAttribute(nsIDOMElement* aElement,
PRInt32 offset = 0;
olState defaultOLState(0, PR_FALSE);
olState* state = nsnull;
if (mOLStateStack.Count() > 0)
state = (olState*)mOLStateStack.ElementAt(mOLStateStack.Count()-1);
/* Though we should never reach to a "state" as null or mOLStateStack.Count() == 0
if (!mOLStateStack.IsEmpty())
state = mOLStateStack.ElementAt(mOLStateStack.Length()-1);
/* Though we should never reach to a "state" as null or mOLStateStack.IsEmpty()
at this point as all LI are supposed to be inside some OL and OL tag should have
pushed a state to the olStateStack.*/
if (!state || mOLStateStack.Count() == 0)
if (!state || mOLStateStack.IsEmpty())
state = &defaultOLState;
PRInt32 startVal = state->startVal;
state->isFirstListItem = PR_FALSE;
@ -1315,8 +1313,8 @@ nsHTMLContentSerializer::IsFirstChildOfOL(nsIDOMElement* aElement){
if (parentName.LowerCaseEqualsLiteral("ol")) {
olState defaultOLState(0, PR_FALSE);
olState* state = nsnull;
if (mOLStateStack.Count() > 0)
state = (olState*)mOLStateStack.ElementAt(mOLStateStack.Count()-1);
if (!mOLStateStack.IsEmpty())
state = mOLStateStack.ElementAt(mOLStateStack.Length()-1);
/* Though we should never reach to a "state" as null at this point as
all LI are supposed to be inside some OL and OL tag should have pushed
a state to the mOLStateStack.*/

View File

@ -48,6 +48,7 @@
#include "nsXMLContentSerializer.h"
#include "nsIEntityConverter.h"
#include "nsString.h"
#include "nsTArray.h"
class nsIContent;
class nsIAtom;
@ -168,7 +169,8 @@ class nsHTMLContentSerializer : public nsXMLContentSerializer {
PRBool isFirstListItem;
};
nsAutoVoidArray mOLStateStack;// Stack to store one olState struct per <OL>.
// Stack to store one olState struct per <OL>.
nsAutoTArray<olState*, 8> mOLStateStack;
};
nsresult

View File

@ -235,21 +235,21 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn,
}
PRBool
nsPlainTextSerializer::GetLastBool(const nsVoidArray& aStack)
nsPlainTextSerializer::GetLastBool(const nsTArray<PRPackedBool>& aStack)
{
PRUint32 size = aStack.Count();
PRUint32 size = aStack.Length();
if (size == 0) {
return PR_FALSE;
}
return (aStack.ElementAt(size-1) != reinterpret_cast<void*>(PR_FALSE));
return aStack.ElementAt(size-1);
}
void
nsPlainTextSerializer::SetLastBool(nsVoidArray& aStack, PRBool aValue)
nsPlainTextSerializer::SetLastBool(nsTArray<PRPackedBool>& aStack, PRBool aValue)
{
PRUint32 size = aStack.Count();
PRUint32 size = aStack.Length();
if (size > 0) {
aStack.ReplaceElementAt(reinterpret_cast<void*>(aValue), size-1);
aStack.ElementAt(size-1) = aValue;
}
else {
NS_ERROR("There is no \"Last\" value");
@ -257,18 +257,18 @@ nsPlainTextSerializer::SetLastBool(nsVoidArray& aStack, PRBool aValue)
}
void
nsPlainTextSerializer::PushBool(nsVoidArray& aStack, PRBool aValue)
nsPlainTextSerializer::PushBool(nsTArray<PRPackedBool>& aStack, PRBool aValue)
{
aStack.AppendElement(reinterpret_cast<void*>(aValue));
aStack.AppendElement(PRPackedBool(aValue));
}
PRBool
nsPlainTextSerializer::PopBool(nsVoidArray& aStack)
nsPlainTextSerializer::PopBool(nsTArray<PRPackedBool>& aStack)
{
PRBool returnValue = PR_FALSE;
PRUint32 size = aStack.Count();
PRUint32 size = aStack.Length();
if (size > 0) {
returnValue = (aStack.ElementAt(size-1) != reinterpret_cast<void*>(PR_FALSE));
returnValue = aStack.ElementAt(size-1);
aStack.RemoveElementAt(size-1);
}
return returnValue;
@ -681,7 +681,7 @@ nsPlainTextSerializer::DoOpenContainer(const nsIParserNode* aNode, PRInt32 aTag)
AddToLine(NS_LITERAL_STRING("\t").get(), 1);
mInWhitespace = PR_TRUE;
}
else if (mHasWrittenCellsForRow.Count() == 0) {
else if (mHasWrittenCellsForRow.IsEmpty()) {
// We don't always see a <tr> (nor a <table>) before the <td> if we're
// copying part of a table
PushBool(mHasWrittenCellsForRow, PR_TRUE); // will never be popped

View File

@ -54,7 +54,7 @@
#include "nsIAtom.h"
#include "nsIHTMLToTextSink.h"
#include "nsIDocumentEncoder.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
class nsPlainTextSerializer : public nsIContentSerializer,
@ -164,10 +164,10 @@ protected:
}
// Stack handling functions
PRBool GetLastBool(const nsVoidArray& aStack);
void SetLastBool(nsVoidArray& aStack, PRBool aValue);
void PushBool(nsVoidArray& aStack, PRBool aValue);
PRBool PopBool(nsVoidArray& aStack);
PRBool GetLastBool(const nsTArray<PRPackedBool>& aStack);
void SetLastBool(nsTArray<PRPackedBool>& aStack, PRBool aValue);
void PushBool(nsTArray<PRPackedBool>& aStack, PRBool aValue);
PRBool PopBool(nsTArray<PRPackedBool>& aStack);
protected:
nsString mCurrentLine;
@ -241,11 +241,11 @@ protected:
nsCOMPtr<nsIContent> mContent;
// For handling table rows
nsAutoVoidArray mHasWrittenCellsForRow; // really an array of bools
nsAutoTArray<PRPackedBool, 8> mHasWrittenCellsForRow;
// Values gotten in OpenContainer that is (also) needed in CloseContainer
nsAutoVoidArray mCurrentNodeIsConverted; // really an array of bools
nsAutoVoidArray mIsInCiteBlockquote; // really an array of bools
nsAutoTArray<PRPackedBool, 8> mCurrentNodeIsConverted;
nsAutoTArray<PRPackedBool, 8> mIsInCiteBlockquote;
// The output data
nsAString* mOutputString;

View File

@ -53,8 +53,6 @@
#include "prmon.h"
#include "nsStubMutationObserver.h"
class nsVoidArray;
// -------------------------------------------------------------------------------
class nsRangeUtils : public nsIRangeUtils

View File

@ -44,7 +44,6 @@
#include "nsCOMPtr.h"
#include "nsAString.h"
#include "nsVoidArray.h"
#include "nsIScriptEventManager.h"
#include "nsIDOMNodeList.h"

View File

@ -57,7 +57,6 @@
#include "nsISimpleUnicharStreamFactory.h"
#include "nsNetUtil.h"
#include "nsUnicharUtils.h"
#include "nsVoidArray.h"
#include "nsCRT.h"
#include "nsXPCOMCIDInternal.h"
#include "nsUnicharInputStream.h"

View File

@ -558,9 +558,8 @@ PRInt32 nsTreeWalker::IndexOf(nsINode* aParent,
nsINode* aChild,
PRInt32 aIndexPos)
{
if (aIndexPos >= 0 && aIndexPos < mPossibleIndexes.Count()) {
PRInt32 possibleIndex =
NS_PTR_TO_INT32(mPossibleIndexes.FastElementAt(aIndexPos));
if (aIndexPos >= 0 && aIndexPos < PRInt32(mPossibleIndexes.Length())) {
PRInt32 possibleIndex = mPossibleIndexes.ElementAt(aIndexPos);
if (aChild == aParent->GetChildAt(possibleIndex)) {
return possibleIndex;
}

View File

@ -47,7 +47,7 @@
#include "nsIDOMTreeWalker.h"
#include "nsTraversal.h"
#include "nsCOMPtr.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsCycleCollectionParticipant.h"
class nsINode;
@ -74,9 +74,8 @@ private:
/*
* Array with all child indexes up the tree. This should only be
* considered a hint and the value could be wrong.
* The array contains casted PRInt32's
*/
nsAutoVoidArray mPossibleIndexes;
nsAutoTArray<PRInt32, 8> mPossibleIndexes;
/*
* Position of mCurrentNode in mPossibleIndexes
@ -168,9 +167,10 @@ private:
*/
void SetChildIndex(PRInt32 aIndexPos, PRInt32 aChildIndex)
{
if (aIndexPos != -1)
mPossibleIndexes.ReplaceElementAt(NS_INT32_TO_PTR(aChildIndex),
aIndexPos);
if (aIndexPos > 0) {
mPossibleIndexes.EnsureLengthAtLeast(aIndexPos+1);
mPossibleIndexes.ElementAt(aIndexPos) = aChildIndex;
}
}
};

View File

@ -64,11 +64,11 @@
#include "nsContentUtils.h"
#include "nsAttrName.h"
typedef struct {
struct NameSpaceDecl {
nsString mPrefix;
nsString mURI;
nsIDOMElement* mOwner;
} NameSpaceDecl;
};
nsresult NS_NewXMLContentSerializer(nsIContentSerializer** aSerializer)
{
@ -346,7 +346,7 @@ nsXMLContentSerializer::PushNameSpaceDecl(const nsAString& aPrefix,
// we pop the stack
decl->mOwner = aOwner;
mNameSpaceStack.AppendElement((void*)decl);
mNameSpaceStack.AppendElement(decl);
return NS_OK;
}
@ -355,9 +355,9 @@ nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIDOMElement* aOwner)
{
PRInt32 index, count;
count = mNameSpaceStack.Count();
count = mNameSpaceStack.Length();
for (index = count - 1; index >= 0; index--) {
NameSpaceDecl* decl = (NameSpaceDecl*)mNameSpaceStack.ElementAt(index);
NameSpaceDecl* decl = mNameSpaceStack.ElementAt(index);
if (decl->mOwner != aOwner) {
break;
}
@ -411,10 +411,10 @@ nsXMLContentSerializer::ConfirmPrefix(nsAString& aPrefix,
// later (so in a more outer scope) see it bound to aURI we can't reuse it.
PRBool haveSeenOurPrefix = PR_FALSE;
PRInt32 count = mNameSpaceStack.Count();
PRInt32 count = mNameSpaceStack.Length();
PRInt32 index = count - 1;
while (index >= 0) {
NameSpaceDecl* decl = (NameSpaceDecl*)mNameSpaceStack.ElementAt(index);
NameSpaceDecl* decl = mNameSpaceStack.ElementAt(index);
// Check if we've found a prefix match
if (aPrefix.Equals(decl->mPrefix)) {
@ -464,8 +464,7 @@ nsXMLContentSerializer::ConfirmPrefix(nsAString& aPrefix,
PRBool prefixOK = PR_TRUE;
PRInt32 index2;
for (index2 = count-1; index2 > index && prefixOK; --index2) {
NameSpaceDecl* decl2 =
(NameSpaceDecl*)mNameSpaceStack.ElementAt(index2);
NameSpaceDecl* decl2 = mNameSpaceStack.ElementAt(index2);
prefixOK = (decl2->mPrefix != decl->mPrefix);
}

View File

@ -47,10 +47,12 @@
#include "nsIContentSerializer.h"
#include "nsISupportsUtils.h"
#include "nsCOMPtr.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsString.h"
class nsIDOMNode;
class nsIAtom;
struct NameSpaceDecl;
class nsXMLContentSerializer : public nsIContentSerializer {
public:
@ -156,7 +158,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
void MaybeFlagNewline(nsIDOMNode* aNode);
PRInt32 mPrefixIndex;
nsVoidArray mNameSpaceStack;
nsTArray<NameSpaceDecl*> mNameSpaceStack;
// nsIDocumentEncoder flags
PRUint32 mFlags;

View File

@ -82,12 +82,11 @@ nsXMLNameSpaceMap::nsXMLNameSpaceMap()
nsresult
nsXMLNameSpaceMap::AddPrefix(nsIAtom *aPrefix, PRInt32 aNameSpaceID)
{
PRInt32 count = mNameSpaces.Count();
PRUint32 count = mNameSpaces.Length();
nsNameSpaceEntry *foundEntry = nsnull;
for (PRInt32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = static_cast<nsNameSpaceEntry*>
(mNameSpaces.FastElementAt(i));
for (PRUint32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = mNameSpaces.ElementAt(i);
NS_ASSERTION(entry, "null entry in namespace map!");
@ -101,7 +100,7 @@ nsXMLNameSpaceMap::AddPrefix(nsIAtom *aPrefix, PRInt32 aNameSpaceID)
foundEntry = new nsNameSpaceEntry(aPrefix);
NS_ENSURE_TRUE(foundEntry, NS_ERROR_OUT_OF_MEMORY);
if (!mNameSpaces.AppendElement(foundEntry)) {
if (mNameSpaces.AppendElement(foundEntry) == nsnull) {
delete foundEntry;
return NS_ERROR_OUT_OF_MEMORY;
}
@ -126,11 +125,10 @@ nsXMLNameSpaceMap::AddPrefix(nsIAtom *aPrefix, nsString &aURI)
void
nsXMLNameSpaceMap::RemovePrefix(nsIAtom *aPrefix)
{
PRInt32 count = mNameSpaces.Count();
PRUint32 count = mNameSpaces.Length();
for (PRInt32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = static_cast<nsNameSpaceEntry*>
(mNameSpaces.FastElementAt(i));
for (PRUint32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = mNameSpaces.ElementAt(i);
NS_ASSERTION(entry, "null entry in namespace map!");
@ -144,11 +142,10 @@ nsXMLNameSpaceMap::RemovePrefix(nsIAtom *aPrefix)
PRInt32
nsXMLNameSpaceMap::FindNameSpaceID(nsIAtom *aPrefix) const
{
PRInt32 count = mNameSpaces.Count();
PRUint32 count = mNameSpaces.Length();
for (PRInt32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = static_cast<nsNameSpaceEntry*>
(mNameSpaces.FastElementAt(i));
for (PRUint32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = mNameSpaces.ElementAt(i);
NS_ASSERTION(entry, "null entry in namespace map!");
@ -166,11 +163,10 @@ nsXMLNameSpaceMap::FindNameSpaceID(nsIAtom *aPrefix) const
nsIAtom*
nsXMLNameSpaceMap::FindPrefix(PRInt32 aNameSpaceID) const
{
PRInt32 count = mNameSpaces.Count();
PRUint32 count = mNameSpaces.Length();
for (PRInt32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = static_cast<nsNameSpaceEntry*>
(mNameSpaces.FastElementAt(i));
for (PRUint32 i = 0; i < count; ++i) {
nsNameSpaceEntry *entry = mNameSpaces.ElementAt(i);
NS_ASSERTION(entry, "null entry in namespace map!");
@ -182,14 +178,11 @@ nsXMLNameSpaceMap::FindPrefix(PRInt32 aNameSpaceID) const
return nsnull;
}
static PRBool DeleteEntry(void *aElement, void *aData)
{
delete static_cast<nsNameSpaceEntry*>(aElement);
return PR_TRUE;
}
void
nsXMLNameSpaceMap::Clear()
{
mNameSpaces.EnumerateForwards(DeleteEntry, nsnull);
for (PRUint32 i = 0, len = mNameSpaces.Length(); i < len; ++i) {
delete mNameSpaces[i];
}
mNameSpaces.Clear();
}

View File

@ -94,7 +94,6 @@
#include "nsINameSpaceManager.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsICookieService.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
@ -247,7 +246,7 @@ protected:
nsRefPtr<nsGenericHTMLElement> mCurrentForm;
nsAutoVoidArray mContextStack;
nsAutoTArray<SinkContext*, 8> mContextStack;
SinkContext* mCurrentContext;
SinkContext* mHeadContext;
PRInt32 mNumOpenIFRAMES;
@ -1550,7 +1549,7 @@ HTMLContentSink::~HTMLContentSink()
mNotificationTimer->Cancel();
}
PRInt32 numContexts = mContextStack.Count();
PRInt32 numContexts = mContextStack.Length();
if (mCurrentContext == mHeadContext && numContexts > 0) {
// Pop off the second html context if it's not done earlier
@ -1559,7 +1558,7 @@ HTMLContentSink::~HTMLContentSink()
PRInt32 i;
for (i = 0; i < numContexts; i++) {
SinkContext* sc = (SinkContext*)mContextStack.ElementAt(i);
SinkContext* sc = mContextStack.ElementAt(i);
if (sc) {
sc->End();
if (sc == mCurrentContext) {
@ -1923,8 +1922,8 @@ HTMLContentSink::EndContext(PRInt32 aPosition)
MOZ_TIMER_START(mWatch);
NS_PRECONDITION(mCurrentContext && aPosition > -1, "non-existing context");
PRInt32 n = mContextStack.Count() - 1;
SinkContext* sc = (SinkContext*) mContextStack.ElementAt(n);
PRUint32 n = mContextStack.Length() - 1;
SinkContext* sc = mContextStack.ElementAt(n);
const SinkContext::Node &bottom = mCurrentContext->mStack[0];
@ -1985,10 +1984,10 @@ HTMLContentSink::CloseHTML()
if (mHeadContext) {
if (mCurrentContext == mHeadContext) {
PRInt32 numContexts = mContextStack.Count();
PRUint32 numContexts = mContextStack.Length();
// Pop off the second html context if it's not done earlier
mCurrentContext = (SinkContext*)mContextStack.ElementAt(--numContexts);
mCurrentContext = mContextStack.ElementAt(--numContexts);
mContextStack.RemoveElementAt(numContexts);
}
@ -2832,11 +2831,12 @@ HTMLContentSink::CloseHeadContext()
mCurrentContext->FlushTextAndRelease();
}
NS_ASSERTION(mContextStack.Count() > 0, "Stack should not be empty");
PRInt32 n = mContextStack.Count() - 1;
mCurrentContext = (SinkContext*) mContextStack.ElementAt(n);
mContextStack.RemoveElementAt(n);
if (!mContextStack.IsEmpty())
{
PRUint32 n = mContextStack.Length() - 1;
mCurrentContext = mContextStack.ElementAt(n);
mContextStack.RemoveElementAt(n);
}
}
void
@ -3070,9 +3070,9 @@ HTMLContentSink::IsMonolithicContainer(nsHTMLTag aTag)
void
HTMLContentSink::UpdateChildCounts()
{
PRInt32 numContexts = mContextStack.Count();
for (PRInt32 i = 0; i < numContexts; i++) {
SinkContext* sc = (SinkContext*)mContextStack.ElementAt(i);
PRUint32 numContexts = mContextStack.Length();
for (PRUint32 i = 0; i < numContexts; i++) {
SinkContext* sc = mContextStack.ElementAt(i);
sc->UpdateChildCounts();
}

View File

@ -2083,9 +2083,7 @@ nsHTMLDocument::Close()
if (mParser && mWriteState == eDocumentOpened) {
mPendingScripts.RemoveElement(GenerateParserKey());
mWriteState = mPendingScripts.Count() == 0
? eDocumentClosed
: ePendingClose;
mWriteState = mPendingScripts.IsEmpty() ? eDocumentClosed : ePendingClose;
++mWriteLevel;
rv = mParser->Parse(EmptyString(), mParser->GetRootContextKey(),
@ -2150,7 +2148,7 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
void *key = GenerateParserKey();
if (mWriteState == eDocumentClosed ||
(mWriteState == ePendingClose &&
mPendingScripts.IndexOf(key) == kNotFound)) {
!mPendingScripts.Contains(key))) {
mWriteState = eDocumentClosed;
mParser->Terminate();
NS_ASSERTION(!mParser, "mParser should have been null'd out");
@ -2370,7 +2368,7 @@ nsHTMLDocument::ScriptExecuted(nsIScriptElement *aScript)
}
mPendingScripts.RemoveElement(aScript);
if (mPendingScripts.Count() == 0 && mWriteState == ePendingClose) {
if (mPendingScripts.IsEmpty() && mWriteState == ePendingClose) {
// The last pending script just finished, terminate our parser now.
mWriteState = eDocumentClosed;
}

View File

@ -47,6 +47,7 @@
#include "nsIDOMHTMLCollection.h"
#include "nsIScriptElement.h"
#include "jsapi.h"
#include "nsTArray.h"
#include "pldhash.h"
#include "nsIHttpChannel.h"
@ -342,7 +343,7 @@ protected:
// finishes processing that script.
PRUint32 mWriteLevel;
nsSmallVoidArray mPendingScripts;
nsAutoTArray<nsIScriptElement*, 1> mPendingScripts;
// Load flags of the document's channel
PRUint32 mLoadFlags;

View File

@ -49,7 +49,7 @@
#include "nsIDOMComment.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMDocumentFragment.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsINameSpaceManager.h"
#include "nsIDocument.h"
#include "nsINodeInfo.h"
@ -150,7 +150,7 @@ public:
nsCOMPtr<nsIContent> mRoot;
nsCOMPtr<nsIParser> mParser;
nsVoidArray* mContentStack;
nsTArray<nsIContent*>* mContentStack;
PRUnichar* mText;
PRInt32 mTextLength;
@ -210,9 +210,9 @@ nsHTMLFragmentContentSink::~nsHTMLFragmentContentSink()
if (nsnull != mContentStack) {
// there shouldn't be anything here except in an error condition
PRInt32 indx = mContentStack->Count();
PRInt32 indx = mContentStack->Length();
while (0 < indx--) {
nsIContent* content = (nsIContent*)mContentStack->ElementAt(indx);
nsIContent* content = mContentStack->ElementAt(indx);
NS_RELEASE(content);
}
delete mContentStack;
@ -680,9 +680,9 @@ nsIContent*
nsHTMLFragmentContentSink::GetCurrentContent()
{
if (nsnull != mContentStack) {
PRInt32 indx = mContentStack->Count() - 1;
PRInt32 indx = mContentStack->Length() - 1;
if (indx >= 0)
return (nsIContent *)mContentStack->ElementAt(indx);
return mContentStack->ElementAt(indx);
}
return nsnull;
}
@ -691,11 +691,11 @@ PRInt32
nsHTMLFragmentContentSink::PushContent(nsIContent *aContent)
{
if (nsnull == mContentStack) {
mContentStack = new nsVoidArray();
mContentStack = new nsTArray<nsIContent*>();
}
mContentStack->AppendElement((void *)aContent);
return mContentStack->Count();
mContentStack->AppendElement(aContent);
return mContentStack->Length();
}
nsIContent*
@ -703,9 +703,9 @@ nsHTMLFragmentContentSink::PopContent()
{
nsIContent* content = nsnull;
if (nsnull != mContentStack) {
PRInt32 indx = mContentStack->Count() - 1;
PRInt32 indx = mContentStack->Length() - 1;
if (indx >= 0) {
content = (nsIContent *)mContentStack->ElementAt(indx);
content = mContentStack->ElementAt(indx);
mContentStack->RemoveElementAt(indx);
}
}

View File

@ -39,7 +39,6 @@
#define __NS_SVGDATAPARSER_H__
#include "nsCOMPtr.h"
#include "nsVoidArray.h"
//----------------------------------------------------------------------
// helper macros

View File

@ -40,7 +40,7 @@
#include "nsSVGLength.h"
#include "nsSVGValue.h"
#include "nsWeakReference.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsDOMError.h"
#include "nsReadableUtils.h"
#include "nsSVGSVGElement.h"
@ -93,7 +93,7 @@ protected:
void ReleaseLengths();
nsAutoVoidArray mLengths;
nsAutoTArray<nsISVGLength*, 1> mLengths;
nsWeakPtr mContext; // needs to be weak to avoid reference loop
PRUint8 mCtxType;
};
@ -168,11 +168,11 @@ nsSVGLengthList::GetValueString(nsAString& aValue)
{
aValue.Truncate();
PRInt32 count = mLengths.Count();
PRUint32 count = mLengths.Length();
if (count<=0) return NS_OK;
if (count == 0) return NS_OK;
PRInt32 i = 0;
PRUint32 i = 0;
while (1) {
nsISVGLength* length = ElementAt(i);
@ -197,7 +197,7 @@ nsSVGLengthList::GetValueString(nsAString& aValue)
/* readonly attribute unsigned long numberOfItems; */
NS_IMETHODIMP nsSVGLengthList::GetNumberOfItems(PRUint32 *aNumberOfItems)
{
*aNumberOfItems = mLengths.Count();
*aNumberOfItems = mLengths.Length();
return NS_OK;
}
@ -225,7 +225,7 @@ NS_IMETHODIMP nsSVGLengthList::Initialize(nsIDOMSVGLength *newItem,
/* nsIDOMSVGLength getItem (in unsigned long index); */
NS_IMETHODIMP nsSVGLengthList::GetItem(PRUint32 index, nsIDOMSVGLength **_retval)
{
if (index >= static_cast<PRUint32>(mLengths.Count())) {
if (index >= mLengths.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -266,7 +266,7 @@ nsSVGLengthList::ReplaceItem(nsIDOMSVGLength *newItem,
/* nsIDOMSVGLengthList removeItem (in unsigned long index); */
NS_IMETHODIMP nsSVGLengthList::RemoveItem(PRUint32 index, nsIDOMSVGLength **_retval)
{
if (index >= static_cast<PRUint32>(mLengths.Count())) {
if (index >= mLengths.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -321,8 +321,8 @@ void
nsSVGLengthList::ReleaseLengths()
{
WillModify();
PRInt32 count = mLengths.Count();
for (PRInt32 i = 0; i < count; ++i) {
PRUint32 count = mLengths.Length();
for (PRUint32 i = 0; i < count; ++i) {
nsISVGLength* length = ElementAt(i);
length->SetContext(nsnull, 0);
NS_REMOVE_SVGVALUE_OBSERVER(length);
@ -335,7 +335,7 @@ nsSVGLengthList::ReleaseLengths()
nsISVGLength*
nsSVGLengthList::ElementAt(PRInt32 index)
{
return (nsISVGLength*)mLengths.ElementAt(index);
return mLengths.ElementAt(index);
}
void
@ -350,7 +350,7 @@ nsSVGLengthList::AppendElement(nsISVGLength* aElement)
// aElement->SetListOwner(this);
aElement->SetContext(mContext, mCtxType);
mLengths.AppendElement((void*)aElement);
mLengths.AppendElement(aElement);
NS_ADD_SVGVALUE_OBSERVER(aElement);
DidModify();
}
@ -380,7 +380,7 @@ nsSVGLengthList::InsertElementAt(nsISVGLength* aElement, PRInt32 index)
aElement->SetContext(mContext, mCtxType);
mLengths.InsertElementAt((void*)aElement, index);
mLengths.InsertElementAt(index, aElement);
NS_ADD_SVGVALUE_OBSERVER(aElement);
DidModify();
}

View File

@ -40,7 +40,6 @@
#include "nsSVGNumber.h"
#include "nsSVGValue.h"
#include "nsWeakReference.h"
#include "nsVoidArray.h"
#include "nsDOMError.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
@ -91,7 +90,7 @@ protected:
void ReleaseNumbers();
nsAutoVoidArray mNumbers;
nsAutoTArray<nsIDOMSVGNumber*, 8> mNumbers;
};
@ -165,11 +164,11 @@ nsSVGNumberList::GetValueString(nsAString& aValue)
{
aValue.Truncate();
PRInt32 count = mNumbers.Count();
PRUint32 count = mNumbers.Length();
if (count<=0) return NS_OK;
if (count == 0) return NS_OK;
PRInt32 i = 0;
PRUint32 i = 0;
while (1) {
nsIDOMSVGNumber* number = ElementAt(i);
@ -194,7 +193,7 @@ nsSVGNumberList::GetValueString(nsAString& aValue)
/* readonly attribute unsigned long numberOfItems; */
NS_IMETHODIMP nsSVGNumberList::GetNumberOfItems(PRUint32 *aNumberOfItems)
{
*aNumberOfItems = mNumbers.Count();
*aNumberOfItems = mNumbers.Length();
return NS_OK;
}
@ -222,7 +221,7 @@ NS_IMETHODIMP nsSVGNumberList::Initialize(nsIDOMSVGNumber *newItem,
/* nsIDOMSVGNumber getItem (in unsigned long index); */
NS_IMETHODIMP nsSVGNumberList::GetItem(PRUint32 index, nsIDOMSVGNumber **_retval)
{
if (index >= static_cast<PRUint32>(mNumbers.Count())) {
if (index >= mNumbers.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -244,10 +243,9 @@ nsSVGNumberList::InsertItemBefore(nsIDOMSVGNumber *newItem,
nsSVGValueAutoNotifier autonotifier(this);
PRInt32 idx = index;
PRInt32 count = mNumbers.Count();
PRUint32 count = mNumbers.Length();
if (!InsertElementAt(newItem, (idx < count)? idx: count)) {
if (!InsertElementAt(newItem, (index < count)? index: count)) {
*_retval = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
@ -277,7 +275,7 @@ nsSVGNumberList::ReplaceItem(nsIDOMSVGNumber *newItem,
/* nsIDOMSVGNumberList removeItem (in unsigned long index); */
NS_IMETHODIMP nsSVGNumberList::RemoveItem(PRUint32 index, nsIDOMSVGNumber **_retval)
{
if (index >= static_cast<PRUint32>(mNumbers.Count())) {
if (index >= mNumbers.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -328,8 +326,8 @@ void
nsSVGNumberList::ReleaseNumbers()
{
WillModify();
PRInt32 count = mNumbers.Count();
for (PRInt32 i = 0; i < count; ++i) {
PRUint32 count = mNumbers.Length();
for (PRUint32 i = 0; i < count; ++i) {
nsIDOMSVGNumber* number = ElementAt(i);
NS_REMOVE_SVGVALUE_OBSERVER(number);
NS_RELEASE(number);
@ -341,7 +339,7 @@ nsSVGNumberList::ReleaseNumbers()
nsIDOMSVGNumber*
nsSVGNumberList::ElementAt(PRInt32 index)
{
return (nsIDOMSVGNumber*)mNumbers.ElementAt(index);
return mNumbers.ElementAt(index);
}
void
@ -355,7 +353,7 @@ nsSVGNumberList::AppendElement(nsIDOMSVGNumber* aElement)
// list':
// aElement->SetListOwner(this);
mNumbers.AppendElement((void*)aElement);
mNumbers.AppendElement(aElement);
NS_ADD_SVGVALUE_OBSERVER(aElement);
DidModify();
}
@ -384,7 +382,7 @@ nsSVGNumberList::InsertElementAt(nsIDOMSVGNumber* aElement, PRInt32 index)
// list':
// aElement->SetListOwner(this);
if (!NS_FAILED(rv = mNumbers.InsertElementAt((void*)aElement, index)))
if (mNumbers.InsertElementAt(index, aElement))
NS_ADD_SVGVALUE_OBSERVER(aElement);
DidModify();
return rv;

View File

@ -41,7 +41,6 @@
#include "nsSVGDataParser.h"
#include "nsCOMPtr.h"
#include "nsVoidArray.h"
#include "nsCOMArray.h"
#include "nsIDOMSVGPathSeg.h"
#include "nsTArray.h"

View File

@ -40,7 +40,6 @@
#include "nsSVGPathSeg.h"
#include "nsSVGValue.h"
#include "nsWeakReference.h"
#include "nsVoidArray.h"
#include "nsCOMArray.h"
#include "nsDOMError.h"
#include "nsSVGPathDataParser.h"

View File

@ -82,8 +82,8 @@ void
nsSVGPointList::ReleasePoints()
{
WillModify();
PRInt32 count = mPoints.Count();
for (PRInt32 i = 0; i < count; ++i) {
PRUint32 count = mPoints.Length();
for (PRUint32 i = 0; i < count; ++i) {
nsIDOMSVGPoint* point = ElementAt(i);
nsCOMPtr<nsISVGValue> val = do_QueryInterface(point);
if (val)
@ -97,7 +97,7 @@ nsSVGPointList::ReleasePoints()
nsIDOMSVGPoint*
nsSVGPointList::ElementAt(PRInt32 index)
{
return (nsIDOMSVGPoint*)mPoints.ElementAt(index);
return mPoints.ElementAt(index);
}
void
@ -105,7 +105,7 @@ nsSVGPointList::AppendElement(nsIDOMSVGPoint* aElement)
{
WillModify();
NS_ADDREF(aElement);
mPoints.AppendElement((void*)aElement);
mPoints.AppendElement(aElement);
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
if (val)
val->AddObserver(this);
@ -131,7 +131,7 @@ nsSVGPointList::InsertElementAt(nsIDOMSVGPoint* aElement, PRInt32 index)
{
WillModify();
NS_ADDREF(aElement);
mPoints.InsertElementAt((void*)aElement, index);
mPoints.InsertElementAt(index, aElement);
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
if (val)
val->AddObserver(this);
@ -219,11 +219,11 @@ nsSVGPointList::GetValueString(nsAString& aValue)
{
aValue.Truncate();
PRInt32 count = mPoints.Count();
PRUint32 count = mPoints.Length();
if (count<=0) return NS_OK;
if (count == 0) return NS_OK;
PRInt32 i = 0;
PRUint32 i = 0;
PRUnichar buf[48];
while (1) {
@ -249,7 +249,7 @@ nsSVGPointList::GetValueString(nsAString& aValue)
/* readonly attribute unsigned long numberOfItems; */
NS_IMETHODIMP nsSVGPointList::GetNumberOfItems(PRUint32 *aNumberOfItems)
{
*aNumberOfItems = mPoints.Count();
*aNumberOfItems = mPoints.Length();
return NS_OK;
}
@ -277,7 +277,7 @@ NS_IMETHODIMP nsSVGPointList::Initialize(nsIDOMSVGPoint *newItem,
/* nsIDOMSVGPoint getItem (in unsigned long index); */
NS_IMETHODIMP nsSVGPointList::GetItem(PRUint32 index, nsIDOMSVGPoint **_retval)
{
if (index >= static_cast<PRUint32>(mPoints.Count())) {
if (index >= mPoints.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -316,7 +316,7 @@ NS_IMETHODIMP nsSVGPointList::ReplaceItem(nsIDOMSVGPoint *newItem,
/* nsIDOMSVGPoint removeItem (in unsigned long index); */
NS_IMETHODIMP nsSVGPointList::RemoveItem(PRUint32 index, nsIDOMSVGPoint **_retval)
{
if (index >= static_cast<PRUint32>(mPoints.Count())) {
if (index >= mPoints.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}

View File

@ -43,7 +43,7 @@
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
#include "nsIDOMSVGPointList.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
class nsSVGPointList : public nsSVGValue,
@ -88,7 +88,7 @@ public:
protected:
void ReleasePoints();
nsAutoVoidArray mPoints;
nsAutoTArray<nsIDOMSVGPoint*, 8> mPoints;
};

View File

@ -80,8 +80,8 @@ nsSVGTransformList::~nsSVGTransformList()
void
nsSVGTransformList::ReleaseTransforms()
{
PRInt32 count = mTransforms.Count();
for (PRInt32 i = 0; i < count; ++i) {
PRUint32 count = mTransforms.Length();
for (PRUint32 i = 0; i < count; ++i) {
nsIDOMSVGTransform* transform = ElementAt(i);
nsCOMPtr<nsISVGValue> val = do_QueryInterface(transform);
val->RemoveObserver(this);
@ -93,20 +93,20 @@ nsSVGTransformList::ReleaseTransforms()
nsIDOMSVGTransform*
nsSVGTransformList::ElementAt(PRInt32 index)
{
return (nsIDOMSVGTransform*)mTransforms.ElementAt(index);
return mTransforms.ElementAt(index);
}
PRBool
nsSVGTransformList::AppendElement(nsIDOMSVGTransform* aElement)
{
PRBool rv = mTransforms.AppendElement((void*)aElement);
if (rv) {
if (mTransforms.AppendElement(aElement)) {
NS_ADDREF(aElement);
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
val->AddObserver(this);
return PR_TRUE;
}
return rv;
return PR_FALSE;
}
already_AddRefed<nsIDOMSVGMatrix>
@ -199,11 +199,11 @@ nsSVGTransformList::GetValueString(nsAString& aValue)
{
aValue.Truncate();
PRInt32 count = mTransforms.Count();
PRUint32 count = mTransforms.Length();
if (count<=0) return NS_OK;
if (count == 0) return NS_OK;
PRInt32 i = 0;
PRUint32 i = 0;
while (1) {
nsIDOMSVGTransform* transform = ElementAt(i);
@ -228,7 +228,7 @@ nsSVGTransformList::GetValueString(nsAString& aValue)
/* readonly attribute unsigned long numberOfItems; */
NS_IMETHODIMP nsSVGTransformList::GetNumberOfItems(PRUint32 *aNumberOfItems)
{
*aNumberOfItems = mTransforms.Count();
*aNumberOfItems = mTransforms.Length();
return NS_OK;
}
@ -262,7 +262,7 @@ NS_IMETHODIMP nsSVGTransformList::Initialize(nsIDOMSVGTransform *newItem,
/* nsIDOMSVGTransform getItem (in unsigned long index); */
NS_IMETHODIMP nsSVGTransformList::GetItem(PRUint32 index, nsIDOMSVGTransform **_retval)
{
if (index >= static_cast<PRUint32>(mTransforms.Count())) {
if (index >= mTransforms.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -281,9 +281,9 @@ NS_IMETHODIMP nsSVGTransformList::InsertItemBefore(nsIDOMSVGTransform *newItem,
nsSVGValueAutoNotifier autonotifier(this);
PRUint32 count = mTransforms.Count();
PRUint32 count = mTransforms.Length();
if (!mTransforms.InsertElementAt((void*)newItem, (index < count)? index: count)) {
if (!mTransforms.InsertElementAt((index < count)? index: count, newItem)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -305,15 +305,12 @@ NS_IMETHODIMP nsSVGTransformList::ReplaceItem(nsIDOMSVGTransform *newItem,
nsSVGValueAutoNotifier autonotifier(this);
if (index >= PRUint32(mTransforms.Count()))
if (index >= mTransforms.Length())
return NS_ERROR_DOM_INDEX_SIZE_ERR;
nsIDOMSVGTransform* oldItem = ElementAt(index);
if (!mTransforms.ReplaceElementAt((void*)newItem, index)) {
NS_NOTREACHED("removal of element failed");
return NS_ERROR_UNEXPECTED;
}
mTransforms.ElementAt(index) = newItem;
nsCOMPtr<nsISVGValue> val = do_QueryInterface(oldItem);
val->RemoveObserver(this);
@ -332,18 +329,14 @@ NS_IMETHODIMP nsSVGTransformList::RemoveItem(PRUint32 index, nsIDOMSVGTransform
{
nsSVGValueAutoNotifier autonotifier(this);
if (index >= static_cast<PRUint32>(mTransforms.Count())) {
if (index >= mTransforms.Length()) {
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
*_retval = ElementAt(index);
if (!mTransforms.RemoveElementAt(index)) {
NS_NOTREACHED("removal of element failed");
*_retval = nsnull;
return NS_ERROR_UNEXPECTED;
}
mTransforms.RemoveElementAt(index);
nsCOMPtr<nsISVGValue> val = do_QueryInterface(*_retval);
val->RemoveObserver(this);
@ -392,7 +385,7 @@ NS_IMETHODIMP nsSVGTransformList::Consolidate(nsIDOMSVGTransform **_retval)
*_retval = nsnull;
PRInt32 count = mTransforms.Count();
PRUint32 count = mTransforms.Length();
if (count==0) return NS_OK;
if (count==1) {
*_retval = ElementAt(0);

View File

@ -43,7 +43,7 @@
#include "nsISVGValueObserver.h"
#include "nsWeakReference.h"
#include "nsIDOMSVGTransformList.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
class nsSVGTransformList : public nsSVGValue,
public nsIDOMSVGTransformList,
@ -87,7 +87,7 @@ protected:
PRInt32 ParseParameterList(char *paramstr, float *vars, PRInt32 nvars);
void ReleaseTransforms();
nsAutoVoidArray mTransforms;
nsAutoTArray<nsIDOMSVGTransform*, 8> mTransforms;
};

View File

@ -52,27 +52,26 @@ nsSVGValue::~nsSVGValue()
void
nsSVGValue::ReleaseObservers()
{
PRInt32 count = mObservers.Count();
PRInt32 i;
PRUint32 count = mObservers.Length();
PRUint32 i;
for (i = 0; i < count; ++i) {
nsIWeakReference* wr = static_cast<nsIWeakReference*>(mObservers.ElementAt(i));
nsIWeakReference* wr = mObservers.ElementAt(i);
NS_RELEASE(wr);
}
while (i)
mObservers.RemoveElementAt(--i);
mObservers.Clear();
}
void
nsSVGValue::NotifyObservers(SVGObserverNotifyFunction f,
modificationType aModType)
{
PRInt32 count = mObservers.Count();
PRInt32 count = mObservers.Length();
// Since notification might cause the listeners to remove themselves
// from the observer list (mod_die), walk backwards through the list
// to catch everyone.
for (PRInt32 i = count - 1; i >= 0; i--) {
nsIWeakReference* wr = static_cast<nsIWeakReference*>(mObservers.ElementAt(i));
nsIWeakReference* wr = mObservers.ElementAt(i);
nsCOMPtr<nsISVGValueObserver> observer = do_QueryReferent(wr);
if (observer)
(static_cast<nsISVGValueObserver*>(observer)->*f)(this, aModType);
@ -108,12 +107,12 @@ nsSVGValue::AddObserver(nsISVGValueObserver* observer)
// stroke and fill. Safe, as on a style change we remove both, as
// the change notification isn't fine grained, and re-add as
// appropriate.
if (mObservers.IndexOf((void*)wr) >= 0) {
if (mObservers.Contains(wr)) {
NS_RELEASE(wr);
return NS_OK;
}
mObservers.AppendElement((void*)wr);
mObservers.AppendElement(wr);
return NS_OK;
}
@ -122,9 +121,9 @@ nsSVGValue::RemoveObserver(nsISVGValueObserver* observer)
{
nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(observer);
if (!wr) return NS_ERROR_FAILURE;
PRInt32 i = mObservers.IndexOf((void*)wr);
PRInt32 i = mObservers.IndexOf(wr);
if (i<0) return NS_ERROR_FAILURE;
nsIWeakReference* wr2 = static_cast<nsIWeakReference*>(mObservers.ElementAt(i));
nsIWeakReference* wr2 = mObservers.ElementAt(i);
NS_RELEASE(wr2);
mObservers.RemoveElementAt(i);
return NS_OK;

View File

@ -42,7 +42,7 @@
#include "nscore.h"
#include "nsISVGValue.h"
#include "nsAutoPtr.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsISVGValueObserver.h"
class nsSVGValue : public nsISVGValue
@ -80,7 +80,7 @@ protected:
private:
virtual void OnDidModify(){} // hook that will be called before observers are notified
nsSmallVoidArray mObservers;
nsAutoTArray<nsIWeakReference*, 1> mObservers;
PRInt32 mModifyNestCount;
};

View File

@ -136,9 +136,8 @@ nsXBLKeyEventHandler::ExecuteMatchedHandlers(nsIDOMKeyEvent* aKeyEvent,
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(target);
PRBool executed = PR_FALSE;
for (PRUint32 i = 0; i < mProtoHandlers.Count(); ++i) {
nsXBLPrototypeHandler* handler = static_cast<nsXBLPrototypeHandler*>
(mProtoHandlers[i]);
for (PRUint32 i = 0; i < mProtoHandlers.Length(); ++i) {
nsXBLPrototypeHandler* handler = mProtoHandlers[i];
PRBool hasAllowUntrustedAttr = handler->HasAllowUntrustedAttr();
if ((trustedEvent ||
(hasAllowUntrustedAttr && handler->AllowUntrustedEvents()) ||
@ -154,7 +153,7 @@ nsXBLKeyEventHandler::ExecuteMatchedHandlers(nsIDOMKeyEvent* aKeyEvent,
NS_IMETHODIMP
nsXBLKeyEventHandler::HandleEvent(nsIDOMEvent* aEvent)
{
PRUint32 count = mProtoHandlers.Count();
PRUint32 count = mProtoHandlers.Length();
if (count == 0)
return NS_ERROR_FAILURE;

View File

@ -41,7 +41,7 @@
#include "nsCOMPtr.h"
#include "nsIDOMEventListener.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
class nsIAtom;
class nsIContent;
@ -125,7 +125,7 @@ private:
PRBool ExecuteMatchedHandlers(nsIDOMKeyEvent* aEvent, PRUint32 aCharCode,
PRBool aIgnoreShiftKey);
nsVoidArray mProtoHandlers;
nsTArray<nsXBLPrototypeHandler*> mProtoHandlers;
nsCOMPtr<nsIAtom> mEventType;
PRUint8 mPhase;
PRUint8 mType;

View File

@ -74,6 +74,7 @@
#include "nsSyncLoadService.h"
#include "nsIDOM3Node.h"
#include "nsContentPolicyUtils.h"
#include "nsTArray.h"
#include "nsIPresShell.h"
#include "nsIDocumentObserver.h"
@ -332,7 +333,7 @@ private:
nsXBLService* mXBLService; // [WEAK]
nsCOMPtr<nsIStreamListener> mInner;
nsAutoVoidArray mBindingRequests;
nsAutoTArray<nsXBLBindingRequest*, 8> mBindingRequests;
nsCOMPtr<nsIWeakReference> mBoundDocument;
nsCOMPtr<nsIXMLContentSink> mSink; // Only set until OnStartRequest
@ -355,8 +356,8 @@ nsXBLStreamListener::nsXBLStreamListener(nsXBLService* aXBLService,
nsXBLStreamListener::~nsXBLStreamListener()
{
for (PRInt32 i = 0; i < mBindingRequests.Count(); i++) {
nsXBLBindingRequest* req = (nsXBLBindingRequest*)mBindingRequests.ElementAt(i);
for (PRInt32 i = 0; i < mBindingRequests.Length(); i++) {
nsXBLBindingRequest* req = mBindingRequests.ElementAt(i);
nsXBLBindingRequest::Destroy(mXBLService->mPool, req);
}
}
@ -421,9 +422,9 @@ PRBool
nsXBLStreamListener::HasRequest(nsIURI* aURI, nsIContent* aElt)
{
// XXX Could be more efficient.
PRUint32 count = mBindingRequests.Count();
PRUint32 count = mBindingRequests.Length();
for (PRUint32 i = 0; i < count; i++) {
nsXBLBindingRequest* req = (nsXBLBindingRequest*)mBindingRequests.ElementAt(i);
nsXBLBindingRequest* req = mBindingRequests.ElementAt(i);
PRBool eq;
if (req->mBoundElement == aElt &&
NS_SUCCEEDED(req->mBindingURI->Equals(aURI, &eq)) && eq)
@ -438,7 +439,7 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent)
{
nsresult rv = NS_OK;
PRUint32 i;
PRUint32 count = mBindingRequests.Count();
PRUint32 count = mBindingRequests.Length();
// Get the binding document; note that we don't hold onto it in this object
// to avoid creating a cycle
@ -460,7 +461,7 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent)
// We need to get the sink's notifications flushed and then make the binding
// ready.
if (count > 0) {
nsXBLBindingRequest* req = (nsXBLBindingRequest*)mBindingRequests.ElementAt(0);
nsXBLBindingRequest* req = mBindingRequests.ElementAt(0);
nsIDocument* document = req->mBoundElement->GetCurrentDoc();
if (document)
document->FlushPendingNotifications(Flush_ContentAndNotify);
@ -500,7 +501,7 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent)
// Notify all pending requests that their bindings are
// ready and can be installed.
for (i = 0; i < count; i++) {
nsXBLBindingRequest* req = (nsXBLBindingRequest*)mBindingRequests.ElementAt(i);
nsXBLBindingRequest* req = mBindingRequests.ElementAt(i);
req->DocumentLoaded(bindingDocument);
}
}

View File

@ -58,7 +58,6 @@
#include "nsIDOMCDATASection.h"
#include "nsDOMDocumentType.h"
#include "nsHTMLParts.h"
#include "nsVoidArray.h"
#include "nsCRT.h"
#include "nsICSSLoader.h"
#include "nsICSSStyleSheet.h"

View File

@ -79,7 +79,7 @@ txNamespaceMap::mapNamespace(nsIAtom* aPrefix, const nsAString& aNamespaceURI)
// Check if the mapping already exists
PRInt32 index = mPrefixes.IndexOf(prefix);
if (index >= 0) {
mNamespaces.ReplaceElementAt(NS_INT32_TO_PTR(nsId), index);
mNamespaces.ElementAt(index) = nsId;
return NS_OK;
}
@ -89,7 +89,7 @@ txNamespaceMap::mapNamespace(nsIAtom* aPrefix, const nsAString& aNamespaceURI)
return NS_ERROR_OUT_OF_MEMORY;
}
if (!mNamespaces.AppendElement(NS_INT32_TO_PTR(nsId))) {
if (mNamespaces.AppendElement(nsId) == nsnull) {
mPrefixes.RemoveObjectAt(mPrefixes.Count() - 1);
return NS_ERROR_OUT_OF_MEMORY;
@ -109,7 +109,7 @@ txNamespaceMap::lookupNamespace(nsIAtom* aPrefix)
PRInt32 index = mPrefixes.IndexOf(prefix);
if (index >= 0) {
return NS_PTR_TO_INT32(mNamespaces.SafeElementAt(index));
return mNamespaces.SafeElementAt(index, kNameSpaceID_Unknown);
}
if (!prefix) {

View File

@ -41,6 +41,7 @@
#include "nsIAtom.h"
#include "nsCOMArray.h"
#include "nsTArray.h"
class txNamespaceMap
{
@ -70,7 +71,7 @@ public:
private:
nsAutoRefCnt mRefCnt;
nsCOMArray<nsIAtom> mPrefixes;
nsVoidArray mNamespaces;
nsTArray<PRInt32> mNamespaces;
};
#endif //TRANSFRMX_TXNAMESPACEMAP_H

View File

@ -39,9 +39,9 @@
#ifndef txStack_h___
#define txStack_h___
#include "nsVoidArray.h"
#include "nsTArray.h"
class txStack : private nsVoidArray
class txStack : private nsTArray<void*>
{
public:
/**
@ -53,7 +53,7 @@ public:
inline void* peek()
{
NS_ASSERTION(!isEmpty(), "peeking at empty stack");
return ElementAt(Count() - 1);
return !isEmpty() ? ElementAt(Length() - 1) : nsnull;
}
/**
@ -64,8 +64,7 @@ public:
*/
inline nsresult push(void* aObject)
{
return InsertElementAt(aObject, Count()) ? NS_OK :
NS_ERROR_OUT_OF_MEMORY;
return AppendElement(aObject) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
/**
@ -76,10 +75,14 @@ public:
*/
inline void* pop()
{
void* object = nsnull;
NS_ASSERTION(!isEmpty(), "popping from empty stack");
const PRInt32 count = Count() - 1;
void* object = ElementAt(count);
RemoveElementsAt(count, 1);
if (!isEmpty())
{
const PRUint32 count = Length() - 1;
object = ElementAt(count);
RemoveElementAt(count);
}
return object;
}
@ -90,7 +93,7 @@ public:
*/
inline PRBool isEmpty()
{
return (Count() <= 0);
return IsEmpty();
}
/**
@ -100,7 +103,7 @@ public:
*/
inline PRInt32 size()
{
return Count();
return Length();
}
private:
@ -128,7 +131,7 @@ public:
*/
inline PRBool hasNext()
{
return (mPosition < mStack->Count());
return (mPosition < mStack->Length());
}
/**
@ -138,7 +141,7 @@ public:
*/
inline void* next()
{
if (mPosition == mStack->Count()) {
if (mPosition == mStack->Length()) {
return nsnull;
}
return mStack->ElementAt(mPosition++);
@ -146,7 +149,7 @@ public:
private:
txStack* mStack;
PRInt32 mPosition;
PRUint32 mPosition;
};
#endif /* txStack_h___ */

View File

@ -44,7 +44,6 @@
#include "nsILocalFile.h"
#include "nsISimpleEnumerator.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "prenv.h"
#include "prsystem.h"
#include "nsDirectoryServiceUtils.h"

View File

@ -57,7 +57,6 @@
#include "nsIAtom.h"
#include "nsDoubleHashtable.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "txCore.h"
#include "nsAutoPtr.h"

View File

@ -46,7 +46,6 @@
//
#include "txDOM.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "txURIUtils.h"
#include "txAtoms.h"

View File

@ -54,6 +54,7 @@
#include "txLog.h"
#include "nsUnicharUtils.h"
#include "nsAttrName.h"
#include "nsTArray.h"
const PRUint32 kUnknownIndex = PRUint32(-1);
@ -209,9 +210,9 @@ txXPathTreeWalker::moveToFirstChild()
}
NS_ASSERTION(!mPosition.isDocument() ||
(mCurrentIndex == kUnknownIndex && !mDescendants.Count()),
(mCurrentIndex == kUnknownIndex && mDescendants.IsEmpty()),
"we shouldn't have any position info at the document");
NS_ASSERTION(mCurrentIndex != kUnknownIndex || !mDescendants.Count(),
NS_ASSERTION(mCurrentIndex != kUnknownIndex || mDescendants.IsEmpty(),
"Index should be known if parents index are");
nsIContent* child = mPosition.mNode->GetChildAt(0);
@ -238,9 +239,9 @@ txXPathTreeWalker::moveToLastChild()
}
NS_ASSERTION(!mPosition.isDocument() ||
(mCurrentIndex == kUnknownIndex && !mDescendants.Count()),
(mCurrentIndex == kUnknownIndex && mDescendants.IsEmpty()),
"we shouldn't have any position info at the document");
NS_ASSERTION(mCurrentIndex != kUnknownIndex || !mDescendants.Count(),
NS_ASSERTION(mCurrentIndex != kUnknownIndex || mDescendants.IsEmpty(),
"Index should be known if parents index are");
PRUint32 total = mPosition.mNode->GetChildCount();
@ -296,7 +297,7 @@ txXPathTreeWalker::moveToParent()
return PR_FALSE;
}
PRInt32 count = mDescendants.Count();
PRUint32 count = mDescendants.Length();
if (count) {
mCurrentIndex = mDescendants.ValueAt(--count);
mDescendants.RemoveValueAt(count);
@ -691,7 +692,7 @@ txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
// same tree.
// Get parents up the tree.
nsAutoVoidArray parents, otherParents;
nsAutoTArray<nsINode*, 8> parents, otherParents;
nsINode* node = aNode.mNode;
nsINode* otherNode = aOtherNode.mNode;
nsINode* parent, *otherParent;
@ -727,17 +728,16 @@ txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
}
// Walk back down along the parent-chains until we find where they split.
PRInt32 total = parents.Count() - 1;
PRInt32 otherTotal = otherParents.Count() - 1;
PRInt32 total = parents.Length() - 1;
PRInt32 otherTotal = otherParents.Length() - 1;
NS_ASSERTION(total != otherTotal, "Can't have same number of parents");
PRInt32 lastIndex = PR_MIN(total, otherTotal);
PRInt32 i;
parent = nsnull;
for (i = 0; i <= lastIndex; ++i) {
node = static_cast<nsINode*>(parents.ElementAt(total - i));
otherNode = static_cast<nsINode*>
(otherParents.ElementAt(otherTotal - i));
node = parents.ElementAt(total - i);
otherNode = otherParents.ElementAt(otherTotal - i);
if (node != otherNode) {
if (!parent) {
// The two nodes are in different orphan subtrees.

View File

@ -44,7 +44,6 @@
#define txNodeSet_h__
#include "txExprResult.h"
#include "nsVoidArray.h"
#include "txError.h"
#include "txXPathNode.h"

View File

@ -46,22 +46,25 @@ class nsIAtom;
#ifndef TX_EXE
#include "nsINodeInfo.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
class txUint32Array : public nsVoidArray
class txUint32Array : public nsTArray<PRUint32>
{
public:
PRBool AppendValue(PRUint32 aValue)
{
return InsertElementAt(NS_INT32_TO_PTR(aValue), Count());
return AppendElement(aValue) != nsnull;
}
PRBool RemoveValueAt(PRUint32 aIndex)
{
return RemoveElementsAt(aIndex, 1);
if (aIndex < Length()) {
RemoveElementAt(aIndex);
}
return PR_TRUE;
}
PRInt32 ValueAt(PRUint32 aIndex) const
PRUint32 ValueAt(PRUint32 aIndex) const
{
return NS_PTR_TO_INT32(ElementAt(aIndex));
return (aIndex < Length()) ? ElementAt(aIndex) : 0;
}
};

View File

@ -343,22 +343,17 @@ txBufferingHandler::startElement(nsIAtom* aPrefix,
return mBuffer->addTransaction(transaction);
}
static PRBool
deleteTransaction(void* aElement, void *aData)
{
delete static_cast<txOutputTransaction*>(aElement);
return PR_TRUE;
}
txResultBuffer::~txResultBuffer()
{
mTransactions.EnumerateForwards(deleteTransaction, nsnull);
for (PRUint32 i, len = mTransactions.Length(); i < len; ++i) {
delete mTransactions[i];
}
}
nsresult
txResultBuffer::addTransaction(txOutputTransaction* aTransaction)
{
if (!mTransactions.AppendElement(aTransaction)) {
if (mTransactions.AppendElement(aTransaction) == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
@ -372,12 +367,11 @@ struct Holder
};
static PRBool
flushTransaction(void* aElement, void *aData)
flushTransaction(txOutputTransaction* aElement, Holder* aData)
{
Holder* holder = static_cast<Holder*>(aData);
Holder* holder = aData;
txAXMLEventHandler* handler = *holder->mHandler;
txOutputTransaction* transaction =
static_cast<txOutputTransaction*>(aElement);
txOutputTransaction* transaction = aElement;
nsresult rv;
switch (transaction->mType) {
@ -474,7 +468,11 @@ txResultBuffer::flushToHandler(txAXMLEventHandler** aHandler)
Holder data = { aHandler, NS_OK };
mStringValue.BeginReading(data.mIter);
mTransactions.EnumerateForwards(flushTransaction, &data);
for (PRUint32 i, len = mTransactions.Length(); i < len; ++i) {
if (!flushTransaction(mTransactions[i], &data)) {
break;
}
}
return data.mResult;
}
@ -482,9 +480,9 @@ txResultBuffer::flushToHandler(txAXMLEventHandler** aHandler)
txOutputTransaction*
txResultBuffer::getLastTransaction()
{
PRInt32 last = mTransactions.Count() - 1;
PRInt32 last = mTransactions.Length() - 1;
if (last < 0) {
return nsnull;
}
return static_cast<txOutputTransaction*>(mTransactions[last]);
return mTransactions[last];
}

View File

@ -42,7 +42,7 @@
#include "txXMLEventHandler.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsAutoPtr.h"
class txOutputTransaction;
@ -67,7 +67,7 @@ public:
nsString mStringValue;
private:
nsVoidArray mTransactions;
nsTArray<txOutputTransaction*> mTransactions;
};
class txBufferingHandler : public txAXMLEventHandler

View File

@ -42,7 +42,6 @@
#include "txCore.h"
#include "txStack.h"
#include "txXMLUtils.h"
#include "nsVoidArray.h"
#include "txIXPathContext.h"
#include "txVariableMap.h"
#include "nsTHashtable.h"

View File

@ -642,10 +642,10 @@ txPushNewContext::txPushNewContext(nsAutoPtr<Expr> aSelect)
txPushNewContext::~txPushNewContext()
{
PRInt32 i;
for (i = 0; i < mSortKeys.Count(); ++i)
PRUint32 i;
for (i = 0; i < mSortKeys.Length(); ++i)
{
delete static_cast<SortKey*>(mSortKeys[i]);
delete mSortKeys[i];
}
}
@ -673,9 +673,9 @@ txPushNewContext::execute(txExecutionState& aEs)
}
txNodeSorter sorter;
PRInt32 i, count = mSortKeys.Count();
PRUint32 i, count = mSortKeys.Length();
for (i = 0; i < count; ++i) {
SortKey* sort = static_cast<SortKey*>(mSortKeys[i]);
SortKey* sort = mSortKeys[i];
rv = sorter.addSortElement(sort->mSelectExpr, sort->mLangExpr,
sort->mDataTypeExpr, sort->mOrderExpr,
sort->mCaseOrderExpr,
@ -711,7 +711,7 @@ txPushNewContext::addSort(nsAutoPtr<Expr> aSelectExpr,
aOrderExpr, aCaseOrderExpr);
NS_ENSURE_TRUE(sort, NS_ERROR_OUT_OF_MEMORY);
if (!mSortKeys.AppendElement(sort)) {
if (mSortKeys.AppendElement(sort) == nsnull) {
delete sort;
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -46,6 +46,7 @@
#include "txNamespaceMap.h"
#include "nsAutoPtr.h"
#include "txXSLTNumber.h"
#include "nsTArray.h"
class nsIAtom;
class txExecutionState;
@ -304,7 +305,7 @@ public:
nsAutoPtr<Expr> mCaseOrderExpr;
};
nsVoidArray mSortKeys;
nsTArray<SortKey*> mSortKeys;
nsAutoPtr<Expr> mSelect;
txInstruction* mBailTarget;
};

View File

@ -229,8 +229,8 @@ txStylesheetCompiler::startElementInternal(PRInt32 aNamespaceID,
{
nsresult rv = NS_OK;
PRInt32 i;
for (i = mInScopeVariables.Count() - 1; i >= 0; --i) {
++(static_cast<txInScopeVariable*>(mInScopeVariables[i]))->mLevel;
for (i = mInScopeVariables.Length() - 1; i >= 0; --i) {
++mInScopeVariables[i]->mLevel;
}
// Update the elementcontext if we have special attributes
@ -287,7 +287,7 @@ txStylesheetCompiler::startElementInternal(PRInt32 aNamespaceID,
return NS_ERROR_XSLT_PARSE_FAILURE;
if (!mElementContext->mInstructionNamespaces.
AppendElement(NS_INT32_TO_PTR(namespaceID))) {
AppendElement(namespaceID)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
@ -318,10 +318,9 @@ txStylesheetCompiler::startElementInternal(PRInt32 aNamespaceID,
// Find the right elementhandler and execute it
MBool isInstruction = MB_FALSE;
PRInt32 count = mElementContext->mInstructionNamespaces.Count();
PRInt32 count = mElementContext->mInstructionNamespaces.Length();
for (i = 0; i < count; ++i) {
if (NS_PTR_TO_INT32(mElementContext->mInstructionNamespaces[i]) ==
aNamespaceID) {
if (mElementContext->mInstructionNamespaces[i] == aNamespaceID) {
isInstruction = MB_TRUE;
break;
}
@ -381,9 +380,8 @@ txStylesheetCompiler::endElement()
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 i;
for (i = mInScopeVariables.Count() - 1; i >= 0; --i) {
txInScopeVariable* var =
static_cast<txInScopeVariable*>(mInScopeVariables[i]);
for (i = mInScopeVariables.Length() - 1; i >= 0; --i) {
txInScopeVariable* var = mInScopeVariables[i];
if (!--(var->mLevel)) {
nsAutoPtr<txInstruction> instr(new txRemoveVariable(var->mName));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
@ -544,7 +542,7 @@ txStylesheetCompiler::ensureNewElementContext()
nsresult
txStylesheetCompiler::maybeDoneCompiling()
{
if (!mDoneWithThisStylesheet || mChildCompilerList.Count()) {
if (!mDoneWithThisStylesheet || !mChildCompilerList.IsEmpty()) {
return NS_OK;
}
@ -647,8 +645,8 @@ txStylesheetCompilerState::~txStylesheetCompilerState()
}
PRInt32 i;
for (i = mInScopeVariables.Count() - 1; i >= 0; --i) {
delete static_cast<txInScopeVariable*>(mInScopeVariables[i]);
for (i = mInScopeVariables.Length() - 1; i >= 0; --i) {
delete mInScopeVariables[i];
}
}
@ -755,7 +753,7 @@ txStylesheetCompilerState::openInstructionContainer(txInstructionContainer* aCon
void
txStylesheetCompilerState::closeInstructionContainer()
{
NS_ASSERTION(mGotoTargetPointers.Count() == 0,
NS_ASSERTION(mGotoTargetPointers.IsEmpty(),
"GotoTargets still exists, did you forget to add txReturn?");
mNextInstrPtr = 0;
}
@ -770,9 +768,9 @@ txStylesheetCompilerState::addInstruction(nsAutoPtr<txInstruction> aInstruction)
*mNextInstrPtr = aInstruction.forget();
mNextInstrPtr = newInstr->mNext.StartAssignment();
PRInt32 i, count = mGotoTargetPointers.Count();
PRUint32 i, count = mGotoTargetPointers.Length();
for (i = 0; i < count; ++i) {
*static_cast<txInstruction**>(mGotoTargetPointers[i]) = newInstr;
*mGotoTargetPointers[i] = newInstr;
}
mGotoTargetPointers.Clear();
@ -811,7 +809,7 @@ txStylesheetCompilerState::loadIncludedStylesheet(const nsAString& aURI)
// step forward before calling the observer in case of syncronous loading
mToplevelIterator.next();
if (!mChildCompilerList.AppendElement(compiler)) {
if (mChildCompilerList.AppendElement(compiler) == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -844,7 +842,7 @@ txStylesheetCompilerState::loadImportedStylesheet(const nsAString& aURI,
new txStylesheetCompiler(aURI, mStylesheet, &iter, observer);
NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);
if (!mChildCompilerList.AppendElement(compiler)) {
if (mChildCompilerList.AppendElement(compiler) == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -859,7 +857,7 @@ txStylesheetCompilerState::loadImportedStylesheet(const nsAString& aURI,
nsresult
txStylesheetCompilerState::addGotoTarget(txInstruction** aTargetPointer)
{
if (!mGotoTargetPointers.AppendElement(aTargetPointer)) {
if (mGotoTargetPointers.AppendElement(aTargetPointer) == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1162,7 +1160,7 @@ txElementContext::txElementContext(const nsAString& aBaseURI)
mMappings(new txNamespaceMap),
mDepth(0)
{
mInstructionNamespaces.AppendElement(NS_INT32_TO_PTR(kNameSpaceID_XSLT));
mInstructionNamespaces.AppendElement(kNameSpaceID_XSLT);
}
txElementContext::txElementContext(const txElementContext& aOther)

View File

@ -45,6 +45,7 @@
#include "txIXPathContext.h"
#include "nsAutoPtr.h"
#include "txStylesheet.h"
#include "nsTArray.h"
extern PRBool
TX_XSLTFunctionAvailable(nsIAtom* aName, PRInt32 aNameSpaceID);
@ -57,6 +58,7 @@ class txNamespaceMap;
class txToplevelItem;
class txPushNewContext;
class txStylesheetCompiler;
class txInScopeVariable;
class txElementContext : public TxObject
{
@ -68,7 +70,7 @@ public:
PRBool mForwardsCompatibleParsing;
nsString mBaseURI;
nsRefPtr<txNamespaceMap> mMappings;
nsVoidArray mInstructionNamespaces;
nsTArray<PRInt32> mInstructionNamespaces;
PRInt32 mDepth;
};
@ -169,8 +171,8 @@ public:
protected:
nsRefPtr<txACompileObserver> mObserver;
nsVoidArray mInScopeVariables;
nsVoidArray mChildCompilerList;
nsTArray<txInScopeVariable*> mInScopeVariables;
nsTArray<txStylesheetCompiler*> mChildCompilerList;
// embed info, target information is the ID
nsString mTarget;
enum
@ -189,7 +191,7 @@ protected:
private:
txInstruction** mNextInstrPtr;
txListIterator mToplevelIterator;
nsVoidArray mGotoTargetPointers;
nsTArray<txInstruction**> mGotoTargetPointers;
};
struct txStylesheetAttr

View File

@ -41,7 +41,6 @@
#include "txExpr.h"
#include "txXMLUtils.h"
#include "nsVoidArray.h"
class ProcessorState;

View File

@ -46,7 +46,6 @@
#include "nsIXMLContentSink.h"
#include "nsAutoPtr.h"
#include "nsNodeInfoManager.h"
#include "nsVoidArray.h"
#include "nsWeakPtr.h"
#include "nsXULElement.h"

View File

@ -67,10 +67,10 @@ nsXULControllers::~nsXULControllers(void)
void
nsXULControllers::DeleteControllers()
{
PRUint32 count = mControllers.Count();
PRUint32 count = mControllers.Length();
for (PRUint32 i = 0; i < count; i++)
{
nsXULControllerData* controllerData = static_cast<nsXULControllerData*>(mControllers.ElementAt(i));
nsXULControllerData* controllerData = mControllers.ElementAt(i);
if (controllerData)
delete controllerData; // releases the nsIController
}
@ -103,10 +103,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULControllers)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULControllers)
{
PRUint32 i, count = tmp->mControllers.Count();
PRUint32 i, count = tmp->mControllers.Length();
for (i = 0; i < count; ++i) {
nsXULControllerData* controllerData =
static_cast<nsXULControllerData*>(tmp->mControllers[i]);
nsXULControllerData* controllerData = tmp->mControllers[i];
if (controllerData) {
cb.NoteXPCOMChild(controllerData->mController);
}
@ -130,10 +129,10 @@ nsXULControllers::GetControllerForCommand(const char *aCommand, nsIController**
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
PRUint32 count = mControllers.Count();
PRUint32 count = mControllers.Length();
for (PRUint32 i=0; i < count; i++)
{
nsXULControllerData* controllerData = static_cast<nsXULControllerData*>(mControllers.ElementAt(i));
nsXULControllerData* controllerData = mControllers.ElementAt(i);
if (controllerData)
{
nsCOMPtr<nsIController> controller;
@ -160,10 +159,10 @@ nsXULControllers::InsertControllerAt(PRUint32 aIndex, nsIController *controller)
nsXULControllerData* controllerData = new nsXULControllerData(++mCurControllerID, controller);
if (!controllerData) return NS_ERROR_OUT_OF_MEMORY;
#ifdef DEBUG
PRBool inserted =
nsXULControllerData** inserted =
#endif
mControllers.InsertElementAt((void *)controllerData, aIndex);
NS_ASSERTION(inserted, "Insertion of controller failed");
mControllers.InsertElementAt(aIndex, controllerData);
NS_ASSERTION(inserted != nsnull, "Insertion of controller failed");
return NS_OK;
}
@ -173,14 +172,10 @@ nsXULControllers::RemoveControllerAt(PRUint32 aIndex, nsIController **_retval)
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
nsXULControllerData* controllerData = static_cast<nsXULControllerData*>(mControllers.SafeElementAt(aIndex));
nsXULControllerData* controllerData = mControllers.SafeElementAt(aIndex);
if (!controllerData) return NS_ERROR_FAILURE;
#ifdef DEBUG
PRBool removed =
#endif
mControllers.RemoveElementAt(aIndex);
NS_ASSERTION(removed, "Removal of controller failed");
controllerData->GetController(_retval);
delete controllerData;
@ -195,7 +190,7 @@ nsXULControllers::GetControllerAt(PRUint32 aIndex, nsIController **_retval)
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
nsXULControllerData* controllerData = static_cast<nsXULControllerData*>(mControllers.SafeElementAt(aIndex));
nsXULControllerData* controllerData = mControllers.SafeElementAt(aIndex);
if (!controllerData) return NS_ERROR_FAILURE;
return controllerData->GetController(_retval); // does the addref
@ -209,10 +204,10 @@ nsXULControllers::AppendController(nsIController *controller)
if (!controllerData) return NS_ERROR_OUT_OF_MEMORY;
#ifdef DEBUG
PRBool appended =
nsXULControllerData** appended =
#endif
mControllers.AppendElement((void *)controllerData);
NS_ASSERTION(appended, "Appending controller failed");
mControllers.AppendElement(controllerData);
NS_ASSERTION(appended != nsnull, "Appending controller failed");
return NS_OK;
}
@ -222,10 +217,10 @@ nsXULControllers::RemoveController(nsIController *controller)
// first get the identity pointer
nsCOMPtr<nsISupports> controllerSup(do_QueryInterface(controller));
// then find it
PRUint32 count = mControllers.Count();
PRUint32 count = mControllers.Length();
for (PRUint32 i = 0; i < count; i++)
{
nsXULControllerData* controllerData = static_cast<nsXULControllerData*>(mControllers.ElementAt(i));
nsXULControllerData* controllerData = mControllers.ElementAt(i);
if (controllerData)
{
nsCOMPtr<nsIController> thisController;
@ -248,10 +243,10 @@ nsXULControllers::GetControllerId(nsIController *controller, PRUint32 *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
PRUint32 count = mControllers.Count();
PRUint32 count = mControllers.Length();
for (PRUint32 i = 0; i < count; i++)
{
nsXULControllerData* controllerData = static_cast<nsXULControllerData*>(mControllers.ElementAt(i));
nsXULControllerData* controllerData = mControllers.ElementAt(i);
if (controllerData)
{
nsCOMPtr<nsIController> thisController;
@ -272,10 +267,10 @@ nsXULControllers::GetControllerById(PRUint32 controllerID, nsIController **_retv
{
NS_ENSURE_ARG_POINTER(_retval);
PRUint32 count = mControllers.Count();
PRUint32 count = mControllers.Length();
for (PRUint32 i = 0; i < count; i++)
{
nsXULControllerData* controllerData = static_cast<nsXULControllerData*>(mControllers.ElementAt(i));
nsXULControllerData* controllerData = mControllers.ElementAt(i);
if (controllerData && controllerData->GetControllerID() == controllerID)
{
return controllerData->GetController(_retval);
@ -288,7 +283,7 @@ NS_IMETHODIMP
nsXULControllers::GetControllerCount(PRUint32 *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mControllers.Count();
*_retval = mControllers.Length();
return NS_OK;
}

View File

@ -46,7 +46,7 @@
#define nsXULControllers_h__
#include "nsCOMPtr.h"
#include "nsVoidArray.h"
#include "nsTPtrArray.h"
#include "nsWeakPtr.h"
#include "nsIControllers.h"
#include "nsISecurityCheckedComponent.h"
@ -97,8 +97,8 @@ protected:
void DeleteControllers();
nsVoidArray mControllers;
PRUint32 mCurControllerID;
nsTPtrArray<nsXULControllerData> mControllers;
PRUint32 mCurControllerID;
};

View File

@ -45,7 +45,6 @@
#include "nsIRDFResource.h"
#include "nsIContent.h"
#include "nsIDOMNode.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsString.h"
#include "nsIXULTemplateRuleFilter.h"
@ -277,7 +276,7 @@ protected:
class nsTemplateQuerySet
{
protected:
nsVoidArray mRules; // rules owned by nsTemplateQuerySet
nsTArray<nsTemplateRule*> mRules; // rules owned by nsTemplateQuerySet
// a number which increments for each successive queryset. It is stored so
// it can be used as an optimization when updating results so that it is
@ -321,28 +320,28 @@ public:
{
// nsTemplateMatch stores the index as a 16-bit value,
// so check to make sure for overflow
if (mRules.Count() == PR_INT16_MAX)
if (mRules.Length() == PR_INT16_MAX)
return NS_ERROR_FAILURE;
if (!mRules.AppendElement(aChild))
if (mRules.AppendElement(aChild) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
PRInt16 RuleCount() const
{
return mRules.Count();
return mRules.Length();
}
nsTemplateRule* GetRuleAt(PRInt16 aIndex)
{
return static_cast<nsTemplateRule*>(mRules[aIndex]);
return mRules[aIndex];
}
void Clear()
{
for (PRInt32 r = mRules.Count() - 1; r >= 0; r--) {
nsTemplateRule* rule = static_cast<nsTemplateRule*>(mRules[r]);
for (PRInt32 r = mRules.Length() - 1; r >= 0; r--) {
nsTemplateRule* rule = mRules[r];
delete rule;
}
mRules.Clear();

View File

@ -54,7 +54,7 @@
#include "nsXULSortService.h"
#include "nsTemplateRule.h"
#include "nsTemplateMap.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsXPIDLString.h"
#include "nsGkAtoms.h"
#include "nsXULContentUtils.h"
@ -1323,15 +1323,15 @@ nsXULContentBuilder::RemoveGeneratedContent(nsIContent* aElement)
{
// Keep a queue of "ungenerated" elements that we have to probe
// for generated content.
nsAutoVoidArray ungenerated;
if (!ungenerated.AppendElement(aElement))
nsAutoTArray<nsIContent*, 8> ungenerated;
if (ungenerated.AppendElement(aElement) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
PRInt32 count;
while (0 != (count = ungenerated.Count())) {
PRUint32 count;
while (0 != (count = ungenerated.Length())) {
// Pull the next "ungenerated" element off the queue.
PRInt32 last = count - 1;
nsIContent* element = static_cast<nsIContent*>(ungenerated[last]);
PRUint32 last = count - 1;
nsIContent* element = ungenerated[last];
ungenerated.RemoveElementAt(last);
PRUint32 i = element->GetChildCount();
@ -1357,7 +1357,7 @@ nsXULContentBuilder::RemoveGeneratedContent(nsIContent* aElement)
if (! tmpl) {
// No 'template' attribute, so this must not have been
// generated. We'll need to examine its kids.
if (!ungenerated.AppendElement(child))
if (ungenerated.AppendElement(child) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
continue;
}

View File

@ -89,7 +89,7 @@
#include "nsRDFCID.h"
#include "nsXULContentUtils.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsXPIDLString.h"
#include "nsWhitespaceTokenizer.h"
#include "nsGkAtoms.h"
@ -2488,15 +2488,15 @@ nsXULTemplateBuilder::AddSimpleRuleBindings(nsTemplateRule* aRule,
// Crawl the content tree of a "simple" rule, adding a variable
// assignment for any attribute whose value is "rdf:".
nsAutoVoidArray elements;
nsAutoTArray<nsIContent*, 8> elements;
if (!elements.AppendElement(aElement))
if (elements.AppendElement(aElement) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
while (elements.Count()) {
while (elements.Length()) {
// Pop the next element off the stack
PRUint32 i = (PRUint32)(elements.Count() - 1);
nsIContent* element = static_cast<nsIContent*>(elements[i]);
PRUint32 i = elements.Length() - 1;
nsIContent* element = elements[i];
elements.RemoveElementAt(i);
// Iterate through its attributes, looking for substitutions
@ -2521,7 +2521,7 @@ nsXULTemplateBuilder::AddSimpleRuleBindings(nsTemplateRule* aRule,
count = element->GetChildCount();
while (count-- > 0) {
if (!elements.AppendElement(element->GetChildAt(count)))
if (elements.AppendElement(element->GetChildAt(count)) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
}
}

View File

@ -56,7 +56,6 @@
#include "nsIXULTemplateBuilder.h"
#include "nsFixedSizeAllocator.h"
#include "nsVoidArray.h"
#include "nsCOMArray.h"
#include "nsTArray.h"
#include "nsDataHashtable.h"

View File

@ -61,7 +61,6 @@
#include "nsRDFQuery.h"
#include "nsRDFBinding.h"
#include "nsXULTemplateResultSetRDF.h"
#include "nsVoidArray.h"
#include "nsCOMArray.h"
#include "nsIArray.h"
#include "nsString.h"

View File

@ -59,7 +59,7 @@
#include "nsGkAtoms.h"
#include "nsXULContentUtils.h"
#include "nsXULTemplateBuilder.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsUnicharUtils.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMClassInfo.h"
@ -152,7 +152,7 @@ protected:
nsIXULTemplateResult *aResult,
nsTemplateQuerySet* aQuerySet,
PRInt32* aDelta,
nsAutoVoidArray& open);
nsTArray<PRInt32>& open);
/**
* Close a container row, removing the container's childrem from
@ -1522,7 +1522,7 @@ nsXULTreeBuilder::OpenSubtreeOf(nsTreeRows::Subtree* aSubtree,
nsIXULTemplateResult *aResult,
PRInt32* aDelta)
{
nsAutoVoidArray open;
nsAutoTArray<PRInt32, 8> open;
PRInt32 count = 0;
PRInt32 rulecount = mQuerySets.Length();
@ -1534,8 +1534,8 @@ nsXULTreeBuilder::OpenSubtreeOf(nsTreeRows::Subtree* aSubtree,
// Now recursively deal with any open sub-containers that just got
// inserted. We need to do this back-to-front to avoid skewing offsets.
for (PRInt32 i = open.Count() - 1; i >= 0; --i) {
PRInt32 index = NS_PTR_TO_INT32(open[i]);
for (PRInt32 i = open.Length() - 1; i >= 0; --i) {
PRInt32 index = open[i];
nsTreeRows::Subtree* child =
mRows.EnsureSubtreeFor(aSubtree, index);
@ -1566,7 +1566,7 @@ nsXULTreeBuilder::OpenSubtreeForQuerySet(nsTreeRows::Subtree* aSubtree,
nsIXULTemplateResult* aResult,
nsTemplateQuerySet* aQuerySet,
PRInt32* aDelta,
nsAutoVoidArray& open)
nsTArray<PRInt32>& open)
{
PRInt32 count = *aDelta;
@ -1674,7 +1674,7 @@ nsXULTreeBuilder::OpenSubtreeForQuerySet(nsTreeRows::Subtree* aSubtree,
PRBool isOpen = PR_FALSE;
IsContainerOpen(nextresult, &isOpen);
if (isOpen) {
if (!open.AppendElement(NS_INT32_TO_PTR(count)))
if (open.AppendElement(count) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
}