Bug 461047 follow-up patch - Fix a number of small issues from the nsStringArray to nsTArray<nsString> switchover, mostly related to signed vs unsigned array sizes. r+sr=roc
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 10 Feb 2009 12:39:43 -0800
changeset 24835 70ae20e89604399a6c65f43cc377c820c1310020
parent 24834 4e892b36c3f57bf77fae370f57b9218c635868bf
child 24836 4db1cd62b2c34764b251a74b649f5e6eeb6d5628
child 24886 b59ebaa8675118ce7fc02492e5fdba460644c40f
push idunknown
push userunknown
push dateunknown
bugs461047
milestone1.9.2a1pre
Bug 461047 follow-up patch - Fix a number of small issues from the nsStringArray to nsTArray<nsString> switchover, mostly related to signed vs unsigned array sizes. r+sr=roc
content/base/src/nsDOMLists.cpp
content/xslt/src/xml/txDOM.h
content/xslt/src/xml/txNodeDefinition.cpp
editor/libeditor/html/nsHTMLEditor.cpp
toolkit/components/commandlines/src/nsCommandLine.cpp
widget/src/cocoa/nsFilePicker.mm
--- a/content/base/src/nsDOMLists.cpp
+++ b/content/base/src/nsDOMLists.cpp
@@ -167,17 +167,17 @@ nsNameList::Contains(const nsAString& aN
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNameList::ContainsNS(const nsAString& aNamespaceURI, const nsAString& aName,
                        PRBool *aResult)
 {
   PRUint32 index = mNames.IndexOf(aName);
-  if (index != PRUint32(-1)) {
+  if (index != mNames.NoIndex) {
     *aResult = mNamespaceURIs[index].Equals(aNamespaceURI);
   }
   else {
     *aResult = PR_FALSE;
   }
 
   return NS_OK;
 }
--- a/content/xslt/src/xml/txDOM.h
+++ b/content/xslt/src/xml/txDOM.h
@@ -53,17 +53,16 @@
 #include <stdlib.h>
 #endif
 
 #include "txList.h"
 #include "nsIAtom.h"
 #include "nsDoubleHashtable.h"
 #include "nsString.h"
 #include "nsVoidArray.h"
-#include "nsTArray.h"
 #include "txCore.h"
 #include "nsAutoPtr.h"
 
 #define kTxNsNodeIndexOffset 0x00000000;
 #define kTxAttrIndexOffset 0x40000000;
 #define kTxChildIndexOffset 0x80000000;
 
 class NamedNodeMap;
@@ -418,17 +417,17 @@ public:
     }
 
     static MBool init()
     {
         NS_ASSERTION(!mNamespaces,
                      "called without matching shutdown()");
         if (mNamespaces)
             return MB_TRUE;
-        mNamespaces = new nsTArray<nsString>();
+        mNamespaces = new nsStringArray();
         if (!mNamespaces)
             return MB_FALSE;
         /*
          * Hardwiring some Namespace IDs.
          * no Namespace is 0
          * xmlns prefix is 1, mapped to http://www.w3.org/2000/xmlns/
          * xml prefix is 2, mapped to http://www.w3.org/XML/1998/namespace
          */
@@ -448,15 +447,15 @@ public:
         NS_ASSERTION(mNamespaces, "called without matching init()");
         if (!mNamespaces)
             return;
         delete mNamespaces;
         mNamespaces = nsnull;
     }
 
 private:
-    static nsTArray<nsString>* mNamespaces;
+    static nsStringArray* mNamespaces;
 };
 
 #define TX_IMPL_DOM_STATICS \
-    nsTArray<nsString>* txStandaloneNamespaceManager::mNamespaces = 0
+    nsStringArray* txStandaloneNamespaceManager::mNamespaces = 0
 
 #endif
--- a/content/xslt/src/xml/txNodeDefinition.cpp
+++ b/content/xslt/src/xml/txNodeDefinition.cpp
@@ -249,17 +249,17 @@ nsresult NodeDefinition::getBaseURI(nsAS
   }
 
   PRUint32 count = baseUrls.Length();
   if (count) {
     aURI = baseUrls[--count];
 
     while (count > 0) {
       nsAutoString dest;
-      URIUtils::resolveHref(*baseUrls[--count], aURI, dest);
+      URIUtils::resolveHref(baseUrls[--count], aURI, dest);
       aURI = dest;
     }
   }
   
   return NS_OK;
 } // getBaseURI
 
 /*
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -3722,19 +3722,19 @@ nsHTMLEditor::AddNewStyleSheetToList(con
 
   return mStyleSheets.AppendObject(aStyleSheet) ? NS_OK : NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 nsHTMLEditor::RemoveStyleSheetFromList(const nsAString &aURL)
 {
   // is it already in the list?
-  PRInt32 foundIndex;
+  PRUint32 foundIndex;
   foundIndex = mStyleSheetURLs.IndexOf(aURL);
-  if (foundIndex < 0)
+  if (foundIndex == mStyleSheetURLs.NoIndex)
     return NS_ERROR_FAILURE;
 
   // Attempt both removals; if one fails there's not much we can do.
   nsresult rv = NS_OK;
   if (!mStyleSheets.RemoveObjectAt(foundIndex))
     rv = NS_ERROR_FAILURE;
   mStyleSheetURLs.RemoveElementAt(foundIndex);
 
@@ -3744,19 +3744,19 @@ nsHTMLEditor::RemoveStyleSheetFromList(c
 NS_IMETHODIMP
 nsHTMLEditor::GetStyleSheetForURL(const nsAString &aURL,
                                   nsICSSStyleSheet **aStyleSheet)
 {
   NS_ENSURE_ARG_POINTER(aStyleSheet);
   *aStyleSheet = 0;
 
   // is it already in the list?
-  PRInt32 foundIndex;
+  PRUint32 foundIndex;
   foundIndex = mStyleSheetURLs.IndexOf(aURL);
-  if (foundIndex < 0)
+  if (foundIndex == mStyleSheetURLs.NoIndex)
     return NS_OK; //No sheet -- don't fail!
 
   *aStyleSheet = mStyleSheets[foundIndex];
   if (!*aStyleSheet)
     return NS_ERROR_FAILURE;
 
   NS_ADDREF(*aStyleSheet);
 
@@ -3766,16 +3766,18 @@ nsHTMLEditor::GetStyleSheetForURL(const 
 NS_IMETHODIMP
 nsHTMLEditor::GetURLForStyleSheet(nsICSSStyleSheet *aStyleSheet,
                                   nsAString &aURL)
 {
   // is it already in the list?
   PRInt32 foundIndex = mStyleSheets.IndexOf(aStyleSheet);
 
   // Don't fail if we don't find it in our list
+  // Note: mStyleSheets is nsCOMArray, so its IndexOf() method
+  // returns -1 on failure.
   if (foundIndex == -1)
     return NS_OK;
 
   // Found it in the list!
   aURL = mStyleSheetURLs[foundIndex];
   return NS_OK;
 }
 
--- a/toolkit/components/commandlines/src/nsCommandLine.cpp
+++ b/toolkit/components/commandlines/src/nsCommandLine.cpp
@@ -161,17 +161,17 @@ nsCommandLine::FindFlag(const nsAString&
   *aResult = -1;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCommandLine::RemoveArguments(PRInt32 aStart, PRInt32 aEnd)
 {
   NS_ENSURE_ARG_MIN(aStart, 0);
-  NS_ENSURE_ARG_MAX(aEnd, mArgs.Length() - 1);
+  NS_ENSURE_ARG_MAX(aEnd + 1, mArgs.Length());
 
   for (PRInt32 i = aEnd; i >= aStart; --i) {
     mArgs.RemoveElementAt(i);
   }
 
   return NS_OK;
 }
 
--- a/widget/src/cocoa/nsFilePicker.mm
+++ b/widget/src/cocoa/nsFilePicker.mm
@@ -120,18 +120,18 @@ NSView* nsFilePicker::GetAccessoryView()
   [textField setBordered:NO];
   [textField setFont:[NSFont labelFontOfSize:13.0]];
   [textField setStringValue:saveAsLabel];
   [textField setTag:0];
   [textField sizeToFit];
 
   // set up popup button
   NSPopUpButton* popupButton = [[[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0) pullsDown:NO] autorelease];
-  PRInt32 numMenuItems = mTitles.Length();
-  for (int i = 0; i < numMenuItems; i++) {
+  PRUint32 numMenuItems = mTitles.Length();
+  for (PRUint32 i = 0; i < numMenuItems; i++) {
     const nsString& currentTitle = mTitles[i];
     NSString *titleString;
     if (currentTitle.IsEmpty()) {
       const nsString& currentFilter = mFilters[i];
       titleString = [[NSString alloc] initWithCharacters:currentFilter.get()
                                                   length:currentFilter.Length()];
     }
     else {
@@ -418,17 +418,17 @@ nsFilePicker::GenerateFilterList()
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   NSArray *filterArray = nil;
   if (mFilters.Length() > 0) {
     // Set up our filter string
     NSMutableString *giantFilterString = [[[NSMutableString alloc] initWithString:@""] autorelease];
 
     // Loop through each of the filter strings
-    for (PRInt32 loop = 0; PRInt32(loop < mFilters.Length()); loop++) {
+    for (PRUint32 loop = 0; loop < mFilters.Length(); loop++) {
       const nsString& filterWide = mFilters[loop];
 
       // separate individual filters
       if ([giantFilterString length] > 0)
         [giantFilterString appendString:[NSString stringWithString:@";"]];
 
       // handle special case filters
       if (filterWide.Equals(NS_LITERAL_STRING("*"))) {