--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -107,37 +107,37 @@ nsAccessibleDOMStringList::~nsAccessible
{
}
NS_IMPL_ISUPPORTS1(nsAccessibleDOMStringList, nsIDOMDOMStringList)
NS_IMETHODIMP
nsAccessibleDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
{
- if (aIndex >= (PRUint32)mNames.Count()) {
+ if (aIndex >= mNames.Length()) {
SetDOMStringToNull(aResult);
} else {
- mNames.StringAt(aIndex, aResult);
+ aResult = mNames.ElementAt(aIndex);
}
return NS_OK;
}
NS_IMETHODIMP
nsAccessibleDOMStringList::GetLength(PRUint32 *aLength)
{
- *aLength = (PRUint32)mNames.Count();
+ *aLength = mNames.Length();
return NS_OK;
}
NS_IMETHODIMP
nsAccessibleDOMStringList::Contains(const nsAString& aString, PRBool *aResult)
{
- *aResult = mNames.IndexOf(aString) > -1;
+ *aResult = mNames.Contains(aString);
return NS_OK;
}
/*
* Class nsAccessible
*/
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -50,16 +50,17 @@
#include "nsIAccessibleStates.h"
#include "nsAccessibleRelationWrap.h"
#include "nsIAccessibleEvent.h"
#include "nsIDOMNodeList.h"
#include "nsINameSpaceManager.h"
#include "nsWeakReference.h"
#include "nsString.h"
+#include "nsTArray.h"
#include "nsIDOMDOMStringList.h"
#include "nsARIAMap.h"
struct nsRect;
class nsIContent;
class nsIFrame;
class nsIPresShell;
class nsIDOMNode;
@@ -83,21 +84,21 @@ class nsAccessibleDOMStringList : public
public:
nsAccessibleDOMStringList();
virtual ~nsAccessibleDOMStringList();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMDOMSTRINGLIST
PRBool Add(const nsAString& aName) {
- return mNames.AppendString(aName);
+ return mNames.AppendElement(aName) != nsnull;
}
private:
- nsStringArray mNames;
+ nsTArray<nsString> mNames;
};
#define NS_ACCESSIBLE_IMPL_CID \
{ /* 4E36C7A8-9203-4ef9-B619-271DDF6BB839 */ \
0x4e36c7a8, \
0x9203, \
0x4ef9, \
--- a/content/base/public/nsIXPathEvaluatorInternal.h
+++ b/content/base/public/nsIXPathEvaluatorInternal.h
@@ -35,16 +35,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIXPathEvaluatorInternal_h__
#define nsIXPathEvaluatorInternal_h__
#include "nsCOMArray.h"
+#include "nsTArray.h"
class nsIDOMDocument;
class nsIDOMXPathExpression;
class nsIDOMXPathNSResolver;
#define NS_IXPATHEVALUATORINTERNAL_IID \
{0xb4b72daa, 0x65d6, 0x440f, \
{ 0xb6, 0x08, 0xe2, 0xee, 0x9a, 0x82, 0xf3, 0x13 }}
@@ -57,17 +58,17 @@ public:
/**
* Sets the document this evaluator corresponds to
*/
NS_IMETHOD SetDocument(nsIDOMDocument* aDocument) = 0;
NS_IMETHOD CreateExpression(const nsAString &aExpression,
nsIDOMXPathNSResolver *aResolver,
- nsStringArray *aNamespaceURIs,
+ nsTArray<nsString> *aNamespaceURIs,
nsCStringArray *aContractIDs,
nsCOMArray<nsISupports> *aState,
nsIDOMXPathExpression **aResult) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIXPathEvaluatorInternal,
NS_IXPATHEVALUATORINTERNAL_IID)
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -351,17 +351,17 @@ nsContentSink::ScriptAvailable(nsresult
if (count == 0) {
return NS_OK;
}
// aElement will not be in mScriptElements if a <script> was added
// using the DOM during loading, or if the script was inline and thus
// never blocked.
- NS_ASSERTION(mScriptElements.IndexOf(aElement) == count - 1 ||
+ NS_ASSERTION(mScriptElements.IndexOf(aElement) == PRUint32(count - 1) ||
mScriptElements.IndexOf(aElement) == PRUint32(-1),
"script found at unexpected position");
// Check if this is the element we were waiting for
if (aElement != mScriptElements[count - 1]) {
return NS_OK;
}
@@ -714,35 +714,35 @@ nsContentSink::ProcessLinkHeader(nsICont
nsresult
nsContentSink::ProcessLink(nsIContent* aElement,
const nsSubstring& aHref, const nsSubstring& aRel,
const nsSubstring& aTitle, const nsSubstring& aType,
const nsSubstring& aMedia)
{
// XXX seems overkill to generate this string array
- nsStringArray linkTypes;
+ nsTArray<nsString> linkTypes;
nsStyleLinkElement::ParseLinkTypes(aRel, linkTypes);
- PRBool hasPrefetch = (linkTypes.IndexOf(NS_LITERAL_STRING("prefetch")) != -1);
+ PRBool hasPrefetch = linkTypes.Contains(NS_LITERAL_STRING("prefetch"));
// prefetch href if relation is "next" or "prefetch"
- if (hasPrefetch || linkTypes.IndexOf(NS_LITERAL_STRING("next")) != -1) {
+ if (hasPrefetch || linkTypes.Contains(NS_LITERAL_STRING("next"))) {
PrefetchHref(aHref, aElement, hasPrefetch);
}
- if ((!aHref.IsEmpty()) && linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
+ if ((!aHref.IsEmpty()) && linkTypes.Contains(NS_LITERAL_STRING("dns-prefetch"))) {
PrefetchDNS(aHref);
}
// is it a stylesheet link?
- if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) == -1) {
+ if (!linkTypes.Contains(NS_LITERAL_STRING("stylesheet"))) {
return NS_OK;
}
- PRBool isAlternate = linkTypes.IndexOf(NS_LITERAL_STRING("alternate")) != -1;
+ PRBool isAlternate = linkTypes.Contains(NS_LITERAL_STRING("alternate"));
return ProcessStyleLink(aElement, aHref, isAlternate, aTitle, aType,
aMedia);
}
nsresult
nsContentSink::ProcessStyleLink(nsIContent* aElement,
const nsSubstring& aHref,
PRBool aAlternate,
--- a/content/base/src/nsContentSink.h
+++ b/content/base/src/nsContentSink.h
@@ -50,16 +50,17 @@
#include "nsWeakReference.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "nsString.h"
#include "nsAutoPtr.h"
#include "nsGkAtoms.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
+#include "nsTArray.h"
#include "nsITimer.h"
#include "nsStubDocumentObserver.h"
#include "nsIParserService.h"
#include "nsIContentSink.h"
#include "prlog.h"
#include "nsIRequest.h"
#include "nsTimer.h"
#include "nsCycleCollectionParticipant.h"
--- a/content/base/src/nsDOMLists.cpp
+++ b/content/base/src/nsDOMLists.cpp
@@ -64,37 +64,37 @@ NS_INTERFACE_TABLE_HEAD(nsDOMStringList)
NS_OFFSET_AND_INTERFACE_TABLE_END
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DOMStringList)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
{
- if (aIndex >= (PRUint32)mNames.Count()) {
+ if (aIndex >= mNames.Length()) {
SetDOMStringToNull(aResult);
} else {
- mNames.StringAt(aIndex, aResult);
+ aResult = mNames[aIndex];
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMStringList::GetLength(PRUint32 *aLength)
{
- *aLength = (PRUint32)mNames.Count();
+ *aLength = mNames.Length();
return NS_OK;
}
NS_IMETHODIMP
nsDOMStringList::Contains(const nsAString& aString, PRBool *aResult)
{
- *aResult = mNames.IndexOf(aString) > -1;
+ *aResult = mNames.Contains(aString);
return NS_OK;
}
nsNameList::nsNameList()
{
}
@@ -111,76 +111,73 @@ NS_INTERFACE_TABLE_HEAD(nsNameList)
NS_OFFSET_AND_INTERFACE_TABLE_END
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NameList)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsNameList::GetName(PRUint32 aIndex, nsAString& aResult)
{
- if (aIndex >= (PRUint32)mNames.Count()) {
+ if (aIndex >= mNames.Length()) {
SetDOMStringToNull(aResult);
} else {
- mNames.StringAt(aIndex, aResult);
+ aResult = mNames[aIndex];
}
return NS_OK;
}
NS_IMETHODIMP
nsNameList::GetNamespaceURI(PRUint32 aIndex, nsAString& aResult)
{
- if (aIndex >= (PRUint32)mNames.Count()) {
+ if (aIndex >= mNames.Length()) {
SetDOMStringToNull(aResult);
} else {
- mNamespaceURIs.StringAt(aIndex, aResult);
+ aResult = mNamespaceURIs[aIndex];
}
return NS_OK;
}
NS_IMETHODIMP
nsNameList::GetLength(PRUint32 *aLength)
{
- *aLength = (PRUint32)mNames.Count();
+ *aLength = mNames.Length();
return NS_OK;
}
PRBool
nsNameList::Add(const nsAString& aNamespaceURI, const nsAString& aName)
{
- PRInt32 count = mNamespaceURIs.Count();
- if (mNamespaceURIs.InsertStringAt(aNamespaceURI, count)) {
- if (mNames.InsertStringAt(aName, count)) {
+ PRUint32 count = mNamespaceURIs.Length();
+ if (mNamespaceURIs.InsertElementAt(count, aNamespaceURI)) {
+ if (mNames.InsertElementAt(count, aName)) {
return PR_TRUE;
}
- mNamespaceURIs.RemoveStringAt(count);
+ mNamespaceURIs.RemoveElementAt(count);
}
return PR_FALSE;
}
NS_IMETHODIMP
nsNameList::Contains(const nsAString& aName, PRBool *aResult)
{
- *aResult = mNames.IndexOf(aName) > -1;
+ *aResult = mNames.Contains(aName);
return NS_OK;
}
NS_IMETHODIMP
nsNameList::ContainsNS(const nsAString& aNamespaceURI, const nsAString& aName,
PRBool *aResult)
{
- PRInt32 index = mNames.IndexOf(aName);
- if (index > -1) {
- nsAutoString ns;
- mNamespaceURIs.StringAt(index, ns);
-
- *aResult = ns.Equals(aNamespaceURI);
+ PRUint32 index = mNames.IndexOf(aName);
+ if (index != PRUint32(-1)) {
+ *aResult = mNamespaceURIs[index].Equals(aNamespaceURI);
}
else {
*aResult = PR_FALSE;
}
return NS_OK;
}
--- a/content/base/src/nsDOMLists.h
+++ b/content/base/src/nsDOMLists.h
@@ -43,44 +43,46 @@
*/
#ifndef nsDOMLists_h___
#define nsDOMLists_h___
#include "nsIDOMDOMStringList.h"
#include "nsIDOMNameList.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
+#include "nsString.h"
class nsDOMStringList : public nsIDOMDOMStringList
{
public:
nsDOMStringList();
virtual ~nsDOMStringList();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMDOMSTRINGLIST
PRBool Add(const nsAString& aName)
{
- return mNames.AppendString(aName);
+ return mNames.AppendElement(aName) != nsnull;
}
private:
- nsStringArray mNames;
+ nsTArray<nsString> mNames;
};
class nsNameList : public nsIDOMNameList
{
public:
nsNameList();
virtual ~nsNameList();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMNAMELIST
PRBool Add(const nsAString& aNamespaceURI, const nsAString& aName);
private:
- nsStringArray mNamespaceURIs;
- nsStringArray mNames;
+ nsTArray<nsString> mNamespaceURIs;
+ nsTArray<nsString> mNames;
};
#endif /* nsDOMLists_h___ */
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1217,17 +1217,17 @@ public:
void Disconnect()
{
mDocument = nsnull;
}
protected:
// Rebuild our list of style sets
- nsresult GetSets(nsStringArray& aStyleSets);
+ nsresult GetSets(nsTArray<nsString>& aStyleSets);
nsIDocument* mDocument; // Our document; weak ref. It'll let us know if it
// dies.
};
NS_IMPL_ADDREF(nsDOMStyleSheetSetList)
NS_IMPL_RELEASE(nsDOMStyleSheetSetList)
NS_INTERFACE_TABLE_HEAD(nsDOMStyleSheetSetList)
@@ -1242,70 +1242,70 @@ nsDOMStyleSheetSetList::nsDOMStyleSheetS
: mDocument(aDocument)
{
NS_ASSERTION(mDocument, "Must have document!");
}
NS_IMETHODIMP
nsDOMStyleSheetSetList::Item(PRUint32 aIndex, nsAString& aResult)
{
- nsStringArray styleSets;
+ nsTArray<nsString> styleSets;
nsresult rv = GetSets(styleSets);
NS_ENSURE_SUCCESS(rv, rv);
- if (aIndex >= (PRUint32)styleSets.Count()) {
+ if (aIndex >= styleSets.Length()) {
SetDOMStringToNull(aResult);
} else {
- styleSets.StringAt(aIndex, aResult);
+ aResult = styleSets[aIndex];
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMStyleSheetSetList::GetLength(PRUint32 *aLength)
{
- nsStringArray styleSets;
+ nsTArray<nsString> styleSets;
nsresult rv = GetSets(styleSets);
NS_ENSURE_SUCCESS(rv, rv);
- *aLength = (PRUint32)styleSets.Count();
+ *aLength = styleSets.Length();
return NS_OK;
}
NS_IMETHODIMP
nsDOMStyleSheetSetList::Contains(const nsAString& aString, PRBool *aResult)
{
- nsStringArray styleSets;
+ nsTArray<nsString> styleSets;
nsresult rv = GetSets(styleSets);
NS_ENSURE_SUCCESS(rv, rv);
- *aResult = styleSets.IndexOf(aString) != -1;
+ *aResult = styleSets.Contains(aString);
return NS_OK;
}
nsresult
-nsDOMStyleSheetSetList::GetSets(nsStringArray& aStyleSets)
+nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
{
if (!mDocument) {
return NS_OK; // Spec says "no exceptions", and we have no style sets if we
// have no document, for sure
}
PRInt32 count = mDocument->GetNumberOfStyleSheets();
nsAutoString title;
nsAutoString temp;
for (PRInt32 index = 0; index < count; index++) {
nsIStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
sheet->GetTitle(title);
- if (!title.IsEmpty() && aStyleSets.IndexOf(title) == -1 &&
- !aStyleSets.AppendString(title)) {
+ if (!title.IsEmpty() && !aStyleSets.Contains(title) &&
+ !aStyleSets.AppendElement(title)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
return NS_OK;
}
// ==================================================================
--- a/content/base/src/nsNameSpaceManager.cpp
+++ b/content/base/src/nsNameSpaceManager.cpp
@@ -40,16 +40,17 @@
* between namespace IDs and namespace URIs.
*/
#include "nscore.h"
#include "nsINameSpaceManager.h"
#include "nsAutoPtr.h"
#include "nsINodeInfo.h"
#include "nsCOMArray.h"
+#include "nsTArray.h"
#include "nsContentCreatorFunctions.h"
#include "nsDataHashtable.h"
#include "nsString.h"
#ifdef MOZ_XTF
#include "nsIServiceManager.h"
#include "nsIXTFService.h"
#include "nsContentUtils.h"
@@ -126,17 +127,17 @@ public:
PRInt32 GetNameSpaceID(const nsAString& aURI);
PRBool HasElementCreator(PRInt32 aNameSpaceID);
private:
nsresult AddNameSpace(const nsAString& aURI, const PRInt32 aNameSpaceID);
nsDataHashtable<nsNameSpaceKey,PRInt32> mURIToIDTable;
- nsStringArray mURIArray;
+ nsTArray< nsAutoPtr<nsString> > mURIArray;
};
static NameSpaceManagerImpl* sNameSpaceManager = nsnull;
NS_IMPL_ISUPPORTS1(NameSpaceManagerImpl, nsINameSpaceManager)
nsresult NameSpaceManagerImpl::Init()
{
@@ -172,17 +173,17 @@ NameSpaceManagerImpl::RegisterNameSpace(
if (aURI.IsEmpty()) {
aNameSpaceID = kNameSpaceID_None; // xmlns="", see bug 75700 for details
return NS_OK;
}
nsresult rv = NS_OK;
if (!mURIToIDTable.Get(&aURI, &aNameSpaceID)) {
- aNameSpaceID = mURIArray.Count() + 1; // id is index + 1
+ aNameSpaceID = mURIArray.Length() + 1; // id is index + 1
rv = AddNameSpace(aURI, aNameSpaceID);
if (NS_FAILED(rv)) {
aNameSpaceID = kNameSpaceID_Unknown;
}
}
NS_POSTCONDITION(aNameSpaceID >= -1, "Bogus namespace ID");
@@ -191,23 +192,23 @@ NameSpaceManagerImpl::RegisterNameSpace(
}
nsresult
NameSpaceManagerImpl::GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI)
{
NS_PRECONDITION(aNameSpaceID >= 0, "Bogus namespace ID");
PRInt32 index = aNameSpaceID - 1; // id is index + 1
- if (index < 0 || index >= mURIArray.Count()) {
+ if (index < 0 || index >= PRInt32(mURIArray.Length())) {
aURI.Truncate();
return NS_ERROR_ILLEGAL_VALUE;
}
- mURIArray.StringAt(index, aURI);
+ aURI = *mURIArray.ElementAt(index);
return NS_OK;
}
PRInt32
NameSpaceManagerImpl::GetNameSpaceID(const nsAString& aURI)
{
if (aURI.IsEmpty()) {
@@ -281,26 +282,27 @@ NameSpaceManagerImpl::HasElementCreator(
nsresult NameSpaceManagerImpl::AddNameSpace(const nsAString& aURI,
const PRInt32 aNameSpaceID)
{
if (aNameSpaceID < 0) {
// We've wrapped... Can't do anything else here; just bail.
return NS_ERROR_OUT_OF_MEMORY;
}
- NS_ASSERTION(aNameSpaceID - 1 == mURIArray.Count(),
+ NS_ASSERTION(aNameSpaceID - 1 == mURIArray.Length(),
"BAD! AddNameSpace not called in right order!");
- if (!mURIArray.AppendString(aURI)) {
+ nsString* uri = new nsString(aURI);
+ if (!uri || !mURIArray.AppendElement(uri)) {
+ delete uri;
return NS_ERROR_OUT_OF_MEMORY;
}
- const nsString* uri = mURIArray.StringAt(aNameSpaceID - 1);
if (!mURIToIDTable.Put(uri, aNameSpaceID)) {
- mURIArray.RemoveStringAt(aNameSpaceID - 1);
+ mURIArray.RemoveElementAt(aNameSpaceID - 1);
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
nsresult
--- a/content/base/src/nsStyleLinkElement.cpp
+++ b/content/base/src/nsStyleLinkElement.cpp
@@ -156,47 +156,47 @@ nsStyleLinkElement::OverrideBaseURI(nsIU
/* virtual */ void
nsStyleLinkElement::SetLineNumber(PRUint32 aLineNumber)
{
mLineNumber = aLineNumber;
}
void nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes,
- nsStringArray& aResult)
+ nsTArray<nsString>& aResult)
{
nsAString::const_iterator start, done;
aTypes.BeginReading(start);
aTypes.EndReading(done);
if (start == done)
return;
nsAString::const_iterator current(start);
PRBool inString = !nsCRT::IsAsciiSpace(*current);
nsAutoString subString;
while (current != done) {
if (nsCRT::IsAsciiSpace(*current)) {
if (inString) {
ToLowerCase(Substring(start, current), subString);
- aResult.AppendString(subString);
+ aResult.AppendElement(subString);
inString = PR_FALSE;
}
}
else {
if (!inString) {
start = current;
inString = PR_TRUE;
}
}
++current;
}
if (inString) {
ToLowerCase(Substring(start, current), subString);
- aResult.AppendString(subString);
+ aResult.AppendElement(subString);
}
}
NS_IMETHODIMP
nsStyleLinkElement::UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
PRBool* aWillNotify,
PRBool* aIsAlternate)
{
--- a/content/base/src/nsStyleLinkElement.h
+++ b/content/base/src/nsStyleLinkElement.h
@@ -46,19 +46,19 @@
#ifndef nsStyleLinkElement_h___
#define nsStyleLinkElement_h___
#include "nsCOMPtr.h"
#include "nsIDOMLinkStyle.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsIStyleSheet.h"
#include "nsIURI.h"
+#include "nsTArray.h"
class nsIDocument;
-class nsStringArray;
class nsStyleLinkElement : public nsIDOMLinkStyle,
public nsIStyleSheetLinkingElement
{
public:
nsStyleLinkElement();
virtual ~nsStyleLinkElement();
@@ -75,17 +75,17 @@ public:
PRBool* aWillNotify,
PRBool* aIsAlternate);
NS_IMETHOD SetEnableUpdates(PRBool aEnableUpdates);
NS_IMETHOD GetCharset(nsAString& aCharset);
virtual void OverrideBaseURI(nsIURI* aNewBaseURI);
virtual void SetLineNumber(PRUint32 aLineNumber);
- static void ParseLinkTypes(const nsAString& aTypes, nsStringArray& aResult);
+ static void ParseLinkTypes(const nsAString& aTypes, nsTArray<nsString>& aResult);
protected:
/**
* @param aOldDocument should be non-null only if we're updating because we
* removed the node from the document.
* @param aForceUpdate PR_TRUE will force the update even if the URI has not
* changed. This should be used in cases when something
* about the content that affects the resulting sheet
--- a/content/html/content/public/nsIFormProcessor.h
+++ b/content/html/content/public/nsIFormProcessor.h
@@ -44,19 +44,19 @@
#ifndef nsIFormProcessor_h__
#define nsIFormProcessor_h__
#include "nsISupports.h"
#include "prtypes.h"
#include "nsIDOMHTMLInputElement.h"
+#include "nsTArray.h"
class nsString;
-class nsStringArray;
// {0ae53c0f-8ea2-4916-bedc-717443c3e185}
#define NS_FORMPROCESSOR_CID \
{ 0x0ae53c0f, 0x8ea2, 0x4916, { 0xbe, 0xdc, 0x71, 0x74, 0x43, 0xc3, 0xe1, 0x85 } }
#define NS_FORMPROCESSOR_CONTRACTID "@mozilla.org/layout/form-processor;1"
// 6d4ea1aa-a6b2-43bd-a19d-3f0f26750df3
@@ -98,17 +98,17 @@ public:
*
* @param aFormType Type of form to get content for.
* @param aOptions List of nsStrings which define the contents for the form element
* @param aAttr Attribute to be attached to the form element. It is used to identify
* the form element contains non-standard content.
*/
NS_IMETHOD ProvideContent(const nsAString& aFormType,
- nsStringArray& aContent,
+ nsTArray<nsString>& aContent,
nsAString& aAttribute) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIFormProcessor, NS_IFORMPROCESSOR_IID)
#endif /* nsIFormProcessor_h__ */
--- a/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/content/html/content/src/nsHTMLLinkElement.cpp
@@ -299,19 +299,19 @@ nsHTMLLinkElement::SetAttr(PRInt32 aName
}
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
if (NS_SUCCEEDED(rv)) {
PRBool dropSheet = PR_FALSE;
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::rel &&
mStyleSheet) {
- nsStringArray linkTypes(4);
+ nsAutoTArray<nsString, 4> linkTypes;
nsStyleLinkElement::ParseLinkTypes(aValue, linkTypes);
- dropSheet = linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) < 0;
+ dropSheet = !linkTypes.Contains(NS_LITERAL_STRING("stylesheet"));
}
UpdateStyleSheetInternal(nsnull,
dropSheet ||
(aNameSpaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type)));
@@ -409,31 +409,31 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsA
PRBool* aIsAlternate)
{
aTitle.Truncate();
aType.Truncate();
aMedia.Truncate();
*aIsAlternate = PR_FALSE;
nsAutoString rel;
- nsStringArray linkTypes(4);
+ nsAutoTArray<nsString, 4> linkTypes;
GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel);
nsStyleLinkElement::ParseLinkTypes(rel, linkTypes);
// Is it a stylesheet link?
- if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) < 0) {
+ if (!linkTypes.Contains(NS_LITERAL_STRING("stylesheet"))) {
return;
}
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
aTitle.Assign(title);
// If alternate, does it have title?
- if (-1 != linkTypes.IndexOf(NS_LITERAL_STRING("alternate"))) {
+ if (linkTypes.Contains(NS_LITERAL_STRING("alternate"))) {
if (aTitle.IsEmpty()) { // alternates must have title
return;
} else {
*aIsAlternate = PR_TRUE;
}
}
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
--- a/content/html/content/src/nsHTMLScriptElement.cpp
+++ b/content/html/content/src/nsHTMLScriptElement.cpp
@@ -50,16 +50,17 @@
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIXPConnect.h"
#include "nsServiceManagerUtils.h"
#include "nsIScriptEventHandler.h"
#include "nsIDOMDocument.h"
#include "nsContentErrors.h"
#include "nsIArray.h"
+#include "nsTArray.h"
#include "nsDOMJSUtils.h"
//
// Helper class used to support <SCRIPT FOR=object EVENT=handler ...>
// style script tags...
//
class nsHTMLScriptEventHandler : public nsIScriptEventHandler
{
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -90,16 +90,17 @@
#include "nsIDocShell.h"
#include "nsIDocument.h"
#include "nsStubDocumentObserver.h"
#include "nsIHTMLDocument.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsICookieService.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
#include "nsTextFragment.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIParserService.h"
#include "nsISelectElement.h"
@@ -2927,27 +2928,27 @@ HTMLContentSink::ProcessLINKTag(const ns
mScriptLoader->AddExecuteBlocker();
}
// look for <link rel="next" href="url">
nsAutoString relVal;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
if (!relVal.IsEmpty()) {
// XXX seems overkill to generate this string array
- nsStringArray linkTypes;
+ nsAutoTArray<nsString, 4> linkTypes;
nsStyleLinkElement::ParseLinkTypes(relVal, linkTypes);
- PRBool hasPrefetch = (linkTypes.IndexOf(NS_LITERAL_STRING("prefetch")) != -1);
- if (hasPrefetch || linkTypes.IndexOf(NS_LITERAL_STRING("next")) != -1) {
+ PRBool hasPrefetch = linkTypes.Contains(NS_LITERAL_STRING("prefetch"));
+ if (hasPrefetch || linkTypes.Contains(NS_LITERAL_STRING("next"))) {
nsAutoString hrefVal;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
if (!hrefVal.IsEmpty()) {
PrefetchHref(hrefVal, element, hasPrefetch);
}
}
- if (linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
+ if (linkTypes.Contains(NS_LITERAL_STRING("dns-prefetch"))) {
nsAutoString hrefVal;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
if (!hrefVal.IsEmpty()) {
PrefetchDNS(hrefVal);
}
}
}
}
--- a/content/xslt/src/main/txTestExpr.cpp
+++ b/content/xslt/src/main/txTestExpr.cpp
@@ -34,16 +34,17 @@
* 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 "nsXPCOM.h"
#include "txStandaloneXSLTProcessor.h"
#include "nsString.h"
+#include "nsTArray.h"
#include "txExprParser.h"
#include "txIXPathContext.h"
/**
* A ExprParser test exe
*/
static const char* kTokens[] = {"(", "concat", "(", "foo", ",", "'", "bar",
@@ -111,35 +112,35 @@ int main(int argc, char** argv)
using namespace std;
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
if (!txXSLTProcessor::init())
return 1;
nsAutoString exprOrig, expr;
- nsStringArray exprHead, exprTail;
+ nsTArray<nsString> exprHead, exprTail;
PRUint8 i, dropStart, dropEnd;
- exprHead.AppendString(NS_ConvertASCIItoUTF16(kTokens[0]));
- exprTail.AppendString(NS_ConvertASCIItoUTF16(kTokens[kCount - 1]));
+ exprHead.AppendElement(NS_ConvertASCIItoUTF16(kTokens[0]));
+ exprTail.AppendiElement(NS_ConvertASCIItoUTF16(kTokens[kCount - 1]));
for (i = 2; i < kCount; ++i) {
- exprHead.AppendString(*exprHead[i - 2] +
+ exprHead.AppendElement(exprHead[i - 2] +
NS_ConvertASCIItoUTF16(kTokens[i - 1]));
- exprTail.AppendString(NS_ConvertASCIItoUTF16(kTokens[kCount - i]) +
- *exprTail[i - 2]);
+ exprTail.AppendElement(NS_ConvertASCIItoUTF16(kTokens[kCount - i]) +
+ exprTail[i - 2]);
}
- exprOrig = NS_ConvertASCIItoUTF16(kTokens[0]) + *exprTail[kCount - 2];
+ exprOrig = NS_ConvertASCIItoUTF16(kTokens[0]) + exprTail[kCount - 2];
cout << NS_LossyConvertUTF16toASCII(exprOrig).get() << endl << endl;
for (dropStart = 0; dropStart < kCount - 2; ++dropStart) {
- doTest(*exprTail[kCount - 2 - dropStart]);
+ doTest(exprTail[kCount - 2 - dropStart]);
for (dropEnd = kCount - 3 - dropStart; dropEnd > 0; --dropEnd) {
- expr = *exprHead[dropStart] + *exprTail[dropEnd];
+ expr = exprHead[dropStart] + exprTail[dropEnd];
doTest(expr);
}
- doTest(*exprHead[dropStart]);
+ doTest(exprHead[dropStart]);
}
- doTest(*exprHead[kCount - 2]);
+ doTest(exprHead[kCount - 2]);
txXSLTProcessor::shutdown();
rv = NS_ShutdownXPCOM(nsnull);
NS_ENSURE_SUCCESS(rv, rv);
return 0;
}
--- a/content/xslt/src/xml/txDOM.h
+++ b/content/xslt/src/xml/txDOM.h
@@ -53,16 +53,17 @@
#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;
@@ -417,17 +418,17 @@ public:
}
static MBool init()
{
NS_ASSERTION(!mNamespaces,
"called without matching shutdown()");
if (mNamespaces)
return MB_TRUE;
- mNamespaces = new nsStringArray();
+ mNamespaces = new nsTArray<nsString>();
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
*/
@@ -447,15 +448,15 @@ public:
NS_ASSERTION(mNamespaces, "called without matching init()");
if (!mNamespaces)
return;
delete mNamespaces;
mNamespaces = nsnull;
}
private:
- static nsStringArray* mNamespaces;
+ static nsTArray<nsString>* mNamespaces;
};
#define TX_IMPL_DOM_STATICS \
- nsStringArray* txStandaloneNamespaceManager::mNamespaces = 0
+ nsTArray<nsString>* txStandaloneNamespaceManager::mNamespaces = 0
#endif
--- a/content/xslt/src/xml/txNodeDefinition.cpp
+++ b/content/xslt/src/xml/txNodeDefinition.cpp
@@ -42,16 +42,17 @@
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "txDOM.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "txURIUtils.h"
#include "txAtoms.h"
#include <string.h>
NodeDefinition::NodeDefinition(NodeType type, nsIAtom *aLocalName,
const nsAString& value, Document* owner) :
mLocalName(aLocalName),
nodeValue(value),
@@ -220,41 +221,41 @@ Node* NodeDefinition::getXPathParent()
// Returns the base URI of the node. Acccounts for xml:base
// attributes.
//
// @return base URI for the node
//
nsresult NodeDefinition::getBaseURI(nsAString& aURI)
{
Node* node = this;
- nsStringArray baseUrls;
+ nsTArray<nsString> baseUrls;
nsAutoString url;
while (node) {
switch (node->getNodeType()) {
case Node::ELEMENT_NODE :
if (((Element*)node)->getAttr(txXMLAtoms::base, kNameSpaceID_XML,
url))
- baseUrls.AppendString(url);
+ baseUrls.AppendElement(url);
break;
case Node::DOCUMENT_NODE :
node->getBaseURI(url);
- baseUrls.AppendString(url);
+ baseUrls.AppendElement(url);
break;
default:
break;
}
node = node->getXPathParent();
}
- PRInt32 count = baseUrls.Count();
+ PRUint32 count = baseUrls.Length();
if (count) {
- baseUrls.StringAt(--count, aURI);
+ aURI = baseUrls[--count];
while (count > 0) {
nsAutoString dest;
URIUtils::resolveHref(*baseUrls[--count], aURI, dest);
aURI = dest;
}
}
--- a/content/xslt/src/xpath/nsXPathEvaluator.cpp
+++ b/content/xslt/src/xpath/nsXPathEvaluator.cpp
@@ -165,40 +165,40 @@ nsXPathEvaluator::SetDocument(nsIDOMDocu
{
mDocument = do_GetWeakReference(aDocument);
return NS_OK;
}
NS_IMETHODIMP
nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
nsIDOMXPathNSResolver *aResolver,
- nsStringArray *aNamespaceURIs,
+ nsTArray<nsString> *aNamespaceURIs,
nsCStringArray *aContractIDs,
nsCOMArray<nsISupports> *aState,
nsIDOMXPathExpression **aResult)
{
nsTArray<PRInt32> namespaceIDs;
if (aNamespaceURIs) {
- PRInt32 count = aNamespaceURIs->Count();
+ PRUint32 count = aNamespaceURIs->Length();
if (!aContractIDs || aContractIDs->Count() != count) {
return NS_ERROR_FAILURE;
}
if (!namespaceIDs.SetLength(count)) {
return NS_ERROR_OUT_OF_MEMORY;
}
- PRInt32 i;
+ PRUint32 i;
for (i = 0; i < count; ++i) {
if (aContractIDs->CStringAt(i)->IsEmpty()) {
return NS_ERROR_FAILURE;
}
- nsContentUtils::NameSpaceManager()->RegisterNameSpace(*aNamespaceURIs->StringAt(i), namespaceIDs[i]);
+ nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURIs->ElementAt(i), namespaceIDs[i]);
}
}
return CreateExpression(aExpression, aResolver, &namespaceIDs, aContractIDs,
aState, aResult);
}
--- a/content/xslt/src/xpath/nsXPathEvaluator.h
+++ b/content/xslt/src/xpath/nsXPathEvaluator.h
@@ -64,17 +64,17 @@ public:
// nsIDOMXPathEvaluator interface
NS_DECL_NSIDOMXPATHEVALUATOR
// nsIXPathEvaluatorInternal interface
NS_IMETHOD SetDocument(nsIDOMDocument* aDocument);
NS_IMETHOD CreateExpression(const nsAString &aExpression,
nsIDOMXPathNSResolver *aResolver,
- nsStringArray *aNamespaceURIs,
+ nsTArray<nsString> *aNamespaceURIs,
nsCStringArray *aContractIDs,
nsCOMArray<nsISupports> *aState,
nsIDOMXPathExpression **aResult);
private:
nsresult CreateExpression(const nsAString & aExpression,
nsIDOMXPathNSResolver *aResolver,
nsTArray<PRInt32> *aNamespaceIDs,
--- a/content/xul/templates/src/nsTemplateRule.cpp
+++ b/content/xul/templates/src/nsTemplateRule.cpp
@@ -71,26 +71,26 @@ nsTemplateCondition::nsTemplateCondition
mNext(nsnull)
{
SetRelation(aRelation);
if (aIsMultiple) {
PRInt32 start = 0, end = 0;
while ((end = aTargets.FindChar(',',start)) >= 0) {
if (end > start) {
- mTargetList.AppendString(Substring(aTargets, start, end - start));
+ mTargetList.AppendElement(Substring(aTargets, start, end - start));
}
start = end + 1;
}
- if (start < (PRInt32)aTargets.Length()) {
- mTargetList.AppendString(Substring(aTargets, start));
+ if (start < PRInt32(aTargets.Length())) {
+ mTargetList.AppendElement(Substring(aTargets, start));
}
}
else {
- mTargetList.AppendString(aTargets);
+ mTargetList.AppendElement(aTargets);
}
MOZ_COUNT_CTOR(nsTemplateCondition);
}
nsTemplateCondition::nsTemplateCondition(const nsAString& aSource,
const nsAString& aRelation,
nsIAtom* aTargetVariable,
@@ -145,19 +145,19 @@ nsTemplateCondition::CheckMatch(nsIXULTe
nsAutoString rightString;
aResult->GetBindingFor(mTargetVariable, rightString);
match = CheckMatchStrings(leftString, rightString);
}
else {
// iterate over the strings in the target and determine
// whether there is a match.
- PRInt32 length = mTargetList.Count();
- for (PRInt32 t = 0; t < length; t++) {
- match = CheckMatchStrings(leftString, *mTargetList[t]);
+ PRUint32 length = mTargetList.Length();
+ for (PRUint32 t = 0; t < length; t++) {
+ match = CheckMatchStrings(leftString, mTargetList[t]);
// stop once a match is found. In negate mode, stop once a
// target does not match.
if (match != mNegate) break;
}
}
return match;
--- a/content/xul/templates/src/nsTemplateRule.h
+++ b/content/xul/templates/src/nsTemplateRule.h
@@ -41,16 +41,17 @@
#include "nsCOMPtr.h"
#include "nsIAtom.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFResource.h"
#include "nsIContent.h"
#include "nsIDOMNode.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsString.h"
#include "nsIXULTemplateRuleFilter.h"
#include "nsCycleCollectionParticipant.h"
class nsIXULTemplateQueryProcessor;
class nsTemplateQuerySet;
class nsTemplateCondition
@@ -108,17 +109,17 @@ public:
CheckMatchStrings(const nsAString& aLeftString,
const nsAString& aRightString);
protected:
nsCOMPtr<nsIAtom> mSourceVariable;
nsString mSource;
ConditionRelation mRelation;
nsCOMPtr<nsIAtom> mTargetVariable;
- nsStringArray mTargetList;
+ nsTArray<nsString> mTargetList;
PRPackedBool mIgnoreCase;
PRPackedBool mNegate;
nsTemplateCondition* mNext;
};
/**
* A rule consists of:
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -265,17 +265,17 @@ nsDOMStorageManager::Shutdown()
static PLDHashOperator
ClearStorage(nsDOMStorageEntry* aEntry, void* userArg)
{
aEntry->mStorage->ClearAll();
return PL_DHASH_REMOVE;
}
static nsresult
-GetOfflineDomains(nsStringArray& aDomains)
+GetOfflineDomains(nsTArray<nsString>& aDomains)
{
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
if (permissionManager) {
nsCOMPtr<nsISimpleEnumerator> enumerator;
nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(rv, rv);
@@ -293,17 +293,17 @@ GetOfflineDomains(nsStringArray& aDomain
rv = perm->GetType(type);
NS_ENSURE_SUCCESS(rv, rv);
if (type.EqualsLiteral("offline-app")) {
nsCAutoString host;
rv = perm->GetHost(host);
NS_ENSURE_SUCCESS(rv, rv);
- aDomains.AppendString(NS_ConvertUTF8toUTF16(host));
+ aDomains.AppendElement(NS_ConvertUTF8toUTF16(host));
}
}
}
}
return NS_OK;
}
@@ -322,17 +322,17 @@ nsDOMStorageManager::Observe(nsISupports
!nsCRT::strcmp(aData, NS_LITERAL_STRING("cleared").get())) {
mStorages.EnumerateEntries(ClearStorage, nsnull);
#ifdef MOZ_STORAGE
nsresult rv = nsDOMStorage::InitDB();
NS_ENSURE_SUCCESS(rv, rv);
// Remove global storage for domains that aren't marked for offline use.
- nsStringArray domains;
+ nsTArray<nsString> domains;
rv = GetOfflineDomains(domains);
NS_ENSURE_SUCCESS(rv, rv);
return nsDOMStorage::gStorageDB->RemoveOwners(domains, PR_FALSE);
#endif
}
return NS_OK;
}
@@ -348,17 +348,17 @@ nsDOMStorageManager::GetUsage(const nsAS
}
NS_IMETHODIMP
nsDOMStorageManager::ClearOfflineApps()
{
nsresult rv = nsDOMStorage::InitDB();
NS_ENSURE_SUCCESS(rv, rv);
- nsStringArray domains;
+ nsTArray<nsString> domains;
rv = GetOfflineDomains(domains);
NS_ENSURE_SUCCESS(rv, rv);
return nsDOMStorage::gStorageDB->RemoveOwners(domains, PR_TRUE);
}
void
nsDOMStorageManager::AddToStoragesHash(nsDOMStorage* aStorage)
{
@@ -1210,33 +1210,33 @@ nsDOMStorageList::CanAccessDomain(const
}
nsIDOMStorage*
nsDOMStorageList::GetStorageForDomain(const nsAString& aRequestedDomain,
const nsAString& aCurrentDomain,
PRBool aNoCurrentDomainCheck,
nsresult* aResult)
{
- nsStringArray requestedDomainArray;
+ nsTArray<nsString> requestedDomainArray;
if ((!aNoCurrentDomainCheck &&
!CanAccessDomain(aRequestedDomain, aCurrentDomain)) ||
- !ConvertDomainToArray(aRequestedDomain, &requestedDomainArray)) {
+ !ConvertDomainToArray(aRequestedDomain, &requestedDomainArray)) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
// now rebuild a string for the domain.
nsAutoString usedDomain;
- PRInt32 requestedPos = 0;
- for (requestedPos = 0; requestedPos < requestedDomainArray.Count();
+ PRUint32 requestedPos = 0;
+ for (requestedPos = 0; requestedPos < requestedDomainArray.Length();
requestedPos++) {
if (!usedDomain.IsEmpty())
usedDomain.AppendLiteral(".");
- usedDomain.Append(*requestedDomainArray[requestedPos]);
+ usedDomain.Append(requestedDomainArray[requestedPos]);
}
*aResult = NS_OK;
// now have a valid domain, so look it up in the storage table
nsIDOMStorage* storage = mStorages.GetWeak(usedDomain);
if (!storage) {
nsCOMPtr<nsIDOMStorage> newstorage = new nsDOMStorage(usedDomain, PR_TRUE);
@@ -1247,33 +1247,33 @@ nsDOMStorageList::GetStorageForDomain(co
}
return storage;
}
// static
PRBool
nsDOMStorageList::ConvertDomainToArray(const nsAString& aDomain,
- nsStringArray* aArray)
+ nsTArray<nsString> *aArray)
{
PRInt32 length = aDomain.Length();
PRInt32 n = 0;
while (n < length) {
PRInt32 dotpos = aDomain.FindChar('.', n);
nsAutoString domain;
if (dotpos == -1) // no more dots
domain.Assign(Substring(aDomain, n));
else if (dotpos - n == 0) // no point continuing in this case
return false;
else if (dotpos >= 0)
domain.Assign(Substring(aDomain, n, dotpos - n));
ToLowerCase(domain);
- aArray->AppendString(domain);
+ aArray->AppendElement(domain);
if (dotpos == -1)
break;
n = dotpos + 1;
}
// if n equals the length, there is a dot at the end, so treat it as invalid
--- a/dom/src/storage/nsDOMStorage.h
+++ b/dom/src/storage/nsDOMStorage.h
@@ -42,16 +42,17 @@
#include "nscore.h"
#include "nsAutoPtr.h"
#include "nsIDOMStorage.h"
#include "nsIDOMStorageList.h"
#include "nsIDOMStorageItem.h"
#include "nsInterfaceHashtable.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsPIDOMStorage.h"
#include "nsIDOMToString.h"
#include "nsDOMEvent.h"
#include "nsIDOMStorageEvent.h"
#include "nsIDOMStorageManager.h"
#include "nsCycleCollectionParticipant.h"
#ifdef MOZ_STORAGE
@@ -258,17 +259,17 @@ protected:
PRBool aNoCurrentDomainCheck,
nsresult* aResult);
/**
* Convert the domain into an array of its component parts.
*/
static PRBool
ConvertDomainToArray(const nsAString& aDomain,
- nsStringArray* aArray);
+ nsTArray<nsString>* aArray);
nsInterfaceHashtable<nsStringHashKey, nsIDOMStorage> mStorages;
};
class nsDOMStorageItem : public nsIDOMStorageItem,
public nsIDOMToString
{
public:
--- a/dom/src/storage/nsDOMStorageDB.cpp
+++ b/dom/src/storage/nsDOMStorageDB.cpp
@@ -435,19 +435,19 @@ nsDOMStorageDB::RemoveOwner(const nsAStr
nsresult rv = mRemoveOwnerStatement->BindStringParameter(0, aOwner);
NS_ENSURE_SUCCESS(rv, rv);
return mRemoveOwnerStatement->Execute();
}
nsresult
-nsDOMStorageDB::RemoveOwners(const nsStringArray &aOwners, PRBool aMatch)
+nsDOMStorageDB::RemoveOwners(const nsTArray<nsString> &aOwners, PRBool aMatch)
{
- if (aOwners.Count() == 0) {
+ if (aOwners.Length() == 0) {
if (aMatch) {
return NS_OK;
}
return RemoveAll();
}
nsCAutoString expression;
@@ -455,29 +455,29 @@ nsDOMStorageDB::RemoveOwners(const nsStr
if (aMatch) {
expression.Assign(NS_LITERAL_CSTRING("DELETE FROM webappsstore "
"WHERE owner IN (?"));
} else {
expression.Assign(NS_LITERAL_CSTRING("DELETE FROM webappsstore "
"WHERE owner NOT IN (?"));
}
- for (PRInt32 i = 1; i < aOwners.Count(); i++) {
+ for (PRUint32 i = 1; i < aOwners.Length(); i++) {
expression.Append(", ?");
}
expression.Append(")");
nsCOMPtr<mozIStorageStatement> statement;
nsresult rv = mConnection->CreateStatement(expression,
getter_AddRefs(statement));
NS_ENSURE_SUCCESS(rv, rv);
- for (PRInt32 i = 0; i < aOwners.Count(); i++) {
- rv = statement->BindStringParameter(i, *aOwners[i]);
+ for (PRUint32 i = 0; i < aOwners.Length(); i++) {
+ rv = statement->BindStringParameter(i, aOwners[i]);
NS_ENSURE_SUCCESS(rv, rv);
}
return statement->Execute();
}
nsresult
nsDOMStorageDB::RemoveAll()
--- a/dom/src/storage/nsDOMStorageDB.h
+++ b/dom/src/storage/nsDOMStorageDB.h
@@ -112,17 +112,17 @@ public:
nsresult
RemoveOwner(const nsAString& aOwner);
/**
* Removes keys owned by domains that either match or don't match the
* list.
*/
nsresult
- RemoveOwners(const nsStringArray& aOwners, PRBool aMatch);
+ RemoveOwners(const nsTArray<nsString>& aOwners, PRBool aMatch);
/**
* Removes all keys from storage. Used when clearing storage.
*/
nsresult
RemoveAll();
nsresult GetUsage(const nsAString &aOwner, PRInt32 *aUsage);
--- a/editor/composer/src/nsEditorParserObserver.cpp
+++ b/editor/composer/src/nsEditorParserObserver.cpp
@@ -84,18 +84,18 @@ NS_IMETHODIMP nsEditorParserObserver::No
return NS_OK;
}
else
return NS_ERROR_ILLEGAL_VALUE;
}
NS_IMETHODIMP nsEditorParserObserver::Notify(nsISupports* aWebShell,
nsISupports* aChannel,
const PRUnichar* aTag,
- const nsStringArray* aKeys,
- const nsStringArray* aValues,
+ const nsTArray<nsString>* aKeys,
+ const nsTArray<nsString>* aValues,
const PRUint32 aFlags)
{
Notify();
return NS_OK;
}
NS_IMETHODIMP nsEditorParserObserver::Observe(nsISupports*, const char*, const PRUnichar*)
{
--- a/editor/composer/src/nsEditorParserObserver.h
+++ b/editor/composer/src/nsEditorParserObserver.h
@@ -57,18 +57,18 @@ public:
/* method for nsIElementObserver */
NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag, PRUint32 numOfAttributes,
const PRUnichar* nameArray[], const PRUnichar* valueArray[]);
NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag, PRUint32 numOfAttributes,
const PRUnichar* nameArray[], const PRUnichar* valueArray[]);
NS_IMETHOD Notify(nsISupports* aWebShell,
nsISupports* aChannel,
const PRUnichar* aTag,
- const nsStringArray* aKeys,
- const nsStringArray* aValues,
+ const nsTArray<nsString>* aKeys,
+ const nsTArray<nsString>* aValues,
const PRUint32 aFlags);
/* methods for nsIObserver */
NS_DECL_NSIOBSERVER
/* begin and end observing */
NS_IMETHOD Start(eHTMLTags* aWatchTags);
NS_IMETHOD End();
--- a/editor/composer/src/nsEditorSpellCheck.cpp
+++ b/editor/composer/src/nsEditorSpellCheck.cpp
@@ -86,21 +86,21 @@ nsEditorSpellCheck::CanSpellCheck(PRBool
nsresult rv;
nsCOMPtr<nsISpellChecker> spellChecker;
if (! mSpellChecker) {
spellChecker = do_CreateInstance(NS_SPELLCHECKER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
} else {
spellChecker = mSpellChecker;
}
- nsStringArray dictList;
+ nsTArray<nsString> dictList;
rv = spellChecker->GetDictionaryList(&dictList);
NS_ENSURE_SUCCESS(rv, rv);
- *_retval = (dictList.Count() > 0);
+ *_retval = (dictList.Length() > 0);
return NS_OK;
}
NS_IMETHODIMP
nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, PRBool aEnableSelectionChecking)
{
nsresult rv;
@@ -213,21 +213,21 @@ nsEditorSpellCheck::InitSpellChecker(nsI
if (NS_SUCCEEDED(rv))
setDictionary = PR_TRUE;
}
// If there was no dictionary specified by spellchecker.dictionary and setting it to the
// locale dictionary didn't work, try to use the first dictionary we find. This helps when
// the first dictionary is installed
if (! setDictionary) {
- nsStringArray dictList;
+ nsTArray<nsString> dictList;
rv = mSpellChecker->GetDictionaryList(&dictList);
NS_ENSURE_SUCCESS(rv, rv);
- if (dictList.Count() > 0) {
- rv = SetCurrentDictionary(dictList[0]->get());
+ if (dictList.Length() > 0) {
+ rv = SetCurrentDictionary(dictList[0].get());
if (NS_SUCCEEDED(rv))
SaveDefaultDictionary();
}
}
// If an error was thrown while checking the dictionary pref, just
// fail silently so that the spellchecker dialog is allowed to come
// up. The user can manually reset the language to their choice on
@@ -255,26 +255,24 @@ nsEditorSpellCheck::GetNextMisspelledWor
*aNextMisspelledWord = ToNewUnicode(nextMisspelledWord);
return rv;
}
NS_IMETHODIMP
nsEditorSpellCheck::GetSuggestedWord(PRUnichar **aSuggestedWord)
{
nsAutoString word;
- if ( mSuggestedWordIndex < mSuggestedWordList.Count())
+ if ( mSuggestedWordIndex < PRInt32(mSuggestedWordList.Length()))
{
- mSuggestedWordList.StringAt(mSuggestedWordIndex, word);
+ *aSuggestedWord = ToNewUnicode(mSuggestedWordList[mSuggestedWordIndex]);
mSuggestedWordIndex++;
} else {
// A blank string signals that there are no more strings
- word.Truncate();
+ *aSuggestedWord = ToNewUnicode(EmptyString());
}
-
- *aSuggestedWord = ToNewUnicode(word);
return NS_OK;
}
NS_IMETHODIMP
nsEditorSpellCheck::CheckCurrentWord(const PRUnichar *aSuggestedWord,
PRBool *aIsMisspelled)
{
if (!mSpellChecker)
@@ -327,27 +325,25 @@ nsEditorSpellCheck::GetPersonalDictionar
mDictionaryList.Clear();
mDictionaryIndex = 0;
return mSpellChecker->GetPersonalDictionary(&mDictionaryList);
}
NS_IMETHODIMP
nsEditorSpellCheck::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord)
{
- nsAutoString word;
- if ( mDictionaryIndex < mDictionaryList.Count())
+ if ( mDictionaryIndex < PRInt32( mDictionaryList.Length()))
{
- mDictionaryList.StringAt(mDictionaryIndex, word);
+ *aDictionaryWord = ToNewUnicode(mDictionaryList[mDictionaryIndex]);
mDictionaryIndex++;
} else {
// A blank string signals that there are no more strings
- word.Truncate();
+ *aDictionaryWord = ToNewUnicode(EmptyString());
}
- *aDictionaryWord = ToNewUnicode(word);
return NS_OK;
}
NS_IMETHODIMP
nsEditorSpellCheck::AddWordToDictionary(const PRUnichar *aWord)
{
if (!mSpellChecker)
return NS_ERROR_NOT_INITIALIZED;
@@ -371,58 +367,55 @@ nsEditorSpellCheck::GetDictionaryList(PR
return NS_ERROR_NOT_INITIALIZED;
if (!aDictionaryList || !aCount)
return NS_ERROR_NULL_POINTER;
*aDictionaryList = 0;
*aCount = 0;
- nsStringArray dictList;
+ nsTArray<nsString> dictList;
nsresult rv = mSpellChecker->GetDictionaryList(&dictList);
if (NS_FAILED(rv))
return rv;
PRUnichar **tmpPtr = 0;
- if (dictList.Count() < 1)
+ if (dictList.Length() < 1)
{
// If there are no dictionaries, return an array containing
// one element and a count of one.
tmpPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *));
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
*tmpPtr = 0;
*aDictionaryList = tmpPtr;
*aCount = 0;
return NS_OK;
}
- tmpPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * dictList.Count());
+ tmpPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * dictList.Length());
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
*aDictionaryList = tmpPtr;
- *aCount = dictList.Count();
-
- nsAutoString dictStr;
+ *aCount = dictList.Length();
PRUint32 i;
for (i = 0; i < *aCount; i++)
{
- dictList.StringAt(i, dictStr);
- tmpPtr[i] = ToNewUnicode(dictStr);
+ tmpPtr[i] = ToNewUnicode(dictList[i]);
}
return rv;
}
NS_IMETHODIMP
nsEditorSpellCheck::GetCurrentDictionary(PRUnichar **aDictionary)
{
--- a/editor/composer/src/nsEditorSpellCheck.h
+++ b/editor/composer/src/nsEditorSpellCheck.h
@@ -61,22 +61,22 @@ public:
NS_DECL_ISUPPORTS
/* Declare all methods in the nsIEditorSpellCheck interface */
NS_DECL_NSIEDITORSPELLCHECK
protected:
nsCOMPtr<nsISpellChecker> mSpellChecker;
- nsStringArray mSuggestedWordList;
+ nsTArray<nsString> mSuggestedWordList;
PRInt32 mSuggestedWordIndex;
// these are the words in the current personal dictionary,
// GetPersonalDictionary must be called to load them.
- nsStringArray mDictionaryList;
+ nsTArray<nsString> mDictionaryList;
PRInt32 mDictionaryIndex;
nsresult DeleteSuggestedWordList();
nsCOMPtr<nsITextServicesFilter> mTxtSrvFilter;
};
#endif // nsEditorSpellCheck_h___
--- a/editor/libeditor/html/nsHTMLCSSUtils.cpp
+++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp
@@ -846,17 +846,17 @@ nsHTMLCSSUtils::GetCSSPropertyAtom(nsCSS
}
}
}
// Populate aProperty and aValueArray with the CSS declarations equivalent to the
// value aValue according to the equivalence table aEquivTable
void
nsHTMLCSSUtils::BuildCSSDeclarations(nsVoidArray & aPropertyArray,
- nsStringArray & aValueArray,
+ nsTArray<nsString> & aValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest)
{
// clear arrays
aPropertyArray.Clear();
aValueArray.Clear();
@@ -878,32 +878,32 @@ nsHTMLCSSUtils::BuildCSSDeclarations(nsV
// the equivalence table
(*aEquivTable[index].processValueFunctor) ((!aGetOrRemoveRequest || aEquivTable[index].caseSensitiveValue) ? &value : &lowerCasedValue,
cssValue,
aEquivTable[index].defaultValue,
aEquivTable[index].prependValue,
aEquivTable[index].appendValue);
GetCSSPropertyAtom(cssProperty, &cssPropertyAtom);
aPropertyArray.AppendElement(cssPropertyAtom);
- aValueArray.AppendString(cssValue);
+ aValueArray.AppendElement(cssValue);
}
index++;
cssProperty = aEquivTable[index].cssProperty;
}
}
// Populate cssPropertyArray and cssValueArray with the declarations equivalent
// to aHTMLProperty/aAttribute/aValue for the node aNode
void
nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom *aHTMLProperty,
const nsAString * aAttribute,
const nsAString * aValue,
nsVoidArray & cssPropertyArray,
- nsStringArray & cssValueArray,
+ nsTArray<nsString> & cssValueArray,
PRBool aGetOrRemoveRequest)
{
nsCOMPtr<nsIDOMNode> node = aNode;
if (mHTMLEditor->IsTextNode(aNode)) {
aNode->GetParentNode(getter_AddRefs(node));
}
if (!node) return;
@@ -996,29 +996,27 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLSt
nsresult res = NS_OK;
*aCount = 0;
if (theElement && IsCSSEditableProperty(aNode, aHTMLProperty, aAttribute)) {
// we can apply the styles only if the node is an element and if we have
// an equivalence for the requested HTML style in this implementation
// Find the CSS equivalence to the HTML style
nsVoidArray cssPropertyArray;
- nsStringArray cssValueArray;
+ nsTArray<nsString> cssValueArray;
GenerateCSSDeclarationsFromHTMLStyle(aNode, aHTMLProperty, aAttribute, aValue,
cssPropertyArray, cssValueArray, PR_FALSE);
// set the individual CSS inline styles
*aCount = cssPropertyArray.Count();
PRInt32 index;
for (index = 0; index < *aCount; index++) {
- nsAutoString valueString;
- cssValueArray.StringAt(index, valueString);
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
res = SetCSSProperty(theElement, (nsIAtom *)cssPropertyArray.ElementAt(index),
- valueString, aSuppressTransaction);
+ cssValueArray[index], aSuppressTransaction);
if (NS_FAILED(res)) return res;
}
}
return NS_OK;
}
// Remove from aNode the CSS inline style equivalent to HTMLProperty/aAttribute/aValue for the node
nsresult
@@ -1032,28 +1030,28 @@ nsHTMLCSSUtils::RemoveCSSEquivalentToHTM
nsresult res = NS_OK;
PRInt32 count = 0;
if (theElement && IsCSSEditableProperty(aNode, aHTMLProperty, aAttribute)) {
// we can apply the styles only if the node is an element and if we have
// an equivalence for the requested HTML style in this implementation
// Find the CSS equivalence to the HTML style
nsVoidArray cssPropertyArray;
- nsStringArray cssValueArray;
+ nsTArray<nsString> cssValueArray;
GenerateCSSDeclarationsFromHTMLStyle(aNode, aHTMLProperty, aAttribute, aValue,
cssPropertyArray, cssValueArray, PR_TRUE);
// remove the individual CSS inline styles
count = cssPropertyArray.Count();
PRInt32 index;
for (index = 0; index < count; index++) {
- nsAutoString valueString;
- cssValueArray.StringAt(index, valueString);
- res = RemoveCSSProperty(theElement, (nsIAtom *)cssPropertyArray.ElementAt(index), valueString,
- aSuppressTransaction);
+ res = RemoveCSSProperty(theElement,
+ (nsIAtom *)cssPropertyArray.ElementAt(index),
+ cssValueArray[index],
+ aSuppressTransaction);
if (NS_FAILED(res)) return res;
}
}
return NS_OK;
}
// aReturn is true if the element aElement carries an ID or a class.
nsresult
@@ -1095,17 +1093,17 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLIn
// Yes, the requested HTML style has a CSS equivalence in this implementation
// Retrieve the default ViewCSS if we are asked for computed styles
nsCOMPtr<nsIDOMViewCSS> viewCSS = nsnull;
if (COMPUTED_STYLE_TYPE == aStyleType) {
res = GetDefaultViewCSS(theElement, getter_AddRefs(viewCSS));
if (NS_FAILED(res)) return res;
}
nsVoidArray cssPropertyArray;
- nsStringArray cssValueArray;
+ nsTArray<nsString> cssValueArray;
// get the CSS equivalence with last param PR_TRUE indicating we want only the
// "gettable" properties
GenerateCSSDeclarationsFromHTMLStyle(theElement, aHTMLProperty, aAttribute, nsnull,
cssPropertyArray, cssValueArray, PR_TRUE);
PRInt32 count = cssPropertyArray.Count();
PRInt32 index;
for (index = 0; index < count; index++) {
nsAutoString valueString;
--- a/editor/libeditor/html/nsHTMLCSSUtils.h
+++ b/editor/libeditor/html/nsHTMLCSSUtils.h
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLCSSUtils_h__
#define nsHTMLCSSUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
+#include "nsTArray.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
@@ -336,17 +337,17 @@ private:
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
- nsStringArray & cssValueArray,
+ nsTArray<nsString> & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
@@ -359,17 +360,17 @@ private:
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
- nsStringArray & aValueArray,
+ nsTArray<nsString> & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -209,24 +209,19 @@ nsHTMLEditor::~nsHTMLEditor()
NS_IF_RELEASE(mTypeInState);
mSelectionListenerP = nsnull;
delete mHTMLCSSUtils;
// free any default style propItems
RemoveAllDefaultProperties();
- while (mStyleSheetURLs.Count())
+ while (mStyleSheetURLs.Length())
{
- nsAString* strp = mStyleSheetURLs.StringAt(0);
-
- if (strp)
- {
- RemoveOverrideStyleSheet(*strp);
- }
+ RemoveOverrideStyleSheet(mStyleSheetURLs[0]);
}
if (mLinkHandler && mPresShellWeak)
{
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (ps && ps->GetPresContext())
{
@@ -2179,20 +2174,18 @@ nsHTMLEditor::SetParagraphFormat(const n
return MakeDefinitionItem(tag);
else
return InsertBasicBlock(tag);
}
// XXX: ERROR_HANDLING -- this method needs a little work to ensure all error codes are
// checked properly, all null pointers are checked, and no memory leaks occur
NS_IMETHODIMP
-nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
+nsHTMLEditor::GetParentBlockTags(nsTArray<nsString> *aTagList, PRBool aGetLists)
{
- if (!aTagList) { return NS_ERROR_NULL_POINTER; }
-
nsresult res;
nsCOMPtr<nsISelection>selection;
res = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
// Find out if the selection is collapsed:
@@ -2222,17 +2215,17 @@ nsHTMLEditor::GetParentBlockTags(nsStrin
if (isBlock) blockParent = node;
else blockParent = GetBlockNodeParent(node);
blockParentElem = do_QueryInterface(blockParent);
}
if (blockParentElem)
{
nsAutoString blockParentTag;
blockParentElem->GetTagName(blockParentTag);
- aTagList->AppendString(blockParentTag);
+ aTagList->AppendElement(blockParentTag);
}
return res;
}
// else non-collapsed selection
nsCOMPtr<nsIEnumerator> enumerator;
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
@@ -2271,18 +2264,18 @@ nsHTMLEditor::GetParentBlockTags(nsStrin
blockParent = do_QueryInterface(GetBlockNodeParent(startParent));
}
if (NS_SUCCEEDED(res) && blockParent)
{
nsAutoString blockParentTag;
blockParent->GetTagName(blockParentTag);
PRBool isRoot;
IsRootTag(blockParentTag, isRoot);
- if ((!isRoot) && (-1==aTagList->IndexOf(blockParentTag))) {
- aTagList->AppendString(blockParentTag);
+ if ((!isRoot) && !aTagList->Contains(blockParentTag)) {
+ aTagList->AppendElement(blockParentTag);
}
}
}
if (NS_FAILED(res))
return res;
blockSections.RemoveObject(0);
if (blockSections.Count() == 0)
break;
@@ -3714,22 +3707,22 @@ nsHTMLEditor::EnableExistingStyleSheet(c
return PR_FALSE;
}
nsresult
nsHTMLEditor::AddNewStyleSheetToList(const nsAString &aURL,
nsICSSStyleSheet *aStyleSheet)
{
PRInt32 countSS = mStyleSheets.Count();
- PRInt32 countU = mStyleSheetURLs.Count();
+ PRUint32 countU = mStyleSheetURLs.Length();
if (countU < 0 || countSS != countU)
return NS_ERROR_UNEXPECTED;
- if (!mStyleSheetURLs.AppendString(aURL))
+ if (!mStyleSheetURLs.AppendElement(aURL))
return NS_ERROR_UNEXPECTED;
return mStyleSheets.AppendObject(aStyleSheet) ? NS_OK : NS_ERROR_UNEXPECTED;
}
nsresult
nsHTMLEditor::RemoveStyleSheetFromList(const nsAString &aURL)
{
@@ -3738,18 +3731,17 @@ nsHTMLEditor::RemoveStyleSheetFromList(c
foundIndex = mStyleSheetURLs.IndexOf(aURL);
if (foundIndex < 0)
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;
- if (!mStyleSheetURLs.RemoveStringAt(foundIndex))
- rv = NS_ERROR_FAILURE;
+ mStyleSheetURLs.RemoveElementAt(foundIndex);
return rv;
}
NS_IMETHODIMP
nsHTMLEditor::GetStyleSheetForURL(const nsAString &aURL,
nsICSSStyleSheet **aStyleSheet)
{
@@ -3778,20 +3770,17 @@ nsHTMLEditor::GetURLForStyleSheet(nsICSS
// is it already in the list?
PRInt32 foundIndex = mStyleSheets.IndexOf(aStyleSheet);
// Don't fail if we don't find it in our list
if (foundIndex == -1)
return NS_OK;
// Found it in the list!
- nsAString* strp = mStyleSheetURLs.StringAt(foundIndex);
- if (!strp)
- return NS_ERROR_UNEXPECTED;
- aURL = *strp;
+ aURL = mStyleSheetURLs[foundIndex];
return NS_OK;
}
nsresult
nsHTMLEditor::GetCSSLoader(const nsAString& aURL, nsICSSLoader** aCSSLoader)
{
if (!aCSSLoader)
return NS_ERROR_NULL_POINTER;
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -58,16 +58,17 @@
#include "nsITableLayout.h"
#include "nsEditRules.h"
#include "nsEditProperty.h"
#include "nsHTMLCSSUtils.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsHTMLObjectResizer.h"
#include "nsIHTMLAbsPosEditor.h"
#include "nsIHTMLInlineTableEditor.h"
#include "nsIHTMLObjectResizeListener.h"
#include "nsIDocumentObserver.h"
@@ -166,17 +167,17 @@ public:
NS_DECL_NSIHTMLINLINETABLEEDITOR
/* ------------ nsIHTMLEditor methods -------------- */
NS_IMETHOD CopyLastEditableChildStyles(nsIDOMNode *aPreviousBlock, nsIDOMNode *aNewBlock,
nsIDOMNode **aOutBrNode);
NS_IMETHOD LoadHTML(const nsAString &aInputString);
- NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists);
+ NS_IMETHOD GetParentBlockTags(nsTArray<nsString> *aTagList, PRBool aGetLists);
nsresult GetCSSBackgroundColorState(PRBool *aMixed, nsAString &aOutColor,
PRBool aBlockLevel);
NS_IMETHOD GetHTMLBackgroundColorState(PRBool *aMixed, nsAString &outColor);
NS_IMETHOD GetHighlightColor(PRBool *mixed, PRUnichar **_retval);
NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsAString *aTagName, nsIDOMElement **aReturn);
@@ -774,17 +775,17 @@ protected:
// Used by GetFirstSelectedCell and GetNextSelectedCell
PRInt32 mSelectedCellIndex;
nsString mLastStyleSheetURL;
nsString mLastOverrideStyleSheetURL;
// Maintain a list of associated style sheets and their urls.
- nsStringArray mStyleSheetURLs;
+ nsTArray<nsString> mStyleSheetURLs;
nsCOMArray<nsICSSStyleSheet> mStyleSheets;
// an array for holding default style settings
nsVoidArray mDefaultStyles;
// for real-time spelling
nsCOMPtr<nsITextServicesDocument> mTextServices;
--- a/editor/txtsvc/public/nsISpellChecker.h
+++ b/editor/txtsvc/public/nsISpellChecker.h
@@ -34,27 +34,27 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsISpellChecker_h__
#define nsISpellChecker_h__
#include "nsISupports.h"
+#include "nsTArray.h"
#define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1"
#define NS_ISPELLCHECKER_IID \
{ /* E75AC48C-E948-452E-8DB3-30FEE29FE3D2 */ \
0xe75ac48c, 0xe948, 0x452e, \
{ 0x8d, 0xb3, 0x30, 0xfe, 0xe2, 0x9f, 0xe3, 0xd2 } }
class nsITextServicesDocument;
class nsString;
-class nsStringArray;
/**
* A generic interface for a spelling checker.
*/
class nsISpellChecker : public nsISupports{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPELLCHECKER_IID)
@@ -68,27 +68,27 @@ public:
NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, PRBool aFromStartofDoc) = 0;
/**
* Selects (hilites) the next misspelled word in the document.
* @param aWord will contain the misspelled word.
* @param aSuggestions is an array of nsStrings, that represent the
* suggested replacements for the misspelled word.
*/
- NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestions) = 0;
+ NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) = 0;
/**
* Checks if a word is misspelled. No document is required to use this method.
* @param aWord is the word to check.
* @param aIsMisspelled will be set to true if the word is misspelled.
* @param aSuggestions is an array of nsStrings which represent the
* suggested replacements for the misspelled word. The array will be empty
* if there aren't any suggestions.
*/
- NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStringArray *aSuggestions) = 0;
+ NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsTArray<nsString> *aSuggestions) = 0;
/**
* Replaces the old word with the specified new word.
* @param aOldWord is the word to be replaced.
* @param aNewWord is the word that is to replace old word.
* @param aAllOccurrences will replace all occurrences of old
* word, in the document, with new word when it is true. If
* false, it will replace the 1st occurrence only!
@@ -113,28 +113,28 @@ public:
*/
NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord) = 0;
/**
* Returns the list of words in the user's personal dictionary.
* @param aWordList is an array of nsStrings that represent the
* list of words in the user's personal dictionary.
*/
- NS_IMETHOD GetPersonalDictionary(nsStringArray *aWordList) = 0;
+ NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList) = 0;
/**
* Returns the list of strings representing the dictionaries
* the spellchecker supports. It was suggested that the strings
* returned be in the RFC 1766 format. This format looks something
* like <ISO 639 language code>-<ISO 3166 country code>.
* For example: en-US
* @param aDictionaryList is an array of nsStrings that represent the
* dictionaries supported by the spellchecker.
*/
- NS_IMETHOD GetDictionaryList(nsStringArray *aDictionaryList) = 0;
+ NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) = 0;
/**
* Returns a string representing the current dictionary.
* @param aDictionary will contain the name of the dictionary.
* This name is the same string that is in the list returned
* by GetDictionaryList().
*/
NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) = 0;
--- a/extensions/spellcheck/src/mozPersonalDictionary.cpp
+++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp
@@ -153,17 +153,17 @@ NS_IMETHODIMP mozPersonalDictionary::Loa
}
// A little helper function to add the key to the list.
// This is not threadsafe, and only safe if the consumer does not
// modify the list.
static PLDHashOperator
AddHostToStringArray(nsUniCharEntry *aEntry, void *aArg)
{
- static_cast<nsStringArray*>(aArg)->AppendString(nsDependentString(aEntry->GetKey()));
+ static_cast<nsTArray<nsString>*>(aArg)->AppendElement(nsDependentString(aEntry->GetKey()));
return PL_DHASH_NEXT;
}
/* void Save (); */
NS_IMETHODIMP mozPersonalDictionary::Save()
{
nsCOMPtr<nsIFile> theFile;
nsresult res;
@@ -180,38 +180,37 @@ NS_IMETHODIMP mozPersonalDictionary::Sav
nsCOMPtr<nsIOutputStream> outStream;
NS_NewLocalFileOutputStream(getter_AddRefs(outStream), theFile, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE ,0664);
// get a buffered output stream 4096 bytes big, to optimize writes
nsCOMPtr<nsIOutputStream> bufferedOutputStream;
res = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream), outStream, 4096);
if (NS_FAILED(res)) return res;
- nsStringArray array(mDictionaryTable.Count());
+ nsTArray<nsString> array(mDictionaryTable.Count());
mDictionaryTable.EnumerateEntries(AddHostToStringArray, &array);
PRUint32 bytesWritten;
nsCAutoString utf8Key;
- for (PRInt32 i = 0; i < array.Count(); ++i ) {
- const nsString *key = array[i];
- CopyUTF16toUTF8(*key, utf8Key);
+ for (PRInt32 i = 0; i < array.Length(); ++i ) {
+ CopyUTF16toUTF8(array[i], utf8Key);
bufferedOutputStream->Write(utf8Key.get(), utf8Key.Length(), &bytesWritten);
bufferedOutputStream->Write("\n", 1, &bytesWritten);
}
return res;
}
/* readonly attribute nsIStringEnumerator GetWordList() */
NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator **aWords)
{
NS_ENSURE_ARG_POINTER(aWords);
*aWords = nsnull;
- nsStringArray *array = new nsStringArray(mDictionaryTable.Count());
+ nsTArray<nsString> *array = new nsTArray<nsString>(mDictionaryTable.Count());
if (!array)
return NS_ERROR_OUT_OF_MEMORY;
mDictionaryTable.EnumerateEntries(AddHostToStringArray, array);
array->Sort();
return NS_NewAdoptingStringEnumerator(aWords, array);
--- a/extensions/spellcheck/src/mozPersonalDictionary.h
+++ b/extensions/spellcheck/src/mozPersonalDictionary.h
@@ -41,16 +41,17 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "mozIPersonalDictionary.h"
#include "nsIUnicodeEncoder.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsTHashtable.h"
+#include "nsTArray.h"
#include "nsCRT.h"
#define MOZ_PERSONALDICTIONARY_CONTRACTID "@mozilla.org/spellchecker/personaldictionary;1"
#define MOZ_PERSONALDICTIONARY_CID \
{ /* 7EF52EAF-B7E1-462B-87E2-5D1DBACA9048 */ \
0X7EF52EAF, 0XB7E1, 0X462B, \
{ 0X87, 0XE2, 0X5D, 0X1D, 0XBA, 0XCA, 0X90, 0X48 } }
@@ -96,16 +97,16 @@ public:
NS_DECL_NSIOBSERVER
mozPersonalDictionary();
virtual ~mozPersonalDictionary();
nsresult Init();
protected:
- nsStringArray mDictionary; /* use something a little smarter eventually*/
+ nsTArray<nsString> mDictionary; /* use something a little smarter eventually*/
PRBool mDirty; /* has the dictionary been modified */
nsTHashtable<nsUniCharEntry> mDictionaryTable;
nsTHashtable<nsUniCharEntry> mIgnoreTable;
nsCOMPtr<nsIUnicodeEncoder> mEncoder; /*Encoder to use to compare with spellchecker word */
};
#endif
--- a/extensions/spellcheck/src/mozSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozSpellChecker.cpp
@@ -79,17 +79,17 @@ mozSpellChecker::SetDocument(nsITextServ
{
mTsDoc = aDoc;
mFromStart = aFromStartofDoc;
return NS_OK;
}
NS_IMETHODIMP
-mozSpellChecker::NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestions)
+mozSpellChecker::NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions)
{
if(!aSuggestions||!mConverter)
return NS_ERROR_NULL_POINTER;
PRUint32 selOffset;
PRInt32 begin,end;
nsresult result;
result = SetupDoc(&selOffset);
@@ -123,17 +123,17 @@ mozSpellChecker::NextMisspelledWord(nsAS
}while(end != -1);
mTsDoc->NextBlock();
selOffset=0;
}
return NS_OK;
}
NS_IMETHODIMP
-mozSpellChecker::CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStringArray *aSuggestions)
+mozSpellChecker::CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsTArray<nsString> *aSuggestions)
{
nsresult result;
PRBool correct;
if(!mSpellCheckingEngine)
return NS_ERROR_NULL_POINTER;
// don't bother to check crazy words
if (aWord.Length() > UNREASONABLE_WORD_LENGTH) {
@@ -147,17 +147,17 @@ mozSpellChecker::CheckWord(const nsAStri
if(!correct){
if(aSuggestions){
PRUint32 count,i;
PRUnichar **words;
result = mSpellCheckingEngine->Suggest(PromiseFlatString(aWord).get(), &words, &count);
NS_ENSURE_SUCCESS(result, result);
for(i=0;i<count;i++){
- aSuggestions->AppendString(nsDependentString(words[i]));
+ aSuggestions->AppendElement(nsDependentString(words[i]));
}
if (count)
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
}
if(aIsMisspelled){
*aIsMisspelled = PR_TRUE;
}
@@ -282,55 +282,55 @@ mozSpellChecker::RemoveWordFromPersonalD
PRUnichar empty=0;
if (!mPersonalDictionary)
return NS_ERROR_NULL_POINTER;
res = mPersonalDictionary->RemoveWord(PromiseFlatString(aWord).get(),&empty);
return res;
}
NS_IMETHODIMP
-mozSpellChecker::GetPersonalDictionary(nsStringArray *aWordList)
+mozSpellChecker::GetPersonalDictionary(nsTArray<nsString> *aWordList)
{
if(!aWordList || !mPersonalDictionary)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStringEnumerator> words;
mPersonalDictionary->GetWordList(getter_AddRefs(words));
PRBool hasMore;
nsAutoString word;
while (NS_SUCCEEDED(words->HasMore(&hasMore)) && hasMore) {
words->GetNext(word);
- aWordList->AppendString(word);
+ aWordList->AppendElement(word);
}
return NS_OK;
}
struct AppendNewStruct
{
- nsStringArray *dictionaryList;
+ nsTArray<nsString> *dictionaryList;
PRBool failed;
};
static PLDHashOperator
AppendNewString(const nsAString& aString, nsCString*, void* aClosure)
{
AppendNewStruct *ans = (AppendNewStruct*) aClosure;
- if (!ans->dictionaryList->AppendString(aString))
+ if (!ans->dictionaryList->AppendElement(aString))
{
ans->failed = PR_TRUE;
return PL_DHASH_STOP;
}
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
-mozSpellChecker::GetDictionaryList(nsStringArray *aDictionaryList)
+mozSpellChecker::GetDictionaryList(nsTArray<nsString> *aDictionaryList)
{
AppendNewStruct ans = {aDictionaryList, PR_FALSE};
mDictionariesMap.EnumerateRead(AppendNewString, &ans);
if (ans.failed)
return NS_ERROR_OUT_OF_MEMORY;
--- a/extensions/spellcheck/src/mozSpellChecker.h
+++ b/extensions/spellcheck/src/mozSpellChecker.h
@@ -41,56 +41,57 @@
#include "nsCOMPtr.h"
#include "nsISpellChecker.h"
#include "nsString.h"
#include "nsITextServicesDocument.h"
#include "mozIPersonalDictionary.h"
#include "mozISpellCheckingEngine.h"
#include "nsClassHashtable.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "mozISpellI18NUtil.h"
class mozSpellChecker : public nsISpellChecker
{
public:
NS_DECL_ISUPPORTS
mozSpellChecker();
virtual ~mozSpellChecker();
nsresult Init();
// nsISpellChecker
NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, PRBool aFromStartofDoc);
- NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestions);
- NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStringArray *aSuggestions);
+ NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions);
+ NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsTArray<nsString> *aSuggestions);
NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, PRBool aAllOccurrences);
NS_IMETHOD IgnoreAll(const nsAString &aWord);
NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord);
NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord);
- NS_IMETHOD GetPersonalDictionary(nsStringArray *aWordList);
+ NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList);
- NS_IMETHOD GetDictionaryList(nsStringArray *aDictionaryList);
+ NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList);
NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary);
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary);
protected:
nsCOMPtr<mozISpellI18NUtil> mConverter;
nsCOMPtr<nsITextServicesDocument> mTsDoc;
nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;
// Hastable maps directory name to the spellchecker contract ID
nsClassHashtable<nsStringHashKey, nsCString> mDictionariesMap;
nsString mDictionaryName;
nsCString *mCurrentEngineContractId;
nsCOMPtr<mozISpellCheckingEngine> mSpellCheckingEngine;
PRBool mFromStart;
- nsStringArray mIgnoreList;
+ nsTArray<nsString> mIgnoreList;
nsresult SetupDoc(PRUint32 *outBlockOffset);
nsresult GetCurrentBlockIndex(nsITextServicesDocument *aDoc, PRInt32 *outBlockIndex);
nsresult InitSpellCheckDictionaryMap();
};
#endif // mozSpellChecker_h__
--- a/gfx/src/thebes/nsThebesFontEnumerator.cpp
+++ b/gfx/src/thebes/nsThebesFontEnumerator.cpp
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsThebesFontEnumerator.h"
#include "nsMemory.h"
#include "gfxPlatform.h"
+#include "nsTArray.h"
NS_IMPL_ISUPPORTS1(nsThebesFontEnumerator, nsIFontEnumerator)
nsThebesFontEnumerator::nsThebesFontEnumerator()
{
}
NS_IMETHODIMP
@@ -59,17 +60,17 @@ NS_IMETHODIMP
nsThebesFontEnumerator::EnumerateFonts(const char *aLangGroup,
const char *aGeneric,
PRUint32 *aCount,
PRUnichar ***aResult)
{
NS_ENSURE_ARG_POINTER(aCount);
NS_ENSURE_ARG_POINTER(aResult);
- nsStringArray fontList;
+ nsTArray<nsString> fontList;
nsCAutoString langGroup;
nsCAutoString generic;
if (aLangGroup)
langGroup.Assign(aLangGroup);
else
langGroup.SetIsVoid(PR_TRUE);
@@ -84,23 +85,23 @@ nsThebesFontEnumerator::EnumerateFonts(c
if (NS_FAILED(rv)) {
*aCount = 0;
*aResult = nsnull;
/* XXX in this case, do we want to return the CSS generics? */
return NS_OK;
}
PRUnichar **fs = static_cast<PRUnichar **>
- (nsMemory::Alloc(fontList.Count() * sizeof(PRUnichar*)));
- for (int i = 0; i < fontList.Count(); i++) {
- fs[i] = ToNewUnicode(*fontList[i]);
+ (nsMemory::Alloc(fontList.Length() * sizeof(PRUnichar*)));
+ for (PRUint32 i = 0; i < fontList.Length(); i++) {
+ fs[i] = ToNewUnicode(fontList[i]);
}
*aResult = fs;
- *aCount = fontList.Count();
+ *aCount = fontList.Length();
return NS_OK;
}
NS_IMETHODIMP
nsThebesFontEnumerator::HaveFontFor(const char *aLangGroup,
PRBool *aResult)
{
--- a/gfx/thebes/public/gfxBeOSPlatform.h
+++ b/gfx/thebes/public/gfxBeOSPlatform.h
@@ -35,16 +35,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_PLATFORM_BEOS_H
#define GFX_PLATFORM_BEOS_H
#include "gfxPlatform.h"
+#include "gfxTArray.h"
class gfxFontconfigUtils;
class NS_EXPORT gfxBeOSPlatform : public gfxPlatform {
public:
gfxBeOSPlatform();
virtual ~gfxBeOSPlatform();
@@ -54,17 +55,17 @@ public:
already_AddRefed<gfxASurface>
CreateOffscreenSurface(PRUint32 width,
PRUint32 height,
gfxASurface::gfxImageFormat imageFormat);
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
nsresult ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
--- a/gfx/thebes/public/gfxOS2Platform.h
+++ b/gfx/thebes/public/gfxOS2Platform.h
@@ -39,16 +39,17 @@
#define GFX_OS2_PLATFORM_H
#define INCL_GPIBITMAPS
#include <os2.h>
#include "gfxPlatform.h"
#include "gfxOS2Fonts.h"
#include "gfxFontUtils.h"
+#include "nsTArray.h"
class gfxFontconfigUtils;
class THEBES_API gfxOS2Platform : public gfxPlatform {
public:
gfxOS2Platform();
virtual ~gfxOS2Platform();
@@ -58,17 +59,17 @@ public:
}
already_AddRefed<gfxASurface>
CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat);
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
nsresult ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle,
--- a/gfx/thebes/public/gfxPangoFonts.h
+++ b/gfx/thebes/public/gfxPangoFonts.h
@@ -39,16 +39,17 @@
#ifndef GFX_PANGOFONTS_H
#define GFX_PANGOFONTS_H
#include "cairo.h"
#include "gfxTypes.h"
#include "gfxFont.h"
#include "nsAutoRef.h"
+#include "nsTArray.h"
#include <pango/pango.h>
// Control when we bypass Pango
// Enable this to use FreeType to glyph-convert 8bit-only textruns, but use Pango
// to shape any textruns with non-8bit characters
// XXX
#define ENABLE_FAST_PATH_8BIT
--- a/gfx/thebes/public/gfxPlatform.h
+++ b/gfx/thebes/public/gfxPlatform.h
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_PLATFORM_H
#define GFX_PLATFORM_H
#include "prtypes.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsIObserver.h"
#include "gfxTypes.h"
#include "gfxASurface.h"
#include "gfxColor.h"
#ifdef XP_OS2
@@ -153,17 +154,17 @@ public:
/**
* Fill aListOfFonts with the results of querying the list of font names
* that correspond to the given language group or generic font family
* (or both, or neither).
*/
virtual nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
/**
* Rebuilds the any cached system font lists
*/
virtual nsresult UpdateFontList();
/**
* Font name resolver, this returns actual font name(s) by the callback
--- a/gfx/thebes/public/gfxPlatformGtk.h
+++ b/gfx/thebes/public/gfxPlatformGtk.h
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_PLATFORM_GTK_H
#define GFX_PLATFORM_GTK_H
#include "gfxPlatform.h"
#include "nsAutoRef.h"
+#include "nsTArray.h"
extern "C" {
typedef struct _GdkDrawable GdkDrawable;
}
class gfxFontconfigUtils;
#ifndef MOZ_PANGO
class FontFamily;
@@ -69,17 +70,17 @@ public:
return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
}
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat);
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
nsresult ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
--- a/gfx/thebes/public/gfxPlatformMac.h
+++ b/gfx/thebes/public/gfxPlatformMac.h
@@ -76,17 +76,17 @@ public:
nsISupports *aLoader,
const PRUint8 *aFontData,
PRUint32 aLength);
PRBool IsFontFormatSupported(nsIURI *aFontURI, PRUint32 aFormatFlags);
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
// in some situations, need to make decisions about ambiguous characters, may need to look at multiple pref langs
void GetLangPrefs(eFontPrefLang aPrefLangs[], PRUint32 &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang);
// Returns the OS X version as returned from Gestalt(gestaltSystemVersion, ...)
// Ex: Mac OS X 10.4.x ==> 0x104x
PRInt32 OSXVersion();
--- a/gfx/thebes/public/gfxQtPlatform.h
+++ b/gfx/thebes/public/gfxQtPlatform.h
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_PLATFORM_QT_H
#define GFX_PLATFORM_QT_H
#include "gfxPlatform.h"
#include "nsDataHashtable.h"
+#include "nsTArray.h"
typedef struct FT_LibraryRec_ *FT_Library;
class gfxFontconfigUtils;
class FontFamily;
class FontEntry;
class THEBES_API gfxQtPlatform : public gfxPlatform {
@@ -57,17 +58,17 @@ public:
return (gfxQtPlatform*) gfxPlatform::GetPlatform();
}
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat);
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
nsresult ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
--- a/gfx/thebes/public/gfxWindowsPlatform.h
+++ b/gfx/thebes/public/gfxWindowsPlatform.h
@@ -40,16 +40,17 @@
#define GFX_WINDOWS_PLATFORM_H
#include "gfxFontUtils.h"
#include "gfxWindowsSurface.h"
#include "gfxWindowsFonts.h"
#include "gfxPlatform.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsDataHashtable.h"
#include <windows.h>
class THEBES_API gfxWindowsPlatform : public gfxPlatform, private gfxFontInfoLoader {
public:
gfxWindowsPlatform();
virtual ~gfxWindowsPlatform();
@@ -57,17 +58,17 @@ public:
return (gfxWindowsPlatform*) gfxPlatform::GetPlatform();
}
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat);
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
void GetFontFamilyList(nsTArray<nsRefPtr<FontFamily> >& aFamilyArray);
nsresult ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
@@ -154,17 +155,17 @@ private:
// gfxFontInfoLoader overrides, used to load in font cmaps
virtual void InitLoader();
virtual PRBool RunLoader();
virtual void FinishLoader();
FontTable mFonts;
FontTable mFontAliases;
FontTable mFontSubstitutes;
- nsStringArray mNonExistingFonts;
+ nsTArray<nsString> mNonExistingFonts;
// when system-wide font lookup fails for a character, cache it to skip future searches
gfxSparseBitSet mCodepointsWithNoFonts;
nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<FontEntry> > > mPrefFonts;
// data used as part of the font cmap loading process
nsTArray<nsRefPtr<FontFamily> > mFontFamilies;
--- a/gfx/thebes/src/gfxBeOSPlatform.cpp
+++ b/gfx/thebes/src/gfxBeOSPlatform.cpp
@@ -37,16 +37,18 @@
#include "gfxBeOSPlatform.h"
#include "gfxFontconfigUtils.h"
#include "gfxPangoFonts.h"
#include "gfxImageSurface.h"
#include "gfxBeOSSurface.h"
+#include "nsTArray.h"
+
gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nsnull;
gfxBeOSPlatform::gfxBeOSPlatform()
{
if (!sFontconfigUtils)
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
}
@@ -83,17 +85,17 @@ gfxBeOSPlatform::CreateOffscreenSurface
NS_ADDREF(newSurface);
return newSurface;
}
nsresult
gfxBeOSPlatform::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
aListOfFonts);
}
nsresult
gfxBeOSPlatform::UpdateFontList()
{
--- a/gfx/thebes/src/gfxFT2Fonts.cpp
+++ b/gfx/thebes/src/gfxFT2Fonts.cpp
@@ -43,16 +43,17 @@
#define gfxToolkitPlatform gfxQtPlatform
#endif
#include "gfxTypes.h"
#include "gfxFT2Fonts.h"
#include <locale.h>
#include "cairo-ft.h"
#include <freetype/tttables.h>
#include "gfxFontUtils.h"
+#include "nsTArray.h"
/**
* FontEntry
*/
FontEntry::FontEntry(const FontEntry& aFontEntry) :
gfxFontEntry(aFontEntry)
{
@@ -172,20 +173,20 @@ FontFamily::FindFontEntry(const gfxFontS
* gfxFT2FontGroup
*/
PRBool
gfxFT2FontGroup::FontCallback(const nsAString& fontName,
const nsACString& genericName,
void *closure)
{
- nsStringArray *sa = static_cast<nsStringArray*>(closure);
+ nsTArray<nsString> *sa = static_cast<nsTArray<nsString>*>(closure);
- if (!fontName.IsEmpty() && sa->IndexOf(fontName) < 0) {
- sa->AppendString(fontName);
+ if (!fontName.IsEmpty() && !sa->Contains(fontName)) {
+ sa->AppendElement(fontName);
#ifdef DEBUG_pavlov
printf(" - %s\n", NS_ConvertUTF16toUTF8(fontName).get());
#endif
}
return PR_TRUE;
}
@@ -218,38 +219,38 @@ GetOrMakeFont(const nsAString& aName, co
gfxFT2FontGroup::gfxFT2FontGroup(const nsAString& families,
const gfxFontStyle *aStyle)
: gfxFontGroup(families, aStyle)
{
#ifdef DEBUG_pavlov
printf("Looking for %s\n", NS_ConvertUTF16toUTF8(families).get());
#endif
- nsStringArray familyArray;
+ nsTArray<nsString> familyArray;
ForEachFont(FontCallback, &familyArray);
- if (familyArray.Count() == 0) {
+ if (familyArray.Length() == 0) {
nsAutoString prefFamilies;
gfxToolkitPlatform::GetPlatform()->GetPrefFonts(aStyle->langGroup.get(), prefFamilies, nsnull);
if (!prefFamilies.IsEmpty()) {
ForEachFont(prefFamilies, aStyle->langGroup, FontCallback, &familyArray);
}
}
#if defined(MOZ_WIDGET_QT) /* FIXME DFB */
- if (familyArray.Count() == 0) {
+ if (familyArray.Length() == 0) {
printf("failde to find a font. sadface\n");
// We want to get rid of this entirely at some point, but first we need real lists of fonts.
QFont defaultFont;
QFontInfo fi (defaultFont);
- familyArray.AppendString(nsDependentString(static_cast<const PRUnichar *>(fi.family().utf16())));
+ familyArray.AppendElement(nsDependentString(static_cast<const PRUnichar *>(fi.family().utf16())));
}
#endif
- for (int i = 0; i < familyArray.Count(); i++) {
- nsRefPtr<gfxFT2Font> font = GetOrMakeFont(*familyArray[i], &mStyle);
+ for (PRUint32 i = 0; i < familyArray.Length(); i++) {
+ nsRefPtr<gfxFT2Font> font = GetOrMakeFont(familyArray[i], &mStyle);
if (font) {
mFonts.AppendElement(font);
}
}
}
gfxFT2FontGroup::~gfxFT2FontGroup()
{
--- a/gfx/thebes/src/gfxFontconfigUtils.cpp
+++ b/gfx/thebes/src/gfxFontconfigUtils.cpp
@@ -42,16 +42,17 @@
#include <locale.h>
#include <fontconfig/fontconfig.h>
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsServiceManagerUtils.h"
#include "nsILanguageAtomService.h"
+#include "nsTArray.h"
#include "nsIAtom.h"
#include "nsCRT.h"
/* static */ gfxFontconfigUtils* gfxFontconfigUtils::sUtils = nsnull;
static nsILanguageAtomService* gLangService = nsnull;
/* static */ void
@@ -268,27 +269,27 @@ gfxFontconfigUtils::gfxFontconfigUtils()
mFontsByFullname.Init(50);
mLangSupportTable.Init(20);
UpdateFontListInternal();
}
nsresult
gfxFontconfigUtils::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
aListOfFonts.Clear();
nsCStringArray fonts;
nsresult rv = GetFontListInternal(fonts, aLangGroup);
if (NS_FAILED(rv))
return rv;
for (PRInt32 i = 0; i < fonts.Count(); ++i) {
- aListOfFonts.AppendString(NS_ConvertUTF8toUTF16(*fonts.CStringAt(i)));
+ aListOfFonts.AppendElement(NS_ConvertUTF8toUTF16(*fonts.CStringAt(i)));
}
aListOfFonts.Sort();
PRInt32 serif = 0, sansSerif = 0, monospace = 0;
// Fontconfig supports 3 generic fonts, "serif", "sans-serif", and
// "monospace", slightly different from CSS's 5.
@@ -305,21 +306,21 @@ gfxFontconfigUtils::GetFontList(const ns
serif = sansSerif = 1;
else
NS_NOTREACHED("unexpected CSS generic font family");
// The first in the list becomes the default in
// gFontsDialog.readFontSelection() if the preference-selected font is not
// available, so put system configured defaults first.
if (monospace)
- aListOfFonts.InsertStringAt(NS_LITERAL_STRING("monospace"), 0);
+ aListOfFonts.InsertElementAt(0, NS_LITERAL_STRING("monospace"));
if (sansSerif)
- aListOfFonts.InsertStringAt(NS_LITERAL_STRING("sans-serif"), 0);
+ aListOfFonts.InsertElementAt(0, NS_LITERAL_STRING("sans-serif"));
if (serif)
- aListOfFonts.InsertStringAt(NS_LITERAL_STRING("serif"), 0);
+ aListOfFonts.InsertElementAt(0, NS_LITERAL_STRING("serif"));
return NS_OK;
}
struct MozLangGroupData {
const char *mozLangGroup;
const char *defaultLang;
};
--- a/gfx/thebes/src/gfxFontconfigUtils.h
+++ b/gfx/thebes/src/gfxFontconfigUtils.h
@@ -87,17 +87,17 @@ public:
sUtils = new gfxFontconfigUtils();
return sUtils;
}
static void Shutdown();
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
nsresult ResolveFontName(const nsAString& aFontName,
gfxPlatform::FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
--- a/gfx/thebes/src/gfxOS2Fonts.cpp
+++ b/gfx/thebes/src/gfxOS2Fonts.cpp
@@ -39,16 +39,17 @@
*
* ***** END LICENSE BLOCK ***** */
#include "gfxContext.h"
#include "gfxOS2Platform.h"
#include "gfxOS2Surface.h"
#include "gfxOS2Fonts.h"
+#include "nsTArray.h"
#include "nsIServiceManager.h"
#include "nsIPlatformCharset.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
/**********************************************************************
* class gfxOS2Font
@@ -478,38 +479,38 @@ gfxOS2FontGroup::gfxOS2FontGroup(const n
// check for WarpSans and as we cannot display that (yet), replace
// it with Workplace Sans
int pos = 0;
if ((pos = mFamilies.Find("WarpSans", PR_FALSE, 0, -1)) > -1) {
mFamilies.Replace(pos, 8, NS_LITERAL_STRING("Workplace Sans"));
}
- nsStringArray familyArray;
+ nsTArray<nsString> familyArray;
ForEachFont(FontCallback, &familyArray);
// To be able to easily search for glyphs in other fonts, append a few good
// replacement candidates to the list. The best ones are the Unicode fonts that
// are set up, and if the user was so clever to set up the User Defined fonts,
// then these are probable candidates, too.
nsString fontString;
gfxPlatform::GetPlatform()->GetPrefFonts("x-unicode", fontString, PR_FALSE);
ForEachFont(fontString, NS_LITERAL_CSTRING("x-unicode"), FontCallback, &familyArray);
gfxPlatform::GetPlatform()->GetPrefFonts("x-user-def", fontString, PR_FALSE);
ForEachFont(fontString, NS_LITERAL_CSTRING("x-user-def"), FontCallback, &familyArray);
// Should append some default font if there are no available fonts.
// Let's use Helv which should be available on any OS/2 system; if
// it's not there, Fontconfig replaces it with something else...
- if (familyArray.Count() == 0) {
- familyArray.AppendString(NS_LITERAL_STRING("Helv"));
+ if (familyArray.Length() == 0) {
+ familyArray.AppendElement(NS_LITERAL_STRING("Helv"));
}
- for (int i = 0; i < familyArray.Count(); i++) {
- nsRefPtr<gfxOS2Font> font = gfxOS2Font::GetOrMakeFont(*familyArray[i], &mStyle);
+ for (PRUint32 i = 0; i < familyArray.Length(); i++) {
+ nsRefPtr<gfxOS2Font> font = gfxOS2Font::GetOrMakeFont(familyArray[i], &mStyle);
if (font) {
mFonts.AppendElement(font);
}
}
}
gfxOS2FontGroup::~gfxOS2FontGroup()
{
@@ -815,14 +816,14 @@ void gfxOS2FontGroup::CreateGlyphRunsFT(
cairo_ft_scaled_font_unlock_face(font0->CairoScaledFont());
}
// append aFontName to aClosure string array, if not already present
PRBool gfxOS2FontGroup::FontCallback(const nsAString& aFontName,
const nsACString& aGenericName,
void *aClosure)
{
- nsStringArray *sa = static_cast<nsStringArray*>(aClosure);
- if (!aFontName.IsEmpty() && sa->IndexOf(aFontName) < 0) {
- sa->AppendString(aFontName);
+ nsTArray<nsString> *sa = static_cast<nsTArray<nsString>*>(aClosure);
+ if (!aFontName.IsEmpty() && !sa->Contains(aFontName)) {
+ sa->AppendElement(aFontName);
}
return PR_TRUE;
}
--- a/gfx/thebes/src/gfxOS2Platform.cpp
+++ b/gfx/thebes/src/gfxOS2Platform.cpp
@@ -36,16 +36,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "gfxOS2Platform.h"
#include "gfxOS2Surface.h"
#include "gfxImageSurface.h"
#include "gfxOS2Fonts.h"
+#include "nsTArray.h"
#include "gfxFontconfigUtils.h"
//#include <fontconfig/fontconfig.h>
/**********************************************************************
* class gfxOS2Platform
**********************************************************************/
gfxFontconfigUtils *gfxOS2Platform::sFontconfigUtils = nsnull;
@@ -106,17 +107,17 @@ gfxOS2Platform::CreateOffscreenSurface(c
NS_IF_ADDREF(newSurface);
return newSurface;
}
nsresult
gfxOS2Platform::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
#ifdef DEBUG_thebes
char *langgroup = ToNewCString(aLangGroup),
*family = ToNewCString(aGenericFamily);
printf("gfxOS2Platform::GetFontList(%s, %s, ..)\n",
langgroup, family);
free(langgroup);
free(family);
@@ -179,28 +180,28 @@ gfxOS2Platform::FindFontForChar(PRUint32
if (mCodepointsWithNoFonts.test(aCh)) {
return nsnull;
}
// the following is not very clever but it's a quick fix to search all fonts
// (one should instead cache the charmaps as done on Mac and Win)
// just continue to append all fonts known to the system
- nsStringArray fontList;
+ nsTArray<nsString> fontList;
nsCAutoString generic;
nsresult rv = GetFontList(aFont->GetStyle()->langGroup, generic, fontList);
if (NS_SUCCEEDED(rv)) {
// start at 3 to skip over the generic entries
- for (int i = 3; i < fontList.Count(); i++) {
+ for (PRUint32 i = 3; i < fontList.Length(); i++) {
#ifdef DEBUG_thebes
printf("searching in entry i=%d (%s)\n",
- i, NS_LossyConvertUTF16toASCII(*fontList[i]).get());
+ i, NS_LossyConvertUTF16toASCII(fontList[i]).get());
#endif
nsRefPtr<gfxOS2Font> font =
- gfxOS2Font::GetOrMakeFont(*fontList[i], aFont->GetStyle());
+ gfxOS2Font::GetOrMakeFont(fontList[i], aFont->GetStyle());
if (!font)
continue;
FT_Face face = cairo_ft_scaled_font_lock_face(font->CairoScaledFont());
if (!face || !face->charmap) {
if (face)
cairo_ft_scaled_font_unlock_face(font->CairoScaledFont());
continue;
}
--- a/gfx/thebes/src/gfxPangoFonts.cpp
+++ b/gfx/thebes/src/gfxPangoFonts.cpp
@@ -44,16 +44,17 @@
#define PANGO_ENABLE_BACKEND
#include "prtypes.h"
#include "prlink.h"
#include "gfxTypes.h"
#include "nsMathUtils.h"
+#include "nsTArray.h"
#include "nsServiceManagerUtils.h"
#include "nsILanguageAtomService.h"
#include "gfxContext.h"
#include "gfxPlatformGtk.h"
#include "gfxPangoFonts.h"
#include "gfxFontconfigUtils.h"
#include "gfxUserFontSet.h"
--- a/gfx/thebes/src/gfxPlatform.cpp
+++ b/gfx/thebes/src/gfxPlatform.cpp
@@ -55,16 +55,17 @@
#include "gfxContext.h"
#include "gfxImageSurface.h"
#include "gfxTextRunCache.h"
#include "gfxTextRunWordCache.h"
#include "gfxUserFontSet.h"
#include "nsIPref.h"
#include "nsServiceManagerUtils.h"
+#include "nsTArray.h"
#include "nsWeakReference.h"
#include "cairo.h"
#include "lcms.h"
#include "plstr.h"
#include "nsIPrefService.h"
@@ -299,17 +300,17 @@ gfxPlatform::OptimizeImage(gfxImageSurfa
gfxASurface *ret = optSurface;
NS_ADDREF(ret);
return ret;
}
nsresult
gfxPlatform::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
gfxPlatform::UpdateFontList()
{
return NS_ERROR_NOT_IMPLEMENTED;
--- a/gfx/thebes/src/gfxPlatformGtk.cpp
+++ b/gfx/thebes/src/gfxPlatformGtk.cpp
@@ -243,17 +243,17 @@ gfxPlatformGtk::CreateOffscreenSurface(c
return newSurface.forget();
}
#ifdef MOZ_PANGO
nsresult
gfxPlatformGtk::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
aListOfFonts);
}
nsresult
gfxPlatformGtk::UpdateFontList()
{
@@ -330,17 +330,17 @@ gfxPlatformGtk::IsFontFormatSupported(ns
return PR_TRUE;
}
#else
nsresult
gfxPlatformGtk::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
aListOfFonts);
}
nsresult
gfxPlatformGtk::UpdateFontList()
{
--- a/gfx/thebes/src/gfxPlatformMac.cpp
+++ b/gfx/thebes/src/gfxPlatformMac.cpp
@@ -46,16 +46,17 @@
#include "gfxAtsuiFonts.h"
#include "gfxUserFontSet.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
#include "nsServiceManagerUtils.h"
#include "nsCRT.h"
+#include "nsTArray.h"
#include "lcms.h"
gfxPlatformMac::gfxPlatformMac()
{
mOSXVersion = 0;
mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
}
@@ -158,17 +159,17 @@ gfxPlatformMac::IsFontFormatSupported(ns
// no format hint set, need to look at data
return PR_TRUE;
}
nsresult
gfxPlatformMac::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
gfxQuartzFontCache::SharedFontCache()->
GetFontList(aLangGroup, aGenericFamily, aListOfFonts);
return NS_OK;
}
nsresult
gfxPlatformMac::UpdateFontList()
--- a/gfx/thebes/src/gfxQtPlatform.cpp
+++ b/gfx/thebes/src/gfxQtPlatform.cpp
@@ -52,16 +52,17 @@
#include "gfxFT2Fonts.h"
#include "nsUnicharUtils.h"
#include <fontconfig/fontconfig.h>
#include "nsMathUtils.h"
+#include "nsTArray.h"
#include "lcms.h"
#include <ft2build.h>
#include FT_FREETYPE_H
PRInt32 gfxQtPlatform::sDPI = -1;
gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nsnull;
@@ -128,17 +129,17 @@ gfxQtPlatform::CreateOffscreenSurface(co
new gfxQPainterSurface (size, gfxASurface::ContentFromFormat(imageFormat));
return newSurface.forget();
}
nsresult
gfxQtPlatform::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
aListOfFonts);
}
nsresult
gfxQtPlatform::UpdateFontList()
{
--- a/gfx/thebes/src/gfxQuartzFontCache.h
+++ b/gfx/thebes/src/gfxQuartzFontCache.h
@@ -46,16 +46,17 @@
#include "gfxFontUtils.h"
#include "gfxAtsuiFonts.h"
#include "gfxPlatform.h"
#include <Carbon/Carbon.h>
#include "nsUnicharUtils.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
// used when picking fallback font
struct FontSearch {
FontSearch(const PRUint32 aCharacter, gfxFont *aFont) :
ch(aCharacter), fontToMatch(aFont), matchRank(0) {
}
const PRUint32 ch;
gfxFont *fontToMatch;
@@ -205,17 +206,17 @@ public:
delete sSharedFontCache;
sSharedFontCache = nsnull;
}
// methods used by gfxPlatformMac
void GetFontList (const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts);
+ nsTArray<nsString>& aListOfFonts);
PRBool ResolveFontName(const nsAString& aFontName,
nsAString& aResolvedFontName);
PRBool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
void UpdateFontList() { InitFontList(); }
void GetFontFamilyList(nsTArray<nsRefPtr<MacOSFamilyEntry> >& aFamilyArray);
MacOSFontEntry* FindFontForChar(const PRUint32 aCh, gfxFont *aPrevFont);
--- a/gfx/thebes/src/gfxQuartzFontCache.mm
+++ b/gfx/thebes/src/gfxQuartzFontCache.mm
@@ -44,16 +44,17 @@
#include "gfxPlatformMac.h"
#include "gfxQuartzFontCache.h"
#include "gfxAtsuiFonts.h"
#include "gfxUserFontSet.h"
#include "nsIPref.h" // for pref changes callback notification
#include "nsServiceManagerUtils.h"
+#include "nsTArray.h"
#include "nsDirectoryServiceUtils.h"
#include "nsDirectoryServiceDefs.h"
#include "nsISimpleEnumerator.h"
#include <unistd.h>
#include <time.h>
@@ -1096,41 +1097,41 @@ gfxQuartzFontCache::GetDefaultFont(const
GetStringForNSString(defaultFamily, familyName);
return FindFontForFamily(familyName, aStyle, aNeedsBold);
}
struct FontListData {
FontListData(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts) :
+ nsTArray<nsString>& aListOfFonts) :
mLangGroup(aLangGroup), mGenericFamily(aGenericFamily),
mListOfFonts(aListOfFonts) {}
const nsACString& mLangGroup;
const nsACString& mGenericFamily;
- nsStringArray& mListOfFonts;
+ nsTArray<nsString>& mListOfFonts;
};
PLDHashOperator PR_CALLBACK
gfxQuartzFontCache::HashEnumFuncForFamilies(nsStringHashKey::KeyType aKey,
nsRefPtr<MacOSFamilyEntry>& aFamilyEntry,
void *aUserArg)
{
FontListData *data = (FontListData*)aUserArg;
nsAutoString localizedFamilyName;
aFamilyEntry->LocalizedName(localizedFamilyName);
- data->mListOfFonts.AppendString(localizedFamilyName);
+ data->mListOfFonts.AppendElement(localizedFamilyName);
return PL_DHASH_NEXT;
}
void
gfxQuartzFontCache::GetFontList (const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
FontListData data(aLangGroup, aGenericFamily, aListOfFonts);
mFontFamilies.Enumerate(gfxQuartzFontCache::HashEnumFuncForFamilies, &data);
aListOfFonts.Sort();
aListOfFonts.Compact();
}
--- a/gfx/thebes/src/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/src/gfxWindowsPlatform.cpp
@@ -42,16 +42,17 @@
#include "gfxImageSurface.h"
#include "gfxWindowsSurface.h"
#include "nsUnicharUtils.h"
#include "nsIPref.h"
#include "nsServiceManagerUtils.h"
+#include "nsTArray.h"
#include "nsIWindowsRegKey.h"
#include "nsILocalFile.h"
#include "plbase64.h"
#include "gfxWindowsFonts.h"
#include "gfxUserFontSet.h"
@@ -145,21 +146,21 @@ gfxWindowsPlatform::FontEnumProc(const E
return 1;
}
// general cmap reading routines moved to gfxFontUtils.cpp
struct FontListData {
- FontListData(const nsACString& aLangGroup, const nsACString& aGenericFamily, nsStringArray& aListOfFonts) :
+ FontListData(const nsACString& aLangGroup, const nsACString& aGenericFamily, nsTArray<nsString>& aListOfFonts) :
mLangGroup(aLangGroup), mGenericFamily(aGenericFamily), mStringArray(aListOfFonts) {}
const nsACString& mLangGroup;
const nsACString& mGenericFamily;
- nsStringArray& mStringArray;
+ nsTArray<nsString>& mStringArray;
};
PLDHashOperator
gfxWindowsPlatform::HashEnumFunc(nsStringHashKey::KeyType aKey,
nsRefPtr<FontFamily>& aFontFamily,
void* userArg)
{
FontListData *data = (FontListData*)userArg;
@@ -180,17 +181,17 @@ gfxWindowsPlatform::HashEnumFunc(nsStrin
data->mStringArray.AppendString(aFontFamily->mName);
return PL_DHASH_NEXT;
}
nsresult
gfxWindowsPlatform::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
- nsStringArray& aListOfFonts)
+ nsTArray<nsString>& aListOfFonts)
{
FontListData data(aLangGroup, aGenericFamily, aListOfFonts);
mFonts.Enumerate(gfxWindowsPlatform::HashEnumFunc, &data);
aListOfFonts.Sort();
aListOfFonts.Compact();
@@ -265,17 +266,17 @@ gfxWindowsPlatform::UpdateFontList()
RemoveCharsetFromFontSubstitute(substituteName);
BuildKeyNameFromFontName(substituteName);
RemoveCharsetFromFontSubstitute(actualFontName);
BuildKeyNameFromFontName(actualFontName);
nsRefPtr<FontFamily> ff;
if (!actualFontName.IsEmpty() && mFonts.Get(actualFontName, &ff))
mFontSubstitutes.Put(substituteName, ff);
else
- mNonExistingFonts.AppendString(substituteName);
+ mNonExistingFonts.AppendElement(substituteName);
}
// initialize ranges of characters for which system-wide font search should be skipped
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
InitBadUnderlineList();
@@ -369,17 +370,17 @@ gfxWindowsPlatform::ResolveFontName(cons
if (mFonts.Get(keyName, &ff) ||
mFontSubstitutes.Get(keyName, &ff) ||
mFontAliases.Get(keyName, &ff)) {
aAborted = !(*aCallback)(ff->mName, aClosure);
// XXX If the font has font link, we should add the linked font.
return NS_OK;
}
- if (mNonExistingFonts.IndexOf(keyName) >= 0) {
+ if (mNonExistingFonts.Contains(keyName)) {
aAborted = PR_FALSE;
return NS_OK;
}
LOGFONTW logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
logFont.lfPitchAndFamily = 0;
PRInt32 len = aFontName.Length();
@@ -390,17 +391,17 @@ gfxWindowsPlatform::ResolveFontName(cons
logFont.lfFaceName[len] = 0;
HDC dc = ::GetDC(nsnull);
ResolveData data(aCallback, this, &keyName, aClosure);
aAborted = !EnumFontFamiliesExW(dc, &logFont,
(FONTENUMPROCW)gfxWindowsPlatform::FontResolveProc,
(LPARAM)&data, 0);
if (data.mFoundCount == 0)
- mNonExistingFonts.AppendString(keyName);
+ mNonExistingFonts.AppendElement(keyName);
::ReleaseDC(nsnull, dc);
return NS_OK;
}
int CALLBACK
gfxWindowsPlatform::FontResolveProc(const ENUMLOGFONTEXW *lpelfe,
const NEWTEXTMETRICEXW *nmetrics,
--- a/intl/chardet/src/nsMetaCharsetObserver.cpp
+++ b/intl/chardet/src/nsMetaCharsetObserver.cpp
@@ -132,18 +132,18 @@ NS_IMETHODIMP nsMetaCharsetObserver::Not
values.Push((void*)valueArray[i]);
}
return NS_OK;//Notify((nsISupports*)aDocumentID, &keys, &values);
}
NS_IMETHODIMP nsMetaCharsetObserver::Notify(
nsISupports* aWebShell,
nsISupports* aChannel,
const PRUnichar* aTag,
- const nsStringArray* keys,
- const nsStringArray* values,
+ const nsTArray<nsString>* keys,
+ const nsTArray<nsString>* values,
const PRUint32 aFlags)
{
nsresult result = NS_OK;
// bug 125317 - document.write content is already an unicode content.
if (!(aFlags & nsIElementObserver::IS_DOCUMENT_WRITE)) {
if(!nsDependentString(aTag).LowerCaseEqualsLiteral("meta")) {
result = NS_ERROR_ILLEGAL_VALUE;
}
@@ -154,78 +154,75 @@ NS_IMETHODIMP nsMetaCharsetObserver::Not
return result;
}
#define IS_SPACE_CHARS(ch) (ch == ' ' || ch == '\b' || ch == '\r' || ch == '\n')
NS_IMETHODIMP nsMetaCharsetObserver::Notify(
nsISupports* aWebShell,
nsISupports* aChannel,
- const nsStringArray* keys,
- const nsStringArray* values)
+ const nsTArray<nsString>* keys,
+ const nsTArray<nsString>* values)
{
NS_PRECONDITION(keys!=nsnull && values!=nsnull,"Need key-value pair");
- PRInt32 numOfAttributes = keys->Count();
- NS_ASSERTION( numOfAttributes == values->Count(), "size mismatch");
+ PRUint32 numOfAttributes = keys->Length();
+ NS_ASSERTION( numOfAttributes == values->Length(), "size mismatch");
nsresult res=NS_OK;
#ifdef DEBUG
PRUnichar Uxcommand[]={'X','_','C','O','M','M','A','N','D','\0'};
PRUnichar UcharsetSource[]={'c','h','a','r','s','e','t','S','o','u','r','c','e','\0'};
PRUnichar Ucharset[]={'c','h','a','r','s','e','t','\0'};
NS_ASSERTION(numOfAttributes >= 3, "should have at least 3 private attribute");
- NS_ASSERTION(0==nsCRT::strcmp(Uxcommand,(keys->StringAt(numOfAttributes-1))->get()),"last name should be 'X_COMMAND'" );
- NS_ASSERTION(0==nsCRT::strcmp(UcharsetSource,(keys->StringAt(numOfAttributes-2))->get()),"2nd last name should be 'charsetSource'" );
- NS_ASSERTION(0==nsCRT::strcmp(Ucharset,(keys->StringAt(numOfAttributes-3))->get()),"3rd last name should be 'charset'" );
+ NS_ASSERTION(0==nsCRT::strcmp(Uxcommand,(keys->ElementAt(numOfAttributes-1)).get()),"last name should be 'X_COMMAND'" );
+ NS_ASSERTION(0==nsCRT::strcmp(UcharsetSource,(keys->ElementAt(numOfAttributes-2)).get()),"2nd last name should be 'charsetSource'" );
+ NS_ASSERTION(0==nsCRT::strcmp(Ucharset,(keys->ElementAt(numOfAttributes-3)).get()),"3rd last name should be 'charset'" );
#endif
NS_ASSERTION(mAlias, "Didn't get nsICharsetAlias in constructor");
if(nsnull == mAlias)
return NS_ERROR_ABORT;
// we need at least 5 - HTTP-EQUIV, CONTENT and 3 private
if(numOfAttributes >= 5 )
{
- const PRUnichar *charset = (values->StringAt(numOfAttributes-3))->get();
- const PRUnichar *source = (values->StringAt(numOfAttributes-2))->get();
+ const nsString& srcStr = values->ElementAt(numOfAttributes-2);
PRInt32 err;
- nsAutoString srcStr(source);
PRInt32 src = srcStr.ToInteger(&err);
// if we cannot convert the string into PRInt32, return error
NS_ASSERTION(NS_SUCCEEDED(err), "cannot get charset source");
if(NS_FAILED(err))
return NS_ERROR_ILLEGAL_VALUE;
if(kCharsetFromMetaTag <= src)
return NS_OK; // current charset has higher priority. don't bother to do the following
- PRInt32 i;
const PRUnichar *httpEquivValue=nsnull;
const PRUnichar *contentValue=nsnull;
const PRUnichar *charsetValue=nsnull;
- for(i=0;i<(numOfAttributes-3);i++)
+ for (PRUint32 i = 0; i < numOfAttributes - 3; i++)
{
const PRUnichar *keyStr;
- keyStr = (keys->StringAt(i))->get();
+ keyStr = keys->ElementAt(i).get();
//Change 3.190 in nsHTMLTokens.cpp allow ws/tab/cr/lf exist before
// and after text value, this need to be skipped before comparison
while(IS_SPACE_CHARS(*keyStr))
keyStr++;
if(Substring(keyStr, keyStr+10).LowerCaseEqualsLiteral("http-equiv"))
- httpEquivValue = values->StringAt(i)->get();
+ httpEquivValue = values->ElementAt(i).get();
else if(Substring(keyStr, keyStr+7).LowerCaseEqualsLiteral("content"))
- contentValue = values->StringAt(i)->get();
+ contentValue = values->ElementAt(i).get();
else if (Substring(keyStr, keyStr+7).LowerCaseEqualsLiteral("charset"))
- charsetValue = values->StringAt(i)->get();
+ charsetValue = values->ElementAt(i).get();
}
NS_NAMED_LITERAL_STRING(contenttype, "Content-Type");
NS_NAMED_LITERAL_STRING(texthtml, "text/html");
if(nsnull == httpEquivValue || nsnull == contentValue)
return NS_OK;
while(IS_SPACE_CHARS(*httpEquivValue))
@@ -273,17 +270,18 @@ NS_IMETHODIMP nsMetaCharsetObserver::Not
}
}
}
else
{
LossyCopyUTF16toASCII(nsDependentString(charsetValue), newCharset);
}
- nsCAutoString charsetString; charsetString.AssignWithConversion(charset);
+ nsCAutoString charsetString;
+ charsetString.AssignWithConversion(values->ElementAt(numOfAttributes-3));
if (!newCharset.IsEmpty())
{
if(! newCharset.Equals(charsetString, nsCaseInsensitiveCStringComparator()))
{
PRBool same = PR_FALSE;
nsresult res2 = mAlias->Equals( newCharset, charsetString , &same);
if(NS_SUCCEEDED(res2) && (! same))
@@ -328,56 +326,56 @@ NS_IMETHODIMP nsMetaCharsetObserver::Not
}
}
}
return res;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag(
- const nsStringArray* keys,
- const nsStringArray* values,
+ const nsTArray<nsString>* keys,
+ const nsTArray<nsString>* values,
nsAString& aCharset)
{
if (!mAlias)
return NS_ERROR_ABORT;
aCharset.Truncate(0);
nsresult res = NS_OK;
// support for non standard case for compatibility
// e.g. <META charset="ISO-8859-1">
- PRInt32 numOfAttributes = keys->Count();
+ PRUint32 numOfAttributes = keys->Length();
if ((numOfAttributes >= 3) &&
- (keys->StringAt(0)->LowerCaseEqualsLiteral("charset")))
+ (keys->ElementAt(0).LowerCaseEqualsLiteral("charset")))
{
- nsAutoString srcStr((values->StringAt(numOfAttributes-2))->get());
+ const nsString& srcStr = values->ElementAt(numOfAttributes-2);
PRInt32 err;
PRInt32 src = srcStr.ToInteger(&err);
// if we cannot convert the string into PRInt32, return error
if (NS_FAILED(err))
return NS_ERROR_ILLEGAL_VALUE;
// current charset have a lower priority
if (kCharsetFromMetaTag > src)
{
nsCAutoString newCharset;
- newCharset.AssignWithConversion(values->StringAt(0)->get());
+ newCharset.AssignWithConversion(values->ElementAt(0).get());
nsCAutoString preferred;
res = mAlias->GetPreferred(newCharset,
preferred);
if (NS_SUCCEEDED(res))
{
// compare against the current charset,
// also some charsets which should have been found in
// the BOM detection.
- nsString* currentCharset = values->StringAt(numOfAttributes-3);
- if (!preferred.Equals(NS_LossyConvertUTF16toASCII(*currentCharset)) &&
+ const nsString& currentCharset = values->ElementAt(numOfAttributes-3);
+ if (!preferred.Equals(NS_LossyConvertUTF16toASCII(currentCharset)) &&
!preferred.EqualsLiteral("UTF-16") &&
!preferred.EqualsLiteral("UTF-16BE") &&
!preferred.EqualsLiteral("UTF-16LE") &&
!preferred.EqualsLiteral("UTF-32") &&
!preferred.EqualsLiteral("UTF-32BE") &&
!preferred.EqualsLiteral("UTF-32LE"))
AppendASCIItoUTF16(preferred, aCharset);
}
--- a/intl/chardet/src/nsMetaCharsetObserver.h
+++ b/intl/chardet/src/nsMetaCharsetObserver.h
@@ -38,16 +38,17 @@
#define nsMetaCharsetObserverFactory_h__
#include "nsIFactory.h"
#include "nsIMetaCharsetService.h"
#include "nsIElementObserver.h"
#include "nsIObserver.h"
#include "nsObserverBase.h"
#include "nsWeakReference.h"
+#include "nsTArray.h"
//==========================================================================
//
// Class declaration for the class
//
//==========================================================================
class nsMetaCharsetObserver: public nsIElementObserver,
public nsIObserver,
@@ -71,18 +72,18 @@ public:
NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag, PRUint32 numOfAttributes,
const PRUnichar* nameArray[], const PRUnichar* valueArray[]);
NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag, PRUint32 numOfAttributes,
const PRUnichar* nameArray[], const PRUnichar* valueArray[]);
NS_IMETHOD Notify(nsISupports* aWebShell,
nsISupports* aChannel,
const PRUnichar* aTag,
- const nsStringArray* keys,
- const nsStringArray* values,
+ const nsTArray<nsString>* keys,
+ const nsTArray<nsString>* values,
const PRUint32 aFlags);
NS_DECL_ISUPPORTS
/* methode for nsIObserver */
NS_DECL_NSIOBSERVER
/* methode for nsIMetaCharsetService */
@@ -91,21 +92,21 @@ public:
private:
NS_IMETHOD Notify(PRUint32 aDocumentID, PRUint32 numOfAttributes,
const PRUnichar* nameArray[], const PRUnichar* valueArray[]);
NS_IMETHOD Notify(nsISupports* aWebShell,
nsISupports* aChannel,
- const nsStringArray* keys,
- const nsStringArray* values);
+ const nsTArray<nsString>* keys,
+ const nsTArray<nsString>* values);
- NS_IMETHOD GetCharsetFromCompatibilityTag(const nsStringArray* keys,
- const nsStringArray* values,
+ NS_IMETHOD GetCharsetFromCompatibilityTag(const nsTArray<nsString>* keys,
+ const nsTArray<nsString>* values,
nsAString& aCharset);
nsCOMPtr<nsICharsetAlias> mAlias;
PRBool bMetaCharsetObserverStarted;
};
#endif // nsMetaCharsetObserverFactory_h__
--- a/intl/chardet/src/nsXMLEncodingObserver.h
+++ b/intl/chardet/src/nsXMLEncodingObserver.h
@@ -39,16 +39,17 @@
#include "nsIFactory.h"
#include "nsIXMLEncodingService.h"
#include "nsIElementObserver.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsObserverBase.h"
#include "nsWeakReference.h"
+#include "nsTArray.h"
class nsXMLEncodingObserver: public nsIElementObserver,
public nsIObserver,
public nsObserverBase,
public nsIXMLEncodingService,
public nsSupportsWeakReference {
public:
nsXMLEncodingObserver();
@@ -66,18 +67,18 @@ public:
*/
NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag, PRUint32 numOfAttributes,
const PRUnichar* nameArray[], const PRUnichar* valueArray[]);
NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag, PRUint32 numOfAttributes,
const PRUnichar* nameArray[], const PRUnichar* valueArray[]);
NS_IMETHOD Notify(nsISupports* aWebShell,
nsISupports* aChannel,
const PRUnichar* aTag,
- const nsStringArray* keys,
- const nsStringArray* values,
+ const nsTArray<nsString>* keys,
+ const nsTArray<nsString>* values,
const PRUint32 aFlags)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_DECL_ISUPPORTS
/* methode for nsIObserver */
NS_DECL_NSIOBSERVER
--- a/intl/locale/src/nsLocale.cpp
+++ b/intl/locale/src/nsLocale.cpp
@@ -73,36 +73,35 @@ nsLocale::nsLocale(nsLocale* other) : fH
//
// enumerate Hash and copy
//
PL_HashTableEnumerateEntries(other->fHashtable,
&nsLocale::Hash_EnumerateCopy, fHashtable);
}
-nsLocale::nsLocale(const nsStringArray& categoryList,
- const nsStringArray& valueList)
+nsLocale::nsLocale(const nsTArray<nsString>& categoryList,
+ const nsTArray<nsString>& valueList)
: fHashtable(NULL), fCategoryCount(0)
{
- PRInt32 i;
PRUnichar* key, *value;
fHashtable = PL_NewHashTable(LOCALE_HASH_SIZE,&nsLocale::Hash_HashFunction,
&nsLocale::Hash_CompareNSString,
&nsLocale::Hash_CompareNSString,
NULL, NULL);
NS_ASSERTION(fHashtable, "nsLocale: failed to allocate PR_Hashtable");
if (fHashtable)
{
- for(i=0; i < categoryList.Count(); ++i)
+ for(PRUint32 i=0; i < categoryList.Length(); ++i)
{
- key = ToNewUnicode(*categoryList.StringAt(i));
+ key = ToNewUnicode(categoryList[i]);
NS_ASSERTION(key, "nsLocale: failed to allocate internal hash key");
- value = ToNewUnicode(*valueList.StringAt(i));
+ value = ToNewUnicode(valueList[i]);
NS_ASSERTION(value, "nsLocale: failed to allocate internal hash value");
if (!PL_HashTableAdd(fHashtable,key,value)) {
nsMemory::Free(key);
nsMemory::Free(value);
}
}
}
}
--- a/intl/locale/src/nsLocale.h
+++ b/intl/locale/src/nsLocale.h
@@ -48,28 +48,27 @@
* Date Modified by Description of modification
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
* use in OS2
*/
#ifndef nsLocale_h__
#define nsLocale_h__
#include "nsString.h"
+#include "nsTArray.h"
#include "nsILocale.h"
#include "plhash.h"
-class nsStringArray;
-
class nsLocale : public nsILocale {
friend class nsLocaleService;
NS_DECL_ISUPPORTS
public:
nsLocale(void);
- nsLocale(const nsStringArray& categoryList, const nsStringArray& valueList);
+ nsLocale(const nsTArray<nsString>& categoryList, const nsTArray<nsString>& valueList);
nsLocale(nsLocale* other);
virtual ~nsLocale(void);
/* Declare methods from nsILocale */
NS_DECL_NSILOCALE
protected:
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -74,17 +74,16 @@ class nsIFrame;
class nsPresContext;
class nsStyleSet;
class nsIViewManager;
class nsIDeviceContext;
class nsIRenderingContext;
class nsIPageSequenceFrame;
class nsString;
class nsAString;
-class nsStringArray;
class nsCaret;
class nsStyleContext;
class nsFrameSelection;
class nsFrameManager;
class nsILayoutHistoryState;
class nsIReflowCallback;
class nsISupportsArray;
class nsIDOMNode;
--- a/layout/mathml/base/src/nsMathMLChar.cpp
+++ b/layout/mathml/base/src/nsMathMLChar.cpp
@@ -215,32 +215,32 @@ class nsGlyphTable {
public:
explicit nsGlyphTable(const nsString& aPrimaryFontName)
: mType(NS_TABLE_TYPE_UNICODE),
mFontName(1), // ensure space for primary font name.
mState(NS_TABLE_STATE_EMPTY),
mCharCache(0)
{
MOZ_COUNT_CTOR(nsGlyphTable);
- mFontName.AppendString(aPrimaryFontName);
+ mFontName.AppendElement(aPrimaryFontName);
}
~nsGlyphTable() // not a virtual destructor: this class is not intended to be subclassed
{
MOZ_COUNT_DTOR(nsGlyphTable);
}
const nsAString& PrimaryFontName() const
{
- return *mFontName.StringAt(0);
+ return mFontName[0];
}
const nsAString& FontNameFor(const nsGlyphCode& aGlyphCode) const
{
- return *mFontName.StringAt(aGlyphCode.font);
+ return mFontName[aGlyphCode.font];
}
// True if this table contains some glyphs (variants and/or parts)
// or contains child chars that can be used to render this char
PRBool Has(nsPresContext* aPresContext, nsMathMLChar* aChar);
// True if this table contains variants of larger sizes to render this char
PRBool HasVariantsOf(nsPresContext* aPresContext, nsMathMLChar* aChar);
@@ -281,17 +281,17 @@ private:
nsGlyphCode ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint32 aPosition);
// The type is either NS_TABLE_TYPE_UNICODE or NS_TABLE_TYPE_GLYPH_INDEX
PRInt32 mType;
// mFontName[0] is the primary font associated to this table. The others
// are possible "external" fonts for glyphs not in the primary font
// but which are needed to stretch certain characters in the table
- nsStringArray mFontName;
+ nsTArray<nsString> mFontName;
// Tri-state variable for error/empty/ready
PRInt32 mState;
// The set of glyph data in this table, as provided by the MathFont Property File
nsCOMPtr<nsIPersistentProperties> mGlyphProperties;
// For speedy re-use, we always cache the last data used in the table.
@@ -315,21 +315,21 @@ private:
};
nsGlyphCode
nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint32 aPosition)
{
if (mState == NS_TABLE_STATE_ERROR) return kNullGlyph;
// Load glyph properties if this is the first time we have been here
if (mState == NS_TABLE_STATE_EMPTY) {
- nsresult rv = LoadProperties(*mFontName[0], mGlyphProperties);
+ nsresult rv = LoadProperties(mFontName[0], mGlyphProperties);
#ifdef NS_DEBUG
nsCAutoString uriStr;
uriStr.AssignLiteral("resource://gre/res/fonts/mathfont");
- LossyAppendUTF16toASCII(*mFontName[0], uriStr);
+ LossyAppendUTF16toASCII(mFontName[0], uriStr);
uriStr.StripWhitespace(); // that may come from mFontName
uriStr.AppendLiteral(".properties");
printf("Loading %s ... %s\n",
uriStr.get(),
(NS_FAILED(rv)) ? "Failed" : "Done");
#endif
if (NS_FAILED(rv)) {
mState = NS_TABLE_STATE_ERROR; // never waste time with this table again
@@ -341,17 +341,17 @@ nsGlyphTable::ElementAt(nsPresContext* a
nsCAutoString key;
nsAutoString value;
for (PRInt32 i = 1; ; i++) {
key.AssignLiteral("external.");
key.AppendInt(i, 10);
rv = mGlyphProperties->GetStringProperty(key, value);
if (NS_FAILED(rv)) break;
Clean(value);
- mFontName.AppendString(value); // i.e., mFontName[i] holds this font name
+ mFontName.AppendElement(value); // i.e., mFontName[i] holds this font name
}
}
// If aChar is a child char to be used by a parent composite char, make
// sure that it is really attached to this table
if (aChar->mParent && (aChar->mGlyphTable != this)) return kNullGlyph;
// Update our cache if it is not associated to this character
@@ -405,24 +405,22 @@ nsGlyphTable::ElementAt(nsPresContext* a
#endif
// See if an external font is needed for the code point.
// Limit of 9 external fonts
if (i+1 < length && value[i] == PRUnichar('@') &&
value[i+1] >= PRUnichar('0') && value[i+1] <= PRUnichar('9')) {
++i;
font = value[i] - '0';
++i;
- if (font >= mFontName.Count()) {
+ if (font >= mFontName.Length()) {
NS_ERROR("Non-existant font referenced in glyph table");
return kNullGlyph;
}
// The char cannot be handled if this font is not installed
- nsAutoString fontName;
- mFontName.StringAt(font, fontName);
- if (!fontName.Length() || !CheckFontExistence(aPresContext, fontName)) {
+ if (!mFontName[font].Length() || !CheckFontExistence(aPresContext, mFontName[font])) {
return kNullGlyph;
}
}
buffer.Append(code);
buffer.Append(font);
++j;
}
// update our cache with the new settings
@@ -1563,17 +1561,16 @@ nsMathMLChar::StretchInternal(nsPresCont
if (mOperator >= 0) {
// mOperator is initialized in SetData() and remains unchanged
direction = nsMathMLOperators::GetStretchyDirectionAt(mOperator);
}
// Set default font and get the default bounding metrics
// mStyleContext is a leaf context used only when stretching happens.
// For the base size, the default font should come from the parent context
- nsAutoString fontName;
nsFont font = mStyleContext->GetParent()->GetStyleFont()->mFont;
// Override with specific fonts if applicable for this character
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
nsAutoString families;
if (GetFontExtensionPref(prefBranch, mData[0], eExtension_base, families)) {
font.name = families;
}
@@ -2087,17 +2084,16 @@ nsMathMLChar::PaintForeground(nsPresCont
nscolor fgColor = styleContext->GetStyleColor()->mColor;
if (aIsSelected) {
// get color to use for selection from the look&feel object
aPresContext->LookAndFeel()->
GetColor(nsILookAndFeel::eColor_TextSelectForeground, fgColor);
}
aRenderingContext.SetColor(fgColor);
- nsAutoString fontName;
nsFont theFont(styleContext->GetStyleFont()->mFont);
if (! mFamily.IsEmpty()) {
theFont.name = mFamily;
}
aRenderingContext.SetFont(theFont, nsnull, aPresContext->GetUserFontSet());
if (NS_STRETCH_DIRECTION_UNSUPPORTED == mDirection) {
// normal drawing if there is nothing special about this char ...
--- a/layout/mathml/content/src/nsMathMLOperators.cpp
+++ b/layout/mathml/content/src/nsMathMLOperators.cpp
@@ -36,16 +36,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsHashtable.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsIComponentManager.h"
#include "nsIPersistentProperties2.h"
#include "nsNetUtil.h"
#include "nsCRT.h"
#include "nsMathMLOperators.h"
@@ -76,17 +77,17 @@ struct OperatorData {
*/
static OperatorData* gOperatorFound[4];
static PRInt32 gTableRefCount = 0;
static PRInt32 gOperatorCount = 0;
static OperatorData* gOperatorArray = nsnull;
static nsHashtable* gOperatorTable = nsnull;
static nsVoidArray* gStretchyOperatorArray = nsnull;
-static nsStringArray* gInvariantCharArray = nsnull;
+static nsTArray<nsString>* gInvariantCharArray = nsnull;
static PRBool gInitialized = PR_FALSE;
static const PRUnichar kNullCh = PRUnichar('\0');
static const PRUnichar kDashCh = PRUnichar('#');
static const PRUnichar kEqualCh = PRUnichar('=');
static const PRUnichar kColonCh = PRUnichar(':');
static const char* const kMathVariant_name[] = {
@@ -302,17 +303,17 @@ InitOperators(void)
if (NS_FAILED(rv)) return rv;
// Get the list of invariant chars
for (PRInt32 i = 0; i < eMATHVARIANT_COUNT; ++i) {
nsCAutoString key(NS_LITERAL_CSTRING("mathvariant."));
key.Append(kMathVariant_name[i]);
nsAutoString value;
mathfontProp->GetStringProperty(key, value);
- gInvariantCharArray->AppendString(value); // i.e., gInvariantCharArray[i] holds this list
+ gInvariantCharArray->AppendElement(value); // i.e., gInvariantCharArray[i] holds this list
}
// Parse the Operator Dictionary in two passes.
// The first pass is to count the number of operators; the second pass is to
// allocate the necessary space for them and to add them in the hash table.
for (PRInt32 pass = 1; pass <= 2; pass++) {
OperatorData dummyData;
OperatorData* operatorData = &dummyData;
@@ -371,17 +372,17 @@ InitOperators(void)
return NS_OK;
}
nsresult
InitGlobals()
{
gInitialized = PR_TRUE;
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
- gInvariantCharArray = new nsStringArray();
+ gInvariantCharArray = new nsTArray<nsString>();
gStretchyOperatorArray = new nsVoidArray();
if (gInvariantCharArray && gStretchyOperatorArray) {
gOperatorTable = new nsHashtable();
if (gOperatorTable) {
rv = InitOperators();
}
}
if (NS_FAILED(rv))
@@ -615,21 +616,21 @@ nsMathMLOperators::DisableStretchyOperat
/* static */ eMATHVARIANT
nsMathMLOperators::LookupInvariantChar(const nsAString& aChar)
{
if (!gInitialized) {
InitGlobals();
}
if (gInvariantCharArray) {
- for (PRInt32 i = gInvariantCharArray->Count()-1; i >= 0; --i) {
- nsString* list = gInvariantCharArray->StringAt(i);
+ for (PRUint32 i = gInvariantCharArray->Length()-1; i >= 0; --i) {
+ const nsString& list = gInvariantCharArray->ElementAt(i);
nsString::const_iterator start, end;
- list->BeginReading(start);
- list->EndReading(end);
+ list.BeginReading(start);
+ list.EndReading(end);
// Style-invariant characters are at offset 3*j + 1.
if (FindInReadable(aChar, start, end) &&
start.size_backward() % 3 == 1) {
return eMATHVARIANT(i);
}
}
}
return eMATHVARIANT_NONE;
@@ -638,21 +639,21 @@ nsMathMLOperators::LookupInvariantChar(c
/* static */ const nsDependentSubstring
nsMathMLOperators::TransformVariantChar(const PRUnichar& aChar,
eMATHVARIANT aVariant)
{
if (!gInitialized) {
InitGlobals();
}
if (gInvariantCharArray) {
- nsString* list = gInvariantCharArray->StringAt(aVariant);
- PRInt32 index = list->FindChar(aChar);
+ nsString list = gInvariantCharArray->ElementAt(aVariant);
+ PRInt32 index = list.FindChar(aChar);
// BMP characters are at offset 3*j
- if (index != kNotFound && index % 3 == 0 && list->Length() - index >= 2 ) {
+ if (index != kNotFound && index % 3 == 0 && list.Length() - index >= 2 ) {
// The style-invariant character is the next character
// (and list should contain padding if the next character is in the BMP).
++index;
- PRUint32 len = NS_IS_HIGH_SURROGATE(list->CharAt(index)) ? 2 : 1;
- return nsDependentSubstring(*list, index, len);
+ PRUint32 len = NS_IS_HIGH_SURROGATE(list.CharAt(index)) ? 2 : 1;
+ return nsDependentSubstring(list, index, len);
}
}
return nsDependentSubstring(&aChar, &aChar + 1);
}
--- a/parser/htmlparser/public/nsIElementObserver.h
+++ b/parser/htmlparser/public/nsIElementObserver.h
@@ -44,16 +44,17 @@
#ifndef nsIElementObserver_h__
#define nsIElementObserver_h__
#include "nsISupports.h"
#include "prtypes.h"
#include "nsHTMLTags.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
// {4672AA04-F6AE-11d2-B3B7-00805F8A6670}
#define NS_IELEMENTOBSERVER_IID \
{ 0x4672aa04, 0xf6ae, 0x11d2, { 0xb3, 0xb7, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
class nsIElementObserver : public nsISupports {
@@ -75,18 +76,18 @@ public:
NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag,
PRUint32 numOfAttributes, const PRUnichar* nameArray[],
const PRUnichar* valueArray[]) = 0;
NS_IMETHOD Notify(nsISupports* aWebShell,
nsISupports* aChannel,
const PRUnichar* aTag,
- const nsStringArray* aKeys,
- const nsStringArray* aValues,
+ const nsTArray<nsString>* aKeys,
+ const nsTArray<nsString>* aValues,
const PRUint32 aFlags) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIElementObserver, NS_IELEMENTOBSERVER_IID)
#define NS_HTMLPARSER_VALID_META_CHARSET NS_ERROR_GENERATE_SUCCESS( \
NS_ERROR_MODULE_HTMLPARSER,3000)
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -52,16 +52,17 @@
#include "nsDTDUtils.h"
#include "nsHTMLTokenizer.h"
#include "nsTime.h"
#include "nsParserNode.h"
#include "nsHTMLEntities.h"
#include "nsLinebreakConverter.h"
#include "nsIFormProcessor.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "prmem.h"
#include "nsIServiceManager.h"
#ifdef NS_DEBUG
#include "nsLoggingSink.h"
#endif
@@ -1225,44 +1226,42 @@ CNavDTD::HandleKeyGen(nsIParserNode* aNo
nsCOMPtr<nsIFormProcessor> theFormProcessor =
do_GetService(kFormProcessorCID, &result);
if (NS_FAILED(result)) {
return result;
}
PRInt32 theAttrCount = aNode->GetAttributeCount();
- nsStringArray theContent;
+ nsTArray<nsString> theContent;
nsAutoString theAttribute;
nsAutoString theFormType;
CToken* theToken = nsnull;
theFormType.AssignLiteral("select");
result = theFormProcessor->ProvideContent(theFormType, theContent,
theAttribute);
if (NS_FAILED(result)) {
return result;
}
- nsString* theTextValue = nsnull;
PRInt32 theIndex = nsnull;
// Populate the tokenizer with the fabricated elements in the reverse
// order such that <SELECT> is on the top fo the tokenizer followed by
// <OPTION>s and </SELECT>.
theToken = mTokenAllocator->CreateTokenOfType(eToken_end,
eHTMLTag_select);
NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
mTokenizer->PushTokenFront(theToken);
- for (theIndex = theContent.Count()-1; theIndex > -1; --theIndex) {
- theTextValue = theContent[theIndex];
+ for (theIndex = theContent.Length()-1; theIndex > -1; --theIndex) {
theToken = mTokenAllocator->CreateTokenOfType(eToken_text,
eHTMLTag_text,
- *theTextValue);
+ theContent[theIndex]);
NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
mTokenizer->PushTokenFront(theToken);
theToken = mTokenAllocator->CreateTokenOfType(eToken_start,
eHTMLTag_option);
NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
mTokenizer->PushTokenFront(theToken);
}
--- a/parser/htmlparser/src/nsDTDUtils.cpp
+++ b/parser/htmlparser/src/nsDTDUtils.cpp
@@ -1070,39 +1070,39 @@ nsObserverEntry::Notify(nsIParserNode* a
PRInt32 theCharsetSource;
nsCAutoString charset;
aParser->GetDocumentCharset(charset,theCharsetSource);
NS_ConvertASCIItoUTF16 theCharsetValue(charset);
PRInt32 theAttrCount = aNode->GetAttributeCount();
PRInt32 theObserversCount = theObservers->Count();
if (0 < theObserversCount){
- nsStringArray keys(theAttrCount+4), values(theAttrCount+4);
+ nsTArray<nsString> keys(theAttrCount + 4), values(theAttrCount + 4);
// XXX this and the following code may be a performance issue.
// Every key and value is copied and added to an voidarray (causing at
// least 2 allocations for mImpl, usually more, plus at least 1 per
// string (total = 2*(keys+3) + 2(or more) array allocations )).
PRInt32 index;
for (index = 0; index < theAttrCount; ++index) {
- keys.AppendString(aNode->GetKeyAt(index));
- values.AppendString(aNode->GetValueAt(index));
+ keys.AppendElement(aNode->GetKeyAt(index));
+ values.AppendElement(aNode->GetValueAt(index));
}
nsAutoString intValue;
- keys.AppendString(NS_LITERAL_STRING("charset"));
- values.AppendString(theCharsetValue);
+ keys.AppendElement(NS_LITERAL_STRING("charset"));
+ values.AppendElement(theCharsetValue);
- keys.AppendString(NS_LITERAL_STRING("charsetSource"));
+ keys.AppendElement(NS_LITERAL_STRING("charsetSource"));
intValue.AppendInt(PRInt32(theCharsetSource),10);
- values.AppendString(intValue);
+ values.AppendElement(intValue);
- keys.AppendString(NS_LITERAL_STRING("X_COMMAND"));
- values.AppendString(NS_LITERAL_STRING("text/html"));
+ keys.AppendElement(NS_LITERAL_STRING("X_COMMAND"));
+ values.AppendElement(NS_LITERAL_STRING("text/html"));
nsCOMPtr<nsIChannel> channel;
aParser->GetChannel(getter_AddRefs(channel));
for (index=0;index<theObserversCount;++index) {
nsIElementObserver* observer = static_cast<nsIElementObserver*>(theObservers->ElementAt(index));
if (observer) {
result = observer->Notify(aWebShell, channel,
--- a/security/manager/ssl/src/nsKeygenHandler.cpp
+++ b/security/manager/ssl/src/nsKeygenHandler.cpp
@@ -838,22 +838,22 @@ nsKeygenFormProcessor::ProcessValue(nsID
aValue, keyParamsValue);
}
}
return rv;
}
NS_METHOD nsKeygenFormProcessor::ProvideContent(const nsAString& aFormType,
- nsStringArray& aContent,
+ nsTArray<nsString>& aContent,
nsAString& aAttribute)
{
if (Compare(aFormType, NS_LITERAL_STRING("SELECT"),
nsCaseInsensitiveStringComparator()) == 0) {
for (size_t i = 0; i < number_of_key_size_choices; ++i) {
- aContent.AppendString(mSECKeySizeChoiceList[i].name);
+ aContent.AppendElement(mSECKeySizeChoiceList[i].name);
}
aAttribute.AssignLiteral("-mozilla-keygen");
}
return NS_OK;
}
--- a/security/manager/ssl/src/nsKeygenHandler.h
+++ b/security/manager/ssl/src/nsKeygenHandler.h
@@ -36,16 +36,18 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _NSKEYGENHANDLER_H_
#define _NSKEYGENHANDLER_H_
// Form Processor
#include "nsIFormProcessor.h"
+#include "nsVoidArray.h"
+#include "nsTArray.h"
nsresult GetSlotWithMechanism(PRUint32 mechanism,
nsIInterfaceRequestor *ctx,
PK11SlotInfo **retSlot);
#define DEFAULT_RSA_KEYGEN_PE 65537L
#define DEFAULT_RSA_KEYGEN_ALG SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION
@@ -57,17 +59,17 @@ public:
virtual ~nsKeygenFormProcessor();
nsresult Init();
NS_IMETHOD ProcessValue(nsIDOMHTMLElement *aElement,
const nsAString& aName,
nsAString& aValue);
NS_IMETHOD ProvideContent(const nsAString& aFormType,
- nsStringArray& aContent,
+ nsTArray<nsString>& aContent,
nsAString& aAttribute);
NS_DECL_ISUPPORTS
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
protected:
nsresult GetPublicKey(nsAString& aValue, nsAString& aChallenge,
nsAFlatString& akeyType, nsAString& aOutPublicKey,
--- a/storage/src/mozStorageStatementWrapper.cpp
+++ b/storage/src/mozStorageStatementWrapper.cpp
@@ -75,17 +75,17 @@ mozStorageStatementWrapper::Initialize(m
mStatement = static_cast<mozStorageStatement *>(aStatement);
// fetch various things we care about
mStatement->GetParameterCount(&mParamCount);
mStatement->GetColumnCount(&mResultColumnCount);
for (unsigned int i = 0; i < mResultColumnCount; i++) {
const void *name = sqlite3_column_name16 (NativeStatement(), i);
- mColumnNames.AppendString(nsDependentString(static_cast<const PRUnichar*>(name)));
+ mColumnNames.AppendElement(nsDependentString(static_cast<const PRUnichar*>(name)));
}
return NS_OK;
}
NS_IMETHODIMP
mozStorageStatementWrapper::GetStatement(mozIStorageStatement **aStatement)
{
--- a/storage/src/mozStorageStatementWrapper.h
+++ b/storage/src/mozStorageStatementWrapper.h
@@ -39,16 +39,17 @@
#ifndef _MOZSTORAGESTATEMENTWRAPPER_H_
#define _MOZSTORAGESTATEMENTWRAPPER_H_
#include "mozStorageStatement.h"
#include "mozIStorageStatementWrapper.h"
#include "nsIXPCScriptable.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "sqlite3.h"
/***
*** mozStorageStatementWrapper
***/
class mozStorageStatementWrapper : public mozIStorageStatementWrapper,
@@ -69,15 +70,15 @@ protected:
sqlite3_stmt* NativeStatement() {
return mStatement->GetNativeStatementPointer();
}
// note: pointer to the concrete statement
nsRefPtr<mozStorageStatement> mStatement;
PRUint32 mParamCount;
PRUint32 mResultColumnCount;
- nsStringArray mColumnNames;
+ nsTArray<nsString> mColumnNames;
nsCOMPtr<mozIStorageStatementRow> mStatementRow;
nsCOMPtr<mozIStorageStatementParams> mStatementParams;
};
#endif /* _MOZSTORAGESTATEMENTWRAPPER_H_ */
--- a/toolkit/components/autocomplete/src/nsAutoCompleteSimpleResult.cpp
+++ b/toolkit/components/autocomplete/src/nsAutoCompleteSimpleResult.cpp
@@ -105,116 +105,105 @@ nsAutoCompleteSimpleResult::SetErrorDesc
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::AppendMatch(const nsAString& aValue,
const nsAString& aComment,
const nsAString& aImage,
const nsAString& aStyle)
{
- NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
+ CheckInvariants();
- if (! mValues.AppendString(aValue))
+ if (! mValues.AppendElement(aValue))
return NS_ERROR_OUT_OF_MEMORY;
- if (! mComments.AppendString(aComment)) {
- mValues.RemoveStringAt(mValues.Count() - 1);
+ if (! mComments.AppendElement(aComment)) {
+ mValues.RemoveElementAt(mValues.Length() - 1);
return NS_ERROR_OUT_OF_MEMORY;
}
- if (! mImages.AppendString(aImage)) {
- mValues.RemoveStringAt(mValues.Count() - 1);
- mComments.RemoveStringAt(mComments.Count() - 1);
+ if (! mImages.AppendElement(aImage)) {
+ mValues.RemoveElementAt(mValues.Length() - 1);
+ mComments.RemoveElementAt(mComments.Length() - 1);
return NS_ERROR_OUT_OF_MEMORY;
}
- if (! mStyles.AppendString(aStyle)) {
- mValues.RemoveStringAt(mValues.Count() - 1);
- mComments.RemoveStringAt(mComments.Count() - 1);
- mImages.RemoveStringAt(mImages.Count() - 1);
+ if (! mStyles.AppendElement(aStyle)) {
+ mValues.RemoveElementAt(mValues.Length() - 1);
+ mComments.RemoveElementAt(mComments.Length() - 1);
+ mImages.RemoveElementAt(mImages.Length() - 1);
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::GetMatchCount(PRUint32 *aMatchCount)
{
- NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
+ CheckInvariants();
- *aMatchCount = mValues.Count();
+ *aMatchCount = mValues.Length();
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::GetValueAt(PRInt32 aIndex, nsAString& _retval)
{
- NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mValues.Count(),
+ NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mValues.Length()),
NS_ERROR_ILLEGAL_VALUE);
- NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
- mValues.StringAt(aIndex, _retval);
+ CheckInvariants();
+
+ _retval = mValues[aIndex];
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::GetCommentAt(PRInt32 aIndex, nsAString& _retval)
{
- NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mComments.Count(),
+ NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mComments.Length()),
NS_ERROR_ILLEGAL_VALUE);
- NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
- mComments.StringAt(aIndex, _retval);
+ CheckInvariants();
+ _retval = mComments[aIndex];
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::GetImageAt(PRInt32 aIndex, nsAString& _retval)
{
- NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mImages.Count(),
+ NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mImages.Length()),
NS_ERROR_ILLEGAL_VALUE);
- NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
- mImages.StringAt(aIndex, _retval);
+ CheckInvariants();
+ _retval = mImages[aIndex];
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::GetStyleAt(PRInt32 aIndex, nsAString& _retval)
{
- NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mStyles.Count(),
+ NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mStyles.Length()),
NS_ERROR_ILLEGAL_VALUE);
- NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
- NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
- mStyles.StringAt(aIndex, _retval);
+ CheckInvariants();
+ _retval = mStyles[aIndex];
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::SetListener(nsIAutoCompleteSimpleResultListener* aListener)
{
mListener = aListener;
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteSimpleResult::RemoveValueAt(PRInt32 aRowIndex,
PRBool aRemoveFromDb)
{
- NS_ENSURE_TRUE(aRowIndex >= 0 && aRowIndex < mValues.Count(),
+ NS_ENSURE_TRUE(aRowIndex >= 0 && aRowIndex < PRInt32(mValues.Length()),
NS_ERROR_ILLEGAL_VALUE);
- nsAutoString removedValue(*mValues.StringAt(aRowIndex));
- mValues.RemoveStringAt(aRowIndex);
- mComments.RemoveStringAt(aRowIndex);
- mImages.RemoveStringAt(aRowIndex);
- mStyles.RemoveStringAt(aRowIndex);
+ nsAutoString removedValue(mValues[aRowIndex]);
+ mValues.RemoveElementAt(aRowIndex);
+ mComments.RemoveElementAt(aRowIndex);
+ mImages.RemoveElementAt(aRowIndex);
+ mStyles.RemoveElementAt(aRowIndex);
if (mListener)
mListener->OnValueRemoved(this, removedValue, aRemoveFromDb);
return NS_OK;
}
--- a/toolkit/components/autocomplete/src/nsAutoCompleteSimpleResult.h
+++ b/toolkit/components/autocomplete/src/nsAutoCompleteSimpleResult.h
@@ -40,38 +40,44 @@
#include "nsIAutoCompleteResult.h"
#include "nsIAutoCompleteSimpleResult.h"
#include "nsVoidArray.h"
#include "nsString.h"
#include "prtypes.h"
#include "nsCOMPtr.h"
+#include "nsTArray.h"
class nsAutoCompleteSimpleResult : public nsIAutoCompleteSimpleResult
{
public:
nsAutoCompleteSimpleResult();
+ inline void CheckInvariants() {
+ NS_ASSERTION(mValues.Length() == mComments.Length(), "Arrays out of sync");
+ NS_ASSERTION(mValues.Length() == mImages.Length(), "Arrays out of sync");
+ NS_ASSERTION(mValues.Length() == mStyles.Length(), "Arrays out of sync");
+ }
NS_DECL_ISUPPORTS
NS_DECL_NSIAUTOCOMPLETERESULT
NS_DECL_NSIAUTOCOMPLETESIMPLERESULT
private:
~nsAutoCompleteSimpleResult() {}
protected:
// What we really want is an array of structs with value/comment/image/style contents.
// But then we'd either have to use COM or manage object lifetimes ourselves.
// Having four arrays of string simplifies this, but is stupid.
- nsStringArray mValues;
- nsStringArray mComments;
- nsStringArray mImages;
- nsStringArray mStyles;
+ nsTArray<nsString> mValues;
+ nsTArray<nsString> mComments;
+ nsTArray<nsString> mImages;
+ nsTArray<nsString> mStyles;
nsString mSearchString;
nsString mErrorDescription;
PRInt32 mDefaultIndex;
PRUint32 mSearchResult;
nsCOMPtr<nsIAutoCompleteSimpleResultListener> mListener;
};
--- a/toolkit/components/commandlines/src/nsCommandLine.cpp
+++ b/toolkit/components/commandlines/src/nsCommandLine.cpp
@@ -48,16 +48,17 @@
#include "nsCOMPtr.h"
#include "nsIGenericFactory.h"
#include "nsISupportsImpl.h"
#include "nsNativeCharsetUtils.h"
#include "nsNetUtil.h"
#include "nsUnicharUtils.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsXPCOMCID.h"
#include "plstr.h"
#ifdef XP_MACOSX
#include <CFURL.h>
#include "nsILocalFileMac.h"
#elif defined(XP_WIN)
#include <windows.h>
@@ -94,21 +95,21 @@ protected:
nsICommandLine* aThis,
void *aClosure);
void appendArg(const char* arg);
void resolveShortcutURL(nsILocalFile* aFile, nsACString& outURL);
nsresult EnumerateHandlers(EnumerateHandlersCallback aCallback, void *aClosure);
nsresult EnumerateValidators(EnumerateValidatorsCallback aCallback, void *aClosure);
- nsStringArray mArgs;
- PRUint32 mState;
- nsCOMPtr<nsIFile> mWorkingDir;
- nsCOMPtr<nsIDOMWindow> mWindowContext;
- PRBool mPreventDefault;
+ nsTArray<nsString> mArgs;
+ PRUint32 mState;
+ nsCOMPtr<nsIFile> mWorkingDir;
+ nsCOMPtr<nsIDOMWindow> mWindowContext;
+ PRBool mPreventDefault;
};
nsCommandLine::nsCommandLine() :
mState(STATE_INITIAL_LAUNCH),
mPreventDefault(PR_FALSE)
{
}
@@ -116,45 +117,43 @@ nsCommandLine::nsCommandLine() :
NS_IMPL_ISUPPORTS2_CI(nsCommandLine,
nsICommandLine,
nsICommandLineRunner)
NS_IMETHODIMP
nsCommandLine::GetLength(PRInt32 *aResult)
{
- *aResult = mArgs.Count();
+ *aResult = PRInt32(mArgs.Length());
return NS_OK;
}
NS_IMETHODIMP
nsCommandLine::GetArgument(PRInt32 aIndex, nsAString& aResult)
{
NS_ENSURE_ARG_MIN(aIndex, 0);
- NS_ENSURE_ARG_MAX(aIndex, mArgs.Count());
+ NS_ENSURE_ARG_MAX(aIndex, mArgs.Length());
- mArgs.StringAt(aIndex, aResult);
+ aResult = mArgs[aIndex];
return NS_OK;
}
NS_IMETHODIMP
nsCommandLine::FindFlag(const nsAString& aFlag, PRBool aCaseSensitive, PRInt32 *aResult)
{
NS_ENSURE_ARG(!aFlag.IsEmpty());
- PRInt32 f;
-
nsDefaultStringComparator caseCmp;
nsCaseInsensitiveStringComparator caseICmp;
nsStringComparator& c = aCaseSensitive ?
static_cast<nsStringComparator&>(caseCmp) :
static_cast<nsStringComparator&>(caseICmp);
- for (f = 0; f < mArgs.Count(); ++f) {
- const nsString &arg = *mArgs[f];
+ for (PRUint32 f = 0; f < mArgs.Length(); f++) {
+ const nsString &arg = mArgs[f];
if (arg.Length() >= 2 && arg.First() == PRUnichar('-')) {
if (aFlag.Equals(Substring(arg, 1), c)) {
*aResult = f;
return NS_OK;
}
}
}
@@ -162,20 +161,20 @@ 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.Count() - 1);
+ NS_ENSURE_ARG_MAX(aEnd, mArgs.Length() - 1);
for (PRInt32 i = aEnd; i >= aStart; --i) {
- mArgs.RemoveStringAt(i);
+ mArgs.RemoveElementAt(i);
}
return NS_OK;
}
NS_IMETHODIMP
nsCommandLine::HandleFlag(const nsAString& aFlag, PRBool aCaseSensitive,
PRBool *aResult)
@@ -207,27 +206,27 @@ nsCommandLine::HandleFlagWithParam(const
rv = FindFlag(aFlag, aCaseSensitive, &found);
NS_ENSURE_SUCCESS(rv, rv);
if (found == -1) {
aResult.SetIsVoid(PR_TRUE);
return NS_OK;
}
- if (found == mArgs.Count() - 1) {
+ if (found == PRInt32(mArgs.Length()) - 1) {
return NS_ERROR_INVALID_ARG;
}
++found;
- if (mArgs[found]->First() == '-') {
+ if (mArgs[found].First() == '-') {
return NS_ERROR_INVALID_ARG;
}
- mArgs.StringAt(found, aResult);
+ aResult = mArgs[found];
RemoveArguments(found - 1, found);
return NS_OK;
}
NS_IMETHODIMP
nsCommandLine::GetState(PRUint32 *aResult)
{
@@ -480,17 +479,17 @@ nsCommandLine::appendArg(const char* arg
nsAutoString warg;
#ifdef XP_WIN
CopyUTF8toUTF16(nsDependentCString(arg), warg);
#else
NS_CopyNativeToUnicode(nsDependentCString(arg), warg);
#endif
- mArgs.AppendString(warg);
+ mArgs.AppendElement(warg);
}
void
nsCommandLine::resolveShortcutURL(nsILocalFile* aFile, nsACString& outURL)
{
nsCOMPtr<nsIFileProtocolHandler> fph;
nsresult rv = NS_GetFileProtocolHandler(getter_AddRefs(fph));
if (NS_FAILED(rv))
--- a/toolkit/components/filepicker/src/nsFileView.cpp
+++ b/toolkit/components/filepicker/src/nsFileView.cpp
@@ -53,16 +53,17 @@
#include "nsDateTimeFormatCID.h"
#include "nsQuickSort.h"
#include "nsIAtom.h"
#include "nsIAutoCompleteResult.h"
#include "nsIAutoCompleteSearch.h"
#include "nsISimpleEnumerator.h"
#include "nsAutoPtr.h"
#include "nsIMutableArray.h"
+#include "nsTArray.h"
#include "nsWildCard.h"
#define NS_FILECOMPLETE_CID { 0xcb60980e, 0x18a5, 0x4a77, \
{ 0x91, 0x10, 0x81, 0x46, 0x61, 0x4c, 0xa7, 0xf0 } }
#define NS_FILECOMPLETE_CONTRACTID "@mozilla.org/autocomplete/search;1?name=file"
class nsFileResult : public nsIAutoCompleteResult
@@ -70,17 +71,17 @@ class nsFileResult : public nsIAutoCompl
public:
// aSearchString is the text typed into the autocomplete widget
// aSearchParam is the picker's currently displayed directory
nsFileResult(const nsAString& aSearchString, const nsAString& aSearchParam);
NS_DECL_ISUPPORTS
NS_DECL_NSIAUTOCOMPLETERESULT
- nsStringArray mValues;
+ nsTArray<nsString> mValues;
nsAutoString mSearchString;
PRUint16 mSearchResult;
};
NS_IMPL_ISUPPORTS1(nsFileResult, nsIAutoCompleteResult)
nsFileResult::nsFileResult(const nsAString& aSearchString,
const nsAString& aSearchParam):
@@ -110,17 +111,17 @@ nsFileResult::nsFileResult(const nsAStri
while (NS_SUCCEEDED(dirEntries->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> nextItem;
dirEntries->GetNext(getter_AddRefs(nextItem));
nsCOMPtr<nsILocalFile> nextFile(do_QueryInterface(nextItem));
nsAutoString fileName;
nextFile->GetLeafName(fileName);
if (StringBeginsWith(fileName, prefix)) {
fileName.Insert(parent, 0);
- mValues.AppendString(fileName);
+ mValues.AppendElement(fileName);
if (mSearchResult == RESULT_NOMATCH && fileName.Equals(mSearchString))
mSearchResult = RESULT_IGNORED;
else
mSearchResult = RESULT_SUCCESS;
}
}
mValues.Sort();
}
@@ -150,23 +151,23 @@ NS_IMETHODIMP nsFileResult::GetErrorDesc
{
aErrorDescription.Truncate();
return NS_OK;
}
NS_IMETHODIMP nsFileResult::GetMatchCount(PRUint32 *aMatchCount)
{
NS_ENSURE_ARG_POINTER(aMatchCount);
- *aMatchCount = mValues.Count();
+ *aMatchCount = mValues.Length();
return NS_OK;
}
NS_IMETHODIMP nsFileResult::GetValueAt(PRInt32 index, nsAString & aValue)
{
- mValues.StringAt(index, aValue);
+ aValue = mValues[index];
return NS_OK;
}
NS_IMETHODIMP nsFileResult::GetCommentAt(PRInt32 index, nsAString & aComment)
{
aComment.Truncate();
return NS_OK;
}
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -44,16 +44,17 @@
#include <stdio.h>
#include "nsNavHistory.h"
#include "nsNavBookmarks.h"
#include "nsAnnotationService.h"
#include "nsPlacesTables.h"
#include "nsIArray.h"
+#include "nsTArray.h"
#include "nsArrayEnumerator.h"
#include "nsCollationCID.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsDateTimeFormatCID.h"
#include "nsDebug.h"
#include "nsEnumeratorUtils.h"
#include "nsFaviconService.h"
@@ -243,17 +244,17 @@ NS_IMPL_CI_INTERFACE_GETTER5(
static nsresult GetReversedHostname(nsIURI* aURI, nsAString& host);
static void GetReversedHostname(const nsString& aForward, nsAString& aReversed);
static nsresult GenerateTitleFromURI(nsIURI* aURI, nsAString& aTitle);
static PRInt64 GetSimpleBookmarksQueryFolder(
const nsCOMArray<nsNavHistoryQuery>& aQueries,
nsNavHistoryQueryOptions* aOptions);
static void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
- nsTArray<nsStringArray*>* aTerms);
+ nsTArray<nsTArray<nsString>*>* aTerms);
inline void ReverseString(const nsString& aInput, nsAString& aReversed)
{
aReversed.Truncate(0);
for (PRInt32 i = aInput.Length() - 1; i >= 0; i --)
aReversed.Append(aInput[i]);
}
@@ -5918,17 +5919,17 @@ nsNavHistory::FilterResultSet(nsNavHisto
{
nsresult rv;
// get the bookmarks service
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
// parse the search terms
- nsTArray<nsStringArray*> terms;
+ nsTArray<nsTArray<nsString>*> terms;
ParseSearchTermsFromQueries(aQueries, &terms);
PRInt32 queryIndex;
PRUint16 resultType = aOptions->ResultType();
// The includeFolders array for each query is initialized with its
// query's folders array. We add sub-folders as we check items.
nsTArray< nsTArray<PRInt64>* > includeFolders;
@@ -5984,17 +5985,17 @@ nsNavHistory::FilterResultSet(nsNavHisto
if (aQueryNode->mItemId == aSet[nodeIndex]->mItemId)
continue;
rv = bookmarks->GetFolderIdForItem(aSet[nodeIndex]->mItemId, &parentId);
NS_ENSURE_SUCCESS(rv, rv);
}
// if we are excluding items by parent annotation,
// exclude items who's parent is a folder with that annotation
- if (!parentAnnotationToExclude.IsEmpty() && (parentFoldersToExclude.IndexOf(parentId) != -1))
+ if (!parentAnnotationToExclude.IsEmpty() && parentFoldersToExclude.Contains(parentId))
continue;
// Append the node if it matches one of the queries
PRBool appendNode = PR_FALSE;
for (queryIndex = 0;
queryIndex < aQueries.Count() && !appendNode; queryIndex++) {
// parent folder
// RESULTS_AS_TAG_CONTENTS changes bookmarks parent, so we must not filter
@@ -6002,36 +6003,36 @@ nsNavHistory::FilterResultSet(nsNavHisto
if (includeFolders[queryIndex]->Length() != 0 &&
resultType != nsINavHistoryQueryOptions::RESULTS_AS_TAG_CONTENTS) {
// filter out simple history nodes from bookmark queries
if (aSet[nodeIndex]->mItemId == -1)
continue;
// filter out the node of which their parent is in the exclude-folders
// cache
- if (excludeFolders[queryIndex]->IndexOf(parentId) != -1)
+ if (excludeFolders[queryIndex]->Contains(parentId))
continue;
- if (includeFolders[queryIndex]->IndexOf(parentId) == -1) {
+ if (!includeFolders[queryIndex]->Contains(parentId)) {
// check ancestors
PRInt64 ancestor = parentId, lastAncestor;
PRBool belongs = PR_FALSE;
nsTArray<PRInt64> ancestorFolders;
while (!belongs) {
// Avoid using |ancestor| itself if GetFolderIdForItem failed.
lastAncestor = ancestor;
ancestorFolders.AppendElement(ancestor);
// GetFolderIdForItems throws when called for the places-root
if (NS_FAILED(bookmarks->GetFolderIdForItem(ancestor,&ancestor))) {
break;
- } else if (excludeFolders[queryIndex]->IndexOf(ancestor) != -1) {
+ } else if (excludeFolders[queryIndex]->Contains(ancestor)) {
break;
- } else if (includeFolders[queryIndex]->IndexOf(ancestor) != -1) {
+ } else if (includeFolders[queryIndex]->Contains(ancestor)) {
belongs = PR_TRUE;
}
}
// if the parentId or any of its ancestors "belong",
// include all of them. otherwise, exclude all of them.
if (belongs) {
includeFolders[queryIndex]->AppendElements(ancestorFolders);
} else {
@@ -6060,24 +6061,24 @@ nsNavHistory::FilterResultSet(nsNavHisto
PRBool hasTag = PR_FALSE;
if (NS_SUCCEEDED(mDBGetTags->ExecuteStep(&hasTag)) && hasTag) {
rv = mDBGetTags->GetString(0, nodeTags);
NS_ENSURE_SUCCESS(rv, rv);
}
// Determine if every search term matches anywhere in the title, url, tag
PRBool matchAll = PR_TRUE;
- for (PRInt32 termIndex = terms[queryIndex]->Count(); --termIndex >= 0 &&
+ for (PRInt32 termIndex = terms[queryIndex]->Length(); --termIndex >= 0 &&
matchAll; ) {
- const nsString *term = terms[queryIndex]->StringAt(termIndex);
+ const nsString& term = terms[queryIndex]->ElementAt(termIndex);
// True if any of them match; false makes us quit the loop
- matchAll = CaseInsensitiveFindInReadable(*term, nodeTitle) ||
- CaseInsensitiveFindInReadable(*term, nodeURL) ||
- CaseInsensitiveFindInReadable(*term, nodeTags);
+ matchAll = CaseInsensitiveFindInReadable(term, nodeTitle) ||
+ CaseInsensitiveFindInReadable(term, nodeURL) ||
+ CaseInsensitiveFindInReadable(term, nodeTags);
}
// Skip if we don't match all terms in the title, url or tag
if (!matchAll)
continue;
appendNode = PR_TRUE;
}
@@ -6887,44 +6888,44 @@ GetSimpleBookmarksQueryFolder(const nsCO
// back.
inline PRBool isQueryWhitespace(PRUnichar ch)
{
return ch == ' ';
}
void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
- nsTArray<nsStringArray*>* aTerms)
+ nsTArray<nsTArray<nsString>*>* aTerms)
{
PRInt32 lastBegin = -1;
for (PRUint32 i=0; i < aQueries.Count(); i++) {
- nsStringArray *queryTerms = new nsStringArray();
+ nsTArray<nsString> *queryTerms = new nsTArray<nsString>();
PRBool hasSearchTerms;
if (NS_SUCCEEDED(aQueries[i]->GetHasSearchTerms(&hasSearchTerms)) &&
hasSearchTerms) {
const nsString& searchTerms = aQueries[i]->SearchTerms();
for (PRUint32 j = 0; j < searchTerms.Length(); j++) {
if (isQueryWhitespace(searchTerms[j]) ||
searchTerms[j] == '"') {
if (lastBegin >= 0) {
// found the end of a word
- queryTerms->AppendString(Substring(searchTerms, lastBegin,
+ queryTerms->AppendElement(Substring(searchTerms, lastBegin,
j - lastBegin));
lastBegin = -1;
}
} else {
if (lastBegin < 0) {
// found the beginning of a word
lastBegin = j;
}
}
}
// last word
if (lastBegin >= 0)
- queryTerms->AppendString(Substring(searchTerms, lastBegin));
+ queryTerms->AppendElement(Substring(searchTerms, lastBegin));
}
aTerms->AppendElement(queryTerms);
}
}
// GenerateTitleFromURI
//
--- a/toolkit/components/places/src/nsNavHistory.h
+++ b/toolkit/components/places/src/nsNavHistory.h
@@ -735,17 +735,17 @@ protected:
PRInt32 mAutoCompleteDefaultBehavior; // kAutoCompleteBehavior* bitmap
PRInt32 mAutoCompleteCurrentBehavior; // kAutoCompleteBehavior* bitmap
// Original search string for case-sensitive usage
nsString mOrigSearchString;
// Search string and tokens for case-insensitive matching
nsString mCurrentSearchString;
- nsStringArray mCurrentSearchTokens;
+ nsTArray<nsString> mCurrentSearchTokens;
void GenerateSearchTokens();
void AddSearchToken(nsAutoString &aToken);
void ProcessTokensForSpecialSearch();
#ifdef MOZ_XUL
nsresult AutoCompleteFeedback(PRInt32 aIndex,
nsIAutoCompleteController *aController);
--- a/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp
+++ b/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp
@@ -231,30 +231,30 @@ void GetAutoCompleteBaseQuery(nsACString
inline PRBool
StartsWithJS(const nsAString &aString)
{
return StringBeginsWith(aString, NS_LITERAL_STRING("javascript:"));
}
/**
* Callback function for putting URLs from a nsDataHashtable<nsStringHashKey,
- * PRBool> into a nsStringArray.
+ * PRBool> into a nsTArray<nsString>.
*
* @param aKey
* The hashtable entry's key (the url)
* @param aData
* Unused data
* @param aArg
- * The nsStringArray pointer for collecting URLs
+ * The nsTArray<nsString> pointer for collecting URLs
*/
PLDHashOperator
HashedURLsToArray(const nsAString &aKey, PRBool aData, void *aArg)
{
// Append the current url to the array of urls
- static_cast<nsStringArray *>(aArg)->AppendString(aKey);
+ static_cast<nsTArray<nsString> *>(aArg)->AppendElement(aKey);
return PL_DHASH_NEXT;
}
/**
* Returns true if the unicode character is a word boundary. I.e., anything
* that *isn't* used to build up a word from a string of characters. We are
* conservative here because anything that we don't list will be treated as
* word boundary. This means searching for that not-actually-a-word-boundary
@@ -565,17 +565,17 @@ nsNavHistory::PerformAutoComplete()
// if there is no listener, our search has been stopped
if (!mCurrentListener)
return NS_OK;
nsresult rv;
// Only do some extra searches on the first chunk
if (!mCurrentChunkOffset) {
// Only show keywords if there's a search
- if (mCurrentSearchTokens.Count()) {
+ if (mCurrentSearchTokens.Length()) {
rv = AutoCompleteKeywordSearch();
NS_ENSURE_SUCCESS(rv, rv);
}
// Get adaptive results first
rv = AutoCompleteAdaptiveSearch();
NS_ENSURE_SUCCESS(rv, rv);
}
@@ -752,22 +752,22 @@ nsNavHistory::StartSearch(const nsAStrin
") AS h "
"LEFT OUTER JOIN moz_favicons f ON f.id = h.favicon_id "
"ORDER BY h.frecency DESC");
rv = mDBConn->CreateStatement(sql, getter_AddRefs(mDBPreviousQuery));
NS_ENSURE_SUCCESS(rv, rv);
// Collect the previous result's URLs that we want to process
- nsStringArray urls;
+ nsTArray<nsString> urls;
(void)mCurrentResultURLs.EnumerateRead(HashedURLsToArray, &urls);
// Bind the parameters right away. We can only use the query once.
for (PRUint32 i = 0; i < prevMatchCount; i++) {
- rv = mDBPreviousQuery->BindStringParameter(i + 1, *urls[i]);
+ rv = mDBPreviousQuery->BindStringParameter(i + 1, urls[i]);
NS_ENSURE_SUCCESS(rv, rv);
}
// Use the same match behavior as the previous search
mCurrentMatchType = mPreviousMatchType;
}
} else {
// Clear out any previous result queries
@@ -857,55 +857,55 @@ nsNavHistory::GenerateSearchTokens()
AddSearchToken(lastMatch);
}
inline void
nsNavHistory::AddSearchToken(nsAutoString &aToken)
{
aToken.Trim("\r\n\t\b");
if (!aToken.IsEmpty())
- mCurrentSearchTokens.AppendString(aToken);
+ mCurrentSearchTokens.AppendElement(aToken);
}
void
nsNavHistory::ProcessTokensForSpecialSearch()
{
// Start with the default behavior
mAutoCompleteCurrentBehavior = mAutoCompleteDefaultBehavior;
// If we're searching only one of history or bookmark, we can use filters
if (mAutoCompleteSearchSources == SEARCH_HISTORY)
SET_BEHAVIOR(History);
else if (mAutoCompleteSearchSources == SEARCH_BOOKMARK)
SET_BEHAVIOR(Bookmark);
// SEARCH_BOTH doesn't require any filtering
// Determine which special searches to apply
- for (PRInt32 i = mCurrentSearchTokens.Count(); --i >= 0; ) {
+ for (PRInt32 i = PRInt32(mCurrentSearchTokens.Length()); --i >= 0;) {
PRBool needToRemove = PR_TRUE;
- const nsString *token = mCurrentSearchTokens.StringAt(i);
+ const nsString& token = mCurrentSearchTokens[i];
- if (token->Equals(mAutoCompleteRestrictHistory))
+ if (token.Equals(mAutoCompleteRestrictHistory))
SET_BEHAVIOR(History);
- else if (token->Equals(mAutoCompleteRestrictBookmark))
+ else if (token.Equals(mAutoCompleteRestrictBookmark))
SET_BEHAVIOR(Bookmark);
- else if (token->Equals(mAutoCompleteRestrictTag))
+ else if (token.Equals(mAutoCompleteRestrictTag))
SET_BEHAVIOR(Tag);
- else if (token->Equals(mAutoCompleteMatchTitle))
+ else if (token.Equals(mAutoCompleteMatchTitle))
SET_BEHAVIOR(Title);
- else if (token->Equals(mAutoCompleteMatchUrl))
+ else if (token.Equals(mAutoCompleteMatchUrl))
SET_BEHAVIOR(Url);
- else if (token->Equals(mAutoCompleteRestrictTyped))
+ else if (token.Equals(mAutoCompleteRestrictTyped))
SET_BEHAVIOR(Typed);
else
needToRemove = PR_FALSE;
// Remove the token if it's special search token
if (needToRemove)
- (void)mCurrentSearchTokens.RemoveStringAt(i);
+ mCurrentSearchTokens.RemoveElementAt(i);
}
// Search only typed pages in history for empty searches
if (mOrigSearchString.IsEmpty()) {
SET_BEHAVIOR(History);
SET_BEHAVIOR(Typed);
}
@@ -1114,31 +1114,31 @@ nsNavHistory::AutoCompleteProcessSearch(
(GET_BEHAVIOR(Bookmark) && !parentId) ||
(GET_BEHAVIOR(Tag) && entryTags.IsEmpty()));
// Unescape the url to search for unescaped terms
nsString entryURL = FixupURIText(escapedEntryURL);
// Determine if every token matches either the bookmark title, tags,
// page title, or page url
- for (PRInt32 i = 0; i < mCurrentSearchTokens.Count() && matchAll; i++) {
- const nsString *token = mCurrentSearchTokens.StringAt(i);
+ for (PRUint32 i = 0; i < mCurrentSearchTokens.Length() && matchAll; i++) {
+ const nsString& token = mCurrentSearchTokens[i];
// Check if the tags match the search term
- PRBool matchTags = (*tokenMatchesTarget)(*token, entryTags);
+ PRBool matchTags = (*tokenMatchesTarget)(token, entryTags);
// Check if the title matches the search term
- PRBool matchTitle = (*tokenMatchesTarget)(*token, title);
+ PRBool matchTitle = (*tokenMatchesTarget)(token, title);
// Make sure we match something in the title or tags if we have to
matchAll = matchTags || matchTitle;
if (GET_BEHAVIOR(Title) && !matchAll)
break;
// Check if the url matches the search term
- PRBool matchUrl = (*tokenMatchesTarget)(*token, entryURL);
+ PRBool matchUrl = (*tokenMatchesTarget)(token, entryURL);
// If we don't match the url when we have to, reset matchAll to
// false; otherwise keep track that we did match the current search
if (GET_BEHAVIOR(Url) && !matchUrl)
matchAll = PR_FALSE;
else
matchAll |= matchUrl;
}
--- a/tools/relic/test/relicense_inputs/need_to_relicense.h
+++ b/tools/relic/test/relicense_inputs/need_to_relicense.h
@@ -44,16 +44,17 @@
#include "nsString.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
+#include "nsTArray.h"
#define SPECIFIED_STYLE_TYPE 1
#define COMPUTED_STYLE_TYPE 2
class nsHTMLEditor;
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
const char * aDefaultValueString,
@@ -332,17 +333,17 @@ private:
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
- nsStringArray & cssValueArray,
+ nsTArray<nsString> & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
@@ -355,17 +356,17 @@ private:
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
- nsStringArray & aValueArray,
+ nsTArray<nsString> & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
--- a/tools/relic/test/relicense_inputs/npl.h
+++ b/tools/relic/test/relicense_inputs/npl.h
@@ -29,16 +29,17 @@
#include "nsString.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
+#include "nsTArray.h"
#define SPECIFIED_STYLE_TYPE 1
#define COMPUTED_STYLE_TYPE 2
class nsHTMLEditor;
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
const char * aDefaultValueString,
@@ -317,17 +318,17 @@ private:
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
- nsStringArray & cssValueArray,
+ nsTArray<nsString> & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
@@ -340,17 +341,17 @@ private:
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
- nsStringArray & aValueArray,
+ nsTArray<nsString> & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
--- a/tools/relic/test/relicense_outputs/need_to_relicense.h
+++ b/tools/relic/test/relicense_outputs/need_to_relicense.h
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLCSSUtils_h__
#define nsHTMLCSSUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
+#include "nsTArray.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
@@ -331,17 +332,17 @@ private:
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
- nsStringArray & cssValueArray,
+ nsTArray<nsString> & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
@@ -354,17 +355,17 @@ private:
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
- nsStringArray & aValueArray,
+ nsTArray<nsString> & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
--- a/tools/relic/test/relicense_outputs/npl.h
+++ b/tools/relic/test/relicense_outputs/npl.h
@@ -36,16 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLCSSUtils_h__
#define nsHTMLCSSUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
+#include "nsTArray.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
@@ -331,17 +332,17 @@ private:
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
- nsStringArray & cssValueArray,
+ nsTArray<nsString> & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
@@ -354,17 +355,17 @@ private:
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
- nsStringArray & aValueArray,
+ nsTArray<nsString> & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
--- a/widget/src/beos/nsDeviceContextSpecB.cpp
+++ b/widget/src/beos/nsDeviceContextSpecB.cpp
@@ -40,16 +40,17 @@
#include "nsDeviceContextSpecB.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "prenv.h" /* for PR_GetEnv */
#include "nsIServiceManager.h"
#include "nsReadableUtils.h"
#include "nsStringEnumerator.h"
+#include "nsTArray.h"
#include "nsCRT.h"
//----------------------------------------------------------------------------------
// The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecG
// The PrinterEnumerator creates the printer info
// but the nsDeviceContextSpecG cleans it up
// If it gets created (via the Page Setup Dialog) but the user never prints anything
// then it will never be delete, so this class takes care of that.
@@ -64,24 +65,24 @@ public:
PRBool PrintersAreAllocated() { return mGlobalPrinterList != nsnull; }
PRInt32 GetNumPrinters() { return mGlobalNumPrinters; }
nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
protected:
GlobalPrinters() {}
static GlobalPrinters mGlobalPrinters;
- static nsStringArray* mGlobalPrinterList;
+ static nsTArray<nsString>* mGlobalPrinterList;
static int mGlobalNumPrinters;
};
//---------------
// static members
GlobalPrinters GlobalPrinters::mGlobalPrinters;
-nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
+nsTArray<nsString>* GlobalPrinters::mGlobalPrinterList = nsnull;
int GlobalPrinters::mGlobalNumPrinters = 0;
nsDeviceContextSpecBeOS::nsDeviceContextSpecBeOS()
{
}
nsDeviceContextSpecBeOS::~nsDeviceContextSpecBeOS()
{
@@ -146,26 +147,26 @@ NS_IMETHODIMP nsPrinterEnumeratorBeOS::G
*aPrinterNameList = nsnull;
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
- nsStringArray *printers = new nsStringArray(numPrinters);
+ nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
if (!printers) {
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_OUT_OF_MEMORY;
}
int count = 0;
while( count < numPrinters )
{
- printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
+ printers->AppendElement(*GlobalPrinters::GetInstance()->GetStringAt(count++));
}
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
}
/* readonly attribute wstring defaultPrinterName; */
NS_IMETHODIMP nsPrinterEnumeratorBeOS::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName)
@@ -190,22 +191,22 @@ NS_IMETHODIMP nsPrinterEnumeratorBeOS::D
nsresult GlobalPrinters::InitializeGlobalPrinters ()
{
if (PrintersAreAllocated())
return NS_OK;
mGlobalNumPrinters = 0;
#ifdef USE_POSTSCRIPT
- mGlobalPrinterList = new nsStringArray();
+ mGlobalPrinterList = new nsTArray<nsString>();
if (!mGlobalPrinterList)
return NS_ERROR_OUT_OF_MEMORY;
/* add an entry for the default printer (see nsPostScriptObj.cpp) */
- mGlobalPrinterList->AppendString(
+ mGlobalPrinterList->AppendElement(
nsString(NS_ConvertASCIItoUTF16(NS_POSTSCRIPT_DRIVER_NAME "default")));
mGlobalNumPrinters++;
/* get the list of printers */
char *printerList = nsnull;
/* the env var MOZILLA_PRINTER_LIST can "override" the prefs */
printerList = PR_GetEnv("MOZILLA_PRINTER_LIST");
@@ -227,17 +228,17 @@ nsresult GlobalPrinters::InitializeGloba
printerList = strdup(printerList);
if (!printerList)
return NS_ERROR_OUT_OF_MEMORY;
for( name = PL_strtok_r(printerList, " ", &tok_lasts) ;
name != nsnull ;
name = PL_strtok_r(nsnull, " ", &tok_lasts) )
{
- mGlobalPrinterList->AppendString(
+ mGlobalPrinterList->AppendElement(
nsString(NS_ConvertASCIItoUTF16(NS_POSTSCRIPT_DRIVER_NAME)) +
nsString(NS_ConvertASCIItoUTF16(name)));
mGlobalNumPrinters++;
}
NS_Free(printerList);
}
#endif /* USE_POSTSCRIPT */
--- a/widget/src/cocoa/nsFilePicker.h
+++ b/widget/src/cocoa/nsFilePicker.h
@@ -43,16 +43,17 @@
#ifndef nsFilePicker_h_
#define nsFilePicker_h_
#include "nsBaseFilePicker.h"
#include "nsString.h"
#include "nsIFileChannel.h"
#include "nsILocalFile.h"
#include "nsCOMArray.h"
+#include "nsTArray.h"
class nsILocalFileMac;
@class NSArray;
/**
* Native Mac Cocoa FileSelector wrapper
*/
@@ -96,15 +97,15 @@ protected:
NSString *PanelDefaultDirectory();
NSView* GetAccessoryView();
nsString mTitle;
PRInt16 mMode;
nsCOMArray<nsILocalFile> mFiles;
nsString mDefault;
- nsStringArray mFilters;
- nsStringArray mTitles;
+ nsTArray<nsString> mFilters;
+ nsTArray<nsString> mTitles;
PRInt32 mSelectedTypeIndex;
};
#endif // nsFilePicker_h_
--- a/widget/src/cocoa/nsFilePicker.mm
+++ b/widget/src/cocoa/nsFilePicker.mm
@@ -120,22 +120,22 @@ 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.Count();
+ PRInt32 numMenuItems = mTitles.Length();
for (int i = 0; i < numMenuItems; i++) {
- const nsString& currentTitle = *mTitles[i];
+ const nsString& currentTitle = mTitles[i];
NSString *titleString;
if (currentTitle.IsEmpty()) {
- const nsString& currentFilter = *mFilters[i];
+ const nsString& currentFilter = mFilters[i];
titleString = [[NSString alloc] initWithCharacters:currentFilter.get()
length:currentFilter.Length()];
}
else {
titleString = [[NSString alloc] initWithCharacters:currentTitle.get()
length:currentTitle.Length()];
}
[popupButton addItemWithTitle:titleString];
@@ -413,44 +413,44 @@ nsFilePicker::PutLocalFile(const nsStrin
// an NSArray of them for the Open Panel. Note: Will return nil if we should allow
// all file types.
NSArray *
nsFilePicker::GenerateFilterList()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
NSArray *filterArray = nil;
- if (mFilters.Count() > 0) {
+ 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; loop < mFilters.Count(); loop++) {
- nsString *filterWide = mFilters[loop];
+ for (PRInt32 loop = 0; PRInt32(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("*"))) {
+ if (filterWide.Equals(NS_LITERAL_STRING("*"))) {
// if we'll allow all files, we won't bother parsing all other
// file types. just return early.
return nil;
}
- else if (filterWide->Equals(NS_LITERAL_STRING("..apps"))) {
+ else if (filterWide.Equals(NS_LITERAL_STRING("..apps"))) {
// this magic filter means that we should enable app bundles.
// translate it into a usable filter, and continue looping through
// other filters.
[giantFilterString appendString:@"*.app"];
continue;
}
- if (filterWide && filterWide->Length() > 0)
- [giantFilterString appendString:[NSString stringWithCharacters:filterWide->get() length:filterWide->Length()]];
+ if (filterWide && filterWide.Length() > 0)
+ [giantFilterString appendString:[NSString stringWithCharacters:filterWide.get() length:filterWide.Length()]];
}
// Now we clean stuff up. Get rid of white spaces, "*"'s, and the odd period or two.
NSCharacterSet *aSet = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithString:@". *"]];
NSRange aRange = [giantFilterString rangeOfCharacterFromSet:aSet];
while (aRange.length) {
[giantFilterString replaceCharactersInRange:aRange withString:@""];
aRange = [giantFilterString rangeOfCharacterFromSet:aSet];
@@ -558,18 +558,18 @@ NS_IMETHODIMP nsFilePicker::SetDefaultEx
return NS_OK;
}
// Append an entry to the filters array
NS_IMETHODIMP
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
{
- mFilters.AppendString(aFilter);
- mTitles.AppendString(aTitle);
+ mFilters.AppendElement(aFilter);
+ mTitles.AppendElemet(aTitle);
return NS_OK;
}
// Get the filter index - do we still need this?
NS_IMETHODIMP nsFilePicker::GetFilterIndex(PRInt32 *aFilterIndex)
{
--- a/widget/src/gtk2/nsDeviceContextSpecG.cpp
+++ b/widget/src/gtk2/nsDeviceContextSpecG.cpp
@@ -66,16 +66,17 @@
#include "nsPSPrinters.h"
#include "nsPaperPS.h" /* Paper size list */
#endif /* USE_POSTSCRIPT */
#include "nsPrintSettingsGTK.h"
#include "nsIFileStreams.h"
#include "nsILocalFile.h"
+#include "nsTArray.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
/* Ensure that the result is always equal to either PR_TRUE or PR_FALSE */
#define MAKE_PR_BOOL(val) ((val)?(PR_TRUE):(PR_FALSE))
@@ -96,25 +97,25 @@ public:
static GlobalPrinters* GetInstance() { return &mGlobalPrinters; }
~GlobalPrinters() { FreeGlobalPrinters(); }
void FreeGlobalPrinters();
nsresult InitializeGlobalPrinters();
PRBool PrintersAreAllocated() { return mGlobalPrinterList != nsnull; }
PRInt32 GetNumPrinters()
- { return mGlobalPrinterList ? mGlobalPrinterList->Count() : 0; }
- nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
+ { return mGlobalPrinterList ? mGlobalPrinterList->Length() : 0; }
+ nsString* GetStringAt(PRInt32 aInx) { return &mGlobalPrinterList->ElementAt(aInx); }
void GetDefaultPrinterName(PRUnichar **aDefaultPrinterName);
protected:
GlobalPrinters() {}
static GlobalPrinters mGlobalPrinters;
- static nsStringArray* mGlobalPrinterList;
+ static nsTArray<nsString>* mGlobalPrinterList;
};
#ifdef SET_PRINTER_FEATURES_VIA_PREFS
/* "Prototype" for the new nsPrinterFeatures service */
class nsPrinterFeatures {
public:
nsPrinterFeatures( const char *printername );
~nsPrinterFeatures() {}
@@ -375,17 +376,17 @@ void nsPrinterFeatures::SetMultipleConcu
SetBoolValue("can_use_multiple_devicecontexts_concurrently", aCanUseMultipleInstances);
}
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
//---------------
// static members
GlobalPrinters GlobalPrinters::mGlobalPrinters;
-nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
+nsTArray<nsString>* GlobalPrinters::mGlobalPrinterList = nsnull;
//---------------
nsDeviceContextSpecGTK::nsDeviceContextSpecGTK()
{
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::nsDeviceContextSpecGTK()\n"));
mGtkPageSetup = nsnull;
mGtkPrintSettings = nsnull;
}
@@ -826,26 +827,26 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::Ge
*aPrinterNameList = nsnull;
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
- nsStringArray *printers = new nsStringArray(numPrinters);
+ nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
if (!printers) {
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_OUT_OF_MEMORY;
}
int count = 0;
while( count < numPrinters )
{
- printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
+ printers->AppendElement(*GlobalPrinters::GetInstance()->GetStringAt(count++));
}
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
}
/* readonly attribute wstring defaultPrinterName; */
NS_IMETHODIMP nsPrinterEnumeratorGTK::GetDefaultPrinterName(PRUnichar **aDefaultPrinterName)
@@ -1070,29 +1071,29 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::Di
//----------------------------------------------------------------------
//String array enumeration callback to append a printer to the global
//printer list.
static PRBool
GlobalPrinterEnumFunc(nsCString& aName, void *aData)
{
- nsStringArray *a = (nsStringArray *)aData;
- a->AppendString(NS_ConvertUTF8toUTF16(aName));
+ nsTArray<nsString> *a = (nsTArray<nsString> *)aData;
+ a->AppendElement(NS_ConvertUTF8toUTF16(aName));
return PR_TRUE;
}
//----------------------------------------------------------------------
nsresult GlobalPrinters::InitializeGlobalPrinters ()
{
if (PrintersAreAllocated()) {
return NS_OK;
}
- mGlobalPrinterList = new nsStringArray();
+ mGlobalPrinterList = new nsTArray<nsString>();
if (!mGlobalPrinterList)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
nsCOMPtr<nsIPrefBranch> pPrefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
@@ -1102,17 +1103,17 @@ nsresult GlobalPrinters::InitializeGloba
/* Get the list of PostScript-module printers */
nsCStringArray printerList;
psMgr.GetPrinterList(printerList);
printerList.EnumerateForwards(GlobalPrinterEnumFunc, mGlobalPrinterList);
}
#endif /* USE_POSTSCRIPT */
/* If there are no printers available after all checks, return an error */
- if (!mGlobalPrinterList->Count())
+ if (!mGlobalPrinterList->Length())
{
/* Make sure we do not cache an empty printer list */
FreeGlobalPrinters();
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
}
return NS_OK;
--- a/widget/src/os2/nsDeviceContextSpecOS2.cpp
+++ b/widget/src/os2/nsDeviceContextSpecOS2.cpp
@@ -38,16 +38,17 @@
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h>
#include "nsDeviceContextSpecOS2.h"
#include "nsReadableUtils.h"
#include "nsISupportsArray.h"
+#include "nsTArray.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "prenv.h" /* for PR_GetEnv */
#include "prtime.h"
#include "nsPrintfCString.h"
#include "nsIServiceManager.h"
@@ -84,24 +85,24 @@ public:
PRInt32 GetNumPrinters() { return mGlobalNumPrinters; }
nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
void GetDefaultPrinterName(PRUnichar*& aDefaultPrinterName);
protected:
GlobalPrinters() {}
static GlobalPrinters mGlobalPrinters;
- static nsStringArray* mGlobalPrinterList;
+ static nsTArray<nsString>* mGlobalPrinterList;
static ULONG mGlobalNumPrinters;
};
//---------------
// static members
GlobalPrinters GlobalPrinters::mGlobalPrinters;
-nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
+nsTArray<nsString>* GlobalPrinters::mGlobalPrinterList = nsnull;
ULONG GlobalPrinters::mGlobalNumPrinters = 0;
//---------------
nsDeviceContextSpecOS2::nsDeviceContextSpecOS2()
: mQueue(nsnull), mPrintDC(nsnull), mPrintingStarted(PR_FALSE)
{
}
@@ -570,26 +571,26 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::Ge
nsDeviceContextSpecOS2::PrnDlg.RefreshPrintQueue();
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
- nsStringArray *printers = new nsStringArray(numPrinters);
+ nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
if (!printers) {
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_OUT_OF_MEMORY;
}
ULONG count = 0;
while( count < numPrinters )
{
- printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
+ printers->AppendElement(*GlobalPrinters::GetInstance()->GetStringAt(count++));
}
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
}
NS_IMETHODIMP nsPrinterEnumeratorOS2::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName)
{
@@ -649,33 +650,33 @@ nsresult GlobalPrinters::InitializeGloba
if (PrintersAreAllocated())
return NS_OK;
mGlobalNumPrinters = 0;
mGlobalNumPrinters = nsDeviceContextSpecOS2::PrnDlg.GetNumPrinters();
if (!mGlobalNumPrinters)
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
- mGlobalPrinterList = new nsStringArray();
+ mGlobalPrinterList = new nsTArray<nsString>();
if (!mGlobalPrinterList)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
nsCOMPtr<nsIPrefBranch> pPrefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
BOOL prefFailed = NS_FAILED(rv); // don't return on failure, optional feature
for (ULONG i = 0; i < mGlobalNumPrinters; i++) {
nsXPIDLCString printer;
nsDeviceContextSpecOS2::PrnDlg.GetPrinter(i, getter_Copies(printer));
nsAutoChar16Buffer printerName;
PRInt32 printerNameLength;
rv = MultiByteToWideChar(0, printer, strlen(printer),
printerName, printerNameLength);
- mGlobalPrinterList->AppendString(nsDependentString(printerName.Elements()));
+ mGlobalPrinterList->AppendElement(nsDependentString(printerName.Elements()));
// store printer description in prefs for the print dialog
if (!prefFailed) {
nsCAutoString printerDescription;
printerDescription = nsCAutoString(nsDeviceContextSpecOS2::PrnDlg.GetPrintDriver(i)->szDeviceName);
printerDescription += " (";
printerDescription += nsCAutoString(nsDeviceContextSpecOS2::PrnDlg.GetDriverType(i));
printerDescription += ")";
--- a/widget/src/os2/nsFilePicker.cpp
+++ b/widget/src/os2/nsFilePicker.cpp
@@ -184,37 +184,37 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16
} else {
filedlg.fl |= FDS_OPEN_DIALOG;
}
PMYDATA pmydata;
pmydata = (PMYDATA)calloc(1, sizeof(MYDATA));
filedlg.ulUser = (ULONG)pmydata;
filedlg.pfnDlgProc = FileDialogProc;
- int i;
+ PRUint32 i;
PSZ *apszTypeList;
- apszTypeList = (PSZ *)malloc(mTitles.Count()*sizeof(PSZ)+1);
- for (i = 0; i < mTitles.Count(); i++)
+ apszTypeList = (PSZ *)malloc(mTitles.Length()*sizeof(PSZ)+1);
+ for (i = 0; i < mTitles.Length(); i++)
{
- const nsString& typeWide = *mTitles[i];
+ const nsString& typeWide = mTitles[i];
nsAutoCharBuffer buffer;
PRInt32 bufLength;
WideCharToMultiByte(0, typeWide.get(), typeWide.Length(),
buffer, bufLength);
apszTypeList[i] = ToNewCString(nsDependentCString(buffer.Elements()));
}
apszTypeList[i] = 0;
filedlg.papszITypeList = (PAPSZ)apszTypeList;
PSZ *apszFilterList;
- apszFilterList = (PSZ *)malloc(mFilters.Count()*sizeof(PSZ)+1);
- for (i = 0; i < mFilters.Count(); i++)
+ apszFilterList = (PSZ *)malloc(mFilters.Length()*sizeof(PSZ)+1);
+ for (i = 0; i < mFilters.Length(); i++)
{
- const nsString& filterWide = *mFilters[i];
+ const nsString& filterWide = mFilters[i];
apszFilterList[i] = ToNewCString(filterWide);
}
apszFilterList[i] = 0;
pmydata->papszIFilterList = (PAPSZ)apszFilterList;
pmydata->ulCurExt = mSelectedType;
PRBool fileExists;
@@ -314,23 +314,23 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16
NS_ENSURE_SUCCESS(rv,rv);
}
} else {
mFile.Assign(filedlg.szFullFile);
}
mSelectedType = (PRInt16)pmydata->ulCurExt;
}
- for (i = 0; i < mTitles.Count(); i++)
+ for (i = 0; i < mTitles.Length(); i++)
{
nsMemory::Free(*(filedlg.papszITypeList[i]));
}
free(filedlg.papszITypeList);
- for (i = 0; i < mFilters.Count(); i++)
+ for (i = 0; i < mFilters.Length(); i++)
{
nsMemory::Free(*(pmydata->papszIFilterList[i]));
}
free(pmydata->papszIFilterList);
free(pmydata);
}
if (title)
@@ -611,20 +611,20 @@ PRUnichar * nsFilePicker::ConvertFromFil
return NS_SUCCEEDED(rv) ? outString : nsnull;
}
NS_IMETHODIMP
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
{
if (aFilter.EqualsLiteral("..apps"))
- mFilters.AppendString(NS_LITERAL_STRING("*.exe;*.cmd;*.com;*.bat"));
+ mFilters.AppendElement(NS_LITERAL_STRING("*.exe;*.cmd;*.com;*.bat"));
else
- mFilters.AppendString(aFilter);
- mTitles.AppendString(aTitle);
+ mFilters.AppendElement(aFilter);
+ mTitles.AppendElement(aTitle);
return NS_OK;
}
MRESULT EXPENTRY DirDialogProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
switch ( msg ) {
case WM_INITDLG:
--- a/widget/src/os2/nsFilePicker.h
+++ b/widget/src/os2/nsFilePicker.h
@@ -37,16 +37,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFilePicker_h__
#define nsFilePicker_h__
#include "nsISimpleEnumerator.h"
#include "nsISupportsArray.h"
+#include "nsTArray.h"
#include "nsICharsetConverterManager.h"
#include "nsBaseFilePicker.h"
#include "nsString.h"
#include "nsdefs.h"
/**
* Native Windows FileSelector wrapper
@@ -87,18 +88,18 @@ protected:
PRUnichar * ConvertFromFileSystemCharset(const char *inString);
HWND mWnd;
nsString mTitle;
PRInt16 mMode;
nsCString mFile;
nsString mDefault;
nsString mDefaultExtension;
- nsStringArray mFilters;
- nsStringArray mTitles;
+ nsTArray<nsString> mFilters;
+ nsTArray<nsString> mTitles;
nsIUnicodeEncoder* mUnicodeEncoder;
nsIUnicodeDecoder* mUnicodeDecoder;
PRInt16 mSelectedType;
nsCOMPtr <nsISupportsArray> mFiles;
static char mLastUsedDirectory[];
};
#endif // nsFilePicker_h__
--- a/widget/src/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/src/windows/nsDeviceContextSpecWin.cpp
@@ -43,16 +43,17 @@
#endif
#include <tchar.h>
#include "nsAutoPtr.h"
#include "nsIWidget.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "nsIPrintSettingsWin.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsIServiceManager.h"
#include "nsReadableUtils.h"
#include "nsStringEnumerator.h"
@@ -934,30 +935,30 @@ nsPrinterEnumeratorWin::GetPrinterNameLi
nsresult rv = GlobalPrinters::GetInstance()->EnumeratePrinterList();
if (NS_FAILED(rv)) {
PR_PL(("***** nsDeviceContextSpecWin::GetPrinterNameList - Couldn't enumerate printers!\n"));
return rv;
}
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
- nsStringArray *printers = new nsStringArray(numPrinters);
+ nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
if (!printers)
return NS_ERROR_OUT_OF_MEMORY;
PRInt32 printerInx = 0;
while( printerInx < numPrinters ) {
LPTSTR name = GlobalPrinters::GetInstance()->GetItemFromList(printerInx++);
#ifdef UNICODE
nsDependentString newName(name);
#else
nsAutoString newName;
NS_CopyNativeToUnicode(nsDependentCString(name), newName);
#endif
- printers->AppendString(newName);
+ printers->AppendElement(newName);
}
return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
}
//----------------------------------------------------------------------------------
// Display the AdvancedDocumentProperties for the selected Printer
NS_IMETHODIMP nsPrinterEnumeratorWin::DisplayPropertiesDlg(const PRUnichar *aPrinterName, nsIPrintSettings* aPrintSettings)
--- a/xpcom/ds/nsStringEnumerator.cpp
+++ b/xpcom/ds/nsStringEnumerator.cpp
@@ -49,25 +49,25 @@
// nsStringEnumerator
//
class nsStringEnumerator : public nsIStringEnumerator,
public nsIUTF8StringEnumerator,
public nsISimpleEnumerator
{
public:
- nsStringEnumerator(const nsStringArray* aArray, PRBool aOwnsArray) :
+ nsStringEnumerator(const nsTArray<nsString>* aArray, PRBool aOwnsArray) :
mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE)
{}
nsStringEnumerator(const nsCStringArray* aArray, PRBool aOwnsArray) :
mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE)
{}
- nsStringEnumerator(const nsStringArray* aArray, nsISupports* aOwner) :
+ nsStringEnumerator(const nsTArray<nsString>* aArray, nsISupports* aOwner) :
mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE)
{}
nsStringEnumerator(const nsCStringArray* aArray, nsISupports* aOwner) :
mCArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_FALSE)
{}
NS_DECL_ISUPPORTS
@@ -80,29 +80,29 @@ public:
private:
~nsStringEnumerator() {
if (mOwnsArray) {
// const-casting is safe here, because the NS_New*
// constructors make sure mOwnsArray is consistent with
// the constness of the objects
if (mIsUnicode)
- delete const_cast<nsStringArray*>(mArray);
+ delete const_cast<nsTArray<nsString>*>(mArray);
else
delete const_cast<nsCStringArray*>(mCArray);
}
}
union {
- const nsStringArray* mArray;
+ const nsTArray<nsString>* mArray;
const nsCStringArray* mCArray;
};
inline PRUint32 Count() {
- return mIsUnicode ? mArray->Count() : mCArray->Count();
+ return mIsUnicode ? mArray->Length() : mCArray->Count();
}
PRUint32 mIndex;
// the owner allows us to hold a strong reference to the object
// that owns the array. Having a non-null value in mOwner implies
// that mOwnsArray is PR_FALSE, because we rely on the real owner
// to release the array
@@ -132,17 +132,17 @@ nsStringEnumerator::HasMoreElements(PRBo
NS_IMETHODIMP
nsStringEnumerator::GetNext(nsISupports** aResult)
{
if (mIsUnicode) {
nsSupportsStringImpl* stringImpl = new nsSupportsStringImpl();
if (!stringImpl) return NS_ERROR_OUT_OF_MEMORY;
- stringImpl->SetData(*mArray->StringAt(mIndex++));
+ stringImpl->SetData(mArray->ElementAt(mIndex++));
*aResult = stringImpl;
}
else {
nsSupportsCStringImpl* cstringImpl = new nsSupportsCStringImpl();
if (!cstringImpl) return NS_ERROR_OUT_OF_MEMORY;
cstringImpl->SetData(*mCArray->CStringAt(mIndex++));
*aResult = cstringImpl;
@@ -152,30 +152,30 @@ nsStringEnumerator::GetNext(nsISupports*
}
NS_IMETHODIMP
nsStringEnumerator::GetNext(nsAString& aResult)
{
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
if (mIsUnicode)
- aResult = *mArray->StringAt(mIndex++);
+ aResult = mArray->ElementAt(mIndex++);
else
CopyUTF8toUTF16(*mCArray->CStringAt(mIndex++), aResult);
return NS_OK;
}
NS_IMETHODIMP
nsStringEnumerator::GetNext(nsACString& aResult)
{
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
if (mIsUnicode)
- CopyUTF16toUTF8(*mArray->StringAt(mIndex++), aResult);
+ CopyUTF16toUTF8(mArray->ElementAt(mIndex++), aResult);
else
aResult = *mCArray->CStringAt(mIndex++);
return NS_OK;
}
template<class T>
static inline nsresult
@@ -188,17 +188,17 @@ StringEnumeratorTail(T** aResult NS_INPA
}
//
// constructors
//
NS_COM nsresult
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
- const nsStringArray* aArray, nsISupports* aOwner)
+ const nsTArray<nsString>* aArray, nsISupports* aOwner)
{
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_ARG_POINTER(aArray);
*aResult = new nsStringEnumerator(aArray, aOwner);
return StringEnumeratorTail(aResult);
}
@@ -211,17 +211,17 @@ NS_NewUTF8StringEnumerator(nsIUTF8String
NS_ENSURE_ARG_POINTER(aArray);
*aResult = new nsStringEnumerator(aArray, aOwner);
return StringEnumeratorTail(aResult);
}
NS_COM nsresult
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
- nsStringArray* aArray)
+ nsTArray<nsString>* aArray)
{
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_ARG_POINTER(aArray);
*aResult = new nsStringEnumerator(aArray, PR_TRUE);
return StringEnumeratorTail(aResult);
}
@@ -234,17 +234,17 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUT
*aResult = new nsStringEnumerator(aArray, PR_TRUE);
return StringEnumeratorTail(aResult);
}
// const ones internally just forward to the non-const equivalents
NS_COM nsresult
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
- const nsStringArray* aArray)
+ const nsTArray<nsString>* aArray)
{
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_ARG_POINTER(aArray);
*aResult = new nsStringEnumerator(aArray, PR_FALSE);
return StringEnumeratorTail(aResult);
}
--- a/xpcom/ds/nsStringEnumerator.h
+++ b/xpcom/ds/nsStringEnumerator.h
@@ -33,16 +33,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 "nsIStringEnumerator.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
// nsIStringEnumerator/nsIUTF8StringEnumerator implementations
//
// Currently all implementations support both interfaces. The
// constructors below provide the most common interface for the given
// type (i.e. nsIStringEnumerator for PRUnichar* strings, and so
// forth) but any resulting enumerators can be queried to the other
// type. Internally, the enumerators will hold onto the type that was
@@ -70,35 +71,39 @@
// array.AppendCString("def");
// NS_NewStringEnumerator(&enumerator, &array, PR_TRUE);
//
// // call some internal method which iterates the enumerator
// InternalMethod(enumerator);
// NS_RELEASE(enumerator);
//
NS_COM nsresult
+NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
+ const nsTArray<nsString>* aArray,
+ nsISupports* aOwner);
+NS_COM nsresult
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
const nsCStringArray* aArray);
NS_COM nsresult
NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
- const nsStringArray* aArray);
+ const nsTArray<nsString>* aArray);
// Adopting string enumerators assume ownership of the array and will
// call |operator delete| on the array when the enumerator is destroyed
// this is useful when the provider creates an array solely for the
// purpose of creating the enumerator.
// For example:
//
// nsCStringArray* array = new nsCStringArray;
// array->AppendString("abcd");
// NS_NewAdoptingStringEnumerator(&result, array);
NS_COM nsresult
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
- nsStringArray* aArray);
+ nsTArray<nsString>* aArray);
NS_COM nsresult
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
nsCStringArray* aArray);
// these versions take a refcounted "owner" which will be addreffed
// when the enumerator is created, and destroyed when the enumerator
@@ -108,15 +113,11 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUT
// For example:
//
// nsresult MyClass::Enumerate(nsIUTF8StringEnumerator** aResult) {
// mCategoryList->AppendString("abcd");
// return NS_NewStringEnumerator(aResult, mCategoryList, this);
// }
//
NS_COM nsresult
-NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
- const nsStringArray* aArray,
- nsISupports* aOwner);
-NS_COM nsresult
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
const nsCStringArray* aArray,
nsISupports* aOwner);
--- a/xpcom/io/nsLocalFileOSX.mm
+++ b/xpcom/io/nsLocalFileOSX.mm
@@ -45,16 +45,17 @@
#include "nsObjCExceptions.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIDirectoryEnumerator.h"
#include "nsISimpleEnumerator.h"
#include "nsITimelineService.h"
#include "nsVoidArray.h"
+#include "nsTArray.h"
#include "plbase64.h"
#include "prmem.h"
#include "nsCRT.h"
#include "nsHashKeys.h"
#include "MoreFilesX.h"
#include "FSCopyObject.h"
@@ -451,17 +452,17 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
if (type != NORMAL_FILE_TYPE && type != DIRECTORY_TYPE)
return NS_ERROR_FILE_UNKNOWN_TYPE;
// Check we are correctly initialized.
CHECK_mBaseRef();
- nsStringArray nonExtantNodes;
+ nsTArray<nsString> nonExtantNodes;
CFURLRef pathURLRef = mBaseRef;
FSRef pathFSRef;
CFStringRef leafStrRef = nsnull;
nsAutoTArray<UniChar, FILENAME_BUFFER_SIZE> buffer;
Boolean success;
// Work backwards through the path to find the last node which
// exists. Place the nodes which don't exist in an array and we'll
@@ -470,17 +471,17 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint
leafStrRef = ::CFURLCopyLastPathComponent(pathURLRef);
if (!leafStrRef)
break;
CFIndex leafLen = ::CFStringGetLength(leafStrRef);
if (!buffer.SetLength(leafLen + 1))
break;
::CFStringGetCharacters(leafStrRef, CFRangeMake(0, leafLen), buffer.Elements());
buffer[leafLen] = '\0';
- nonExtantNodes.AppendString(nsString(nsDependentString(buffer.Elements())));
+ nonExtantNodes.AppendElement(nsString(nsDependentString(buffer.Elements())));
::CFRelease(leafStrRef);
leafStrRef = nsnull;
// Get the parent of the leaf for the next go round
CFURLRef parent = ::CFURLCreateCopyDeletingLastPathComponent(NULL, pathURLRef);
if (!parent)
break;
if (pathURLRef != mBaseRef)
@@ -488,33 +489,33 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint
pathURLRef = parent;
}
if (pathURLRef != mBaseRef)
::CFRelease(pathURLRef);
if (leafStrRef != nsnull)
::CFRelease(leafStrRef);
if (!success)
return NS_ERROR_FAILURE;
- PRInt32 nodesToCreate = nonExtantNodes.Count();
+ PRInt32 nodesToCreate = PRInt32(nonExtantNodes.Length());
if (nodesToCreate == 0)
return NS_ERROR_FILE_ALREADY_EXISTS;
OSErr err;
nsAutoString nextNodeName;
for (PRInt32 i = nodesToCreate - 1; i > 0; i--) {
- nonExtantNodes.StringAt(i, nextNodeName);
+ nextNodeName = nonExtantNodes[i];
err = ::FSCreateDirectoryUnicode(&pathFSRef,
nextNodeName.Length(),
(const UniChar *)nextNodeName.get(),
kFSCatInfoNone,
nsnull, &pathFSRef, nsnull, nsnull);
if (err != noErr)
return MacErrorMapper(err);
}
- nonExtantNodes.StringAt(0, nextNodeName);
+ nextNodeName = nonExtantNodes[0];
if (type == NORMAL_FILE_TYPE) {
err = ::FSCreateFileUnicode(&pathFSRef,
nextNodeName.Length(),
(const UniChar *)nextNodeName.get(),
kFSCatInfoNone,
nsnull, nsnull, nsnull);
}
else {