зеркало из https://github.com/mozilla/pjs.git
Bug 461047 - Replace nsStringArray with nsTArray<nsString>. r+sr=roc
This commit is contained in:
Родитель
0419f1d947
Коммит
9bd9de1b83
|
@ -112,10 +112,10 @@ NS_IMPL_ISUPPORTS1(nsAccessibleDOMStringList, nsIDOMDOMStringList)
|
|||
NS_IMETHODIMP
|
||||
nsAccessibleDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
if (aIndex >= (PRUint32)mNames.Count()) {
|
||||
if (aIndex >= mNames.Length()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
mNames.StringAt(aIndex, aResult);
|
||||
aResult = mNames.ElementAt(aIndex);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -124,7 +124,7 @@ nsAccessibleDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
|
|||
NS_IMETHODIMP
|
||||
nsAccessibleDOMStringList::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
*aLength = (PRUint32)mNames.Count();
|
||||
*aLength = mNames.Length();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ nsAccessibleDOMStringList::GetLength(PRUint32 *aLength)
|
|||
NS_IMETHODIMP
|
||||
nsAccessibleDOMStringList::Contains(const nsAString& aString, PRBool *aResult)
|
||||
{
|
||||
*aResult = mNames.IndexOf(aString) > -1;
|
||||
*aResult = mNames.Contains(aString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsINameSpaceManager.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIDOMDOMStringList.h"
|
||||
#include "nsARIAMap.h"
|
||||
|
||||
|
@ -88,11 +89,11 @@ public:
|
|||
NS_DECL_NSIDOMDOMSTRINGLIST
|
||||
|
||||
PRBool Add(const nsAString& aName) {
|
||||
return mNames.AppendString(aName);
|
||||
return mNames.AppendElement(aName) != nsnull;
|
||||
}
|
||||
|
||||
private:
|
||||
nsStringArray mNames;
|
||||
nsTArray<nsString> mNames;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define nsIXPathEvaluatorInternal_h__
|
||||
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMXPathExpression;
|
||||
|
@ -62,7 +63,7 @@ public:
|
|||
|
||||
NS_IMETHOD CreateExpression(const nsAString &aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsStringArray *aNamespaceURIs,
|
||||
nsTArray<nsString> *aNamespaceURIs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult) = 0;
|
||||
|
|
|
@ -356,7 +356,7 @@ nsContentSink::ScriptAvailable(nsresult aResult,
|
|||
// aElement will not be in mScriptElements if a <script> was added
|
||||
// using the DOM during loading, or if the script was inline and thus
|
||||
// never blocked.
|
||||
NS_ASSERTION(mScriptElements.IndexOf(aElement) == count - 1 ||
|
||||
NS_ASSERTION(mScriptElements.IndexOf(aElement) == PRUint32(count - 1) ||
|
||||
mScriptElements.IndexOf(aElement) == PRUint32(-1),
|
||||
"script found at unexpected position");
|
||||
|
||||
|
@ -719,25 +719,25 @@ nsContentSink::ProcessLink(nsIContent* aElement,
|
|||
const nsSubstring& aMedia)
|
||||
{
|
||||
// XXX seems overkill to generate this string array
|
||||
nsStringArray linkTypes;
|
||||
nsTArray<nsString> linkTypes;
|
||||
nsStyleLinkElement::ParseLinkTypes(aRel, linkTypes);
|
||||
|
||||
PRBool hasPrefetch = (linkTypes.IndexOf(NS_LITERAL_STRING("prefetch")) != -1);
|
||||
PRBool hasPrefetch = linkTypes.Contains(NS_LITERAL_STRING("prefetch"));
|
||||
// prefetch href if relation is "next" or "prefetch"
|
||||
if (hasPrefetch || linkTypes.IndexOf(NS_LITERAL_STRING("next")) != -1) {
|
||||
if (hasPrefetch || linkTypes.Contains(NS_LITERAL_STRING("next"))) {
|
||||
PrefetchHref(aHref, aElement, hasPrefetch);
|
||||
}
|
||||
|
||||
if ((!aHref.IsEmpty()) && linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
|
||||
if ((!aHref.IsEmpty()) && linkTypes.Contains(NS_LITERAL_STRING("dns-prefetch"))) {
|
||||
PrefetchDNS(aHref);
|
||||
}
|
||||
|
||||
// is it a stylesheet link?
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) == -1) {
|
||||
if (!linkTypes.Contains(NS_LITERAL_STRING("stylesheet"))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool isAlternate = linkTypes.IndexOf(NS_LITERAL_STRING("alternate")) != -1;
|
||||
PRBool isAlternate = linkTypes.Contains(NS_LITERAL_STRING("alternate"));
|
||||
return ProcessStyleLink(aElement, aHref, isAlternate, aTitle, aType,
|
||||
aMedia);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsGkAtoms.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsIParserService.h"
|
||||
|
|
|
@ -69,10 +69,10 @@ NS_INTERFACE_MAP_END
|
|||
NS_IMETHODIMP
|
||||
nsDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
if (aIndex >= (PRUint32)mNames.Count()) {
|
||||
if (aIndex >= mNames.Length()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
mNames.StringAt(aIndex, aResult);
|
||||
aResult = mNames[aIndex];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -81,7 +81,7 @@ nsDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
|
|||
NS_IMETHODIMP
|
||||
nsDOMStringList::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
*aLength = (PRUint32)mNames.Count();
|
||||
*aLength = mNames.Length();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ nsDOMStringList::GetLength(PRUint32 *aLength)
|
|||
NS_IMETHODIMP
|
||||
nsDOMStringList::Contains(const nsAString& aString, PRBool *aResult)
|
||||
{
|
||||
*aResult = mNames.IndexOf(aString) > -1;
|
||||
*aResult = mNames.Contains(aString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ NS_INTERFACE_TABLE_HEAD(nsNameList)
|
|||
NS_IMETHODIMP
|
||||
nsNameList::GetName(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
if (aIndex >= (PRUint32)mNames.Count()) {
|
||||
if (aIndex >= mNames.Length()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
mNames.StringAt(aIndex, aResult);
|
||||
aResult = mNames[aIndex];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -128,10 +128,10 @@ nsNameList::GetName(PRUint32 aIndex, nsAString& aResult)
|
|||
NS_IMETHODIMP
|
||||
nsNameList::GetNamespaceURI(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
if (aIndex >= (PRUint32)mNames.Count()) {
|
||||
if (aIndex >= mNames.Length()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
mNamespaceURIs.StringAt(aIndex, aResult);
|
||||
aResult = mNamespaceURIs[aIndex];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -140,7 +140,7 @@ nsNameList::GetNamespaceURI(PRUint32 aIndex, nsAString& aResult)
|
|||
NS_IMETHODIMP
|
||||
nsNameList::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
*aLength = (PRUint32)mNames.Count();
|
||||
*aLength = mNames.Length();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -148,12 +148,12 @@ nsNameList::GetLength(PRUint32 *aLength)
|
|||
PRBool
|
||||
nsNameList::Add(const nsAString& aNamespaceURI, const nsAString& aName)
|
||||
{
|
||||
PRInt32 count = mNamespaceURIs.Count();
|
||||
if (mNamespaceURIs.InsertStringAt(aNamespaceURI, count)) {
|
||||
if (mNames.InsertStringAt(aName, count)) {
|
||||
PRUint32 count = mNamespaceURIs.Length();
|
||||
if (mNamespaceURIs.InsertElementAt(count, aNamespaceURI)) {
|
||||
if (mNames.InsertElementAt(count, aName)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
mNamespaceURIs.RemoveStringAt(count);
|
||||
mNamespaceURIs.RemoveElementAt(count);
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
|
@ -162,7 +162,7 @@ nsNameList::Add(const nsAString& aNamespaceURI, const nsAString& aName)
|
|||
NS_IMETHODIMP
|
||||
nsNameList::Contains(const nsAString& aName, PRBool *aResult)
|
||||
{
|
||||
*aResult = mNames.IndexOf(aName) > -1;
|
||||
*aResult = mNames.Contains(aName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -171,12 +171,9 @@ NS_IMETHODIMP
|
|||
nsNameList::ContainsNS(const nsAString& aNamespaceURI, const nsAString& aName,
|
||||
PRBool *aResult)
|
||||
{
|
||||
PRInt32 index = mNames.IndexOf(aName);
|
||||
if (index > -1) {
|
||||
nsAutoString ns;
|
||||
mNamespaceURIs.StringAt(index, ns);
|
||||
|
||||
*aResult = ns.Equals(aNamespaceURI);
|
||||
PRUint32 index = mNames.IndexOf(aName);
|
||||
if (index != PRUint32(-1)) {
|
||||
*aResult = mNamespaceURIs[index].Equals(aNamespaceURI);
|
||||
}
|
||||
else {
|
||||
*aResult = PR_FALSE;
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
#include "nsIDOMDOMStringList.h"
|
||||
#include "nsIDOMNameList.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsDOMStringList : public nsIDOMDOMStringList
|
||||
{
|
||||
|
@ -60,11 +62,11 @@ public:
|
|||
|
||||
PRBool Add(const nsAString& aName)
|
||||
{
|
||||
return mNames.AppendString(aName);
|
||||
return mNames.AppendElement(aName) != nsnull;
|
||||
}
|
||||
|
||||
private:
|
||||
nsStringArray mNames;
|
||||
nsTArray<nsString> mNames;
|
||||
};
|
||||
|
||||
class nsNameList : public nsIDOMNameList
|
||||
|
@ -79,8 +81,8 @@ public:
|
|||
PRBool Add(const nsAString& aNamespaceURI, const nsAString& aName);
|
||||
|
||||
private:
|
||||
nsStringArray mNamespaceURIs;
|
||||
nsStringArray mNames;
|
||||
nsTArray<nsString> mNamespaceURIs;
|
||||
nsTArray<nsString> mNames;
|
||||
};
|
||||
|
||||
#endif /* nsDOMLists_h___ */
|
||||
|
|
|
@ -1222,7 +1222,7 @@ public:
|
|||
|
||||
protected:
|
||||
// Rebuild our list of style sets
|
||||
nsresult GetSets(nsStringArray& aStyleSets);
|
||||
nsresult GetSets(nsTArray<nsString>& aStyleSets);
|
||||
|
||||
nsIDocument* mDocument; // Our document; weak ref. It'll let us know if it
|
||||
// dies.
|
||||
|
@ -1247,14 +1247,14 @@ nsDOMStyleSheetSetList::nsDOMStyleSheetSetList(nsIDocument* aDocument)
|
|||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetSetList::Item(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
nsStringArray styleSets;
|
||||
nsTArray<nsString> styleSets;
|
||||
nsresult rv = GetSets(styleSets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aIndex >= (PRUint32)styleSets.Count()) {
|
||||
if (aIndex >= styleSets.Length()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
styleSets.StringAt(aIndex, aResult);
|
||||
aResult = styleSets[aIndex];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1263,11 +1263,11 @@ nsDOMStyleSheetSetList::Item(PRUint32 aIndex, nsAString& aResult)
|
|||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetSetList::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
nsStringArray styleSets;
|
||||
nsTArray<nsString> styleSets;
|
||||
nsresult rv = GetSets(styleSets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aLength = (PRUint32)styleSets.Count();
|
||||
*aLength = styleSets.Length();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1275,17 +1275,17 @@ nsDOMStyleSheetSetList::GetLength(PRUint32 *aLength)
|
|||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetSetList::Contains(const nsAString& aString, PRBool *aResult)
|
||||
{
|
||||
nsStringArray styleSets;
|
||||
nsTArray<nsString> styleSets;
|
||||
nsresult rv = GetSets(styleSets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aResult = styleSets.IndexOf(aString) != -1;
|
||||
*aResult = styleSets.Contains(aString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMStyleSheetSetList::GetSets(nsStringArray& aStyleSets)
|
||||
nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
|
||||
{
|
||||
if (!mDocument) {
|
||||
return NS_OK; // Spec says "no exceptions", and we have no style sets if we
|
||||
|
@ -1299,8 +1299,8 @@ nsDOMStyleSheetSetList::GetSets(nsStringArray& aStyleSets)
|
|||
nsIStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
sheet->GetTitle(title);
|
||||
if (!title.IsEmpty() && aStyleSets.IndexOf(title) == -1 &&
|
||||
!aStyleSets.AppendString(title)) {
|
||||
if (!title.IsEmpty() && !aStyleSets.Contains(title) &&
|
||||
!aStyleSets.AppendElement(title)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nsAutoPtr.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsString.h"
|
||||
|
@ -131,7 +132,7 @@ private:
|
|||
nsresult AddNameSpace(const nsAString& aURI, const PRInt32 aNameSpaceID);
|
||||
|
||||
nsDataHashtable<nsNameSpaceKey,PRInt32> mURIToIDTable;
|
||||
nsStringArray mURIArray;
|
||||
nsTArray< nsAutoPtr<nsString> > mURIArray;
|
||||
};
|
||||
|
||||
static NameSpaceManagerImpl* sNameSpaceManager = nsnull;
|
||||
|
@ -177,7 +178,7 @@ NameSpaceManagerImpl::RegisterNameSpace(const nsAString& aURI,
|
|||
|
||||
nsresult rv = NS_OK;
|
||||
if (!mURIToIDTable.Get(&aURI, &aNameSpaceID)) {
|
||||
aNameSpaceID = mURIArray.Count() + 1; // id is index + 1
|
||||
aNameSpaceID = mURIArray.Length() + 1; // id is index + 1
|
||||
|
||||
rv = AddNameSpace(aURI, aNameSpaceID);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -196,13 +197,13 @@ NameSpaceManagerImpl::GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI)
|
|||
NS_PRECONDITION(aNameSpaceID >= 0, "Bogus namespace ID");
|
||||
|
||||
PRInt32 index = aNameSpaceID - 1; // id is index + 1
|
||||
if (index < 0 || index >= mURIArray.Count()) {
|
||||
if (index < 0 || index >= PRInt32(mURIArray.Length())) {
|
||||
aURI.Truncate();
|
||||
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
mURIArray.StringAt(index, aURI);
|
||||
aURI = *mURIArray.ElementAt(index);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -286,16 +287,17 @@ nsresult NameSpaceManagerImpl::AddNameSpace(const nsAString& aURI,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ASSERTION(aNameSpaceID - 1 == mURIArray.Count(),
|
||||
NS_ASSERTION(aNameSpaceID - 1 == mURIArray.Length(),
|
||||
"BAD! AddNameSpace not called in right order!");
|
||||
|
||||
if (!mURIArray.AppendString(aURI)) {
|
||||
nsString* uri = new nsString(aURI);
|
||||
if (!uri || !mURIArray.AppendElement(uri)) {
|
||||
delete uri;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
const nsString* uri = mURIArray.StringAt(aNameSpaceID - 1);
|
||||
if (!mURIToIDTable.Put(uri, aNameSpaceID)) {
|
||||
mURIArray.RemoveStringAt(aNameSpaceID - 1);
|
||||
mURIArray.RemoveElementAt(aNameSpaceID - 1);
|
||||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ nsStyleLinkElement::SetLineNumber(PRUint32 aLineNumber)
|
|||
}
|
||||
|
||||
void nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes,
|
||||
nsStringArray& aResult)
|
||||
nsTArray<nsString>& aResult)
|
||||
{
|
||||
nsAString::const_iterator start, done;
|
||||
aTypes.BeginReading(start);
|
||||
|
@ -177,7 +177,7 @@ void nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes,
|
|||
if (nsCRT::IsAsciiSpace(*current)) {
|
||||
if (inString) {
|
||||
ToLowerCase(Substring(start, current), subString);
|
||||
aResult.AppendString(subString);
|
||||
aResult.AppendElement(subString);
|
||||
inString = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ void nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes,
|
|||
}
|
||||
if (inString) {
|
||||
ToLowerCase(Substring(start, current), subString);
|
||||
aResult.AppendString(subString);
|
||||
aResult.AppendElement(subString);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@
|
|||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsStringArray;
|
||||
|
||||
class nsStyleLinkElement : public nsIDOMLinkStyle,
|
||||
public nsIStyleSheetLinkingElement
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
virtual void OverrideBaseURI(nsIURI* aNewBaseURI);
|
||||
virtual void SetLineNumber(PRUint32 aLineNumber);
|
||||
|
||||
static void ParseLinkTypes(const nsAString& aTypes, nsStringArray& aResult);
|
||||
static void ParseLinkTypes(const nsAString& aTypes, nsTArray<nsString>& aResult);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -49,9 +49,9 @@
|
|||
#include "prtypes.h"
|
||||
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsString;
|
||||
class nsStringArray;
|
||||
|
||||
// {0ae53c0f-8ea2-4916-bedc-717443c3e185}
|
||||
#define NS_FORMPROCESSOR_CID \
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
*/
|
||||
|
||||
NS_IMETHOD ProvideContent(const nsAString& aFormType,
|
||||
nsStringArray& aContent,
|
||||
nsTArray<nsString>& aContent,
|
||||
nsAString& aAttribute) = 0;
|
||||
|
||||
};
|
||||
|
|
|
@ -304,9 +304,9 @@ nsHTMLLinkElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
PRBool dropSheet = PR_FALSE;
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::rel &&
|
||||
mStyleSheet) {
|
||||
nsStringArray linkTypes(4);
|
||||
nsAutoTArray<nsString, 4> linkTypes;
|
||||
nsStyleLinkElement::ParseLinkTypes(aValue, linkTypes);
|
||||
dropSheet = linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) < 0;
|
||||
dropSheet = !linkTypes.Contains(NS_LITERAL_STRING("stylesheet"));
|
||||
}
|
||||
|
||||
UpdateStyleSheetInternal(nsnull,
|
||||
|
@ -414,11 +414,11 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
|
|||
*aIsAlternate = PR_FALSE;
|
||||
|
||||
nsAutoString rel;
|
||||
nsStringArray linkTypes(4);
|
||||
nsAutoTArray<nsString, 4> linkTypes;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel);
|
||||
nsStyleLinkElement::ParseLinkTypes(rel, linkTypes);
|
||||
// Is it a stylesheet link?
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) < 0) {
|
||||
if (!linkTypes.Contains(NS_LITERAL_STRING("stylesheet"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
|
|||
aTitle.Assign(title);
|
||||
|
||||
// If alternate, does it have title?
|
||||
if (-1 != linkTypes.IndexOf(NS_LITERAL_STRING("alternate"))) {
|
||||
if (linkTypes.Contains(NS_LITERAL_STRING("alternate"))) {
|
||||
if (aTitle.IsEmpty()) { // alternates must have title
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
#include "nsContentErrors.h"
|
||||
#include "nsIArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
|
||||
//
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
#include "nsIDOMHTMLMapElement.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsTextFragment.h"
|
||||
|
@ -2932,17 +2933,17 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
|
|||
element->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
|
||||
if (!relVal.IsEmpty()) {
|
||||
// XXX seems overkill to generate this string array
|
||||
nsStringArray linkTypes;
|
||||
nsAutoTArray<nsString, 4> linkTypes;
|
||||
nsStyleLinkElement::ParseLinkTypes(relVal, linkTypes);
|
||||
PRBool hasPrefetch = (linkTypes.IndexOf(NS_LITERAL_STRING("prefetch")) != -1);
|
||||
if (hasPrefetch || linkTypes.IndexOf(NS_LITERAL_STRING("next")) != -1) {
|
||||
PRBool hasPrefetch = linkTypes.Contains(NS_LITERAL_STRING("prefetch"));
|
||||
if (hasPrefetch || linkTypes.Contains(NS_LITERAL_STRING("next"))) {
|
||||
nsAutoString hrefVal;
|
||||
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
PrefetchHref(hrefVal, element, hasPrefetch);
|
||||
}
|
||||
}
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
|
||||
if (linkTypes.Contains(NS_LITERAL_STRING("dns-prefetch"))) {
|
||||
nsAutoString hrefVal;
|
||||
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "nsXPCOM.h"
|
||||
#include "txStandaloneXSLTProcessor.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "txExprParser.h"
|
||||
#include "txIXPathContext.h"
|
||||
|
||||
|
@ -116,27 +117,27 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
|
||||
nsAutoString exprOrig, expr;
|
||||
nsStringArray exprHead, exprTail;
|
||||
nsTArray<nsString> exprHead, exprTail;
|
||||
PRUint8 i, dropStart, dropEnd;
|
||||
exprHead.AppendString(NS_ConvertASCIItoUTF16(kTokens[0]));
|
||||
exprTail.AppendString(NS_ConvertASCIItoUTF16(kTokens[kCount - 1]));
|
||||
exprHead.AppendElement(NS_ConvertASCIItoUTF16(kTokens[0]));
|
||||
exprTail.AppendiElement(NS_ConvertASCIItoUTF16(kTokens[kCount - 1]));
|
||||
for (i = 2; i < kCount; ++i) {
|
||||
exprHead.AppendString(*exprHead[i - 2] +
|
||||
exprHead.AppendElement(exprHead[i - 2] +
|
||||
NS_ConvertASCIItoUTF16(kTokens[i - 1]));
|
||||
exprTail.AppendString(NS_ConvertASCIItoUTF16(kTokens[kCount - i]) +
|
||||
*exprTail[i - 2]);
|
||||
exprTail.AppendElement(NS_ConvertASCIItoUTF16(kTokens[kCount - i]) +
|
||||
exprTail[i - 2]);
|
||||
}
|
||||
exprOrig = NS_ConvertASCIItoUTF16(kTokens[0]) + *exprTail[kCount - 2];
|
||||
exprOrig = NS_ConvertASCIItoUTF16(kTokens[0]) + exprTail[kCount - 2];
|
||||
cout << NS_LossyConvertUTF16toASCII(exprOrig).get() << endl << endl;
|
||||
for (dropStart = 0; dropStart < kCount - 2; ++dropStart) {
|
||||
doTest(*exprTail[kCount - 2 - dropStart]);
|
||||
doTest(exprTail[kCount - 2 - dropStart]);
|
||||
for (dropEnd = kCount - 3 - dropStart; dropEnd > 0; --dropEnd) {
|
||||
expr = *exprHead[dropStart] + *exprTail[dropEnd];
|
||||
expr = exprHead[dropStart] + exprTail[dropEnd];
|
||||
doTest(expr);
|
||||
}
|
||||
doTest(*exprHead[dropStart]);
|
||||
doTest(exprHead[dropStart]);
|
||||
}
|
||||
doTest(*exprHead[kCount - 2]);
|
||||
doTest(exprHead[kCount - 2]);
|
||||
|
||||
txXSLTProcessor::shutdown();
|
||||
rv = NS_ShutdownXPCOM(nsnull);
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nsDoubleHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "txCore.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
|
@ -422,7 +423,7 @@ public:
|
|||
"called without matching shutdown()");
|
||||
if (mNamespaces)
|
||||
return MB_TRUE;
|
||||
mNamespaces = new nsStringArray();
|
||||
mNamespaces = new nsTArray<nsString>();
|
||||
if (!mNamespaces)
|
||||
return MB_FALSE;
|
||||
/*
|
||||
|
@ -452,10 +453,10 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static nsStringArray* mNamespaces;
|
||||
static nsTArray<nsString>* mNamespaces;
|
||||
};
|
||||
|
||||
#define TX_IMPL_DOM_STATICS \
|
||||
nsStringArray* txStandaloneNamespaceManager::mNamespaces = 0
|
||||
nsTArray<nsString>* txStandaloneNamespaceManager::mNamespaces = 0
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include "txDOM.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "txURIUtils.h"
|
||||
#include "txAtoms.h"
|
||||
#include <string.h>
|
||||
|
@ -225,7 +226,7 @@ Node* NodeDefinition::getXPathParent()
|
|||
nsresult NodeDefinition::getBaseURI(nsAString& aURI)
|
||||
{
|
||||
Node* node = this;
|
||||
nsStringArray baseUrls;
|
||||
nsTArray<nsString> baseUrls;
|
||||
nsAutoString url;
|
||||
|
||||
while (node) {
|
||||
|
@ -233,12 +234,12 @@ nsresult NodeDefinition::getBaseURI(nsAString& aURI)
|
|||
case Node::ELEMENT_NODE :
|
||||
if (((Element*)node)->getAttr(txXMLAtoms::base, kNameSpaceID_XML,
|
||||
url))
|
||||
baseUrls.AppendString(url);
|
||||
baseUrls.AppendElement(url);
|
||||
break;
|
||||
|
||||
case Node::DOCUMENT_NODE :
|
||||
node->getBaseURI(url);
|
||||
baseUrls.AppendString(url);
|
||||
baseUrls.AppendElement(url);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -247,9 +248,9 @@ nsresult NodeDefinition::getBaseURI(nsAString& aURI)
|
|||
node = node->getXPathParent();
|
||||
}
|
||||
|
||||
PRInt32 count = baseUrls.Count();
|
||||
PRUint32 count = baseUrls.Length();
|
||||
if (count) {
|
||||
baseUrls.StringAt(--count, aURI);
|
||||
aURI = baseUrls[--count];
|
||||
|
||||
while (count > 0) {
|
||||
nsAutoString dest;
|
||||
|
|
|
@ -170,14 +170,14 @@ nsXPathEvaluator::SetDocument(nsIDOMDocument* aDocument)
|
|||
NS_IMETHODIMP
|
||||
nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsStringArray *aNamespaceURIs,
|
||||
nsTArray<nsString> *aNamespaceURIs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult)
|
||||
{
|
||||
nsTArray<PRInt32> namespaceIDs;
|
||||
if (aNamespaceURIs) {
|
||||
PRInt32 count = aNamespaceURIs->Count();
|
||||
PRUint32 count = aNamespaceURIs->Length();
|
||||
|
||||
if (!aContractIDs || aContractIDs->Count() != count) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -187,13 +187,13 @@ nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRInt32 i;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (aContractIDs->CStringAt(i)->IsEmpty()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsContentUtils::NameSpaceManager()->RegisterNameSpace(*aNamespaceURIs->StringAt(i), namespaceIDs[i]);
|
||||
nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURIs->ElementAt(i), namespaceIDs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
NS_IMETHOD SetDocument(nsIDOMDocument* aDocument);
|
||||
NS_IMETHOD CreateExpression(const nsAString &aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsStringArray *aNamespaceURIs,
|
||||
nsTArray<nsString> *aNamespaceURIs,
|
||||
nsCStringArray *aContractIDs,
|
||||
nsCOMArray<nsISupports> *aState,
|
||||
nsIDOMXPathExpression **aResult);
|
||||
|
|
|
@ -76,16 +76,16 @@ nsTemplateCondition::nsTemplateCondition(nsIAtom* aSourceVariable,
|
|||
PRInt32 start = 0, end = 0;
|
||||
while ((end = aTargets.FindChar(',',start)) >= 0) {
|
||||
if (end > start) {
|
||||
mTargetList.AppendString(Substring(aTargets, start, end - start));
|
||||
mTargetList.AppendElement(Substring(aTargets, start, end - start));
|
||||
}
|
||||
start = end + 1;
|
||||
}
|
||||
if (start < (PRInt32)aTargets.Length()) {
|
||||
mTargetList.AppendString(Substring(aTargets, start));
|
||||
if (start < PRInt32(aTargets.Length())) {
|
||||
mTargetList.AppendElement(Substring(aTargets, start));
|
||||
}
|
||||
}
|
||||
else {
|
||||
mTargetList.AppendString(aTargets);
|
||||
mTargetList.AppendElement(aTargets);
|
||||
}
|
||||
|
||||
MOZ_COUNT_CTOR(nsTemplateCondition);
|
||||
|
@ -150,9 +150,9 @@ nsTemplateCondition::CheckMatch(nsIXULTemplateResult* aResult)
|
|||
else {
|
||||
// iterate over the strings in the target and determine
|
||||
// whether there is a match.
|
||||
PRInt32 length = mTargetList.Count();
|
||||
for (PRInt32 t = 0; t < length; t++) {
|
||||
match = CheckMatchStrings(leftString, *mTargetList[t]);
|
||||
PRUint32 length = mTargetList.Length();
|
||||
for (PRUint32 t = 0; t < length; t++) {
|
||||
match = CheckMatchStrings(leftString, mTargetList[t]);
|
||||
|
||||
// stop once a match is found. In negate mode, stop once a
|
||||
// target does not match.
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIXULTemplateRuleFilter.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
@ -113,7 +114,7 @@ protected:
|
|||
nsString mSource;
|
||||
ConditionRelation mRelation;
|
||||
nsCOMPtr<nsIAtom> mTargetVariable;
|
||||
nsStringArray mTargetList;
|
||||
nsTArray<nsString> mTargetList;
|
||||
PRPackedBool mIgnoreCase;
|
||||
PRPackedBool mNegate;
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ ClearStorage(nsDOMStorageEntry* aEntry, void* userArg)
|
|||
}
|
||||
|
||||
static nsresult
|
||||
GetOfflineDomains(nsStringArray& aDomains)
|
||||
GetOfflineDomains(nsTArray<nsString>& aDomains)
|
||||
{
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
|
@ -298,7 +298,7 @@ GetOfflineDomains(nsStringArray& aDomains)
|
|||
rv = perm->GetHost(host);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aDomains.AppendString(NS_ConvertUTF8toUTF16(host));
|
||||
aDomains.AppendElement(NS_ConvertUTF8toUTF16(host));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ nsDOMStorageManager::Observe(nsISupports *aSubject,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Remove global storage for domains that aren't marked for offline use.
|
||||
nsStringArray domains;
|
||||
nsTArray<nsString> domains;
|
||||
rv = GetOfflineDomains(domains);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return nsDOMStorage::gStorageDB->RemoveOwners(domains, PR_FALSE);
|
||||
|
@ -353,7 +353,7 @@ nsDOMStorageManager::ClearOfflineApps()
|
|||
nsresult rv = nsDOMStorage::InitDB();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsStringArray domains;
|
||||
nsTArray<nsString> domains;
|
||||
rv = GetOfflineDomains(domains);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return nsDOMStorage::gStorageDB->RemoveOwners(domains, PR_TRUE);
|
||||
|
@ -1215,10 +1215,10 @@ nsDOMStorageList::GetStorageForDomain(const nsAString& aRequestedDomain,
|
|||
PRBool aNoCurrentDomainCheck,
|
||||
nsresult* aResult)
|
||||
{
|
||||
nsStringArray requestedDomainArray;
|
||||
nsTArray<nsString> requestedDomainArray;
|
||||
if ((!aNoCurrentDomainCheck &&
|
||||
!CanAccessDomain(aRequestedDomain, aCurrentDomain)) ||
|
||||
!ConvertDomainToArray(aRequestedDomain, &requestedDomainArray)) {
|
||||
!ConvertDomainToArray(aRequestedDomain, &requestedDomainArray)) {
|
||||
*aResult = NS_ERROR_DOM_SECURITY_ERR;
|
||||
|
||||
return nsnull;
|
||||
|
@ -1226,12 +1226,12 @@ nsDOMStorageList::GetStorageForDomain(const nsAString& aRequestedDomain,
|
|||
|
||||
// now rebuild a string for the domain.
|
||||
nsAutoString usedDomain;
|
||||
PRInt32 requestedPos = 0;
|
||||
for (requestedPos = 0; requestedPos < requestedDomainArray.Count();
|
||||
PRUint32 requestedPos = 0;
|
||||
for (requestedPos = 0; requestedPos < requestedDomainArray.Length();
|
||||
requestedPos++) {
|
||||
if (!usedDomain.IsEmpty())
|
||||
usedDomain.AppendLiteral(".");
|
||||
usedDomain.Append(*requestedDomainArray[requestedPos]);
|
||||
usedDomain.Append(requestedDomainArray[requestedPos]);
|
||||
}
|
||||
|
||||
*aResult = NS_OK;
|
||||
|
@ -1252,7 +1252,7 @@ nsDOMStorageList::GetStorageForDomain(const nsAString& aRequestedDomain,
|
|||
// static
|
||||
PRBool
|
||||
nsDOMStorageList::ConvertDomainToArray(const nsAString& aDomain,
|
||||
nsStringArray* aArray)
|
||||
nsTArray<nsString> *aArray)
|
||||
{
|
||||
PRInt32 length = aDomain.Length();
|
||||
PRInt32 n = 0;
|
||||
|
@ -1268,7 +1268,7 @@ nsDOMStorageList::ConvertDomainToArray(const nsAString& aDomain,
|
|||
domain.Assign(Substring(aDomain, n, dotpos - n));
|
||||
|
||||
ToLowerCase(domain);
|
||||
aArray->AppendString(domain);
|
||||
aArray->AppendElement(domain);
|
||||
|
||||
if (dotpos == -1)
|
||||
break;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "nsIDOMStorageItem.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsPIDOMStorage.h"
|
||||
#include "nsIDOMToString.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
@ -263,7 +264,7 @@ protected:
|
|||
*/
|
||||
static PRBool
|
||||
ConvertDomainToArray(const nsAString& aDomain,
|
||||
nsStringArray* aArray);
|
||||
nsTArray<nsString>* aArray);
|
||||
|
||||
nsInterfaceHashtable<nsStringHashKey, nsIDOMStorage> mStorages;
|
||||
};
|
||||
|
|
|
@ -440,9 +440,9 @@ nsDOMStorageDB::RemoveOwner(const nsAString& aOwner)
|
|||
|
||||
|
||||
nsresult
|
||||
nsDOMStorageDB::RemoveOwners(const nsStringArray &aOwners, PRBool aMatch)
|
||||
nsDOMStorageDB::RemoveOwners(const nsTArray<nsString> &aOwners, PRBool aMatch)
|
||||
{
|
||||
if (aOwners.Count() == 0) {
|
||||
if (aOwners.Length() == 0) {
|
||||
if (aMatch) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ nsDOMStorageDB::RemoveOwners(const nsStringArray &aOwners, PRBool aMatch)
|
|||
"WHERE owner NOT IN (?"));
|
||||
}
|
||||
|
||||
for (PRInt32 i = 1; i < aOwners.Count(); i++) {
|
||||
for (PRUint32 i = 1; i < aOwners.Length(); i++) {
|
||||
expression.Append(", ?");
|
||||
}
|
||||
expression.Append(")");
|
||||
|
@ -471,8 +471,8 @@ nsDOMStorageDB::RemoveOwners(const nsStringArray &aOwners, PRBool aMatch)
|
|||
getter_AddRefs(statement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRInt32 i = 0; i < aOwners.Count(); i++) {
|
||||
rv = statement->BindStringParameter(i, *aOwners[i]);
|
||||
for (PRUint32 i = 0; i < aOwners.Length(); i++) {
|
||||
rv = statement->BindStringParameter(i, aOwners[i]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
* list.
|
||||
*/
|
||||
nsresult
|
||||
RemoveOwners(const nsStringArray& aOwners, PRBool aMatch);
|
||||
RemoveOwners(const nsTArray<nsString>& aOwners, PRBool aMatch);
|
||||
|
||||
/**
|
||||
* Removes all keys from storage. Used when clearing storage.
|
||||
|
|
|
@ -89,8 +89,8 @@ NS_IMETHODIMP nsEditorParserObserver::Notify(
|
|||
NS_IMETHODIMP nsEditorParserObserver::Notify(nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const PRUnichar* aTag,
|
||||
const nsStringArray* aKeys,
|
||||
const nsStringArray* aValues,
|
||||
const nsTArray<nsString>* aKeys,
|
||||
const nsTArray<nsString>* aValues,
|
||||
const PRUint32 aFlags)
|
||||
{
|
||||
Notify();
|
||||
|
|
|
@ -62,8 +62,8 @@ public:
|
|||
NS_IMETHOD Notify(nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const PRUnichar* aTag,
|
||||
const nsStringArray* aKeys,
|
||||
const nsStringArray* aValues,
|
||||
const nsTArray<nsString>* aKeys,
|
||||
const nsTArray<nsString>* aValues,
|
||||
const PRUint32 aFlags);
|
||||
|
||||
/* methods for nsIObserver */
|
||||
|
|
|
@ -91,11 +91,11 @@ nsEditorSpellCheck::CanSpellCheck(PRBool* _retval)
|
|||
} else {
|
||||
spellChecker = mSpellChecker;
|
||||
}
|
||||
nsStringArray dictList;
|
||||
nsTArray<nsString> dictList;
|
||||
rv = spellChecker->GetDictionaryList(&dictList);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = (dictList.Count() > 0);
|
||||
*_retval = (dictList.Length() > 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,11 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, PRBool aEnableSelection
|
|||
// locale dictionary didn't work, try to use the first dictionary we find. This helps when
|
||||
// the first dictionary is installed
|
||||
if (! setDictionary) {
|
||||
nsStringArray dictList;
|
||||
nsTArray<nsString> dictList;
|
||||
rv = mSpellChecker->GetDictionaryList(&dictList);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (dictList.Count() > 0) {
|
||||
rv = SetCurrentDictionary(dictList[0]->get());
|
||||
if (dictList.Length() > 0) {
|
||||
rv = SetCurrentDictionary(dictList[0].get());
|
||||
if (NS_SUCCEEDED(rv))
|
||||
SaveDefaultDictionary();
|
||||
}
|
||||
|
@ -260,16 +260,14 @@ NS_IMETHODIMP
|
|||
nsEditorSpellCheck::GetSuggestedWord(PRUnichar **aSuggestedWord)
|
||||
{
|
||||
nsAutoString word;
|
||||
if ( mSuggestedWordIndex < mSuggestedWordList.Count())
|
||||
if ( mSuggestedWordIndex < PRInt32(mSuggestedWordList.Length()))
|
||||
{
|
||||
mSuggestedWordList.StringAt(mSuggestedWordIndex, word);
|
||||
*aSuggestedWord = ToNewUnicode(mSuggestedWordList[mSuggestedWordIndex]);
|
||||
mSuggestedWordIndex++;
|
||||
} else {
|
||||
// A blank string signals that there are no more strings
|
||||
word.Truncate();
|
||||
*aSuggestedWord = ToNewUnicode(EmptyString());
|
||||
}
|
||||
|
||||
*aSuggestedWord = ToNewUnicode(word);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -332,17 +330,15 @@ nsEditorSpellCheck::GetPersonalDictionary()
|
|||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord)
|
||||
{
|
||||
nsAutoString word;
|
||||
if ( mDictionaryIndex < mDictionaryList.Count())
|
||||
if ( mDictionaryIndex < PRInt32( mDictionaryList.Length()))
|
||||
{
|
||||
mDictionaryList.StringAt(mDictionaryIndex, word);
|
||||
*aDictionaryWord = ToNewUnicode(mDictionaryList[mDictionaryIndex]);
|
||||
mDictionaryIndex++;
|
||||
} else {
|
||||
// A blank string signals that there are no more strings
|
||||
word.Truncate();
|
||||
*aDictionaryWord = ToNewUnicode(EmptyString());
|
||||
}
|
||||
|
||||
*aDictionaryWord = ToNewUnicode(word);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -376,7 +372,7 @@ nsEditorSpellCheck::GetDictionaryList(PRUnichar ***aDictionaryList, PRUint32 *aC
|
|||
*aDictionaryList = 0;
|
||||
*aCount = 0;
|
||||
|
||||
nsStringArray dictList;
|
||||
nsTArray<nsString> dictList;
|
||||
|
||||
nsresult rv = mSpellChecker->GetDictionaryList(&dictList);
|
||||
|
||||
|
@ -385,7 +381,7 @@ nsEditorSpellCheck::GetDictionaryList(PRUnichar ***aDictionaryList, PRUint32 *aC
|
|||
|
||||
PRUnichar **tmpPtr = 0;
|
||||
|
||||
if (dictList.Count() < 1)
|
||||
if (dictList.Length() < 1)
|
||||
{
|
||||
// If there are no dictionaries, return an array containing
|
||||
// one element and a count of one.
|
||||
|
@ -402,22 +398,19 @@ nsEditorSpellCheck::GetDictionaryList(PRUnichar ***aDictionaryList, PRUint32 *aC
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
tmpPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * dictList.Count());
|
||||
tmpPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * dictList.Length());
|
||||
|
||||
if (!tmpPtr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aDictionaryList = tmpPtr;
|
||||
*aCount = dictList.Count();
|
||||
|
||||
nsAutoString dictStr;
|
||||
*aCount = dictList.Length();
|
||||
|
||||
PRUint32 i;
|
||||
|
||||
for (i = 0; i < *aCount; i++)
|
||||
{
|
||||
dictList.StringAt(i, dictStr);
|
||||
tmpPtr[i] = ToNewUnicode(dictStr);
|
||||
tmpPtr[i] = ToNewUnicode(dictList[i]);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -66,12 +66,12 @@ public:
|
|||
protected:
|
||||
nsCOMPtr<nsISpellChecker> mSpellChecker;
|
||||
|
||||
nsStringArray mSuggestedWordList;
|
||||
nsTArray<nsString> mSuggestedWordList;
|
||||
PRInt32 mSuggestedWordIndex;
|
||||
|
||||
// these are the words in the current personal dictionary,
|
||||
// GetPersonalDictionary must be called to load them.
|
||||
nsStringArray mDictionaryList;
|
||||
nsTArray<nsString> mDictionaryList;
|
||||
PRInt32 mDictionaryIndex;
|
||||
|
||||
nsresult DeleteSuggestedWordList();
|
||||
|
|
|
@ -851,7 +851,7 @@ nsHTMLCSSUtils::GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** a
|
|||
// value aValue according to the equivalence table aEquivTable
|
||||
void
|
||||
nsHTMLCSSUtils::BuildCSSDeclarations(nsVoidArray & aPropertyArray,
|
||||
nsStringArray & aValueArray,
|
||||
nsTArray<nsString> & aValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
PRBool aGetOrRemoveRequest)
|
||||
|
@ -883,7 +883,7 @@ nsHTMLCSSUtils::BuildCSSDeclarations(nsVoidArray & aPropertyArray,
|
|||
aEquivTable[index].appendValue);
|
||||
GetCSSPropertyAtom(cssProperty, &cssPropertyAtom);
|
||||
aPropertyArray.AppendElement(cssPropertyAtom);
|
||||
aValueArray.AppendString(cssValue);
|
||||
aValueArray.AppendElement(cssValue);
|
||||
}
|
||||
index++;
|
||||
cssProperty = aEquivTable[index].cssProperty;
|
||||
|
@ -898,7 +898,7 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
|
|||
const nsAString * aAttribute,
|
||||
const nsAString * aValue,
|
||||
nsVoidArray & cssPropertyArray,
|
||||
nsStringArray & cssValueArray,
|
||||
nsTArray<nsString> & cssValueArray,
|
||||
PRBool aGetOrRemoveRequest)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node = aNode;
|
||||
|
@ -1001,7 +1001,7 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
|
||||
// Find the CSS equivalence to the HTML style
|
||||
nsVoidArray cssPropertyArray;
|
||||
nsStringArray cssValueArray;
|
||||
nsTArray<nsString> cssValueArray;
|
||||
GenerateCSSDeclarationsFromHTMLStyle(aNode, aHTMLProperty, aAttribute, aValue,
|
||||
cssPropertyArray, cssValueArray, PR_FALSE);
|
||||
|
||||
|
@ -1009,11 +1009,9 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
*aCount = cssPropertyArray.Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < *aCount; index++) {
|
||||
nsAutoString valueString;
|
||||
cssValueArray.StringAt(index, valueString);
|
||||
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
|
||||
res = SetCSSProperty(theElement, (nsIAtom *)cssPropertyArray.ElementAt(index),
|
||||
valueString, aSuppressTransaction);
|
||||
cssValueArray[index], aSuppressTransaction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
@ -1037,7 +1035,7 @@ nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
|
||||
// Find the CSS equivalence to the HTML style
|
||||
nsVoidArray cssPropertyArray;
|
||||
nsStringArray cssValueArray;
|
||||
nsTArray<nsString> cssValueArray;
|
||||
GenerateCSSDeclarationsFromHTMLStyle(aNode, aHTMLProperty, aAttribute, aValue,
|
||||
cssPropertyArray, cssValueArray, PR_TRUE);
|
||||
|
||||
|
@ -1045,10 +1043,10 @@ nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
count = cssPropertyArray.Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsAutoString valueString;
|
||||
cssValueArray.StringAt(index, valueString);
|
||||
res = RemoveCSSProperty(theElement, (nsIAtom *)cssPropertyArray.ElementAt(index), valueString,
|
||||
aSuppressTransaction);
|
||||
res = RemoveCSSProperty(theElement,
|
||||
(nsIAtom *)cssPropertyArray.ElementAt(index),
|
||||
cssValueArray[index],
|
||||
aSuppressTransaction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
@ -1100,7 +1098,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
|||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
nsVoidArray cssPropertyArray;
|
||||
nsStringArray cssValueArray;
|
||||
nsTArray<nsString> cssValueArray;
|
||||
// get the CSS equivalence with last param PR_TRUE indicating we want only the
|
||||
// "gettable" properties
|
||||
GenerateCSSDeclarationsFromHTMLStyle(theElement, aHTMLProperty, aAttribute, nsnull,
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -341,7 +342,7 @@ private:
|
|||
*/
|
||||
|
||||
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
|
||||
nsStringArray & cssValueArray,
|
||||
nsTArray<nsString> & cssValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
@ -364,7 +365,7 @@ private:
|
|||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
nsVoidArray & aPropertyArray,
|
||||
nsStringArray & aValueArray,
|
||||
nsTArray<nsString> & aValueArray,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
||||
/** creates a Transaction for setting or removing a css property
|
||||
|
|
|
@ -214,14 +214,9 @@ nsHTMLEditor::~nsHTMLEditor()
|
|||
// free any default style propItems
|
||||
RemoveAllDefaultProperties();
|
||||
|
||||
while (mStyleSheetURLs.Count())
|
||||
while (mStyleSheetURLs.Length())
|
||||
{
|
||||
nsAString* strp = mStyleSheetURLs.StringAt(0);
|
||||
|
||||
if (strp)
|
||||
{
|
||||
RemoveOverrideStyleSheet(*strp);
|
||||
}
|
||||
RemoveOverrideStyleSheet(mStyleSheetURLs[0]);
|
||||
}
|
||||
|
||||
if (mLinkHandler && mPresShellWeak)
|
||||
|
@ -2184,10 +2179,8 @@ nsHTMLEditor::SetParagraphFormat(const nsAString& aParagraphFormat)
|
|||
// XXX: ERROR_HANDLING -- this method needs a little work to ensure all error codes are
|
||||
// checked properly, all null pointers are checked, and no memory leaks occur
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
|
||||
nsHTMLEditor::GetParentBlockTags(nsTArray<nsString> *aTagList, PRBool aGetLists)
|
||||
{
|
||||
if (!aTagList) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
nsresult res;
|
||||
nsCOMPtr<nsISelection>selection;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
|
@ -2227,7 +2220,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
|
|||
{
|
||||
nsAutoString blockParentTag;
|
||||
blockParentElem->GetTagName(blockParentTag);
|
||||
aTagList->AppendString(blockParentTag);
|
||||
aTagList->AppendElement(blockParentTag);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -2276,8 +2269,8 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
|
|||
blockParent->GetTagName(blockParentTag);
|
||||
PRBool isRoot;
|
||||
IsRootTag(blockParentTag, isRoot);
|
||||
if ((!isRoot) && (-1==aTagList->IndexOf(blockParentTag))) {
|
||||
aTagList->AppendString(blockParentTag);
|
||||
if ((!isRoot) && !aTagList->Contains(blockParentTag)) {
|
||||
aTagList->AppendElement(blockParentTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3719,12 +3712,12 @@ nsHTMLEditor::AddNewStyleSheetToList(const nsAString &aURL,
|
|||
nsICSSStyleSheet *aStyleSheet)
|
||||
{
|
||||
PRInt32 countSS = mStyleSheets.Count();
|
||||
PRInt32 countU = mStyleSheetURLs.Count();
|
||||
PRUint32 countU = mStyleSheetURLs.Length();
|
||||
|
||||
if (countU < 0 || countSS != countU)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (!mStyleSheetURLs.AppendString(aURL))
|
||||
if (!mStyleSheetURLs.AppendElement(aURL))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return mStyleSheets.AppendObject(aStyleSheet) ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
|
@ -3743,8 +3736,7 @@ nsHTMLEditor::RemoveStyleSheetFromList(const nsAString &aURL)
|
|||
nsresult rv = NS_OK;
|
||||
if (!mStyleSheets.RemoveObjectAt(foundIndex))
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (!mStyleSheetURLs.RemoveStringAt(foundIndex))
|
||||
rv = NS_ERROR_FAILURE;
|
||||
mStyleSheetURLs.RemoveElementAt(foundIndex);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -3783,10 +3775,7 @@ nsHTMLEditor::GetURLForStyleSheet(nsICSSStyleSheet *aStyleSheet,
|
|||
return NS_OK;
|
||||
|
||||
// Found it in the list!
|
||||
nsAString* strp = mStyleSheetURLs.StringAt(foundIndex);
|
||||
if (!strp)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
aURL = *strp;
|
||||
aURL = mStyleSheetURLs[foundIndex];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "nsHTMLCSSUtils.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsHTMLObjectResizer.h"
|
||||
#include "nsIHTMLAbsPosEditor.h"
|
||||
|
@ -171,7 +172,7 @@ public:
|
|||
|
||||
NS_IMETHOD LoadHTML(const nsAString &aInputString);
|
||||
|
||||
NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists);
|
||||
NS_IMETHOD GetParentBlockTags(nsTArray<nsString> *aTagList, PRBool aGetLists);
|
||||
|
||||
nsresult GetCSSBackgroundColorState(PRBool *aMixed, nsAString &aOutColor,
|
||||
PRBool aBlockLevel);
|
||||
|
@ -779,7 +780,7 @@ protected:
|
|||
nsString mLastOverrideStyleSheetURL;
|
||||
|
||||
// Maintain a list of associated style sheets and their urls.
|
||||
nsStringArray mStyleSheetURLs;
|
||||
nsTArray<nsString> mStyleSheetURLs;
|
||||
nsCOMArray<nsICSSStyleSheet> mStyleSheets;
|
||||
|
||||
// an array for holding default style settings
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#define nsISpellChecker_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1"
|
||||
|
||||
|
@ -49,7 +50,6 @@
|
|||
|
||||
class nsITextServicesDocument;
|
||||
class nsString;
|
||||
class nsStringArray;
|
||||
|
||||
/**
|
||||
* A generic interface for a spelling checker.
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
* @param aSuggestions is an array of nsStrings, that represent the
|
||||
* suggested replacements for the misspelled word.
|
||||
*/
|
||||
NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestions) = 0;
|
||||
NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) = 0;
|
||||
|
||||
/**
|
||||
* Checks if a word is misspelled. No document is required to use this method.
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
* suggested replacements for the misspelled word. The array will be empty
|
||||
* if there aren't any suggestions.
|
||||
*/
|
||||
NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStringArray *aSuggestions) = 0;
|
||||
NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsTArray<nsString> *aSuggestions) = 0;
|
||||
|
||||
/**
|
||||
* Replaces the old word with the specified new word.
|
||||
|
@ -118,7 +118,7 @@ public:
|
|||
* @param aWordList is an array of nsStrings that represent the
|
||||
* list of words in the user's personal dictionary.
|
||||
*/
|
||||
NS_IMETHOD GetPersonalDictionary(nsStringArray *aWordList) = 0;
|
||||
NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList) = 0;
|
||||
|
||||
/**
|
||||
* Returns the list of strings representing the dictionaries
|
||||
|
@ -129,7 +129,7 @@ public:
|
|||
* @param aDictionaryList is an array of nsStrings that represent the
|
||||
* dictionaries supported by the spellchecker.
|
||||
*/
|
||||
NS_IMETHOD GetDictionaryList(nsStringArray *aDictionaryList) = 0;
|
||||
NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) = 0;
|
||||
|
||||
/**
|
||||
* Returns a string representing the current dictionary.
|
||||
|
|
|
@ -158,7 +158,7 @@ NS_IMETHODIMP mozPersonalDictionary::Load()
|
|||
static PLDHashOperator
|
||||
AddHostToStringArray(nsUniCharEntry *aEntry, void *aArg)
|
||||
{
|
||||
static_cast<nsStringArray*>(aArg)->AppendString(nsDependentString(aEntry->GetKey()));
|
||||
static_cast<nsTArray<nsString>*>(aArg)->AppendElement(nsDependentString(aEntry->GetKey()));
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
|
@ -185,14 +185,13 @@ NS_IMETHODIMP mozPersonalDictionary::Save()
|
|||
res = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream), outStream, 4096);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsStringArray array(mDictionaryTable.Count());
|
||||
nsTArray<nsString> array(mDictionaryTable.Count());
|
||||
mDictionaryTable.EnumerateEntries(AddHostToStringArray, &array);
|
||||
|
||||
PRUint32 bytesWritten;
|
||||
nsCAutoString utf8Key;
|
||||
for (PRInt32 i = 0; i < array.Count(); ++i ) {
|
||||
const nsString *key = array[i];
|
||||
CopyUTF16toUTF8(*key, utf8Key);
|
||||
for (PRInt32 i = 0; i < array.Length(); ++i ) {
|
||||
CopyUTF16toUTF8(array[i], utf8Key);
|
||||
|
||||
bufferedOutputStream->Write(utf8Key.get(), utf8Key.Length(), &bytesWritten);
|
||||
bufferedOutputStream->Write("\n", 1, &bytesWritten);
|
||||
|
@ -206,7 +205,7 @@ NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator **aWords)
|
|||
NS_ENSURE_ARG_POINTER(aWords);
|
||||
*aWords = nsnull;
|
||||
|
||||
nsStringArray *array = new nsStringArray(mDictionaryTable.Count());
|
||||
nsTArray<nsString> *array = new nsTArray<nsString>(mDictionaryTable.Count());
|
||||
if (!array)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#define MOZ_PERSONALDICTIONARY_CONTRACTID "@mozilla.org/spellchecker/personaldictionary;1"
|
||||
|
@ -101,7 +102,7 @@ public:
|
|||
nsresult Init();
|
||||
|
||||
protected:
|
||||
nsStringArray mDictionary; /* use something a little smarter eventually*/
|
||||
nsTArray<nsString> mDictionary; /* use something a little smarter eventually*/
|
||||
PRBool mDirty; /* has the dictionary been modified */
|
||||
nsTHashtable<nsUniCharEntry> mDictionaryTable;
|
||||
nsTHashtable<nsUniCharEntry> mIgnoreTable;
|
||||
|
|
|
@ -84,7 +84,7 @@ mozSpellChecker::SetDocument(nsITextServicesDocument *aDoc, PRBool aFromStartofD
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSpellChecker::NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestions)
|
||||
mozSpellChecker::NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions)
|
||||
{
|
||||
if(!aSuggestions||!mConverter)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -128,7 +128,7 @@ mozSpellChecker::NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestion
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSpellChecker::CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStringArray *aSuggestions)
|
||||
mozSpellChecker::CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsTArray<nsString> *aSuggestions)
|
||||
{
|
||||
nsresult result;
|
||||
PRBool correct;
|
||||
|
@ -152,7 +152,7 @@ mozSpellChecker::CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStri
|
|||
result = mSpellCheckingEngine->Suggest(PromiseFlatString(aWord).get(), &words, &count);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
for(i=0;i<count;i++){
|
||||
aSuggestions->AppendString(nsDependentString(words[i]));
|
||||
aSuggestions->AppendElement(nsDependentString(words[i]));
|
||||
}
|
||||
|
||||
if (count)
|
||||
|
@ -287,7 +287,7 @@ mozSpellChecker::RemoveWordFromPersonalDictionary(const nsAString &aWord)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSpellChecker::GetPersonalDictionary(nsStringArray *aWordList)
|
||||
mozSpellChecker::GetPersonalDictionary(nsTArray<nsString> *aWordList)
|
||||
{
|
||||
if(!aWordList || !mPersonalDictionary)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -299,14 +299,14 @@ mozSpellChecker::GetPersonalDictionary(nsStringArray *aWordList)
|
|||
nsAutoString word;
|
||||
while (NS_SUCCEEDED(words->HasMore(&hasMore)) && hasMore) {
|
||||
words->GetNext(word);
|
||||
aWordList->AppendString(word);
|
||||
aWordList->AppendElement(word);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
struct AppendNewStruct
|
||||
{
|
||||
nsStringArray *dictionaryList;
|
||||
nsTArray<nsString> *dictionaryList;
|
||||
PRBool failed;
|
||||
};
|
||||
|
||||
|
@ -315,7 +315,7 @@ AppendNewString(const nsAString& aString, nsCString*, void* aClosure)
|
|||
{
|
||||
AppendNewStruct *ans = (AppendNewStruct*) aClosure;
|
||||
|
||||
if (!ans->dictionaryList->AppendString(aString))
|
||||
if (!ans->dictionaryList->AppendElement(aString))
|
||||
{
|
||||
ans->failed = PR_TRUE;
|
||||
return PL_DHASH_STOP;
|
||||
|
@ -325,7 +325,7 @@ AppendNewString(const nsAString& aString, nsCString*, void* aClosure)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSpellChecker::GetDictionaryList(nsStringArray *aDictionaryList)
|
||||
mozSpellChecker::GetDictionaryList(nsTArray<nsString> *aDictionaryList)
|
||||
{
|
||||
AppendNewStruct ans = {aDictionaryList, PR_FALSE};
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "mozISpellCheckingEngine.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozISpellI18NUtil.h"
|
||||
|
||||
class mozSpellChecker : public nsISpellChecker
|
||||
|
@ -60,16 +61,16 @@ public:
|
|||
|
||||
// nsISpellChecker
|
||||
NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, PRBool aFromStartofDoc);
|
||||
NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestions);
|
||||
NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStringArray *aSuggestions);
|
||||
NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions);
|
||||
NS_IMETHOD CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsTArray<nsString> *aSuggestions);
|
||||
NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, PRBool aAllOccurrences);
|
||||
NS_IMETHOD IgnoreAll(const nsAString &aWord);
|
||||
|
||||
NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord);
|
||||
NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord);
|
||||
NS_IMETHOD GetPersonalDictionary(nsStringArray *aWordList);
|
||||
NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList);
|
||||
|
||||
NS_IMETHOD GetDictionaryList(nsStringArray *aDictionaryList);
|
||||
NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList);
|
||||
NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary);
|
||||
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary);
|
||||
|
||||
|
@ -85,7 +86,7 @@ protected:
|
|||
nsCString *mCurrentEngineContractId;
|
||||
nsCOMPtr<mozISpellCheckingEngine> mSpellCheckingEngine;
|
||||
PRBool mFromStart;
|
||||
nsStringArray mIgnoreList;
|
||||
nsTArray<nsString> mIgnoreList;
|
||||
|
||||
nsresult SetupDoc(PRUint32 *outBlockOffset);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsMemory.h"
|
||||
|
||||
#include "gfxPlatform.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsThebesFontEnumerator, nsIFontEnumerator)
|
||||
|
||||
|
@ -64,7 +65,7 @@ nsThebesFontEnumerator::EnumerateFonts(const char *aLangGroup,
|
|||
NS_ENSURE_ARG_POINTER(aCount);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
nsStringArray fontList;
|
||||
nsTArray<nsString> fontList;
|
||||
|
||||
nsCAutoString langGroup;
|
||||
nsCAutoString generic;
|
||||
|
@ -89,13 +90,13 @@ nsThebesFontEnumerator::EnumerateFonts(const char *aLangGroup,
|
|||
}
|
||||
|
||||
PRUnichar **fs = static_cast<PRUnichar **>
|
||||
(nsMemory::Alloc(fontList.Count() * sizeof(PRUnichar*)));
|
||||
for (int i = 0; i < fontList.Count(); i++) {
|
||||
fs[i] = ToNewUnicode(*fontList[i]);
|
||||
(nsMemory::Alloc(fontList.Length() * sizeof(PRUnichar*)));
|
||||
for (PRUint32 i = 0; i < fontList.Length(); i++) {
|
||||
fs[i] = ToNewUnicode(fontList[i]);
|
||||
}
|
||||
|
||||
*aResult = fs;
|
||||
*aCount = fontList.Count();
|
||||
*aCount = fontList.Length();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define GFX_PLATFORM_BEOS_H
|
||||
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxTArray.h"
|
||||
|
||||
class gfxFontconfigUtils;
|
||||
|
||||
|
@ -59,7 +60,7 @@ public:
|
|||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
|
||||
nsresult UpdateFontList();
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "gfxPlatform.h"
|
||||
#include "gfxOS2Fonts.h"
|
||||
#include "gfxFontUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class gfxFontconfigUtils;
|
||||
|
||||
|
@ -63,7 +64,7 @@ public:
|
|||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
nsresult UpdateFontList();
|
||||
nsresult ResolveFontName(const nsAString& aFontName,
|
||||
FontResolverCallback aCallback,
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "gfxFont.h"
|
||||
|
||||
#include "nsAutoRef.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include <pango/pango.h>
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "prtypes.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsIObserver.h"
|
||||
|
||||
|
@ -158,7 +159,7 @@ public:
|
|||
*/
|
||||
virtual nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
|
||||
/**
|
||||
* Rebuilds the any cached system font lists
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "gfxPlatform.h"
|
||||
#include "nsAutoRef.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
extern "C" {
|
||||
typedef struct _GdkDrawable GdkDrawable;
|
||||
|
@ -74,7 +75,7 @@ public:
|
|||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
|
||||
nsresult UpdateFontList();
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
nsresult UpdateFontList();
|
||||
|
||||
// in some situations, need to make decisions about ambiguous characters, may need to look at multiple pref langs
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "gfxPlatform.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
typedef struct FT_LibraryRec_ *FT_Library;
|
||||
|
||||
|
@ -62,7 +63,7 @@ public:
|
|||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
|
||||
nsresult UpdateFontList();
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "gfxPlatform.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsDataHashtable.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
@ -62,7 +63,7 @@ public:
|
|||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
|
||||
nsresult UpdateFontList();
|
||||
|
||||
|
@ -159,7 +160,7 @@ private:
|
|||
FontTable mFonts;
|
||||
FontTable mFontAliases;
|
||||
FontTable mFontSubstitutes;
|
||||
nsStringArray mNonExistingFonts;
|
||||
nsTArray<nsString> mNonExistingFonts;
|
||||
|
||||
// when system-wide font lookup fails for a character, cache it to skip future searches
|
||||
gfxSparseBitSet mCodepointsWithNoFonts;
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "gfxImageSurface.h"
|
||||
#include "gfxBeOSSurface.h"
|
||||
|
||||
#include "nsTArray.h"
|
||||
|
||||
gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nsnull;
|
||||
|
||||
gfxBeOSPlatform::gfxBeOSPlatform()
|
||||
|
@ -88,7 +90,7 @@ gfxBeOSPlatform::CreateOffscreenSurface (PRUint32 width,
|
|||
nsresult
|
||||
gfxBeOSPlatform::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
|
||||
aListOfFonts);
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "cairo-ft.h"
|
||||
#include <freetype/tttables.h>
|
||||
#include "gfxFontUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
/**
|
||||
* FontEntry
|
||||
|
@ -177,10 +178,10 @@ gfxFT2FontGroup::FontCallback(const nsAString& fontName,
|
|||
const nsACString& genericName,
|
||||
void *closure)
|
||||
{
|
||||
nsStringArray *sa = static_cast<nsStringArray*>(closure);
|
||||
nsTArray<nsString> *sa = static_cast<nsTArray<nsString>*>(closure);
|
||||
|
||||
if (!fontName.IsEmpty() && sa->IndexOf(fontName) < 0) {
|
||||
sa->AppendString(fontName);
|
||||
if (!fontName.IsEmpty() && !sa->Contains(fontName)) {
|
||||
sa->AppendElement(fontName);
|
||||
#ifdef DEBUG_pavlov
|
||||
printf(" - %s\n", NS_ConvertUTF16toUTF8(fontName).get());
|
||||
#endif
|
||||
|
@ -223,10 +224,10 @@ gfxFT2FontGroup::gfxFT2FontGroup(const nsAString& families,
|
|||
#ifdef DEBUG_pavlov
|
||||
printf("Looking for %s\n", NS_ConvertUTF16toUTF8(families).get());
|
||||
#endif
|
||||
nsStringArray familyArray;
|
||||
nsTArray<nsString> familyArray;
|
||||
ForEachFont(FontCallback, &familyArray);
|
||||
|
||||
if (familyArray.Count() == 0) {
|
||||
if (familyArray.Length() == 0) {
|
||||
nsAutoString prefFamilies;
|
||||
gfxToolkitPlatform::GetPlatform()->GetPrefFonts(aStyle->langGroup.get(), prefFamilies, nsnull);
|
||||
if (!prefFamilies.IsEmpty()) {
|
||||
|
@ -234,17 +235,17 @@ gfxFT2FontGroup::gfxFT2FontGroup(const nsAString& families,
|
|||
}
|
||||
}
|
||||
#if defined(MOZ_WIDGET_QT) /* FIXME DFB */
|
||||
if (familyArray.Count() == 0) {
|
||||
if (familyArray.Length() == 0) {
|
||||
printf("failde to find a font. sadface\n");
|
||||
// We want to get rid of this entirely at some point, but first we need real lists of fonts.
|
||||
QFont defaultFont;
|
||||
QFontInfo fi (defaultFont);
|
||||
familyArray.AppendString(nsDependentString(static_cast<const PRUnichar *>(fi.family().utf16())));
|
||||
familyArray.AppendElement(nsDependentString(static_cast<const PRUnichar *>(fi.family().utf16())));
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < familyArray.Count(); i++) {
|
||||
nsRefPtr<gfxFT2Font> font = GetOrMakeFont(*familyArray[i], &mStyle);
|
||||
for (PRUint32 i = 0; i < familyArray.Length(); i++) {
|
||||
nsRefPtr<gfxFT2Font> font = GetOrMakeFont(familyArray[i], &mStyle);
|
||||
if (font) {
|
||||
mFonts.AppendElement(font);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "nsIPrefService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsIAtom.h"
|
||||
#include "nsCRT.h"
|
||||
|
@ -273,7 +274,7 @@ gfxFontconfigUtils::gfxFontconfigUtils()
|
|||
nsresult
|
||||
gfxFontconfigUtils::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
aListOfFonts.Clear();
|
||||
|
||||
|
@ -283,7 +284,7 @@ gfxFontconfigUtils::GetFontList(const nsACString& aLangGroup,
|
|||
return rv;
|
||||
|
||||
for (PRInt32 i = 0; i < fonts.Count(); ++i) {
|
||||
aListOfFonts.AppendString(NS_ConvertUTF8toUTF16(*fonts.CStringAt(i)));
|
||||
aListOfFonts.AppendElement(NS_ConvertUTF8toUTF16(*fonts.CStringAt(i)));
|
||||
}
|
||||
|
||||
aListOfFonts.Sort();
|
||||
|
@ -310,11 +311,11 @@ gfxFontconfigUtils::GetFontList(const nsACString& aLangGroup,
|
|||
// gFontsDialog.readFontSelection() if the preference-selected font is not
|
||||
// available, so put system configured defaults first.
|
||||
if (monospace)
|
||||
aListOfFonts.InsertStringAt(NS_LITERAL_STRING("monospace"), 0);
|
||||
aListOfFonts.InsertElementAt(0, NS_LITERAL_STRING("monospace"));
|
||||
if (sansSerif)
|
||||
aListOfFonts.InsertStringAt(NS_LITERAL_STRING("sans-serif"), 0);
|
||||
aListOfFonts.InsertElementAt(0, NS_LITERAL_STRING("sans-serif"));
|
||||
if (serif)
|
||||
aListOfFonts.InsertStringAt(NS_LITERAL_STRING("serif"), 0);
|
||||
aListOfFonts.InsertElementAt(0, NS_LITERAL_STRING("serif"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
|
||||
nsresult UpdateFontList();
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "gfxOS2Platform.h"
|
||||
#include "gfxOS2Surface.h"
|
||||
#include "gfxOS2Fonts.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
|
@ -483,7 +484,7 @@ gfxOS2FontGroup::gfxOS2FontGroup(const nsAString& aFamilies,
|
|||
mFamilies.Replace(pos, 8, NS_LITERAL_STRING("Workplace Sans"));
|
||||
}
|
||||
|
||||
nsStringArray familyArray;
|
||||
nsTArray<nsString> familyArray;
|
||||
ForEachFont(FontCallback, &familyArray);
|
||||
|
||||
// To be able to easily search for glyphs in other fonts, append a few good
|
||||
|
@ -499,12 +500,12 @@ gfxOS2FontGroup::gfxOS2FontGroup(const nsAString& aFamilies,
|
|||
// Should append some default font if there are no available fonts.
|
||||
// Let's use Helv which should be available on any OS/2 system; if
|
||||
// it's not there, Fontconfig replaces it with something else...
|
||||
if (familyArray.Count() == 0) {
|
||||
familyArray.AppendString(NS_LITERAL_STRING("Helv"));
|
||||
if (familyArray.Length() == 0) {
|
||||
familyArray.AppendElement(NS_LITERAL_STRING("Helv"));
|
||||
}
|
||||
|
||||
for (int i = 0; i < familyArray.Count(); i++) {
|
||||
nsRefPtr<gfxOS2Font> font = gfxOS2Font::GetOrMakeFont(*familyArray[i], &mStyle);
|
||||
for (PRUint32 i = 0; i < familyArray.Length(); i++) {
|
||||
nsRefPtr<gfxOS2Font> font = gfxOS2Font::GetOrMakeFont(familyArray[i], &mStyle);
|
||||
if (font) {
|
||||
mFonts.AppendElement(font);
|
||||
}
|
||||
|
@ -820,9 +821,9 @@ PRBool gfxOS2FontGroup::FontCallback(const nsAString& aFontName,
|
|||
const nsACString& aGenericName,
|
||||
void *aClosure)
|
||||
{
|
||||
nsStringArray *sa = static_cast<nsStringArray*>(aClosure);
|
||||
if (!aFontName.IsEmpty() && sa->IndexOf(aFontName) < 0) {
|
||||
sa->AppendString(aFontName);
|
||||
nsTArray<nsString> *sa = static_cast<nsTArray<nsString>*>(aClosure);
|
||||
if (!aFontName.IsEmpty() && !sa->Contains(aFontName)) {
|
||||
sa->AppendElement(aFontName);
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "gfxOS2Surface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfxOS2Fonts.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "gfxFontconfigUtils.h"
|
||||
//#include <fontconfig/fontconfig.h>
|
||||
|
@ -111,7 +112,7 @@ gfxOS2Platform::CreateOffscreenSurface(const gfxIntSize& aSize,
|
|||
nsresult
|
||||
gfxOS2Platform::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
#ifdef DEBUG_thebes
|
||||
char *langgroup = ToNewCString(aLangGroup),
|
||||
|
@ -184,18 +185,18 @@ gfxOS2Platform::FindFontForChar(PRUint32 aCh, gfxOS2Font *aFont)
|
|||
// (one should instead cache the charmaps as done on Mac and Win)
|
||||
|
||||
// just continue to append all fonts known to the system
|
||||
nsStringArray fontList;
|
||||
nsTArray<nsString> fontList;
|
||||
nsCAutoString generic;
|
||||
nsresult rv = GetFontList(aFont->GetStyle()->langGroup, generic, fontList);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// start at 3 to skip over the generic entries
|
||||
for (int i = 3; i < fontList.Count(); i++) {
|
||||
for (PRUint32 i = 3; i < fontList.Length(); i++) {
|
||||
#ifdef DEBUG_thebes
|
||||
printf("searching in entry i=%d (%s)\n",
|
||||
i, NS_LossyConvertUTF16toASCII(*fontList[i]).get());
|
||||
i, NS_LossyConvertUTF16toASCII(fontList[i]).get());
|
||||
#endif
|
||||
nsRefPtr<gfxOS2Font> font =
|
||||
gfxOS2Font::GetOrMakeFont(*fontList[i], aFont->GetStyle());
|
||||
gfxOS2Font::GetOrMakeFont(fontList[i], aFont->GetStyle());
|
||||
if (!font)
|
||||
continue;
|
||||
FT_Face face = cairo_ft_scaled_font_lock_face(font->CairoScaledFont());
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "gfxTypes.h"
|
||||
|
||||
#include "nsMathUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
|
||||
#include "nsIPref.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
@ -304,7 +305,7 @@ gfxPlatform::OptimizeImage(gfxImageSurface *aSurface,
|
|||
nsresult
|
||||
gfxPlatform::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
|
|||
nsresult
|
||||
gfxPlatformGtk::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
|
||||
aListOfFonts);
|
||||
|
@ -335,7 +335,7 @@ gfxPlatformGtk::IsFontFormatSupported(nsIURI *aFontURI, PRUint32 aFormatFlags)
|
|||
nsresult
|
||||
gfxPlatformGtk::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
|
||||
aListOfFonts);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "lcms.h"
|
||||
|
||||
|
@ -163,7 +164,7 @@ gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, PRUint32 aFormatFlags)
|
|||
nsresult
|
||||
gfxPlatformMac::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
gfxQuartzFontCache::SharedFontCache()->
|
||||
GetFontList(aLangGroup, aGenericFamily, aListOfFonts);
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include <fontconfig/fontconfig.h>
|
||||
|
||||
#include "nsMathUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "lcms.h"
|
||||
|
||||
|
@ -133,7 +134,7 @@ gfxQtPlatform::CreateOffscreenSurface(const gfxIntSize& size,
|
|||
nsresult
|
||||
gfxQtPlatform::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
|
||||
aListOfFonts);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
// used when picking fallback font
|
||||
struct FontSearch {
|
||||
|
@ -210,7 +211,7 @@ public:
|
|||
|
||||
void GetFontList (const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
PRBool ResolveFontName(const nsAString& aFontName,
|
||||
nsAString& aResolvedFontName);
|
||||
PRBool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
#include "nsIPref.h" // for pref changes callback notification
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
@ -1101,12 +1102,12 @@ gfxQuartzFontCache::GetDefaultFont(const gfxFontStyle* aStyle, PRBool& aNeedsBol
|
|||
struct FontListData {
|
||||
FontListData(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts) :
|
||||
nsTArray<nsString>& aListOfFonts) :
|
||||
mLangGroup(aLangGroup), mGenericFamily(aGenericFamily),
|
||||
mListOfFonts(aListOfFonts) {}
|
||||
const nsACString& mLangGroup;
|
||||
const nsACString& mGenericFamily;
|
||||
nsStringArray& mListOfFonts;
|
||||
nsTArray<nsString>& mListOfFonts;
|
||||
};
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
|
@ -1118,14 +1119,14 @@ gfxQuartzFontCache::HashEnumFuncForFamilies(nsStringHashKey::KeyType aKey,
|
|||
|
||||
nsAutoString localizedFamilyName;
|
||||
aFamilyEntry->LocalizedName(localizedFamilyName);
|
||||
data->mListOfFonts.AppendString(localizedFamilyName);
|
||||
data->mListOfFonts.AppendElement(localizedFamilyName);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
gfxQuartzFontCache::GetFontList (const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
FontListData data(aLangGroup, aGenericFamily, aListOfFonts);
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include "nsIPref.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsIWindowsRegKey.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
@ -150,11 +151,11 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe,
|
|||
// general cmap reading routines moved to gfxFontUtils.cpp
|
||||
|
||||
struct FontListData {
|
||||
FontListData(const nsACString& aLangGroup, const nsACString& aGenericFamily, nsStringArray& aListOfFonts) :
|
||||
FontListData(const nsACString& aLangGroup, const nsACString& aGenericFamily, nsTArray<nsString>& aListOfFonts) :
|
||||
mLangGroup(aLangGroup), mGenericFamily(aGenericFamily), mStringArray(aListOfFonts) {}
|
||||
const nsACString& mLangGroup;
|
||||
const nsACString& mGenericFamily;
|
||||
nsStringArray& mStringArray;
|
||||
nsTArray<nsString>& mStringArray;
|
||||
};
|
||||
|
||||
PLDHashOperator
|
||||
|
@ -177,7 +178,7 @@ gfxWindowsPlatform::HashEnumFunc(nsStringHashKey::KeyType aKey,
|
|||
|
||||
if (aFontEntry->SupportsLangGroup(data->mLangGroup) &&
|
||||
aFontEntry->MatchesGenericFamily(data->mGenericFamily))
|
||||
data->mStringArray.AppendString(aFontFamily->mName);
|
||||
data->mStringArray.AppendElement(aFontFamily->mName);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
@ -185,7 +186,7 @@ gfxWindowsPlatform::HashEnumFunc(nsStringHashKey::KeyType aKey,
|
|||
nsresult
|
||||
gfxWindowsPlatform::GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts)
|
||||
nsTArray<nsString>& aListOfFonts)
|
||||
{
|
||||
FontListData data(aLangGroup, aGenericFamily, aListOfFonts);
|
||||
|
||||
|
@ -270,7 +271,7 @@ gfxWindowsPlatform::UpdateFontList()
|
|||
if (!actualFontName.IsEmpty() && mFonts.Get(actualFontName, &ff))
|
||||
mFontSubstitutes.Put(substituteName, ff);
|
||||
else
|
||||
mNonExistingFonts.AppendString(substituteName);
|
||||
mNonExistingFonts.AppendElement(substituteName);
|
||||
}
|
||||
|
||||
// initialize ranges of characters for which system-wide font search should be skipped
|
||||
|
@ -374,7 +375,7 @@ gfxWindowsPlatform::ResolveFontName(const nsAString& aFontName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mNonExistingFonts.IndexOf(keyName) >= 0) {
|
||||
if (mNonExistingFonts.Contains(keyName)) {
|
||||
aAborted = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -395,7 +396,7 @@ gfxWindowsPlatform::ResolveFontName(const nsAString& aFontName,
|
|||
(FONTENUMPROCW)gfxWindowsPlatform::FontResolveProc,
|
||||
(LPARAM)&data, 0);
|
||||
if (data.mFoundCount == 0)
|
||||
mNonExistingFonts.AppendString(keyName);
|
||||
mNonExistingFonts.AppendElement(keyName);
|
||||
::ReleaseDC(nsnull, dc);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -841,7 +842,8 @@ gfxWindowsPlatform::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
|||
PRUint32 eotlen;
|
||||
|
||||
PRUint32 nameLen = PR_MIN(uniqueName.Length(), LF_FACESIZE - 1);
|
||||
nsPromiseFlatString fontName(Substring(uniqueName, 0, nameLen));
|
||||
nsPromiseFlatString fontName(Substring(uniqueName, 0, nameLen));
|
||||
|
||||
|
||||
rv = gfxFontUtils::MakeEOTHeader(aFontData, aLength, &eotHeader);
|
||||
if (NS_FAILED(rv))
|
||||
|
|
|
@ -137,8 +137,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const PRUnichar* aTag,
|
||||
const nsStringArray* keys,
|
||||
const nsStringArray* values,
|
||||
const nsTArray<nsString>* keys,
|
||||
const nsTArray<nsString>* values,
|
||||
const PRUint32 aFlags)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
@ -159,13 +159,13 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
||||
nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const nsStringArray* keys,
|
||||
const nsStringArray* values)
|
||||
const nsTArray<nsString>* keys,
|
||||
const nsTArray<nsString>* values)
|
||||
{
|
||||
NS_PRECONDITION(keys!=nsnull && values!=nsnull,"Need key-value pair");
|
||||
|
||||
PRInt32 numOfAttributes = keys->Count();
|
||||
NS_ASSERTION( numOfAttributes == values->Count(), "size mismatch");
|
||||
PRUint32 numOfAttributes = keys->Length();
|
||||
NS_ASSERTION( numOfAttributes == values->Length(), "size mismatch");
|
||||
nsresult res=NS_OK;
|
||||
#ifdef DEBUG
|
||||
|
||||
|
@ -174,9 +174,9 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
PRUnichar Ucharset[]={'c','h','a','r','s','e','t','\0'};
|
||||
|
||||
NS_ASSERTION(numOfAttributes >= 3, "should have at least 3 private attribute");
|
||||
NS_ASSERTION(0==nsCRT::strcmp(Uxcommand,(keys->StringAt(numOfAttributes-1))->get()),"last name should be 'X_COMMAND'" );
|
||||
NS_ASSERTION(0==nsCRT::strcmp(UcharsetSource,(keys->StringAt(numOfAttributes-2))->get()),"2nd last name should be 'charsetSource'" );
|
||||
NS_ASSERTION(0==nsCRT::strcmp(Ucharset,(keys->StringAt(numOfAttributes-3))->get()),"3rd last name should be 'charset'" );
|
||||
NS_ASSERTION(0==nsCRT::strcmp(Uxcommand,(keys->ElementAt(numOfAttributes-1)).get()),"last name should be 'X_COMMAND'" );
|
||||
NS_ASSERTION(0==nsCRT::strcmp(UcharsetSource,(keys->ElementAt(numOfAttributes-2)).get()),"2nd last name should be 'charsetSource'" );
|
||||
NS_ASSERTION(0==nsCRT::strcmp(Ucharset,(keys->ElementAt(numOfAttributes-3)).get()),"3rd last name should be 'charset'" );
|
||||
|
||||
#endif
|
||||
NS_ASSERTION(mAlias, "Didn't get nsICharsetAlias in constructor");
|
||||
|
@ -187,10 +187,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
// we need at least 5 - HTTP-EQUIV, CONTENT and 3 private
|
||||
if(numOfAttributes >= 5 )
|
||||
{
|
||||
const PRUnichar *charset = (values->StringAt(numOfAttributes-3))->get();
|
||||
const PRUnichar *source = (values->StringAt(numOfAttributes-2))->get();
|
||||
const nsString& srcStr = values->ElementAt(numOfAttributes-2);
|
||||
PRInt32 err;
|
||||
nsAutoString srcStr(source);
|
||||
PRInt32 src = srcStr.ToInteger(&err);
|
||||
// if we cannot convert the string into PRInt32, return error
|
||||
NS_ASSERTION(NS_SUCCEEDED(err), "cannot get charset source");
|
||||
|
@ -200,15 +198,14 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
if(kCharsetFromMetaTag <= src)
|
||||
return NS_OK; // current charset has higher priority. don't bother to do the following
|
||||
|
||||
PRInt32 i;
|
||||
const PRUnichar *httpEquivValue=nsnull;
|
||||
const PRUnichar *contentValue=nsnull;
|
||||
const PRUnichar *charsetValue=nsnull;
|
||||
|
||||
for(i=0;i<(numOfAttributes-3);i++)
|
||||
for (PRUint32 i = 0; i < numOfAttributes - 3; i++)
|
||||
{
|
||||
const PRUnichar *keyStr;
|
||||
keyStr = (keys->StringAt(i))->get();
|
||||
keyStr = keys->ElementAt(i).get();
|
||||
|
||||
//Change 3.190 in nsHTMLTokens.cpp allow ws/tab/cr/lf exist before
|
||||
// and after text value, this need to be skipped before comparison
|
||||
|
@ -216,11 +213,11 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
keyStr++;
|
||||
|
||||
if(Substring(keyStr, keyStr+10).LowerCaseEqualsLiteral("http-equiv"))
|
||||
httpEquivValue = values->StringAt(i)->get();
|
||||
httpEquivValue = values->ElementAt(i).get();
|
||||
else if(Substring(keyStr, keyStr+7).LowerCaseEqualsLiteral("content"))
|
||||
contentValue = values->StringAt(i)->get();
|
||||
contentValue = values->ElementAt(i).get();
|
||||
else if (Substring(keyStr, keyStr+7).LowerCaseEqualsLiteral("charset"))
|
||||
charsetValue = values->StringAt(i)->get();
|
||||
charsetValue = values->ElementAt(i).get();
|
||||
}
|
||||
NS_NAMED_LITERAL_STRING(contenttype, "Content-Type");
|
||||
NS_NAMED_LITERAL_STRING(texthtml, "text/html");
|
||||
|
@ -278,7 +275,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
LossyCopyUTF16toASCII(nsDependentString(charsetValue), newCharset);
|
||||
}
|
||||
|
||||
nsCAutoString charsetString; charsetString.AssignWithConversion(charset);
|
||||
nsCAutoString charsetString;
|
||||
charsetString.AssignWithConversion(values->ElementAt(numOfAttributes-3));
|
||||
|
||||
if (!newCharset.IsEmpty())
|
||||
{
|
||||
|
@ -333,8 +331,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
|||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag(
|
||||
const nsStringArray* keys,
|
||||
const nsStringArray* values,
|
||||
const nsTArray<nsString>* keys,
|
||||
const nsTArray<nsString>* values,
|
||||
nsAString& aCharset)
|
||||
{
|
||||
if (!mAlias)
|
||||
|
@ -346,11 +344,11 @@ NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag(
|
|||
|
||||
// support for non standard case for compatibility
|
||||
// e.g. <META charset="ISO-8859-1">
|
||||
PRInt32 numOfAttributes = keys->Count();
|
||||
PRUint32 numOfAttributes = keys->Length();
|
||||
if ((numOfAttributes >= 3) &&
|
||||
(keys->StringAt(0)->LowerCaseEqualsLiteral("charset")))
|
||||
(keys->ElementAt(0).LowerCaseEqualsLiteral("charset")))
|
||||
{
|
||||
nsAutoString srcStr((values->StringAt(numOfAttributes-2))->get());
|
||||
const nsString& srcStr = values->ElementAt(numOfAttributes-2);
|
||||
PRInt32 err;
|
||||
PRInt32 src = srcStr.ToInteger(&err);
|
||||
// if we cannot convert the string into PRInt32, return error
|
||||
|
@ -361,7 +359,7 @@ NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag(
|
|||
if (kCharsetFromMetaTag > src)
|
||||
{
|
||||
nsCAutoString newCharset;
|
||||
newCharset.AssignWithConversion(values->StringAt(0)->get());
|
||||
newCharset.AssignWithConversion(values->ElementAt(0).get());
|
||||
|
||||
nsCAutoString preferred;
|
||||
res = mAlias->GetPreferred(newCharset,
|
||||
|
@ -371,8 +369,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag(
|
|||
// compare against the current charset,
|
||||
// also some charsets which should have been found in
|
||||
// the BOM detection.
|
||||
nsString* currentCharset = values->StringAt(numOfAttributes-3);
|
||||
if (!preferred.Equals(NS_LossyConvertUTF16toASCII(*currentCharset)) &&
|
||||
const nsString& currentCharset = values->ElementAt(numOfAttributes-3);
|
||||
if (!preferred.Equals(NS_LossyConvertUTF16toASCII(currentCharset)) &&
|
||||
!preferred.EqualsLiteral("UTF-16") &&
|
||||
!preferred.EqualsLiteral("UTF-16BE") &&
|
||||
!preferred.EqualsLiteral("UTF-16LE") &&
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsObserverBase.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -76,8 +77,8 @@ public:
|
|||
NS_IMETHOD Notify(nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const PRUnichar* aTag,
|
||||
const nsStringArray* keys,
|
||||
const nsStringArray* values,
|
||||
const nsTArray<nsString>* keys,
|
||||
const nsTArray<nsString>* values,
|
||||
const PRUint32 aFlags);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -96,11 +97,11 @@ private:
|
|||
|
||||
NS_IMETHOD Notify(nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const nsStringArray* keys,
|
||||
const nsStringArray* values);
|
||||
const nsTArray<nsString>* keys,
|
||||
const nsTArray<nsString>* values);
|
||||
|
||||
NS_IMETHOD GetCharsetFromCompatibilityTag(const nsStringArray* keys,
|
||||
const nsStringArray* values,
|
||||
NS_IMETHOD GetCharsetFromCompatibilityTag(const nsTArray<nsString>* keys,
|
||||
const nsTArray<nsString>* values,
|
||||
nsAString& aCharset);
|
||||
|
||||
nsCOMPtr<nsICharsetAlias> mAlias;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsObserverBase.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsXMLEncodingObserver: public nsIElementObserver,
|
||||
public nsIObserver,
|
||||
|
@ -71,8 +72,8 @@ public:
|
|||
NS_IMETHOD Notify(nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const PRUnichar* aTag,
|
||||
const nsStringArray* keys,
|
||||
const nsStringArray* values,
|
||||
const nsTArray<nsString>* keys,
|
||||
const nsTArray<nsString>* values,
|
||||
const PRUint32 aFlags)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
|
|
|
@ -78,11 +78,10 @@ nsLocale::nsLocale(nsLocale* other) : fHashtable(nsnull), fCategoryCount(0)
|
|||
}
|
||||
|
||||
|
||||
nsLocale::nsLocale(const nsStringArray& categoryList,
|
||||
const nsStringArray& valueList)
|
||||
nsLocale::nsLocale(const nsTArray<nsString>& categoryList,
|
||||
const nsTArray<nsString>& valueList)
|
||||
: fHashtable(NULL), fCategoryCount(0)
|
||||
{
|
||||
PRInt32 i;
|
||||
PRUnichar* key, *value;
|
||||
|
||||
fHashtable = PL_NewHashTable(LOCALE_HASH_SIZE,&nsLocale::Hash_HashFunction,
|
||||
|
@ -93,11 +92,11 @@ nsLocale::nsLocale(const nsStringArray& categoryList,
|
|||
|
||||
if (fHashtable)
|
||||
{
|
||||
for(i=0; i < categoryList.Count(); ++i)
|
||||
for(PRUint32 i=0; i < categoryList.Length(); ++i)
|
||||
{
|
||||
key = ToNewUnicode(*categoryList.StringAt(i));
|
||||
key = ToNewUnicode(categoryList[i]);
|
||||
NS_ASSERTION(key, "nsLocale: failed to allocate internal hash key");
|
||||
value = ToNewUnicode(*valueList.StringAt(i));
|
||||
value = ToNewUnicode(valueList[i]);
|
||||
NS_ASSERTION(value, "nsLocale: failed to allocate internal hash value");
|
||||
if (!PL_HashTableAdd(fHashtable,key,value)) {
|
||||
nsMemory::Free(key);
|
||||
|
|
|
@ -53,18 +53,17 @@
|
|||
#define nsLocale_h__
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsILocale.h"
|
||||
#include "plhash.h"
|
||||
|
||||
class nsStringArray;
|
||||
|
||||
class nsLocale : public nsILocale {
|
||||
friend class nsLocaleService;
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
nsLocale(void);
|
||||
nsLocale(const nsStringArray& categoryList, const nsStringArray& valueList);
|
||||
nsLocale(const nsTArray<nsString>& categoryList, const nsTArray<nsString>& valueList);
|
||||
nsLocale(nsLocale* other);
|
||||
virtual ~nsLocale(void);
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ class nsIRenderingContext;
|
|||
class nsIPageSequenceFrame;
|
||||
class nsString;
|
||||
class nsAString;
|
||||
class nsStringArray;
|
||||
class nsCaret;
|
||||
class nsStyleContext;
|
||||
class nsFrameSelection;
|
||||
|
|
|
@ -220,7 +220,7 @@ public:
|
|||
mCharCache(0)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsGlyphTable);
|
||||
mFontName.AppendString(aPrimaryFontName);
|
||||
mFontName.AppendElement(aPrimaryFontName);
|
||||
}
|
||||
|
||||
~nsGlyphTable() // not a virtual destructor: this class is not intended to be subclassed
|
||||
|
@ -230,12 +230,12 @@ public:
|
|||
|
||||
const nsAString& PrimaryFontName() const
|
||||
{
|
||||
return *mFontName.StringAt(0);
|
||||
return mFontName[0];
|
||||
}
|
||||
|
||||
const nsAString& FontNameFor(const nsGlyphCode& aGlyphCode) const
|
||||
{
|
||||
return *mFontName.StringAt(aGlyphCode.font);
|
||||
return mFontName[aGlyphCode.font];
|
||||
}
|
||||
|
||||
// True if this table contains some glyphs (variants and/or parts)
|
||||
|
@ -286,7 +286,7 @@ private:
|
|||
// mFontName[0] is the primary font associated to this table. The others
|
||||
// are possible "external" fonts for glyphs not in the primary font
|
||||
// but which are needed to stretch certain characters in the table
|
||||
nsStringArray mFontName;
|
||||
nsTArray<nsString> mFontName;
|
||||
|
||||
// Tri-state variable for error/empty/ready
|
||||
PRInt32 mState;
|
||||
|
@ -320,11 +320,11 @@ nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint
|
|||
if (mState == NS_TABLE_STATE_ERROR) return kNullGlyph;
|
||||
// Load glyph properties if this is the first time we have been here
|
||||
if (mState == NS_TABLE_STATE_EMPTY) {
|
||||
nsresult rv = LoadProperties(*mFontName[0], mGlyphProperties);
|
||||
nsresult rv = LoadProperties(mFontName[0], mGlyphProperties);
|
||||
#ifdef NS_DEBUG
|
||||
nsCAutoString uriStr;
|
||||
uriStr.AssignLiteral("resource://gre/res/fonts/mathfont");
|
||||
LossyAppendUTF16toASCII(*mFontName[0], uriStr);
|
||||
LossyAppendUTF16toASCII(mFontName[0], uriStr);
|
||||
uriStr.StripWhitespace(); // that may come from mFontName
|
||||
uriStr.AppendLiteral(".properties");
|
||||
printf("Loading %s ... %s\n",
|
||||
|
@ -346,7 +346,7 @@ nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint
|
|||
rv = mGlyphProperties->GetStringProperty(key, value);
|
||||
if (NS_FAILED(rv)) break;
|
||||
Clean(value);
|
||||
mFontName.AppendString(value); // i.e., mFontName[i] holds this font name
|
||||
mFontName.AppendElement(value); // i.e., mFontName[i] holds this font name
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,14 +410,12 @@ nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint
|
|||
++i;
|
||||
font = value[i] - '0';
|
||||
++i;
|
||||
if (font >= mFontName.Count()) {
|
||||
if (font >= mFontName.Length()) {
|
||||
NS_ERROR("Non-existant font referenced in glyph table");
|
||||
return kNullGlyph;
|
||||
}
|
||||
// The char cannot be handled if this font is not installed
|
||||
nsAutoString fontName;
|
||||
mFontName.StringAt(font, fontName);
|
||||
if (!fontName.Length() || !CheckFontExistence(aPresContext, fontName)) {
|
||||
if (!mFontName[font].Length() || !CheckFontExistence(aPresContext, mFontName[font])) {
|
||||
return kNullGlyph;
|
||||
}
|
||||
}
|
||||
|
@ -1568,7 +1566,6 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
|
|||
// Set default font and get the default bounding metrics
|
||||
// mStyleContext is a leaf context used only when stretching happens.
|
||||
// For the base size, the default font should come from the parent context
|
||||
nsAutoString fontName;
|
||||
nsFont font = mStyleContext->GetParent()->GetStyleFont()->mFont;
|
||||
|
||||
// Override with specific fonts if applicable for this character
|
||||
|
@ -2092,7 +2089,6 @@ nsMathMLChar::PaintForeground(nsPresContext* aPresContext,
|
|||
}
|
||||
aRenderingContext.SetColor(fgColor);
|
||||
|
||||
nsAutoString fontName;
|
||||
nsFont theFont(styleContext->GetStyleFont()->mFont);
|
||||
if (! mFamily.IsEmpty()) {
|
||||
theFont.name = mFamily;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsString.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
|
@ -81,7 +82,7 @@ static PRInt32 gOperatorCount = 0;
|
|||
static OperatorData* gOperatorArray = nsnull;
|
||||
static nsHashtable* gOperatorTable = nsnull;
|
||||
static nsVoidArray* gStretchyOperatorArray = nsnull;
|
||||
static nsStringArray* gInvariantCharArray = nsnull;
|
||||
static nsTArray<nsString>* gInvariantCharArray = nsnull;
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
|
||||
static const PRUnichar kNullCh = PRUnichar('\0');
|
||||
|
@ -307,7 +308,7 @@ InitOperators(void)
|
|||
key.Append(kMathVariant_name[i]);
|
||||
nsAutoString value;
|
||||
mathfontProp->GetStringProperty(key, value);
|
||||
gInvariantCharArray->AppendString(value); // i.e., gInvariantCharArray[i] holds this list
|
||||
gInvariantCharArray->AppendElement(value); // i.e., gInvariantCharArray[i] holds this list
|
||||
}
|
||||
|
||||
// Parse the Operator Dictionary in two passes.
|
||||
|
@ -376,7 +377,7 @@ InitGlobals()
|
|||
{
|
||||
gInitialized = PR_TRUE;
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
gInvariantCharArray = new nsStringArray();
|
||||
gInvariantCharArray = new nsTArray<nsString>();
|
||||
gStretchyOperatorArray = new nsVoidArray();
|
||||
if (gInvariantCharArray && gStretchyOperatorArray) {
|
||||
gOperatorTable = new nsHashtable();
|
||||
|
@ -620,11 +621,11 @@ nsMathMLOperators::LookupInvariantChar(const nsAString& aChar)
|
|||
InitGlobals();
|
||||
}
|
||||
if (gInvariantCharArray) {
|
||||
for (PRInt32 i = gInvariantCharArray->Count()-1; i >= 0; --i) {
|
||||
nsString* list = gInvariantCharArray->StringAt(i);
|
||||
for (PRInt32 i = gInvariantCharArray->Length()-1; i >= 0; --i) {
|
||||
const nsString& list = gInvariantCharArray->ElementAt(i);
|
||||
nsString::const_iterator start, end;
|
||||
list->BeginReading(start);
|
||||
list->EndReading(end);
|
||||
list.BeginReading(start);
|
||||
list.EndReading(end);
|
||||
// Style-invariant characters are at offset 3*j + 1.
|
||||
if (FindInReadable(aChar, start, end) &&
|
||||
start.size_backward() % 3 == 1) {
|
||||
|
@ -643,15 +644,15 @@ nsMathMLOperators::TransformVariantChar(const PRUnichar& aChar,
|
|||
InitGlobals();
|
||||
}
|
||||
if (gInvariantCharArray) {
|
||||
nsString* list = gInvariantCharArray->StringAt(aVariant);
|
||||
PRInt32 index = list->FindChar(aChar);
|
||||
nsString list = gInvariantCharArray->ElementAt(aVariant);
|
||||
PRInt32 index = list.FindChar(aChar);
|
||||
// BMP characters are at offset 3*j
|
||||
if (index != kNotFound && index % 3 == 0 && list->Length() - index >= 2 ) {
|
||||
if (index != kNotFound && index % 3 == 0 && list.Length() - index >= 2 ) {
|
||||
// The style-invariant character is the next character
|
||||
// (and list should contain padding if the next character is in the BMP).
|
||||
++index;
|
||||
PRUint32 len = NS_IS_HIGH_SURROGATE(list->CharAt(index)) ? 2 : 1;
|
||||
return nsDependentSubstring(*list, index, len);
|
||||
PRUint32 len = NS_IS_HIGH_SURROGATE(list.CharAt(index)) ? 2 : 1;
|
||||
return nsDependentSubstring(list, index, len);
|
||||
}
|
||||
}
|
||||
return nsDependentSubstring(&aChar, &aChar + 1);
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "prtypes.h"
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
|
||||
// {4672AA04-F6AE-11d2-B3B7-00805F8A6670}
|
||||
|
@ -80,8 +81,8 @@ public:
|
|||
NS_IMETHOD Notify(nsISupports* aWebShell,
|
||||
nsISupports* aChannel,
|
||||
const PRUnichar* aTag,
|
||||
const nsStringArray* aKeys,
|
||||
const nsStringArray* aValues,
|
||||
const nsTArray<nsString>* aKeys,
|
||||
const nsTArray<nsString>* aValues,
|
||||
const PRUint32 aFlags) = 0;
|
||||
|
||||
};
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "nsLinebreakConverter.h"
|
||||
#include "nsIFormProcessor.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "prmem.h"
|
||||
|
@ -1230,7 +1231,7 @@ CNavDTD::HandleKeyGen(nsIParserNode* aNode)
|
|||
}
|
||||
|
||||
PRInt32 theAttrCount = aNode->GetAttributeCount();
|
||||
nsStringArray theContent;
|
||||
nsTArray<nsString> theContent;
|
||||
nsAutoString theAttribute;
|
||||
nsAutoString theFormType;
|
||||
CToken* theToken = nsnull;
|
||||
|
@ -1242,7 +1243,6 @@ CNavDTD::HandleKeyGen(nsIParserNode* aNode)
|
|||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
nsString* theTextValue = nsnull;
|
||||
PRInt32 theIndex = nsnull;
|
||||
|
||||
// Populate the tokenizer with the fabricated elements in the reverse
|
||||
|
@ -1253,11 +1253,10 @@ CNavDTD::HandleKeyGen(nsIParserNode* aNode)
|
|||
NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
|
||||
mTokenizer->PushTokenFront(theToken);
|
||||
|
||||
for (theIndex = theContent.Count()-1; theIndex > -1; --theIndex) {
|
||||
theTextValue = theContent[theIndex];
|
||||
for (theIndex = theContent.Length()-1; theIndex > -1; --theIndex) {
|
||||
theToken = mTokenAllocator->CreateTokenOfType(eToken_text,
|
||||
eHTMLTag_text,
|
||||
*theTextValue);
|
||||
theContent[theIndex]);
|
||||
NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
|
||||
mTokenizer->PushTokenFront(theToken);
|
||||
|
||||
|
|
|
@ -1075,7 +1075,7 @@ nsObserverEntry::Notify(nsIParserNode* aNode,
|
|||
PRInt32 theAttrCount = aNode->GetAttributeCount();
|
||||
PRInt32 theObserversCount = theObservers->Count();
|
||||
if (0 < theObserversCount){
|
||||
nsStringArray keys(theAttrCount+4), values(theAttrCount+4);
|
||||
nsTArray<nsString> keys(theAttrCount + 4), values(theAttrCount + 4);
|
||||
|
||||
// XXX this and the following code may be a performance issue.
|
||||
// Every key and value is copied and added to an voidarray (causing at
|
||||
|
@ -1083,21 +1083,21 @@ nsObserverEntry::Notify(nsIParserNode* aNode,
|
|||
// string (total = 2*(keys+3) + 2(or more) array allocations )).
|
||||
PRInt32 index;
|
||||
for (index = 0; index < theAttrCount; ++index) {
|
||||
keys.AppendString(aNode->GetKeyAt(index));
|
||||
values.AppendString(aNode->GetValueAt(index));
|
||||
keys.AppendElement(aNode->GetKeyAt(index));
|
||||
values.AppendElement(aNode->GetValueAt(index));
|
||||
}
|
||||
|
||||
nsAutoString intValue;
|
||||
|
||||
keys.AppendString(NS_LITERAL_STRING("charset"));
|
||||
values.AppendString(theCharsetValue);
|
||||
keys.AppendElement(NS_LITERAL_STRING("charset"));
|
||||
values.AppendElement(theCharsetValue);
|
||||
|
||||
keys.AppendString(NS_LITERAL_STRING("charsetSource"));
|
||||
keys.AppendElement(NS_LITERAL_STRING("charsetSource"));
|
||||
intValue.AppendInt(PRInt32(theCharsetSource),10);
|
||||
values.AppendString(intValue);
|
||||
values.AppendElement(intValue);
|
||||
|
||||
keys.AppendString(NS_LITERAL_STRING("X_COMMAND"));
|
||||
values.AppendString(NS_LITERAL_STRING("text/html"));
|
||||
keys.AppendElement(NS_LITERAL_STRING("X_COMMAND"));
|
||||
values.AppendElement(NS_LITERAL_STRING("text/html"));
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
aParser->GetChannel(getter_AddRefs(channel));
|
||||
|
|
|
@ -843,14 +843,14 @@ nsKeygenFormProcessor::ProcessValue(nsIDOMHTMLElement *aElement,
|
|||
}
|
||||
|
||||
NS_METHOD nsKeygenFormProcessor::ProvideContent(const nsAString& aFormType,
|
||||
nsStringArray& aContent,
|
||||
nsTArray<nsString>& aContent,
|
||||
nsAString& aAttribute)
|
||||
{
|
||||
if (Compare(aFormType, NS_LITERAL_STRING("SELECT"),
|
||||
nsCaseInsensitiveStringComparator()) == 0) {
|
||||
|
||||
for (size_t i = 0; i < number_of_key_size_choices; ++i) {
|
||||
aContent.AppendString(mSECKeySizeChoiceList[i].name);
|
||||
aContent.AppendElement(mSECKeySizeChoiceList[i].name);
|
||||
}
|
||||
aAttribute.AssignLiteral("-mozilla-keygen");
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#define _NSKEYGENHANDLER_H_
|
||||
// Form Processor
|
||||
#include "nsIFormProcessor.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
nsresult GetSlotWithMechanism(PRUint32 mechanism,
|
||||
nsIInterfaceRequestor *ctx,
|
||||
|
@ -62,7 +64,7 @@ public:
|
|||
nsAString& aValue);
|
||||
|
||||
NS_IMETHOD ProvideContent(const nsAString& aFormType,
|
||||
nsStringArray& aContent,
|
||||
nsTArray<nsString>& aContent,
|
||||
nsAString& aAttribute);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ mozStorageStatementWrapper::Initialize(mozIStorageStatement *aStatement)
|
|||
|
||||
for (unsigned int i = 0; i < mResultColumnCount; i++) {
|
||||
const void *name = sqlite3_column_name16 (NativeStatement(), i);
|
||||
mColumnNames.AppendString(nsDependentString(static_cast<const PRUnichar*>(name)));
|
||||
mColumnNames.AppendElement(nsDependentString(static_cast<const PRUnichar*>(name)));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsIXPCScriptable.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "sqlite3.h"
|
||||
|
||||
|
@ -74,7 +75,7 @@ protected:
|
|||
nsRefPtr<mozStorageStatement> mStatement;
|
||||
PRUint32 mParamCount;
|
||||
PRUint32 mResultColumnCount;
|
||||
nsStringArray mColumnNames;
|
||||
nsTArray<nsString> mColumnNames;
|
||||
|
||||
nsCOMPtr<mozIStorageStatementRow> mStatementRow;
|
||||
nsCOMPtr<mozIStorageStatementParams> mStatementParams;
|
||||
|
|
|
@ -110,25 +110,23 @@ nsAutoCompleteSimpleResult::AppendMatch(const nsAString& aValue,
|
|||
const nsAString& aImage,
|
||||
const nsAString& aStyle)
|
||||
{
|
||||
NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
|
||||
CheckInvariants();
|
||||
|
||||
if (! mValues.AppendString(aValue))
|
||||
if (! mValues.AppendElement(aValue))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (! mComments.AppendString(aComment)) {
|
||||
mValues.RemoveStringAt(mValues.Count() - 1);
|
||||
if (! mComments.AppendElement(aComment)) {
|
||||
mValues.RemoveElementAt(mValues.Length() - 1);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (! mImages.AppendString(aImage)) {
|
||||
mValues.RemoveStringAt(mValues.Count() - 1);
|
||||
mComments.RemoveStringAt(mComments.Count() - 1);
|
||||
if (! mImages.AppendElement(aImage)) {
|
||||
mValues.RemoveElementAt(mValues.Length() - 1);
|
||||
mComments.RemoveElementAt(mComments.Length() - 1);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (! mStyles.AppendString(aStyle)) {
|
||||
mValues.RemoveStringAt(mValues.Count() - 1);
|
||||
mComments.RemoveStringAt(mComments.Count() - 1);
|
||||
mImages.RemoveStringAt(mImages.Count() - 1);
|
||||
if (! mStyles.AppendElement(aStyle)) {
|
||||
mValues.RemoveElementAt(mValues.Length() - 1);
|
||||
mComments.RemoveElementAt(mComments.Length() - 1);
|
||||
mImages.RemoveElementAt(mImages.Length() - 1);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -137,59 +135,50 @@ nsAutoCompleteSimpleResult::AppendMatch(const nsAString& aValue,
|
|||
NS_IMETHODIMP
|
||||
nsAutoCompleteSimpleResult::GetMatchCount(PRUint32 *aMatchCount)
|
||||
{
|
||||
NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
|
||||
CheckInvariants();
|
||||
|
||||
*aMatchCount = mValues.Count();
|
||||
*aMatchCount = mValues.Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoCompleteSimpleResult::GetValueAt(PRInt32 aIndex, nsAString& _retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mValues.Count(),
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mValues.Length()),
|
||||
NS_ERROR_ILLEGAL_VALUE);
|
||||
NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
|
||||
mValues.StringAt(aIndex, _retval);
|
||||
CheckInvariants();
|
||||
|
||||
_retval = mValues[aIndex];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoCompleteSimpleResult::GetCommentAt(PRInt32 aIndex, nsAString& _retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mComments.Count(),
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mComments.Length()),
|
||||
NS_ERROR_ILLEGAL_VALUE);
|
||||
NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
|
||||
mComments.StringAt(aIndex, _retval);
|
||||
CheckInvariants();
|
||||
_retval = mComments[aIndex];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoCompleteSimpleResult::GetImageAt(PRInt32 aIndex, nsAString& _retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mImages.Count(),
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mImages.Length()),
|
||||
NS_ERROR_ILLEGAL_VALUE);
|
||||
NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
|
||||
mImages.StringAt(aIndex, _retval);
|
||||
CheckInvariants();
|
||||
_retval = mImages[aIndex];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoCompleteSimpleResult::GetStyleAt(PRInt32 aIndex, nsAString& _retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mStyles.Count(),
|
||||
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < PRInt32(mStyles.Length()),
|
||||
NS_ERROR_ILLEGAL_VALUE);
|
||||
NS_ASSERTION(mValues.Count() == mComments.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mImages.Count(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Count() == mStyles.Count(), "Arrays out of sync");
|
||||
mStyles.StringAt(aIndex, _retval);
|
||||
CheckInvariants();
|
||||
_retval = mStyles[aIndex];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -204,14 +193,14 @@ NS_IMETHODIMP
|
|||
nsAutoCompleteSimpleResult::RemoveValueAt(PRInt32 aRowIndex,
|
||||
PRBool aRemoveFromDb)
|
||||
{
|
||||
NS_ENSURE_TRUE(aRowIndex >= 0 && aRowIndex < mValues.Count(),
|
||||
NS_ENSURE_TRUE(aRowIndex >= 0 && aRowIndex < PRInt32(mValues.Length()),
|
||||
NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
nsAutoString removedValue(*mValues.StringAt(aRowIndex));
|
||||
mValues.RemoveStringAt(aRowIndex);
|
||||
mComments.RemoveStringAt(aRowIndex);
|
||||
mImages.RemoveStringAt(aRowIndex);
|
||||
mStyles.RemoveStringAt(aRowIndex);
|
||||
nsAutoString removedValue(mValues[aRowIndex]);
|
||||
mValues.RemoveElementAt(aRowIndex);
|
||||
mComments.RemoveElementAt(aRowIndex);
|
||||
mImages.RemoveElementAt(aRowIndex);
|
||||
mStyles.RemoveElementAt(aRowIndex);
|
||||
|
||||
if (mListener)
|
||||
mListener->OnValueRemoved(this, removedValue, aRemoveFromDb);
|
||||
|
|
|
@ -45,11 +45,17 @@
|
|||
#include "nsString.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsAutoCompleteSimpleResult : public nsIAutoCompleteSimpleResult
|
||||
{
|
||||
public:
|
||||
nsAutoCompleteSimpleResult();
|
||||
inline void CheckInvariants() {
|
||||
NS_ASSERTION(mValues.Length() == mComments.Length(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Length() == mImages.Length(), "Arrays out of sync");
|
||||
NS_ASSERTION(mValues.Length() == mStyles.Length(), "Arrays out of sync");
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAUTOCOMPLETERESULT
|
||||
|
@ -63,10 +69,10 @@ protected:
|
|||
// What we really want is an array of structs with value/comment/image/style contents.
|
||||
// But then we'd either have to use COM or manage object lifetimes ourselves.
|
||||
// Having four arrays of string simplifies this, but is stupid.
|
||||
nsStringArray mValues;
|
||||
nsStringArray mComments;
|
||||
nsStringArray mImages;
|
||||
nsStringArray mStyles;
|
||||
nsTArray<nsString> mValues;
|
||||
nsTArray<nsString> mComments;
|
||||
nsTArray<nsString> mImages;
|
||||
nsTArray<nsString> mStyles;
|
||||
|
||||
nsString mSearchString;
|
||||
nsString mErrorDescription;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
#include "plstr.h"
|
||||
|
||||
|
@ -99,11 +100,11 @@ protected:
|
|||
nsresult EnumerateHandlers(EnumerateHandlersCallback aCallback, void *aClosure);
|
||||
nsresult EnumerateValidators(EnumerateValidatorsCallback aCallback, void *aClosure);
|
||||
|
||||
nsStringArray mArgs;
|
||||
PRUint32 mState;
|
||||
nsCOMPtr<nsIFile> mWorkingDir;
|
||||
nsCOMPtr<nsIDOMWindow> mWindowContext;
|
||||
PRBool mPreventDefault;
|
||||
nsTArray<nsString> mArgs;
|
||||
PRUint32 mState;
|
||||
nsCOMPtr<nsIFile> mWorkingDir;
|
||||
nsCOMPtr<nsIDOMWindow> mWindowContext;
|
||||
PRBool mPreventDefault;
|
||||
};
|
||||
|
||||
nsCommandLine::nsCommandLine() :
|
||||
|
@ -121,7 +122,7 @@ NS_IMPL_ISUPPORTS2_CI(nsCommandLine,
|
|||
NS_IMETHODIMP
|
||||
nsCommandLine::GetLength(PRInt32 *aResult)
|
||||
{
|
||||
*aResult = mArgs.Count();
|
||||
*aResult = PRInt32(mArgs.Length());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -129,9 +130,9 @@ NS_IMETHODIMP
|
|||
nsCommandLine::GetArgument(PRInt32 aIndex, nsAString& aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_MIN(aIndex, 0);
|
||||
NS_ENSURE_ARG_MAX(aIndex, mArgs.Count());
|
||||
NS_ENSURE_ARG_MAX(aIndex, mArgs.Length());
|
||||
|
||||
mArgs.StringAt(aIndex, aResult);
|
||||
aResult = mArgs[aIndex];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -140,16 +141,14 @@ nsCommandLine::FindFlag(const nsAString& aFlag, PRBool aCaseSensitive, PRInt32 *
|
|||
{
|
||||
NS_ENSURE_ARG(!aFlag.IsEmpty());
|
||||
|
||||
PRInt32 f;
|
||||
|
||||
nsDefaultStringComparator caseCmp;
|
||||
nsCaseInsensitiveStringComparator caseICmp;
|
||||
nsStringComparator& c = aCaseSensitive ?
|
||||
static_cast<nsStringComparator&>(caseCmp) :
|
||||
static_cast<nsStringComparator&>(caseICmp);
|
||||
|
||||
for (f = 0; f < mArgs.Count(); ++f) {
|
||||
const nsString &arg = *mArgs[f];
|
||||
for (PRUint32 f = 0; f < mArgs.Length(); f++) {
|
||||
const nsString &arg = mArgs[f];
|
||||
|
||||
if (arg.Length() >= 2 && arg.First() == PRUnichar('-')) {
|
||||
if (aFlag.Equals(Substring(arg, 1), c)) {
|
||||
|
@ -167,10 +166,10 @@ NS_IMETHODIMP
|
|||
nsCommandLine::RemoveArguments(PRInt32 aStart, PRInt32 aEnd)
|
||||
{
|
||||
NS_ENSURE_ARG_MIN(aStart, 0);
|
||||
NS_ENSURE_ARG_MAX(aEnd, mArgs.Count() - 1);
|
||||
NS_ENSURE_ARG_MAX(aEnd, mArgs.Length() - 1);
|
||||
|
||||
for (PRInt32 i = aEnd; i >= aStart; --i) {
|
||||
mArgs.RemoveStringAt(i);
|
||||
mArgs.RemoveElementAt(i);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -212,17 +211,17 @@ nsCommandLine::HandleFlagWithParam(const nsAString& aFlag, PRBool aCaseSensitive
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (found == mArgs.Count() - 1) {
|
||||
if (found == PRInt32(mArgs.Length()) - 1) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
++found;
|
||||
|
||||
if (mArgs[found]->First() == '-') {
|
||||
if (mArgs[found].First() == '-') {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mArgs.StringAt(found, aResult);
|
||||
aResult = mArgs[found];
|
||||
RemoveArguments(found - 1, found);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -485,7 +484,7 @@ nsCommandLine::appendArg(const char* arg)
|
|||
NS_CopyNativeToUnicode(nsDependentCString(arg), warg);
|
||||
#endif
|
||||
|
||||
mArgs.AppendString(warg);
|
||||
mArgs.AppendElement(warg);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsWildCard.h"
|
||||
|
||||
|
@ -75,7 +76,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAUTOCOMPLETERESULT
|
||||
|
||||
nsStringArray mValues;
|
||||
nsTArray<nsString> mValues;
|
||||
nsAutoString mSearchString;
|
||||
PRUint16 mSearchResult;
|
||||
};
|
||||
|
@ -115,7 +116,7 @@ nsFileResult::nsFileResult(const nsAString& aSearchString,
|
|||
nextFile->GetLeafName(fileName);
|
||||
if (StringBeginsWith(fileName, prefix)) {
|
||||
fileName.Insert(parent, 0);
|
||||
mValues.AppendString(fileName);
|
||||
mValues.AppendElement(fileName);
|
||||
if (mSearchResult == RESULT_NOMATCH && fileName.Equals(mSearchString))
|
||||
mSearchResult = RESULT_IGNORED;
|
||||
else
|
||||
|
@ -155,13 +156,13 @@ NS_IMETHODIMP nsFileResult::GetErrorDescription(nsAString & aErrorDescription)
|
|||
NS_IMETHODIMP nsFileResult::GetMatchCount(PRUint32 *aMatchCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMatchCount);
|
||||
*aMatchCount = mValues.Count();
|
||||
*aMatchCount = mValues.Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFileResult::GetValueAt(PRInt32 index, nsAString & aValue)
|
||||
{
|
||||
mValues.StringAt(index, aValue);
|
||||
aValue = mValues[index];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsPlacesTables.h"
|
||||
|
||||
#include "nsIArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsCollationCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -248,7 +249,7 @@ static PRInt64 GetSimpleBookmarksQueryFolder(
|
|||
const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
||||
nsNavHistoryQueryOptions* aOptions);
|
||||
static void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
||||
nsTArray<nsStringArray*>* aTerms);
|
||||
nsTArray<nsTArray<nsString>*>* aTerms);
|
||||
|
||||
inline void ReverseString(const nsString& aInput, nsAString& aReversed)
|
||||
{
|
||||
|
@ -5923,7 +5924,7 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aQueryNode,
|
|||
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// parse the search terms
|
||||
nsTArray<nsStringArray*> terms;
|
||||
nsTArray<nsTArray<nsString>*> terms;
|
||||
ParseSearchTermsFromQueries(aQueries, &terms);
|
||||
|
||||
PRInt32 queryIndex;
|
||||
|
@ -5989,7 +5990,7 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aQueryNode,
|
|||
|
||||
// if we are excluding items by parent annotation,
|
||||
// exclude items who's parent is a folder with that annotation
|
||||
if (!parentAnnotationToExclude.IsEmpty() && (parentFoldersToExclude.IndexOf(parentId) != -1))
|
||||
if (!parentAnnotationToExclude.IsEmpty() && parentFoldersToExclude.Contains(parentId))
|
||||
continue;
|
||||
|
||||
// Append the node if it matches one of the queries
|
||||
|
@ -6007,10 +6008,10 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aQueryNode,
|
|||
|
||||
// filter out the node of which their parent is in the exclude-folders
|
||||
// cache
|
||||
if (excludeFolders[queryIndex]->IndexOf(parentId) != -1)
|
||||
if (excludeFolders[queryIndex]->Contains(parentId))
|
||||
continue;
|
||||
|
||||
if (includeFolders[queryIndex]->IndexOf(parentId) == -1) {
|
||||
if (!includeFolders[queryIndex]->Contains(parentId)) {
|
||||
// check ancestors
|
||||
PRInt64 ancestor = parentId, lastAncestor;
|
||||
PRBool belongs = PR_FALSE;
|
||||
|
@ -6024,9 +6025,9 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aQueryNode,
|
|||
// GetFolderIdForItems throws when called for the places-root
|
||||
if (NS_FAILED(bookmarks->GetFolderIdForItem(ancestor,&ancestor))) {
|
||||
break;
|
||||
} else if (excludeFolders[queryIndex]->IndexOf(ancestor) != -1) {
|
||||
} else if (excludeFolders[queryIndex]->Contains(ancestor)) {
|
||||
break;
|
||||
} else if (includeFolders[queryIndex]->IndexOf(ancestor) != -1) {
|
||||
} else if (includeFolders[queryIndex]->Contains(ancestor)) {
|
||||
belongs = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -6065,14 +6066,14 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aQueryNode,
|
|||
|
||||
// Determine if every search term matches anywhere in the title, url, tag
|
||||
PRBool matchAll = PR_TRUE;
|
||||
for (PRInt32 termIndex = terms[queryIndex]->Count(); --termIndex >= 0 &&
|
||||
for (PRInt32 termIndex = terms[queryIndex]->Length(); --termIndex >= 0 &&
|
||||
matchAll; ) {
|
||||
const nsString *term = terms[queryIndex]->StringAt(termIndex);
|
||||
const nsString& term = terms[queryIndex]->ElementAt(termIndex);
|
||||
|
||||
// True if any of them match; false makes us quit the loop
|
||||
matchAll = CaseInsensitiveFindInReadable(*term, nodeTitle) ||
|
||||
CaseInsensitiveFindInReadable(*term, nodeURL) ||
|
||||
CaseInsensitiveFindInReadable(*term, nodeTags);
|
||||
matchAll = CaseInsensitiveFindInReadable(term, nodeTitle) ||
|
||||
CaseInsensitiveFindInReadable(term, nodeURL) ||
|
||||
CaseInsensitiveFindInReadable(term, nodeTags);
|
||||
}
|
||||
|
||||
// Skip if we don't match all terms in the title, url or tag
|
||||
|
@ -6892,11 +6893,11 @@ inline PRBool isQueryWhitespace(PRUnichar ch)
|
|||
}
|
||||
|
||||
void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
||||
nsTArray<nsStringArray*>* aTerms)
|
||||
nsTArray<nsTArray<nsString>*>* aTerms)
|
||||
{
|
||||
PRInt32 lastBegin = -1;
|
||||
for (PRUint32 i=0; i < aQueries.Count(); i++) {
|
||||
nsStringArray *queryTerms = new nsStringArray();
|
||||
nsTArray<nsString> *queryTerms = new nsTArray<nsString>();
|
||||
PRBool hasSearchTerms;
|
||||
if (NS_SUCCEEDED(aQueries[i]->GetHasSearchTerms(&hasSearchTerms)) &&
|
||||
hasSearchTerms) {
|
||||
|
@ -6906,7 +6907,7 @@ void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
|||
searchTerms[j] == '"') {
|
||||
if (lastBegin >= 0) {
|
||||
// found the end of a word
|
||||
queryTerms->AppendString(Substring(searchTerms, lastBegin,
|
||||
queryTerms->AppendElement(Substring(searchTerms, lastBegin,
|
||||
j - lastBegin));
|
||||
lastBegin = -1;
|
||||
}
|
||||
|
@ -6919,7 +6920,7 @@ void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
|||
}
|
||||
// last word
|
||||
if (lastBegin >= 0)
|
||||
queryTerms->AppendString(Substring(searchTerms, lastBegin));
|
||||
queryTerms->AppendElement(Substring(searchTerms, lastBegin));
|
||||
}
|
||||
aTerms->AppendElement(queryTerms);
|
||||
}
|
||||
|
|
|
@ -740,7 +740,7 @@ protected:
|
|||
nsString mOrigSearchString;
|
||||
// Search string and tokens for case-insensitive matching
|
||||
nsString mCurrentSearchString;
|
||||
nsStringArray mCurrentSearchTokens;
|
||||
nsTArray<nsString> mCurrentSearchTokens;
|
||||
void GenerateSearchTokens();
|
||||
void AddSearchToken(nsAutoString &aToken);
|
||||
void ProcessTokensForSpecialSearch();
|
||||
|
|
|
@ -236,20 +236,20 @@ StartsWithJS(const nsAString &aString)
|
|||
|
||||
/**
|
||||
* Callback function for putting URLs from a nsDataHashtable<nsStringHashKey,
|
||||
* PRBool> into a nsStringArray.
|
||||
* PRBool> into a nsTArray<nsString>.
|
||||
*
|
||||
* @param aKey
|
||||
* The hashtable entry's key (the url)
|
||||
* @param aData
|
||||
* Unused data
|
||||
* @param aArg
|
||||
* The nsStringArray pointer for collecting URLs
|
||||
* The nsTArray<nsString> pointer for collecting URLs
|
||||
*/
|
||||
PLDHashOperator
|
||||
HashedURLsToArray(const nsAString &aKey, PRBool aData, void *aArg)
|
||||
{
|
||||
// Append the current url to the array of urls
|
||||
static_cast<nsStringArray *>(aArg)->AppendString(aKey);
|
||||
static_cast<nsTArray<nsString> *>(aArg)->AppendElement(aKey);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ nsNavHistory::PerformAutoComplete()
|
|||
// Only do some extra searches on the first chunk
|
||||
if (!mCurrentChunkOffset) {
|
||||
// Only show keywords if there's a search
|
||||
if (mCurrentSearchTokens.Count()) {
|
||||
if (mCurrentSearchTokens.Length()) {
|
||||
rv = AutoCompleteKeywordSearch();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
@ -757,12 +757,12 @@ nsNavHistory::StartSearch(const nsAString & aSearchString,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Collect the previous result's URLs that we want to process
|
||||
nsStringArray urls;
|
||||
nsTArray<nsString> urls;
|
||||
(void)mCurrentResultURLs.EnumerateRead(HashedURLsToArray, &urls);
|
||||
|
||||
// Bind the parameters right away. We can only use the query once.
|
||||
for (PRUint32 i = 0; i < prevMatchCount; i++) {
|
||||
rv = mDBPreviousQuery->BindStringParameter(i + 1, *urls[i]);
|
||||
rv = mDBPreviousQuery->BindStringParameter(i + 1, urls[i]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -862,7 +862,7 @@ nsNavHistory::AddSearchToken(nsAutoString &aToken)
|
|||
{
|
||||
aToken.Trim("\r\n\t\b");
|
||||
if (!aToken.IsEmpty())
|
||||
mCurrentSearchTokens.AppendString(aToken);
|
||||
mCurrentSearchTokens.AppendElement(aToken);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -879,28 +879,28 @@ nsNavHistory::ProcessTokensForSpecialSearch()
|
|||
// SEARCH_BOTH doesn't require any filtering
|
||||
|
||||
// Determine which special searches to apply
|
||||
for (PRInt32 i = mCurrentSearchTokens.Count(); --i >= 0; ) {
|
||||
for (PRInt32 i = PRInt32(mCurrentSearchTokens.Length()); --i >= 0;) {
|
||||
PRBool needToRemove = PR_TRUE;
|
||||
const nsString *token = mCurrentSearchTokens.StringAt(i);
|
||||
const nsString& token = mCurrentSearchTokens[i];
|
||||
|
||||
if (token->Equals(mAutoCompleteRestrictHistory))
|
||||
if (token.Equals(mAutoCompleteRestrictHistory))
|
||||
SET_BEHAVIOR(History);
|
||||
else if (token->Equals(mAutoCompleteRestrictBookmark))
|
||||
else if (token.Equals(mAutoCompleteRestrictBookmark))
|
||||
SET_BEHAVIOR(Bookmark);
|
||||
else if (token->Equals(mAutoCompleteRestrictTag))
|
||||
else if (token.Equals(mAutoCompleteRestrictTag))
|
||||
SET_BEHAVIOR(Tag);
|
||||
else if (token->Equals(mAutoCompleteMatchTitle))
|
||||
else if (token.Equals(mAutoCompleteMatchTitle))
|
||||
SET_BEHAVIOR(Title);
|
||||
else if (token->Equals(mAutoCompleteMatchUrl))
|
||||
else if (token.Equals(mAutoCompleteMatchUrl))
|
||||
SET_BEHAVIOR(Url);
|
||||
else if (token->Equals(mAutoCompleteRestrictTyped))
|
||||
else if (token.Equals(mAutoCompleteRestrictTyped))
|
||||
SET_BEHAVIOR(Typed);
|
||||
else
|
||||
needToRemove = PR_FALSE;
|
||||
|
||||
// Remove the token if it's special search token
|
||||
if (needToRemove)
|
||||
(void)mCurrentSearchTokens.RemoveStringAt(i);
|
||||
mCurrentSearchTokens.RemoveElementAt(i);
|
||||
}
|
||||
|
||||
// Search only typed pages in history for empty searches
|
||||
|
@ -1119,13 +1119,13 @@ nsNavHistory::AutoCompleteProcessSearch(mozIStorageStatement* aQuery,
|
|||
|
||||
// Determine if every token matches either the bookmark title, tags,
|
||||
// page title, or page url
|
||||
for (PRInt32 i = 0; i < mCurrentSearchTokens.Count() && matchAll; i++) {
|
||||
const nsString *token = mCurrentSearchTokens.StringAt(i);
|
||||
for (PRUint32 i = 0; i < mCurrentSearchTokens.Length() && matchAll; i++) {
|
||||
const nsString& token = mCurrentSearchTokens[i];
|
||||
|
||||
// Check if the tags match the search term
|
||||
PRBool matchTags = (*tokenMatchesTarget)(*token, entryTags);
|
||||
PRBool matchTags = (*tokenMatchesTarget)(token, entryTags);
|
||||
// Check if the title matches the search term
|
||||
PRBool matchTitle = (*tokenMatchesTarget)(*token, title);
|
||||
PRBool matchTitle = (*tokenMatchesTarget)(token, title);
|
||||
|
||||
// Make sure we match something in the title or tags if we have to
|
||||
matchAll = matchTags || matchTitle;
|
||||
|
@ -1133,7 +1133,7 @@ nsNavHistory::AutoCompleteProcessSearch(mozIStorageStatement* aQuery,
|
|||
break;
|
||||
|
||||
// Check if the url matches the search term
|
||||
PRBool matchUrl = (*tokenMatchesTarget)(*token, entryURL);
|
||||
PRBool matchUrl = (*tokenMatchesTarget)(token, entryURL);
|
||||
// If we don't match the url when we have to, reset matchAll to
|
||||
// false; otherwise keep track that we did match the current search
|
||||
if (GET_BEHAVIOR(Url) && !matchUrl)
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "ChangeCSSInlineStyleTxn.h"
|
||||
#include "nsEditProperty.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#define SPECIFIED_STYLE_TYPE 1
|
||||
#define COMPUTED_STYLE_TYPE 2
|
||||
|
@ -337,7 +338,7 @@ private:
|
|||
*/
|
||||
|
||||
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
|
||||
nsStringArray & cssValueArray,
|
||||
nsTArray<nsString> & cssValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
@ -360,7 +361,7 @@ private:
|
|||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
nsVoidArray & aPropertyArray,
|
||||
nsStringArray & aValueArray,
|
||||
nsTArray<nsString> & aValueArray,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
||||
/** creates a Transaction for setting or removing a css property
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "ChangeCSSInlineStyleTxn.h"
|
||||
#include "nsEditProperty.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#define SPECIFIED_STYLE_TYPE 1
|
||||
#define COMPUTED_STYLE_TYPE 2
|
||||
|
@ -322,7 +323,7 @@ private:
|
|||
*/
|
||||
|
||||
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
|
||||
nsStringArray & cssValueArray,
|
||||
nsTArray<nsString> & cssValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
@ -345,7 +346,7 @@ private:
|
|||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
nsVoidArray & aPropertyArray,
|
||||
nsStringArray & aValueArray,
|
||||
nsTArray<nsString> & aValueArray,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
||||
/** creates a Transaction for setting or removing a css property
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -336,7 +337,7 @@ private:
|
|||
*/
|
||||
|
||||
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
|
||||
nsStringArray & cssValueArray,
|
||||
nsTArray<nsString> & cssValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
@ -359,7 +360,7 @@ private:
|
|||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
nsVoidArray & aPropertyArray,
|
||||
nsStringArray & aValueArray,
|
||||
nsTArray<nsString> & aValueArray,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
||||
/** creates a Transaction for setting or removing a css property
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -336,7 +337,7 @@ private:
|
|||
*/
|
||||
|
||||
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
|
||||
nsStringArray & cssValueArray,
|
||||
nsTArray<nsString> & cssValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
@ -359,7 +360,7 @@ private:
|
|||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
nsVoidArray & aPropertyArray,
|
||||
nsStringArray & aValueArray,
|
||||
nsTArray<nsString> & aValueArray,
|
||||
PRBool aGetOrRemoveRequest);
|
||||
|
||||
/** creates a Transaction for setting or removing a css property
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsStringEnumerator.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -69,14 +70,14 @@ protected:
|
|||
GlobalPrinters() {}
|
||||
|
||||
static GlobalPrinters mGlobalPrinters;
|
||||
static nsStringArray* mGlobalPrinterList;
|
||||
static nsTArray<nsString>* mGlobalPrinterList;
|
||||
static int mGlobalNumPrinters;
|
||||
|
||||
};
|
||||
//---------------
|
||||
// static members
|
||||
GlobalPrinters GlobalPrinters::mGlobalPrinters;
|
||||
nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
|
||||
nsTArray<nsString>* GlobalPrinters::mGlobalPrinterList = nsnull;
|
||||
int GlobalPrinters::mGlobalNumPrinters = 0;
|
||||
|
||||
nsDeviceContextSpecBeOS::nsDeviceContextSpecBeOS()
|
||||
|
@ -151,7 +152,7 @@ NS_IMETHODIMP nsPrinterEnumeratorBeOS::GetPrinterNameList(nsIStringEnumerator **
|
|||
}
|
||||
|
||||
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||
nsStringArray *printers = new nsStringArray(numPrinters);
|
||||
nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
|
||||
if (!printers) {
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -160,7 +161,7 @@ NS_IMETHODIMP nsPrinterEnumeratorBeOS::GetPrinterNameList(nsIStringEnumerator **
|
|||
int count = 0;
|
||||
while( count < numPrinters )
|
||||
{
|
||||
printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
|
||||
printers->AppendElement(*GlobalPrinters::GetInstance()->GetStringAt(count++));
|
||||
}
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
|
@ -195,12 +196,12 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
|||
mGlobalNumPrinters = 0;
|
||||
|
||||
#ifdef USE_POSTSCRIPT
|
||||
mGlobalPrinterList = new nsStringArray();
|
||||
mGlobalPrinterList = new nsTArray<nsString>();
|
||||
if (!mGlobalPrinterList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
/* add an entry for the default printer (see nsPostScriptObj.cpp) */
|
||||
mGlobalPrinterList->AppendString(
|
||||
mGlobalPrinterList->AppendElement(
|
||||
nsString(NS_ConvertASCIItoUTF16(NS_POSTSCRIPT_DRIVER_NAME "default")));
|
||||
mGlobalNumPrinters++;
|
||||
|
||||
|
@ -232,7 +233,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
|||
name != nsnull ;
|
||||
name = PL_strtok_r(nsnull, " ", &tok_lasts) )
|
||||
{
|
||||
mGlobalPrinterList->AppendString(
|
||||
mGlobalPrinterList->AppendElement(
|
||||
nsString(NS_ConvertASCIItoUTF16(NS_POSTSCRIPT_DRIVER_NAME)) +
|
||||
nsString(NS_ConvertASCIItoUTF16(name)));
|
||||
mGlobalNumPrinters++;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIFileChannel.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsILocalFileMac;
|
||||
@class NSArray;
|
||||
|
@ -101,8 +102,8 @@ protected:
|
|||
nsCOMArray<nsILocalFile> mFiles;
|
||||
nsString mDefault;
|
||||
|
||||
nsStringArray mFilters;
|
||||
nsStringArray mTitles;
|
||||
nsTArray<nsString> mFilters;
|
||||
nsTArray<nsString> mTitles;
|
||||
|
||||
PRInt32 mSelectedTypeIndex;
|
||||
};
|
||||
|
|
|
@ -125,12 +125,12 @@ NSView* nsFilePicker::GetAccessoryView()
|
|||
|
||||
// set up popup button
|
||||
NSPopUpButton* popupButton = [[[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0) pullsDown:NO] autorelease];
|
||||
PRInt32 numMenuItems = mTitles.Count();
|
||||
PRInt32 numMenuItems = mTitles.Length();
|
||||
for (int i = 0; i < numMenuItems; i++) {
|
||||
const nsString& currentTitle = *mTitles[i];
|
||||
const nsString& currentTitle = mTitles[i];
|
||||
NSString *titleString;
|
||||
if (currentTitle.IsEmpty()) {
|
||||
const nsString& currentFilter = *mFilters[i];
|
||||
const nsString& currentFilter = mFilters[i];
|
||||
titleString = [[NSString alloc] initWithCharacters:currentFilter.get()
|
||||
length:currentFilter.Length()];
|
||||
}
|
||||
|
@ -418,25 +418,25 @@ nsFilePicker::GenerateFilterList()
|
|||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
NSArray *filterArray = nil;
|
||||
if (mFilters.Count() > 0) {
|
||||
if (mFilters.Length() > 0) {
|
||||
// Set up our filter string
|
||||
NSMutableString *giantFilterString = [[[NSMutableString alloc] initWithString:@""] autorelease];
|
||||
|
||||
// Loop through each of the filter strings
|
||||
for (PRInt32 loop = 0; loop < mFilters.Count(); loop++) {
|
||||
nsString *filterWide = mFilters[loop];
|
||||
for (PRInt32 loop = 0; PRInt32(loop < mFilters.Length()); loop++) {
|
||||
const nsString& filterWide = mFilters[loop];
|
||||
|
||||
// separate individual filters
|
||||
if ([giantFilterString length] > 0)
|
||||
[giantFilterString appendString:[NSString stringWithString:@";"]];
|
||||
|
||||
// handle special case filters
|
||||
if (filterWide->Equals(NS_LITERAL_STRING("*"))) {
|
||||
if (filterWide.Equals(NS_LITERAL_STRING("*"))) {
|
||||
// if we'll allow all files, we won't bother parsing all other
|
||||
// file types. just return early.
|
||||
return nil;
|
||||
}
|
||||
else if (filterWide->Equals(NS_LITERAL_STRING("..apps"))) {
|
||||
else if (filterWide.Equals(NS_LITERAL_STRING("..apps"))) {
|
||||
// this magic filter means that we should enable app bundles.
|
||||
// translate it into a usable filter, and continue looping through
|
||||
// other filters.
|
||||
|
@ -444,8 +444,8 @@ nsFilePicker::GenerateFilterList()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (filterWide && filterWide->Length() > 0)
|
||||
[giantFilterString appendString:[NSString stringWithCharacters:filterWide->get() length:filterWide->Length()]];
|
||||
if (filterWide.Length() > 0)
|
||||
[giantFilterString appendString:[NSString stringWithCharacters:filterWide.get() length:filterWide.Length()]];
|
||||
}
|
||||
|
||||
// Now we clean stuff up. Get rid of white spaces, "*"'s, and the odd period or two.
|
||||
|
@ -563,8 +563,8 @@ NS_IMETHODIMP nsFilePicker::SetDefaultExtension(const nsAString& aExtension)
|
|||
NS_IMETHODIMP
|
||||
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
|
||||
{
|
||||
mFilters.AppendString(aFilter);
|
||||
mTitles.AppendString(aTitle);
|
||||
mFilters.AppendElement(aFilter);
|
||||
mTitles.AppendElement(aTitle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -101,15 +102,15 @@ public:
|
|||
|
||||
PRBool PrintersAreAllocated() { return mGlobalPrinterList != nsnull; }
|
||||
PRInt32 GetNumPrinters()
|
||||
{ return mGlobalPrinterList ? mGlobalPrinterList->Count() : 0; }
|
||||
nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
|
||||
{ return mGlobalPrinterList ? mGlobalPrinterList->Length() : 0; }
|
||||
nsString* GetStringAt(PRInt32 aInx) { return &mGlobalPrinterList->ElementAt(aInx); }
|
||||
void GetDefaultPrinterName(PRUnichar **aDefaultPrinterName);
|
||||
|
||||
protected:
|
||||
GlobalPrinters() {}
|
||||
|
||||
static GlobalPrinters mGlobalPrinters;
|
||||
static nsStringArray* mGlobalPrinterList;
|
||||
static nsTArray<nsString>* mGlobalPrinterList;
|
||||
};
|
||||
|
||||
#ifdef SET_PRINTER_FEATURES_VIA_PREFS
|
||||
|
@ -380,7 +381,7 @@ void nsPrinterFeatures::SetMultipleConcurrentDeviceContextsSupported( PRBool aCa
|
|||
//---------------
|
||||
// static members
|
||||
GlobalPrinters GlobalPrinters::mGlobalPrinters;
|
||||
nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
|
||||
nsTArray<nsString>* GlobalPrinters::mGlobalPrinterList = nsnull;
|
||||
//---------------
|
||||
|
||||
nsDeviceContextSpecGTK::nsDeviceContextSpecGTK()
|
||||
|
@ -831,7 +832,7 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::GetPrinterNameList(nsIStringEnumerator **a
|
|||
}
|
||||
|
||||
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||
nsStringArray *printers = new nsStringArray(numPrinters);
|
||||
nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
|
||||
if (!printers) {
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -840,7 +841,7 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::GetPrinterNameList(nsIStringEnumerator **a
|
|||
int count = 0;
|
||||
while( count < numPrinters )
|
||||
{
|
||||
printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
|
||||
printers->AppendElement(*GlobalPrinters::GetInstance()->GetStringAt(count++));
|
||||
}
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
|
@ -1075,8 +1076,8 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::DisplayPropertiesDlg(const PRUnichar *aPri
|
|||
static PRBool
|
||||
GlobalPrinterEnumFunc(nsCString& aName, void *aData)
|
||||
{
|
||||
nsStringArray *a = (nsStringArray *)aData;
|
||||
a->AppendString(NS_ConvertUTF8toUTF16(aName));
|
||||
nsTArray<nsString> *a = (nsTArray<nsString> *)aData;
|
||||
a->AppendElement(NS_ConvertUTF8toUTF16(aName));
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1088,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mGlobalPrinterList = new nsStringArray();
|
||||
mGlobalPrinterList = new nsTArray<nsString>();
|
||||
if (!mGlobalPrinterList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -1107,7 +1108,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
|||
#endif /* USE_POSTSCRIPT */
|
||||
|
||||
/* If there are no printers available after all checks, return an error */
|
||||
if (!mGlobalPrinterList->Count())
|
||||
if (!mGlobalPrinterList->Length())
|
||||
{
|
||||
/* Make sure we do not cache an empty printer list */
|
||||
FreeGlobalPrinters();
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
@ -89,14 +90,14 @@ protected:
|
|||
GlobalPrinters() {}
|
||||
|
||||
static GlobalPrinters mGlobalPrinters;
|
||||
static nsStringArray* mGlobalPrinterList;
|
||||
static nsTArray<nsString>* mGlobalPrinterList;
|
||||
static ULONG mGlobalNumPrinters;
|
||||
|
||||
};
|
||||
//---------------
|
||||
// static members
|
||||
GlobalPrinters GlobalPrinters::mGlobalPrinters;
|
||||
nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
|
||||
nsTArray<nsString>* GlobalPrinters::mGlobalPrinterList = nsnull;
|
||||
ULONG GlobalPrinters::mGlobalNumPrinters = 0;
|
||||
//---------------
|
||||
|
||||
|
@ -575,7 +576,7 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::GetPrinterNameList(nsIStringEnumerator **a
|
|||
}
|
||||
|
||||
ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||
nsStringArray *printers = new nsStringArray(numPrinters);
|
||||
nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
|
||||
if (!printers) {
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -584,7 +585,7 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::GetPrinterNameList(nsIStringEnumerator **a
|
|||
ULONG count = 0;
|
||||
while( count < numPrinters )
|
||||
{
|
||||
printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
|
||||
printers->AppendElement(*GlobalPrinters::GetInstance()->GetStringAt(count++));
|
||||
}
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
|
@ -654,7 +655,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
|||
if (!mGlobalNumPrinters)
|
||||
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
|
||||
|
||||
mGlobalPrinterList = new nsStringArray();
|
||||
mGlobalPrinterList = new nsTArray<nsString>();
|
||||
if (!mGlobalPrinterList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -670,7 +671,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
|||
PRInt32 printerNameLength;
|
||||
rv = MultiByteToWideChar(0, printer, strlen(printer),
|
||||
printerName, printerNameLength);
|
||||
mGlobalPrinterList->AppendString(nsDependentString(printerName.Elements()));
|
||||
mGlobalPrinterList->AppendElement(nsDependentString(printerName.Elements()));
|
||||
|
||||
// store printer description in prefs for the print dialog
|
||||
if (!prefFailed) {
|
||||
|
|
|
@ -189,13 +189,13 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
|
|||
filedlg.ulUser = (ULONG)pmydata;
|
||||
filedlg.pfnDlgProc = FileDialogProc;
|
||||
|
||||
int i;
|
||||
PRUint32 i;
|
||||
|
||||
PSZ *apszTypeList;
|
||||
apszTypeList = (PSZ *)malloc(mTitles.Count()*sizeof(PSZ)+1);
|
||||
for (i = 0; i < mTitles.Count(); i++)
|
||||
apszTypeList = (PSZ *)malloc(mTitles.Length()*sizeof(PSZ)+1);
|
||||
for (i = 0; i < mTitles.Length(); i++)
|
||||
{
|
||||
const nsString& typeWide = *mTitles[i];
|
||||
const nsString& typeWide = mTitles[i];
|
||||
nsAutoCharBuffer buffer;
|
||||
PRInt32 bufLength;
|
||||
WideCharToMultiByte(0, typeWide.get(), typeWide.Length(),
|
||||
|
@ -206,10 +206,10 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
|
|||
filedlg.papszITypeList = (PAPSZ)apszTypeList;
|
||||
|
||||
PSZ *apszFilterList;
|
||||
apszFilterList = (PSZ *)malloc(mFilters.Count()*sizeof(PSZ)+1);
|
||||
for (i = 0; i < mFilters.Count(); i++)
|
||||
apszFilterList = (PSZ *)malloc(mFilters.Length()*sizeof(PSZ)+1);
|
||||
for (i = 0; i < mFilters.Length(); i++)
|
||||
{
|
||||
const nsString& filterWide = *mFilters[i];
|
||||
const nsString& filterWide = mFilters[i];
|
||||
apszFilterList[i] = ToNewCString(filterWide);
|
||||
}
|
||||
apszFilterList[i] = 0;
|
||||
|
@ -319,13 +319,13 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
|
|||
mSelectedType = (PRInt16)pmydata->ulCurExt;
|
||||
}
|
||||
|
||||
for (i = 0; i < mTitles.Count(); i++)
|
||||
for (i = 0; i < mTitles.Length(); i++)
|
||||
{
|
||||
nsMemory::Free(*(filedlg.papszITypeList[i]));
|
||||
}
|
||||
free(filedlg.papszITypeList);
|
||||
|
||||
for (i = 0; i < mFilters.Count(); i++)
|
||||
for (i = 0; i < mFilters.Length(); i++)
|
||||
{
|
||||
nsMemory::Free(*(pmydata->papszIFilterList[i]));
|
||||
}
|
||||
|
@ -616,10 +616,10 @@ NS_IMETHODIMP
|
|||
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
|
||||
{
|
||||
if (aFilter.EqualsLiteral("..apps"))
|
||||
mFilters.AppendString(NS_LITERAL_STRING("*.exe;*.cmd;*.com;*.bat"));
|
||||
mFilters.AppendElement(NS_LITERAL_STRING("*.exe;*.cmd;*.com;*.bat"));
|
||||
else
|
||||
mFilters.AppendString(aFilter);
|
||||
mTitles.AppendString(aTitle);
|
||||
mFilters.AppendElement(aFilter);
|
||||
mTitles.AppendElement(aTitle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsBaseFilePicker.h"
|
||||
|
@ -92,8 +93,8 @@ protected:
|
|||
nsCString mFile;
|
||||
nsString mDefault;
|
||||
nsString mDefaultExtension;
|
||||
nsStringArray mFilters;
|
||||
nsStringArray mTitles;
|
||||
nsTArray<nsString> mFilters;
|
||||
nsTArray<nsString> mTitles;
|
||||
nsIUnicodeEncoder* mUnicodeEncoder;
|
||||
nsIUnicodeDecoder* mUnicodeDecoder;
|
||||
PRInt16 mSelectedType;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIWidget.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIPrintSettingsWin.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
@ -939,7 +940,7 @@ nsPrinterEnumeratorWin::GetPrinterNameList(nsIStringEnumerator **aPrinterNameLis
|
|||
}
|
||||
|
||||
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||
nsStringArray *printers = new nsStringArray(numPrinters);
|
||||
nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
|
||||
if (!printers)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -952,7 +953,7 @@ nsPrinterEnumeratorWin::GetPrinterNameList(nsIStringEnumerator **aPrinterNameLis
|
|||
nsAutoString newName;
|
||||
NS_CopyNativeToUnicode(nsDependentCString(name), newName);
|
||||
#endif
|
||||
printers->AppendString(newName);
|
||||
printers->AppendElement(newName);
|
||||
}
|
||||
|
||||
return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
|
||||
|
|
|
@ -204,7 +204,7 @@ void XXXNeverCalled()
|
|||
new nsVariant();
|
||||
nsUnescape(nsnull);
|
||||
nsEscape(nsnull, url_XAlphas);
|
||||
nsStringArray array;
|
||||
nsTArray<nsString> array;
|
||||
NS_NewStringEnumerator(nsnull, &array);
|
||||
NS_NewAdoptingStringEnumerator(nsnull, &array);
|
||||
nsCStringArray carray;
|
||||
|
|
|
@ -54,7 +54,7 @@ class nsStringEnumerator : public nsIStringEnumerator,
|
|||
public nsISimpleEnumerator
|
||||
{
|
||||
public:
|
||||
nsStringEnumerator(const nsStringArray* aArray, PRBool aOwnsArray) :
|
||||
nsStringEnumerator(const nsTArray<nsString>* aArray, PRBool aOwnsArray) :
|
||||
mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE)
|
||||
{}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE)
|
||||
{}
|
||||
|
||||
nsStringEnumerator(const nsStringArray* aArray, nsISupports* aOwner) :
|
||||
nsStringEnumerator(const nsTArray<nsString>* aArray, nsISupports* aOwner) :
|
||||
mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE)
|
||||
{}
|
||||
|
||||
|
@ -85,19 +85,19 @@ private:
|
|||
// constructors make sure mOwnsArray is consistent with
|
||||
// the constness of the objects
|
||||
if (mIsUnicode)
|
||||
delete const_cast<nsStringArray*>(mArray);
|
||||
delete const_cast<nsTArray<nsString>*>(mArray);
|
||||
else
|
||||
delete const_cast<nsCStringArray*>(mCArray);
|
||||
}
|
||||
}
|
||||
|
||||
union {
|
||||
const nsStringArray* mArray;
|
||||
const nsTArray<nsString>* mArray;
|
||||
const nsCStringArray* mCArray;
|
||||
};
|
||||
|
||||
inline PRUint32 Count() {
|
||||
return mIsUnicode ? mArray->Count() : mCArray->Count();
|
||||
return mIsUnicode ? mArray->Length() : mCArray->Count();
|
||||
}
|
||||
|
||||
PRUint32 mIndex;
|
||||
|
@ -137,7 +137,7 @@ nsStringEnumerator::GetNext(nsISupports** aResult)
|
|||
nsSupportsStringImpl* stringImpl = new nsSupportsStringImpl();
|
||||
if (!stringImpl) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
stringImpl->SetData(*mArray->StringAt(mIndex++));
|
||||
stringImpl->SetData(mArray->ElementAt(mIndex++));
|
||||
*aResult = stringImpl;
|
||||
}
|
||||
else {
|
||||
|
@ -157,7 +157,7 @@ nsStringEnumerator::GetNext(nsAString& aResult)
|
|||
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
|
||||
|
||||
if (mIsUnicode)
|
||||
aResult = *mArray->StringAt(mIndex++);
|
||||
aResult = mArray->ElementAt(mIndex++);
|
||||
else
|
||||
CopyUTF8toUTF16(*mCArray->CStringAt(mIndex++), aResult);
|
||||
|
||||
|
@ -170,7 +170,7 @@ nsStringEnumerator::GetNext(nsACString& aResult)
|
|||
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
|
||||
|
||||
if (mIsUnicode)
|
||||
CopyUTF16toUTF8(*mArray->StringAt(mIndex++), aResult);
|
||||
CopyUTF16toUTF8(mArray->ElementAt(mIndex++), aResult);
|
||||
else
|
||||
aResult = *mCArray->CStringAt(mIndex++);
|
||||
|
||||
|
@ -193,7 +193,7 @@ StringEnumeratorTail(T** aResult NS_INPARAM)
|
|||
|
||||
NS_COM nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
||||
const nsStringArray* aArray, nsISupports* aOwner)
|
||||
const nsTArray<nsString>* aArray, nsISupports* aOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
|
@ -216,7 +216,7 @@ NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
|||
|
||||
NS_COM nsresult
|
||||
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
|
||||
nsStringArray* aArray)
|
||||
nsTArray<nsString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
|
@ -239,7 +239,7 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
|||
// const ones internally just forward to the non-const equivalents
|
||||
NS_COM nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
||||
const nsStringArray* aArray)
|
||||
const nsTArray<nsString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "nsIStringEnumerator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
// nsIStringEnumerator/nsIUTF8StringEnumerator implementations
|
||||
//
|
||||
|
@ -75,12 +76,16 @@
|
|||
// NS_RELEASE(enumerator);
|
||||
//
|
||||
NS_COM nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
||||
const nsTArray<nsString>* aArray,
|
||||
nsISupports* aOwner);
|
||||
NS_COM nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
|
||||
const nsCStringArray* aArray);
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
||||
const nsStringArray* aArray);
|
||||
const nsTArray<nsString>* aArray);
|
||||
|
||||
// Adopting string enumerators assume ownership of the array and will
|
||||
// call |operator delete| on the array when the enumerator is destroyed
|
||||
|
@ -93,7 +98,7 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
|||
// NS_NewAdoptingStringEnumerator(&result, array);
|
||||
NS_COM nsresult
|
||||
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
||||
nsStringArray* aArray);
|
||||
nsTArray<nsString>* aArray);
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
|
||||
|
@ -113,10 +118,6 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM
|
|||
// }
|
||||
//
|
||||
NS_COM nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
|
||||
const nsStringArray* aArray,
|
||||
nsISupports* aOwner);
|
||||
NS_COM nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
|
||||
const nsCStringArray* aArray,
|
||||
nsISupports* aOwner);
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "plbase64.h"
|
||||
#include "prmem.h"
|
||||
|
@ -456,7 +457,7 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions)
|
|||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
nsStringArray nonExtantNodes;
|
||||
nsTArray<nsString> nonExtantNodes;
|
||||
CFURLRef pathURLRef = mBaseRef;
|
||||
FSRef pathFSRef;
|
||||
CFStringRef leafStrRef = nsnull;
|
||||
|
@ -475,7 +476,7 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions)
|
|||
break;
|
||||
::CFStringGetCharacters(leafStrRef, CFRangeMake(0, leafLen), buffer.Elements());
|
||||
buffer[leafLen] = '\0';
|
||||
nonExtantNodes.AppendString(nsString(nsDependentString(buffer.Elements())));
|
||||
nonExtantNodes.AppendElement(nsString(nsDependentString(buffer.Elements())));
|
||||
::CFRelease(leafStrRef);
|
||||
leafStrRef = nsnull;
|
||||
|
||||
|
@ -493,14 +494,14 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions)
|
|||
::CFRelease(leafStrRef);
|
||||
if (!success)
|
||||
return NS_ERROR_FAILURE;
|
||||
PRInt32 nodesToCreate = nonExtantNodes.Count();
|
||||
PRInt32 nodesToCreate = PRInt32(nonExtantNodes.Length());
|
||||
if (nodesToCreate == 0)
|
||||
return NS_ERROR_FILE_ALREADY_EXISTS;
|
||||
|
||||
OSErr err;
|
||||
nsAutoString nextNodeName;
|
||||
for (PRInt32 i = nodesToCreate - 1; i > 0; i--) {
|
||||
nonExtantNodes.StringAt(i, nextNodeName);
|
||||
nextNodeName = nonExtantNodes[i];
|
||||
err = ::FSCreateDirectoryUnicode(&pathFSRef,
|
||||
nextNodeName.Length(),
|
||||
(const UniChar *)nextNodeName.get(),
|
||||
|
@ -509,7 +510,7 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions)
|
|||
if (err != noErr)
|
||||
return MacErrorMapper(err);
|
||||
}
|
||||
nonExtantNodes.StringAt(0, nextNodeName);
|
||||
nextNodeName = nonExtantNodes[0];
|
||||
if (type == NORMAL_FILE_TYPE) {
|
||||
err = ::FSCreateFileUnicode(&pathFSRef,
|
||||
nextNodeName.Length(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче