From 511a78749289cc3f85559fdbb87441452733c7cf Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Sat, 13 Oct 2001 00:16:32 +0000 Subject: [PATCH] convert nsCRT::strn?cmp to Convert() for bug 100214, to depend on string rather than xpcom for case-insensitive unicode support. r=sspitzer for mail stuff, r=jag for everything else, sr=sfraser --- content/base/src/nsDocument.cpp | 5 +- content/base/src/nsHTMLValue.cpp | 5 +- content/html/content/src/Makefile.in | 1 + content/html/content/src/makefile.win | 2 +- .../html/content/src/nsHTMLAnchorElement.cpp | 5 +- content/html/style/src/Makefile.in | 1 + content/html/style/src/makefile.win | 1 + content/html/style/src/nsCSSStyleSheet.cpp | 13 +- content/shared/src/nsHTMLValue.cpp | 5 +- content/xul/templates/src/Makefile.in | 1 + content/xul/templates/src/makefile.win | 1 + .../templates/src/nsXULOutlinerBuilder.cpp | 5 +- .../xul/templates/src/nsXULSortService.cpp | 26 +-- .../xul/templates/src/nsXULTreeBuilder.cpp | 5 +- editor/libeditor/html/Makefile.in | 1 + editor/libeditor/html/makefile.win | 7 +- editor/libeditor/html/nsHTMLEditRules.cpp | 161 +++++++++--------- editor/libeditor/html/nsHTMLEditor.cpp | 41 ++--- editor/libeditor/html/nsHTMLEditorStyle.cpp | 15 +- extensions/wallet/src/makefile.win | 15 +- extensions/wallet/src/wallet.cpp | 47 ++--- intl/chardet/src/Makefile.in | 1 + intl/chardet/src/makefile.win | 2 + intl/chardet/src/nsMetaCharsetObserver.cpp | 56 +++--- intl/chardet/src/nsXMLEncodingObserver.cpp | 7 +- intl/uconv/src/Makefile.in | 1 + intl/uconv/src/makefile.win | 3 +- intl/uconv/src/nsCharsetAliasImp.cpp | 2 +- layout/style/nsCSSStyleSheet.cpp | 13 +- layout/xul/base/src/nsMenuBarFrame.cpp | 3 +- mailnews/addrbook/src/Makefile.in | 1 + mailnews/addrbook/src/makefile.win | 4 +- .../addrbook/src/nsAbAutoCompleteSession.cpp | 76 ++++++--- mailnews/base/src/Makefile.in | 1 + mailnews/base/src/makefile.win | 3 +- mailnews/base/src/nsMsgAccountManager.cpp | 6 +- mailnews/base/util/makefile.win | 1 + mailnews/base/util/nsMsgFolder.cpp | 20 ++- mailnews/compose/src/Makefile.in | 1 + mailnews/compose/src/makefile.win | 4 +- mailnews/compose/src/nsMsgCompose.cpp | 29 ++-- mailnews/imap/src/Makefile.in | 1 + mailnews/imap/src/makefile.win | 1 + mailnews/imap/src/nsImapMailFolder.cpp | 7 +- mailnews/local/src/Makefile.in | 1 + mailnews/local/src/makefile.win | 1 + mailnews/local/src/nsLocalMailFolder.cpp | 14 +- mailnews/mime/src/Makefile.in | 1 + mailnews/mime/src/makefile.win | 3 +- mailnews/mime/src/nsStreamConverter.cpp | 3 +- rdf/base/src/Makefile.in | 1 + rdf/base/src/makefile.win | 1 + rdf/base/src/rdfutil.cpp | 1 + xpfe/components/urlbarhistory/src/Makefile.in | 1 + .../components/urlbarhistory/src/makefile.win | 1 + .../urlbarhistory/src/nsUrlbarHistory.cpp | 13 +- 56 files changed, 382 insertions(+), 265 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 233189b4961..f9668ec579f 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -49,6 +49,7 @@ #include "nsILoadGroup.h" #include "nsIChannel.h" #include "nsString.h" +#include "nsUnicharUtils.h" #include "nsIContent.h" #include "nsIStyleSet.h" #include "nsIStyleSheet.h" @@ -450,7 +451,7 @@ nsDocument::nsDocument() : mIsGoingAway(PR_FALSE), mArena = nsnull; mDocumentURL = nsnull; - mCharacterSet.AssignWithConversion("ISO-8859-1"); + mCharacterSet.Assign(NS_LITERAL_STRING("ISO-8859-1")); mParentDocument = nsnull; mRootContent = nsnull; mListenerManager = nsnull; @@ -3330,7 +3331,7 @@ nsDocument::SaveFile( nsIFile* aFile, { rv = GetDocumentCharacterSet(charsetStr); if(NS_FAILED(rv)) { - charsetStr.AssignWithConversion("ISO-8859-1"); + charsetStr.Assign(NS_LITERAL_STRING("ISO-8859-1")); } } encoder->SetCharset(charsetStr); diff --git a/content/base/src/nsHTMLValue.cpp b/content/base/src/nsHTMLValue.cpp index 24b9f4b1cb7..a76650a431c 100644 --- a/content/base/src/nsHTMLValue.cpp +++ b/content/base/src/nsHTMLValue.cpp @@ -40,6 +40,7 @@ #include "nsHTMLValue.h" #include "nsString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsCRT.h" #include "nsISizeOfHandler.h" @@ -172,7 +173,9 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const } } else if (nsnull != aOther.mValue.mString) { - return 0 == nsCRT::strcasecmp(mValue.mString, aOther.mValue.mString); + return 0 == Compare(nsDependentString(mValue.mString), + nsDependentString(aOther.mValue.mString), + nsCaseInsensitiveStringComparator()); } } else if (eHTMLUnit_ISupports == mUnit) { diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index a3730b6404a..596d930ca18 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -36,6 +36,7 @@ REQUIRES = xpcom \ dom \ js \ locale \ + unicharutil \ webshell \ htmlparser \ necko \ diff --git a/content/html/content/src/makefile.win b/content/html/content/src/makefile.win index 21084594fdb..312e5e0636e 100644 --- a/content/html/content/src/makefile.win +++ b/content/html/content/src/makefile.win @@ -28,8 +28,8 @@ REQUIRES = xpcom \ widget \ dom \ js \ - uriloader \ locale \ + unicharutil \ webshell \ htmlparser \ necko \ diff --git a/content/html/content/src/nsHTMLAnchorElement.cpp b/content/html/content/src/nsHTMLAnchorElement.cpp index c042007a246..cdac6193ad2 100644 --- a/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/content/html/content/src/nsHTMLAnchorElement.cpp @@ -38,6 +38,7 @@ #include "nsCOMPtr.h" #include "nsHTMLUtils.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMNSHTMLAnchorElement.h" #include "nsIDOMEventReceiver.h" @@ -395,8 +396,8 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::suppress) { - if (nsCRT::strcasecmp(PromiseFlatString(aValue).get(), - NS_LITERAL_STRING("true").get())) { + if (Compare(aValue,NS_LITERAL_STRING("true"), + nsCaseInsensitiveStringComparator())) { aResult.SetEmptyValue(); // XXX? shouldn't just leave "true" return NS_CONTENT_ATTR_HAS_VALUE; } diff --git a/content/html/style/src/Makefile.in b/content/html/style/src/Makefile.in index cc9111ab292..b9e3c128f4b 100644 --- a/content/html/style/src/Makefile.in +++ b/content/html/style/src/Makefile.in @@ -36,6 +36,7 @@ REQUIRES = xpcom \ widget \ caps \ locale \ + unicharutil \ js \ necko \ webshell \ diff --git a/content/html/style/src/makefile.win b/content/html/style/src/makefile.win index 44df79e4ccd..ec3797dee2b 100644 --- a/content/html/style/src/makefile.win +++ b/content/html/style/src/makefile.win @@ -35,6 +35,7 @@ REQUIRES = xpcom \ htmlparser \ docshell \ uconv \ + unicharutil \ xpconnect \ pref \ layout \ diff --git a/content/html/style/src/nsCSSStyleSheet.cpp b/content/html/style/src/nsCSSStyleSheet.cpp index b38ebad5b11..e8e42d133c5 100644 --- a/content/html/style/src/nsCSSStyleSheet.cpp +++ b/content/html/style/src/nsCSSStyleSheet.cpp @@ -63,6 +63,7 @@ #include "nsIFrame.h" #include "nsString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsVoidArray.h" #include "nsIUnicharInputStream.h" #include "nsHTMLIIDs.h" @@ -186,6 +187,10 @@ PRBool AtomKey_base::Equals(const nsHashKey* aKey) const return PRBool (((AtomKey_base*)aKey)->mAtom == mAtom); } + // first try case-sensitive match + if (((AtomKey_base*)aKey)->mAtom == mAtom) + return PR_TRUE; + #ifdef DEBUG_HASH DebugHashCount(PR_FALSE); #endif @@ -197,7 +202,9 @@ PRBool AtomKey_base::Equals(const nsHashKey* aKey) const const PRUnichar *theirStr = nsnull; theirAtom->GetUnicode(&theirStr); - return nsCRT::strcasecmp(myStr, theirStr) == 0; + return Compare(nsDependentString(myStr), + nsDependentString(theirStr), + nsCaseInsensitiveStringComparator()) == 0; } @@ -3367,7 +3374,9 @@ static PRBool ValueIncludes(const nsString& aValueList, const nsString& aValue, } } else { - if (!nsCRT::strcasecmp(value, start)) { + if (!Compare(nsDependentString(value), + nsDependentString(start), + nsCaseInsensitiveStringComparator())) { return PR_TRUE; } } diff --git a/content/shared/src/nsHTMLValue.cpp b/content/shared/src/nsHTMLValue.cpp index 24b9f4b1cb7..a76650a431c 100644 --- a/content/shared/src/nsHTMLValue.cpp +++ b/content/shared/src/nsHTMLValue.cpp @@ -40,6 +40,7 @@ #include "nsHTMLValue.h" #include "nsString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsCRT.h" #include "nsISizeOfHandler.h" @@ -172,7 +173,9 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const } } else if (nsnull != aOther.mValue.mString) { - return 0 == nsCRT::strcasecmp(mValue.mString, aOther.mValue.mString); + return 0 == Compare(nsDependentString(mValue.mString), + nsDependentString(aOther.mValue.mString), + nsCaseInsensitiveStringComparator()); } } else if (eHTMLUnit_ISupports == mUnit) { diff --git a/content/xul/templates/src/Makefile.in b/content/xul/templates/src/Makefile.in index 3891c0f7132..f571af2d74d 100644 --- a/content/xul/templates/src/Makefile.in +++ b/content/xul/templates/src/Makefile.in @@ -42,6 +42,7 @@ REQUIRES = xpcom \ rdf \ necko \ locale \ + unicharutil \ xul \ xuldoc \ $(NULL) diff --git a/content/xul/templates/src/makefile.win b/content/xul/templates/src/makefile.win index 2f1045567af..164402a8faf 100644 --- a/content/xul/templates/src/makefile.win +++ b/content/xul/templates/src/makefile.win @@ -34,6 +34,7 @@ REQUIRES = xpcom \ rdf \ necko \ locale \ + unicharutil \ layout \ gfx \ layout_xul \ diff --git a/content/xul/templates/src/nsXULOutlinerBuilder.cpp b/content/xul/templates/src/nsXULOutlinerBuilder.cpp index 08228d35d8b..aaef6795b09 100644 --- a/content/xul/templates/src/nsXULOutlinerBuilder.cpp +++ b/content/xul/templates/src/nsXULOutlinerBuilder.cpp @@ -63,6 +63,7 @@ #include "nsXULContentUtils.h" #include "nsXULTemplateBuilder.h" #include "nsVoidArray.h" +#include "nsUnicharUtils.h" // For security check #include "nsIDocument.h" @@ -1821,7 +1822,9 @@ nsXULOutlinerBuilder::CompareMatches(nsTemplateMatch* aLeft, nsTemplateMatch* aR &result); } else - result = nsCRT::strcasecmp(lstr, rstr); + result = ::Compare(nsDependentString(lstr), + nsDependentString(rstr), + nsCaseInsensitiveStringComparator()); return result * mSortDirection; } diff --git a/content/xul/templates/src/nsXULSortService.cpp b/content/xul/templates/src/nsXULSortService.cpp index 0e16de74991..1c6f1b7da3e 100644 --- a/content/xul/templates/src/nsXULSortService.cpp +++ b/content/xul/templates/src/nsXULSortService.cpp @@ -66,13 +66,13 @@ #include "nsXULContentUtils.h" #include "nsString.h" #include "nsXPIDLString.h" +#include "nsUnicharUtils.h" #include "rdf.h" #include "nsRDFSort.h" #include "nsVoidArray.h" #include "nsQuickSort.h" #include "nsIAtom.h" #include "nsIXULSortService.h" -#include "nsString.h" #include "plhash.h" #include "plstr.h" #include "prlong.h" @@ -938,7 +938,9 @@ XULSortServiceImpl::CompareNodes(nsIRDFNode *cellNode1, PRBool isCollationKey1, v1,v2,&sortOrder); } if (NS_FAILED(rv)) { - sortOrder = nsCRT::strcasecmp(uni1, uni2); + sortOrder = Compare(nsDependentString(uni1), + nsDependentString(uni2), + nsCaseInsensitiveStringComparator()); } } else if (*uni1) sortOrder = -1; @@ -1383,7 +1385,7 @@ XULSortServiceImpl::GetNodeValue(nsIContent *node1, sortPtr sortInfo, PRBool fir cellPosVal1.Cut(0, sizeof(kRDFNameSpace_Seq_Prefix)-1); // hack: assume that its a number, so pad out a bit - nsAutoString zero; zero.AssignWithConversion("000000"); + nsAutoString zero; zero.Assign(NS_LITERAL_STRING("000000")); if (cellPosVal1.Length() < zero.Length()) { cellPosVal1.Insert(zero.get(), 0, PRInt32(zero.Length() - cellPosVal1.Length())); @@ -1554,7 +1556,7 @@ XULSortServiceImpl::GetNodeValue(contentSortInfo *info1, sortPtr sortInfo, PRBoo cellPosVal1.Cut(0, sizeof(kRDFNameSpace_Seq_Prefix)-1); // hack: assume that its a number, so pad out a bit - nsAutoString zero; zero.AssignWithConversion("000000"); + nsAutoString zero; zero.Assign(NS_LITERAL_STRING("000000")); if (cellPosVal1.Length() < zero.Length()) { cellPosVal1.Insert(zero.get(), 0, zero.Length() - cellPosVal1.Length()); @@ -2044,13 +2046,13 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort sortState->sortProperty = sortInfo.sortProperty; temp = sortResource; - temp.AppendWithConversion("?collation=true"); + temp.Append(NS_LITERAL_STRING("?collation=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertyColl)); if (NS_FAILED(rv)) return(rv); sortState->sortPropertyColl = sortInfo.sortPropertyColl; temp = sortResource; - temp.AppendWithConversion("?sort=true"); + temp.Append(NS_LITERAL_STRING("?sort=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertySort)); if (NS_FAILED(rv)) return(rv); sortState->sortPropertySort = sortInfo.sortPropertySort; @@ -2063,13 +2065,13 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort sortState->sortProperty2 = sortInfo.sortProperty2; temp = sortResource2; - temp.AppendWithConversion("?collation=true"); + temp.Append(NS_LITERAL_STRING("?collation=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertyColl2)); if (NS_FAILED(rv)) return(rv); sortState->sortPropertyColl2 = sortInfo.sortPropertyColl2; temp = sortResource2; - temp.AppendWithConversion("?sort=true"); + temp.Append(NS_LITERAL_STRING("?sort=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertySort2)); if (NS_FAILED(rv)) return(rv); sortState->sortPropertySort2 = sortInfo.sortPropertySort2; @@ -2400,12 +2402,12 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, nsAutoString temp; temp.Assign(sortResource); - temp.AppendWithConversion("?collation=true"); + temp.Append(NS_LITERAL_STRING("?collation=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertyColl)); if (NS_FAILED(rv)) return(rv); temp.Assign(sortResource); - temp.AppendWithConversion("?sort=true"); + temp.Append(NS_LITERAL_STRING("?sort=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertySort)); if (NS_FAILED(rv)) return(rv); @@ -2415,12 +2417,12 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, if (NS_FAILED(rv)) return(rv); temp = sortResource2; - temp.AppendWithConversion("?collation=true"); + temp.Append(NS_LITERAL_STRING("?collation=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertyColl2)); if (NS_FAILED(rv)) return(rv); temp = sortResource2; - temp.AppendWithConversion("?sort=true"); + temp.Append(NS_LITERAL_STRING("?sort=true")); rv = gRDFService->GetUnicodeResource(temp.get(), getter_AddRefs(sortInfo.sortPropertySort2)); if (NS_FAILED(rv)) return(rv); } diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp index 08228d35d8b..aaef6795b09 100644 --- a/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -63,6 +63,7 @@ #include "nsXULContentUtils.h" #include "nsXULTemplateBuilder.h" #include "nsVoidArray.h" +#include "nsUnicharUtils.h" // For security check #include "nsIDocument.h" @@ -1821,7 +1822,9 @@ nsXULOutlinerBuilder::CompareMatches(nsTemplateMatch* aLeft, nsTemplateMatch* aR &result); } else - result = nsCRT::strcasecmp(lstr, rstr); + result = ::Compare(nsDependentString(lstr), + nsDependentString(rstr), + nsCaseInsensitiveStringComparator()); return result * mSortDirection; } diff --git a/editor/libeditor/html/Makefile.in b/editor/libeditor/html/Makefile.in index ff3e84a8efc..5af151cabbc 100644 --- a/editor/libeditor/html/Makefile.in +++ b/editor/libeditor/html/Makefile.in @@ -34,6 +34,7 @@ REQUIRES = xpcom \ dom \ layout \ locale \ + unicharutil \ content \ txmgr \ htmlparser \ diff --git a/editor/libeditor/html/makefile.win b/editor/libeditor/html/makefile.win index 21859be687b..571212f318d 100644 --- a/editor/libeditor/html/makefile.win +++ b/editor/libeditor/html/makefile.win @@ -28,17 +28,12 @@ REQUIRES = xpcom \ dom \ layout \ locale \ + unicharutil \ content \ - uriloader \ txmgr \ htmlparser \ necko \ pref \ - view \ - webshell \ - timer \ - intl \ - docshell \ gfx \ widget \ $(NULL) diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index fa04c70dcf0..4f08892684f 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -75,6 +75,7 @@ #include "InsertTextTxn.h" #include "DeleteTextTxn.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" //const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE"; @@ -726,17 +727,17 @@ nsHTMLEditRules::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign) nsCOMPtr elem = do_QueryInterface(nodeToExamine); if (elem) { - nsAutoString typeAttrName; typeAttrName.AssignWithConversion("align"); + nsAutoString typeAttrName; typeAttrName.Assign(NS_LITERAL_STRING("align")); nsAutoString typeAttrVal; res = elem->GetAttribute(typeAttrName, typeAttrVal); typeAttrVal.ToLowerCase(); if (NS_SUCCEEDED(res) && typeAttrVal.Length()) { - if (typeAttrVal.EqualsWithConversion("center")) + if (typeAttrVal.Equals(NS_LITERAL_STRING("center"))) *aAlign = nsIHTMLEditor::eCenter; - else if (typeAttrVal.EqualsWithConversion("right")) + else if (typeAttrVal.Equals(NS_LITERAL_STRING("right"))) *aAlign = nsIHTMLEditor::eRight; - else if (typeAttrVal.EqualsWithConversion("justify")) + else if (typeAttrVal.Equals(NS_LITERAL_STRING("justify"))) *aAlign = nsIHTMLEditor::eJustify; else *aAlign = nsIHTMLEditor::eLeft; @@ -935,7 +936,7 @@ nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat) } // if this is the first node, we've found, remember it as the format - if (formatStr.EqualsWithConversion("x")) + if (formatStr.Equals(NS_LITERAL_STRING("x"))) formatStr = format; // else make sure it matches previously found format else if (format != formatStr) @@ -1069,7 +1070,7 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction, if (NS_FAILED(res)) return res; // dont put text in places that cant have it - nsAutoString textTag; textTag.AssignWithConversion("__moz_text"); + nsAutoString textTag; textTag.Assign(NS_LITERAL_STRING("__moz_text")); if (!mHTMLEditor->IsTextNode(selNode) && !mHTMLEditor->CanContainTag(selNode, textTag)) return NS_ERROR_FAILURE; @@ -1155,7 +1156,7 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction, NS_NAMED_LITERAL_STRING(tabStr, "\t"); NS_NAMED_LITERAL_STRING(newlineStr, "\n"); char specialChars[] = {'\t','\n',0}; - nsAutoString tabString; tabString.AssignWithConversion(" "); + nsAutoString tabString; tabString.Assign(NS_LITERAL_STRING(" ")); while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length())) { PRInt32 oldPos = pos; @@ -2141,9 +2142,9 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection, if (aItemType) itemType = *aItemType; else if (!Compare(*aListType,NS_LITERAL_STRING("dl"),nsCaseInsensitiveStringComparator())) - itemType.AssignWithConversion("dd"); + itemType.Assign(NS_LITERAL_STRING("dd")); else - itemType.AssignWithConversion("li"); + itemType.Assign(NS_LITERAL_STRING("li")); // convert the selection ranges into "promoted" selection ranges: // this basically just expands the range to include the immediate @@ -2488,7 +2489,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, { // for now we let WillMakeList handle this nsAutoString listType; - listType.AssignWithConversion("dl"); + listType.Assign(NS_LITERAL_STRING("dl")); return WillMakeList(aSelection, &listType, aEntireList, aCancel, aHandled, aItemType); } @@ -2532,7 +2533,7 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, // get selection location res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(parent), &offset); if (NS_FAILED(res)) return res; - if (tString.EqualsWithConversion("normal") || + if (tString.Equals(NS_LITERAL_STRING("normal")) || tString.IsEmpty() ) // we are removing blocks (going to "body text") { nsCOMPtr curBlock = parent; @@ -2544,15 +2545,15 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, nsAutoString curBlockTag; nsEditor::GetTagString(curBlock, curBlockTag); curBlockTag.ToLowerCase(); - if ((curBlockTag.EqualsWithConversion("pre")) || - (curBlockTag.EqualsWithConversion("p")) || - (curBlockTag.EqualsWithConversion("h1")) || - (curBlockTag.EqualsWithConversion("h2")) || - (curBlockTag.EqualsWithConversion("h3")) || - (curBlockTag.EqualsWithConversion("h4")) || - (curBlockTag.EqualsWithConversion("h5")) || - (curBlockTag.EqualsWithConversion("h6")) || - (curBlockTag.EqualsWithConversion("address"))) + if ((curBlockTag.Equals(NS_LITERAL_STRING("pre"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("p"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h1"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h2"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h3"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h4"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h5"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h6"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("address")))) { // if the first editable node after selection is a br, consume it. Otherwise // it gets pushed into a following block after the split, which is visually bad. @@ -2619,9 +2620,9 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, // Ok, now go through all the nodes and make the right kind of blocks, // or whatever is approriate. Wohoo! // Note: blockquote is handled a little differently - if (tString.EqualsWithConversion("blockquote")) + if (tString.Equals(NS_LITERAL_STRING("blockquote"))) res = MakeBlockquote(arrayOfNodes); - else if (tString.EqualsWithConversion("normal") || + else if (tString.Equals(NS_LITERAL_STRING("normal")) || tString.IsEmpty() ) res = RemoveBlockStyle(arrayOfNodes); else @@ -2715,7 +2716,7 @@ nsHTMLEditRules::WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool * { nsCOMPtr parent, theBlock; PRInt32 offset; - nsAutoString quoteType; quoteType.AssignWithConversion("blockquote"); + nsAutoString quoteType; quoteType.Assign(NS_LITERAL_STRING("blockquote")); // get selection location res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(parent), &offset); @@ -2801,7 +2802,7 @@ nsHTMLEditRules::WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool * // or if this node doesn't go in blockquote we used earlier. if (!curQuote) // || transitionList[i]) { - nsAutoString quoteType; quoteType.AssignWithConversion("blockquote"); + nsAutoString quoteType; quoteType.Assign(NS_LITERAL_STRING("blockquote")); res = SplitAsNeeded("eType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(quoteType, curParent, offset, getter_AddRefs(curQuote)); @@ -3343,7 +3344,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection, { PRInt32 offset; nsCOMPtr brNode, parent, theDiv, sib; - nsAutoString divType; divType.AssignWithConversion("div"); + nsAutoString divType; divType.Assign(NS_LITERAL_STRING("div")); res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(parent), &offset); if (NS_FAILED(res)) return res; res = SplitAsNeeded(&divType, address_of(parent), &offset); @@ -3410,7 +3411,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection, if (nsHTMLEditUtils::SupportsAlignAttr(curNode)) { nsCOMPtr divElem = do_QueryInterface(curNode); - nsAutoString attr; attr.AssignWithConversion("align"); + nsAutoString attr; attr.Assign(NS_LITERAL_STRING("align")); res = mHTMLEditor->SetAttribute(divElem, attr, *alignType); if (NS_FAILED(res)) return res; // clear out curDiv so that we don't put nodes after this one into it @@ -3443,7 +3444,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection, // or if this node doesn't go in div we used earlier. if (!curDiv || transitionList[i]) { - nsAutoString divType; divType.AssignWithConversion("div"); + nsAutoString divType; divType.Assign(NS_LITERAL_STRING("div")); res = SplitAsNeeded(&divType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(divType, curParent, offset, getter_AddRefs(curDiv)); @@ -3452,7 +3453,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection, mNewBlock = curDiv; // set up the alignment on the div nsCOMPtr divElem = do_QueryInterface(curDiv); - nsAutoString attr; attr.AssignWithConversion("align"); + nsAutoString attr; attr.Assign(NS_LITERAL_STRING("align")); res = mHTMLEditor->SetAttribute(divElem, attr, *alignType); if (NS_FAILED(res)) return res; // curDiv is now the correct thing to put curNode in @@ -3531,19 +3532,19 @@ nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString * // the cell already has a div containing all of it's content: just // act on this div. nsCOMPtr divElem = do_QueryInterface(firstChild); - nsAutoString attr; attr.AssignWithConversion("align"); + nsAutoString attr; attr.Assign(NS_LITERAL_STRING("align")); res = mHTMLEditor->SetAttribute(divElem, attr, *alignType); if (NS_FAILED(res)) return res; } else { // else we need to put in a div, set the alignment, and toss in all the children - nsAutoString divType; divType.AssignWithConversion("div"); + nsAutoString divType; divType.Assign(NS_LITERAL_STRING("div")); res = mHTMLEditor->CreateNode(divType, aNode, 0, getter_AddRefs(divNode)); if (NS_FAILED(res)) return res; // set up the alignment on the div nsCOMPtr divElem = do_QueryInterface(divNode); - nsAutoString attr; attr.AssignWithConversion("align"); + nsAutoString attr; attr.Assign(NS_LITERAL_STRING("align")); res = mHTMLEditor->SetAttribute(divElem, attr, *alignType); if (NS_FAILED(res)) return res; // tuck the children into the end of the active div @@ -5210,7 +5211,7 @@ nsHTMLEditRules::MakeBlockquote(nsISupportsArray *arrayOfNodes) // if no curBlock, make one if (!curBlock) { - nsAutoString quoteType; quoteType.AssignWithConversion("blockquote"); + nsAutoString quoteType; quoteType.Assign(NS_LITERAL_STRING("blockquote")); res = SplitAsNeeded("eType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(quoteType, curParent, offset, getter_AddRefs(curBlock)); @@ -5263,15 +5264,15 @@ nsHTMLEditRules::RemoveBlockStyle(nsISupportsArray *arrayOfNodes) curNodeTag.ToLowerCase(); // if curNode is a address, p, header, address, or pre, remove it - if ((curNodeTag.EqualsWithConversion("pre")) || - (curNodeTag.EqualsWithConversion("p")) || - (curNodeTag.EqualsWithConversion("h1")) || - (curNodeTag.EqualsWithConversion("h2")) || - (curNodeTag.EqualsWithConversion("h3")) || - (curNodeTag.EqualsWithConversion("h4")) || - (curNodeTag.EqualsWithConversion("h5")) || - (curNodeTag.EqualsWithConversion("h6")) || - (curNodeTag.EqualsWithConversion("address"))) + if ((curNodeTag.Equals(NS_LITERAL_STRING("pre"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("p"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h1"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h2"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h3"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h4"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h5"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h6"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("address")))) { // process any partial progress saved if (curBlock) @@ -5284,16 +5285,16 @@ nsHTMLEditRules::RemoveBlockStyle(nsISupportsArray *arrayOfNodes) res = mHTMLEditor->RemoveBlockContainer(curNode); if (NS_FAILED(res)) return res; } - else if ((curNodeTag.EqualsWithConversion("table")) || - (curNodeTag.EqualsWithConversion("tbody")) || - (curNodeTag.EqualsWithConversion("tr")) || - (curNodeTag.EqualsWithConversion("td")) || - (curNodeTag.EqualsWithConversion("ol")) || - (curNodeTag.EqualsWithConversion("ul")) || - (curNodeTag.EqualsWithConversion("dl")) || - (curNodeTag.EqualsWithConversion("li")) || - (curNodeTag.EqualsWithConversion("blockquote")) || - (curNodeTag.EqualsWithConversion("div"))) + else if ((curNodeTag.Equals(NS_LITERAL_STRING("table"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("tbody"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("tr"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("td"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("ol"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("ul"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("dl"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("li"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("blockquote"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("div")))) { // process any partial progress saved if (curBlock) @@ -5333,15 +5334,15 @@ nsHTMLEditRules::RemoveBlockStyle(nsISupportsArray *arrayOfNodes) curBlock = mHTMLEditor->GetBlockNodeParent(curNode); nsEditor::GetTagString(curBlock, curBlockTag); curBlockTag.ToLowerCase(); - if ((curBlockTag.EqualsWithConversion("pre")) || - (curBlockTag.EqualsWithConversion("p")) || - (curBlockTag.EqualsWithConversion("h1")) || - (curBlockTag.EqualsWithConversion("h2")) || - (curBlockTag.EqualsWithConversion("h3")) || - (curBlockTag.EqualsWithConversion("h4")) || - (curBlockTag.EqualsWithConversion("h5")) || - (curBlockTag.EqualsWithConversion("h6")) || - (curBlockTag.EqualsWithConversion("address"))) + if ((curBlockTag.Equals(NS_LITERAL_STRING("pre"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("p"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h1"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h2"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h3"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h4"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h5"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("h6"))) || + (curBlockTag.Equals(NS_LITERAL_STRING("address")))) { firstNode = curNode; lastNode = curNode; @@ -5415,30 +5416,30 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadab // it with a new block of correct type. // xxx floppy moose: pre cant hold everything the others can if (nsHTMLEditUtils::IsMozDiv(curNode) || - (curNodeTag.EqualsWithConversion("pre")) || - (curNodeTag.EqualsWithConversion("p")) || - (curNodeTag.EqualsWithConversion("h1")) || - (curNodeTag.EqualsWithConversion("h2")) || - (curNodeTag.EqualsWithConversion("h3")) || - (curNodeTag.EqualsWithConversion("h4")) || - (curNodeTag.EqualsWithConversion("h5")) || - (curNodeTag.EqualsWithConversion("h6")) || - (curNodeTag.EqualsWithConversion("address"))) + (curNodeTag.Equals(NS_LITERAL_STRING("pre"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("p"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h1"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h2"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h3"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h4"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h5"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("h6"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("address")))) { curBlock = 0; // forget any previous block used for previous inline nodes res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), *aBlockTag); if (NS_FAILED(res)) return res; } - else if ((curNodeTag.EqualsWithConversion("table")) || - (curNodeTag.EqualsWithConversion("tbody")) || - (curNodeTag.EqualsWithConversion("tr")) || - (curNodeTag.EqualsWithConversion("td")) || - (curNodeTag.EqualsWithConversion("ol")) || - (curNodeTag.EqualsWithConversion("ul")) || - (curNodeTag.EqualsWithConversion("dl")) || - (curNodeTag.EqualsWithConversion("li")) || - (curNodeTag.EqualsWithConversion("blockquote")) || - (curNodeTag.EqualsWithConversion("div"))) + else if ((curNodeTag.Equals(NS_LITERAL_STRING("table"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("tbody"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("tr"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("td"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("ol"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("ul"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("dl"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("li"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("blockquote"))) || + (curNodeTag.Equals(NS_LITERAL_STRING("div")))) { curBlock = 0; // forget any previous block used for previous inline nodes // recursion time @@ -5450,7 +5451,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadab } // if the node is a break, we honor it by putting further nodes in a new parent - else if (curNodeTag.EqualsWithConversion("br")) + else if (curNodeTag.Equals(NS_LITERAL_STRING("br"))) { curBlock = 0; // forget any previous block used for previous inline nodes res = mHTMLEditor->DeleteNode(curNode); diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 0b0c1499655..1cf848b21bb 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -39,6 +39,7 @@ #include "nsICaret.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsHTMLEditor.h" #include "nsHTMLEditRules.h" @@ -1141,8 +1142,8 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent) else if (nsHTMLEditUtils::IsListItem(blockParent)) { nsAutoString indentstr; - if (isShift) indentstr.AssignWithConversion("outdent"); - else indentstr.AssignWithConversion("indent"); + if (isShift) indentstr.Assign(NS_LITERAL_STRING("outdent")); + else indentstr.Assign(NS_LITERAL_STRING("indent")); res = Indent(indentstr); bHandled = PR_TRUE; } @@ -1305,7 +1306,7 @@ NS_IMETHODIMP nsHTMLEditor::CreateBRImpl(nsCOMPtr *aInOutParent, nsCOMPtr node = *aInOutParent; PRInt32 theOffset = *aInOutOffset; nsCOMPtr nodeAsText = do_QueryInterface(node); - nsAutoString brType; brType.AssignWithConversion("br"); + nsAutoString brType; brType.Assign(NS_LITERAL_STRING("br")); nsCOMPtr brNode; if (nodeAsText) { @@ -1541,7 +1542,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAReadableString& aSourceToInse // Do not use nsAutoRules -- rules code won't let us insert in // Use the head node as a parent and delete/insert directly nsCOMPtrnodeList; - nsAutoString headTag; headTag.AssignWithConversion("head"); + nsAutoString headTag; headTag.Assign(NS_LITERAL_STRING("head")); nsCOMPtr doc = do_QueryReferent(mDocWeak); if (!doc) return NS_ERROR_NOT_INITIALIZED; @@ -1966,7 +1967,7 @@ nsHTMLEditor::SetParagraphFormat(const nsAReadableString& aParagraphFormat) { nsAutoString tag; tag.Assign(aParagraphFormat); tag.ToLowerCase(); - if (tag.EqualsWithConversion("dd") || tag.EqualsWithConversion("dt")) + if (tag.Equals(NS_LITERAL_STRING("dd")) || tag.Equals(NS_LITERAL_STRING("dt"))) return MakeDefinitionItem(tag); else return InsertBasicBlock(tag); @@ -2114,7 +2115,7 @@ nsHTMLEditor::GetBackgroundColorState(PRBool *aMixed, nsAWritableString &aOutCol nsresult res = GetSelectedOrParentTableElement(*getter_AddRefs(element), tagName, selectedCount); if (NS_FAILED(res)) return res; - nsAutoString styleName; styleName.AssignWithConversion("bgcolor"); + nsAutoString styleName; styleName.Assign(NS_LITERAL_STRING("bgcolor")); while (element) { @@ -2256,7 +2257,7 @@ nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entire res = CreateNode(aListType, parent, offset, getter_AddRefs(newList)); if (NS_FAILED(res)) return res; // make a list item - nsAutoString tag; tag.AssignWithConversion("li"); + nsAutoString tag; tag.Assign(NS_LITERAL_STRING("li")); nsCOMPtr newItem; res = CreateNode(tag, newList, 0, getter_AddRefs(newItem)); if (NS_FAILED(res)) return res; @@ -2442,7 +2443,7 @@ nsHTMLEditor::Indent(const nsAReadableString& aIndent) if (!node) res = NS_ERROR_FAILURE; if (NS_FAILED(res)) return res; - nsAutoString inward; inward.AssignWithConversion("indent"); + nsAutoString inward; inward.Assign(NS_LITERAL_STRING("indent")); if (aIndent == inward) { if (isCollapsed) @@ -2559,10 +2560,10 @@ nsHTMLEditor::GetElementOrParentByTagName(const nsAReadableString& aTagName, nsI PRBool getNamedAnchor = IsNamedAnchorTag(TagName); if ( getLink || getNamedAnchor) { - TagName.AssignWithConversion("a"); + TagName.Assign(NS_LITERAL_STRING("a")); } - PRBool findTableCell = TagName.EqualsWithConversion("td"); - PRBool findList = TagName.EqualsWithConversion("list"); + PRBool findTableCell = TagName.Equals(NS_LITERAL_STRING("td")); + PRBool findList = TagName.Equals(NS_LITERAL_STRING("list")); // default is null - no element found *aReturn = nsnull; @@ -2898,7 +2899,7 @@ nsHTMLEditor::CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDO if (IsLinkTag(TagName) || IsNamedAnchorTag(TagName)) { - realTagName.AssignWithConversion("a"); + realTagName.Assign(NS_LITERAL_STRING("a")); } else { realTagName = TagName; } @@ -2920,17 +2921,17 @@ nsHTMLEditor::CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDO newElement->SetAttribute(NS_LITERAL_STRING("_moz_dirty"), nsAutoString()); // Set default values for new elements - if (TagName.EqualsWithConversion("hr")) + if (TagName.Equals(NS_LITERAL_STRING("hr"))) { // Note that we read the user's attributes for these from prefs (in InsertHLine JS) newElement->SetAttribute(NS_LITERAL_STRING("width"),NS_LITERAL_STRING("100%")); newElement->SetAttribute(NS_LITERAL_STRING("size"),NS_LITERAL_STRING("2")); - } else if (TagName.EqualsWithConversion("table")) + } else if (TagName.Equals(NS_LITERAL_STRING("table"))) { newElement->SetAttribute(NS_LITERAL_STRING("cellpadding"),NS_LITERAL_STRING("2")); newElement->SetAttribute(NS_LITERAL_STRING("cellspacing"),NS_LITERAL_STRING("2")); newElement->SetAttribute(NS_LITERAL_STRING("border"),NS_LITERAL_STRING("1")); - } else if (TagName.EqualsWithConversion("td")) + } else if (TagName.Equals(NS_LITERAL_STRING("td"))) { newElement->SetAttribute(NS_LITERAL_STRING("valign"),NS_LITERAL_STRING("top")); } @@ -3355,9 +3356,9 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList) tagName.ToLowerCase(); // See if it's an image or an embed - if (tagName.EqualsWithConversion("img") || tagName.EqualsWithConversion("embed")) + if (tagName.Equals(NS_LITERAL_STRING("img")) || tagName.Equals(NS_LITERAL_STRING("embed"))) (*aNodeList)->AppendElement(node); - else if (tagName.EqualsWithConversion("a")) + else if (tagName.Equals(NS_LITERAL_STRING("a"))) { // Only include links if they're links to file: URLs nsCOMPtr anchor (do_QueryInterface(content)); @@ -3391,7 +3392,7 @@ static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelection nsresult res = NS_OK; // Set selection around node nsCOMPtrnodeList; - nsAutoString headTag; headTag.AssignWithConversion("head"); + nsAutoString headTag; headTag.Assign(NS_LITERAL_STRING("head")); nsCOMPtr doc = do_QueryReferent(aDocWeak); if (!doc) return NS_ERROR_NOT_INITIALIZED; @@ -3677,9 +3678,9 @@ nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsARea /* // if parent is a pre, and child is not inline, say "no" - if ( aParentTag.EqualsWithConversion("pre") ) + if ( aParentTag.Equals(NS_LITERAL_STRING("pre")) ) { - if (aChildTag.EqualsWithConversion("__moz_text")) + if (aChildTag.Equals(NS_LITERAL_STRING("__moz_text"))) return PR_TRUE; PRInt32 childTagEnum, parentTagEnum; nsAutoString non_const_childTag(aChildTag); diff --git a/editor/libeditor/html/nsHTMLEditorStyle.cpp b/editor/libeditor/html/nsHTMLEditorStyle.cpp index 5747ffa07f1..944ec5d7139 100644 --- a/editor/libeditor/html/nsHTMLEditorStyle.cpp +++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp @@ -38,6 +38,7 @@ #include "nsICaret.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsHTMLEditor.h" #include "nsHTMLEditRules.h" @@ -645,7 +646,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1, attrName->ToString(attrString); // if it's a special _moz... attribute, keep going attrString.Left(tmp,4); - if (tmp.EqualsWithConversion("_moz")) continue; + if (tmp.Equals(NS_LITERAL_STRING("_moz"))) continue; // otherwise, it's another attribute, so count it realCount1++; // and compare it to element2's attributes @@ -664,7 +665,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1, attrName->ToString(attrString); // if it's a special _moz... attribute, keep going attrString.Left(tmp,4); - if (tmp.EqualsWithConversion("_moz")) continue; + if (tmp.Equals(NS_LITERAL_STRING("_moz"))) continue; // otherwise, it's another attribute, so count it realCount2++; } @@ -1444,8 +1445,8 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange, nsresult res = NS_OK; nsCOMPtr tmp; nsAutoString tag; - if (aSizeChange == 1) tag.AssignWithConversion("big"); - else tag.AssignWithConversion("small"); + if (aSizeChange == 1) tag.Assign(NS_LITERAL_STRING("big")); + else tag.Assign(NS_LITERAL_STRING("small")); // is this node a text node? if (IsTextNode(aNode)) @@ -1500,12 +1501,12 @@ nsHTMLEditor::GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace) if (!aMixed) return NS_ERROR_FAILURE; *aMixed = PR_TRUE; - //outFace.AssignWithConversion(""); + //outFace.Assign(NS_LITERAL_STRING("")); outFace.SetLength(0); nsresult res; nsAutoString faceStr; - faceStr.AssignWithConversion("face"); + faceStr.Assign(NS_LITERAL_STRING("face")); PRBool first, any, all; @@ -1545,7 +1546,7 @@ nsHTMLEditor::GetFontColorState(PRBool *aMixed, nsAWritableString &aOutColor) aOutColor.SetLength(0); nsresult res; - nsAutoString colorStr; colorStr.AssignWithConversion("color"); + nsAutoString colorStr; colorStr.Assign(NS_LITERAL_STRING("color")); PRBool first, any, all; res = GetInlinePropertyBase(nsIEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor); diff --git a/extensions/wallet/src/makefile.win b/extensions/wallet/src/makefile.win index de262d2ad39..a5db48314d2 100644 --- a/extensions/wallet/src/makefile.win +++ b/extensions/wallet/src/makefile.win @@ -33,10 +33,10 @@ REQUIRES = xpcom \ docshell \ appshell \ intl \ + unicharutil \ windowwatcher \ gfx \ content \ - raptor \ $(NULL) include <$(DEPTH)/config/config.mak> @@ -67,23 +67,12 @@ EXPORTS= $(NULL) LLIBS=$(LLIBS) $(LIBNSPR) \ $(DIST)\lib\xpcom.lib \ + $(DIST)\lib\unicharutil_s.lib \ !ifndef NECKO $(DIST)\lib\netlib.lib \ !endif $(NULL) -LINCS= \ - -I$(PUBLIC)\raptor \ - -I$(PUBLIC)\xpcom \ - -I$(PUBLIC)\dom \ - -I$(PUBLIC)\js \ - -I$(PUBLIC)\security\ - -I$(PUBLIC)\pref \ - -I$(PUBLIC)\wallet \ - -I$(PUBLIC)\intl \ - -I$(PUBLIC)\locale \ - $(NULL) - LCFLAGS = \ $(LCFLAGS) \ $(DEFINES) \ diff --git a/extensions/wallet/src/wallet.cpp b/extensions/wallet/src/wallet.cpp index 5cbcc08ac85..282f3f10022 100644 --- a/extensions/wallet/src/wallet.cpp +++ b/extensions/wallet/src/wallet.cpp @@ -48,6 +48,7 @@ #include "nsNetUtil.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsIServiceManager.h" #include "nsIDocument.h" @@ -1779,7 +1780,7 @@ static PRInt32 FieldToValue( if (!failed && wallet_ReadFromList(sublistPtr->item, value2, dummy, wallet_SchemaToValue_list, PR_TRUE, index3)) { if (value.Length()>0) { - value.AppendWithConversion(" "); + value.Append(NS_LITERAL_STRING(" ")); } /* found an unused value for the multi-rhs item */ @@ -1813,7 +1814,7 @@ static PRInt32 FieldToValue( nsAutoString temp; wallet_GetHostFile(wallet_lastUrl, temp); - temp.AppendWithConversion(":"); + temp.Append(NS_LITERAL_STRING(":")); temp.Append(field); if (wallet_ReadFromList(temp, value, itemList, wallet_SchemaToValue_list, PR_TRUE, index2)) { @@ -2107,7 +2108,7 @@ wallet_ResolvePositionalSchema(nsIDOMNode* elementNode, nsString& schema) { nsAutoString fractionStringWithoutDenominator; /* of form 2/ meaning 2nd in any-length set */ fractionString.SetLength(0); fractionString.AppendInt(numerator); - fractionString.AppendWithConversion("/"); + fractionString.Append(NS_LITERAL_STRING("/")); fractionStringWithoutDenominator.Assign(fractionString); fractionString.AppendInt(denominator); @@ -2203,7 +2204,7 @@ wallet_ResolveStateSchema(nsIDOMNode* elementNode, nsString& schema) { /* test to see if we obtained the catch-all (*) state. * Note: the catch-all must be the last entry in the list */ - if (sublistPtr->item.EqualsWithConversion("*")) { + if (sublistPtr->item.Equals(NS_LITERAL_STRING("*"))) { sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j+1)); schema = sublistPtr->item; return; @@ -2237,7 +2238,7 @@ wallet_ResolveStateSchema(nsIDOMNode* elementNode, nsString& schema) { PRInt32 count2 = LIST_COUNT(mapElementPtr->itemList); for (PRInt32 j=0; jitemList->ElementAt(j)); - if (sublistPtr->item.EqualsWithConversion("*")) { + if (sublistPtr->item.Equals(NS_LITERAL_STRING("*"))) { previousElementNode = localElementNode; sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j+1)); schema = sublistPtr->item; @@ -2378,7 +2379,7 @@ wallet_GetPrefills( if (schema.Length() == 0) { nsCOMPtr element = do_QueryInterface(elementNode); if (element) { - nsAutoString vcard; vcard.AssignWithConversion("VCARD_NAME"); + nsAutoString vcard; vcard.Assign(NS_LITERAL_STRING("VCARD_NAME")); nsAutoString vcardValue; result = element->GetAttribute(vcard, vcardValue); if (NS_OK == result) { @@ -2754,7 +2755,7 @@ wallet_OKToCapture(char* urlName, nsIDOMWindowInternal* window) { /* see if this url is already on list of url's for which we don't want to capture */ wallet_InitializeURLList(); nsVoidArray* dummy; - nsAutoString value; value.AssignWithConversion("nn"); + nsAutoString value; value.Assign(NS_LITERAL_STRING("nn")); if (wallet_ReadFromList(url, value, dummy, wallet_URL_list, PR_FALSE)) { if (value.CharAt(NO_CAPTURE) == 'y') { return PR_FALSE; @@ -2852,7 +2853,7 @@ wallet_Capture(nsIDocument* doc, const nsString& field, const nsString& value, c nsAutoString concat_param; wallet_GetHostFile(wallet_lastUrl, concat_param); - concat_param.AppendWithConversion(":"); + concat_param.Append(NS_LITERAL_STRING(":")); concat_param.Append(field); while(wallet_ReadFromList(concat_param, oldValue, dummy, wallet_SchemaToValue_list, PR_TRUE, index)) { @@ -2878,7 +2879,7 @@ wallet_Capture(nsIDocument* doc, const nsString& field, const nsString& value, c lastIndex = index; wallet_GetHostFile(wallet_lastUrl, concat_param); - concat_param.AppendWithConversion(":"); + concat_param.Append(NS_LITERAL_STRING(":")); concat_param.Append(field); } @@ -2886,7 +2887,7 @@ wallet_Capture(nsIDocument* doc, const nsString& field, const nsString& value, c dummy = 0; nsAutoString hostFileField; wallet_GetHostFile(wallet_lastUrl, hostFileField); - hostFileField.AppendWithConversion(":"); + hostFileField.Append(NS_LITERAL_STRING(":")); hostFileField.Append(field); if (wallet_WriteToList(hostFileField, value, dummy, wallet_SchemaToValue_list, PR_TRUE)) { @@ -2916,11 +2917,11 @@ WLLT_GetNopreviewListForViewer(nsString& aNopreviewList) url = NS_STATIC_CAST(wallet_MapElement*, wallet_URL_list->ElementAt(i)); if (url->item2.CharAt(NO_PREVIEW) == 'y') { buffer.AppendWithConversion(BREAK); - buffer.AppendWithConversion("\n"); + buffer.Append(NS_LITERAL_STRING("\n")); nopreviewNum++; } } @@ -2940,11 +2941,11 @@ WLLT_GetNocaptureListForViewer(nsString& aNocaptureList) url = NS_STATIC_CAST(wallet_MapElement*, wallet_URL_list->ElementAt(i)); if (url->item2.CharAt(NO_CAPTURE) == 'y') { buffer.AppendWithConversion(BREAK); - buffer.AppendWithConversion("\n"); + buffer.Append(NS_LITERAL_STRING("\n")); nocaptureNum++; } } @@ -2974,7 +2975,7 @@ WLLT_PostEdit(const nsString& walletList) tail = temp; /* return if OK button was not pressed */ - if (!head.EqualsWithConversion("OK")) { + if (!head.Equals(NS_LITERAL_STRING("OK"))) { return; } @@ -3183,10 +3184,10 @@ WLLT_PrefillReturn(const nsString& results) wallet_DecodeVerticalBars(urlName); /* add url to url list if user doesn't want to preview this page in the future */ - if (skip.EqualsWithConversion("true")) { + if (skip.Equals(NS_LITERAL_STRING("true"))) { nsAutoString url = nsAutoString(urlName); nsVoidArray* dummy; - nsAutoString value; value.AssignWithConversion("nn"); + nsAutoString value; value.Assign(NS_LITERAL_STRING("nn")); wallet_ReadFromList(url, value, dummy, wallet_URL_list, PR_FALSE); value.SetCharAt('y', NO_PREVIEW); if (wallet_WriteToList(url, value, dummy, wallet_URL_list, PR_FALSE, DUP_OVERWRITE)) { @@ -3473,7 +3474,7 @@ WLLT_Prefill(nsIPresShell* shell, PRBool quick, nsIDOMWindowInternal* win) if (!quick) { wallet_InitializeURLList(); nsVoidArray* dummy; - nsAutoString value; value.AssignWithConversion("nn"); + nsAutoString value; value.Assign(NS_LITERAL_STRING("nn")); if (urlName.Length() != 0) { wallet_ReadFromList(urlName, value, dummy, wallet_URL_list, PR_FALSE); noPreview = (value.CharAt(NO_PREVIEW) == 'y'); @@ -3533,7 +3534,7 @@ wallet_CaptureInputElement(nsIDOMNode* elementNode, nsIDocument* doc) { nsAutoString schema; nsCOMPtr element = do_QueryInterface(elementNode); if (element) { - nsAutoString vcardName; vcardName.AssignWithConversion("VCARD_NAME"); + nsAutoString vcardName; vcardName.Assign(NS_LITERAL_STRING("VCARD_NAME")); nsAutoString vcardValue; result = element->GetAttribute(vcardName, vcardValue); if (NS_OK == result) { @@ -3603,7 +3604,7 @@ wallet_CaptureSelectElement(nsIDOMNode* elementNode, nsIDocument* doc) { nsAutoString schema; nsCOMPtr element = do_QueryInterface(elementNode); if (element) { - nsAutoString vcardName; vcardName.AssignWithConversion("VCARD_NAME"); + nsAutoString vcardName; vcardName.Assign(NS_LITERAL_STRING("VCARD_NAME")); nsAutoString vcardValue; result = element->GetAttribute(vcardName, vcardValue); if (NS_OK == result) { @@ -3781,7 +3782,7 @@ wallet_IsFromCartman(nsIURI* aURL) { #ifdef AutoCapture PRIVATE PRBool wallet_IsNewValue(nsIDOMNode* elementNode, nsString valueOnForm) { - if (valueOnForm.EqualsWithConversion("")) { + if (valueOnForm.Equals(NS_LITERAL_STRING(""))) { return PR_FALSE; } nsIDOMHTMLInputElement* inputElement; diff --git a/intl/chardet/src/Makefile.in b/intl/chardet/src/Makefile.in index cd6a4e5bbbf..9590ee34f35 100644 --- a/intl/chardet/src/Makefile.in +++ b/intl/chardet/src/Makefile.in @@ -34,6 +34,7 @@ MODULE_NAME = nsCharDetModule REQUIRES = xpcom \ string \ uconv \ + unicharutil \ webshell \ docshell \ htmlparser \ diff --git a/intl/chardet/src/makefile.win b/intl/chardet/src/makefile.win index 7e4e0e16ab1..6fc17d4a905 100644 --- a/intl/chardet/src/makefile.win +++ b/intl/chardet/src/makefile.win @@ -65,6 +65,7 @@ MODULE_NAME=nsCharDetModule REQUIRES = xpcom \ string \ uconv \ + unicharutil \ webshell \ docshell \ htmlparser \ @@ -77,6 +78,7 @@ REQUIRES = xpcom \ $(NULL) LLIBS= \ + $(DIST)\lib\unicharutil_s.lib \ $(DIST)\lib\xpcom.lib \ $(LIBNSPR) diff --git a/intl/chardet/src/nsMetaCharsetObserver.cpp b/intl/chardet/src/nsMetaCharsetObserver.cpp index fa25ff20c3d..4489bd3b678 100644 --- a/intl/chardet/src/nsMetaCharsetObserver.cpp +++ b/intl/chardet/src/nsMetaCharsetObserver.cpp @@ -54,6 +54,7 @@ #include "nsIParserService.h" #include "nsParserCIID.h" #include "nsMetaCharsetCID.h" +#include "nsUnicharUtils.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kParserServiceCID, NS_PARSERSERVICE_CID); @@ -104,7 +105,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify( const PRUnichar* nameArray[], const PRUnichar* valueArray[]) { - if(0 != nsCRT::strcasecmp(aTag, NS_LITERAL_STRING("META").get())) + + if(0 != Compare(nsDependentString(aTag), NS_LITERAL_STRING("META"), nsCaseInsensitiveStringComparator())) return NS_ERROR_ILLEGAL_VALUE; else return Notify(aDocumentID, numOfAttributes, nameArray, valueArray); @@ -145,7 +147,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify( const PRUnichar* aTag, const nsStringArray* keys, const nsStringArray* values) { - if(0 != nsCRT::strcasecmp(aTag, NS_LITERAL_STRING("META").get())) + if(0 != Compare(nsDependentString(aTag), NS_LITERAL_STRING("META"), + nsCaseInsensitiveStringComparator())) return NS_ERROR_ILLEGAL_VALUE; else return Notify(aWebShell, aChannel, keys, values); @@ -212,12 +215,18 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify( while(IS_SPACE_CHARS(*keyStr)) keyStr++; - if(0 == nsCRT::strncasecmp(keyStr, NS_LITERAL_STRING("HTTP-EQUIV").get(), 10)) - httpEquivValue=((values->StringAt(i))->get()); - else if(0 == nsCRT::strncasecmp(keyStr, NS_LITERAL_STRING("content").get(), 7)) - contentValue=(values->StringAt(i))->get(); - else if (0 == nsCRT::strncasecmp(keyStr, NS_LITERAL_STRING("charset").get(), 7)) - charsetValue =(values->StringAt(i))->get(); + if(0 == Compare(nsDependentString(keyStr, 10), + NS_LITERAL_STRING("HTTP-EQUIV"), + nsCaseInsensitiveStringComparator())) + httpEquivValue = values->StringAt(i)->get(); + else if(0 == Compare(nsDependentString(keyStr, 7), + NS_LITERAL_STRING("content"), + nsCaseInsensitiveStringComparator())) + contentValue = values->StringAt(i)->get(); + else if (0 == Compare(nsDependentString(keyStr, 7), + NS_LITERAL_STRING("charset"), + nsCaseInsensitiveStringComparator())) + charsetValue = values->StringAt(i)->get(); } NS_NAMED_LITERAL_STRING(contenttype, "Content-Type"); NS_NAMED_LITERAL_STRING(texthtml, "text/html"); @@ -225,25 +234,33 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify( if(nsnull == httpEquivValue || nsnull == contentValue) return NS_OK; - while(IS_SPACE_CHARS(*httpEquivValue)) + while(IS_SPACE_CHARS(*httpEquivValue)) httpEquivValue++; - while(IS_SPACE_CHARS(*contentValue)) + while(IS_SPACE_CHARS(*contentValue)) contentValue++; if( - ((0==nsCRT::strcasecmp(httpEquivValue,contenttype.get())) || + // first try unquoted strings + ((0==Compare(nsDependentString(httpEquivValue,contenttype.Length()), + contenttype, + nsCaseInsensitiveStringComparator())) || + // now try "quoted" or 'quoted' strings (( (httpEquivValue[0]=='\'') || (httpEquivValue[0]=='\"') ) && - (0==nsCRT::strncasecmp(httpEquivValue+1, - contenttype.get(), - contenttype.Length())) + (0==Compare(nsDependentString(httpEquivValue+1, contenttype.Length()), + contenttype, + nsCaseInsensitiveStringComparator())) )) && - ((0==nsCRT::strncasecmp(contentValue,texthtml.get(),texthtml.Length())) || + // first try unquoted strings + ((0==Compare(nsDependentString(contentValue,texthtml.Length()), + texthtml, + nsCaseInsensitiveStringComparator())) || + // now try "quoted" or 'quoted' strings (((contentValue[0]=='\'') || (contentValue[0]=='\"'))&& - (0==nsCRT::strncasecmp(contentValue+1, - texthtml.get(), - texthtml.Length())) + (0==Compare(nsDependentString(contentValue+1, texthtml.Length()), + texthtml, + nsCaseInsensitiveStringComparator())) )) ) { @@ -335,7 +352,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag( // e.g. PRInt32 numOfAttributes = keys->Count(); if ((numOfAttributes >= 3) && - (0 == nsCRT::strcasecmp((keys->StringAt(0))->get(), NS_LITERAL_STRING("charset").get()))) + (0 == Compare(*keys->StringAt(0), NS_LITERAL_STRING("charset"), + nsCaseInsensitiveStringComparator()))) { nsAutoString srcStr((values->StringAt(numOfAttributes-2))->get()); PRInt32 err; diff --git a/intl/chardet/src/nsXMLEncodingObserver.cpp b/intl/chardet/src/nsXMLEncodingObserver.cpp index b818804e6fc..e570384b6a2 100644 --- a/intl/chardet/src/nsXMLEncodingObserver.cpp +++ b/intl/chardet/src/nsXMLEncodingObserver.cpp @@ -51,6 +51,7 @@ #include "nsObserverBase.h" #include "nsWeakReference.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -93,7 +94,8 @@ NS_IMETHODIMP nsXMLEncodingObserver::Notify( const PRUnichar* nameArray[], const PRUnichar* valueArray[]) { - if(0 != nsCRT::strcasecmp(aTag, NS_LITERAL_STRING("?XML").get())) + if(0 != Compare(nsDependentString(aTag), NS_LITERAL_STRING("?XML"), + nsCaseInsensitiveStringComparator())) return NS_ERROR_ILLEGAL_VALUE; else return Notify(aDocumentID, numOfAttributes, nameArray, valueArray); @@ -141,7 +143,8 @@ NS_IMETHODIMP nsXMLEncodingObserver::Notify( } else if(0==nsCRT::strcmp(nameArray[i], NS_LITERAL_STRING("charsetSource").get())) { bGotCurrentCharsetSource = PR_TRUE; charsetSourceStr = valueArray[i]; - } else if(0==nsCRT::strcasecmp(nameArray[i], NS_LITERAL_STRING("encoding").get())) { + } else if(0==Compare(nsDependentString(nameArray[i]), NS_LITERAL_STRING("encoding"), + nsCaseInsensitiveStringComparator())) { bGotEncoding = PR_TRUE; encoding = valueArray[i]; } diff --git a/intl/uconv/src/Makefile.in b/intl/uconv/src/Makefile.in index 53786116e33..bcea485e28a 100644 --- a/intl/uconv/src/Makefile.in +++ b/intl/uconv/src/Makefile.in @@ -39,6 +39,7 @@ REQUIRES = xpcom \ intl \ locale \ chardet \ + unicharutil \ necko \ $(NULL) diff --git a/intl/uconv/src/makefile.win b/intl/uconv/src/makefile.win index 92809164849..cedb2c518eb 100644 --- a/intl/uconv/src/makefile.win +++ b/intl/uconv/src/makefile.win @@ -26,8 +26,8 @@ REQUIRES = xpcom \ intl \ locale \ chardet \ + unicharutil \ necko \ - pref \ $(NULL) include <$(DEPTH)/config/config.mak> @@ -99,6 +99,7 @@ EXPORTS= \ LLIBS= \ $(DIST)\lib\xpcom.lib \ + $(DIST)\lib\unicharutil_s.lib \ $(LIBNSPR) LCFLAGS = \ diff --git a/intl/uconv/src/nsCharsetAliasImp.cpp b/intl/uconv/src/nsCharsetAliasImp.cpp index dc274159de5..8b2cc5a3084 100644 --- a/intl/uconv/src/nsCharsetAliasImp.cpp +++ b/intl/uconv/src/nsCharsetAliasImp.cpp @@ -48,7 +48,7 @@ #include "nsUConvDll.h" #include "nsReadableUtils.h" - +#include "nsUnicharUtils.h" #include "nsURLProperties.h" //============================================================== class nsCharsetAlias2 : public nsICharsetAlias diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index b38ebad5b11..e8e42d133c5 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -63,6 +63,7 @@ #include "nsIFrame.h" #include "nsString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsVoidArray.h" #include "nsIUnicharInputStream.h" #include "nsHTMLIIDs.h" @@ -186,6 +187,10 @@ PRBool AtomKey_base::Equals(const nsHashKey* aKey) const return PRBool (((AtomKey_base*)aKey)->mAtom == mAtom); } + // first try case-sensitive match + if (((AtomKey_base*)aKey)->mAtom == mAtom) + return PR_TRUE; + #ifdef DEBUG_HASH DebugHashCount(PR_FALSE); #endif @@ -197,7 +202,9 @@ PRBool AtomKey_base::Equals(const nsHashKey* aKey) const const PRUnichar *theirStr = nsnull; theirAtom->GetUnicode(&theirStr); - return nsCRT::strcasecmp(myStr, theirStr) == 0; + return Compare(nsDependentString(myStr), + nsDependentString(theirStr), + nsCaseInsensitiveStringComparator()) == 0; } @@ -3367,7 +3374,9 @@ static PRBool ValueIncludes(const nsString& aValueList, const nsString& aValue, } } else { - if (!nsCRT::strcasecmp(value, start)) { + if (!Compare(nsDependentString(value), + nsDependentString(start), + nsCaseInsensitiveStringComparator())) { return PR_TRUE; } } diff --git a/layout/xul/base/src/nsMenuBarFrame.cpp b/layout/xul/base/src/nsMenuBarFrame.cpp index bdbe2e1829a..c1c52119981 100644 --- a/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/layout/xul/base/src/nsMenuBarFrame.cpp @@ -57,6 +57,7 @@ #include "nsIFrameManager.h" #include "nsMenuPopupFrame.h" #include "nsGUIEvent.h" +#include "nsUnicharUtils.h" // @@ -699,7 +700,7 @@ nsMenuBarFrame::IsDisabled(nsIContent* aContent) { nsString disabled; aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled); - if (disabled.EqualsWithConversion("true")) + if (disabled.Equals(NS_LITERAL_STRING("true"))) return PR_TRUE; return PR_FALSE; } diff --git a/mailnews/addrbook/src/Makefile.in b/mailnews/addrbook/src/Makefile.in index 84da172cf2c..0a861d49b0a 100644 --- a/mailnews/addrbook/src/Makefile.in +++ b/mailnews/addrbook/src/Makefile.in @@ -44,6 +44,7 @@ REQUIRES = xpcom \ pref \ necko \ locale \ + unicharutil \ webshell \ uconv \ msgbase \ diff --git a/mailnews/addrbook/src/makefile.win b/mailnews/addrbook/src/makefile.win index 20f43898b8d..9f08e9315c3 100644 --- a/mailnews/addrbook/src/makefile.win +++ b/mailnews/addrbook/src/makefile.win @@ -34,14 +34,14 @@ REQUIRES = xpcom \ pref \ necko \ locale \ - webshell \ uconv \ + unicharutil \ + webshell \ msgbase \ msgbaseutil \ mime \ msgcompo \ appcomps \ - raptor \ gfx \ content \ mozldap \ diff --git a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp index c878574d387..23d6d2f917f 100644 --- a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp +++ b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp @@ -45,6 +45,7 @@ #include "nsIAbCard.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsMsgBaseCID.h" #include "nsMsgI18N.h" #include "nsIMsgIdentity.h" @@ -107,7 +108,8 @@ PRBool nsAbAutoCompleteSession::ItsADuplicate(PRUnichar* fullAddrStr, nsIAutoCom rv = resultItem->GetValue(valueStr); if (NS_SUCCEEDED(rv) && !valueStr.IsEmpty()) { - if (nsCRT::strcasecmp(fullAddrStr, valueStr.get())==0) + if (Compare(nsDependentString(fullAddrStr), valueStr, + nsCaseInsensitiveStringComparator())==0) return PR_TRUE; } } @@ -139,7 +141,7 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr, return; nsAutoString aStr(pDisplayNameStr); - aStr.AppendWithConversion('@'); + aStr.Append(PRUnichar('@')); aStr += mDefaultDomain; fullAddrStr = ToNewUnicode(aStr); } @@ -184,9 +186,9 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr, // check this so we do not get a bogus entry "someName <>" if (pStr && pStr[0] != 0) { nsAutoString aStr(pDisplayNameStr); - aStr.AppendWithConversion(" <"); + aStr.Append(NS_LITERAL_STRING(" <")); aStr += pStr; - aStr.AppendWithConversion(">"); + aStr.Append(NS_LITERAL_STRING(">")); fullAddrStr = ToNewUnicode(aStr); } else @@ -249,8 +251,25 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr, PR_Free(fullAddrStr); } -PRBool nsAbAutoCompleteSession::CheckEntry(nsAbAutoCompleteSearchString* searchStr, const PRUnichar* nickName, const PRUnichar* displayName, - const PRUnichar* firstName, const PRUnichar* lastName, const PRUnichar* emailAddress, MatchType* matchType) +static PRBool CommonPrefix(const PRUnichar *aString, const PRUnichar *aSubstr, PRInt32 aSubstrLen) { + PRUint32 len = MinInt(aSubstrLen, nsCRT::strlen(aString)); + + if (len == 0) return PR_FALSE; + + return (Compare(nsDependentString(aString, len), + nsDependentString(aSubstr, len), + nsCaseInsensitiveStringComparator()) == 0); +} + + +PRBool +nsAbAutoCompleteSession::CheckEntry(nsAbAutoCompleteSearchString* searchStr, + const PRUnichar* nickName, + const PRUnichar* displayName, + const PRUnichar* firstName, + const PRUnichar* lastName, + const PRUnichar* emailAddress, + MatchType* matchType) { const PRUnichar * fullString; PRUint32 fullStringLen; @@ -267,70 +286,80 @@ PRBool nsAbAutoCompleteSession::CheckEntry(nsAbAutoCompleteSearchString* searchS } // First check for a Nickname exact match - if (nickName && nsCRT::strcasecmp(fullString, nickName) == 0) + if (nickName && Compare(nsDependentString(fullString), + nsDependentString(nickName), + nsCaseInsensitiveStringComparator()) == 0) { *matchType = NICKNAME_EXACT_MATCH; return PR_TRUE; } // Then check for a display Name exact match - if (displayName && nsCRT::strcasecmp(fullString, displayName) == 0) + if (displayName && Compare(nsDependentString(fullString), + nsDependentString(displayName), + nsCaseInsensitiveStringComparator()) == 0) { *matchType = NAME_EXACT_MATCH; return PR_TRUE; } // Then check for a fisrt Name exact match - if (firstName && nsCRT::strcasecmp(fullString, firstName) == 0) + if (firstName && Compare(nsDependentString(fullString), + nsDependentString(firstName), + nsCaseInsensitiveStringComparator()) == 0) { *matchType = NAME_EXACT_MATCH; return PR_TRUE; } // Then check for a last Name exact match - if (lastName && nsCRT::strcasecmp(fullString, lastName) == 0) + if (lastName && Compare(nsDependentString(fullString), + nsDependentString(lastName), + nsCaseInsensitiveStringComparator()) == 0) { *matchType = NAME_EXACT_MATCH; return PR_TRUE; } // Then check for a Email exact match - if (emailAddress && nsCRT::strcasecmp(fullString, emailAddress) == 0) + if (emailAddress && Compare(nsDependentString(fullString), + nsDependentString(emailAddress), + nsCaseInsensitiveStringComparator()) == 0) { *matchType = EMAIL_EXACT_MATCH; return PR_TRUE; } // Then check for a NickName partial match - if (nickName && nsCRT::strncasecmp(fullString, nickName, fullStringLen) == 0) + if (nickName && CommonPrefix(nickName, fullString, fullStringLen)) { *matchType = NICKNAME_MATCH; return PR_TRUE; } // Then check for a display Name partial match - if (displayName && nsCRT::strncasecmp(fullString, displayName, fullStringLen) == 0) + if (displayName && CommonPrefix(displayName, fullString, fullStringLen)) { *matchType = NAME_MATCH; return PR_TRUE; } // Then check for a first Name partial match - if (firstName && nsCRT::strncasecmp(fullString, firstName, fullStringLen) == 0) + if (firstName && CommonPrefix(firstName, fullString, fullStringLen)) { *matchType = NAME_MATCH; return PR_TRUE; } // Then check for a last Name partial match - if (lastName && nsCRT::strncasecmp(fullString, lastName, fullStringLen) == 0) + if (lastName && CommonPrefix(lastName, fullString, fullStringLen)) { *matchType = NAME_MATCH; return PR_TRUE; } // Then check for a Email partial match - if (emailAddress && nsCRT::strncasecmp(fullString, emailAddress, fullStringLen) == 0) + if (emailAddress && CommonPrefix(emailAddress, fullString, fullStringLen)) { *matchType = EMAIL_MATCH; return PR_TRUE; @@ -339,11 +368,13 @@ PRBool nsAbAutoCompleteSession::CheckEntry(nsAbAutoCompleteSearchString* searchS //If we have a muti-part search string, look for a partial match with first name and last name or reverse if (searchStr->mFirstPartLen && searchStr->mSecondPartLen) { - if (((firstName && nsCRT::strncasecmp(searchStr->mFirstPart, firstName, searchStr->mFirstPartLen) == 0) && - (lastName && nsCRT::strncasecmp(searchStr->mSecondPart, lastName, searchStr->mSecondPartLen) == 0)) || - ((lastName && nsCRT::strncasecmp(searchStr->mFirstPart, lastName, searchStr->mFirstPartLen) == 0) && - (firstName && nsCRT::strncasecmp(searchStr->mSecondPart, firstName, searchStr->mSecondPartLen) == 0)) - ) + if (((firstName && CommonPrefix(firstName, searchStr->mFirstPart, searchStr->mFirstPartLen)) && + (lastName && CommonPrefix(lastName, searchStr->mSecondPart, searchStr->mSecondPartLen))) || + + + ((lastName && CommonPrefix(lastName, searchStr->mFirstPart, searchStr->mFirstPartLen)) && + (firstName && CommonPrefix(firstName, searchStr->mSecondPart, searchStr->mSecondPartLen))) + ) { *matchType = NAME_MATCH; return PR_TRUE; @@ -516,7 +547,8 @@ nsresult nsAbAutoCompleteSession::SearchPreviousResults(nsAbAutoCompleteSearchSt return NS_ERROR_FAILURE; PRUint32 prevSearchStrLen = nsCRT::strlen(prevSearchString); - if (searchStr->mFullStringLen < prevSearchStrLen || nsCRT::strncasecmp(searchStr->mFullString, prevSearchString, prevSearchStrLen != 0)) + if (searchStr->mFullStringLen < prevSearchStrLen || + CommonPrefix(searchStr->mFullString, prevSearchString, prevSearchStrLen)) return NS_ERROR_ABORT; nsCOMPtr array; diff --git a/mailnews/base/src/Makefile.in b/mailnews/base/src/Makefile.in index a726a048270..90c50bf974f 100644 --- a/mailnews/base/src/Makefile.in +++ b/mailnews/base/src/Makefile.in @@ -47,6 +47,7 @@ REQUIRES = xpcom \ content \ mailnews \ locale \ + unicharutil \ msgbaseutil \ webshell \ txmgr \ diff --git a/mailnews/base/src/makefile.win b/mailnews/base/src/makefile.win index 83fea87ce69..28017e0f1e1 100644 --- a/mailnews/base/src/makefile.win +++ b/mailnews/base/src/makefile.win @@ -28,6 +28,8 @@ REQUIRES = xpcom \ appshell \ appcomps \ uconv \ + locale \ + unicharutil \ intl \ htmlparser \ widget \ @@ -36,7 +38,6 @@ REQUIRES = xpcom \ editor \ layout \ mailnews \ - locale \ msgbaseutil \ webshell \ txmgr \ diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index d464dd294fb..693a02e0407 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -54,6 +54,7 @@ #include "plstr.h" #include "nsString.h" #include "nsXPIDLString.h" +#include "nsUnicharUtils.h" #include "nscore.h" #include "nsCRT.h" // for nsCRT::strtok #include "prprf.h" @@ -64,7 +65,6 @@ #include "nsIURL.h" #include "nsNetCID.h" #include "nsISmtpService.h" -#include "nsString.h" #include "nsIMsgBiffManager.h" #include "nsIObserverService.h" #include "nsIMsgMailSession.h" @@ -238,7 +238,7 @@ NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const PRUnicha nsAutoString shutdownString; shutdownString.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); nsAutoString quitApplicationString; - quitApplicationString.AssignWithConversion("quit-application"); + quitApplicationString.Assign(NS_LITERAL_STRING("quit-application")); nsAutoString offlineStatusChangedString(NS_LITERAL_STRING("network:offline-status-changed")); NS_NAMED_LITERAL_STRING(sessionLogoutString, "session-logout"); NS_NAMED_LITERAL_STRING(beforeProfileChangeString, "profile-before-change"); @@ -1041,7 +1041,7 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa nsCOMPtrinboxFolder = do_QueryInterface(aSupport); nsXPIDLString folderName; inboxFolder->GetName(getter_Copies(folderName)); - if (folderName && nsCRT::strcasecmp(folderName, NS_LITERAL_STRING("INBOX").get()) ==0) + if (folderName && Compare(folderName, NS_LITERAL_STRING("INBOX"), nsCaseInsensitiveStringComparator()) ==0) { rv1 = inboxFolder->Compact(urlListener, nsnull /* msgwindow */); if (NS_SUCCEEDED(rv1)) diff --git a/mailnews/base/util/makefile.win b/mailnews/base/util/makefile.win index c65bd7198eb..8b26836753c 100644 --- a/mailnews/base/util/makefile.win +++ b/mailnews/base/util/makefile.win @@ -118,6 +118,7 @@ CPP_OBJS= \ LLIBS= \ $(DIST)\lib\xpcom.lib \ $(DIST)\lib\rdfutil_s.lib \ + $(DIST)\lib\unicharutil_s.lib \ $(LIBNSPR) \ $(NULL) diff --git a/mailnews/base/util/nsMsgFolder.cpp b/mailnews/base/util/nsMsgFolder.cpp index ead92d4a2db..f4c2ba0085d 100644 --- a/mailnews/base/util/nsMsgFolder.cpp +++ b/mailnews/base/util/nsMsgFolder.cpp @@ -44,6 +44,7 @@ #include "nsIServiceManager.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsCOMPtr.h" #include "nsAutoLock.h" #include "nsMemory.h" @@ -221,17 +222,17 @@ nsMsgFolder::initializeStrings() getter_AddRefs(bundle)); NS_ENSURE_SUCCESS(rv, rv); - bundle->GetStringFromName(NS_ConvertASCIItoUCS2("inboxFolderName").get(), + bundle->GetStringFromName(NS_LITERAL_STRING("inboxFolderName").get(), &kInboxName); - bundle->GetStringFromName(NS_ConvertASCIItoUCS2("trashFolderName").get(), + bundle->GetStringFromName(NS_LITERAL_STRING("trashFolderName").get(), &kTrashName); - bundle->GetStringFromName(NS_ConvertASCIItoUCS2("sentFolderName").get(), + bundle->GetStringFromName(NS_LITERAL_STRING("sentFolderName").get(), &kSentName); - bundle->GetStringFromName(NS_ConvertASCIItoUCS2("draftsFolderName").get(), + bundle->GetStringFromName(NS_LITERAL_STRING("draftsFolderName").get(), &kDraftsName); - bundle->GetStringFromName(NS_ConvertASCIItoUCS2("templatesFolderName").get(), + bundle->GetStringFromName(NS_LITERAL_STRING("templatesFolderName").get(), &kTemplatesName); - bundle->GetStringFromName(NS_ConvertASCIItoUCS2("unsentFolderName").get(), + bundle->GetStringFromName(NS_LITERAL_STRING("unsentFolderName").get(), &kUnsentName); return NS_OK; } @@ -916,7 +917,8 @@ NS_IMETHODIMP nsMsgFolder::GetChildNamed(const char *name, nsISupports ** aChild rv = folder->GetName(getter_Copies(folderName)); // case-insensitive compare is probably LCD across OS filesystems - if (NS_SUCCEEDED(rv) && nsCRT::strcasecmp(folderName, uniName.get()) == 0) + if (NS_SUCCEEDED(rv) && Compare(folderName, uniName, + nsCaseInsensitiveStringComparator()) == 0) { *aChild = folder; NS_ADDREF(*aChild); @@ -2071,7 +2073,7 @@ NS_IMETHODIMP nsMsgFolder::GetNewMessagesNotificationDescription(PRUnichar * *aD // put this test here because we don't want to just put "folder name on" // in case the above failed if (!(mFlags & MSG_FOLDER_FLAG_INBOX)) - description.AppendWithConversion(" on "); + description.Append(NS_LITERAL_STRING(" on ")); description.Append(serverName); } } @@ -2455,7 +2457,7 @@ nsresult nsMsgFolder::NotifyFolderEvent(nsIAtom* aEvent) nsresult nsGetMailFolderSeparator(nsString& result) { - result.AssignWithConversion(".sbd"); + result.Assign(NS_LITERAL_STRING(".sbd")); return NS_OK; } diff --git a/mailnews/compose/src/Makefile.in b/mailnews/compose/src/Makefile.in index 8988e4ac8c0..564e2ab8836 100644 --- a/mailnews/compose/src/Makefile.in +++ b/mailnews/compose/src/Makefile.in @@ -41,6 +41,7 @@ REQUIRES = xpcom \ pref \ intl \ locale \ + unicharutil \ layout \ content \ msgbaseutil \ diff --git a/mailnews/compose/src/makefile.win b/mailnews/compose/src/makefile.win index 01062182c5b..445251991a6 100644 --- a/mailnews/compose/src/makefile.win +++ b/mailnews/compose/src/makefile.win @@ -34,6 +34,8 @@ REQUIRES = xpcom \ pref \ intl \ locale \ + uconv \ + unicharutil \ layout \ msgbaseutil \ msgdb \ @@ -41,7 +43,6 @@ REQUIRES = xpcom \ appshell \ msgimap \ msgnews \ - uconv \ docshell \ webshell \ addrbook \ @@ -55,7 +56,6 @@ REQUIRES = xpcom \ mimetype \ windowwatcher \ content \ - raptor \ $(NULL) include <$(DEPTH)\config\config.mak> diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 545d9aa773d..4d8a26eced6 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -106,6 +106,7 @@ #include "nsIMsgImapMailFolder.h" #include "nsImapCore.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsNetUtil.h" #include "nsMsgSimulateError.h" @@ -1039,7 +1040,7 @@ nsresult nsMsgCompose::SetEditor(nsIEditorShell * aEditor) // Now, lets init the editor here! // Just get a blank editor started... - m_editor->LoadUrl(NS_ConvertASCIItoUCS2("about:blank").get()); + m_editor->LoadUrl(NS_LITERAL_STRING("about:blank").get()); return NS_OK; } @@ -1783,7 +1784,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIRequest *request, if (NS_SUCCEEDED(rv) && numWritten > 0) { PRUnichar *u = nsnull; - nsAutoString fmt; fmt.AssignWithConversion("%s"); + nsAutoString fmt; fmt.Assign(NS_LITERAL_STRING("%s")); u = nsTextFormatter::smprintf(fmt.get(), newBuf); // this converts UTF-8 to UCS-2 if (u) @@ -2102,7 +2103,9 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS { if (fieldsFCC && *fieldsFCC) { - if (nsCRT::strcasecmp(fieldsFCC, "nocopy://") == 0) + if (Compare(nsDependentString(fieldsFCC), + NS_LITERAL_STRING("nocopy://"), + nsCaseInsensitiveStringComparator()) == 0) { compose->NotifyStateListeners(eComposeProcessDone, NS_OK); if (progress) @@ -3577,7 +3580,7 @@ nsresult nsMsgCompose::TagConvertible(nsIDOMNode *node, PRInt32 *_retval) if (NS_SUCCEEDED(node->GetAttributes(getter_AddRefs(pAttributes))) && pAttributes) { - nsAutoString typeName; typeName.AssignWithConversion("type"); + nsAutoString typeName; typeName.Assign(NS_LITERAL_STRING("type")); if (NS_SUCCEEDED(pAttributes->GetNamedItem(typeName, getter_AddRefs(pItem))) && pItem) @@ -3612,7 +3615,7 @@ nsresult nsMsgCompose::TagConvertible(nsIDOMNode *node, PRInt32 *_retval) && pAttributes) { nsAutoString className; - className.AssignWithConversion("class"); + className.Assign(NS_LITERAL_STRING("class")); if (NS_SUCCEEDED(pAttributes->GetNamedItem(className, getter_AddRefs(pItem))) && pItem) @@ -3638,7 +3641,7 @@ nsresult nsMsgCompose::TagConvertible(nsIDOMNode *node, PRInt32 *_retval) if (NS_SUCCEEDED(node->GetAttributes(getter_AddRefs(pAttributes))) && pAttributes) { - nsAutoString hrefName; hrefName.AssignWithConversion("href"); + nsAutoString hrefName; hrefName.Assign(NS_LITERAL_STRING("href")); if (NS_SUCCEEDED(pAttributes->GetNamedItem(hrefName, getter_AddRefs(pItem))) && pItem) @@ -3677,7 +3680,7 @@ nsresult nsMsgCompose::TagConvertible(nsIDOMNode *node, PRInt32 *_retval) && pAttributes) { nsAutoString styleName; - styleName.AssignWithConversion("style"); + styleName.Assign(NS_LITERAL_STRING("style")); if (NS_SUCCEEDED(pAttributes->GetNamedItem(styleName, getter_AddRefs(pItem))) && pItem) @@ -3792,7 +3795,7 @@ nsresult nsMsgCompose::SetSignature(nsIMsgIdentity *identity) { nsAutoString attributeName; nsAutoString attributeValue; - attributeName.AssignWithConversion("class"); + attributeName.Assign(NS_LITERAL_STRING("class")); rv = element->GetAttribute(attributeName, attributeValue); if (NS_SUCCEEDED(rv)) @@ -3813,7 +3816,7 @@ nsresult nsMsgCompose::SetSignature(nsIMsgIdentity *identity) if (tempNode) { tempNode->GetLocalName(tagLocalName); - if (tagLocalName.EqualsWithConversion("BR")) + if (tagLocalName.Equals(NS_LITERAL_STRING("BR"))) editor->DeleteNode(tempNode); } editor->EndTransaction(); @@ -3834,7 +3837,7 @@ nsresult nsMsgCompose::SetSignature(nsIMsgIdentity *identity) switch (searchState) { case 0: - if (nodeType == nsIDOMNode::ELEMENT_NODE && tagLocalName.EqualsWithConversion("BR")) + if (nodeType == nsIDOMNode::ELEMENT_NODE && tagLocalName.Equals(NS_LITERAL_STRING("BR"))) searchState = 1; break; @@ -3844,11 +3847,11 @@ nsresult nsMsgCompose::SetSignature(nsIMsgIdentity *identity) { nsString nodeValue; node->GetNodeValue(nodeValue); - if (nodeValue.EqualsWithConversion("-- ")) + if (nodeValue.Equals(NS_LITERAL_STRING("-- "))) searchState = 2; } else - if (nodeType == nsIDOMNode::ELEMENT_NODE && tagLocalName.EqualsWithConversion("BR")) + if (nodeType == nsIDOMNode::ELEMENT_NODE && tagLocalName.Equals(NS_LITERAL_STRING("BR"))) { searchState = 1; break; @@ -3856,7 +3859,7 @@ nsresult nsMsgCompose::SetSignature(nsIMsgIdentity *identity) break; case 2: - if (nodeType == nsIDOMNode::ELEMENT_NODE && tagLocalName.EqualsWithConversion("BR")) + if (nodeType == nsIDOMNode::ELEMENT_NODE && tagLocalName.Equals(NS_LITERAL_STRING("BR"))) searchState = 3; else searchState = 0; diff --git a/mailnews/imap/src/Makefile.in b/mailnews/imap/src/Makefile.in index 05da528f3b8..e4092572c2c 100644 --- a/mailnews/imap/src/Makefile.in +++ b/mailnews/imap/src/Makefile.in @@ -39,6 +39,7 @@ REQUIRES = xpcom \ necko \ msgdb \ uconv \ + unicharutil \ mime \ pref \ intl \ diff --git a/mailnews/imap/src/makefile.win b/mailnews/imap/src/makefile.win index 4798bdca992..5978a9fd0fb 100644 --- a/mailnews/imap/src/makefile.win +++ b/mailnews/imap/src/makefile.win @@ -32,6 +32,7 @@ REQUIRES = xpcom \ necko \ msgdb \ uconv \ + unicharutil \ mime \ pref \ intl \ diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 8ef330f16a4..d634d1aff7e 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -78,6 +78,7 @@ #include "nsSpecialSystemDirectory.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsIImapFlagAndUidState.h" #include "nsIMessenger.h" #include "nsIMsgSearchAdapter.h" @@ -677,12 +678,12 @@ NS_IMETHODIMP nsImapMailFolder::CreateSubfolder(const PRUnichar* folderName, nsI nsresult rv = NS_ERROR_NULL_POINTER; if (!folderName) return rv; - if ( nsCRT::strcasecmp(folderName,"Trash") == 0 ) // Trash , a special folder + if ( Compare(nsDependentString(folderName),NS_LITERAL_STRING("Trash"),nsCaseInsensitiveStringComparator()) == 0 ) // Trash , a special folder { AlertSpecialFolderExists(msgWindow); return NS_MSG_FOLDER_EXISTS; } - else if ( nsCRT::strcasecmp(folderName,"Inbox") == 0 ) // Inbox, a special folder + else if ( Compare(nsDependentString(folderName),NS_LITERAL_STRING("Inbox"),nsCaseInsensitiveStringComparator()) == 0 ) // Inbox, a special folder { AlertSpecialFolderExists(msgWindow); return NS_MSG_FOLDER_EXISTS; @@ -3684,7 +3685,7 @@ PRBool nsImapMailFolder::ShowDeletedMessages() { nsXPIDLString folderName; GetName(getter_Copies(folderName)); - if (!nsCRT::strncasecmp(folderName, convertedName, nsCRT::strlen(convertedName))) + if (!Compare(folderName, convertedName, nsCaseInsensitiveStringComparator())) showDeleted = PR_TRUE; } } diff --git a/mailnews/local/src/Makefile.in b/mailnews/local/src/Makefile.in index 0af4426ec48..1d1143c701e 100644 --- a/mailnews/local/src/Makefile.in +++ b/mailnews/local/src/Makefile.in @@ -39,6 +39,7 @@ REQUIRES = xpcom \ msgdb \ rdf \ intl \ + unicharutil \ mime \ dom \ rdfutil \ diff --git a/mailnews/local/src/makefile.win b/mailnews/local/src/makefile.win index 3100855c67b..c08fc7f6b3c 100644 --- a/mailnews/local/src/makefile.win +++ b/mailnews/local/src/makefile.win @@ -40,6 +40,7 @@ REQUIRES = xpcom \ msgimap \ chrome \ nkcache \ + unicharutil \ $(NULL) include <$(DEPTH)\config\config.mak> diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index 48af4c62003..2343e4bbc17 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -76,6 +76,7 @@ #include "nsMsgLocalCID.h" #include "nsString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsLocalFolderSummarySpec.h" #include "nsMsgUtils.h" #include "nsICopyMsgStreamListener.h" @@ -296,7 +297,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::AddSubfolder(nsAutoString *name, else if (name->EqualsIgnoreCase(nsAutoString(kTrashName))) flags |= MSG_FOLDER_FLAG_TRASH; else if (name->EqualsIgnoreCase(nsAutoString(kUnsentName)) - || name->CompareWithConversion("Outbox", PR_TRUE) == 0) + || Compare(*name, NS_LITERAL_STRING("Outbox"), nsCaseInsensitiveStringComparator()) == 0) flags |= MSG_FOLDER_FLAG_QUEUE; #if 0 // the logic for this has been moved into @@ -767,21 +768,20 @@ nsresult nsMsgLocalMailFolder::CheckIfFolderExists(const PRUnichar *folderName, nsFileSpec &path, nsIMsgWindow *msgWindow) { nsresult rv = NS_OK; - char *leafName=nsnull; + nsAutoString leafName; for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++) { nsFileSpec currentFolderPath = dir.Spec(); - leafName = currentFolderPath.GetLeafName(); - if (leafName && nsCRT::strcasecmp(folderName,leafName) == 0) + currentFolderPath.GetLeafName(leafName); + if (!leafName.IsEmpty() && + Compare(nsDependentString(folderName), leafName, + nsCaseInsensitiveStringComparator()) == 0) { if (msgWindow) AlertFolderExists(msgWindow); - PL_strfree(leafName); return NS_MSG_FOLDER_EXISTS; } } - if (leafName) - PL_strfree(leafName); return rv; } diff --git a/mailnews/mime/src/Makefile.in b/mailnews/mime/src/Makefile.in index 84ee82f8a79..b1174e70f05 100644 --- a/mailnews/mime/src/Makefile.in +++ b/mailnews/mime/src/Makefile.in @@ -37,6 +37,7 @@ REQUIRES = xpcom \ js \ necko \ uconv \ + unicharutil \ msgcompose \ editor \ dom \ diff --git a/mailnews/mime/src/makefile.win b/mailnews/mime/src/makefile.win index c6b46a2fcc8..c487cd08092 100644 --- a/mailnews/mime/src/makefile.win +++ b/mailnews/mime/src/makefile.win @@ -28,6 +28,8 @@ REQUIRES = xpcom \ js \ necko \ uconv \ + chardet \ + unicharutil \ msgcompo \ editor \ dom \ @@ -36,7 +38,6 @@ REQUIRES = xpcom \ exthandler \ mailnews \ msgdb \ - chardet \ caps \ mimetype \ uriloader \ diff --git a/mailnews/mime/src/nsStreamConverter.cpp b/mailnews/mime/src/nsStreamConverter.cpp index d64d6233336..11f98e6881c 100644 --- a/mailnews/mime/src/nsStreamConverter.cpp +++ b/mailnews/mime/src/nsStreamConverter.cpp @@ -52,6 +52,7 @@ #include "nsIURL.h" #include "nsString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" #include "nsMemory.h" @@ -448,7 +449,7 @@ nsStreamConverter::DetermineOutputFormat(const char *url, nsMimeOutputType *aNe // or text/html emitter. // check the desired output content type that was passed into AsyncConvertData. - if (mDesiredOutputType && nsCRT::strcasecmp(mDesiredOutputType, "application/vnd.mozilla.xul+xml") == 0) + if (mDesiredOutputType && Compare(nsDependentString(mDesiredOutputType), NS_LITERAL_STRING("application/vnd.mozilla.xul+xml"),nsCaseInsensitiveStringComparator()) == 0) { CRTFREEIF(mOutputFormat); mOutputFormat = nsCRT::strdup("application/vnd.mozilla.xul+xml"); diff --git a/rdf/base/src/Makefile.in b/rdf/base/src/Makefile.in index 845b6df970a..b85d7408b19 100644 --- a/rdf/base/src/Makefile.in +++ b/rdf/base/src/Makefile.in @@ -37,6 +37,7 @@ REQUIRES = xpcom \ content \ htmlparser \ js \ + unicharutil \ $(NULL) CPPSRCS = \ diff --git a/rdf/base/src/makefile.win b/rdf/base/src/makefile.win index 30600decfeb..7ca352c9ef6 100644 --- a/rdf/base/src/makefile.win +++ b/rdf/base/src/makefile.win @@ -26,6 +26,7 @@ LCFLAGS= MODULE=rdf LIBRARY_NAME=rdfbase_s REQUIRES = xpcom \ + unicharutil \ string \ rdfutil \ htmlparser \ diff --git a/rdf/base/src/rdfutil.cpp b/rdf/base/src/rdfutil.cpp index 0fb57266b70..0d6f6d79995 100644 --- a/rdf/base/src/rdfutil.cpp +++ b/rdf/base/src/rdfutil.cpp @@ -63,6 +63,7 @@ #include "nsRDFCID.h" #include "nsString.h" #include "nsXPIDLString.h" +#include "nsUnicharUtils.h" #include "prtime.h" #include "rdfutil.h" diff --git a/xpfe/components/urlbarhistory/src/Makefile.in b/xpfe/components/urlbarhistory/src/Makefile.in index 85b5c1a0670..364c3e102eb 100644 --- a/xpfe/components/urlbarhistory/src/Makefile.in +++ b/xpfe/components/urlbarhistory/src/Makefile.in @@ -33,6 +33,7 @@ REQUIRES = xpcom \ rdf \ pref \ necko \ + unicharutil \ $(NULL) CPPSRCS = nsUrlbarHistory.cpp diff --git a/xpfe/components/urlbarhistory/src/makefile.win b/xpfe/components/urlbarhistory/src/makefile.win index 4cbdfe30c0c..4a22b126272 100644 --- a/xpfe/components/urlbarhistory/src/makefile.win +++ b/xpfe/components/urlbarhistory/src/makefile.win @@ -26,6 +26,7 @@ REQUIRES = xpcom \ pref \ necko \ appcomps \ + unicharutil \ $(NULL) LIBRARY_NAME=urlbarhistory_s diff --git a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp index 65bf83bf9f4..0dfc0e2b150 100644 --- a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp +++ b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp @@ -24,6 +24,7 @@ // Local Includes #include "nsString.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" #include "nsUrlbarHistory.h" // Helper Classes @@ -332,7 +333,10 @@ nsUrlbarHistory::SearchPreviousResults(const PRUnichar *searchStr, nsIAutoComple return NS_ERROR_FAILURE; PRUint32 prevSearchStrLen = nsCRT::strlen(prevSearchString); - if (searchStrLen < prevSearchStrLen || nsCRT::strncasecmp(searchStr, prevSearchString, prevSearchStrLen != 0)) + if (searchStrLen < prevSearchStrLen || + Compare(nsDependentString(searchStr), + nsDependentString(prevSearchString, prevSearchStrLen), + nsCaseInsensitiveStringComparator())!= 0) return NS_ERROR_ABORT; nsCOMPtr array; @@ -361,7 +365,9 @@ nsUrlbarHistory::SearchPreviousResults(const PRUnichar *searchStr, nsIAutoComple if (itemValue.IsEmpty()) continue; - if (nsCRT::strncasecmp(searchStr, itemValue.get(), searchStrLen) == 0) + if (Compare(nsDependentString(searchStr, searchStrLen), + itemValue, + nsCaseInsensitiveStringComparator()) == 0) continue; } @@ -617,7 +623,8 @@ nsUrlbarHistory::CheckItemAvailability(const PRUnichar * aItem, nsIAutoCompleteR resultItem->GetValue(itemValue); // Using nsIURI to do comparisons didn't quite work out. // So use nsCRT methods - if (nsCRT::strcasecmp(itemValue.get(), aItem) == 0) + if (Compare(itemValue, nsDependentString(aItem), + nsCaseInsensitiveStringComparator()) == 0) { //printf("In CheckItemAvailability. Item already found\n"); *aResult = PR_TRUE;