diff --git a/mozilla/xpcom/ds/nsArray.cpp b/mozilla/xpcom/ds/nsArray.cpp index 3e512a3a596..0a099645537 100644 --- a/mozilla/xpcom/ds/nsArray.cpp +++ b/mozilla/xpcom/ds/nsArray.cpp @@ -47,7 +47,7 @@ struct findIndexOfClosure PRUint32 resultIndex; }; -static PRBool FindElementCallback(nsISupports* aElement, void* aClosure); +static PRBool FindElementCallback(void* aElement, void* aClosure); NS_IMPL_ISUPPORTS2(nsArray, nsIArray, nsIMutableArray) @@ -133,14 +133,17 @@ nsArray::Clear() } PRBool -FindElementCallback(nsISupports *aElement, void* aClosure) +FindElementCallback(void *aElement, void* aClosure) { findIndexOfClosure* closure = NS_STATIC_CAST(findIndexOfClosure*, aClosure); + nsISupports* element = + NS_STATIC_CAST(nsISupports*, aElement); + // don't start searching until we're past the startIndex if (closure->resultIndex >= closure->startIndex && - aElement == closure->targetElement) { + element == closure->targetElement) { return PR_FALSE; // stop! We found it } closure->resultIndex++; diff --git a/mozilla/xpcom/ds/nsArray.h b/mozilla/xpcom/ds/nsArray.h index 12e070a89d4..316bf300d2f 100644 --- a/mozilla/xpcom/ds/nsArray.h +++ b/mozilla/xpcom/ds/nsArray.h @@ -81,7 +81,7 @@ public: NS_DECL_NSIMUTABLEARRAY private: - nsCOMArray mArray; + nsCOMArray_base mArray; }; diff --git a/mozilla/xpcom/ds/nsCOMArray.h b/mozilla/xpcom/ds/nsCOMArray.h index 95c2cc84400..3b63b41c827 100644 --- a/mozilla/xpcom/ds/nsCOMArray.h +++ b/mozilla/xpcom/ds/nsCOMArray.h @@ -48,6 +48,7 @@ // work of this class in the XPCOM dll class NS_COM nsCOMArray_base { + friend class nsArray; protected: nsCOMArray_base() {} nsCOMArray_base(PRInt32 aCount) : mArray(aCount) {} @@ -61,6 +62,10 @@ protected: return mArray.EnumerateForwards(aFunc, aData); } + PRBool EnumerateBackwards(nsVoidArrayEnumFunc aFunc, void* aData) { + return mArray.EnumerateBackwards(aFunc, aData); + } + // any method which is not a direct forward to mArray should // avoid inline bodies, so that the compiler doesn't inline them // all over the place @@ -120,7 +125,9 @@ class nsCOMArray : public nsCOMArray_base nsCOMArray() {} nsCOMArray(PRInt32 aCount) : nsCOMArray_base(aCount) {} - nsCOMArray(const nsCOMArray_base& aOther) : nsCOMArray_base(aOther) { } + // only to be used by trusted classes who are going to pass us the + // right type! + nsCOMArray(const nsCOMArray& aOther) : nsCOMArray_base(aOther) { } ~nsCOMArray() {} @@ -176,6 +183,11 @@ class nsCOMArray : public nsCOMArray_base aData); } + PRBool EnumerateBackwards(nsCOMArrayEnumFunc aFunc, void* aData) { + return nsCOMArray_base::EnumerateBackwards(nsVoidArrayEnumFunc(aFunc), + aData); + } + // append an object, growing the array as necessary PRBool AppendObject(T *aObject) { return nsCOMArray_base::AppendObject(aObject); @@ -194,10 +206,9 @@ class nsCOMArray : public nsCOMArray_base return nsCOMArray_base::RemoveObjectAt(aIndex); } - private: +private: // don't implement these! - nsCOMArray(const nsCOMArray& other); nsCOMArray& operator=(const nsCOMArray& other); };