зеркало из https://github.com/mozilla/pjs.git
Bug 466622. Replace nsCStringArray with nsTArray<nsCString> for more consistent code and fewer heap allocations. r+sr=roc,r=bsmedberg
--HG-- extra : rebase_source : b963bf5de9d9c445b14620479691482512e0faf2
This commit is contained in:
Родитель
588f9c6984
Коммит
fd612bd117
|
@ -337,12 +337,12 @@ nsChromeRegistry::nsProviderArray::SetBase(const nsACString& aProvider, nsIURI*
|
|||
}
|
||||
|
||||
void
|
||||
nsChromeRegistry::nsProviderArray::EnumerateToArray(nsCStringArray *a)
|
||||
nsChromeRegistry::nsProviderArray::EnumerateToArray(nsTArray<nsCString> *a)
|
||||
{
|
||||
PRInt32 i = mArray.Count();
|
||||
while (i--) {
|
||||
ProviderEntry *entry = reinterpret_cast<ProviderEntry*>(mArray[i]);
|
||||
a->AppendCString(entry->provider);
|
||||
a->AppendElement(entry->provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -826,7 +826,7 @@ NS_IMETHODIMP
|
|||
nsChromeRegistry::GetLocalesForPackage(const nsACString& aPackage,
|
||||
nsIUTF8StringEnumerator* *aResult)
|
||||
{
|
||||
nsCStringArray *a = new nsCStringArray;
|
||||
nsTArray<nsCString> *a = new nsTArray<nsCString>;
|
||||
if (!a)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsTHashtable.h"
|
||||
#include "nsURIHashKey.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
|
||||
struct PRFileDesc;
|
||||
|
@ -164,7 +165,7 @@ public:
|
|||
nsIURI* GetBase(const nsACString& aPreferred, MatchType aType);
|
||||
const nsACString& GetSelected(const nsACString& aPreferred, MatchType aType);
|
||||
void SetBase(const nsACString& aProvider, nsIURI* base);
|
||||
void EnumerateToArray(nsCStringArray *a);
|
||||
void EnumerateToArray(nsTArray<nsCString> *a);
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
NS_IMETHOD CreateExpression(const nsAString &aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsTArray<nsString> *aNamespaceURIs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsTArray<nsCString> *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult) = 0;
|
||||
};
|
||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
|||
nsIDOMHTMLScriptElement *mOuter;
|
||||
|
||||
// Javascript argument names must be ASCII...
|
||||
nsCStringArray mArgNames;
|
||||
nsTArray<nsCString> mArgNames;
|
||||
|
||||
// The event name is kept UCS2 for 'quick comparisions'...
|
||||
nsString mEventName;
|
||||
|
@ -144,7 +144,7 @@ nsresult nsHTMLScriptEventHandler::ParseEventString(const nsAString &aValue)
|
|||
NS_LossyConvertUTF16toASCII sig(Substring(next, end));
|
||||
|
||||
// Store each (comma separated) argument in mArgNames
|
||||
mArgNames.ParseString(sig.get(), ",");
|
||||
ParseString(sig, ',', mArgNames);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ nsHTMLScriptEventHandler::Invoke(nsISupports *aTargetObject,
|
|||
const char* stackArgs[kMaxArgsOnStack];
|
||||
|
||||
args = stackArgs;
|
||||
argc = mArgNames.Count();
|
||||
argc = PRInt32(mArgNames.Length());
|
||||
|
||||
// If there are too many arguments then allocate the array from the heap
|
||||
// otherwise build it up on the stack...
|
||||
|
@ -267,7 +267,7 @@ nsHTMLScriptEventHandler::Invoke(nsISupports *aTargetObject,
|
|||
}
|
||||
|
||||
for(i=0; i<argc; i++) {
|
||||
args[i] = mArgNames[i]->get();
|
||||
args[i] = mArgNames[i].get();
|
||||
}
|
||||
|
||||
// Null terminate for good luck ;-)
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "nsXPCOM.h"
|
||||
#include <fstream.h>
|
||||
#include "nsDoubleHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#ifdef MOZ_JPROF
|
||||
#include "jprof.h"
|
||||
#endif
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
txOptionEntry(const void* aKey) : PLDHashCStringEntry(aKey)
|
||||
{
|
||||
}
|
||||
nsCStringArray mValues;
|
||||
nsTArray<nsCString> mValues;
|
||||
};
|
||||
|
||||
DECL_DHASH_WRAPPER(txOptions, txOptionEntry, nsACString&)
|
||||
|
@ -106,7 +106,7 @@ void parseCommandLine(int argc, char** argv, txOptions& aOptions)
|
|||
else {
|
||||
txOptionEntry* option = aOptions.AddEntry(flag);
|
||||
if (option) {
|
||||
option->mValues.AppendCString(nsCString(arg));
|
||||
option->mValues.AppendElement(nsCString(arg));
|
||||
}
|
||||
flag.Truncate();
|
||||
}
|
||||
|
@ -163,19 +163,19 @@ int main(int argc, char** argv)
|
|||
|
||||
txOptionEntry* option = options.GetEntry(NS_LITERAL_CSTRING("o"));
|
||||
if (option &&
|
||||
option->mValues.Count() > 0 &&
|
||||
!option->mValues[0]->EqualsLiteral("-")) {
|
||||
resultFileStream.open(option->mValues[0]->get(), ios::out);
|
||||
option->mValues.Length() > 0 &&
|
||||
!option->mValues[0].EqualsLiteral("-")) {
|
||||
resultFileStream.open(option->mValues[0].get(), ios::out);
|
||||
if (!resultFileStream) {
|
||||
cerr << "error opening output file: ";
|
||||
cerr << option->mValues[0]->get() << endl;
|
||||
cerr << option->mValues[0].get() << endl;
|
||||
return -1;
|
||||
}
|
||||
resultOutput = &resultFileStream;
|
||||
}
|
||||
|
||||
option = options.GetEntry(NS_LITERAL_CSTRING("i"));
|
||||
if (!option || option->mValues.Count() == 0) {
|
||||
if (!option || option->mValues.Length() == 0) {
|
||||
cerr << "you must specify at least a source XML path" << endl;
|
||||
printUsage();
|
||||
return -1;
|
||||
|
@ -185,12 +185,12 @@ int main(int argc, char** argv)
|
|||
txStandaloneXSLTProcessor proc;
|
||||
|
||||
txOptionEntry* styleOption = options.GetEntry(NS_LITERAL_CSTRING("s"));
|
||||
if (!styleOption || styleOption->mValues.Count() == 0) {
|
||||
rv = proc.transform(*option->mValues[0], *resultOutput, obs);
|
||||
if (!styleOption || styleOption->mValues.Length() == 0) {
|
||||
rv = proc.transform(option->mValues[0], *resultOutput, obs);
|
||||
}
|
||||
else {
|
||||
// XXX TODO: Handle multiple stylesheets
|
||||
rv = proc.transform(*option->mValues[0], *styleOption->mValues[0],
|
||||
rv = proc.transform(option->mValues[0], styleOption->mValues[0],
|
||||
*resultOutput, obs);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
nsXPathEvaluatorParseContext(nsXPathEvaluator &aEvaluator,
|
||||
nsIDOMXPathNSResolver* aResolver,
|
||||
nsTArray<PRInt32> *aNamespaceIDs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsTArray<nsCString> *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
PRBool aIsCaseSensitive)
|
||||
: mEvaluator(aEvaluator),
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
nsXPathEvaluator &mEvaluator;
|
||||
nsIDOMXPathNSResolver* mResolver;
|
||||
nsTArray<PRInt32> *mNamespaceIDs;
|
||||
nsCStringArray *mContractIDs;
|
||||
nsTArray<nsCString> *mContractIDs;
|
||||
nsCOMArray<nsISupports> *mState;
|
||||
nsresult mLastError;
|
||||
PRBool mIsCaseSensitive;
|
||||
|
@ -171,7 +171,7 @@ NS_IMETHODIMP
|
|||
nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsTArray<nsString> *aNamespaceURIs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsTArray<nsCString> *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult)
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
|||
if (aNamespaceURIs) {
|
||||
PRUint32 count = aNamespaceURIs->Length();
|
||||
|
||||
if (!aContractIDs || aContractIDs->Count() != count) {
|
||||
if (!aContractIDs || aContractIDs->Length() != count) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
|||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (aContractIDs->CStringAt(i)->IsEmpty()) {
|
||||
if (aContractIDs->ElementAt(i).IsEmpty()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ nsresult
|
|||
nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsTArray<PRInt32> *aNamespaceIDs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsTArray<nsCString> *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult)
|
||||
{
|
||||
|
@ -301,7 +301,7 @@ nsXPathEvaluatorParseContext::resolveFunctionCall(nsIAtom* aName,
|
|||
for (i = 0; i < count; ++i) {
|
||||
if (mNamespaceIDs->ElementAt(i) == aID) {
|
||||
nsISupports *state = mState ? mState->SafeObjectAt(i) : nsnull;
|
||||
rv = TX_ResolveFunctionCallXPCOM(*mContractIDs->CStringAt(i), aID,
|
||||
rv = TX_ResolveFunctionCallXPCOM(mContractIDs->ElementAt(i), aID,
|
||||
aName, state, aFn);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
break;
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
NS_IMETHOD CreateExpression(const nsAString &aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsTArray<nsString> *aNamespaceURIs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsTArray<nsCString> *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult);
|
||||
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
nsresult CreateExpression(const nsAString & aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsTArray<PRInt32> *aNamespaceIDs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsTArray<nsCString> *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult);
|
||||
|
||||
|
|
|
@ -1995,7 +1995,7 @@ nsWebBrowserPersist::CalculateUniqueFilename(nsIURI *aURI)
|
|||
// Create a filename if it's empty, or if the filename / datapath is
|
||||
// already taken by another URI and create an alternate name.
|
||||
|
||||
if (base.IsEmpty() || mFilenameList.Count() > 0)
|
||||
if (base.IsEmpty() || mFilenameList.Length() > 0)
|
||||
{
|
||||
nsCAutoString tmpPath;
|
||||
nsCAutoString tmpBase;
|
||||
|
@ -2048,7 +2048,7 @@ nsWebBrowserPersist::CalculateUniqueFilename(nsIURI *aURI)
|
|||
// Add name to list of those already used
|
||||
nsCAutoString newFilepath(directory);
|
||||
newFilepath.Append(filename);
|
||||
mFilenameList.AppendCString(newFilepath);
|
||||
mFilenameList.AppendElement(newFilepath);
|
||||
|
||||
// Update the uri accordingly if the filename actually changed
|
||||
if (nameHasChanged)
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
|
||||
#include "nsHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsInt64.h"
|
||||
|
||||
#include "nsCWebBrowserPersist.h"
|
||||
|
@ -226,7 +227,7 @@ private:
|
|||
nsHashtable mURIMap;
|
||||
nsVoidArray mDocList;
|
||||
nsVoidArray mCleanupList;
|
||||
nsCStringArray mFilenameList;
|
||||
nsTArray<nsCString> mFilenameList;
|
||||
PRPackedBool mFirstAndOnlyUse;
|
||||
PRPackedBool mCancel;
|
||||
PRPackedBool mJustStartedLoading;
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILineInputStream.h"
|
||||
#include "nsIIDNService.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
|
@ -743,27 +745,27 @@ nsPermissionManager::Import()
|
|||
continue;
|
||||
}
|
||||
|
||||
nsCStringArray lineArray;
|
||||
nsTArray<nsCString> lineArray;
|
||||
|
||||
// Split the line at tabs
|
||||
lineArray.ParseString(buffer.get(), "\t");
|
||||
ParseString(buffer, '\t', lineArray);
|
||||
|
||||
if (lineArray[0]->EqualsLiteral(kMatchTypeHost) &&
|
||||
lineArray.Count() == 4) {
|
||||
if (lineArray[0].EqualsLiteral(kMatchTypeHost) &&
|
||||
lineArray.Length() == 4) {
|
||||
|
||||
PRInt32 error;
|
||||
PRUint32 permission = lineArray[2]->ToInteger(&error);
|
||||
PRUint32 permission = lineArray[2].ToInteger(&error);
|
||||
if (error)
|
||||
continue;
|
||||
|
||||
// hosts might be encoded in UTF8; switch them to ACE to be consistent
|
||||
if (!IsASCII(*lineArray[3])) {
|
||||
rv = NormalizeToACE(*lineArray[3]);
|
||||
if (!IsASCII(lineArray[3])) {
|
||||
rv = NormalizeToACE(lineArray[3]);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = AddInternal(*lineArray[3], *lineArray[1], permission, 0, eDontNotify, eWriteToDB);
|
||||
rv = AddInternal(lineArray[3], lineArray[1], permission, 0, eDontNotify, eWriteToDB);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ mozSpellChecker::InitSpellCheckDictionaryMap()
|
|||
nsresult rv;
|
||||
PRBool hasMoreEngines;
|
||||
PRInt32 i;
|
||||
nsCStringArray contractIds;
|
||||
nsTArray<nsCString> contractIds;
|
||||
|
||||
nsCOMPtr<nsICategoryManager> catMgr = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
||||
if (!catMgr)
|
||||
|
@ -500,28 +500,28 @@ mozSpellChecker::InitSpellCheckDictionaryMap()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
contractIds.AppendCString(contractId);
|
||||
contractIds.AppendElement(contractId);
|
||||
}
|
||||
|
||||
contractIds.AppendCString(NS_LITERAL_CSTRING(DEFAULT_SPELL_CHECKER));
|
||||
contractIds.AppendElement(NS_LITERAL_CSTRING(DEFAULT_SPELL_CHECKER));
|
||||
|
||||
// Retrieve dictionaries from all available spellcheckers and
|
||||
// fill mDictionariesMap hash (only the first dictionary with the
|
||||
// each name is used).
|
||||
for (i=0;i<contractIds.Count();i++){
|
||||
for (i=0;i < PRInt32(contractIds.Length());i++){
|
||||
PRUint32 count,k;
|
||||
PRUnichar **words;
|
||||
|
||||
nsCString *contractId = contractIds[i];
|
||||
const nsCString& contractId = contractIds[i];
|
||||
|
||||
// Try to load spellchecker engine. Ignore errors silently
|
||||
// except for the last one (HunSpell).
|
||||
nsCOMPtr<mozISpellCheckingEngine> engine =
|
||||
do_GetService(contractId->get(), &rv);
|
||||
do_GetService(contractId.get(), &rv);
|
||||
if (NS_FAILED(rv)){
|
||||
// Fail if not succeeded to load HunSpell. Ignore errors
|
||||
// for external spellcheck engines.
|
||||
if (i==contractIds.Count()-1){
|
||||
if (i==contractIds.Length()-1){
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ mozSpellChecker::InitSpellCheckDictionaryMap()
|
|||
if (mDictionariesMap.Get(dictName, NULL))
|
||||
continue;
|
||||
|
||||
mDictionariesMap.Put(dictName, new nsCString(*contractId));
|
||||
mDictionariesMap.Put(dictName, new nsCString(contractId));
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
|
||||
|
|
|
@ -93,7 +93,7 @@ nsPSPrinterList::Enabled()
|
|||
|
||||
/* Fetch a list of printers handled by the PostsScript module */
|
||||
void
|
||||
nsPSPrinterList::GetPrinterList(nsCStringArray& aList)
|
||||
nsPSPrinterList::GetPrinterList(nsTArray<nsCString>& aList)
|
||||
{
|
||||
aList.Clear();
|
||||
|
||||
|
@ -112,9 +112,9 @@ nsPSPrinterList::GetPrinterList(nsCStringArray& aList)
|
|||
fullName.Append(dests[i].instance);
|
||||
}
|
||||
if (dests[i].is_default)
|
||||
aList.InsertCStringAt(fullName, 0);
|
||||
aList.InsertElementAt(0, fullName);
|
||||
else
|
||||
aList.AppendCString(fullName);
|
||||
aList.AppendElement(fullName);
|
||||
}
|
||||
}
|
||||
(mCups.mCupsFreeDests)(num_dests, dests);
|
||||
|
@ -126,7 +126,7 @@ nsPSPrinterList::GetPrinterList(nsCStringArray& aList)
|
|||
// MOZILLA_POSTSCRIPT_PRINTER_LIST or a preference setting
|
||||
// print.printer_list, which contains a space-separated list of printer
|
||||
// names.
|
||||
aList.AppendCString(
|
||||
aList.AppendElement(
|
||||
NS_LITERAL_CSTRING(NS_POSTSCRIPT_DRIVER_NAME "default"));
|
||||
|
||||
nsXPIDLCString list;
|
||||
|
@ -145,7 +145,7 @@ nsPSPrinterList::GetPrinterList(nsCStringArray& aList)
|
|||
if (0 != strcmp(name, "default")) {
|
||||
nsCAutoString fullName(NS_POSTSCRIPT_DRIVER_NAME);
|
||||
fullName.Append(name);
|
||||
aList.AppendCString(fullName);
|
||||
aList.AppendElement(fullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define nsPSPrinters_h___
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsCUPSShim.h"
|
||||
#include "psSharedCore.h"
|
||||
|
@ -77,7 +77,7 @@ class NS_PSSHARED nsPSPrinterList {
|
|||
* There should always be at least one entry. The
|
||||
* first entry is the default print destination.
|
||||
*/
|
||||
void GetPrinterList(nsCStringArray& aList);
|
||||
void GetPrinterList(nsTArray<nsCString>& aList);
|
||||
|
||||
enum PrinterType {
|
||||
kTypeUnknown, // Not actually handled by the PS module
|
||||
|
|
|
@ -278,13 +278,13 @@ gfxFontconfigUtils::GetFontList(const nsACString& aLangGroup,
|
|||
{
|
||||
aListOfFonts.Clear();
|
||||
|
||||
nsCStringArray fonts;
|
||||
nsTArray<nsCString> fonts;
|
||||
nsresult rv = GetFontListInternal(fonts, aLangGroup);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
for (PRInt32 i = 0; i < fonts.Count(); ++i) {
|
||||
aListOfFonts.AppendElement(NS_ConvertUTF8toUTF16(*fonts.CStringAt(i)));
|
||||
for (PRUint32 i = 0; i < fonts.Length(); ++i) {
|
||||
aListOfFonts.AppendElement(NS_ConvertUTF8toUTF16(fonts[i]));
|
||||
}
|
||||
|
||||
aListOfFonts.Sort();
|
||||
|
@ -448,7 +448,7 @@ gfxFontconfigUtils::GetSampleLangForGroup(const nsACString& aLangGroup,
|
|||
}
|
||||
|
||||
nsresult
|
||||
gfxFontconfigUtils::GetFontListInternal(nsCStringArray& aListOfFonts,
|
||||
gfxFontconfigUtils::GetFontListInternal(nsTArray<nsCString>& aListOfFonts,
|
||||
const nsACString& aLangGroup)
|
||||
{
|
||||
FcPattern *pat = NULL;
|
||||
|
@ -486,10 +486,10 @@ gfxFontconfigUtils::GetFontListInternal(nsCStringArray& aListOfFonts,
|
|||
|
||||
// Remove duplicates...
|
||||
nsCAutoString strFamily(family);
|
||||
if (aListOfFonts.IndexOf(strFamily) >= 0)
|
||||
if (aListOfFonts.Contains(strFamily))
|
||||
continue;
|
||||
|
||||
aListOfFonts.AppendCString(strFamily);
|
||||
aListOfFonts.AppendElement(strFamily);
|
||||
}
|
||||
|
||||
rv = NS_OK;
|
||||
|
@ -603,7 +603,7 @@ gfxFontconfigUtils::UpdateFontListInternal(PRBool aForce)
|
|||
/* nothing */ ;
|
||||
nsCAutoString name(Substring(start, p));
|
||||
name.CompressWhitespace(PR_FALSE, PR_TRUE);
|
||||
mAliasForMultiFonts.AppendCString(name);
|
||||
mAliasForMultiFonts.AppendElement(name);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
@ -638,7 +638,7 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString&
|
|||
FcPattern *pat = NULL;
|
||||
FcObjectSet *os = NULL;
|
||||
FcFontSet *givenFS = NULL;
|
||||
nsCStringArray candidates;
|
||||
nsTArray<nsCString> candidates;
|
||||
FcFontSet *candidateFS = NULL;
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -667,8 +667,8 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString&
|
|||
continue;
|
||||
|
||||
nsDependentCString first(firstFamily);
|
||||
if (candidates.IndexOf(first) < 0) {
|
||||
candidates.AppendCString(first);
|
||||
if (!candidates.Contains(first)) {
|
||||
candidates.AppendElement(first);
|
||||
|
||||
if (fontname.Equals(first)) {
|
||||
aFamilyName.Assign(aFontName);
|
||||
|
@ -680,9 +680,9 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString&
|
|||
|
||||
// See if any of the first family names represent the same set of font
|
||||
// faces as the given family.
|
||||
for (PRInt32 j = 0; j < candidates.Count(); ++j) {
|
||||
for (PRUint32 j = 0; j < candidates.Length(); ++j) {
|
||||
FcPatternDel(pat, FC_FAMILY);
|
||||
FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)candidates[j]->get());
|
||||
FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)candidates[j].get());
|
||||
|
||||
candidateFS = FcFontList(NULL, pat, os);
|
||||
if (!candidateFS)
|
||||
|
@ -699,7 +699,7 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString&
|
|||
}
|
||||
}
|
||||
if (equal) {
|
||||
AppendUTF8toUTF16(*candidates[j], aFamilyName);
|
||||
AppendUTF8toUTF16(candidates[j], aFamilyName);
|
||||
rv = NS_OK;
|
||||
goto end;
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ gfxFontconfigUtils::ResolveFontName(const nsAString& aFontName,
|
|||
// entire match pattern. That info is not available here, but there
|
||||
// will be a font so leave the resolving to the gfxFontGroup.
|
||||
if (IsExistingFamily(fontname) ||
|
||||
mAliasForMultiFonts.IndexOfIgnoreCase(fontname) != -1)
|
||||
mAliasForMultiFonts.Contains(fontname, gfxIgnoreCaseCStringComparator()))
|
||||
aAborted = !(*aCallback)(aFontName, aClosure);
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -70,6 +70,19 @@ public:
|
|||
static void Release(FcCharSet *ptr) { FcCharSetDestroy(ptr); }
|
||||
};
|
||||
|
||||
class gfxIgnoreCaseCStringComparator
|
||||
{
|
||||
public:
|
||||
PRBool Equals(const nsACString& a, const nsACString& b) const
|
||||
{
|
||||
return nsCString(a).Equals(b, nsCaseInsensitiveCStringComparator());
|
||||
}
|
||||
|
||||
PRBool LessThan(const nsACString& a, const nsACString& b) const
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
class gfxFontNameList : public nsTArray<nsString>
|
||||
{
|
||||
|
@ -308,7 +321,7 @@ protected:
|
|||
|
||||
PRBool IsExistingFamily(const nsCString& aFamilyName);
|
||||
|
||||
nsresult GetFontListInternal(nsCStringArray& aListOfFonts,
|
||||
nsresult GetFontListInternal(nsTArray<nsCString>& aListOfFonts,
|
||||
const nsACString& aLangGroup);
|
||||
nsresult UpdateFontListInternal(PRBool aForce = PR_FALSE);
|
||||
|
||||
|
@ -327,7 +340,7 @@ protected:
|
|||
nsTHashtable<LangSupportEntry> mLangSupportTable;
|
||||
const nsTArray< nsCountedRef<FcPattern> > mEmptyPatternArray;
|
||||
|
||||
nsCStringArray mAliasForMultiFonts;
|
||||
nsTArray<nsCString> mAliasForMultiFonts;
|
||||
|
||||
FcConfig *mLastConfig;
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "nsUConvDll.h"
|
||||
#include "prmem.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsStringEnumerator.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
|
@ -303,7 +303,7 @@ nsCharsetConverterManager::GetList(const nsACString& aCategory,
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCStringArray* array = new nsCStringArray;
|
||||
nsTArray<nsCString>* array = new nsTArray<nsCString>;
|
||||
if (!array)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -332,7 +332,7 @@ nsCharsetConverterManager::GetList(const nsACString& aCategory,
|
|||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
rv = array->AppendCString(alias);
|
||||
rv = array->AppendElement(alias) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_NewAdoptingUTF8StringEnumerator(aResult, array);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "nsUCSupport.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIStringEnumerator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Global functions and data [declaration]
|
||||
|
@ -346,7 +346,7 @@ nsresult nsTestUConv::DisplayCharsets()
|
|||
PRUint32 encCount = 0, decCount = 0;
|
||||
PRUint32 basicEncCount = 0, basicDecCount = 0;
|
||||
|
||||
nsCStringArray allCharsets;
|
||||
nsTArray<nsCString> allCharsets;
|
||||
|
||||
nsCAutoString charset;
|
||||
PRBool hasMore;
|
||||
|
@ -354,22 +354,22 @@ nsresult nsTestUConv::DisplayCharsets()
|
|||
while (hasMore) {
|
||||
res = encoders->GetNext(charset);
|
||||
if (NS_SUCCEEDED(res))
|
||||
allCharsets.AppendCString(charset);
|
||||
allCharsets.AppendElement(charset);
|
||||
|
||||
encoders->HasMore(&hasMore);
|
||||
}
|
||||
|
||||
nsAutoString prop, str;
|
||||
PRUint32 count = allCharsets.Count();
|
||||
PRUint32 count = allCharsets.Length();
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
|
||||
const nsCString* charset = allCharsets[i];
|
||||
printf("%s", charset->get());
|
||||
PrintSpaces(24 - charset->Length()); // align to hard coded column number
|
||||
const nsCString& charset = allCharsets[i];
|
||||
printf("%s", charset.get());
|
||||
PrintSpaces(24 - charset.Length()); // align to hard coded column number
|
||||
|
||||
|
||||
nsCOMPtr<nsIUnicodeDecoder> dec = NULL;
|
||||
res = ccMan->GetUnicodeDecoder(charset->get(), getter_AddRefs(dec));
|
||||
res = ccMan->GetUnicodeDecoder(charset.get(), getter_AddRefs(dec));
|
||||
if (NS_FAILED(res)) printf (" ");
|
||||
else {
|
||||
printf("D");
|
||||
|
@ -389,7 +389,7 @@ nsresult nsTestUConv::DisplayCharsets()
|
|||
#endif
|
||||
|
||||
nsCOMPtr<nsIUnicodeEncoder> enc = NULL;
|
||||
res = ccMan->GetUnicodeEncoder(charset->get(), getter_AddRefs(enc));
|
||||
res = ccMan->GetUnicodeEncoder(charset.get(), getter_AddRefs(enc));
|
||||
if (NS_FAILED(res)) printf (" ");
|
||||
else {
|
||||
printf("E");
|
||||
|
@ -411,27 +411,27 @@ nsresult nsTestUConv::DisplayCharsets()
|
|||
printf(" ");
|
||||
|
||||
prop.AssignLiteral(".notForBrowser");
|
||||
res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
|
||||
res = ccMan->GetCharsetData(charset.get(), prop.get(), str);
|
||||
if ((dec != NULL) && (NS_FAILED(res))) printf ("B");
|
||||
else printf("X");
|
||||
|
||||
prop.AssignLiteral(".notForComposer");
|
||||
res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
|
||||
res = ccMan->GetCharsetData(charset.get(), prop.get(), str);
|
||||
if ((enc != NULL) && (NS_FAILED(res))) printf ("C");
|
||||
else printf("X");
|
||||
|
||||
prop.AssignLiteral(".notForMailView");
|
||||
res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
|
||||
res = ccMan->GetCharsetData(charset.get(), prop.get(), str);
|
||||
if ((dec != NULL) && (NS_FAILED(res))) printf ("V");
|
||||
else printf("X");
|
||||
|
||||
prop.AssignLiteral(".notForMailEdit");
|
||||
res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
|
||||
res = ccMan->GetCharsetData(charset.get(), prop.get(), str);
|
||||
if ((enc != NULL) && (NS_FAILED(res))) printf ("E");
|
||||
else printf("X");
|
||||
|
||||
printf("(%3d, %3d) ", encCount, decCount);
|
||||
res = ccMan->GetCharsetTitle(charset->get(), str);
|
||||
res = ccMan->GetCharsetTitle(charset.get(), str);
|
||||
if (NS_FAILED(res)) str.SetLength(0);
|
||||
NS_LossyConvertUTF16toASCII buff2(str);
|
||||
printf(" \"%s\"\n", buff2.get());
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "nsCRT.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCompressedCharMap.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsWhitespaceTokenizer.h"
|
||||
|
||||
//
|
||||
// nsISupports methods
|
||||
|
@ -148,7 +150,7 @@ nsSaveAsCharset::GetCharset(char * *aCharset)
|
|||
NS_ASSERTION(mCharsetListIndex >= 0, "need to call Init() first");
|
||||
NS_ENSURE_TRUE(mCharsetListIndex >= 0, NS_ERROR_FAILURE);
|
||||
|
||||
const char *charset = mCharsetList[mCharsetListIndex]->get();
|
||||
const char* charset = mCharsetList[mCharsetListIndex].get();
|
||||
if (!charset) {
|
||||
*aCharset = nsnull;
|
||||
NS_ASSERTION(charset, "make sure to call Init() with non empty charset list");
|
||||
|
@ -378,18 +380,21 @@ nsresult nsSaveAsCharset::SetupCharsetList(const char *charsetList)
|
|||
mCharsetListIndex = -1;
|
||||
}
|
||||
|
||||
mCharsetList.ParseString(charsetList, ", ");
|
||||
nsCWhitespaceTokenizer tokenizer = nsDependentCString(charsetList);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
ParseString(tokenizer.nextToken(), ',', mCharsetList);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char * nsSaveAsCharset::GetNextCharset()
|
||||
{
|
||||
if ((mCharsetListIndex + 1) >= mCharsetList.Count())
|
||||
if ((mCharsetListIndex + 1) >= PRInt32(mCharsetList.Length()))
|
||||
return nsnull;
|
||||
|
||||
// bump the index and return the next charset
|
||||
return mCharsetList[++mCharsetListIndex]->get();
|
||||
return mCharsetList[++mCharsetListIndex].get();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsISaveAsCharset.h"
|
||||
|
||||
|
@ -96,7 +96,7 @@ protected:
|
|||
PRUint32 mEntityVersion; // see nsIEntityConverter
|
||||
nsCOMPtr<nsIUnicodeEncoder> mEncoder; // encoder (convert from unicode)
|
||||
nsCOMPtr<nsIEntityConverter> mEntityConverter;
|
||||
nsCStringArray mCharsetList;
|
||||
nsTArray<nsCString> mCharsetList;
|
||||
PRInt32 mCharsetListIndex;
|
||||
};
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ nsJARInputStream::InitDirectory(nsZipArchive* aZip,
|
|||
const char *name;
|
||||
while ((rv = find->FindNext( &name )) == NS_OK) {
|
||||
// No need to copy string, just share the one from nsZipArchive
|
||||
mArray.AppendCString(nsDependentCString(name));
|
||||
mArray.AppendElement(nsDependentCString(name));
|
||||
}
|
||||
delete find;
|
||||
|
||||
|
@ -353,15 +353,15 @@ nsJARInputStream::ReadDirectory(char* aBuffer, PRUint32 aCount, PRUint32 *aBytes
|
|||
// empty the buffer and start writing directory entry lines to it
|
||||
mBuffer.Truncate();
|
||||
mCurPos = 0;
|
||||
const PRUint32 arrayLen = mArray.Count();
|
||||
const PRUint32 arrayLen = mArray.Length();
|
||||
|
||||
for ( ;aCount > mBuffer.Length(); mArrPos++) {
|
||||
// have we consumed all the directory contents?
|
||||
if (arrayLen <= mArrPos)
|
||||
break;
|
||||
|
||||
const char * entryName = mArray[mArrPos]->get();
|
||||
PRUint32 entryNameLen = mArray[mArrPos]->Length();
|
||||
const char * entryName = mArray[mArrPos].get();
|
||||
PRUint32 entryNameLen = mArray[mArrPos].Length();
|
||||
nsZipItem* ze = mZip->GetItem(entryName);
|
||||
NS_ENSURE_TRUE(ze, NS_ERROR_FILE_TARGET_DOES_NOT_EXIST);
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsJAR.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Class nsJARInputStream declaration. This class defines the type of the
|
||||
|
@ -86,7 +87,7 @@ class nsJARInputStream : public nsIInputStream
|
|||
PRUint32 mNameLen; // length of dirname
|
||||
nsCAutoString mBuffer; // storage for generated text of stream
|
||||
PRUint32 mArrPos; // current position within mArray
|
||||
nsCStringArray mArray; // array of names in (zip) directory
|
||||
nsTArray<nsCString> mArray; // array of names in (zip) directory
|
||||
|
||||
PRPackedBool mDirectory;
|
||||
PRPackedBool mClosed; // Whether the stream is closed
|
||||
|
|
|
@ -657,7 +657,7 @@ NS_IMETHODIMP nsPrefBranch::AddObserver(const char *aDomain, nsIObserver *aObser
|
|||
}
|
||||
|
||||
mObservers->AppendElement(pCallback);
|
||||
mObserverDomains.AppendCString(nsCString(aDomain));
|
||||
mObserverDomains.AppendElement(nsCString(aDomain));
|
||||
|
||||
// We must pass a fully qualified preference name to the callback
|
||||
pref = getPrefName(aDomain); // aDomain == nsnull only possible failure, trapped above
|
||||
|
@ -689,7 +689,7 @@ NS_IMETHODIMP nsPrefBranch::RemoveObserver(const char *aDomain, nsIObserver *aOb
|
|||
pCallback = (PrefCallbackData *)mObservers->ElementAt(i);
|
||||
if (pCallback) {
|
||||
if (pCallback->pObserver == aObserver) {
|
||||
mObserverDomains.CStringAt(i, domain);
|
||||
domain = mObserverDomains[i];
|
||||
if (domain.Equals(aDomain)) {
|
||||
// We must pass a fully qualified preference name to remove the callback
|
||||
pref = getPrefName(aDomain); // aDomain == nsnull only possible failure, trapped above
|
||||
|
@ -698,7 +698,7 @@ NS_IMETHODIMP nsPrefBranch::RemoveObserver(const char *aDomain, nsIObserver *aOb
|
|||
// Remove this observer from our array so that nobody else can remove
|
||||
// what we're trying to remove ourselves right now.
|
||||
mObservers->RemoveElementAt(i);
|
||||
mObserverDomains.RemoveCStringAt(i);
|
||||
mObserverDomains.RemoveElementAt(i);
|
||||
if (pCallback->pWeakRef) {
|
||||
NS_RELEASE(pCallback->pWeakRef);
|
||||
} else {
|
||||
|
@ -768,7 +768,7 @@ void nsPrefBranch::freeObserverList(void)
|
|||
for (i = 0; i < count; ++i) {
|
||||
pCallback = (PrefCallbackData *)mObservers->ElementAt(i);
|
||||
if (pCallback) {
|
||||
mObserverDomains.CStringAt(i, domain);
|
||||
domain = mObserverDomains[i];
|
||||
// We must pass a fully qualified preference name to remove the callback
|
||||
pref = getPrefName(domain.get()); // can't fail because domain must be valid
|
||||
// Remove this observer from our array so that nobody else can remove
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsILocalFile.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsPrefBranch : public nsIPrefBranchInternal,
|
||||
|
@ -79,11 +80,11 @@ protected:
|
|||
void freeObserverList(void);
|
||||
|
||||
private:
|
||||
PRInt32 mPrefRootLength;
|
||||
nsAutoVoidArray *mObservers;
|
||||
nsCString mPrefRoot;
|
||||
nsCStringArray mObserverDomains;
|
||||
PRBool mIsDefault;
|
||||
PRInt32 mPrefRootLength;
|
||||
nsAutoVoidArray *mObservers;
|
||||
nsCString mPrefRoot;
|
||||
nsTArray<nsCString> mObserverDomains;
|
||||
PRBool mIsDefault;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include "nsNativeConnectionHelper.h"
|
||||
|
@ -748,14 +749,14 @@ nsIOService::ParsePortList(nsIPrefBranch *prefBranch, const char *pref, PRBool r
|
|||
// Get a pref string and chop it up into a list of ports.
|
||||
prefBranch->GetCharPref(pref, getter_Copies(portList));
|
||||
if (portList) {
|
||||
nsCStringArray portListArray;
|
||||
portListArray.ParseString(portList.get(), ",");
|
||||
PRInt32 index;
|
||||
for (index=0; index < portListArray.Count(); index++) {
|
||||
portListArray[index]->StripWhitespace();
|
||||
nsTArray<nsCString> portListArray;
|
||||
ParseString(portList, ',', portListArray);
|
||||
PRUint32 index;
|
||||
for (index=0; index < portListArray.Length(); index++) {
|
||||
portListArray[index].StripWhitespace();
|
||||
PRInt32 aErrorCode, portBegin, portEnd;
|
||||
|
||||
if (PR_sscanf(portListArray[index]->get(), "%d-%d", &portBegin, &portEnd) == 2) {
|
||||
if (PR_sscanf(portListArray[index].get(), "%d-%d", &portBegin, &portEnd) == 2) {
|
||||
if ((portBegin < 65536) && (portEnd < 65536)) {
|
||||
PRInt32 curPort;
|
||||
if (remove) {
|
||||
|
@ -767,7 +768,7 @@ nsIOService::ParsePortList(nsIPrefBranch *prefBranch, const char *pref, PRBool r
|
|||
}
|
||||
}
|
||||
} else {
|
||||
PRInt32 port = portListArray[index]->ToInteger(&aErrorCode);
|
||||
PRInt32 port = portListArray[index].ToInteger(&aErrorCode);
|
||||
if (NS_SUCCEEDED(aErrorCode) && port < 65536) {
|
||||
if (remove)
|
||||
mRestrictedPortList.RemoveElement((void*)port);
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
#include "nsURLHelper.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include <Files.h>
|
||||
|
||||
static nsCStringArray *gVolumeList = nsnull;
|
||||
static nsTArray<nsCString> *gVolumeList = nsnull;
|
||||
|
||||
static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPathComponent)
|
||||
{
|
||||
|
@ -57,14 +57,14 @@ static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPat
|
|||
// XXX Register an event handler to detect drives being mounted/unmounted?
|
||||
|
||||
if (!gVolumeList) {
|
||||
gVolumeList = new nsCStringArray;
|
||||
gVolumeList = new nsTArray<nsCString>;
|
||||
if (!gVolumeList) {
|
||||
return PR_FALSE; // out of memory
|
||||
}
|
||||
}
|
||||
|
||||
// Cache a list of volume names
|
||||
if (!gVolumeList->Count()) {
|
||||
if (!gVolumeList->Length()) {
|
||||
OSErr err;
|
||||
ItemCount volumeIndex = 1;
|
||||
|
||||
|
@ -75,7 +75,7 @@ static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPat
|
|||
if (err == noErr) {
|
||||
NS_ConvertUTF16toUTF8 volNameStr(Substring((PRUnichar *)volName.unicode,
|
||||
(PRUnichar *)volName.unicode + volName.length));
|
||||
gVolumeList->AppendCString(volNameStr);
|
||||
gVolumeList->AppendElement(volNameStr);
|
||||
volumeIndex++;
|
||||
}
|
||||
} while (err == noErr);
|
||||
|
|
|
@ -308,7 +308,7 @@ public:
|
|||
// CONTRACTID should be made prior to calling this method in an attempt to find a direct
|
||||
// converter rather than walking the graph.
|
||||
nsresult
|
||||
nsStreamConverterService::FindConverter(const char *aContractID, nsCStringArray **aEdgeList) {
|
||||
nsStreamConverterService::FindConverter(const char *aContractID, nsTArray<nsCString> **aEdgeList) {
|
||||
nsresult rv;
|
||||
if (!aEdgeList) return NS_ERROR_NULL_POINTER;
|
||||
*aEdgeList = nsnull;
|
||||
|
@ -420,7 +420,7 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsCStringArray
|
|||
|
||||
// get the root CONTRACTID
|
||||
nsCAutoString ContractIDPrefix(NS_ISTREAMCONVERTER_KEY);
|
||||
nsCStringArray *shortestPath = new nsCStringArray();
|
||||
nsTArray<nsCString> *shortestPath = new nsTArray<nsCString>();
|
||||
if (!shortestPath) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCStringKey toMIMEType(toStr);
|
||||
|
@ -461,7 +461,7 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsCStringArray
|
|||
newContractID.Append(key->GetString());
|
||||
|
||||
// Add this CONTRACTID to the chain.
|
||||
rv = shortestPath->AppendCString(newContractID) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
|
||||
rv = shortestPath->AppendElement(newContractID) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "AppendElement failed");
|
||||
|
||||
// move up the tree.
|
||||
|
@ -501,7 +501,7 @@ nsStreamConverterService::CanConvert(const char* aFromType,
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCStringArray *converterChain = nsnull;
|
||||
nsTArray<nsCString> *converterChain = nsnull;
|
||||
rv = FindConverter(contractID.get(), &converterChain);
|
||||
*_retval = NS_SUCCEEDED(rv);
|
||||
|
||||
|
@ -533,7 +533,7 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
|
|||
rv = BuildGraph();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCStringArray *converterChain = nsnull;
|
||||
nsTArray<nsCString> *converterChain = nsnull;
|
||||
|
||||
rv = FindConverter(cContractID, &converterChain);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -542,7 +542,7 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRInt32 edgeCount = converterChain->Count();
|
||||
PRInt32 edgeCount = PRInt32(converterChain->Length());
|
||||
NS_ASSERTION(edgeCount > 0, "findConverter should have failed");
|
||||
|
||||
|
||||
|
@ -552,12 +552,7 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
|
|||
nsCOMPtr<nsIInputStream> convertedData;
|
||||
|
||||
for (PRInt32 i = edgeCount-1; i >= 0; i--) {
|
||||
nsCString *contractIDStr = converterChain->CStringAt(i);
|
||||
if (!contractIDStr) {
|
||||
delete converterChain;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
const char *lContractID = contractIDStr->get();
|
||||
const char *lContractID = converterChain->ElementAt(i).get();
|
||||
|
||||
converter = do_CreateInstance(lContractID, &rv);
|
||||
|
||||
|
@ -619,7 +614,7 @@ nsStreamConverterService::AsyncConvertData(const char *aFromType,
|
|||
rv = BuildGraph();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCStringArray *converterChain = nsnull;
|
||||
nsTArray<nsCString> *converterChain = nsnull;
|
||||
|
||||
rv = FindConverter(cContractID, &converterChain);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -636,15 +631,10 @@ nsStreamConverterService::AsyncConvertData(const char *aFromType,
|
|||
|
||||
// convert the stream using each edge of the graph as a step.
|
||||
// this is our stream conversion traversal.
|
||||
PRInt32 edgeCount = converterChain->Count();
|
||||
PRInt32 edgeCount = PRInt32(converterChain->Length());
|
||||
NS_ASSERTION(edgeCount > 0, "findConverter should have failed");
|
||||
for (int i = 0; i < edgeCount; i++) {
|
||||
nsCString *contractIDStr = converterChain->CStringAt(i);
|
||||
if (!contractIDStr) {
|
||||
delete converterChain;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
const char *lContractID = contractIDStr->get();
|
||||
const char *lContractID = converterChain->ElementAt(i).get();
|
||||
|
||||
// create the converter for this from/to pair
|
||||
nsCOMPtr<nsIStreamConverter> converter(do_CreateInstance(lContractID));
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsIStreamListener.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class nsStreamConverterService : public nsIStreamConverterService {
|
||||
|
@ -65,7 +66,7 @@ public:
|
|||
|
||||
private:
|
||||
// Responsible for finding a converter for the given MIME-type.
|
||||
nsresult FindConverter(const char *aContractID, nsCStringArray **aEdgeList);
|
||||
nsresult FindConverter(const char *aContractID, nsTArray<nsCString> **aEdgeList);
|
||||
nsresult BuildGraph(void);
|
||||
nsresult AddAdjacency(const char *aContractID);
|
||||
nsresult ParseFromTo(const char *aContractID, nsCString &aFromRes, nsCString &aToRes);
|
||||
|
|
|
@ -222,7 +222,7 @@ mozStorageStatement::Initialize(mozStorageConnection *aDBConnection,
|
|||
|
||||
for (PRUint32 i = 0; i < mResultColumnCount; i++) {
|
||||
const char *name = sqlite3_column_name(mDBStatement, i);
|
||||
mColumnNames.AppendCString(nsDependentCString(name));
|
||||
mColumnNames.AppendElement(nsDependentCString(name));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -428,7 +428,7 @@ mozStorageStatement::GetColumnIndex(const nsACString &aName, PRUint32 *_retval)
|
|||
// Surprisingly enough, SQLite doesn't provide an API for this. We have to
|
||||
// determine it ourselves sadly.
|
||||
for (PRUint32 i = 0; i < mResultColumnCount; i++) {
|
||||
if (mColumnNames[i]->Equals(aName)) {
|
||||
if (mColumnNames[i].Equals(aName)) {
|
||||
*_retval = i;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsAutoPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "mozIStorageStatement.h"
|
||||
|
||||
|
@ -88,7 +88,7 @@ protected:
|
|||
sqlite3_stmt *mDBStatement;
|
||||
PRUint32 mParamCount;
|
||||
PRUint32 mResultColumnCount;
|
||||
nsCStringArray mColumnNames;
|
||||
nsTArray<nsCString> mColumnNames;
|
||||
PRBool mExecuting;
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,8 +65,8 @@
|
|||
#include "nsUrlClassifierUtils.h"
|
||||
#include "nsURILoader.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
@ -1464,8 +1464,8 @@ nsUrlClassifierDBServiceWorker::GetLookupFragments(const nsACString& spec,
|
|||
* successivly removing the leading component. The top-level component
|
||||
* can be skipped.
|
||||
*/
|
||||
nsCStringArray hosts;
|
||||
hosts.AppendCString(host);
|
||||
nsTArray<nsCString> hosts;
|
||||
hosts.AppendElement(host);
|
||||
|
||||
host.BeginReading(begin);
|
||||
host.EndReading(end);
|
||||
|
@ -1475,7 +1475,7 @@ nsUrlClassifierDBServiceWorker::GetLookupFragments(const nsACString& spec,
|
|||
// don't bother checking toplevel domains
|
||||
if (++numComponents >= 2) {
|
||||
host.EndReading(iter);
|
||||
hosts.AppendCString(Substring(end, iter));
|
||||
hosts.AppendElement(Substring(end, iter));
|
||||
}
|
||||
end = begin;
|
||||
host.BeginReading(begin);
|
||||
|
@ -1493,19 +1493,19 @@ nsUrlClassifierDBServiceWorker::GetLookupFragments(const nsACString& spec,
|
|||
* path component, that is, a trailing slash should never be
|
||||
* appended that was not present in the original url.
|
||||
*/
|
||||
nsCStringArray paths;
|
||||
paths.AppendCString(path);
|
||||
nsTArray<nsCString> paths;
|
||||
paths.AppendElement(path);
|
||||
|
||||
path.BeginReading(iter);
|
||||
path.EndReading(end);
|
||||
if (FindCharInReadable('?', iter, end)) {
|
||||
path.BeginReading(begin);
|
||||
path = Substring(begin, iter);
|
||||
paths.AppendCString(path);
|
||||
paths.AppendElement(path);
|
||||
}
|
||||
|
||||
// Check an empty path (for whole-domain blacklist entries)
|
||||
paths.AppendCString(EmptyCString());
|
||||
paths.AppendElement(EmptyCString());
|
||||
|
||||
numComponents = 1;
|
||||
path.BeginReading(begin);
|
||||
|
@ -1514,16 +1514,16 @@ nsUrlClassifierDBServiceWorker::GetLookupFragments(const nsACString& spec,
|
|||
while (FindCharInReadable('/', iter, end) &&
|
||||
numComponents < MAX_PATH_COMPONENTS) {
|
||||
iter++;
|
||||
paths.AppendCString(Substring(begin, iter));
|
||||
paths.AppendElement(Substring(begin, iter));
|
||||
numComponents++;
|
||||
}
|
||||
|
||||
for (int hostIndex = 0; hostIndex < hosts.Count(); hostIndex++) {
|
||||
for (int pathIndex = 0; pathIndex < paths.Count(); pathIndex++) {
|
||||
for (PRUint32 hostIndex = 0; hostIndex < hosts.Length(); hostIndex++) {
|
||||
for (PRUint32 pathIndex = 0; pathIndex < paths.Length(); pathIndex++) {
|
||||
nsCString key;
|
||||
key.Assign(*hosts[hostIndex]);
|
||||
key.Assign(hosts[hostIndex]);
|
||||
key.Append('/');
|
||||
key.Append(*paths[pathIndex]);
|
||||
key.Append(paths[pathIndex]);
|
||||
LOG(("Chking %s", key.get()));
|
||||
|
||||
fragments.AppendElement(key);
|
||||
|
@ -2016,23 +2016,23 @@ nsUrlClassifierDBServiceWorker::GetKey(const nsACString& spec,
|
|||
return hash.FromPlaintext(key, mCryptoHash);
|
||||
}
|
||||
|
||||
nsCStringArray hostComponents;
|
||||
hostComponents.ParseString(PromiseFlatCString(host).get(), ".");
|
||||
nsTArray<nsCString> hostComponents;
|
||||
ParseString(PromiseFlatCString(host), '.', hostComponents);
|
||||
|
||||
if (hostComponents.Count() < 2)
|
||||
if (hostComponents.Length() < 2)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 last = hostComponents.Count() - 1;
|
||||
PRInt32 last = PRInt32(hostComponents.Length()) - 1;
|
||||
nsCAutoString lookupHost;
|
||||
|
||||
if (hostComponents.Count() > 2) {
|
||||
lookupHost.Append(*hostComponents[last - 2]);
|
||||
if (hostComponents.Length() > 2) {
|
||||
lookupHost.Append(hostComponents[last - 2]);
|
||||
lookupHost.Append(".");
|
||||
}
|
||||
|
||||
lookupHost.Append(*hostComponents[last - 1]);
|
||||
lookupHost.Append(hostComponents[last - 1]);
|
||||
lookupHost.Append(".");
|
||||
lookupHost.Append(*hostComponents[last]);
|
||||
lookupHost.Append(hostComponents[last]);
|
||||
lookupHost.Append("/");
|
||||
|
||||
return hash.FromPlaintext(lookupHost, mCryptoHash);
|
||||
|
@ -2063,31 +2063,31 @@ nsUrlClassifierDBServiceWorker::GetHostKeys(const nsACString &spec,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCStringArray hostComponents;
|
||||
hostComponents.ParseString(PromiseFlatCString(host).get(), ".");
|
||||
nsTArray<nsCString> hostComponents;
|
||||
ParseString(PromiseFlatCString(host), '.', hostComponents);
|
||||
|
||||
if (hostComponents.Count() < 2) {
|
||||
if (hostComponents.Length() < 2) {
|
||||
// no host or toplevel host, this won't match anything in the db
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// First check with two domain components
|
||||
PRInt32 last = hostComponents.Count() - 1;
|
||||
PRInt32 last = PRInt32(hostComponents.Length()) - 1;
|
||||
nsCString *lookupHost = hostKeys.AppendElement();
|
||||
if (!lookupHost)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
lookupHost->Assign(*hostComponents[last - 1]);
|
||||
lookupHost->Assign(hostComponents[last - 1]);
|
||||
lookupHost->Append(".");
|
||||
lookupHost->Append(*hostComponents[last]);
|
||||
lookupHost->Append(hostComponents[last]);
|
||||
lookupHost->Append("/");
|
||||
|
||||
// Now check with three domain components
|
||||
if (hostComponents.Count() > 2) {
|
||||
if (hostComponents.Length() > 2) {
|
||||
nsCString *lookupHost2 = hostKeys.AppendElement();
|
||||
if (!lookupHost2)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
lookupHost2->Assign(*hostComponents[last - 2]);
|
||||
lookupHost2->Assign(hostComponents[last - 2]);
|
||||
lookupHost2->Append(".");
|
||||
lookupHost2->Append(*lookupHost);
|
||||
}
|
||||
|
@ -2217,11 +2217,11 @@ nsUrlClassifierDBServiceWorker::GetChunkEntries(const nsACString& table,
|
|||
chunk, entries);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
nsCStringArray lines;
|
||||
lines.ParseString(PromiseFlatCString(chunk).get(), "\n");
|
||||
nsTArray<nsCString> lines;
|
||||
ParseString(PromiseFlatCString(chunk), '\n', lines);
|
||||
|
||||
// non-hashed tables need to be hashed
|
||||
for (PRInt32 i = 0; i < lines.Count(); i++) {
|
||||
for (PRInt32 i = 0; i < PRInt32(lines.Length()); i++) {
|
||||
nsUrlClassifierEntry *entry = entries.AppendElement();
|
||||
if (!entry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -2229,18 +2229,18 @@ nsUrlClassifierDBServiceWorker::GetChunkEntries(const nsACString& table,
|
|||
nsCAutoString entryStr;
|
||||
if (chunkType == CHUNK_SUB) {
|
||||
nsCString::const_iterator begin, iter, end;
|
||||
lines[i]->BeginReading(begin);
|
||||
lines[i]->EndReading(end);
|
||||
lines[i].BeginReading(begin);
|
||||
lines[i].EndReading(end);
|
||||
iter = begin;
|
||||
if (!FindCharInReadable(':', iter, end) ||
|
||||
PR_sscanf(lines[i]->get(), "%d:", &entry->mAddChunkId) != 1) {
|
||||
PR_sscanf(lines[i].get(), "%d:", &entry->mAddChunkId) != 1) {
|
||||
NS_WARNING("Received sub chunk without associated add chunk.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
iter++;
|
||||
entryStr = Substring(iter, end);
|
||||
} else {
|
||||
entryStr = *lines[i];
|
||||
entryStr = lines[i];
|
||||
}
|
||||
|
||||
rv = GetKey(entryStr, entry->mKey);
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsUrlClassifierUtils.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "plbase64.h"
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
|
@ -263,9 +264,9 @@ nsUrlClassifierUtils::ParseIPAddress(const nsACString & host,
|
|||
}
|
||||
|
||||
host.BeginReading(iter);
|
||||
nsCStringArray parts;
|
||||
parts.ParseString(PromiseFlatCString(Substring(iter, end)).get(), ".");
|
||||
if (parts.Count() > 4) {
|
||||
nsTArray<nsCString> parts;
|
||||
ParseString(PromiseFlatCString(Substring(iter, end)), '.', parts);
|
||||
if (parts.Length() > 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -274,8 +275,10 @@ nsUrlClassifierUtils::ParseIPAddress(const nsACString & host,
|
|||
// XXX: this came from the old javascript implementation, is it really
|
||||
// supposed to be like this?
|
||||
PRBool allowOctal = PR_TRUE;
|
||||
for (PRInt32 i = 0; i < parts.Count(); i++) {
|
||||
const nsCString& part = *parts[i];
|
||||
PRUint32 i;
|
||||
|
||||
for (i = 0; i < parts.Length(); i++) {
|
||||
const nsCString& part = parts[i];
|
||||
if (part[0] == '0') {
|
||||
for (PRUint32 j = 1; j < part.Length(); j++) {
|
||||
if (part[j] == 'x') {
|
||||
|
@ -289,13 +292,13 @@ nsUrlClassifierUtils::ParseIPAddress(const nsACString & host,
|
|||
}
|
||||
}
|
||||
|
||||
for (PRInt32 i = 0; i < parts.Count(); i++) {
|
||||
for (i = 0; i < parts.Length(); i++) {
|
||||
nsCAutoString canonical;
|
||||
|
||||
if (i == parts.Count() - 1) {
|
||||
CanonicalNum(*parts[i], 5 - parts.Count(), allowOctal, canonical);
|
||||
if (i == parts.Length() - 1) {
|
||||
CanonicalNum(parts[i], 5 - parts.Length(), allowOctal, canonical);
|
||||
} else {
|
||||
CanonicalNum(*parts[i], 1, allowOctal, canonical);
|
||||
CanonicalNum(parts[i], 1, allowOctal, canonical);
|
||||
}
|
||||
|
||||
if (canonical.IsEmpty()) {
|
||||
|
|
|
@ -582,7 +582,7 @@ PR_Malloc
|
|||
nsVoidArray::SizeTo(int)
|
||||
nsVoidArray::GrowArrayBy(int)
|
||||
nsVoidArray::InsertElementAt(void *, int)
|
||||
nsCStringArray::InsertCStringAt(nsCString const &, int)
|
||||
nsTArray<nsCString>::InsertElementAt(int, nsCString const &)
|
||||
nsFontMetricsGTK::QueryInterface(nsID const &, void **)
|
||||
|
||||
<nsFontMetricsGTK>
|
||||
|
@ -2466,7 +2466,7 @@ PR_Malloc
|
|||
nsVoidArray::SizeTo(int)
|
||||
nsVoidArray::GrowArrayBy(int)
|
||||
nsVoidArray::InsertElementAt(void *, int)
|
||||
nsCStringArray::InsertCStringAt(nsCString const &, int)
|
||||
nsTArray<nsCString>::InsertElementAt(int, nsCString const &)
|
||||
nsMIMEInfoImpl::SetFileExtensions(char const *)
|
||||
nsExternalHelperAppService::AddDefaultMimeTypesToCache(void)
|
||||
|
||||
|
@ -3631,7 +3631,7 @@ nsStr::GrowCapacity(nsStr &, unsigned int)
|
|||
nsStr::StrAppend(nsStr &, nsStr const &, unsigned int, int)
|
||||
nsStr::StrAssign(nsStr &, nsStr const &, unsigned int, int)
|
||||
nsCString::nsCString(nsCString const &)
|
||||
nsCStringArray::InsertCStringAt(nsCString const &, int)
|
||||
nsTArray<nsCString>::InsertElementAt(int, nsCString const &)
|
||||
nsPrefBranch::AddObserver(char const *, nsIObserver *)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -5822,7 +5822,7 @@ PR_Malloc
|
|||
nsVoidArray::SizeTo(int)
|
||||
nsVoidArray::GrowArrayBy(int)
|
||||
nsVoidArray::InsertElementAt(void *, int)
|
||||
nsCStringArray::InsertCStringAt(nsCString const &, int)
|
||||
nsTArray<nsCString>::InsertElementAt(int, nsCString const &)
|
||||
nsXMLMIMEDataSource::AddMapping(char const *, char const *, char const *, nsIURI *, unsigned int, unsigned int)
|
||||
|
||||
<nsXMLMIMEDataSource>
|
||||
|
|
|
@ -112,12 +112,12 @@ nsMIMEInfoBase::ExtensionExists(const nsACString& aExtension, PRBool *_retval)
|
|||
{
|
||||
NS_ASSERTION(!aExtension.IsEmpty(), "no extension");
|
||||
PRBool found = PR_FALSE;
|
||||
PRUint32 extCount = mExtensions.Count();
|
||||
PRUint32 extCount = mExtensions.Length();
|
||||
if (extCount < 1) return NS_OK;
|
||||
|
||||
for (PRUint8 i=0; i < extCount; i++) {
|
||||
nsCString* ext = (nsCString*)mExtensions.CStringAt(i);
|
||||
if (ext->Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
|
||||
const nsCString& ext = mExtensions[i];
|
||||
if (ext.Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -130,10 +130,10 @@ nsMIMEInfoBase::ExtensionExists(const nsACString& aExtension, PRBool *_retval)
|
|||
NS_IMETHODIMP
|
||||
nsMIMEInfoBase::GetPrimaryExtension(nsACString& _retval)
|
||||
{
|
||||
PRUint32 extCount = mExtensions.Count();
|
||||
if (extCount < 1) return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mExtensions.Length())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
_retval = *(mExtensions.CStringAt(0));
|
||||
_retval = mExtensions[0];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -141,21 +141,21 @@ NS_IMETHODIMP
|
|||
nsMIMEInfoBase::SetPrimaryExtension(const nsACString& aExtension)
|
||||
{
|
||||
NS_ASSERTION(!aExtension.IsEmpty(), "no extension");
|
||||
PRUint32 extCount = mExtensions.Count();
|
||||
PRUint32 extCount = mExtensions.Length();
|
||||
PRUint8 i;
|
||||
PRBool found = PR_FALSE;
|
||||
for (i=0; i < extCount; i++) {
|
||||
nsCString* ext = (nsCString*)mExtensions.CStringAt(i);
|
||||
if (ext->Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
|
||||
const nsCString& ext = mExtensions[i];
|
||||
if (ext.Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
mExtensions.RemoveCStringAt(i);
|
||||
mExtensions.RemoveElementAt(i);
|
||||
}
|
||||
|
||||
mExtensions.InsertCStringAt(aExtension, 0);
|
||||
mExtensions.InsertElementAt(0, aExtension);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ nsMIMEInfoBase::SetPrimaryExtension(const nsACString& aExtension)
|
|||
NS_IMETHODIMP
|
||||
nsMIMEInfoBase::AppendExtension(const nsACString& aExtension)
|
||||
{
|
||||
mExtensions.AppendCString(aExtension);
|
||||
mExtensions.AppendElement(aExtension);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -260,11 +260,11 @@ nsMIMEInfoBase::SetFileExtensions(const nsACString& aExtensions)
|
|||
PRInt32 breakLocation = -1;
|
||||
while ( (breakLocation= extList.FindChar(',') )!= -1)
|
||||
{
|
||||
mExtensions.AppendCString(Substring(extList.get(), extList.get() + breakLocation));
|
||||
mExtensions.AppendElement(Substring(extList.get(), extList.get() + breakLocation));
|
||||
extList.Cut(0, breakLocation+1 );
|
||||
}
|
||||
if ( !extList.IsEmpty() )
|
||||
mExtensions.AppendCString( extList );
|
||||
mExtensions.AppendElement( extList );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsIMIMEInfo.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -125,7 +125,7 @@ class nsMIMEInfoBase : public nsIMIMEInfo {
|
|||
/**
|
||||
* Return whether this MIMEInfo has any extensions
|
||||
*/
|
||||
PRBool HasExtensions() const { return mExtensions.Count() != 0; }
|
||||
PRBool HasExtensions() const { return mExtensions.Length() != 0; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@ class nsMIMEInfoBase : public nsIMIMEInfo {
|
|||
nsILocalFile **aFile);
|
||||
|
||||
// member variables
|
||||
nsCStringArray mExtensions; ///< array of file extensions associated w/ this MIME obj
|
||||
nsTArray<nsCString> mExtensions; ///< array of file extensions associated w/ this MIME obj
|
||||
nsString mDescription; ///< human readable description
|
||||
PRUint32 mMacType, mMacCreator; ///< Mac file type and creator
|
||||
nsCString mType;
|
||||
|
|
|
@ -1069,18 +1069,6 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::DisplayPropertiesDlg(const PRUnichar *aPri
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//String array enumeration callback to append a printer to the global
|
||||
//printer list.
|
||||
static PRBool
|
||||
GlobalPrinterEnumFunc(nsCString& aName, void *aData)
|
||||
{
|
||||
nsTArray<nsString> *a = (nsTArray<nsString> *)aData;
|
||||
a->AppendElement(NS_ConvertUTF8toUTF16(aName));
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||
{
|
||||
|
@ -1101,9 +1089,15 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
|||
nsPSPrinterList psMgr;
|
||||
if (NS_SUCCEEDED(psMgr.Init()) && psMgr.Enabled()) {
|
||||
/* Get the list of PostScript-module printers */
|
||||
nsCStringArray printerList;
|
||||
// XXX: this function is the only user of GetPrinterList
|
||||
// So it may be interesting to convert the nsCStrings
|
||||
// in this function, we would save one loop here
|
||||
nsTArray<nsCString> printerList;
|
||||
psMgr.GetPrinterList(printerList);
|
||||
printerList.EnumerateForwards(GlobalPrinterEnumFunc, mGlobalPrinterList);
|
||||
for (PRUint32 i = 0; i < printerList.Length(); i++)
|
||||
{
|
||||
mGlobalPrinterList->AppendElement(NS_ConvertUTF8toUTF16(printerList[i]));
|
||||
}
|
||||
}
|
||||
#endif /* USE_POSTSCRIPT */
|
||||
|
||||
|
|
|
@ -278,8 +278,8 @@ nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
|
|||
CopyUTF16toUTF8(aFilter, filter);
|
||||
CopyUTF16toUTF8(aTitle, name);
|
||||
|
||||
mFilters.AppendCString(filter);
|
||||
mFilterNames.AppendCString(name);
|
||||
mFilters.AppendElement(filter);
|
||||
mFilterNames.AppendElement(name);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -484,12 +484,12 @@ nsFilePicker::Show(PRInt16 *aReturn)
|
|||
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(file_chooser), GTK_RESPONSE_ACCEPT);
|
||||
|
||||
PRInt32 count = mFilters.Count();
|
||||
PRInt32 count = mFilters.Length();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
// This is fun... the GTK file picker does not accept a list of filters
|
||||
// so we need to split out each string, and add it manually.
|
||||
|
||||
char **patterns = g_strsplit(mFilters[i]->get(), ";", -1);
|
||||
char **patterns = g_strsplit(mFilters[i].get(), ";", -1);
|
||||
if (!patterns) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -502,13 +502,13 @@ nsFilePicker::Show(PRInt16 *aReturn)
|
|||
|
||||
g_strfreev(patterns);
|
||||
|
||||
if (!mFilterNames[i]->IsEmpty()) {
|
||||
if (!mFilterNames[i].IsEmpty()) {
|
||||
// If we have a name for our filter, let's use that.
|
||||
const char *filter_name = mFilterNames[i]->get();
|
||||
const char *filter_name = mFilterNames[i].get();
|
||||
gtk_file_filter_set_name(filter, filter_name);
|
||||
} else {
|
||||
// If we don't have a name, let's just use the filter pattern.
|
||||
const char *filter_pattern = mFilters[i]->get();
|
||||
const char *filter_pattern = mFilters[i].get();
|
||||
gtk_file_filter_set_name(filter, filter_pattern);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include "nsBaseFilePicker.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
class nsIWidget;
|
||||
|
@ -89,8 +89,8 @@ protected:
|
|||
nsString mDefault;
|
||||
nsString mDefaultExtension;
|
||||
|
||||
nsCStringArray mFilters;
|
||||
nsCStringArray mFilterNames;
|
||||
nsTArray<nsCString> mFilters;
|
||||
nsTArray<nsCString> mFilterNames;
|
||||
|
||||
private:
|
||||
static nsILocalFile *mPrevDisplayDirectory;
|
||||
|
|
|
@ -1810,7 +1810,7 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
|||
|
||||
nsCOMPtr<nsILocalFile> iconFile;
|
||||
nsCAutoString path;
|
||||
nsCStringArray iconList;
|
||||
nsTArray<nsCString> iconList;
|
||||
|
||||
// Look for icons with the following suffixes appended to the base name.
|
||||
// The last two entries (for the old XPM format) will be ignored unless
|
||||
|
@ -1821,7 +1821,7 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
|||
|
||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(extensions); i++) {
|
||||
// Don't bother looking for XPM versions if we found a PNG.
|
||||
if (i == NS_ARRAY_LENGTH(extensions) - 2 && iconList.Count())
|
||||
if (i == NS_ARRAY_LENGTH(extensions) - 2 && iconList.Length())
|
||||
break;
|
||||
|
||||
nsAutoString extension;
|
||||
|
@ -1830,12 +1830,12 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
|||
ResolveIconName(aIconSpec, extension, getter_AddRefs(iconFile));
|
||||
if (iconFile) {
|
||||
iconFile->GetNativePath(path);
|
||||
iconList.AppendCString(path);
|
||||
iconList.AppendElement(path);
|
||||
}
|
||||
}
|
||||
|
||||
// leave the default icon intact if no matching icons were found
|
||||
if (iconList.Count() == 0)
|
||||
if (iconList.Length() == 0)
|
||||
return NS_OK;
|
||||
|
||||
return SetWindowIconList(iconList);
|
||||
|
@ -4690,12 +4690,12 @@ nsWindow::SetupPluginPort(void)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsWindow::SetWindowIconList(const nsCStringArray &aIconList)
|
||||
nsWindow::SetWindowIconList(const nsTArray<nsCString> &aIconList)
|
||||
{
|
||||
GList *list = NULL;
|
||||
|
||||
for (int i = 0; i < aIconList.Count(); ++i) {
|
||||
const char *path = aIconList[i]->get();
|
||||
for (PRUint32 i = 0; i < aIconList.Length(); ++i) {
|
||||
const char *path = aIconList[i].get();
|
||||
LOG(("window [%p] Loading icon from %s\n", (void *)this, path));
|
||||
|
||||
GdkPixbuf *icon = gdk_pixbuf_new_from_file(path, NULL);
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#define FORCE_PR_LOG
|
||||
|
||||
#include "prlog.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
extern PRLogModuleInfo *gWidgetLog;
|
||||
extern PRLogModuleInfo *gWidgetFocusLog;
|
||||
|
@ -477,7 +478,7 @@ private:
|
|||
void GetContainerWindow(nsWindow **aWindow);
|
||||
void SetUrgencyHint(GtkWidget *top_window, PRBool state);
|
||||
void *SetupPluginPort(void);
|
||||
nsresult SetWindowIconList(const nsCStringArray &aIconList);
|
||||
nsresult SetWindowIconList(const nsTArray<nsCString> &aIconList);
|
||||
void SetDefaultIcon(void);
|
||||
void InitButtonEvent(nsMouseEvent &aEvent, GdkEventButton *aGdkEvent);
|
||||
PRBool DispatchCommandEvent(nsIAtom* aCommand);
|
||||
|
|
|
@ -93,8 +93,8 @@ nsFilePicker::AppendFilter(const nsAString & aTitle, const nsAString & aFilter)
|
|||
CopyUTF16toUTF8(aFilter, filter);
|
||||
CopyUTF16toUTF8(aTitle, name);
|
||||
|
||||
mFilters.AppendCString(filter);
|
||||
mFilterNames.AppendCString(name);
|
||||
mFilters.AppendElement(filter);
|
||||
mFilterNames.AppendElement(name);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -224,9 +224,9 @@ nsFilePicker::Show(PRInt16 *aReturn)
|
|||
mDialog->setDirectory(directory.get());
|
||||
|
||||
QStringList filters;
|
||||
PRInt32 count = mFilters.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
filters.append( mFilters[i]->get() );
|
||||
PRUint32 count = mFilters.Length();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
filters.append( mFilters[i].get() );
|
||||
}
|
||||
mDialog->setFilters(filters);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "nsBaseFilePicker.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include <qfiledialog.h>
|
||||
|
||||
class nsIWidget;
|
||||
|
@ -88,8 +88,8 @@ protected:
|
|||
nsString mDefault;
|
||||
nsString mDefaultExtension;
|
||||
|
||||
nsCStringArray mFilters;
|
||||
nsCStringArray mFilterNames;
|
||||
nsTArray<nsCString> mFilters;
|
||||
nsTArray<nsCString> mFilterNames;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -876,7 +876,7 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
|||
|
||||
nsCOMPtr<nsILocalFile> iconFile;
|
||||
nsCAutoString path;
|
||||
nsCStringArray iconList;
|
||||
nsTArray<nsCString> iconList;
|
||||
|
||||
// Look for icons with the following suffixes appended to the base name.
|
||||
// The last two entries (for the old XPM format) will be ignored unless
|
||||
|
@ -887,7 +887,7 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
|||
|
||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(extensions); i++) {
|
||||
// Don't bother looking for XPM versions if we found a PNG.
|
||||
if (i == NS_ARRAY_LENGTH(extensions) - 2 && iconList.Count())
|
||||
if (i == NS_ARRAY_LENGTH(extensions) - 2 && iconList.Length())
|
||||
break;
|
||||
|
||||
nsAutoString extension;
|
||||
|
@ -896,12 +896,12 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
|||
ResolveIconName(aIconSpec, extension, getter_AddRefs(iconFile));
|
||||
if (iconFile) {
|
||||
iconFile->GetNativePath(path);
|
||||
iconList.AppendCString(path);
|
||||
iconList.AppendElement(path);
|
||||
}
|
||||
}
|
||||
|
||||
// leave the default icon intact if no matching icons were found
|
||||
if (iconList.Count() == 0)
|
||||
if (iconList.Length() == 0)
|
||||
return NS_OK;
|
||||
|
||||
return SetWindowIconList(iconList);
|
||||
|
@ -2002,7 +2002,7 @@ nsWindow::SetupPluginPort(void)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsWindow::SetWindowIconList(const nsCStringArray &aIconList)
|
||||
nsWindow::SetWindowIconList(const nsTArray<nsCString> &aIconList)
|
||||
{
|
||||
qDebug("FIXME:>>>>>>Func:%s::%d\n", __PRETTY_FUNCTION__, __LINE__);
|
||||
return NS_OK;
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#define FORCE_PR_LOG
|
||||
|
||||
#include "prlog.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
extern PRLogModuleInfo *gWidgetLog;
|
||||
extern PRLogModuleInfo *gWidgetFocusLog;
|
||||
|
@ -349,7 +350,7 @@ private:
|
|||
void GetToplevelWidget(QWidget **aWidget);
|
||||
void SetUrgencyHint(QWidget *top_window, PRBool state);
|
||||
void *SetupPluginPort(void);
|
||||
nsresult SetWindowIconList(const nsCStringArray &aIconList);
|
||||
nsresult SetWindowIconList(const nsTArray<nsCString> &aIconList);
|
||||
void SetDefaultIcon(void);
|
||||
void InitButtonEvent(nsMouseEvent &event, QMouseEvent *aEvent, int aClickCount = 1);
|
||||
PRBool DispatchCommandEvent(nsIAtom* aCommand);
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsTPtrArray.h"
|
||||
#include "nsVoidArray.h" // for nsCStringArray
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -471,7 +471,7 @@ struct PtrInfo
|
|||
PtrInfo* mShortestPathToExpectedGarbage;
|
||||
nsCString* mShortestPathToExpectedGarbageEdgeName;
|
||||
|
||||
nsCStringArray mEdgeNames;
|
||||
nsTArray<nsCString> mEdgeNames;
|
||||
#endif
|
||||
|
||||
PtrInfo(void *aPointer, nsCycleCollectionParticipant *aParticipant
|
||||
|
@ -499,7 +499,7 @@ struct PtrInfo
|
|||
#ifdef DEBUG_CC
|
||||
void Destroy() {
|
||||
PL_strfree(mName);
|
||||
mEdgeNames.~nsCStringArray();
|
||||
mEdgeNames.~nsTArray<nsCString>();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1407,7 +1407,7 @@ GCGraphBuilder::NoteXPCOMChild(nsISupports *child)
|
|||
return;
|
||||
mEdgeBuilder.Add(childPi);
|
||||
#ifdef DEBUG_CC
|
||||
mCurrPi->mEdgeNames.AppendCString(edgeName);
|
||||
mCurrPi->mEdgeNames.AppendElement(edgeName);
|
||||
#endif
|
||||
++childPi->mInternalRefs;
|
||||
}
|
||||
|
@ -1431,7 +1431,7 @@ GCGraphBuilder::NoteNativeChild(void *child,
|
|||
return;
|
||||
mEdgeBuilder.Add(childPi);
|
||||
#ifdef DEBUG_CC
|
||||
mCurrPi->mEdgeNames.AppendCString(edgeName);
|
||||
mCurrPi->mEdgeNames.AppendElement(edgeName);
|
||||
#endif
|
||||
++childPi->mInternalRefs;
|
||||
}
|
||||
|
@ -1466,7 +1466,7 @@ GCGraphBuilder::NoteScriptChild(PRUint32 langID, void *child)
|
|||
return;
|
||||
mEdgeBuilder.Add(childPi);
|
||||
#ifdef DEBUG_CC
|
||||
mCurrPi->mEdgeNames.AppendCString(edgeName);
|
||||
mCurrPi->mEdgeNames.AppendElement(edgeName);
|
||||
#endif
|
||||
++childPi->mInternalRefs;
|
||||
}
|
||||
|
@ -2822,7 +2822,7 @@ nsCycleCollector::CreateReversedEdges()
|
|||
for (EdgePool::Iterator e = pi->mFirstChild, e_end = pi->mLastChild;
|
||||
e != e_end; ++e) {
|
||||
current->mTarget = pi;
|
||||
current->mEdgeName = pi->mEdgeNames.CStringAt(i);
|
||||
current->mEdgeName = pi->mEdgeNames[i];
|
||||
current->mNext = (*e)->mReversedEdges;
|
||||
(*e)->mReversedEdges = current;
|
||||
++current;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
#include "nsINIParser.h"
|
||||
#include "nsStringEnumerator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsINIParserImpl :
|
||||
public nsIINIParser
|
||||
|
@ -103,16 +103,16 @@ NS_IMPL_ISUPPORTS1(nsINIParserImpl,
|
|||
static PRBool
|
||||
SectionCB(const char* aSection, void *aClosure)
|
||||
{
|
||||
nsCStringArray *strings = static_cast<nsCStringArray*>(aClosure);
|
||||
nsTArray<nsCString> *strings = static_cast<nsTArray<nsCString>*>(aClosure);
|
||||
|
||||
strings->AppendCString(nsDependentCString(aSection));
|
||||
strings->AppendElement(nsDependentCString(aSection));
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsINIParserImpl::GetSections(nsIUTF8StringEnumerator* *aResult)
|
||||
{
|
||||
nsCStringArray *strings = new nsCStringArray;
|
||||
nsTArray<nsCString> *strings = new nsTArray<nsCString>;
|
||||
if (!strings)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -129,9 +129,9 @@ nsINIParserImpl::GetSections(nsIUTF8StringEnumerator* *aResult)
|
|||
static PRBool
|
||||
KeyCB(const char* aKey, const char *aValue, void *aClosure)
|
||||
{
|
||||
nsCStringArray *strings = static_cast<nsCStringArray*>(aClosure);
|
||||
nsTArray<nsCString> *strings = static_cast<nsTArray<nsCString>*>(aClosure);
|
||||
|
||||
strings->AppendCString(nsDependentCString(aKey));
|
||||
strings->AppendElement(nsDependentCString(aKey));
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ NS_IMETHODIMP
|
|||
nsINIParserImpl::GetKeys(const nsACString& aSection,
|
||||
nsIUTF8StringEnumerator* *aResult)
|
||||
{
|
||||
nsCStringArray *strings = new nsCStringArray;
|
||||
nsTArray<nsCString> *strings = new nsTArray<nsCString>;
|
||||
if (!strings)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE)
|
||||
{}
|
||||
|
||||
nsStringEnumerator(const nsCStringArray* aArray, PRBool aOwnsArray) :
|
||||
nsStringEnumerator(const nsTArray<nsCString>* aArray, PRBool aOwnsArray) :
|
||||
mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE)
|
||||
{}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE)
|
||||
{}
|
||||
|
||||
nsStringEnumerator(const nsCStringArray* aArray, nsISupports* aOwner) :
|
||||
nsStringEnumerator(const nsTArray<nsCString>* aArray, nsISupports* aOwner) :
|
||||
mCArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_FALSE)
|
||||
{}
|
||||
|
||||
|
@ -87,17 +87,17 @@ private:
|
|||
if (mIsUnicode)
|
||||
delete const_cast<nsTArray<nsString>*>(mArray);
|
||||
else
|
||||
delete const_cast<nsCStringArray*>(mCArray);
|
||||
delete const_cast<nsTArray<nsCString>*>(mCArray);
|
||||
}
|
||||
}
|
||||
|
||||
union {
|
||||
const nsTArray<nsString>* mArray;
|
||||
const nsCStringArray* mCArray;
|
||||
const nsTArray<nsCString>* mCArray;
|
||||
};
|
||||
|
||||
inline PRUint32 Count() {
|
||||
return mIsUnicode ? mArray->Length() : mCArray->Count();
|
||||
return mIsUnicode ? mArray->Length() : mCArray->Length();
|
||||
}
|
||||
|
||||
PRUint32 mIndex;
|
||||
|
@ -144,7 +144,7 @@ nsStringEnumerator::GetNext(nsISupports** aResult)
|
|||
nsSupportsCStringImpl* cstringImpl = new nsSupportsCStringImpl();
|
||||
if (!cstringImpl) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
cstringImpl->SetData(*mCArray->CStringAt(mIndex++));
|
||||
cstringImpl->SetData(mCArray->ElementAt(mIndex++));
|
||||
*aResult = cstringImpl;
|
||||
}
|
||||
NS_ADDREF(*aResult);
|
||||
|
@ -159,7 +159,7 @@ nsStringEnumerator::GetNext(nsAString& aResult)
|
|||
if (mIsUnicode)
|
||||
aResult = mArray->ElementAt(mIndex++);
|
||||
else
|
||||
CopyUTF8toUTF16(*mCArray->CStringAt(mIndex++), aResult);
|
||||
CopyUTF8toUTF16(mCArray->ElementAt(mIndex++), aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ nsStringEnumerator::GetNext(nsACString& aResult)
|
|||
if (mIsUnicode)
|
||||
CopyUTF16toUTF8(mArray->ElementAt(mIndex++), aResult);
|
||||
else
|
||||
aResult = *mCArray->CStringAt(mIndex++);
|
||||
aResult = mCArray->ElementAt(mIndex++);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
|||
|
||||
NS_COM nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||
const nsCStringArray* aArray, nsISupports* aOwner)
|
||||
const nsTArray<nsCString>* aArray, nsISupports* aOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
|
@ -227,7 +227,7 @@ NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
|
|||
|
||||
NS_COM nsresult
|
||||
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||
nsCStringArray* aArray)
|
||||
nsTArray<nsCString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
|
@ -250,7 +250,7 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
|||
|
||||
NS_COM nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||
const nsCStringArray* aArray)
|
||||
const nsTArray<nsCString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIStringEnumerator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
// nsIStringEnumerator/nsIUTF8StringEnumerator implementations
|
||||
|
@ -66,7 +66,7 @@
|
|||
// outlast the array.
|
||||
// For example:
|
||||
//
|
||||
// nsCStringArray array;
|
||||
// nsTArray<nsCString> array;
|
||||
// array.AppendCString("abc");
|
||||
// array.AppendCString("def");
|
||||
// NS_NewStringEnumerator(&enumerator, &array, PR_TRUE);
|
||||
|
@ -81,7 +81,7 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
|||
nsISupports* aOwner);
|
||||
NS_COM nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
|
||||
const nsCStringArray* aArray);
|
||||
const nsTArray<nsCString>* aArray);
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
||||
|
@ -93,7 +93,7 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
|||
// purpose of creating the enumerator.
|
||||
// For example:
|
||||
//
|
||||
// nsCStringArray* array = new nsCStringArray;
|
||||
// nsTArray<nsCString>* array = new nsTArray<nsCString>;
|
||||
// array->AppendString("abcd");
|
||||
// NS_NewAdoptingStringEnumerator(&result, array);
|
||||
NS_COM nsresult
|
||||
|
@ -102,7 +102,7 @@ NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
|||
|
||||
NS_COM nsresult
|
||||
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
|
||||
nsCStringArray* aArray);
|
||||
nsTArray<nsCString>* aArray);
|
||||
|
||||
|
||||
// these versions take a refcounted "owner" which will be addreffed
|
||||
|
@ -119,5 +119,5 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM
|
|||
//
|
||||
NS_COM nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
|
||||
const nsCStringArray* aArray,
|
||||
const nsTArray<nsCString>* aArray,
|
||||
nsISupports* aOwner);
|
||||
|
|
|
@ -1146,3 +1146,35 @@ CaseInsensitiveCompare(const char *a, const char *b,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRBool
|
||||
ParseString(const nsACString& aSource, char aDelimiter,
|
||||
nsTArray<nsCString>& aArray)
|
||||
{
|
||||
PRInt32 start = 0;
|
||||
PRInt32 end = aSource.Length();
|
||||
|
||||
PRUint32 oldLength = aArray.Length();
|
||||
|
||||
for (;;) {
|
||||
PRInt32 delimiter = aSource.FindChar(aDelimiter, start);
|
||||
if (delimiter < 0) {
|
||||
delimiter = end;
|
||||
}
|
||||
|
||||
if (delimiter != start) {
|
||||
if (!aArray.AppendElement(Substring(aSource, start, delimiter - start))) {
|
||||
aArray.RemoveElementsAt(oldLength, aArray.Length() - oldLength);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (delimiter == end)
|
||||
break;
|
||||
start = ++delimiter;
|
||||
if (start == end)
|
||||
break;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsXPCOMStrings.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "prlog.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsAString
|
||||
{
|
||||
|
@ -1418,4 +1419,7 @@ typedef nsCString PromiseFlatCString;
|
|||
typedef nsCString nsCAutoString;
|
||||
typedef nsString nsAutoString;
|
||||
|
||||
NS_HIDDEN_(PRBool) ParseString(const nsACString& aAstring, char aDelimiter,
|
||||
nsTArray<nsCString>& aArray);
|
||||
|
||||
#endif // nsStringAPI_h__
|
||||
|
|
|
@ -937,46 +937,6 @@ nsCStringArray::nsCStringArray(void)
|
|||
{
|
||||
}
|
||||
|
||||
// Parses a given string using the delimiter passed in and appends items
|
||||
// parsed to the array.
|
||||
PRBool
|
||||
nsCStringArray::ParseString(const char* string, const char* delimiter)
|
||||
{
|
||||
if (string && *string && delimiter && *delimiter) {
|
||||
char *rest = strdup(string);
|
||||
if (!rest)
|
||||
return PR_FALSE;
|
||||
char *newStr = rest;
|
||||
char *token = NS_strtok(delimiter, &newStr);
|
||||
|
||||
PRInt32 count = Count();
|
||||
while (token) {
|
||||
if (*token) {
|
||||
/* calling AppendElement(void*) to avoid extra nsCString copy */
|
||||
nsCString *cstring = new nsCString(token);
|
||||
if (cstring && !AppendElement(cstring)) {
|
||||
// AppendElement failed, release and null cstring so we fall
|
||||
// through to the case below.
|
||||
delete cstring;
|
||||
cstring = nsnull;
|
||||
}
|
||||
if (!cstring) {
|
||||
// We've run out of memory. Remove all newly appended elements from
|
||||
// our array so we don't leave ourselves in a partially added state.
|
||||
// When we return, the array will be precisely as it was when this
|
||||
// function was called.
|
||||
RemoveElementsAt(count, Count() - count);
|
||||
free(rest);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
token = NS_strtok(delimiter, &newStr);
|
||||
}
|
||||
free(rest);
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsCStringArray::nsCStringArray(PRInt32 aCount)
|
||||
: nsVoidArray(aCount)
|
||||
{
|
||||
|
|
|
@ -270,13 +270,6 @@ public:
|
|||
|
||||
nsCStringArray& operator=(const nsCStringArray& other);
|
||||
|
||||
// Parses a given string using the delimiter passed in. If the array
|
||||
// already has some elements, items parsed from string will be appended
|
||||
// to array. For example, array.ParseString("a,b,c", ","); will add strings
|
||||
// "a", "b" and "c" to the array. Parsing process has the same tokenizing
|
||||
// behavior as strtok().
|
||||
PRBool ParseString(const char* string, const char* delimiter);
|
||||
|
||||
PRInt32 Count(void) const {
|
||||
return nsVoidArray::Count();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#ifndef nsAString_h___
|
||||
#include "nsAString.h"
|
||||
#endif
|
||||
#include "nsTArray.h"
|
||||
|
||||
inline size_t Distance( const nsReadingIterator<PRUnichar>& start, const nsReadingIterator<PRUnichar>& end )
|
||||
{
|
||||
|
@ -252,6 +253,8 @@ NS_COM PRBool IsASCII( const nsACString& aString );
|
|||
*/
|
||||
NS_COM PRBool IsUTF8( const nsACString& aString );
|
||||
|
||||
NS_COM PRBool ParseString(const nsACString& aAstring, char aDelimiter,
|
||||
nsTArray<nsCString>& aArray);
|
||||
|
||||
/**
|
||||
* Converts case in place in the argument string.
|
||||
|
|
|
@ -791,6 +791,41 @@ ToLowerCase( const nsACString& aSource, nsACString& aDest )
|
|||
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
|
||||
}
|
||||
|
||||
NS_COM
|
||||
PRBool
|
||||
ParseString(const nsACString& aSource, char aDelimiter,
|
||||
nsTArray<nsCString>& aArray)
|
||||
{
|
||||
nsACString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
|
||||
PRUint32 oldLength = aArray.Length();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
nsACString::const_iterator delimiter = start;
|
||||
FindCharInReadable(aDelimiter, delimiter, end);
|
||||
|
||||
if (delimiter != start)
|
||||
{
|
||||
if (!aArray.AppendElement(Substring(start, delimiter)))
|
||||
{
|
||||
aArray.RemoveElementsAt(oldLength, aArray.Length() - oldLength);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (delimiter == end)
|
||||
break;
|
||||
start = ++delimiter;
|
||||
if (start == end)
|
||||
break;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
template <class StringT, class IteratorT, class Comparator>
|
||||
PRBool
|
||||
FindInReadable_Impl( const StringT& aPattern, IteratorT& aSearchStart, IteratorT& aSearchEnd, const Comparator& compare )
|
||||
|
|
|
@ -921,6 +921,50 @@ PRBool test_string_tointeger()
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper(const char* str, char separator, int len,
|
||||
const char* s1, const char* s2)
|
||||
{
|
||||
nsCString data(str);
|
||||
nsTArray<nsCString> results;
|
||||
if (!ParseString(data, separator, results))
|
||||
return PR_FALSE;
|
||||
if (int(results.Length()) != len)
|
||||
return PR_FALSE;
|
||||
const char* strings[] = { s1, s2 };
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!results[i].Equals(strings[i]))
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper0(const char* str, char separator)
|
||||
{
|
||||
return test_parse_string_helper(str, separator, 0, nsnull, nsnull);
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper1(const char* str, char separator, const char* s1)
|
||||
{
|
||||
return test_parse_string_helper(str, separator, 1, s1, nsnull);
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper2(const char* str, char separator, const char* s1, const char* s2)
|
||||
{
|
||||
return test_parse_string_helper(str, separator, 2, s1, s2);
|
||||
}
|
||||
|
||||
static PRBool test_parse_string()
|
||||
{
|
||||
return test_parse_string_helper1("foo, bar", '_', "foo, bar") &&
|
||||
test_parse_string_helper2("foo, bar", ',', "foo", " bar") &&
|
||||
test_parse_string_helper2("foo, bar ", ' ', "foo,", "bar") &&
|
||||
test_parse_string_helper2("foo,bar", 'o', "f", ",bar") &&
|
||||
test_parse_string_helper0("", '_') &&
|
||||
test_parse_string_helper0(" ", ' ') &&
|
||||
test_parse_string_helper1(" foo", ' ', "foo") &&
|
||||
test_parse_string_helper1(" foo", ' ', "foo");
|
||||
}
|
||||
|
||||
//----
|
||||
|
||||
typedef PRBool (*TestFunc)();
|
||||
|
@ -965,6 +1009,7 @@ tests[] =
|
|||
{ "test_voided", test_voided },
|
||||
{ "test_voided_autostr", test_voided_autostr },
|
||||
{ "test_string_tointeger", test_string_tointeger },
|
||||
{ "test_parse_string", test_parse_string },
|
||||
{ nsnull, nsnull }
|
||||
};
|
||||
|
||||
|
|
|
@ -899,6 +899,50 @@ static PRBool test_comparisons()
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper(const char* str, char separator, int len,
|
||||
const char* s1, const char* s2)
|
||||
{
|
||||
nsCString data(str);
|
||||
nsTArray<nsCString> results;
|
||||
if (!ParseString(data, separator, results))
|
||||
return PR_FALSE;
|
||||
if (int(results.Length()) != len)
|
||||
return PR_FALSE;
|
||||
const char* strings[] = { s1, s2 };
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!results[i].Equals(strings[i]))
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper0(const char* str, char separator)
|
||||
{
|
||||
return test_parse_string_helper(str, separator, 0, nsnull, nsnull);
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper1(const char* str, char separator, const char* s1)
|
||||
{
|
||||
return test_parse_string_helper(str, separator, 1, s1, nsnull);
|
||||
}
|
||||
|
||||
static PRBool test_parse_string_helper2(const char* str, char separator, const char* s1, const char* s2)
|
||||
{
|
||||
return test_parse_string_helper(str, separator, 2, s1, s2);
|
||||
}
|
||||
|
||||
static PRBool test_parse_string()
|
||||
{
|
||||
return test_parse_string_helper1("foo, bar", '_', "foo, bar") &&
|
||||
test_parse_string_helper2("foo, bar", ',', "foo", " bar") &&
|
||||
test_parse_string_helper2("foo, bar ", ' ', "foo,", "bar") &&
|
||||
test_parse_string_helper2("foo,bar", 'o', "f", ",bar") &&
|
||||
test_parse_string_helper0("", '_') &&
|
||||
test_parse_string_helper0(" ", ' ') &&
|
||||
test_parse_string_helper1(" foo", ' ', "foo") &&
|
||||
test_parse_string_helper1(" foo", ' ', "foo");
|
||||
}
|
||||
|
||||
//----
|
||||
|
||||
typedef PRBool (*TestFunc)();
|
||||
|
@ -926,6 +970,7 @@ tests[] =
|
|||
{ "test_find", test_find },
|
||||
{ "test_compressws", test_compressws },
|
||||
{ "test_comparisons", test_comparisons },
|
||||
{ "test_parse_string", test_parse_string },
|
||||
{ nsnull, nsnull }
|
||||
};
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsStringEnumerator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIRequestObserver.h"
|
||||
#include "nsITimelineService.h"
|
||||
|
@ -112,15 +113,6 @@ DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, NC, type);
|
|||
|
||||
#define kMaileditPrefKey "intl.charsetmenu.mailedit"
|
||||
|
||||
static void CloneCStringArray(const nsCStringArray& src, nsCStringArray& dest)
|
||||
{
|
||||
PRUint32 count = src.Count();
|
||||
PRUint32 i;
|
||||
for (i=0; i<count; i++) {
|
||||
dest.AppendCString(*src.CStringAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsMenuEntry [declaration]
|
||||
|
||||
|
@ -208,37 +200,37 @@ private:
|
|||
nsCOMPtr<nsICharsetConverterManager> mCCManager;
|
||||
nsCOMPtr<nsIPrefBranch> mPrefs;
|
||||
nsCOMPtr<nsIObserver> mCharsetMenuObserver;
|
||||
nsCStringArray mDecoderList;
|
||||
nsTArray<nsCString> mDecoderList;
|
||||
|
||||
nsresult Done();
|
||||
nsresult SetCharsetCheckmark(nsString * aCharset, PRBool aValue);
|
||||
|
||||
nsresult FreeResources();
|
||||
|
||||
nsresult InitStaticMenu(nsCStringArray& aDecs,
|
||||
nsresult InitStaticMenu(nsTArray<nsCString>& aDecs,
|
||||
nsIRDFResource * aResource,
|
||||
const char * aKey,
|
||||
nsVoidArray * aArray);
|
||||
nsresult InitCacheMenu(nsCStringArray& aDecs,
|
||||
nsresult InitCacheMenu(nsTArray<nsCString>& aDecs,
|
||||
nsIRDFResource * aResource,
|
||||
const char * aKey,
|
||||
nsVoidArray * aArray);
|
||||
|
||||
nsresult InitMoreMenu(nsCStringArray& aDecs,
|
||||
nsresult InitMoreMenu(nsTArray<nsCString>& aDecs,
|
||||
nsIRDFResource * aResource,
|
||||
const char * aFlag);
|
||||
|
||||
nsresult InitMoreSubmenus(nsCStringArray& aDecs);
|
||||
nsresult InitMoreSubmenus(nsTArray<nsCString>& aDecs);
|
||||
|
||||
static nsresult SetArrayFromEnumerator(nsIUTF8StringEnumerator* aEnumerator,
|
||||
nsCStringArray& aArray);
|
||||
nsTArray<nsCString>& aArray);
|
||||
|
||||
nsresult AddCharsetToItemArray(nsVoidArray* aArray,
|
||||
const nsAFlatCString& aCharset,
|
||||
nsMenuEntry ** aResult,
|
||||
PRInt32 aPlace);
|
||||
nsresult AddCharsetArrayToItemArray(nsVoidArray &aArray,
|
||||
const nsCStringArray& aCharsets);
|
||||
const nsTArray<nsCString>& aCharsets);
|
||||
nsresult AddMenuItemToContainer(nsIRDFContainer * aContainer,
|
||||
nsMenuEntry * aItem, nsIRDFResource * aType, const char * aIDPrefix,
|
||||
PRInt32 aPlace);
|
||||
|
@ -253,17 +245,17 @@ private:
|
|||
nsresult AddFromPrefsToMenu(nsVoidArray * aArray,
|
||||
nsIRDFContainer * aContainer,
|
||||
const char * aKey,
|
||||
nsCStringArray& aDecs,
|
||||
nsTArray<nsCString>& aDecs,
|
||||
const char * aIDPrefix);
|
||||
nsresult AddFromNolocPrefsToMenu(nsVoidArray * aArray,
|
||||
nsIRDFContainer * aContainer,
|
||||
const char * aKey,
|
||||
nsCStringArray& aDecs,
|
||||
nsTArray<nsCString>& aDecs,
|
||||
const char * aIDPrefix);
|
||||
nsresult AddFromStringToMenu(char * aCharsetList,
|
||||
nsVoidArray * aArray,
|
||||
nsIRDFContainer * aContainer,
|
||||
nsCStringArray& aDecs,
|
||||
nsTArray<nsCString>& aDecs,
|
||||
const char * aIDPrefix);
|
||||
|
||||
nsresult AddSeparatorToContainer(nsIRDFContainer * aContainer);
|
||||
|
@ -282,7 +274,7 @@ private:
|
|||
nsresult RemoveLastMenuItem(nsIRDFContainer * aContainer,
|
||||
nsVoidArray * aArray);
|
||||
|
||||
nsresult RemoveFlaggedCharsets(nsCStringArray& aList, const nsString& aProp);
|
||||
nsresult RemoveFlaggedCharsets(nsTArray<nsCString>& aList, const nsString& aProp);
|
||||
nsresult NewRDFContainer(nsIRDFDataSource * aDataSource,
|
||||
nsIRDFResource * aResource, nsIRDFContainer ** aResult);
|
||||
void FreeMenuItemArray(nsVoidArray * aArray);
|
||||
|
@ -369,7 +361,7 @@ static int CompareMenuItems(const void* aArg1, const void* aArg2, void *data)
|
|||
|
||||
nsresult
|
||||
nsCharsetMenu::SetArrayFromEnumerator(nsIUTF8StringEnumerator* aEnumerator,
|
||||
nsCStringArray& aArray)
|
||||
nsTArray<nsCString>& aArray)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -380,7 +372,7 @@ nsCharsetMenu::SetArrayFromEnumerator(nsIUTF8StringEnumerator* aEnumerator,
|
|||
while (NS_SUCCEEDED(rv) && hasMore) {
|
||||
rv = aEnumerator->GetNext(value);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aArray.AppendCString(value);
|
||||
aArray.AppendElement(value);
|
||||
|
||||
rv = aEnumerator->HasMore(&hasMore);
|
||||
}
|
||||
|
@ -388,6 +380,21 @@ nsCharsetMenu::SetArrayFromEnumerator(nsIUTF8StringEnumerator* aEnumerator,
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
class nsIgnoreCaseCStringComparator
|
||||
{
|
||||
public:
|
||||
PRBool Equals(const nsACString& a, const nsACString& b) const
|
||||
{
|
||||
return nsCString(a).Equals(b, nsCaseInsensitiveCStringComparator());
|
||||
}
|
||||
|
||||
PRBool LessThan(const nsACString& a, const nsACString& b) const
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsCharsetMenuObserver
|
||||
|
||||
|
@ -583,7 +590,7 @@ nsresult nsCharsetMenu::RefreshBrowserMenu()
|
|||
res = mCCManager->GetDecoderList(getter_AddRefs(decoders));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsCStringArray decs;
|
||||
nsTArray<nsCString> decs;
|
||||
SetArrayFromEnumerator(decoders, decs);
|
||||
|
||||
res = AddFromPrefsToMenu(&mBrowserMenu, container, kBrowserStaticPrefKey,
|
||||
|
@ -620,7 +627,7 @@ nsresult nsCharsetMenu::RefreshMailviewMenu()
|
|||
res = mCCManager->GetDecoderList(getter_AddRefs(decoders));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsCStringArray decs;
|
||||
nsTArray<nsCString> decs;
|
||||
SetArrayFromEnumerator(decoders, decs);
|
||||
|
||||
res = AddFromPrefsToMenu(&mMailviewMenu, container, kMailviewStaticPrefKey,
|
||||
|
@ -665,7 +672,7 @@ nsresult nsCharsetMenu::RefreshMaileditMenu()
|
|||
res = mCCManager->GetEncoderList(getter_AddRefs(encoders));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCStringArray encs;
|
||||
nsTArray<nsCString> encs;
|
||||
SetArrayFromEnumerator(encoders, encs);
|
||||
|
||||
// add menu items from pref
|
||||
|
@ -691,7 +698,7 @@ nsresult nsCharsetMenu::RefreshComposerMenu()
|
|||
res = mCCManager->GetDecoderList(getter_AddRefs(decoders));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsCStringArray decs;
|
||||
nsTArray<nsCString> decs;
|
||||
SetArrayFromEnumerator(decoders, decs);
|
||||
|
||||
res = AddFromPrefsToMenu(&mComposerMenu, container, kComposerStaticPrefKey,
|
||||
|
@ -889,8 +896,7 @@ nsresult nsCharsetMenu::InitBrowserMenu()
|
|||
|
||||
|
||||
// how to clone mDecoderList??
|
||||
nsCStringArray browserDecoderList;
|
||||
CloneCStringArray(mDecoderList, browserDecoderList);
|
||||
nsTArray<nsCString> browserDecoderList = mDecoderList;
|
||||
|
||||
res = InitStaticMenu(browserDecoderList, kNC_BrowserCharsetMenuRoot,
|
||||
kBrowserStaticPrefKey, &mBrowserMenu);
|
||||
|
@ -949,7 +955,7 @@ nsresult nsCharsetMenu::InitMaileditMenu()
|
|||
res = mCCManager->GetEncoderList(getter_AddRefs(encoders));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsCStringArray maileditEncoderList;
|
||||
nsTArray<nsCString> maileditEncoderList;
|
||||
SetArrayFromEnumerator(encoders, maileditEncoderList);
|
||||
|
||||
res = AddFromPrefsToMenu(NULL, container, kMaileditPrefKey, maileditEncoderList, NULL);
|
||||
|
@ -980,8 +986,7 @@ nsresult nsCharsetMenu::InitMailviewMenu()
|
|||
res = NewRDFContainer(mInner, kNC_MailviewCharsetMenuRoot, getter_AddRefs(container));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsCStringArray mailviewDecoderList;
|
||||
CloneCStringArray(mDecoderList, mailviewDecoderList);
|
||||
nsTArray<nsCString> mailviewDecoderList = mDecoderList;
|
||||
|
||||
res = InitStaticMenu(mailviewDecoderList, kNC_MailviewCharsetMenuRoot,
|
||||
kMailviewStaticPrefKey, &mMailviewMenu);
|
||||
|
@ -1022,8 +1027,7 @@ nsresult nsCharsetMenu::InitComposerMenu()
|
|||
res = NewRDFContainer(mInner, kNC_ComposerCharsetMenuRoot, getter_AddRefs(container));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsCStringArray composerDecoderList;
|
||||
CloneCStringArray(mDecoderList, composerDecoderList);
|
||||
nsTArray<nsCString> composerDecoderList = mDecoderList;
|
||||
|
||||
// even if we fail, the show must go on
|
||||
res = InitStaticMenu(composerDecoderList, kNC_ComposerCharsetMenuRoot,
|
||||
|
@ -1061,8 +1065,7 @@ nsresult nsCharsetMenu::InitOthers()
|
|||
nsresult res = NS_OK;
|
||||
|
||||
if (!mOthersInitialized) {
|
||||
nsCStringArray othersDecoderList;
|
||||
CloneCStringArray(mDecoderList, othersDecoderList);
|
||||
nsTArray<nsCString> othersDecoderList = mDecoderList;
|
||||
|
||||
res = InitMoreMenu(othersDecoderList, kNC_DecodersRoot, ".notForBrowser");
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
@ -1070,8 +1073,7 @@ nsresult nsCharsetMenu::InitOthers()
|
|||
// Using mDecoderList instead of GetEncoderList(), we can avoid having to
|
||||
// tag a whole bunch of 'font encoders' with '.notForOutgoing' in
|
||||
// charsetData.properties file.
|
||||
nsCStringArray othersEncoderList;
|
||||
CloneCStringArray(mDecoderList, othersEncoderList);
|
||||
nsTArray<nsCString> othersEncoderList = mDecoderList;
|
||||
|
||||
res = InitMoreMenu(othersEncoderList, kNC_EncodersRoot, ".notForOutgoing");
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
@ -1097,8 +1099,7 @@ nsresult nsCharsetMenu::InitSecondaryTiers()
|
|||
nsresult res = NS_OK;
|
||||
|
||||
if (!mSecondaryTiersInitialized) {
|
||||
nsCStringArray secondaryTiersDecoderList;
|
||||
CloneCStringArray(mDecoderList, secondaryTiersDecoderList);
|
||||
nsTArray<nsCString> secondaryTiersDecoderList = mDecoderList;
|
||||
|
||||
res = InitMoreSubmenus(secondaryTiersDecoderList);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "err init browser charset more submenus");
|
||||
|
@ -1115,7 +1116,7 @@ nsresult nsCharsetMenu::InitSecondaryTiers()
|
|||
return res;
|
||||
}
|
||||
|
||||
nsresult nsCharsetMenu::InitStaticMenu(nsCStringArray& aDecs,
|
||||
nsresult nsCharsetMenu::InitStaticMenu(nsTArray<nsCString>& aDecs,
|
||||
nsIRDFResource * aResource,
|
||||
const char * aKey,
|
||||
nsVoidArray * aArray)
|
||||
|
@ -1142,7 +1143,7 @@ nsresult nsCharsetMenu::InitStaticMenu(nsCStringArray& aDecs,
|
|||
}
|
||||
|
||||
nsresult nsCharsetMenu::InitCacheMenu(
|
||||
nsCStringArray& aDecs,
|
||||
nsTArray<nsCString>& aDecs,
|
||||
nsIRDFResource * aResource,
|
||||
const char * aKey,
|
||||
nsVoidArray * aArray)
|
||||
|
@ -1173,7 +1174,7 @@ nsresult nsCharsetMenu::InitAutodetMenu()
|
|||
if (!mAutoDetectInitialized) {
|
||||
nsVoidArray chardetArray;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCStringArray detectorArray;
|
||||
nsTArray<nsCString> detectorArray;
|
||||
|
||||
res = NewRDFContainer(mInner, kNC_BrowserAutodetMenuRoot, getter_AddRefs(container));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
@ -1209,7 +1210,7 @@ nsresult nsCharsetMenu::InitAutodetMenu()
|
|||
return res;
|
||||
}
|
||||
|
||||
nsresult nsCharsetMenu::InitMoreMenu(nsCStringArray& aDecs,
|
||||
nsresult nsCharsetMenu::InitMoreMenu(nsTArray<nsCString>& aDecs,
|
||||
nsIRDFResource * aResource,
|
||||
const char * aFlag)
|
||||
{
|
||||
|
@ -1247,7 +1248,7 @@ done:
|
|||
}
|
||||
|
||||
// XXX please make this method more general; the cut&pasted code is laughable
|
||||
nsresult nsCharsetMenu::InitMoreSubmenus(nsCStringArray& aDecs)
|
||||
nsresult nsCharsetMenu::InitMoreSubmenus(nsTArray<nsCString>& aDecs)
|
||||
{
|
||||
NS_TIMELINE_START_TIMER("nsCharsetMenu::InitMoreSubmenus");
|
||||
|
||||
|
@ -1348,18 +1349,17 @@ done:
|
|||
|
||||
nsresult
|
||||
nsCharsetMenu::AddCharsetArrayToItemArray(nsVoidArray& aArray,
|
||||
const nsCStringArray& aCharsets)
|
||||
const nsTArray<nsCString>& aCharsets)
|
||||
{
|
||||
PRUint32 count = aCharsets.Count();
|
||||
PRUint32 count = aCharsets.Length();
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
|
||||
nsCString* str = aCharsets.CStringAt(i);
|
||||
if (str) {
|
||||
nsresult res = AddCharsetToItemArray(&aArray, *str, NULL, -1);
|
||||
const nsCString& str = aCharsets[i];
|
||||
nsresult res = AddCharsetToItemArray(&aArray, str, NULL, -1);
|
||||
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1474,7 +1474,7 @@ nsresult nsCharsetMenu::AddFromPrefsToMenu(
|
|||
nsVoidArray * aArray,
|
||||
nsIRDFContainer * aContainer,
|
||||
const char * aKey,
|
||||
nsCStringArray& aDecs,
|
||||
nsTArray<nsCString>& aDecs,
|
||||
const char * aIDPrefix)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
@ -1499,7 +1499,7 @@ nsresult
|
|||
nsCharsetMenu::AddFromNolocPrefsToMenu(nsVoidArray * aArray,
|
||||
nsIRDFContainer * aContainer,
|
||||
const char * aKey,
|
||||
nsCStringArray& aDecs,
|
||||
nsTArray<nsCString>& aDecs,
|
||||
const char * aIDPrefix)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
@ -1520,7 +1520,7 @@ nsresult nsCharsetMenu::AddFromStringToMenu(
|
|||
char * aCharsetList,
|
||||
nsVoidArray * aArray,
|
||||
nsIRDFContainer * aContainer,
|
||||
nsCStringArray& aDecs,
|
||||
nsTArray<nsCString>& aDecs,
|
||||
const char * aIDPrefix)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
@ -1533,7 +1533,7 @@ nsresult nsCharsetMenu::AddFromStringToMenu(
|
|||
|
||||
// if this charset is not on the accepted list of charsets, ignore it
|
||||
PRInt32 index;
|
||||
index = aDecs.IndexOfIgnoreCase(nsCAutoString(p));
|
||||
index = aDecs.IndexOf(nsCAutoString(p), 0, nsIgnoreCaseCStringComparator());
|
||||
if (index >= 0) {
|
||||
|
||||
// else, add it to the menu
|
||||
|
@ -1542,8 +1542,7 @@ nsresult nsCharsetMenu::AddFromStringToMenu(
|
|||
NS_ASSERTION(NS_SUCCEEDED(res), "cannot add charset to menu");
|
||||
if (NS_FAILED(res)) break;
|
||||
|
||||
res = aDecs.RemoveCStringAt(index);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "cannot remove atom from array");
|
||||
aDecs.RemoveElementAt(index);
|
||||
}
|
||||
|
||||
*q = temp;
|
||||
|
@ -1704,26 +1703,22 @@ nsresult nsCharsetMenu::RemoveLastMenuItem(nsIRDFContainer * aContainer,
|
|||
return res;
|
||||
}
|
||||
|
||||
nsresult nsCharsetMenu::RemoveFlaggedCharsets(nsCStringArray& aList,
|
||||
nsresult nsCharsetMenu::RemoveFlaggedCharsets(nsTArray<nsCString>& aList,
|
||||
const nsString& aProp)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
PRUint32 count;
|
||||
|
||||
count = aList.Count();
|
||||
count = aList.Length();
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsCString* charset;
|
||||
nsAutoString str;
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
|
||||
charset = aList.CStringAt(i);
|
||||
if (!charset) continue;
|
||||
|
||||
res = mCCManager->GetCharsetData(charset->get(), aProp.get(), str);
|
||||
res = mCCManager->GetCharsetData(aList[i].get(), aProp.get(), str);
|
||||
if (NS_FAILED(res)) continue;
|
||||
|
||||
aList.RemoveCStringAt(i);
|
||||
aList.RemoveElementAt(i);
|
||||
|
||||
i--;
|
||||
count--;
|
||||
|
|
Загрузка…
Ссылка в новой задаче