Bug 474369 - get rid of nsVoidArray; embedding part; r+sr=benjamin
authorArpad Borsos <arpad.borsos@googlemail.com>
Wed, 25 Feb 2009 16:25:08 +0100
changeset 25498 24c37ac3bc3f54ff983e8cc7e079eac44bf40b2d
parent 25497 08b98b9b0868019ac9c6190bf1b6df594f23b31c
child 25499 2603878ec5fc28220d06b81a4c2c853a30209b45
push id5577
push usersgautherie.bz@free.fr
push dateWed, 25 Feb 2009 15:26:20 +0000
treeherdermozilla-central@f4c28aa22bff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs474369
milestone1.9.2a1pre
Bug 474369 - get rid of nsVoidArray; embedding part; r+sr=benjamin
embedding/browser/activex/src/common/StdAfx.h
embedding/browser/activex/src/control/MozillaBrowser.cpp
embedding/browser/activex/src/control/MozillaBrowser.h
embedding/browser/activex/src/control/StdAfx.h
embedding/browser/gtk/src/EmbedPrivate.cpp
embedding/browser/gtk/src/EmbedPrivate.h
embedding/browser/photon/src/EmbedPrivate.cpp
embedding/browser/photon/src/EmbedPrivate.h
embedding/browser/webBrowser/nsWebBrowser.cpp
embedding/browser/webBrowser/nsWebBrowser.h
embedding/components/commandhandler/src/nsCommandGroup.cpp
embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h
embedding/components/windowwatcher/src/nsWindowWatcher.cpp
embedding/components/windowwatcher/src/nsWindowWatcher.h
embedding/qa/testembed/StdAfx.h
--- a/embedding/browser/activex/src/common/StdAfx.h
+++ b/embedding/browser/activex/src/common/StdAfx.h
@@ -65,17 +65,16 @@
 #include "nsIServiceManager.h"
 #include "nsStringAPI.h"
 #include "nsCOMPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 
 #include "nsIDocument.h"
 #include "nsIDocumentObserver.h"
-#include "nsVoidArray.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentType.h"
 #include "nsIDOMElement.h"
 
 #undef _WIN32_WINNT
--- a/embedding/browser/activex/src/control/MozillaBrowser.cpp
+++ b/embedding/browser/activex/src/control/MozillaBrowser.cpp
@@ -147,17 +147,17 @@ GUID CGID_IWebBrowser_Moz =
 
 GUID CGID_MSHTML_Moz =
     { 0xED016940L, 0xBD5B, 0x11cf, {0xBA, 0x4E, 0x00, 0xC0, 0x4F, 0xD7, 0x08, 0x16} };
 
 /////////////////////////////////////////////////////////////////////////////
 // CMozillaBrowser
 
 
-nsVoidArray CMozillaBrowser::sBrowserList;
+nsTArray<CMozillaBrowser*> CMozillaBrowser::sBrowserList;
 
 //
 // Constructor
 //
 CMozillaBrowser::CMozillaBrowser()
 {
     NG_TRACE_METHOD(CMozillaBrowser::CMozillaBrowser);
 
--- a/embedding/browser/activex/src/control/MozillaBrowser.h
+++ b/embedding/browser/activex/src/control/MozillaBrowser.h
@@ -357,17 +357,17 @@ END_OLECOMMAND_TABLE()
         *pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE;
         return S_OK;
     }
 
 // Protected members
 protected:
 
     // List of browsers
-    static nsVoidArray sBrowserList;
+    static nsTArray<CMozillaBrowser*> sBrowserList;
 
     // Name of profile to use
     nsString mProfileName;
 
     // Pointer to web browser manager
     CWebBrowserContainer    * mWebBrowserContainer;
     // CComObject to IHTMLDocument implementer
     CIEHtmlDocumentInstance * mIERootDocument;
--- a/embedding/browser/activex/src/control/StdAfx.h
+++ b/embedding/browser/activex/src/control/StdAfx.h
@@ -95,17 +95,17 @@
 #include "nsIPrompt.h"
 #include "nsIEditor.h"
 #include "nsIEditingSession.h"
 #include "nsICommandManager.h"
 
 #include "nsIDocument.h"
 #include "nsIDocumentObserver.h"
 #include "nsIStreamListener.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
 #include "nsIDocumentViewer.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentType.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEvent.h"
--- a/embedding/browser/gtk/src/EmbedPrivate.cpp
+++ b/embedding/browser/gtk/src/EmbedPrivate.cpp
@@ -84,25 +84,25 @@
 #include "GtkPromptService.h"
 
 #ifdef MOZ_ACCESSIBILITY_ATK
 #include "nsIAccessibilityService.h"
 #include "nsIAccessible.h"
 #include "nsIDOMDocument.h"
 #endif
 
-PRUint32     EmbedPrivate::sWidgetCount = 0;
+PRUint32                 EmbedPrivate::sWidgetCount = 0;
 
-char        *EmbedPrivate::sPath        = nsnull;
-char        *EmbedPrivate::sCompPath    = nsnull;
-nsVoidArray *EmbedPrivate::sWindowList  = nsnull;
-nsILocalFile *EmbedPrivate::sProfileDir  = nsnull;
-nsISupports  *EmbedPrivate::sProfileLock = nsnull;
-GtkWidget   *EmbedPrivate::sOffscreenWindow = 0;
-GtkWidget   *EmbedPrivate::sOffscreenFixed  = 0;
+char                    *EmbedPrivate::sPath        = nsnull;
+char                    *EmbedPrivate::sCompPath    = nsnull;
+nsTArray<EmbedPrivate*> *EmbedPrivate::sWindowList  = nsnull;
+nsILocalFile            *EmbedPrivate::sProfileDir  = nsnull;
+nsISupports             *EmbedPrivate::sProfileLock = nsnull;
+GtkWidget               *EmbedPrivate::sOffscreenWindow = 0;
+GtkWidget               *EmbedPrivate::sOffscreenFixed  = 0;
 
 nsIDirectoryServiceProvider *EmbedPrivate::sAppFileLocProvider = nsnull;
 
 class GTKEmbedDirectoryProvider : public nsIDirectoryServiceProvider2
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
@@ -188,17 +188,17 @@ EmbedPrivate::EmbedPrivate(void)
   mIsChrome         = PR_FALSE;
   mChromeLoaded     = PR_FALSE;
   mListenersAttached = PR_FALSE;
   mMozWindowWidget  = 0;
   mIsDestroyed      = PR_FALSE;
 
   PushStartup();
   if (!sWindowList) {
-    sWindowList = new nsVoidArray();
+    sWindowList = new nsTArray<EmbedPrivate*>();
   }
   sWindowList->AppendElement(this);
 }
 
 EmbedPrivate::~EmbedPrivate()
 {
   sWindowList->RemoveElement(this);
   PopStartup();
@@ -706,23 +706,22 @@ EmbedPrivate::CloseStream(void)
 /* static */
 EmbedPrivate *
 EmbedPrivate::FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser)
 {
   if (!sWindowList)
     return nsnull;
 
   // Get the number of browser windows.
-  PRInt32 count = sWindowList->Count();
+  PRInt32 count = sWindowList->Length();
   // This function doesn't get called very often at all ( only when
   // creating a new window ) so it's OK to walk the list of open
   // windows.
   for (int i = 0; i < count; i++) {
-    EmbedPrivate *tmpPrivate = static_cast<EmbedPrivate *>(
-					      sWindowList->ElementAt(i));
+    EmbedPrivate *tmpPrivate = sWindowList->ElementAt(i);
     // get the browser object for that window
     nsIWebBrowserChrome *chrome = static_cast<nsIWebBrowserChrome *>(
 						 tmpPrivate->mWindow);
     if (chrome == aBrowser)
       return tmpPrivate;
   }
 
   return nsnull;
--- a/embedding/browser/gtk/src/EmbedPrivate.h
+++ b/embedding/browser/gtk/src/EmbedPrivate.h
@@ -42,17 +42,17 @@
 #include "nsStringGlue.h"
 #include "nsIWebNavigation.h"
 #include "nsISHistory.h"
 // for our one function that gets the EmbedPrivate via the chrome
 // object.
 #include "nsIWebBrowserChrome.h"
 #include "nsIAppShell.h"
 #include "nsPIDOMEventTarget.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 // app component registration
 #include "nsIGenericFactory.h"
 #include "nsIComponentRegistrar.h"
 
 #include "gtkmozembedprivate.h"
 
 class EmbedProgress;
 class EmbedWindow;
@@ -148,17 +148,17 @@ class EmbedPrivate {
   // the path to components
   static char                   *sCompPath;
   // the list of application-specific components to register
   static const nsModuleComponentInfo  *sAppComps;
   static int                     sNumAppComps;
   // the appshell we have created
   static nsIAppShell            *sAppShell;
   // the list of all open windows
-  static nsVoidArray            *sWindowList;
+  static nsTArray<EmbedPrivate*> *sWindowList;
   // what is our profile path?
   static nsILocalFile           *sProfileDir;
   static nsISupports            *sProfileLock;
 
   static nsIDirectoryServiceProvider * sAppFileLocProvider;
 
   // chrome mask
   PRUint32                       mChromeMask;
--- a/embedding/browser/photon/src/EmbedPrivate.cpp
+++ b/embedding/browser/photon/src/EmbedPrivate.cpp
@@ -96,37 +96,37 @@
 #include "PtMozilla.h"
 
 /* globals */
 extern char *g_Print_Left_Header_String, *g_Print_Right_Header_String, *g_Print_Left_Footer_String, *g_Print_Right_Footer_String;
 
 static const char sWatcherContractID[] = "@mozilla.org/embedcomp/window-watcher;1";
 static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
 
-nsIAppShell *EmbedPrivate::sAppShell    = nsnull;
-nsIPref     *EmbedPrivate::sPrefs       = nsnull;
-nsVoidArray *EmbedPrivate::sWindowList  = nsnull;
-nsClipboard *EmbedPrivate::sClipboard   = nsnull;
+nsIAppShell             *EmbedPrivate::sAppShell    = nsnull;
+nsIPref                 *EmbedPrivate::sPrefs       = nsnull;
+nsTArray<EmbedPrivate*> *EmbedPrivate::sWindowList  = nsnull;
+nsClipboard             *EmbedPrivate::sClipboard   = nsnull;
 
 EmbedPrivate::EmbedPrivate(void)
 {
   mOwningWidget     = nsnull;
   mWindow           = nsnull;
   mProgress         = nsnull;
   mContentListener  = nsnull;
   mEventListener    = nsnull;
   mStream           = nsnull;
   mChromeMask       = 0;
   mIsChrome         = PR_FALSE;
   mChromeLoaded     = PR_FALSE;
   mListenersAttached = PR_FALSE;
   mMozWindowWidget  = 0;
 
 	if (!sWindowList) {
-  		sWindowList = new nsVoidArray();
+  		sWindowList = new nsTArray<EmbedPrivate*>();
 	}
 	sWindowList->AppendElement(this);
 	if( !sClipboard ) {
 		nsresult rv;
 		nsCOMPtr<nsClipboard> s;
 		s = do_GetService( kCClipboardCID, &rv );
 		sClipboard = ( nsClipboard * ) s;
 		if( NS_FAILED( rv ) ) sClipboard = 0;
@@ -703,24 +703,23 @@ EmbedPrivate::CloseStream(void)
 /* static */
 EmbedPrivate *
 EmbedPrivate::FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser)
 {
 	if (!sWindowList)
 	  return nsnull;
 
 	// Get the number of browser windows.
-	PRInt32 count = sWindowList->Count();
+	PRInt32 count = sWindowList->Length();
 	// This function doesn't get called very often at all ( only when
 	// creating a new window ) so it's OK to walk the list of open
 	// windows.
 	for (int i = 0; i < count; i++) 
 	{
-	  EmbedPrivate *tmpPrivate = static_cast<EmbedPrivate *>
-                                         (sWindowList->ElementAt(i));
+	  EmbedPrivate *tmpPrivate = sWindowList->ElementAt(i);
 	  // get the browser object for that window
 	  nsIWebBrowserChrome *chrome = static_cast<nsIWebBrowserChrome *>
                                             (tmpPrivate->mWindow);
 	  if (chrome == aBrowser)
 		return tmpPrivate;
 	}
 
   return nsnull;
--- a/embedding/browser/photon/src/EmbedPrivate.h
+++ b/embedding/browser/photon/src/EmbedPrivate.h
@@ -46,17 +46,17 @@
 #include <nsISHistory.h>
 #include "nsIExternalHelperAppService.h"
 // for our one function that gets the EmbedPrivate via the chrome
 // object.
 #include <nsIWebBrowserChrome.h>
 #include <nsIPrintSettings.h>
 #include <nsIAppShell.h>
 #include <nsPIDOMEventTarget.h>
-#include <nsVoidArray.h>
+#include <nsTArray.h>
 #include <nsClipboard.h>
 // for profiles
 #include <nsIPref.h>
 
 #include <Pt.h>
 
 class EmbedProgress;
 class EmbedWindow;
@@ -172,17 +172,17 @@ class EmbedPrivate {
   // the number of widgets that have been created
   static PRUint32                sWidgetCount;
   // the path to components
   static char                   *sCompPath;
   // the appshell we have created
   static nsIAppShell            *sAppShell;
   // for profiles
   static nsIPref                *sPrefs;
-	static nsVoidArray            *sWindowList;
+	static nsTArray<EmbedPrivate*> *sWindowList;
   // for clipboard input group setting
   static nsClipboard *sClipboard;
 
   // chrome mask
   PRUint32                       mChromeMask;
   // is this a chrome window?
   PRBool                         mIsChrome;
   // has the chrome finished loading?
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -118,22 +118,16 @@ nsWebBrowser::nsWebBrowser() : mDocShell
     NS_ASSERTION(mWWatch, "failed to get WindowWatcher");
 }
 
 nsWebBrowser::~nsWebBrowser()
 {
    InternalDestroy();
 }
 
-PRBool deleteListener(void *aElement, void *aData) {
-    nsWebBrowserListenerState *state = (nsWebBrowserListenerState*)aElement;
-    NS_DELETEXPCOM(state);
-    return PR_TRUE;
-}
-
 NS_IMETHODIMP nsWebBrowser::InternalDestroy()
 {
 
    if (mInternalWidget) {
      mInternalWidget->SetClientData(0);
      mInternalWidget->Destroy();
      mInternalWidget = nsnull; // Force release here.
    }
@@ -147,17 +141,20 @@ NS_IMETHODIMP nsWebBrowser::InternalDest
       }
    if(mInitInfo)
       {
       delete mInitInfo;
       mInitInfo = nsnull;
       }
 
    if (mListenerArray) {
-      (void)mListenerArray->EnumerateForwards(deleteListener, nsnull);
+      for (PRUint32 i = 0, end = mListenerArray->Length(); i < end; i++) {
+         nsWebBrowserListenerState *state = mListenerArray->ElementAt(i);
+         NS_DELETEXPCOM(state);
+      }
       delete mListenerArray;
       mListenerArray = nsnull;
    }
 
    return NS_OK;
 }
 
 
@@ -237,17 +234,17 @@ NS_IMETHODIMP nsWebBrowser::AddWebBrowse
         nsAutoPtr<nsWebBrowserListenerState> state;
         NS_NEWXPCOM(state, nsWebBrowserListenerState);
         if (!state) return NS_ERROR_OUT_OF_MEMORY;
 
         state->mWeakPtr = aListener;
         state->mID = aIID;
 
         if (!mListenerArray) {
-            NS_NEWXPCOM(mListenerArray, nsVoidArray);
+            NS_NEWXPCOM(mListenerArray, nsTArray<nsWebBrowserListenerState*>);
             if (!mListenerArray) {
                 return NS_ERROR_OUT_OF_MEMORY;
             }
         }
 
         if (!mListenerArray->AppendElement(state)) {
             return NS_ERROR_OUT_OF_MEMORY;
         }
@@ -290,32 +287,35 @@ NS_IMETHODIMP nsWebBrowser::RemoveWebBro
 
     nsresult rv = NS_OK;
     if (!mWebProgress) {
         // if there's no-one to register the listener w/, and we don't have a queue going,
         // the the called is calling Remove before an Add which doesn't make sense.
         if (!mListenerArray) return NS_ERROR_FAILURE;
 
         // iterate the array and remove the queued listener
-        PRInt32 count = mListenerArray->Count();
+        PRInt32 count = mListenerArray->Length();
         while (count > 0) {
-            nsWebBrowserListenerState *state = (nsWebBrowserListenerState*)mListenerArray->ElementAt(count);
+            nsWebBrowserListenerState *state = mListenerArray->ElementAt(count);
             NS_ASSERTION(state, "list construction problem");
 
             if (state->Equals(aListener, aIID)) {
                 // this is the one, pull it out.
                 mListenerArray->RemoveElementAt(count);
                 break;
             }
             count--; 
         }
 
         // if we've emptied the array, get rid of it.
-        if (0 >= mListenerArray->Count()) {
-            (void)mListenerArray->EnumerateForwards(deleteListener, nsnull);
+        if (0 >= mListenerArray->Length()) {
+            for (PRUint32 i = 0, end = mListenerArray->Length(); i < end; i++) {
+               nsWebBrowserListenerState *state = mListenerArray->ElementAt(i);
+               NS_DELETEXPCOM(state);
+            }
             NS_DELETEXPCOM(mListenerArray);
             mListenerArray = nsnull;
         }
 
     } else {
         nsCOMPtr<nsISupports> supports(do_QueryReferent(aListener));
         if (!supports) return NS_ERROR_INVALID_ARG;
         rv = UnBindListener(supports, aIID);
@@ -1143,28 +1143,31 @@ NS_IMETHODIMP nsWebBrowser::Create()
    {
       nsCOMPtr<nsILookAndFeel> laf = do_GetService(kLookAndFeelCID);
       laf->GetColor(nsILookAndFeel::eColor_WindowBackground, mBackgroundColor);
    }
 
    // the docshell has been set so we now have our listener registrars.
    if (mListenerArray) {
       // we had queued up some listeners, let's register them now.
-      PRInt32 count = mListenerArray->Count();
-      PRInt32 i = 0;
+      PRUint32 count = mListenerArray->Length();
+      PRUint32 i = 0;
       NS_ASSERTION(count > 0, "array construction problem");
       while (i < count) {
-          nsWebBrowserListenerState *state = (nsWebBrowserListenerState*)mListenerArray->ElementAt(i);
+          nsWebBrowserListenerState *state = mListenerArray->ElementAt(i);
           NS_ASSERTION(state, "array construction problem");
           nsCOMPtr<nsISupports> listener = do_QueryReferent(state->mWeakPtr);
           NS_ASSERTION(listener, "bad listener");
           (void)BindListener(listener, state->mID);
           i++;
       }
-      (void)mListenerArray->EnumerateForwards(deleteListener, nsnull);
+      for (PRUint32 i = 0, end = mListenerArray->Length(); i < end; i++) {
+         nsWebBrowserListenerState *state = mListenerArray->ElementAt(i);
+         NS_DELETEXPCOM(state);
+      }
       NS_DELETEXPCOM(mListenerArray);
       mListenerArray = nsnull;
    }
 
    // HACK ALERT - this registration registers the nsDocShellTreeOwner as a 
    // nsIWebBrowserListener so it can setup its MouseListener in one of the 
    // progress callbacks. If we can register the MouseListener another way, this 
    // registration can go away, and nsDocShellTreeOwner can stop implementing
--- a/embedding/browser/webBrowser/nsWebBrowser.h
+++ b/embedding/browser/webBrowser/nsWebBrowser.h
@@ -65,17 +65,17 @@
 #include "nsIWebBrowserSetup.h"
 #include "nsIWebBrowserPersist.h"
 #include "nsIWebBrowserFocus.h"
 #include "nsIWebBrowserStream.h"
 #include "nsIWindowWatcher.h"
 #include "nsIPrintSettings.h"
 #include "nsEmbedStream.h"
 
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsWeakPtr.h"
 
 class nsIContentViewerFile;
 
 class nsWebBrowserInitInfo
 {
 public:
    //nsIBaseWindow Stuff
@@ -183,15 +183,15 @@ protected:
    PRUint32                       mPersistResult;
    PRUint32                       mPersistFlags;
 
    // stream
    nsEmbedStream                 *mStream;
    nsCOMPtr<nsISupports>          mStreamGuard;
 
    //Weak Reference interfaces...
-   nsIWidget*                 mParentWidget;
-   nsVoidArray *              mListenerArray;
+   nsIWidget*                            mParentWidget;
+   nsTArray<nsWebBrowserListenerState*>* mListenerArray;
 };
 
 #endif /* nsWebBrowser_h__ */
 
 
--- a/embedding/components/commandhandler/src/nsCommandGroup.cpp
+++ b/embedding/components/commandhandler/src/nsCommandGroup.cpp
@@ -32,17 +32,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsString.h"
 #include "nsReadableUtils.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsISimpleEnumerator.h"
 #include "nsXPCOM.h"
 #include "nsSupportsPrimitives.h"
 #include "nsIComponentManager.h"
 
 #include "nsCommandGroup.h"
 #include "nsIControllerCommand.h"
 #include "nsCRT.h"
@@ -163,30 +163,30 @@ nsGroupsEnumerator::Initialize()
 
 #if 0
 #pragma mark -
 #endif
 
 class nsNamedGroupEnumerator : public nsISimpleEnumerator
 {
 public:
-              nsNamedGroupEnumerator(nsVoidArray* inArray);
+              nsNamedGroupEnumerator(nsTArray<char*>* inArray);
   virtual     ~nsNamedGroupEnumerator();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
 protected:
 
-  nsVoidArray*  mGroupArray;
-  PRInt32       mIndex;
+  nsTArray<char*>* mGroupArray;
+  PRInt32          mIndex;
   
 };
 
-nsNamedGroupEnumerator::nsNamedGroupEnumerator(nsVoidArray* inArray)
+nsNamedGroupEnumerator::nsNamedGroupEnumerator(nsTArray<char*>* inArray)
 : mGroupArray(inArray)
 , mIndex(-1)
 {
 }
 
 nsNamedGroupEnumerator::~nsNamedGroupEnumerator()
 {
 }
@@ -194,35 +194,35 @@ nsNamedGroupEnumerator::~nsNamedGroupEnu
 NS_IMPL_ISUPPORTS1(nsNamedGroupEnumerator, nsISimpleEnumerator)
 
 /* boolean hasMoreElements (); */
 NS_IMETHODIMP
 nsNamedGroupEnumerator::HasMoreElements(PRBool *_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   
-  PRInt32   arrayLen = mGroupArray ? mGroupArray->Count() : 0;
+  PRInt32 arrayLen = mGroupArray ? mGroupArray->Length() : 0;
   *_retval = (mIndex < arrayLen - 1); 
   return NS_OK;
 }
 
 /* nsISupports getNext (); */
 NS_IMETHODIMP
 nsNamedGroupEnumerator::GetNext(nsISupports **_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
 
   if (!mGroupArray)
     return NS_ERROR_FAILURE;
 
   mIndex ++;
-  if (mIndex >= mGroupArray->Count())
+  if (mIndex >= PRInt32(mGroupArray->Length()))
     return NS_ERROR_FAILURE;
     
-  PRUnichar   *thisGroupName = (PRUnichar *)mGroupArray->ElementAt(mIndex);
+  PRUnichar   *thisGroupName = (PRUnichar*)mGroupArray->ElementAt(mIndex);
   NS_ASSERTION(thisGroupName, "Bad Element in mGroupArray");
   
   nsresult rv;
   nsCOMPtr<nsISupportsString> supportsString = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
   if (NS_FAILED(rv)) return rv;
 
   supportsString->SetData(nsDependentString(thisGroupName));
   return CallQueryInterface(supportsString, _retval);
@@ -255,45 +255,45 @@ nsControllerCommandGroup::ClearGroupsHas
 #pragma mark -
 #endif
 
 /* void addCommandToGroup (in DOMString aCommand, in DOMString aGroup); */
 NS_IMETHODIMP
 nsControllerCommandGroup::AddCommandToGroup(const char * aCommand, const char *aGroup)
 {
   nsCStringKey   groupKey(aGroup);  
-  nsVoidArray*  commandList;  
-  if ((commandList = (nsVoidArray *)mGroupsHash.Get(&groupKey)) == nsnull)
+  nsTArray<char*>* commandList;
+  if ((commandList = (nsTArray<char*> *)mGroupsHash.Get(&groupKey)) == nsnull)
   {
     // make this list
-    commandList = new nsAutoVoidArray;    
+    commandList = new nsAutoTArray<char*, 8>;
     mGroupsHash.Put(&groupKey, (void *)commandList);
   }
   // add the command to the list. Note that we're not checking for duplicates here
   char*  commandString = nsCRT::strdup(aCommand);     // we store allocated PRUnichar* in the array
   if (!commandString) return NS_ERROR_OUT_OF_MEMORY;
   
-  PRBool      appended = commandList->AppendElement((void *)commandString);
+  PRBool      appended = commandList->AppendElement(commandString) != nsnull;
   NS_ASSERTION(appended, "Append failed");
 
   return NS_OK;
 }
 
 /* void removeCommandFromGroup (in DOMString aCommand, in DOMString aGroup); */
 NS_IMETHODIMP
 nsControllerCommandGroup::RemoveCommandFromGroup(const char * aCommand, const char * aGroup)
 {
   nsCStringKey   groupKey(aGroup);
-  nsVoidArray*  commandList = (nsVoidArray *)mGroupsHash.Get(&groupKey);
+  nsTArray<char*>* commandList = (nsTArray<char*> *)mGroupsHash.Get(&groupKey);
   if (!commandList) return NS_OK;     // no group
 
-  PRInt32   numEntries = commandList->Count();
-  for (PRInt32 i = 0; i < numEntries; i ++)
+  PRUint32 numEntries = commandList->Length();
+  for (PRUint32 i = 0; i < numEntries; i ++)
   {
-    char*  commandString = (char*)commandList->ElementAt(i);
+    char*  commandString = commandList->ElementAt(i);
     if (!nsCRT::strcmp(aCommand,commandString))
     {
       commandList->RemoveElementAt(i);
       nsMemory::Free(commandString);
       break;
     }
   }
 
@@ -303,23 +303,23 @@ nsControllerCommandGroup::RemoveCommandF
 /* boolean isCommandInGroup (in DOMString aCommand, in DOMString aGroup); */
 NS_IMETHODIMP
 nsControllerCommandGroup::IsCommandInGroup(const char * aCommand, const char * aGroup, PRBool *_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = PR_FALSE;
   
   nsCStringKey   groupKey(aGroup);
-  nsVoidArray*  commandList = (nsVoidArray *)mGroupsHash.Get(&groupKey);
+  nsTArray<char*>* commandList = (nsTArray<char*> *)mGroupsHash.Get(&groupKey);
   if (!commandList) return NS_OK;     // no group
   
-  PRInt32   numEntries = commandList->Count();
-  for (PRInt32 i = 0; i < numEntries; i ++)
+  PRUint32 numEntries = commandList->Length();
+  for (PRUint32 i = 0; i < numEntries; i ++)
   {
-    char*  commandString = (char*)commandList->ElementAt(i);
+    char*  commandString = commandList->ElementAt(i);
     if (!nsCRT::strcmp(aCommand,commandString))
     {
       *_retval = PR_TRUE;
       break;
     }
   }
   return NS_OK;
 }
@@ -334,37 +334,37 @@ nsControllerCommandGroup::GetGroupsEnume
   return groupsEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)_retval);
 }
 
 /* nsISimpleEnumerator getEnumeratorForGroup (in DOMString aGroup); */
 NS_IMETHODIMP
 nsControllerCommandGroup::GetEnumeratorForGroup(const char * aGroup, nsISimpleEnumerator **_retval)
 {
   nsCStringKey   groupKey(aGroup);  
-  nsVoidArray*  commandList = (nsVoidArray *)mGroupsHash.Get(&groupKey);    // may be null
+  nsTArray<char*>* commandList = (nsTArray<char*> *)mGroupsHash.Get(&groupKey); // may be null
 
   nsNamedGroupEnumerator*   theGroupEnum = new nsNamedGroupEnumerator(commandList);
   if (!theGroupEnum) return NS_ERROR_OUT_OF_MEMORY;
 
   return theGroupEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)_retval);
 }
 
 #if 0
 #pragma mark -
 #endif
  
 PRBool nsControllerCommandGroup::ClearEnumerator(nsHashKey *aKey, void *aData, void* closure)
 {
-  nsVoidArray*    commandList = (nsVoidArray *)aData;
+  nsTArray<char*>* commandList = (nsTArray<char*> *)aData;
   if (commandList)
   {  
-    PRInt32   numEntries = commandList->Count();
-    for (PRInt32 i = 0; i < numEntries; i ++)
+    PRUint32 numEntries = commandList->Length();
+    for (PRUint32 i = 0; i < numEntries; i ++)
     {
-      char*  commandString = (char*)commandList->ElementAt(i);
+      char* commandString = commandList->ElementAt(i);
       nsMemory::Free(commandString);
     }
     
     delete commandList;
   }
 
   return PR_TRUE;
 }
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
@@ -616,17 +616,17 @@ nsWebBrowserPersist::SerializeNextFile()
     nsresult rv = SaveGatheredURIs(nsnull);
     if (NS_FAILED(rv))
     {
         return PR_FALSE;
     }
 
     return (mURIMap.Count() 
         || mUploadList.Count()
-        || mDocList.Count()
+        || mDocList.Length()
         || mOutputMap.Count());
 }
 
 
 //*****************************************************************************
 // nsWebBrowserPersist::nsIRequestObserver
 //*****************************************************************************
 
@@ -770,17 +770,17 @@ NS_IMETHODIMP nsWebBrowserPersist::OnSto
         NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
     }
 
     PRBool completed = PR_FALSE;
     if (mOutputMap.Count() == 0 && mUploadList.Count() == 0 && !mCancel)
     {
         // if no documents left in mDocList, --> done
         // if we have no files left to serialize and no error result, --> done
-        if (mDocList.Count() == 0
+        if (mDocList.Length() == 0
             || (!SerializeNextFile() && NS_SUCCEEDED(mPersistResult)))
         {
             completed = PR_TRUE;
         }
     }
 
     if (completed)
     {
@@ -1720,20 +1720,20 @@ nsresult nsWebBrowserPersist::SaveDocume
 {
     nsresult rv = NS_OK;
 
     mStartSaving = PR_TRUE;
 
     // Iterate through all queued documents, saving them to file and fixing
     // them up on the way.
 
-    PRInt32 i;
-    for (i = 0; i < mDocList.Count(); i++)
+    PRUint32 i;
+    for (i = 0; i < mDocList.Length(); i++)
     {
-        DocData *docData = (DocData *) mDocList.ElementAt(i);
+        DocData *docData = mDocList.ElementAt(i);
         if (!docData)
         {
             rv = NS_ERROR_FAILURE;
             break;
         }
 
         mCurrentBaseURI = docData->mBaseURI;
         mCurrentCharset = docData->mCharset;
@@ -1768,19 +1768,19 @@ nsresult nsWebBrowserPersist::SaveDocume
             break;
 
         // if we're serializing, bail after first iteration of loop
         if (mSerializingOutput)
             break;
     }
 
     // delete, cleanup regardless of errors (bug 132417)
-    for (i = 0; i < mDocList.Count(); i++)
+    for (i = 0; i < mDocList.Length(); i++)
     {
-        DocData *docData = (DocData *) mDocList.ElementAt(i);
+        DocData *docData = mDocList.ElementAt(i);
         delete docData;
         if (mSerializingOutput)
         {
             mDocList.RemoveElementAt(i);
             break;
         }
     }
 
@@ -1795,45 +1795,45 @@ nsresult nsWebBrowserPersist::SaveDocume
 void nsWebBrowserPersist::Cleanup()
 {
     mURIMap.Enumerate(EnumCleanupURIMap, this);
     mURIMap.Reset();
     mOutputMap.Enumerate(EnumCleanupOutputMap, this);
     mOutputMap.Reset();
     mUploadList.Enumerate(EnumCleanupUploadList, this);
     mUploadList.Reset();
-    PRInt32 i;
-    for (i = 0; i < mDocList.Count(); i++)
+    PRUint32 i;
+    for (i = 0; i < mDocList.Length(); i++)
     {
-        DocData *docData = (DocData *) mDocList.ElementAt(i);
+        DocData *docData = mDocList.ElementAt(i);
         delete docData;
     }
     mDocList.Clear();
-    for (i = 0; i < mCleanupList.Count(); i++)
+    for (i = 0; i < mCleanupList.Length(); i++)
     {
-        CleanupData *cleanupData = (CleanupData *) mCleanupList.ElementAt(i);
+        CleanupData *cleanupData = mCleanupList.ElementAt(i);
         delete cleanupData;
     }
     mCleanupList.Clear();
     mFilenameList.Clear();
 }
 
 void nsWebBrowserPersist::CleanupLocalFiles()
 {
     // Two passes, the first pass cleans up files, the second pass tests
     // for and then deletes empty directories. Directories that are not
     // empty after the first pass must contain files from something else
     // and are not deleted.
     int pass;
     for (pass = 0; pass < 2; pass++)
     {
-        PRInt32 i;
-        for (i = 0; i < mCleanupList.Count(); i++)
+        PRUint32 i;
+        for (i = 0; i < mCleanupList.Length(); i++)
         {
-            CleanupData *cleanupData = (CleanupData *) mCleanupList.ElementAt(i);
+            CleanupData *cleanupData = mCleanupList.ElementAt(i);
             nsCOMPtr<nsILocalFile> file = cleanupData->mFile;
 
             // Test if the dir / file exists (something in an earlier loop
             // may have already removed it)
             PRBool exists = PR_FALSE;
             file->Exists(&exists);
             if (!exists)
                 continue;
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h
@@ -52,26 +52,27 @@
 #include "nsIStyleSheet.h"
 #include "nsIDocumentEncoder.h"
 #include "nsITransport.h"
 #include "nsIProgressEventSink.h"
 #include "nsILocalFile.h"
 #include "nsIWebProgressListener2.h"
 
 #include "nsHashtable.h"
-#include "nsVoidArray.h"
 #include "nsTArray.h"
 #include "nsInt64.h"
 
 #include "nsCWebBrowserPersist.h"
 
 class nsEncoderNodeFixup;
 class nsIStorageStream;
 
 struct URIData;
+struct CleanupData;
+struct DocData;
 
 class nsWebBrowserPersist : public nsIInterfaceRequestor,
                             public nsIWebBrowserPersist,
                             public nsIStreamListener,
                             public nsIProgressEventSink,
                             public nsSupportsWeakReference
 {
     friend class nsEncoderNodeFixup;
@@ -220,18 +221,18 @@ private:
      * mProgressListener, but is a member to avoid having to qi it for each
      * progress notification.
      */
     nsCOMPtr<nsIWebProgressListener2> mProgressListener2;
     nsCOMPtr<nsIProgressEventSink> mEventSink;
     nsHashtable               mOutputMap;
     nsHashtable               mUploadList;
     nsHashtable               mURIMap;
-    nsVoidArray               mDocList;
-    nsVoidArray               mCleanupList;
+    nsTArray<DocData*>        mDocList;
+    nsTArray<CleanupData*>    mCleanupList;
     nsTArray<nsCString>       mFilenameList;
     PRPackedBool              mFirstAndOnlyUse;
     PRPackedBool              mCancel;
     PRPackedBool              mJustStartedLoading;
     PRPackedBool              mCompleted;
     PRPackedBool              mStartSaving;
     PRPackedBool              mReplaceExisting;
     PRPackedBool              mSerializingOutput;
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
@@ -1242,25 +1242,25 @@ nsWindowWatcher::FindWindowEntry(nsIDOMW
     listEnd = mOldestWindow;
   }
   return 0;
 #endif
 }
 
 nsresult nsWindowWatcher::RemoveWindow(nsWatcherWindowEntry *inInfo)
 {
-  PRInt32  ctr,
-           count = mEnumeratorList.Count();
+  PRUint32  ctr,
+            count = mEnumeratorList.Length();
   nsresult rv;
 
   {
     // notify the enumerators
     nsAutoLock lock(mListLock);
     for (ctr = 0; ctr < count; ++ctr) 
-      ((nsWatcherWindowEnumerator*)mEnumeratorList[ctr])->WindowRemoved(inInfo);
+      mEnumeratorList[ctr]->WindowRemoved(inInfo);
 
     // remove the element from the list
     if (inInfo == mOldestWindow)
       mOldestWindow = inInfo->mYounger == mOldestWindow ? 0 : inInfo->mYounger;
     inInfo->Unlink();
 
     // clear the active window, if they're the same
     if (mActiveWindow == inInfo->mWindow)
@@ -1337,17 +1337,17 @@ nsWindowWatcher::GetWindowByName(const P
 
   return NS_OK;
 }
 
 PRBool
 nsWindowWatcher::AddEnumerator(nsWatcherWindowEnumerator* inEnumerator)
 {
   // (requires a lock; assumes it's called by someone holding the lock)
-  return mEnumeratorList.AppendElement(inEnumerator);
+  return mEnumeratorList.AppendElement(inEnumerator) != nsnull;
 }
 
 PRBool
 nsWindowWatcher::RemoveEnumerator(nsWatcherWindowEnumerator* inEnumerator)
 {
   // (requires a lock; assumes it's called by someone holding the lock)
   return mEnumeratorList.RemoveElement(inEnumerator);
 }
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.h
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.h
@@ -44,17 +44,17 @@
 
 #include "nsCOMPtr.h"
 #include "jspubtd.h"
 #include "nsIWindowCreator.h" // for stupid compilers
 #include "nsIWindowWatcher.h"
 #include "nsIPromptFactory.h"
 #include "nsIAuthPromptAdapterFactory.h"
 #include "nsPIWindowWatcher.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
 class  nsIURI;
 class  nsIDocShellTreeItem;
 class  nsIDocShellTreeOwner;
 class  nsIWebBrowserChrome;
 class  nsString;
 class  nsWatcherWindowEnumerator;
 class  nsIScriptContext;
@@ -139,17 +139,17 @@ private:
   static void       SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
                                            nsIDOMWindow *aParent,
                                            const SizeSpec & aSizeSpec);
   static void       GetWindowTreeItem(nsIDOMWindow *inWindow,
                                       nsIDocShellTreeItem **outTreeItem);
   static void       GetWindowTreeOwner(nsIDOMWindow *inWindow,
                                        nsIDocShellTreeOwner **outTreeOwner);
 
-  nsVoidArray           mEnumeratorList;
+  nsTArray<nsWatcherWindowEnumerator*> mEnumeratorList;
   nsWatcherWindowEntry *mOldestWindow;
   nsIDOMWindow         *mActiveWindow;
   PRLock               *mListLock;
 
   nsCOMPtr<nsIWindowCreator> mWindowCreator;
 };
 
 #endif
--- a/embedding/qa/testembed/StdAfx.h
+++ b/embedding/qa/testembed/StdAfx.h
@@ -56,17 +56,16 @@
 #include <afxpriv.h>		// Needed for MFC MBCS/Unicode Conversion Macros
 #ifndef _AFX_NO_AFXCMN_SUPPORT
 #include <afxcmn.h>			// MFC support for Windows Common Controls
 #endif // _AFX_NO_AFXCMN_SUPPORT
 
 #include "nsCOMPtr.h"
 #include "nsNetUtil.h"
 #include "nsString.h"
-#include "nsVoidArray.h"
 #include "nsCWebBrowser.h"
 #include "nsXPIDLString.h"
 #include "nsWidgetsCID.h"
 #include "nsIDocShell.h"
 #include "nsIWebBrowser.h"
 #include "nsIBaseWindow.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebBrowserChrome.h"