From 2b4ddeae6f4f8942db253f3657a0a02ec198e420 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Fri, 2 Nov 2012 17:57:05 -0700 Subject: [PATCH] Bug 807713 - add operator[] for nsTObserverArray. r=bsmedberg --- accessible/src/base/nsAccessiblePivot.cpp | 4 ++-- xpcom/glue/nsTObserverArray.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/accessible/src/base/nsAccessiblePivot.cpp b/accessible/src/base/nsAccessiblePivot.cpp index aa59452f3814..83df3300b76c 100644 --- a/accessible/src/base/nsAccessiblePivot.cpp +++ b/accessible/src/base/nsAccessiblePivot.cpp @@ -59,9 +59,9 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsAccessiblePivot) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsAccessiblePivot) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mRoot, nsIAccessible) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mPosition, nsIAccessible) - uint32_t i, length = tmp->mObservers.Length(); \ + uint32_t i, length = tmp->mObservers.Length(); for (i = 0; i < length; ++i) { - cb.NoteXPCOMChild(tmp->mObservers.ElementAt(i).get()); + cb.NoteXPCOMChild(tmp->mObservers[i]); } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/xpcom/glue/nsTObserverArray.h b/xpcom/glue/nsTObserverArray.h index 258f453e244e..e6a19f8064b8 100644 --- a/xpcom/glue/nsTObserverArray.h +++ b/xpcom/glue/nsTObserverArray.h @@ -117,6 +117,16 @@ class nsAutoTObserverArray : protected nsTObserverArray_base { return mArray.SafeElementAt(i, def); } + // Shorthand for ElementAt(i) + elem_type& operator[](index_type i) { + return ElementAt(i); + } + + // Shorthand for ElementAt(i) + const elem_type& operator[](index_type i) const { + return ElementAt(i); + } + // // Search methods //