diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 5f5c212b1490..9797b72cfce6 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -99,7 +99,6 @@ class nsIRunnable; class nsIInterfaceRequestor; template 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* 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* aAncestorNodes, + nsTArray* 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* sPtrsToPtrsToRelease; static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND]; static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND]; diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 0eafd97dc012..61f9d024a12c 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -48,7 +48,6 @@ class nsIAtom; class nsIDocument; class nsPresContext; -class nsVoidArray; class nsIDOMEvent; class nsIContent; class nsIEventListenerManager; diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 48c934d0f81c..516e590e1fa1 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -59,7 +59,6 @@ class nsEventChainPreVisitor; class nsEventChainPostVisitor; class nsIEventListenerManager; class nsIPrincipal; -class nsVoidArray; class nsIMutationObserver; class nsChildContentList; class nsNodeWeakReference; diff --git a/content/base/public/nsXMLNameSpaceMap.h b/content/base/public/nsXMLNameSpaceMap.h index 411a2d5f2ca9..b3b0c3c035e6 100644 --- a/content/base/public/nsXMLNameSpaceMap.h +++ b/content/base/public/nsXMLNameSpaceMap.h @@ -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 mNameSpaces; }; #endif diff --git a/content/base/src/nsContentIterator.cpp b/content/base/src/nsContentIterator.cpp index cba70fb6fe33..8eabc626cfd4 100644 --- a/content/base/src/nsContentIterator.cpp +++ b/content/base/src/nsContentIterator.cpp @@ -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 *aIndexes); + nsINode* GetDeepLastChild(nsINode *aRoot, nsTArray *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 *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 *aIndexes); - nsINode* NextNode(nsINode *aNode, nsVoidArray *aIndexes); - nsINode* PrevNode(nsINode *aNode, nsVoidArray *aIndexes); + nsINode* NextNode(nsINode *aNode, nsTArray *aIndexes); + nsINode* PrevNode(nsINode *aNode, nsTArray *aIndexes); // WARNING: This function is expensive nsresult RebuildIndexStack(); @@ -180,7 +180,7 @@ protected: nsCOMPtr mCommonParent; // used by nsContentIterator to cache indices - nsAutoVoidArray mIndexes; + nsAutoTArray 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 *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 *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 *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 *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 *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 *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 oldParentStack; + nsAutoTArray 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 mRange; // these arrays all typically are used and have elements #if 0 - nsAutoVoidArray mStartNodes; - nsAutoVoidArray mStartOffsets; + nsAutoTArray mStartNodes; + nsAutoTArray mStartOffsets; #endif - nsAutoVoidArray mEndNodes; - nsAutoVoidArray mEndOffsets; + nsAutoTArray mEndNodes; + nsAutoTArray mEndOffsets; }; nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aInstancePtrResult); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index e3e97b8444a4..a857ff542da9 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -204,7 +204,7 @@ nsILineBreaker *nsContentUtils::sLineBreaker; nsIWordBreaker *nsContentUtils::sWordBreaker; nsICaseConversion *nsContentUtils::sCaseConv; nsIUGenCategory *nsContentUtils::sGenCat; -nsVoidArray *nsContentUtils::sPtrsToPtrsToRelease; +nsTArray *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(); 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(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* 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* aAncestorNodes, + nsTArray* 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(); } diff --git a/content/base/src/nsDOMLists.h b/content/base/src/nsDOMLists.h index 0be8f3ced121..fa2efde4228a 100644 --- a/content/base/src/nsDOMLists.h +++ b/content/base/src/nsDOMLists.h @@ -47,7 +47,6 @@ #include "nsIDOMDOMStringList.h" #include "nsIDOMNameList.h" -#include "nsVoidArray.h" #include "nsTArray.h" #include "nsString.h" diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 341f74adefce..11dabf0bbbb3 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -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(mCharSetObservers.ElementAt(i)); + nsIObserver* observer = mCharSetObservers.ElementAt(i); observer->Observe(static_cast(this), "charset", NS_ConvertASCIItoUTF16(aCharSetID).get()); diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 1c8a999b7b1f..ed5dc90c4c32 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -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 mCharSetObservers; PLDHashTable *mSubDocuments; diff --git a/content/base/src/nsDocumentEncoder.cpp b/content/base/src/nsDocumentEncoder.cpp index 3e3579f99377..46773549ec49 100644 --- a/content/base/src/nsDocumentEncoder.cpp +++ b/content/base/src/nsDocumentEncoder.cpp @@ -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& aAncestorArray, nsAString& aString); - nsresult SerializeRangeContextEnd(const nsVoidArray& aAncestorArray, + nsresult SerializeRangeContextEnd(const nsTArray& 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 mCommonAncestors; + nsAutoTArray mStartNodes; + nsAutoTArray mStartOffsets; + nsAutoTArray mEndNodes; + nsAutoTArray 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& 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& 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 startNode, endNode; PRInt32 start = mStartRootIndex - aDepth; - if (start >= 0 && start <= mStartNodes.Count()) - startNode = static_cast(mStartNodes[start]); + if (start >= 0 && start <= mStartNodes.Length()) + startNode = mStartNodes[start]; PRInt32 end = mEndRootIndex - aDepth; - if (end >= 0 && end <= mEndNodes.Count()) - endNode = static_cast(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 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& 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& 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 node; if (count > 0) - node = static_cast(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(mCommonAncestors.ElementAt(--i)); + node = mCommonAncestors.ElementAt(--i); SerializeNodeStart(node, 0, -1, aContextString); } //i = 0; guaranteed by above while (i < count) { - node = static_cast(mCommonAncestors.ElementAt(i++)); + node = mCommonAncestors.ElementAt(i++); SerializeNodeEnd(node, aContextString); } diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index 543eaaae14bb..291783b349d7 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -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" diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index 0d9ec89807a7..c6ecd2aa5fd2 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -76,7 +76,6 @@ class nsIDOMNamedNodeMap; class nsDOMCSSDeclaration; class nsIDOMCSSStyleDeclaration; class nsIURI; -class nsVoidArray; class nsINodeInfo; class nsIControllers; class nsIDOMNSFeatureFactory; diff --git a/content/base/src/nsHTMLContentSerializer.cpp b/content/base/src/nsHTMLContentSerializer.cpp index d57e7af751f9..d6e816442a2c 100644 --- a/content/base/src/nsHTMLContentSerializer.cpp +++ b/content/base/src/nsHTMLContentSerializer.cpp @@ -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.*/ diff --git a/content/base/src/nsHTMLContentSerializer.h b/content/base/src/nsHTMLContentSerializer.h index 790a58ec39e1..eaa0966cd453 100644 --- a/content/base/src/nsHTMLContentSerializer.h +++ b/content/base/src/nsHTMLContentSerializer.h @@ -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
    . + // Stack to store one olState struct per
      . + nsAutoTArray mOLStateStack; }; nsresult diff --git a/content/base/src/nsPlainTextSerializer.cpp b/content/base/src/nsPlainTextSerializer.cpp index bd57b0567b9c..88bdf4f36f46 100644 --- a/content/base/src/nsPlainTextSerializer.cpp +++ b/content/base/src/nsPlainTextSerializer.cpp @@ -235,21 +235,21 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn, } PRBool -nsPlainTextSerializer::GetLastBool(const nsVoidArray& aStack) +nsPlainTextSerializer::GetLastBool(const nsTArray& aStack) { - PRUint32 size = aStack.Count(); + PRUint32 size = aStack.Length(); if (size == 0) { return PR_FALSE; } - return (aStack.ElementAt(size-1) != reinterpret_cast(PR_FALSE)); + return aStack.ElementAt(size-1); } void -nsPlainTextSerializer::SetLastBool(nsVoidArray& aStack, PRBool aValue) +nsPlainTextSerializer::SetLastBool(nsTArray& aStack, PRBool aValue) { - PRUint32 size = aStack.Count(); + PRUint32 size = aStack.Length(); if (size > 0) { - aStack.ReplaceElementAt(reinterpret_cast(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& aStack, PRBool aValue) { - aStack.AppendElement(reinterpret_cast(aValue)); + aStack.AppendElement(PRPackedBool(aValue)); } PRBool -nsPlainTextSerializer::PopBool(nsVoidArray& aStack) +nsPlainTextSerializer::PopBool(nsTArray& aStack) { PRBool returnValue = PR_FALSE; - PRUint32 size = aStack.Count(); + PRUint32 size = aStack.Length(); if (size > 0) { - returnValue = (aStack.ElementAt(size-1) != reinterpret_cast(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 (nor a ) before the
      if we're // copying part of a table PushBool(mHasWrittenCellsForRow, PR_TRUE); // will never be popped diff --git a/content/base/src/nsPlainTextSerializer.h b/content/base/src/nsPlainTextSerializer.h index d484cf603627..d296c7333094 100644 --- a/content/base/src/nsPlainTextSerializer.h +++ b/content/base/src/nsPlainTextSerializer.h @@ -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& aStack); + void SetLastBool(nsTArray& aStack, PRBool aValue); + void PushBool(nsTArray& aStack, PRBool aValue); + PRBool PopBool(nsTArray& aStack); protected: nsString mCurrentLine; @@ -241,11 +241,11 @@ protected: nsCOMPtr mContent; // For handling table rows - nsAutoVoidArray mHasWrittenCellsForRow; // really an array of bools + nsAutoTArray 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 mCurrentNodeIsConverted; + nsAutoTArray mIsInCiteBlockquote; // The output data nsAString* mOutputString; diff --git a/content/base/src/nsRange.h b/content/base/src/nsRange.h index 5b62a51e2610..cf7b9c498892 100644 --- a/content/base/src/nsRange.h +++ b/content/base/src/nsRange.h @@ -53,8 +53,6 @@ #include "prmon.h" #include "nsStubMutationObserver.h" -class nsVoidArray; - // ------------------------------------------------------------------------------- class nsRangeUtils : public nsIRangeUtils diff --git a/content/base/src/nsScriptEventManager.h b/content/base/src/nsScriptEventManager.h index 3f26f278c4b7..844727b3ce0d 100644 --- a/content/base/src/nsScriptEventManager.h +++ b/content/base/src/nsScriptEventManager.h @@ -44,7 +44,6 @@ #include "nsCOMPtr.h" #include "nsAString.h" -#include "nsVoidArray.h" #include "nsIScriptEventManager.h" #include "nsIDOMNodeList.h" diff --git a/content/base/src/nsStyleLinkElement.cpp b/content/base/src/nsStyleLinkElement.cpp index 8f2a7d8f6135..d85a09ca4e8e 100644 --- a/content/base/src/nsStyleLinkElement.cpp +++ b/content/base/src/nsStyleLinkElement.cpp @@ -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" diff --git a/content/base/src/nsTreeWalker.cpp b/content/base/src/nsTreeWalker.cpp index d412f1112288..b757d48f5d33 100644 --- a/content/base/src/nsTreeWalker.cpp +++ b/content/base/src/nsTreeWalker.cpp @@ -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; } diff --git a/content/base/src/nsTreeWalker.h b/content/base/src/nsTreeWalker.h index acf5562c02a4..fce5172bd3e3 100644 --- a/content/base/src/nsTreeWalker.h +++ b/content/base/src/nsTreeWalker.h @@ -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 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; + } } }; diff --git a/content/base/src/nsXMLContentSerializer.cpp b/content/base/src/nsXMLContentSerializer.cpp index 6f3fa5d07064..4f4536dd4ac6 100644 --- a/content/base/src/nsXMLContentSerializer.cpp +++ b/content/base/src/nsXMLContentSerializer.cpp @@ -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); } diff --git a/content/base/src/nsXMLContentSerializer.h b/content/base/src/nsXMLContentSerializer.h index 57f4cf005f73..a2ca27210935 100644 --- a/content/base/src/nsXMLContentSerializer.h +++ b/content/base/src/nsXMLContentSerializer.h @@ -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 mNameSpaceStack; // nsIDocumentEncoder flags PRUint32 mFlags; diff --git a/content/base/src/nsXMLNameSpaceMap.cpp b/content/base/src/nsXMLNameSpaceMap.cpp index 025709e135d9..ad12e767a3fb 100644 --- a/content/base/src/nsXMLNameSpaceMap.cpp +++ b/content/base/src/nsXMLNameSpaceMap.cpp @@ -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 - (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 - (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 - (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 - (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(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(); } diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index a7a7a0947242..ac2779d19b5f 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -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 mCurrentForm; - nsAutoVoidArray mContextStack; + nsAutoTArray 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(); } diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index a66d247970e2..b04336f846a3 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -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; } diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index c931290fe852..42a99dec96fd 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -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 mPendingScripts; // Load flags of the document's channel PRUint32 mLoadFlags; diff --git a/content/html/document/src/nsHTMLFragmentContentSink.cpp b/content/html/document/src/nsHTMLFragmentContentSink.cpp index 9380a12fbe51..485909f21286 100644 --- a/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -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 mRoot; nsCOMPtr mParser; - nsVoidArray* mContentStack; + nsTArray* 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(); } - 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); } } diff --git a/content/svg/content/src/nsSVGDataParser.h b/content/svg/content/src/nsSVGDataParser.h index 2661827afb55..7140556b4549 100644 --- a/content/svg/content/src/nsSVGDataParser.h +++ b/content/svg/content/src/nsSVGDataParser.h @@ -39,7 +39,6 @@ #define __NS_SVGDATAPARSER_H__ #include "nsCOMPtr.h" -#include "nsVoidArray.h" //---------------------------------------------------------------------- // helper macros diff --git a/content/svg/content/src/nsSVGLengthList.cpp b/content/svg/content/src/nsSVGLengthList.cpp index d94bfd94bb4c..3c142153f35c 100644 --- a/content/svg/content/src/nsSVGLengthList.cpp +++ b/content/svg/content/src/nsSVGLengthList.cpp @@ -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 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(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(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(); } diff --git a/content/svg/content/src/nsSVGNumberList.cpp b/content/svg/content/src/nsSVGNumberList.cpp index af9494a705f2..b58c9f30982c 100644 --- a/content/svg/content/src/nsSVGNumberList.cpp +++ b/content/svg/content/src/nsSVGNumberList.cpp @@ -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 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(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(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; diff --git a/content/svg/content/src/nsSVGPathDataParser.h b/content/svg/content/src/nsSVGPathDataParser.h index 558a01c3e556..140453cf2fbf 100644 --- a/content/svg/content/src/nsSVGPathDataParser.h +++ b/content/svg/content/src/nsSVGPathDataParser.h @@ -41,7 +41,6 @@ #include "nsSVGDataParser.h" #include "nsCOMPtr.h" -#include "nsVoidArray.h" #include "nsCOMArray.h" #include "nsIDOMSVGPathSeg.h" #include "nsTArray.h" diff --git a/content/svg/content/src/nsSVGPathSegList.cpp b/content/svg/content/src/nsSVGPathSegList.cpp index ac16e5068047..0e3c1c5dc1aa 100644 --- a/content/svg/content/src/nsSVGPathSegList.cpp +++ b/content/svg/content/src/nsSVGPathSegList.cpp @@ -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" diff --git a/content/svg/content/src/nsSVGPointList.cpp b/content/svg/content/src/nsSVGPointList.cpp index 5be972f95a09..ce9641e50fa1 100644 --- a/content/svg/content/src/nsSVGPointList.cpp +++ b/content/svg/content/src/nsSVGPointList.cpp @@ -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 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 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 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(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(mPoints.Count())) { + if (index >= mPoints.Length()) { *_retval = nsnull; return NS_ERROR_DOM_INDEX_SIZE_ERR; } diff --git a/content/svg/content/src/nsSVGPointList.h b/content/svg/content/src/nsSVGPointList.h index fcb99f95453b..528ce126e02d 100644 --- a/content/svg/content/src/nsSVGPointList.h +++ b/content/svg/content/src/nsSVGPointList.h @@ -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 mPoints; }; diff --git a/content/svg/content/src/nsSVGTransformList.cpp b/content/svg/content/src/nsSVGTransformList.cpp index 0991484456d4..1d20170a2e28 100644 --- a/content/svg/content/src/nsSVGTransformList.cpp +++ b/content/svg/content/src/nsSVGTransformList.cpp @@ -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 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 val = do_QueryInterface(aElement); val->AddObserver(this); + return PR_TRUE; } - return rv; + return PR_FALSE; } already_AddRefed @@ -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(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 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(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 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); diff --git a/content/svg/content/src/nsSVGTransformList.h b/content/svg/content/src/nsSVGTransformList.h index 4362c07493b4..80bda1d2305c 100644 --- a/content/svg/content/src/nsSVGTransformList.h +++ b/content/svg/content/src/nsSVGTransformList.h @@ -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 mTransforms; }; diff --git a/content/svg/content/src/nsSVGValue.cpp b/content/svg/content/src/nsSVGValue.cpp index ea235ea00bf1..419326f70db3 100644 --- a/content/svg/content/src/nsSVGValue.cpp +++ b/content/svg/content/src/nsSVGValue.cpp @@ -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(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(mObservers.ElementAt(i)); + nsIWeakReference* wr = mObservers.ElementAt(i); nsCOMPtr observer = do_QueryReferent(wr); if (observer) (static_cast(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 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(mObservers.ElementAt(i)); + nsIWeakReference* wr2 = mObservers.ElementAt(i); NS_RELEASE(wr2); mObservers.RemoveElementAt(i); return NS_OK; diff --git a/content/svg/content/src/nsSVGValue.h b/content/svg/content/src/nsSVGValue.h index 292afe6fb651..1eab0073dec2 100644 --- a/content/svg/content/src/nsSVGValue.h +++ b/content/svg/content/src/nsSVGValue.h @@ -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 mObservers; PRInt32 mModifyNestCount; }; diff --git a/content/xbl/src/nsXBLEventHandler.cpp b/content/xbl/src/nsXBLEventHandler.cpp index 46df94f972d6..fb1428cd9bca 100644 --- a/content/xbl/src/nsXBLEventHandler.cpp +++ b/content/xbl/src/nsXBLEventHandler.cpp @@ -136,9 +136,8 @@ nsXBLKeyEventHandler::ExecuteMatchedHandlers(nsIDOMKeyEvent* aKeyEvent, nsCOMPtr piTarget = do_QueryInterface(target); PRBool executed = PR_FALSE; - for (PRUint32 i = 0; i < mProtoHandlers.Count(); ++i) { - nsXBLPrototypeHandler* handler = static_cast - (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; diff --git a/content/xbl/src/nsXBLEventHandler.h b/content/xbl/src/nsXBLEventHandler.h index 6c984dfb0e1d..9d8a0fea5dda 100644 --- a/content/xbl/src/nsXBLEventHandler.h +++ b/content/xbl/src/nsXBLEventHandler.h @@ -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 mProtoHandlers; nsCOMPtr mEventType; PRUint8 mPhase; PRUint8 mType; diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index 8baef5df837e..650de8894343 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -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 mInner; - nsAutoVoidArray mBindingRequests; + nsAutoTArray mBindingRequests; nsCOMPtr mBoundDocument; nsCOMPtr 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); } } diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index 314ce70af2f4..686d15b300bc 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -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" diff --git a/content/xslt/src/base/txNamespaceMap.cpp b/content/xslt/src/base/txNamespaceMap.cpp index 077cb64d6b9b..6e91d1ba84a0 100644 --- a/content/xslt/src/base/txNamespaceMap.cpp +++ b/content/xslt/src/base/txNamespaceMap.cpp @@ -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) { diff --git a/content/xslt/src/base/txNamespaceMap.h b/content/xslt/src/base/txNamespaceMap.h index 766d709daf4c..8db9707618c2 100644 --- a/content/xslt/src/base/txNamespaceMap.h +++ b/content/xslt/src/base/txNamespaceMap.h @@ -41,6 +41,7 @@ #include "nsIAtom.h" #include "nsCOMArray.h" +#include "nsTArray.h" class txNamespaceMap { @@ -70,7 +71,7 @@ public: private: nsAutoRefCnt mRefCnt; nsCOMArray mPrefixes; - nsVoidArray mNamespaces; + nsTArray mNamespaces; }; #endif //TRANSFRMX_TXNAMESPACEMAP_H diff --git a/content/xslt/src/base/txStack.h b/content/xslt/src/base/txStack.h index 8993bd209778..8d22842d3c6f 100644 --- a/content/xslt/src/base/txStack.h +++ b/content/xslt/src/base/txStack.h @@ -39,9 +39,9 @@ #ifndef txStack_h___ #define txStack_h___ -#include "nsVoidArray.h" +#include "nsTArray.h" -class txStack : private nsVoidArray +class txStack : private nsTArray { 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___ */ diff --git a/content/xslt/src/main/testXalan.cpp b/content/xslt/src/main/testXalan.cpp index f1ca1e2fb770..7a4f17f41111 100644 --- a/content/xslt/src/main/testXalan.cpp +++ b/content/xslt/src/main/testXalan.cpp @@ -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" diff --git a/content/xslt/src/xml/txDOM.h b/content/xslt/src/xml/txDOM.h index d8c37a2d82df..a6275726898e 100644 --- a/content/xslt/src/xml/txDOM.h +++ b/content/xslt/src/xml/txDOM.h @@ -57,7 +57,6 @@ #include "nsIAtom.h" #include "nsDoubleHashtable.h" #include "nsString.h" -#include "nsVoidArray.h" #include "txCore.h" #include "nsAutoPtr.h" diff --git a/content/xslt/src/xml/txNodeDefinition.cpp b/content/xslt/src/xml/txNodeDefinition.cpp index 03acbeee291b..6e448d9734ff 100644 --- a/content/xslt/src/xml/txNodeDefinition.cpp +++ b/content/xslt/src/xml/txNodeDefinition.cpp @@ -46,7 +46,6 @@ // #include "txDOM.h" -#include "nsVoidArray.h" #include "nsTArray.h" #include "txURIUtils.h" #include "txAtoms.h" diff --git a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp index 1449e7d9b88a..c2730126fdc6 100644 --- a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp +++ b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp @@ -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 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(parents.ElementAt(total - i)); - otherNode = static_cast - (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. diff --git a/content/xslt/src/xpath/txNodeSet.h b/content/xslt/src/xpath/txNodeSet.h index 797e81b98d8c..4f0dfb30321f 100644 --- a/content/xslt/src/xpath/txNodeSet.h +++ b/content/xslt/src/xpath/txNodeSet.h @@ -44,7 +44,6 @@ #define txNodeSet_h__ #include "txExprResult.h" -#include "nsVoidArray.h" #include "txError.h" #include "txXPathNode.h" diff --git a/content/xslt/src/xpath/txXPathTreeWalker.h b/content/xslt/src/xpath/txXPathTreeWalker.h index 7fd951e105af..a11e09fa0486 100644 --- a/content/xslt/src/xpath/txXPathTreeWalker.h +++ b/content/xslt/src/xpath/txXPathTreeWalker.h @@ -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 { 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; } }; diff --git a/content/xslt/src/xslt/txBufferingHandler.cpp b/content/xslt/src/xslt/txBufferingHandler.cpp index 402eabef4668..7e690c3f24ae 100644 --- a/content/xslt/src/xslt/txBufferingHandler.cpp +++ b/content/xslt/src/xslt/txBufferingHandler.cpp @@ -343,22 +343,17 @@ txBufferingHandler::startElement(nsIAtom* aPrefix, return mBuffer->addTransaction(transaction); } -static PRBool -deleteTransaction(void* aElement, void *aData) -{ - delete static_cast(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(aData); + Holder* holder = aData; txAXMLEventHandler* handler = *holder->mHandler; - txOutputTransaction* transaction = - static_cast(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(mTransactions[last]); + return mTransactions[last]; } diff --git a/content/xslt/src/xslt/txBufferingHandler.h b/content/xslt/src/xslt/txBufferingHandler.h index 8d298568b9fe..72c20dbc286e 100644 --- a/content/xslt/src/xslt/txBufferingHandler.h +++ b/content/xslt/src/xslt/txBufferingHandler.h @@ -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 mTransactions; }; class txBufferingHandler : public txAXMLEventHandler diff --git a/content/xslt/src/xslt/txExecutionState.h b/content/xslt/src/xslt/txExecutionState.h index 2975780320b3..a1d86a5c8309 100644 --- a/content/xslt/src/xslt/txExecutionState.h +++ b/content/xslt/src/xslt/txExecutionState.h @@ -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" diff --git a/content/xslt/src/xslt/txInstructions.cpp b/content/xslt/src/xslt/txInstructions.cpp index 2bfe93cdf0a6..53346eb43b4e 100644 --- a/content/xslt/src/xslt/txInstructions.cpp +++ b/content/xslt/src/xslt/txInstructions.cpp @@ -642,10 +642,10 @@ txPushNewContext::txPushNewContext(nsAutoPtr aSelect) txPushNewContext::~txPushNewContext() { - PRInt32 i; - for (i = 0; i < mSortKeys.Count(); ++i) + PRUint32 i; + for (i = 0; i < mSortKeys.Length(); ++i) { - delete static_cast(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(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 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; } diff --git a/content/xslt/src/xslt/txInstructions.h b/content/xslt/src/xslt/txInstructions.h index 4079217daec2..c5344794f0b7 100644 --- a/content/xslt/src/xslt/txInstructions.h +++ b/content/xslt/src/xslt/txInstructions.h @@ -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 mCaseOrderExpr; }; - nsVoidArray mSortKeys; + nsTArray mSortKeys; nsAutoPtr mSelect; txInstruction* mBailTarget; }; diff --git a/content/xslt/src/xslt/txStylesheetCompiler.cpp b/content/xslt/src/xslt/txStylesheetCompiler.cpp index b8bde51c0a01..759c5cb4306d 100644 --- a/content/xslt/src/xslt/txStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txStylesheetCompiler.cpp @@ -229,8 +229,8 @@ txStylesheetCompiler::startElementInternal(PRInt32 aNamespaceID, { nsresult rv = NS_OK; PRInt32 i; - for (i = mInScopeVariables.Count() - 1; i >= 0; --i) { - ++(static_cast(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(mInScopeVariables[i]); + for (i = mInScopeVariables.Length() - 1; i >= 0; --i) { + txInScopeVariable* var = mInScopeVariables[i]; if (!--(var->mLevel)) { nsAutoPtr 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(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 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(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) diff --git a/content/xslt/src/xslt/txStylesheetCompiler.h b/content/xslt/src/xslt/txStylesheetCompiler.h index fc1173daac3b..fc23fb4d3d89 100644 --- a/content/xslt/src/xslt/txStylesheetCompiler.h +++ b/content/xslt/src/xslt/txStylesheetCompiler.h @@ -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 mMappings; - nsVoidArray mInstructionNamespaces; + nsTArray mInstructionNamespaces; PRInt32 mDepth; }; @@ -169,8 +171,8 @@ public: protected: nsRefPtr mObserver; - nsVoidArray mInScopeVariables; - nsVoidArray mChildCompilerList; + nsTArray mInScopeVariables; + nsTArray mChildCompilerList; // embed info, target information is the ID nsString mTarget; enum @@ -189,7 +191,7 @@ protected: private: txInstruction** mNextInstrPtr; txListIterator mToplevelIterator; - nsVoidArray mGotoTargetPointers; + nsTArray mGotoTargetPointers; }; struct txStylesheetAttr diff --git a/content/xslt/src/xslt/txXSLTPatterns.h b/content/xslt/src/xslt/txXSLTPatterns.h index 707a55e1ee0c..0b4e195276d8 100644 --- a/content/xslt/src/xslt/txXSLTPatterns.h +++ b/content/xslt/src/xslt/txXSLTPatterns.h @@ -41,7 +41,6 @@ #include "txExpr.h" #include "txXMLUtils.h" -#include "nsVoidArray.h" class ProcessorState; diff --git a/content/xul/document/src/nsXULContentSink.h b/content/xul/document/src/nsXULContentSink.h index 1285d1a5157e..f5ea8e4e7bfa 100644 --- a/content/xul/document/src/nsXULContentSink.h +++ b/content/xul/document/src/nsXULContentSink.h @@ -46,7 +46,6 @@ #include "nsIXMLContentSink.h" #include "nsAutoPtr.h" #include "nsNodeInfoManager.h" -#include "nsVoidArray.h" #include "nsWeakPtr.h" #include "nsXULElement.h" diff --git a/content/xul/document/src/nsXULControllers.cpp b/content/xul/document/src/nsXULControllers.cpp index 3af8d9cc2af5..878ecb417482 100644 --- a/content/xul/document/src/nsXULControllers.cpp +++ b/content/xul/document/src/nsXULControllers.cpp @@ -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(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(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(mControllers.ElementAt(i)); + nsXULControllerData* controllerData = mControllers.ElementAt(i); if (controllerData) { nsCOMPtr 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(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(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 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(mControllers.ElementAt(i)); + nsXULControllerData* controllerData = mControllers.ElementAt(i); if (controllerData) { nsCOMPtr 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(mControllers.ElementAt(i)); + nsXULControllerData* controllerData = mControllers.ElementAt(i); if (controllerData) { nsCOMPtr 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(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; } diff --git a/content/xul/document/src/nsXULControllers.h b/content/xul/document/src/nsXULControllers.h index ce10e771f31a..d4d98a357880 100644 --- a/content/xul/document/src/nsXULControllers.h +++ b/content/xul/document/src/nsXULControllers.h @@ -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 mControllers; + PRUint32 mCurControllerID; }; diff --git a/content/xul/templates/src/nsTemplateRule.h b/content/xul/templates/src/nsTemplateRule.h index fd645084cb4a..e8273134b166 100644 --- a/content/xul/templates/src/nsTemplateRule.h +++ b/content/xul/templates/src/nsTemplateRule.h @@ -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 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(mRules[aIndex]); + return mRules[aIndex]; } void Clear() { - for (PRInt32 r = mRules.Count() - 1; r >= 0; r--) { - nsTemplateRule* rule = static_cast(mRules[r]); + for (PRInt32 r = mRules.Length() - 1; r >= 0; r--) { + nsTemplateRule* rule = mRules[r]; delete rule; } mRules.Clear(); diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 9c780b2a1b33..91dfea86656f 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -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 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(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; } diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index a2eb62a953ff..8d11931708bd 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -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 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(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; } } diff --git a/content/xul/templates/src/nsXULTemplateBuilder.h b/content/xul/templates/src/nsXULTemplateBuilder.h index ea32001c21fe..c513324e158c 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.h +++ b/content/xul/templates/src/nsXULTemplateBuilder.h @@ -56,7 +56,6 @@ #include "nsIXULTemplateBuilder.h" #include "nsFixedSizeAllocator.h" -#include "nsVoidArray.h" #include "nsCOMArray.h" #include "nsTArray.h" #include "nsDataHashtable.h" diff --git a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.h b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.h index 10fafba235eb..5dd40d98dbea 100644 --- a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.h +++ b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.h @@ -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" diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp index 4712d2cc7dcd..e8a3d3bb2d87 100644 --- a/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -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& 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 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& 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; }