From e3b541a10c7b3e74b109ea41d23270e80d85e8d7 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sun, 10 Feb 2002 15:49:46 +0000 Subject: [PATCH] Relanding the Compare --> Equals conversion. a=mcafee --- content/base/src/nsDocument.cpp | 4 +- content/base/src/nsGenericElement.cpp | 24 +- content/base/src/nsHTMLValue.cpp | 5 +- .../html/content/src/nsHTMLAnchorElement.cpp | 4 +- .../html/content/src/nsHTMLButtonElement.cpp | 2 +- content/html/style/src/nsCSSDeclaration.cpp | 2 +- content/html/style/src/nsCSSLoader.cpp | 5 +- content/html/style/src/nsCSSStruct.cpp | 2 +- content/html/style/src/nsCSSStyleSheet.cpp | 26 +- content/html/style/src/nsHTMLAttributes.cpp | 2 +- content/shared/src/nsHTMLValue.cpp | 5 +- content/xbl/src/nsXBLPrototypeHandler.cpp | 16 +- content/xul/document/src/nsXULContentSink.cpp | 9 +- .../base/ChangeCSSInlineStyleTxn.cpp | 10 +- editor/libeditor/html/nsHTMLCSSUtils.cpp | 6 +- editor/libeditor/html/nsHTMLEditRules.cpp | 4 +- editor/libeditor/html/nsHTMLEditor.cpp | 19 +- editor/libeditor/html/nsHTMLEditorStyle.cpp | 8 +- editor/libeditor/text/nsAOLCiter.cpp | 2 +- .../webBrowser/nsDocShellTreeOwner.cpp | 11 +- extensions/wallet/src/nsWalletService.cpp | 9 +- extensions/wallet/src/wallet.cpp | 23 +- htmlparser/src/CNavDTD.cpp | 6 +- htmlparser/src/COtherDTD.cpp | 6 +- htmlparser/src/nsDTDUtils.cpp | 10 +- htmlparser/src/nsHTMLContentSinkStream.cpp | 1344 ----------------- htmlparser/src/nsViewSourceHTML.cpp | 2 +- intl/chardet/src/nsMetaCharsetObserver.cpp | 50 +- intl/chardet/src/nsXMLEncodingObserver.cpp | 8 +- intl/locale/src/unix/nsCollationUnix.cpp | 4 +- intl/uconv/src/nsCharsetAliasImp.cpp | 2 +- layout/generic/nsObjectFrame.cpp | 8 +- layout/html/base/src/nsObjectFrame.cpp | 8 +- layout/style/nsCSSDeclaration.cpp | 2 +- layout/style/nsCSSLoader.cpp | 5 +- layout/style/nsCSSStruct.cpp | 2 +- layout/style/nsCSSStyleSheet.cpp | 26 +- layout/xul/base/src/nsMenuBarFrame.cpp | 3 +- mailnews/absync/src/nsAbSync.cpp | 18 +- .../addrbook/src/nsAbAutoCompleteSession.cpp | 42 +- mailnews/base/src/nsMsgAccountManager.cpp | 4 +- mailnews/base/util/nsMsgFolder.cpp | 5 +- mailnews/base/util/nsMsgI18N.cpp | 3 +- mailnews/compose/src/nsMsgCompose.cpp | 8 +- mailnews/compose/src/nsMsgSend.cpp | 3 +- mailnews/imap/src/nsImapMailFolder.cpp | 9 +- .../import/eudora/src/nsEudoraCompose.cpp | 2 +- mailnews/import/eudora/src/nsEudoraMac.cpp | 2 +- mailnews/import/eudora/src/nsEudoraWin32.cpp | 9 +- mailnews/import/oexpress/nsOEScanBoxes.cpp | 2 +- mailnews/import/outlook/src/MapiApi.cpp | 13 +- mailnews/local/src/nsLocalMailFolder.cpp | 4 +- modules/libjar/nsJAR.cpp | 12 +- netwerk/cache/src/nsCacheEntry.cpp | 2 +- .../ftp/src/nsFtpConnectionThread.cpp | 2 +- .../converters/mozTXTToHTMLConv.cpp | 14 +- .../converters/nsUnknownDecoder.cpp | 6 +- parser/htmlparser/src/CNavDTD.cpp | 6 +- parser/htmlparser/src/COtherDTD.cpp | 6 +- parser/htmlparser/src/nsDTDUtils.cpp | 10 +- .../src/nsHTMLContentSinkStream.cpp | 1344 ----------------- parser/htmlparser/src/nsViewSourceHTML.cpp | 2 +- rdf/base/src/rdfutil.cpp | 4 +- .../exthandler/nsExternalHelperAppService.cpp | 5 +- .../exthandler/unix/nsOSHelperAppService.cpp | 32 +- .../bookmarks/src/nsBookmarksService.cpp | 13 +- .../related/src/nsRelatedLinksHandler.cpp | 13 +- .../urlbarhistory/src/nsUrlbarHistory.cpp | 16 +- 68 files changed, 311 insertions(+), 2984 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 77f31ec279c..bb95d366c88 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -1071,8 +1071,8 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAReadableString& aData) sheet->GetTitle(title); if (!title.IsEmpty()) { // if sheet has title PRBool disabled = (aData.IsEmpty() || - Compare(title, aData, - nsCaseInsensitiveStringComparator()) != 0); + !title.Equals(aData, + nsCaseInsensitiveStringComparator())); SetStyleSheetDisabledState(sheet, disabled); } } diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index b69cb929477..ea527ab844b 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -839,23 +839,23 @@ nsGenericElement::InternalIsSupported(const nsAReadableString& aFeature, *aReturn = PR_FALSE; nsAutoString feature(aFeature); - if (!Compare(feature, NS_LITERAL_STRING("XML"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("HTML"), nsCaseInsensitiveStringComparator())) { + if (feature.Equals(NS_LITERAL_STRING("XML"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("HTML"), nsCaseInsensitiveStringComparator())) { if (aVersion.IsEmpty() || aVersion.Equals(NS_LITERAL_STRING("1.0")) || aVersion.Equals(NS_LITERAL_STRING("2.0"))) { *aReturn = PR_TRUE; } - } else if (!Compare(feature, NS_LITERAL_STRING("Views"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("StyleSheets"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("CSS"), nsCaseInsensitiveStringComparator()) || -// !Compare(feature, NS_LITERAL_STRING("CSS2"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("Events"), nsCaseInsensitiveStringComparator()) || -// !Compare(feature, NS_LITERAL_STRING("UIEvents"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("MouseEvents"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("MouseScrollEvents"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("HTMLEvents"), nsCaseInsensitiveStringComparator()) || - !Compare(feature, NS_LITERAL_STRING("Range"), nsCaseInsensitiveStringComparator())) { + } else if (feature.Equals(NS_LITERAL_STRING("Views"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("StyleSheets"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("CSS"), nsCaseInsensitiveStringComparator()) || +// feature.Equals(NS_LITERAL_STRING("CSS2"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("Events"), nsCaseInsensitiveStringComparator()) || +// feature.Equals(NS_LITERAL_STRING("UIEvents"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("MouseEvents"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("MouseScrollEvents"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("HTMLEvents"), nsCaseInsensitiveStringComparator()) || + feature.Equals(NS_LITERAL_STRING("Range"), nsCaseInsensitiveStringComparator())) { if (aVersion.IsEmpty() || aVersion.Equals(NS_LITERAL_STRING("2.0"))) { *aReturn = PR_TRUE; } diff --git a/content/base/src/nsHTMLValue.cpp b/content/base/src/nsHTMLValue.cpp index 48e1b765f2f..3ed6e80a11f 100644 --- a/content/base/src/nsHTMLValue.cpp +++ b/content/base/src/nsHTMLValue.cpp @@ -172,9 +172,8 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const } } else if (nsnull != aOther.mValue.mString) { - return 0 == Compare(nsDependentString(mValue.mString), - nsDependentString(aOther.mValue.mString), - nsCaseInsensitiveStringComparator()); + return nsDependentString(mValue.mString).Equals(nsDependentString(aOther.mValue.mString), + nsCaseInsensitiveStringComparator()); } } else if (eHTMLUnit_ISupports == mUnit) { diff --git a/content/html/content/src/nsHTMLAnchorElement.cpp b/content/html/content/src/nsHTMLAnchorElement.cpp index 5f3ce60390f..ab2f9c370ba 100644 --- a/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/content/html/content/src/nsHTMLAnchorElement.cpp @@ -398,8 +398,8 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::suppress) { - if (Compare(aValue,NS_LITERAL_STRING("true"), - nsCaseInsensitiveStringComparator())) { + if (!aValue.Equals(NS_LITERAL_STRING("true"), + nsCaseInsensitiveStringComparator())) { aResult.SetEmptyValue(); // XXX? shouldn't just leave "true" return NS_CONTENT_ATTR_HAS_VALUE; } diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index 637231f9907..0e3269ef279 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -212,7 +212,7 @@ nsHTMLButtonElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsAutoString value(aValue); if (aName == nsHTMLAtoms::disabled && - !Compare(value, NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator())) { + value.Equals(NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator())) { return UnsetAttr(aNameSpaceID, aName, aNotify); } diff --git a/content/html/style/src/nsCSSDeclaration.cpp b/content/html/style/src/nsCSSDeclaration.cpp index a04f0fd9a59..20675c406d1 100644 --- a/content/html/style/src/nsCSSDeclaration.cpp +++ b/content/html/style/src/nsCSSDeclaration.cpp @@ -5521,7 +5521,7 @@ nsCSSDeclaration::TryBackgroundPosition(nsAWritableString & aString, AppendValueToString(eCSSProperty_background_x_position, backgroundXValue); AppendValueToString(eCSSProperty_background_y_position, backgroundYValue); aString.Append(backgroundYValue); - if (Compare(backgroundXValue, backgroundYValue, nsCaseInsensitiveStringComparator())) { + if (!backgroundXValue.Equals(backgroundYValue, nsCaseInsensitiveStringComparator())) { // the two values are different aString.Append(PRUnichar(' ')); aString.Append(backgroundXValue); diff --git a/content/html/style/src/nsCSSLoader.cpp b/content/html/style/src/nsCSSLoader.cpp index 6a6b7dc2d6d..d3d482f1aca 100644 --- a/content/html/style/src/nsCSSLoader.cpp +++ b/content/html/style/src/nsCSSLoader.cpp @@ -638,9 +638,8 @@ SheetLoadData::OnStreamComplete(nsIStreamLoader* aLoader, } } if (mLoader->mNavQuirkMode || - Compare(contentType, - NS_LITERAL_CSTRING("text/css"), - nsCaseInsensitiveCStringComparator()) == 0 || + contentType.Equals(NS_LITERAL_CSTRING("text/css"), + nsCaseInsensitiveCStringComparator()) || contentType.IsEmpty()) { /* * First determine the charset (if one is indicated) diff --git a/content/html/style/src/nsCSSStruct.cpp b/content/html/style/src/nsCSSStruct.cpp index a04f0fd9a59..20675c406d1 100644 --- a/content/html/style/src/nsCSSStruct.cpp +++ b/content/html/style/src/nsCSSStruct.cpp @@ -5521,7 +5521,7 @@ nsCSSDeclaration::TryBackgroundPosition(nsAWritableString & aString, AppendValueToString(eCSSProperty_background_x_position, backgroundXValue); AppendValueToString(eCSSProperty_background_y_position, backgroundYValue); aString.Append(backgroundYValue); - if (Compare(backgroundXValue, backgroundYValue, nsCaseInsensitiveStringComparator())) { + if (!backgroundXValue.Equals(backgroundYValue, nsCaseInsensitiveStringComparator())) { // the two values are different aString.Append(PRUnichar(' ')); aString.Append(backgroundXValue); diff --git a/content/html/style/src/nsCSSStyleSheet.cpp b/content/html/style/src/nsCSSStyleSheet.cpp index 3cce72167e6..952aad603de 100644 --- a/content/html/style/src/nsCSSStyleSheet.cpp +++ b/content/html/style/src/nsCSSStyleSheet.cpp @@ -201,9 +201,8 @@ PRBool AtomKey_base::Equals(const nsHashKey* aKey) const const PRUnichar *theirStr = nsnull; theirAtom->GetUnicode(&theirStr); - return Compare(nsDependentString(myStr), - nsDependentString(theirStr), - nsCaseInsensitiveStringComparator()) == 0; + return nsDependentString(myStr).Equals(nsDependentString(theirStr), + nsCaseInsensitiveStringComparator()); } @@ -3352,9 +3351,8 @@ static PRBool ValueIncludes(const nsString& aValueList, const nsString& aValue, } } else { - if (!Compare(nsDependentString(value), - nsDependentString(start), - nsCaseInsensitiveStringComparator())) { + if (nsDependentString(value).Equals(nsDependentString(start), + nsCaseInsensitiveStringComparator())) { return PR_TRUE; } } @@ -3648,9 +3646,9 @@ static PRBool SelectorMatches(RuleProcessorData &data, break; } if (isCaseSensitive) - result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsDefaultStringComparator())); + result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsDefaultStringComparator())); else - result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsCaseInsensitiveStringComparator())); + result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsCaseInsensitiveStringComparator())); } } break; @@ -3662,9 +3660,9 @@ static PRBool SelectorMatches(RuleProcessorData &data, result = localFalse; } else { if (isCaseSensitive) - result = PRBool(localTrue == !Compare(Substring(value, valLen - selLen, selLen), attr->mValue, nsDefaultStringComparator())); + result = PRBool(localTrue == Substring(value, valLen - selLen, selLen).Equals(attr->mValue, nsDefaultStringComparator())); else - result = PRBool(localTrue == !Compare(Substring(value, valLen - selLen, selLen), attr->mValue, nsCaseInsensitiveStringComparator())); + result = PRBool(localTrue == Substring(value, valLen - selLen, selLen).Equals(attr->mValue, nsCaseInsensitiveStringComparator())); } } break; @@ -3676,9 +3674,9 @@ static PRBool SelectorMatches(RuleProcessorData &data, result = localFalse; } else { if (isCaseSensitive) - result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsDefaultStringComparator())); + result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsDefaultStringComparator())); else - result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsCaseInsensitiveStringComparator())); + result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsCaseInsensitiveStringComparator())); } } break; @@ -3718,8 +3716,8 @@ static PRBool SelectorMatches(RuleProcessorData &data, const PRUnichar* id2Str; IDList->mAtom->GetUnicode(&id2Str); nsDependentString id2(id2Str); - if (localTrue == - (Compare(id1, id2, nsCaseInsensitiveStringComparator()) != 0)) { + if (localTrue != + id1.Equals(id2, nsCaseInsensitiveStringComparator())) { result = PR_FALSE; break; } diff --git a/content/html/style/src/nsHTMLAttributes.cpp b/content/html/style/src/nsHTMLAttributes.cpp index c11c1c7f364..5824b0c40e3 100644 --- a/content/html/style/src/nsHTMLAttributes.cpp +++ b/content/html/style/src/nsHTMLAttributes.cpp @@ -1447,7 +1447,7 @@ HTMLAttributesImpl::HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const const PRUnichar* class2Buf; classList->mAtom->GetUnicode(&class2Buf); nsDependentString class2(class2Buf); - if (Compare(class1, class2, nsCaseInsensitiveStringComparator()) == 0) + if (class1.Equals(class2, nsCaseInsensitiveStringComparator())) return NS_OK; classList = classList->mNext; } while (classList); diff --git a/content/shared/src/nsHTMLValue.cpp b/content/shared/src/nsHTMLValue.cpp index 48e1b765f2f..3ed6e80a11f 100644 --- a/content/shared/src/nsHTMLValue.cpp +++ b/content/shared/src/nsHTMLValue.cpp @@ -172,9 +172,8 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const } } else if (nsnull != aOther.mValue.mString) { - return 0 == Compare(nsDependentString(mValue.mString), - nsDependentString(aOther.mValue.mString), - nsCaseInsensitiveStringComparator()); + return nsDependentString(mValue.mString).Equals(nsDependentString(aOther.mValue.mString), + nsCaseInsensitiveStringComparator()); } } else if (eHTMLUnit_ISupports == mUnit) { diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp index 8756b7ccda1..4d57b21f51a 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -852,20 +852,20 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement, mEventName = getter_AddRefs(NS_NewAtom(event)); if (aPhase) { - if (Compare(nsDependentString(aPhase), NS_LITERAL_STRING("capturing")) == 0) + const nsDependentString phase(aPhase); + if (phase.Equals(NS_LITERAL_STRING("capturing"))) mPhase = NS_PHASE_CAPTURING; - else if (Compare(nsDependentString(aPhase), NS_LITERAL_STRING("target")) == 0) + else if (phase.Equals(NS_LITERAL_STRING("target"))) mPhase = NS_PHASE_TARGET; } // Button and clickcount apply only to XBL handlers and don't apply to XUL key // handlers. - nsAutoString button(aButton); - nsAutoString clickcount(aClickCount); - if (!button.IsEmpty()) - mDetail = button.First() - '0'; - if (!clickcount.IsEmpty()) - mMisc = clickcount.First() - '0'; + if (aButton && *aButton) + mDetail = *aButton - '0'; + + if (aClickCount && *aClickCount) + mMisc = *aClickCount - '0'; // Modifiers are supported by both types of handlers (XUL and XBL). nsAutoString modifiers(aModifiers); diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index aec6bc8438f..abe16b6b227 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -1444,10 +1444,12 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes, nsAutoString src; while (*aAttributes) { const nsDependentString key(aAttributes[0]); - if (Compare(key, NS_LITERAL_STRING("src"),nsCaseInsensitiveStringComparator()) == 0) { + if (key.Equals(NS_LITERAL_STRING("src"), + nsCaseInsensitiveStringComparator())) { src.Assign(aAttributes[1]); } - else if (Compare(key, NS_LITERAL_STRING("type"),nsCaseInsensitiveStringComparator()) == 0) { + else if (key.Equals(NS_LITERAL_STRING("type"), + nsCaseInsensitiveStringComparator())) { nsAutoString type(aAttributes[1]); nsAutoString mimeType; nsAutoString params; @@ -1473,7 +1475,8 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes, jsVersionString = JS_VersionToString(jsVersion); } } - else if (Compare(key, NS_LITERAL_STRING("language"),nsCaseInsensitiveStringComparator()) == 0) { + else if (key.Equals(NS_LITERAL_STRING("language"), + nsCaseInsensitiveStringComparator())) { nsAutoString lang(aAttributes[1]); isJavaScript = nsParserUtils::IsJavaScriptLanguage(lang, &jsVersionString); } diff --git a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp index b11bcd2b4d6..e58c5b0a1a6 100644 --- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp +++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp @@ -92,9 +92,8 @@ ChangeCSSInlineStyleTxn::ValueIncludes(const nsAReadableString &aValueList, cons } } else { - if (!Compare(nsDependentString(value), - nsDependentString(start), - nsCaseInsensitiveStringComparator())) { + if (nsDependentString(value).Equals(nsDependentString(start), + nsCaseInsensitiveStringComparator())) { result = PR_TRUE; break; } @@ -370,8 +369,9 @@ ChangeCSSInlineStyleTxn::AcceptsMoreThanOneValue(nsIAtom *aCSSProperty) NS_IMETHODIMP ChangeCSSInlineStyleTxn::AddValueToMultivalueProperty(nsAWritableString & aValues, const nsAReadableString & aNewValue) { - if (!aValues.Length() - || !Compare(aValues, NS_LITERAL_STRING("none"), nsCaseInsensitiveStringComparator())) { + if (aValues.IsEmpty() + || aValues.Equals(NS_LITERAL_STRING("none"), + nsCaseInsensitiveStringComparator())) { // the list of values is empty of the value is 'none' aValues.Assign(aNewValue); } diff --git a/editor/libeditor/html/nsHTMLCSSUtils.cpp b/editor/libeditor/html/nsHTMLCSSUtils.cpp index 3e6632db933..a78614f7628 100644 --- a/editor/libeditor/html/nsHTMLCSSUtils.cpp +++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp @@ -1179,7 +1179,8 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, if (!htmlValueString.Equals(NS_LITERAL_STRING(""))) { nsAutoString leftHTMLValue; htmlValueString.Left(leftHTMLValue, 5); - aIsSet = PRBool(!Compare(leftHTMLValue, leftCSSValue, nsCaseInsensitiveStringComparator())); + aIsSet = leftHTMLValue.Equals(leftCSSValue, + nsCaseInsensitiveStringComparator()); } else { aIsSet = (leftCSSValue.Equals(NS_LITERAL_STRING("times")) || @@ -1202,7 +1203,8 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, } if (!htmlValueString.Equals(NS_LITERAL_STRING(""))) { - if (!Compare(htmlValueString, valueString, nsCaseInsensitiveStringComparator())) { + if (htmlValueString.Equals(valueString, + nsCaseInsensitiveStringComparator())) { aIsSet = PR_TRUE; } } diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 427a924b402..253c1434543 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -2492,7 +2492,7 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection, nsAutoString itemType; if (aItemType) itemType = *aItemType; - else if (!Compare(*aListType,NS_LITERAL_STRING("dl"),nsCaseInsensitiveStringComparator())) + else if (aListType->Equals(NS_LITERAL_STRING("dl"),nsCaseInsensitiveStringComparator())) itemType.Assign(NS_LITERAL_STRING("dd")); else itemType.Assign(NS_LITERAL_STRING("li")); @@ -6148,7 +6148,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadab else if (IsInlineNode(curNode)) { // if curNode is a non editable, drop it if we are going to
-      if (!Compare(tString,NS_LITERAL_STRING("pre"),nsCaseInsensitiveStringComparator()) 
+      if (tString.Equals(NS_LITERAL_STRING("pre"),nsCaseInsensitiveStringComparator()) 
         && (!mHTMLEditor->IsEditable(curNode)))
         continue; // do nothing to this block
       
diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp
index f4ab17890e3..5f04e3a9b2e 100644
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -2461,7 +2461,7 @@ nsHTMLEditor::RemoveList(const nsAReadableString& aListType)
   if (!selection) return NS_ERROR_NULL_POINTER;
 
   nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
-  if (!Compare(aListType,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()))
+  if (aListType.Equals(NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()))
     ruleInfo.bOrdered = PR_TRUE;
   else  ruleInfo.bOrdered = PR_FALSE;
   res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
@@ -2584,7 +2584,7 @@ nsHTMLEditor::Indent(const nsAReadableString& aIndent)
   PRBool cancel, handled;
   PRInt32 theAction = nsTextEditRules::kIndent;
   PRInt32 opID = kOpIndent;
-  if (!Compare(aIndent,NS_LITERAL_STRING("outdent"),nsCaseInsensitiveStringComparator()))
+  if (aIndent.Equals(NS_LITERAL_STRING("outdent"),nsCaseInsensitiveStringComparator()))
   {
     theAction = nsTextEditRules::kOutdent;
     opID = kOpOutdent;
@@ -3571,7 +3571,8 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
           {
             nsAutoString href;
             if (NS_SUCCEEDED(anchor->GetHref(href)))
-              if (Compare(Substring(href, 0, 5), NS_LITERAL_STRING("file:"), nsCaseInsensitiveStringComparator()) == 0)
+              if (Substring(href, 0, 5).Equals(NS_LITERAL_STRING("file:"),
+                                               nsCaseInsensitiveStringComparator()))
                 (*aNodeList)->AppendElement(node);
           }
         }
@@ -3863,20 +3864,20 @@ PRBool
 nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)  
 {
   // COtherDTD gives some unwanted results.  We override them here.
-  if (!Compare(aParentTag,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
-    !Compare(aParentTag,NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
+  if (aParentTag.Equals(NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
+      aParentTag.Equals(NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
   {
     // if parent is a list and tag is also a list, say "yes".
     // This is because the editor does sublists illegally for now. 
-      if (!Compare(aChildTag,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
-        !Compare(aChildTag,NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
+      if (aChildTag.Equals(NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
+          aChildTag.Equals(NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
       return PR_TRUE;
   }
 
-  if (!Compare(aParentTag,NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
+  if (aParentTag.Equals(NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
   {
     // list items cant contain list items
-    if (!Compare(aChildTag,NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
+    if (aChildTag.Equals(NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
       return PR_FALSE;
   }
 
diff --git a/editor/libeditor/html/nsHTMLEditorStyle.cpp b/editor/libeditor/html/nsHTMLEditorStyle.cpp
index 82d5a4d7200..0ea49f6d656 100644
--- a/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -715,7 +715,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
   }  
   if ( aProperty == nsIEditProperty::font &&    // or node is big or small and we are setting font size
        (NodeIsType(aNode, nsIEditProperty::big) || NodeIsType(aNode, nsIEditProperty::small)) &&
-       !Compare(*aAttribute,NS_LITERAL_STRING("size"),nsCaseInsensitiveStringComparator()))       
+       aAttribute->Equals(NS_LITERAL_STRING("size"),nsCaseInsensitiveStringComparator()))       
   {
     res = RemoveContainer(aNode);  // if we are setting font size, remove any nested bigs and smalls
   }
@@ -741,10 +741,10 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
     if (!attrName) continue;  // ooops
     attrName->ToString(attrString);
     // if it's the attribute we know about, keep looking
-    if (!Compare(attrString,*aAttribute,nsCaseInsensitiveStringComparator())) continue;
+    if (attrString.Equals(*aAttribute,nsCaseInsensitiveStringComparator())) continue;
     // if it's a special _moz... attribute, keep looking
     attrString.Left(tmp,4);
-    if (!Compare(tmp,NS_LITERAL_STRING("_moz"),nsCaseInsensitiveStringComparator())) continue;
+    if (tmp.Equals(NS_LITERAL_STRING("_moz"),nsCaseInsensitiveStringComparator())) continue;
     // otherwise, it's another attribute, so return false
     return PR_FALSE;
   }
@@ -798,7 +798,7 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
   attNode->GetValue(attrVal);
   
   // do values match?
-  if (!Compare(attrVal,*aValue,nsCaseInsensitiveStringComparator())) return PR_TRUE;
+  if (attrVal.Equals(*aValue,nsCaseInsensitiveStringComparator())) return PR_TRUE;
   return PR_FALSE;
 }
 
diff --git a/editor/libeditor/text/nsAOLCiter.cpp b/editor/libeditor/text/nsAOLCiter.cpp
index a00a98f26c9..259a50dcbe0 100644
--- a/editor/libeditor/text/nsAOLCiter.cpp
+++ b/editor/libeditor/text/nsAOLCiter.cpp
@@ -107,7 +107,7 @@ nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aO
   nsReadingIterator  iter,enditer;
   aInString.BeginReading(iter);
   aInString.EndReading(enditer);
-  if (!Compare(Substring(aInString,0,2),NS_LITERAL_STRING(">>")))
+  if (Substring(aInString,0,2).Equals(NS_LITERAL_STRING(">>")))
   {
     iter.advance(2);
     while (nsCRT::IsAsciiSpace(*iter))
diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
index 55764eacfb4..4d27844a596 100644
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -1466,27 +1466,27 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
       element->GetTagName(tag);
 
       // Test what kind of element we're dealing with here
-      if (!Compare(tag, NS_LITERAL_STRING("img"), nsCaseInsensitiveStringComparator()))
+      if (tag.Equals(NS_LITERAL_STRING("img"), nsCaseInsensitiveStringComparator()))
       {
         flags |= nsIContextMenuListener::CONTEXT_IMAGE;
         targetDOMnode = node;
         // if we see an image, keep searching for a possible anchor
       }
-      else if (!Compare(tag, NS_LITERAL_STRING("input"), nsCaseInsensitiveStringComparator()))
+      else if (tag.Equals(NS_LITERAL_STRING("input"), nsCaseInsensitiveStringComparator()))
       {
         // INPUT element - button, combo, checkbox, text etc.
         flags |= nsIContextMenuListener::CONTEXT_INPUT;
         targetDOMnode = node;
         break; // exit do-while
       }
-      else if (!Compare(tag, NS_LITERAL_STRING("textarea"), nsCaseInsensitiveStringComparator()))
+      else if (tag.Equals(NS_LITERAL_STRING("textarea"), nsCaseInsensitiveStringComparator()))
       {
         // text area
         flags |= nsIContextMenuListener::CONTEXT_TEXT;
         targetDOMnode = node;
         break; // exit do-while
       }
-      else if (!Compare(tag, NS_LITERAL_STRING("html"), nsCaseInsensitiveStringComparator()))
+      else if (tag.Equals(NS_LITERAL_STRING("html"), nsCaseInsensitiveStringComparator()))
       {
         // only care about this if no other context was found.
         if (!flags) {
@@ -1508,8 +1508,7 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
       if (attributes)
       {
         nsCOMPtr hrefNode;
-        nsAutoString href(NS_LITERAL_STRING("href"));
-        attributes->GetNamedItem(href, getter_AddRefs(hrefNode));
+        attributes->GetNamedItem(NS_LITERAL_STRING("href"), getter_AddRefs(hrefNode));
         if (hrefNode)
         {
           flags |= nsIContextMenuListener::CONTEXT_LINK;
diff --git a/extensions/wallet/src/nsWalletService.cpp b/extensions/wallet/src/nsWalletService.cpp
index 29efe6b3162..2c67ab05565 100644
--- a/extensions/wallet/src/nsWalletService.cpp
+++ b/extensions/wallet/src/nsWalletService.cpp
@@ -429,7 +429,7 @@ nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress,
                         nsAutoString type;
                         rv = inputElement->GetType(type);
                         if (NS_SUCCEEDED(rv)) {
-                          if (Compare(type, NS_LITERAL_STRING("password"), nsCaseInsensitiveStringComparator()) == 0) {
+                          if (type.Equals(NS_LITERAL_STRING("password"), nsCaseInsensitiveStringComparator())) {
                             passwordCount++;
                           }
                         }
@@ -449,8 +449,11 @@ nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress,
                         nsAutoString type;
                         rv = inputElement->GetType(type);
                         if (NS_SUCCEEDED(rv)) {
-                          if ((type.IsEmpty()) || (Compare(type, NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator()) == 0) ||
-                            (Compare(type, NS_LITERAL_STRING("password"), nsCaseInsensitiveStringComparator()) == 0)) {
+                          if (type.IsEmpty() ||
+                              type.Equals(NS_LITERAL_STRING("text"),
+                                          nsCaseInsensitiveStringComparator()) ||
+                              type.Equals(NS_LITERAL_STRING("password"),
+                                          nsCaseInsensitiveStringComparator())) {
                             nsAutoString field;
                             rv = inputElement->GetName(field);
                             if (NS_SUCCEEDED(rv)) {
diff --git a/extensions/wallet/src/wallet.cpp b/extensions/wallet/src/wallet.cpp
index 0a9b646387d..72200363696 100644
--- a/extensions/wallet/src/wallet.cpp
+++ b/extensions/wallet/src/wallet.cpp
@@ -1960,14 +1960,16 @@ wallet_StepForwardOrBack
       if (goForward) {
         if (NS_SUCCEEDED(result) &&
             (type.IsEmpty() ||
-             (Compare(type, NS_LITERAL_STRING("text"), 
-                      nsCaseInsensitiveStringComparator()) == 0))) {
+             type.Equals(NS_LITERAL_STRING("text"), 
+                         nsCaseInsensitiveStringComparator()))) {
           /* at  element and it's type is either "text" or is missing ("text" by default) */
           atInputOrSelect = PR_TRUE;
           return;
         }
       } else {
-        if (NS_SUCCEEDED(result) && (Compare(type, NS_LITERAL_STRING("hidden"), nsCaseInsensitiveStringComparator()) != 0)) {
+        if (NS_SUCCEEDED(result) &&
+            !type.Equals(NS_LITERAL_STRING("hidden"),
+                         nsCaseInsensitiveStringComparator())) {
           /* at  element and it's type is not "hidden" */
           atInputOrSelect = PR_TRUE;
           return;
@@ -2402,7 +2404,10 @@ wallet_GetPrefills(
   if ((NS_SUCCEEDED(result)) && (nsnull != inputElement)) {
     nsAutoString type;
     result = inputElement->GetType(type);
-    if ((NS_SUCCEEDED(result)) && ((type.IsEmpty()) || (Compare(type, NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator()) == 0))) {
+    if (NS_SUCCEEDED(result) &&
+        (type.IsEmpty() ||
+         type.Equals(NS_LITERAL_STRING("text"),
+                     nsCaseInsensitiveStringComparator()))) {
       nsAutoString field;
       result = inputElement->GetName(field);
       if (NS_SUCCEEDED(result)) {
@@ -3636,8 +3641,10 @@ wallet_CaptureInputElement(nsIDOMNode* elementNode, nsIDocument* doc) {
     /* it's an input element */
     nsAutoString type;
     result = inputElement->GetType(type);
-    if ((NS_SUCCEEDED(result)) &&
-        (type.IsEmpty() || (Compare(type, NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator()) == 0))) {
+    if (NS_SUCCEEDED(result) &&
+        (type.IsEmpty() ||
+         type.Equals(NS_LITERAL_STRING("text"),
+                     nsCaseInsensitiveStringComparator()))) {
       nsAutoString field;
       result = inputElement->GetName(field);
       if (NS_SUCCEEDED(result)) {
@@ -3992,8 +3999,8 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindowInternal* window) {
                 rv = inputElement->GetType(type);
                 if (NS_SUCCEEDED(rv)) {
 
-                  PRBool isText = (type.IsEmpty() || (Compare(type, NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator())==0));
-                  PRBool isPassword = (Compare(type, NS_LITERAL_STRING("password"), nsCaseInsensitiveStringComparator())==0);
+                  PRBool isText = (type.IsEmpty() || type.Equals(NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator()));
+                  PRBool isPassword = type.Equals(NS_LITERAL_STRING("password"), nsCaseInsensitiveStringComparator());
 
                   // don't save password if field was left blank
                   if (isPassword) {
diff --git a/htmlparser/src/CNavDTD.cpp b/htmlparser/src/CNavDTD.cpp
index 3c5474218f0..e424a0e72bc 100644
--- a/htmlparser/src/CNavDTD.cpp
+++ b/htmlparser/src/CNavDTD.cpp
@@ -1013,12 +1013,12 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
         if(theCount) {
           PRInt32 theIndex=0;
           for(theIndex=0;theIndex
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the NPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the NPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/**
- * MODULE NOTES:
- * 
- * This file declares the concrete HTMLContentSink class.
- * This class is used during the parsing process as the
- * primary interface between the parser and the content
- * model.
- */
-
-#include "nsHTMLContentSinkStream.h"
-#include "nsIParserNode.h"
-#include 
-#include "nsString.h"
-#include "nsReadableUtils.h"
-#include "nsIParser.h"
-#include "nsICharsetAlias.h"
-#include "nsIServiceManager.h"
-#include "nsIEntityConverter.h"
-#include "nsCRT.h"
-#include "nsIDocumentEncoder.h"   // for output flags
-#include "nsHTMLTokens.h"
-
-#include "nsIOutputStream.h"
-#include "nsFileStream.h"
-
-#include "nsNetUtil.h"           // for NS_MakeAbsoluteURI
-
-static NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
-static NS_DEFINE_CID(kEntityConverterCID, NS_ENTITYCONVERTER_CID);
-
-static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
-static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
-
-const  int            gTabSize=2;
-
-#define gMozDirty NS_LITERAL_STRING("_moz_dirty")
-
-/**
- *  This method gets called as part of our COM-like interfaces.
- *  Its purpose is to create an interface to parser object
- *  of some type.
- *  
- *  @update   gess 4/8/98
- *  @param    nsIID  id of object to discover
- *  @param    aInstancePtr ptr to newly discovered interface
- *  @return   NS_xxx result code
- */
-nsresult
-nsHTMLContentSinkStream::QueryInterface(const nsIID& aIID, void** aInstancePtr)
-{                                                                        
-  if (NULL == aInstancePtr) {                                            
-    return NS_ERROR_NULL_POINTER;                                        
-  }                                                                      
-  if (aIID.Equals(NS_GET_IID(nsISupports))) {
-    *aInstancePtr = (nsIContentSink*)(this);
-  }
-  else if (aIID.Equals(NS_GET_IID(nsIContentSink))) {
-    *aInstancePtr = (nsIContentSink*)(this);
-  }
-  else if (aIID.Equals(NS_GET_IID(nsIHTMLContentSink))) {
-    *aInstancePtr = (nsIHTMLContentSink*)(this);
-  }
-  else if (aIID.Equals(NS_GET_IID(nsIHTMLContentSinkStream))) {
-    *aInstancePtr = (nsIHTMLContentSinkStream*)(this);
-  }
-  else {
-    *aInstancePtr=0;
-    return NS_NOINTERFACE;
-  }
-  NS_ADDREF_THIS();
-  return NS_OK;                                                        
-}
-
-NS_IMPL_ADDREF(nsHTMLContentSinkStream)
-NS_IMPL_RELEASE(nsHTMLContentSinkStream)
-
-/**
- * Construct a content sink stream.
- * @update	gess7/7/98
- * @param 
- * @return
- */
-nsHTMLContentSinkStream::nsHTMLContentSinkStream()
-{
-  NS_INIT_REFCNT();
-  mLowerCaseTags = PR_TRUE;  
-  memset(mHTMLTagStack,0,sizeof(mHTMLTagStack));
-  memset(mDirtyStack,0,sizeof(mDirtyStack));
-  mDTD = 0;
-  mHTMLStackPos = 0;
-  mColPos = 0;
-  mIndent = 0;
-  mInBody = PR_FALSE;
-  mBuffer = nsnull;
-  mBufferSize = 0;
-  mBufferLength = 0;
-  mFlags = 0;
-  mHasOpenHtmlTag=PR_FALSE;
-}
-
-NS_IMETHODIMP
-nsHTMLContentSinkStream::Initialize(nsIOutputStream* aOutStream, 
-                                    nsAWritableString* aOutString,
-                                    const nsAReadableString* aCharsetOverride,
-                                    PRUint32 aFlags)
-{
-  mDoFormat = (aFlags & nsIDocumentEncoder::OutputFormatted) ? PR_TRUE
-                                                             : PR_FALSE;
-
-  mBodyOnly = (aFlags & nsIDocumentEncoder::OutputBodyOnly) ? PR_TRUE
-                                                            : PR_FALSE;
-  mMaxColumn = 72;
-  mFlags = aFlags;
-
-  // Set the line break character:
-  if ((mFlags & nsIDocumentEncoder::OutputCRLineBreak)
-      && (mFlags & nsIDocumentEncoder::OutputLFLineBreak)) // Windows/mail
-    mLineBreak.Assign(NS_LITERAL_STRING("\r\n"));
-  else if (mFlags & nsIDocumentEncoder::OutputCRLineBreak) // Mac
-    mLineBreak.Assign(NS_LITERAL_STRING("\r"));
-  else if (mFlags & nsIDocumentEncoder::OutputLFLineBreak) // Unix/DOM
-    mLineBreak.Assign(NS_LITERAL_STRING("\n"));
-  else
-    mLineBreak.AssignWithConversion(NS_LINEBREAK);         // Platform/default
-
-  mStream = aOutStream;
-  mString = aOutString;
-  if (aCharsetOverride != nsnull)
-    mCharsetOverride.Assign(*aCharsetOverride);
-
-  mPreLevel = 0;
-
-  return NS_OK;
-}
-
-nsHTMLContentSinkStream::~nsHTMLContentSinkStream()
-{
-  NS_IF_RELEASE(mDTD);
-
-  if (mBuffer)
-    delete [] mBuffer;
-}
-
-/**
- * This method tells the sink whether or not it is 
- * encoding an HTML fragment or the whole document.
- * By default, the entire document is encoded.
- *
- * @update 03/14/99 gpk
- * @param  aFlag set to true if only encoding a fragment
- */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::DoFragment(PRBool aFlag) 
-{
-  return NS_OK; 
-}
-
-/**
- * This gets called when handling illegal contents, especially
- * in dealing with tables. This method creates a new context.
- * 
- * @update 04/04/99 harishd
- * @param aPosition - The position from where the new context begins.
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::BeginContext(PRInt32 aPosition) 
-{
-  return NS_OK;
-}
-
-/**
- * This method terminates any new context that got created by
- * BeginContext and switches back to the main context.  
- *
- * @update 04/04/99 harishd
- * @param aPosition - Validates the end of a context.
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::EndContext(PRInt32 aPosition)
-{
-  return NS_OK;
-}
-
-/**
- * Initialize the Unicode encoder with our current mCharsetOverride.
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::InitEncoders()
-{
-  nsresult res;
-
-  // Initialize an entity encoder if we're using the string interface:
-  if (mString && (mFlags & nsIDocumentEncoder::OutputEncodeEntities))
-    res = nsComponentManager::CreateInstance(kEntityConverterCID, NULL, 
-                                             NS_GET_IID(nsIEntityConverter),
-                                             getter_AddRefs(mEntityConverter));
-
-  // Initialize a charset encoder if we're using the stream interface
-  if (mStream)
-  {
-    nsAutoString charsetName; charsetName.Assign(mCharsetOverride);
-    nsCOMPtr calias(do_GetService(kCharsetAliasCID, &res));
-    if (NS_SUCCEEDED(res) && calias) {
-      nsAutoString temp; temp.Assign(mCharsetOverride);
-      res = calias->GetPreferred(temp, charsetName);
-    }
-    if (NS_FAILED(res))
-    {
-      // failed - unknown alias , fallback to ISO-8859-1
-      charsetName.Assign(NS_LITERAL_STRING("ISO-8859-1"));
-    }
-
-    res = nsComponentManager::CreateInstance(kSaveAsCharsetCID, NULL, 
-                                             NS_GET_IID(nsISaveAsCharset),
-                                             getter_AddRefs(mCharsetEncoder));
-    if (NS_FAILED(res))
-      return res;
-    // SaveAsCharset requires a const char* in its first argument:
-    nsCAutoString charsetCString; charsetCString.AssignWithConversion(charsetName);
-    // For ISO-8859-1 only, convert to entity first (always generate entites like  ).
-    res = mCharsetEncoder->Init(charsetCString,
-                                charsetName.EqualsIgnoreCase("ISO-8859-1") ?
-                                nsISaveAsCharset::attr_htmlTextDefault :
-                                nsISaveAsCharset::attr_EntityAfterCharsetConv
-                                 + nsISaveAsCharset::attr_FallbackDecimalNCR,
-                                nsIEntityConverter::html32);
-  }
-
-  return res;
-}
-
-void nsHTMLContentSinkStream::EnsureBufferSize(PRInt32 aNewSize)
-{
-  if (mBufferSize < aNewSize) {
-    if(mBuffer) nsMemory::Free(mBuffer);
-
-    mBufferSize = 2*aNewSize+1; // make this twice as large
-    mBuffer = NS_STATIC_CAST(char *, nsMemory::Alloc(mBufferSize));
-    if(mBuffer){ 
-      mBuffer[0] = 0;
-    }
-  }
-}
-
-/**
- * Writes to the buffer/stream.
- * If we do both string and stream output, stream chars will override string.
- *
- * @param aString - the string to write.
- * @return The number of characters written.
- */
-PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString)
-{
-  if (mBodyOnly && !mInBody)
-    return 0;
-
-  int charsWritten = 0;
-
-  // For the string case, we don't want to do charset conversion,
-  // but we still want to encode entities.
-  if (mString)
-  {
-    if (!mEntityConverter && (mFlags & nsIDocumentEncoder::OutputEncodeEntities))
-      InitEncoders();
-    if (mEntityConverter && (mFlags & nsIDocumentEncoder::OutputEncodeEntities))
-    {
-      nsresult res;
-      PRUnichar *encodedBuffer = nsnull;
-      res = mEntityConverter->ConvertToEntities(PromiseFlatString(aString).get(),
-                                                nsIEntityConverter::html40Latin1,
-                                                &encodedBuffer);
-      if (NS_SUCCEEDED(res) && encodedBuffer)
-      {
-        PRInt32 len = nsCRT::strlen(encodedBuffer);
-        mString->Append(encodedBuffer, len);
-        nsCRT::free(encodedBuffer);
-        charsWritten = len;
-      }
-      else {
-        charsWritten = aString.Length();
-        mString->Append(aString);
-      }
-    }
-    else {
-      charsWritten = aString.Length();
-      mString->Append(aString);
-    }
-  }
-
-  if (!mStream)
-    return charsWritten;
-
-  // Now handle the stream case:
-  nsOutputStream out(mStream);
-
-  // If an encoder is being used then convert first convert the input string
-  char *encodedBuffer = nsnull;
-  nsresult res;
-
-  // Initialize the encoder if we haven't already
-  if (!mCharsetEncoder)
-    InitEncoders();
-
-  if (mCharsetEncoder)
-  {
-    // Call the converter to convert to the target charset.
-    // Convert() takes a char* output param even though it's writing unicode.
-    res = mCharsetEncoder->Convert(PromiseFlatString(aString).get(), &encodedBuffer);
-    if (NS_SUCCEEDED(res) && encodedBuffer)
-    {
-      charsWritten = nsCRT::strlen(encodedBuffer);
-      out.write(encodedBuffer, charsWritten);
-      nsCRT::free(encodedBuffer);
-    }
-
-    // If it didn't work, just write the unicode
-    else
-    {
-      charsWritten = aString.Length();
-      out.write(PromiseFlatString(aString).get(), charsWritten);
-    }
-  }
-
-  // If we couldn't get an encoder, just write the unicode
-  else
-  {
-    charsWritten = aString.Length();
-    out.write(PromiseFlatString(aString).get(), charsWritten);
-  }
-
-  return charsWritten;
-}
-
-void nsHTMLContentSinkStream::Write(const char* aData)
-{
-  if (mBodyOnly && !mInBody)
-    return;
-
-  if (mStream)
-  {
-    nsOutputStream out(mStream);
-    out << aData;
-  }
-  if (mString)
-  {
-    mString->Append(NS_ConvertASCIItoUCS2(aData));
-  }
-}
-
-void nsHTMLContentSinkStream::Write(char aData)
-{
-  if (mBodyOnly && !mInBody)
-    return;
-
-  if (mStream)
-  {
-    nsOutputStream out(mStream);
-    out << aData;
-  }
-  if (mString)
-  {
-    mString->Append(NS_ConvertASCIItoUCS2(aData));
-  }
-}
-
-/**
- * Write the attributes of the current tag.
- * 
- * @param aNode The parser node currently in play.
- */
-void nsHTMLContentSinkStream::WriteAttributes(const nsIParserNode& aNode)
-{
-  int theCount=aNode.GetAttributeCount();
-  if(theCount) {
-    int i=0;
-    for(i=0;i or 
, - // used by the editor. Bug 16988. Yuck. - // - if ((eHTMLTags)aNode.GetNodeType() == eHTMLTag_br - && (!Compare((key, NS_LITERAL_STRING("type"), nsCaseInsensitiveStringComparator()) - && value.Equals(NS_LITERAL_STRING("_moz"))))) - continue; - - if (mLowerCaseTags == PR_TRUE) - ToLowerCase(key); - else - ToUpperCase(key); - - EnsureBufferSize(key.Length() + 1); - key.ToCString(mBuffer,mBufferSize); - - // send to ouput " [KEY]=" - Write(' '); - Write(mBuffer); - mColPos += 1 + strlen(mBuffer) + 1; - - // Make all links absolute when converting only the selection: - if ((mFlags & nsIDocumentEncoder::OutputAbsoluteLinks) - && (!Compare(key, NS_LITERAL_STRING("href"), nsCaseInsensitiveStringComparator()) - || !Compare(key, NS_LITERAL_STRING("src"), nsCaseInsensitiveStringComparator()) - // Would be nice to handle OBJECT and APPLET tags, - // but that gets more complicated since we have to - // search the tag list for CODEBASE as well. - // For now, just leave them relative. - )) - { - if (mURI) - { - nsAutoString absURI; - if (NS_SUCCEEDED(NS_MakeAbsoluteURI(absURI, value, mURI)) - && !absURI.IsEmpty()) - value = absURI; - } - } - - if (value.Length() > 0) - { - Write(char(kEqual)); - mColPos += 1 + strlen(mBuffer) + 1; - - // send to ouput "\"[VALUE]\"" - Write('\"'); - Write(value); - Write('\"'); - } - - mColPos += 1 + strlen(mBuffer) + 1; - } - } -} - -/** - * This method gets called by the parser when it encounters - * a title tag and wants to set the document title in the sink. - * - * @update 04/30/99 gpk - * @param nsString reference to new title value - * @return PR_TRUE if successful. - */ -NS_IMETHODIMP -nsHTMLContentSinkStream::SetTitle(const nsString& aValue) -{ - const char* tagName = GetTagName(eHTMLTag_title); - Write(kLessThan); - Write(tagName); - Write(kGreaterThan); - - Write(aValue); - - Write(kLessThan); - Write(kForwardSlash); - Write(tagName); - Write(kGreaterThan); - - return NS_OK; -} - -/** - * This method is used to open the outer HTML container. - * - * XXX OpenHTML never gets called; AddStartTag gets called on - * XXX the html tag from OpenContainer, from nsXIFDTD::StartTopOfStack, - * XXX from nsXIFDTD::HandleStartToken. - * - * @param nsIParserNode reference to parser node interface - * @return PR_TRUE if successful. - */ -NS_IMETHODIMP -nsHTMLContentSinkStream::OpenHTML(const nsIParserNode& aNode) -{ - eHTMLTags tag = (eHTMLTags)aNode.GetNodeType(); - if (tag == eHTMLTag_html) - { - if(!mHasOpenHtmlTag) { - AddStartTag(aNode); - mHasOpenHtmlTag=PR_TRUE; - } - else { - PRInt32 ac=aNode.GetAttributeCount(); - if(ac>0) { - Write(kLessThan); - nsAutoString tagname; - tagname.AssignWithConversion(nsHTMLTags::GetStringValue(tag)); - Write(tagname); - WriteAttributes(aNode); - Write(kGreaterThan); - } - } - } - return NS_OK; -} - -/** - * All these HTML-specific methods may be called, or may not, - * depending on whether the parser is parsing XIF or HTML. - * So we can't depend on them; instead, we have Open/CloseContainer - * do all the specialized work, and the html-specific Open/Close - * methods must call the more general methods. - * - * Since there are so many of them, make macros: - */ - -#define USE_GENERAL_OPEN_METHOD(methodname, tagtype) \ -NS_IMETHODIMP nsHTMLContentSinkStream::methodname(const nsIParserNode& aNode) \ -{ \ - if ((eHTMLTags)aNode.GetNodeType() == tagtype) \ - AddStartTag(aNode); \ - return NS_OK; \ -} - -#define USE_GENERAL_CLOSE_METHOD(methodname, tagtype) \ -NS_IMETHODIMP nsHTMLContentSinkStream::methodname(const nsIParserNode& aNode) \ -{ \ - if ((eHTMLTags)aNode.GetNodeType() == tagtype) \ - AddEndTag(aNode); \ - return NS_OK; \ -} - -USE_GENERAL_CLOSE_METHOD(CloseHTML, eHTMLTag_html) -USE_GENERAL_OPEN_METHOD(OpenHead, eHTMLTag_head) -USE_GENERAL_CLOSE_METHOD(CloseHead, eHTMLTag_head) -USE_GENERAL_OPEN_METHOD(OpenBody, eHTMLTag_body) -USE_GENERAL_CLOSE_METHOD(CloseBody, eHTMLTag_body) -USE_GENERAL_OPEN_METHOD(OpenForm, eHTMLTag_form) -USE_GENERAL_CLOSE_METHOD(CloseForm, eHTMLTag_form) -USE_GENERAL_OPEN_METHOD(OpenMap, eHTMLTag_map) -USE_GENERAL_CLOSE_METHOD(CloseMap, eHTMLTag_map) -USE_GENERAL_OPEN_METHOD(OpenFrameset, eHTMLTag_frameset) -USE_GENERAL_CLOSE_METHOD(CloseFrameset, eHTMLTag_frameset) - -/** - * - * Check whether a node has the attribute _moz_dirty. - * If it does, we'll prettyprint it, otherwise we adhere to the - * surrounding text/whitespace/newline nodes provide formatting. - */ -PRBool nsHTMLContentSinkStream::IsDirty(const nsIParserNode& aNode) -{ - // Apparently there's no way to just ask for a particular attribute - // without looping over the list. - int theCount = aNode.GetAttributeCount(); - if (theCount) - { - for(int i=0; i < theCount; i++) - { - const nsAReadableString& key = (nsString&)aNode.GetKeyAt(i); - if (key == gMozDirty) - return PR_TRUE; - } - } - return PR_FALSE; -} - -void nsHTMLContentSinkStream::AddIndent() -{ - nsAutoString padding(NS_LITERAL_STRING(" ")); - for (PRInt32 i = mIndent; --i >= 0; ) - { - Write(padding); - mColPos += 2; - } -} - -void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode) -{ - eHTMLTags tag = (eHTMLTags)aNode.GetNodeType(); - PRBool isDirty = IsDirty(aNode); - - const nsAReadableString& name = aNode.GetText(); - nsAutoString tagName; - - if (tag == eHTMLTag_body) - mInBody = PR_TRUE; - - mHTMLTagStack[mHTMLStackPos] = tag; - mDirtyStack[mHTMLStackPos++] = isDirty; - tagName = name; - - if (tag == eHTMLTag_doctypeDecl || tag == eHTMLTag_markupDecl) - { - if (!(mFlags & nsIDocumentEncoder::OutputSelectionOnly)) - { - Write(" Markup Declaration Open. - } - return; - } - // Quoted plaintext mail/news lives in a pre tag. - // The editor has substituted
tags for all the newlines in the pre, - // in order to get clickable blank lines. - // We can't emit these
tags formatted, or we'll get - // double-spacing (one for the br, one for the line break); - // but we can't emit them unformatted, either, - // because then long quoted passages will make html source lines - // too long for news servers (and some mail servers) to handle. - // So we map all
tags inside
 to line breaks.
-  // If this turns out to be a problem, we could do this only if gMozDirty.
-  else if (tag == eHTMLTag_br && mPreLevel > 0)
-  {
-    Write(mLineBreak);
-    return;
-  }
-
-  if (mLowerCaseTags == PR_TRUE)
-    ToLowerCase(tagName);
-  else
-    ToUpperCase(tagName);
-
-#ifdef DEBUG_prettyprint
-  if (isDirty)
-    printf("AddStartTag(%s): BBO=%d, BAO=%d, BBC=%d, BAC=%d\n",
-           NS_LossyConvertUCS2toASCII(name).get(),
-           BreakBeforeOpen(tag),
-           BreakAfterOpen(tag),
-           BreakBeforeClose(tag),
-           BreakAfterClose(tag));
-#endif
-
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos != 0
-      && BreakBeforeOpen(tag))
-  {
-    Write(mLineBreak);
-    mColPos = 0;
-  }
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos == 0)
-    AddIndent();
-
-  EnsureBufferSize(tagName.Length() + 1);
-  tagName.ToCString(mBuffer,mBufferSize);
-
-  Write(kLessThan);
-  Write(mBuffer);
-
-  mColPos += 1 + tagName.Length();
-
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && tag == eHTMLTag_style)
-  {
-    Write(kGreaterThan);
-    Write(mLineBreak);
-    const   nsString& data = aNode.GetSkippedContent();
-    PRInt32 size = data.Length();
-    char*   buffer = new char[size+1];
-    if(buffer){
-      data.ToCString(buffer,size+1);
-      Write(buffer);
-      delete[] buffer;
-    }
-  }
-  else
-  {
-    WriteAttributes(aNode);
-    Write(kGreaterThan);
-    mColPos += 1;
-  }
-
-  if (tag == eHTMLTag_pre)
-    ++mPreLevel;
-
-  if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterOpen(tag)))
-  {
-    Write(mLineBreak);
-    mColPos = 0;
-  }
-
-  if (IndentChildren(tag))
-    mIndent++;
-}
-
-void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
-{
-  eHTMLTags         tag = (eHTMLTags)aNode.GetNodeType();
-  nsAutoString      tagName;
-  PRBool            isDirty = mDirtyStack[mHTMLStackPos-1];
-
-#ifdef DEBUG_prettyprint
-  if (isDirty)
-    printf("AddEndTag(%s): BBO=%d, BAO=%d, BBC=%d, BAC=%d\n",
-           (const char*)NS_ConvertUCS2toUTF8(aNode.GetText()),
-           BreakBeforeOpen(tag),
-           BreakAfterOpen(tag),
-           BreakBeforeClose(tag),
-           BreakAfterClose(tag));
-#endif
-
-  if (tag == eHTMLTag_unknown)
-  {
-    tagName.Assign(aNode.GetText());
-  }
-  else if (tag == eHTMLTag_pre)
-  {
-    --mPreLevel;
-    tagName.Assign(aNode.GetText());
-  }
-  else if (tag == eHTMLTag_comment)
-  {
-    tagName.Assign(NS_LITERAL_STRING("--"));
-  }
-  else if (tag == eHTMLTag_doctypeDecl || tag == eHTMLTag_markupDecl)
-  {
-    if (!(mFlags & nsIDocumentEncoder::OutputSelectionOnly))
-    {
-      Write(kGreaterThan);
-      Write(mLineBreak);
-    }
-    if ( mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_doctypeDecl || mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_markupDecl)
-    {
-      mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
-    }
-    return;
-  }
-  else if (tag == eHTMLTag_userdefined)
-  {
-    // nsHTMLTags::GetStringValue doesn't work for userdefined tags
-    tagName = aNode.GetText();
-  }
-  else
-  {
-    tagName.AssignWithConversion(nsHTMLTags::GetStringValue(tag));
-  }
-  if (mLowerCaseTags == PR_TRUE)
-    ToLowerCase(tagName);
-//  else
-//    ToUpperCase(tagName);
-
-  if (IndentChildren(tag))
-    mIndent--;
-
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && BreakBeforeClose(tag))
-  {
-    if (mColPos != 0)
-    {
-      Write(mLineBreak);
-      mColPos = 0;
-    }
-  }
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos == 0)
-    AddIndent();
-
-  EnsureBufferSize(tagName.Length() + 1);
-  tagName.ToCString(mBuffer,mBufferSize);
-
-  if (tag != eHTMLTag_comment)
-  {
-    Write(kLessThan);
-    Write(kForwardSlash);
-    mColPos += 1 + 1;
-  }
-  
-  Write(mBuffer);
-  Write(kGreaterThan);
-
-  mColPos += strlen(mBuffer) + 1;
-
-  if (tag == eHTMLTag_body)
-    mInBody = PR_FALSE;
-
-  if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterClose(tag))
-      || tag == eHTMLTag_body || tag == eHTMLTag_html)
-  {
-    Write(mLineBreak);
-    mColPos = 0;
-  }
-  mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
-}
-
-/**
- *  This gets called by the parser when you want to add
- *  a leaf node to the current container in the content
- *  model.
- */
-nsresult
-nsHTMLContentSinkStream::AddLeaf(const nsIParserNode& aNode)
-{
-  eHTMLTags type = (eHTMLTags)aNode.GetNodeType();
-  eHTMLTags tag = eHTMLTag_unknown;
-  if (mHTMLStackPos > 0)
-    tag = mHTMLTagStack[mHTMLStackPos-1];
-  
-  if (type ==  eHTMLTag_area     ||
-      type ==  eHTMLTag_base     ||
-      type ==  eHTMLTag_basefont ||
-      type ==  eHTMLTag_br       ||
-      type ==  eHTMLTag_col      ||
-      type ==  eHTMLTag_frame    ||
-      type ==  eHTMLTag_hr       ||
-      type ==  eHTMLTag_img      ||
-      type ==  eHTMLTag_image    ||
-      type ==  eHTMLTag_input    ||
-      type ==  eHTMLTag_isindex  ||
-      type ==  eHTMLTag_link     ||
-      type ==  eHTMLTag_meta     ||
-      type ==  eHTMLTag_param    ||
-      type ==  eHTMLTag_sound)
-  {
-    AddStartTag(aNode);
-    mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
-  }
-  else if (type == eHTMLTag_entity)
-  {
-    Write('&');
-    const nsAReadableString& entity = aNode.GetText();
-    mColPos += Write(entity) + 1;
-    // Don't write the semicolon;
-    // rely on the DTD to include it if one is wanted.
-  }
-  else if (type == eHTMLTag_text)
-  {
-    if ((mHTMLStackPos > 0)
-        && (mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_doctypeDecl || mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_markupDecl)
-        && (mFlags & nsIDocumentEncoder::OutputSelectionOnly))
-      return NS_OK;
-
-    const nsAReadableString& text = aNode.GetText();
-    if (mPreLevel > 0)
-    {
-      Write(text);
-      mColPos += text.Length();
-    }
-    else if (!mDoFormat)
-    {
-      if (HasLongLines(text))
-      {
-        WriteWrapped(text);
-      }
-      else
-      {
-        Write(text);
-        mColPos += text.Length();
-      }
-    }
-    else
-    {
-      WriteWrapped(text);
-    }
-  }
-  else if (type == eHTMLTag_whitespace)
-  {
-    if (!mDoFormat || mPreLevel > 0)
-    {
-      const nsAReadableString& text = aNode.GetText();
-      Write(text);
-      mColPos += text.Length();
-    }
-  }
-  else if (type == eHTMLTag_newline)
-  {
-    if (!mDoFormat || mPreLevel > 0)
-    {
-      Write(mLineBreak);
-      mColPos = 0;
-    }
-  }
-
-  return NS_OK;
-}
-
-// See if the string has any lines longer than longLineLen:
-// if so, we presume formatting is wonky (e.g. the node has been edited)
-// and we'd better rewrap the whole text node.
-PRBool nsHTMLContentSinkStream::HasLongLines(const nsAReadableString& text)
-{
-  const PRUint32 longLineLen = 128;
-  PRUint32 start=0;
-  PRUint32 theLen=text.Length();
-  for (start = 0; start < theLen; )
-  {
-    PRInt32 eol = text.FindChar('\n', start);
-    if (eol < 0) eol = text.Length();
-    if ((PRUint32)(eol - start) > longLineLen)
-      return PR_TRUE;
-    start = eol+1;
-  }
-  return PR_FALSE;
-}
-
-void nsHTMLContentSinkStream::WriteWrapped(const nsAReadableString& text)
-{
-      // 1. Determine the length of the input string
-  PRInt32 length = text.Length();
-
-  // 2. If the offset plus the length of the text is smaller
-  // than the max then just add it 
-  if (mColPos + length < mMaxColumn)
-  {
-    Write(text);
-    mColPos += text.Length();
-  }
-  else
-  {
-    nsAutoString  str(text);
-    PRBool    done = PR_FALSE;
-    PRInt32   indx = 0;
-    PRInt32   offset = mColPos;
-
-    while (!done)
-    {        
-      // find the next break
-      PRInt32 start = mMaxColumn-offset;
-      if (start < 0)
-        start = 0;
-          
-      indx = str.FindChar(' ', PR_FALSE, start);
-
-      // if there is no break than just add it
-      if (indx == kNotFound)
-      {
-        Write(str);
-        mColPos += str.Length();
-        done = PR_TRUE;
-      }
-      else
-      {
-        // make first equal to the str from the 
-        // beginning to the index
-        nsString  first = str;
-
-        first.Truncate(indx);
-  
-        Write(first);
-        Write(mLineBreak);
-        mColPos = 0;
-  
-        // cut the string from the beginning to the index
-        str.Cut(0,indx);
-        offset = 0;
-      }
-    }
-  }
-}
-
-/**
- *  This gets called by the parser when you want to add
- *  a PI node to the current container in the content
- *  model.
- *  
- *  @updated gess 3/25/98
- *  @param   
- *  @return  
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::AddProcessingInstruction(const nsIParserNode& aNode){
-
-#ifdef VERBOSE_DEBUG
-  DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
-#endif
-
-  return NS_OK;
-}
-
-/**
- *  This gets called by the parser when it encounters
- *  a DOCTYPE declaration in the HTML document.
- */
-
-NS_IMETHODIMP
-nsHTMLContentSinkStream::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
-{
-#ifdef VERBOSE_DEBUG
-  DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
-#endif
-   
- // Write(" parser( do_CreateInstance(kCParserCID, &rv) );
-    if (NS_FAILED(rv)) return rv;
-    if (!parser) return NS_ERROR_FAILURE;
-
-    nsAutoString htmlmime (NS_LITERAL_STRING("text/html"));
-    rv = parser->CreateCompatibleDTD(&mDTD, 0, eViewNormal,
-                                     &htmlmime, eDTDMode_transitional);
-  /* XXX Note: We output linebreaks for blocks.
-     I.e. we output linebreaks for "unknown" inline tags.
-     I just hunted such a bug for , same for ,  etc..
-     Better fallback to inline. /BenB */
-    if (NS_FAILED(rv) || !mDTD)
-      return PR_FALSE;
-  }
-
-  // Now we can get the inline status from the DTD:
-  return mDTD->IsBlockElement(aTag, eHTMLTag_unknown);
-}
-
-/**
-  * **** Pretty Printing Methods ******
-  *
-  */
-
-/**
-  * Desired line break state before the open tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakBeforeOpen(eHTMLTags aTag)
-{
- PRBool  result = PR_FALSE;
-  switch (aTag)
-  {
-    case  eHTMLTag_html:
-      result = PR_FALSE;
-      break;
-    case  eHTMLTag_title:
-      result = PR_TRUE;
-      break;
-    default:
-      result = IsBlockLevel(aTag);
-  }
-  return result;
-}
-
-/**
-  * Desired line break state after the open tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakAfterOpen(eHTMLTags aTag)
-{
-  PRBool  result = PR_FALSE;
-  switch (aTag)
-  {
-    case eHTMLTag_html:
-    case eHTMLTag_head:
-    case eHTMLTag_body:
-    case eHTMLTag_ul:
-    case eHTMLTag_ol:
-    case eHTMLTag_table:
-    case eHTMLTag_tbody:
-    case eHTMLTag_style:
-    case eHTMLTag_tr:
-    case eHTMLTag_br:
-      result = PR_TRUE;
-      break;
-
-    default:
-      break;
-  }
-  return result;
-}
-
-/**
-  * Desired line break state before the close tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakBeforeClose(eHTMLTags aTag)
-{
-  PRBool  result = PR_FALSE;
-
-  switch (aTag)
-  {
-    case eHTMLTag_html:
-    case eHTMLTag_head:
-    case eHTMLTag_body:
-    case eHTMLTag_ul:
-    case eHTMLTag_ol:
-    case eHTMLTag_table:
-    case eHTMLTag_tbody:
-    case eHTMLTag_style:
-      result = PR_TRUE;
-      break;
-
-    default:
-      break;
-  }
-  return result;
-}
-
-/**
-  * Desired line break state after the close tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakAfterClose(eHTMLTags aTag)
-{
-  PRBool  result = PR_FALSE;
-
-  switch (aTag)
-  {
-    case eHTMLTag_html:
-    case eHTMLTag_head:
-    case eHTMLTag_body:
-    case eHTMLTag_tr:
-    case eHTMLTag_th:
-    case eHTMLTag_td:
-    case eHTMLTag_pre:
-    case eHTMLTag_title:
-    case eHTMLTag_meta:
-    case eHTMLTag_li:
-    case eHTMLTag_dt:
-    case eHTMLTag_dd:
-    case eHTMLTag_blockquote:
-    case eHTMLTag_p:
-    case eHTMLTag_div:
-      result = PR_TRUE;
-    break;
-
-    default:
-      result = IsBlockLevel(aTag);
-  }
-  return result;
-}
-
-/**
-  * Indent/outdent when the open/close tags are encountered.
-  * This implies that BreakAfterOpen() and BreakBeforeClose()
-  * are true no matter what those methods return.
-  */
-PRBool nsHTMLContentSinkStream::IndentChildren(eHTMLTags aTag)
-{
-  PRBool result = PR_FALSE;
-
-  switch (aTag)
-  {
-    case eHTMLTag_head:
-    case eHTMLTag_table:
-    case eHTMLTag_tr:
-    case eHTMLTag_ul:
-    case eHTMLTag_ol:
-    case eHTMLTag_tbody:
-    case eHTMLTag_form:
-    case eHTMLTag_frameset:
-    case eHTMLTag_li:
-    case eHTMLTag_dt:
-    case eHTMLTag_dd:
-    case eHTMLTag_blockquote:
-      result = PR_TRUE;      
-      break;
-
-    default:
-      result = PR_FALSE;
-      break;
-  }
-  return result;  
-}
-
-/**
-  * This method gets called when the parser begins the process
-  * of building the content model via the content sink.
-  *
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::WillBuildModel(void)
-{
-  mTabLevel=-1;
-
-  return NS_OK;
-}
-
-
-/**
-  * This method gets called when the parser concludes the process
-  * of building the content model via the content sink.
-  *
-  * @param  aQualityLevel describes how well formed the doc was.
-  *         0=GOOD; 1=FAIR; 2=POOR;
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::DidBuildModel(PRInt32 aQualityLevel) {
-  return NS_OK;
-}
-
-
-/**
-  * This method gets called when the parser gets i/o blocked,
-  * and wants to notify the sink that it may be a while before
-  * more data is available.
-  *
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::WillInterrupt(void) {
-  return NS_OK;
-}
-
-
-/**
-  * This method gets called when the parser i/o gets unblocked,
-  * and we're about to start dumping content again to the sink.
-  *
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::WillResume(void) {
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsHTMLContentSinkStream::SetParser(nsIParser* aParser) {
-  return NS_OK;
-}
-
-NS_IMETHODIMP 
-nsHTMLContentSinkStream::NotifyError(const nsParserError* aError)
-{
-  return NS_OK;
-}
-
diff --git a/htmlparser/src/nsViewSourceHTML.cpp b/htmlparser/src/nsViewSourceHTML.cpp
index a281af4f712..9e7baa2b6bf 100644
--- a/htmlparser/src/nsViewSourceHTML.cpp
+++ b/htmlparser/src/nsViewSourceHTML.cpp
@@ -1203,7 +1203,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
       {
         nsAutoString theStr;
         theStr.Assign(aToken->GetStringValue());
-        if(Compare(theStr, NS_LITERAL_STRING("XI"), nsCaseInsensitiveStringComparator()) != 0) {
+        if(!theStr.Equals(NS_LITERAL_STRING("XI"), nsCaseInsensitiveStringComparator())) {
           PRUnichar theChar=theStr.CharAt(0);
           if((nsCRT::IsAsciiDigit(theChar)) || ('X'==theChar) || ('x'==theChar)){
             theStr.Assign(NS_LITERAL_STRING("#") + theStr);
diff --git a/intl/chardet/src/nsMetaCharsetObserver.cpp b/intl/chardet/src/nsMetaCharsetObserver.cpp
index 74073789e6a..cb2e5cbf006 100644
--- a/intl/chardet/src/nsMetaCharsetObserver.cpp
+++ b/intl/chardet/src/nsMetaCharsetObserver.cpp
@@ -106,7 +106,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
                      const PRUnichar* valueArray[])
 {
   
-    if(0 != Compare(nsDependentString(aTag), NS_LITERAL_STRING("META"), nsCaseInsensitiveStringComparator())) 
+    if(!nsDependentString(aTag).Equals(NS_LITERAL_STRING("META"),
+                                       nsCaseInsensitiveStringComparator())) 
         return NS_ERROR_ILLEGAL_VALUE;
     else
         return Notify(aDocumentID, numOfAttributes, nameArray, valueArray);
@@ -147,8 +148,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
                      const PRUnichar* aTag, 
                      const nsStringArray* keys, const nsStringArray* values)
 {
-    if(0 != Compare(nsDependentString(aTag), NS_LITERAL_STRING("META"),
-                    nsCaseInsensitiveStringComparator())) 
+    if(!nsDependentString(aTag).Equals(NS_LITERAL_STRING("META"),
+                                       nsCaseInsensitiveStringComparator())) 
         return NS_ERROR_ILLEGAL_VALUE;
     else
         return Notify(aWebShell, aChannel, keys, values);
@@ -215,17 +216,14 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
         while(IS_SPACE_CHARS(*keyStr)) 
           keyStr++;
 
-        if(0 == Compare(Substring(keyStr, keyStr+10),
-                        NS_LITERAL_STRING("HTTP-EQUIV"),
-                        nsCaseInsensitiveStringComparator()))
+        if(Substring(keyStr, keyStr+10).Equals(NS_LITERAL_STRING("HTTP-EQUIV"),
+                                               nsCaseInsensitiveStringComparator()))
               httpEquivValue = values->StringAt(i)->get();
-        else if(0 == Compare(Substring(keyStr, keyStr+7),
-                             NS_LITERAL_STRING("content"),
-                             nsCaseInsensitiveStringComparator()))
+        else if(Substring(keyStr, keyStr+7).Equals(NS_LITERAL_STRING("content"),
+                                                   nsCaseInsensitiveStringComparator()))
               contentValue = values->StringAt(i)->get();
-        else if (0 == Compare(Substring(keyStr, keyStr+7),
-                              NS_LITERAL_STRING("charset"),
-                              nsCaseInsensitiveStringComparator()))
+        else if (Substring(keyStr, keyStr+7).Equals(NS_LITERAL_STRING("charset"),
+                                                    nsCaseInsensitiveStringComparator()))
               charsetValue = values->StringAt(i)->get();
       }
       NS_NAMED_LITERAL_STRING(contenttype, "Content-Type");
@@ -241,26 +239,26 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
 
       if(
           // first try unquoted strings
-         ((0==Compare(Substring(httpEquivValue,httpEquivValue+contenttype.Length()),
-                      contenttype,
-                      nsCaseInsensitiveStringComparator())) ||
+         ((Substring(httpEquivValue,
+                     httpEquivValue+contenttype.Length()).Equals(contenttype,
+                                                                 nsCaseInsensitiveStringComparator())) ||
           // now try "quoted" or 'quoted' strings
           (( (httpEquivValue[0]=='\'') ||
              (httpEquivValue[0]=='\"') ) && 
-           (0==Compare(Substring(httpEquivValue+1, httpEquivValue+1+contenttype.Length()),
-                       contenttype,
-                       nsCaseInsensitiveStringComparator()))
+           (Substring(httpEquivValue+1,
+                      httpEquivValue+1+contenttype.Length()).Equals(contenttype,
+                                                                    nsCaseInsensitiveStringComparator()))
           )) &&
           // first try unquoted strings
-         ((0==Compare(Substring(contentValue,contentValue+texthtml.Length()),
-                      texthtml,
-                      nsCaseInsensitiveStringComparator())) ||
+         ((Substring(contentValue,
+                     contentValue+texthtml.Length()).Equals(texthtml,
+                                                            nsCaseInsensitiveStringComparator())) ||
           // now try "quoted" or 'quoted' strings
           (((contentValue[0]=='\'') ||
             (contentValue[0]=='\"'))&&
-           (0==Compare(Substring(contentValue+1, contentValue+1+texthtml.Length()),
-                       texthtml,
-                       nsCaseInsensitiveStringComparator()))
+           (Substring(contentValue+1,
+                      contentValue+1+texthtml.Length()).Equals(texthtml,
+                                                               nsCaseInsensitiveStringComparator()))
           ))
         )
       {
@@ -352,8 +350,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag(
     // e.g. 
     PRInt32 numOfAttributes = keys->Count();
     if ((numOfAttributes >= 3) &&
-        (0 == Compare(*keys->StringAt(0), NS_LITERAL_STRING("charset"),
-                      nsCaseInsensitiveStringComparator())))
+        (keys->StringAt(0)->Equals(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 fa12c04a90c..aa437feccc1 100644
--- a/intl/chardet/src/nsXMLEncodingObserver.cpp
+++ b/intl/chardet/src/nsXMLEncodingObserver.cpp
@@ -94,8 +94,8 @@ NS_IMETHODIMP nsXMLEncodingObserver::Notify(
                      const PRUnichar* nameArray[], 
                      const PRUnichar* valueArray[])
 {
-    if(0 != Compare(nsDependentString(aTag), NS_LITERAL_STRING("?XML"),
-                    nsCaseInsensitiveStringComparator())) 
+    if(!nsDependentString(aTag).Equals(NS_LITERAL_STRING("?XML"),
+                                       nsCaseInsensitiveStringComparator())) 
         return NS_ERROR_ILLEGAL_VALUE;
     else
         return Notify(aDocumentID, numOfAttributes, nameArray, valueArray);
@@ -143,8 +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==Compare(nsDependentString(nameArray[i]), NS_LITERAL_STRING("encoding"),
-                              nsCaseInsensitiveStringComparator())) { 
+         } else if(nsDependentString(nameArray[i]).Equals(NS_LITERAL_STRING("encoding"),
+                                                          nsCaseInsensitiveStringComparator())) { 
            bGotEncoding = PR_TRUE;
            encoding = valueArray[i];
          }
diff --git a/intl/locale/src/unix/nsCollationUnix.cpp b/intl/locale/src/unix/nsCollationUnix.cpp
index a73e33c6a6a..392e0420ca4 100644
--- a/intl/locale/src/unix/nsCollationUnix.cpp
+++ b/intl/locale/src/unix/nsCollationUnix.cpp
@@ -96,7 +96,9 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale)
     PRUnichar *prefValue;
     res = prefs->GetLocalizedUnicharPref("intl.collationOption", &prefValue);
     if (NS_SUCCEEDED(res)) {
-      mUseCodePointOrder = (Compare(nsDependentString(prefValue), NS_LITERAL_STRING("useCodePointOrder"), nsCaseInsensitiveStringComparator())==0);
+      mUseCodePointOrder =
+        nsDependentString(prefValue).Equals(NS_LITERAL_STRING("useCodePointOrder"),
+                                            nsCaseInsensitiveStringComparator());
       nsMemory::Free(prefValue);
     }
   }
diff --git a/intl/uconv/src/nsCharsetAliasImp.cpp b/intl/uconv/src/nsCharsetAliasImp.cpp
index a2a479348b6..813c572f8ab 100644
--- a/intl/uconv/src/nsCharsetAliasImp.cpp
+++ b/intl/uconv/src/nsCharsetAliasImp.cpp
@@ -127,7 +127,7 @@ NS_IMETHODIMP nsCharsetAlias2::Equals(const nsAReadableString& aCharset1, const
 {
    nsresult res = NS_OK;
 
-   if(Compare(aCharset1, aCharset2, nsCaseInsensitiveStringComparator()) == 0) {
+   if(aCharset1.Equals(aCharset2, nsCaseInsensitiveStringComparator())) {
       *oResult = PR_TRUE;
       return res;
    }
diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp
index 87477451ebd..bccbd6cf1a6 100644
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -1462,10 +1462,10 @@ nsObjectFrame::IsHidden() const
     // not to hide the  once you'd put the 'hidden' attribute
     // on the tag...
       // these |NS_ConvertASCIItoUCS2|s can't be |NS_LITERAL_STRING|s until |EqualsIgnoreCase| get's fixed
-    if (hidden.Length() &&
-        (Compare(hidden, NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator()) != 0) &&
-        (Compare(hidden, NS_LITERAL_STRING("no"), nsCaseInsensitiveStringComparator()) != 0) &&
-        (Compare(hidden, NS_LITERAL_STRING("off"), nsCaseInsensitiveStringComparator()) != 0)) {
+    if (!hidden.IsEmpty() &&
+        !hidden.Equals(NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator()) &&
+        !hidden.Equals(NS_LITERAL_STRING("no"), nsCaseInsensitiveStringComparator()) &&
+        !hidden.Equals(NS_LITERAL_STRING("off"), nsCaseInsensitiveStringComparator())) {
       // The  or  is hidden.
       return PR_TRUE;
     }
diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp
index 87477451ebd..bccbd6cf1a6 100644
--- a/layout/html/base/src/nsObjectFrame.cpp
+++ b/layout/html/base/src/nsObjectFrame.cpp
@@ -1462,10 +1462,10 @@ nsObjectFrame::IsHidden() const
     // not to hide the  once you'd put the 'hidden' attribute
     // on the tag...
       // these |NS_ConvertASCIItoUCS2|s can't be |NS_LITERAL_STRING|s until |EqualsIgnoreCase| get's fixed
-    if (hidden.Length() &&
-        (Compare(hidden, NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator()) != 0) &&
-        (Compare(hidden, NS_LITERAL_STRING("no"), nsCaseInsensitiveStringComparator()) != 0) &&
-        (Compare(hidden, NS_LITERAL_STRING("off"), nsCaseInsensitiveStringComparator()) != 0)) {
+    if (!hidden.IsEmpty() &&
+        !hidden.Equals(NS_LITERAL_STRING("false"), nsCaseInsensitiveStringComparator()) &&
+        !hidden.Equals(NS_LITERAL_STRING("no"), nsCaseInsensitiveStringComparator()) &&
+        !hidden.Equals(NS_LITERAL_STRING("off"), nsCaseInsensitiveStringComparator())) {
       // The  or  is hidden.
       return PR_TRUE;
     }
diff --git a/layout/style/nsCSSDeclaration.cpp b/layout/style/nsCSSDeclaration.cpp
index a04f0fd9a59..20675c406d1 100644
--- a/layout/style/nsCSSDeclaration.cpp
+++ b/layout/style/nsCSSDeclaration.cpp
@@ -5521,7 +5521,7 @@ nsCSSDeclaration::TryBackgroundPosition(nsAWritableString & aString,
     AppendValueToString(eCSSProperty_background_x_position, backgroundXValue);
     AppendValueToString(eCSSProperty_background_y_position, backgroundYValue);
     aString.Append(backgroundYValue);
-    if (Compare(backgroundXValue, backgroundYValue, nsCaseInsensitiveStringComparator())) {
+    if (!backgroundXValue.Equals(backgroundYValue, nsCaseInsensitiveStringComparator())) {
       // the two values are different
       aString.Append(PRUnichar(' '));
       aString.Append(backgroundXValue);
diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp
index 6a6b7dc2d6d..d3d482f1aca 100644
--- a/layout/style/nsCSSLoader.cpp
+++ b/layout/style/nsCSSLoader.cpp
@@ -638,9 +638,8 @@ SheetLoadData::OnStreamComplete(nsIStreamLoader* aLoader,
       }
     }
     if (mLoader->mNavQuirkMode ||
-        Compare(contentType,
-                NS_LITERAL_CSTRING("text/css"),
-                nsCaseInsensitiveCStringComparator()) == 0 ||
+        contentType.Equals(NS_LITERAL_CSTRING("text/css"),
+                           nsCaseInsensitiveCStringComparator()) ||
         contentType.IsEmpty()) {
       /*
        * First determine the charset (if one is indicated)
diff --git a/layout/style/nsCSSStruct.cpp b/layout/style/nsCSSStruct.cpp
index a04f0fd9a59..20675c406d1 100644
--- a/layout/style/nsCSSStruct.cpp
+++ b/layout/style/nsCSSStruct.cpp
@@ -5521,7 +5521,7 @@ nsCSSDeclaration::TryBackgroundPosition(nsAWritableString & aString,
     AppendValueToString(eCSSProperty_background_x_position, backgroundXValue);
     AppendValueToString(eCSSProperty_background_y_position, backgroundYValue);
     aString.Append(backgroundYValue);
-    if (Compare(backgroundXValue, backgroundYValue, nsCaseInsensitiveStringComparator())) {
+    if (!backgroundXValue.Equals(backgroundYValue, nsCaseInsensitiveStringComparator())) {
       // the two values are different
       aString.Append(PRUnichar(' '));
       aString.Append(backgroundXValue);
diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp
index 3cce72167e6..952aad603de 100644
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -201,9 +201,8 @@ PRBool AtomKey_base::Equals(const nsHashKey* aKey) const
   const PRUnichar *theirStr = nsnull;
   theirAtom->GetUnicode(&theirStr);
 
-  return Compare(nsDependentString(myStr),
-                 nsDependentString(theirStr),
-                 nsCaseInsensitiveStringComparator()) == 0;
+  return nsDependentString(myStr).Equals(nsDependentString(theirStr),
+                                         nsCaseInsensitiveStringComparator());
 }
 
 
@@ -3352,9 +3351,8 @@ static PRBool ValueIncludes(const nsString& aValueList, const nsString& aValue,
         }
       }
       else {
-        if (!Compare(nsDependentString(value),
-                     nsDependentString(start),
-                     nsCaseInsensitiveStringComparator())) {
+        if (nsDependentString(value).Equals(nsDependentString(start),
+                                            nsCaseInsensitiveStringComparator())) {
           return PR_TRUE;
         }
       }
@@ -3648,9 +3646,9 @@ static PRBool SelectorMatches(RuleProcessorData &data,
                     break;
                   }
                   if (isCaseSensitive)
-                    result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsDefaultStringComparator()));
+                    result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsDefaultStringComparator()));
                   else
-                    result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsCaseInsensitiveStringComparator()));
+                    result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsCaseInsensitiveStringComparator()));
                 }
               }
               break;
@@ -3662,9 +3660,9 @@ static PRBool SelectorMatches(RuleProcessorData &data,
                   result = localFalse;
                 } else {
                   if (isCaseSensitive)
-                    result = PRBool(localTrue == !Compare(Substring(value, valLen - selLen, selLen), attr->mValue, nsDefaultStringComparator()));
+                    result = PRBool(localTrue == Substring(value, valLen - selLen, selLen).Equals(attr->mValue, nsDefaultStringComparator()));
                   else
-                    result = PRBool(localTrue == !Compare(Substring(value, valLen - selLen, selLen), attr->mValue, nsCaseInsensitiveStringComparator()));
+                    result = PRBool(localTrue == Substring(value, valLen - selLen, selLen).Equals(attr->mValue, nsCaseInsensitiveStringComparator()));
                 }
               }
               break;
@@ -3676,9 +3674,9 @@ static PRBool SelectorMatches(RuleProcessorData &data,
                   result = localFalse;
                 } else {
                   if (isCaseSensitive)
-                    result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsDefaultStringComparator()));
+                    result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsDefaultStringComparator()));
                   else
-                    result = PRBool(localTrue == !Compare(Substring(value, 0, selLen), attr->mValue, nsCaseInsensitiveStringComparator()));
+                    result = PRBool(localTrue == Substring(value, 0, selLen).Equals(attr->mValue, nsCaseInsensitiveStringComparator()));
                 }
               }
               break;
@@ -3718,8 +3716,8 @@ static PRBool SelectorMatches(RuleProcessorData &data,
             const PRUnichar* id2Str;
             IDList->mAtom->GetUnicode(&id2Str);
             nsDependentString id2(id2Str);
-            if (localTrue ==
-                (Compare(id1, id2, nsCaseInsensitiveStringComparator()) != 0)) {
+            if (localTrue !=
+                id1.Equals(id2, nsCaseInsensitiveStringComparator())) {
               result = PR_FALSE;
               break;
             }
diff --git a/layout/xul/base/src/nsMenuBarFrame.cpp b/layout/xul/base/src/nsMenuBarFrame.cpp
index 326b60be9c9..accd412a0a7 100644
--- a/layout/xul/base/src/nsMenuBarFrame.cpp
+++ b/layout/xul/base/src/nsMenuBarFrame.cpp
@@ -266,7 +266,8 @@ nsMenuBarFrame::FindMenuWithShortcut(PRUint32 aLetter)
       if (!shortcutKey.IsEmpty()) {
         // We've got something.
         PRUnichar letter = PRUnichar(aLetter); // throw away the high-zero-fill
-        if ( Compare(shortcutKey, Substring(&letter, &letter+1), nsCaseInsensitiveStringComparator())==0 )  {
+        if ( shortcutKey.Equals(Substring(&letter, &letter+1),
+                                nsCaseInsensitiveStringComparator()) )  {
           // We match!
           nsCOMPtr menuFrame = do_QueryInterface(currFrame);
           if (menuFrame)
diff --git a/mailnews/absync/src/nsAbSync.cpp b/mailnews/absync/src/nsAbSync.cpp
index 842d76840a2..46f5a62e8a8 100644
--- a/mailnews/absync/src/nsAbSync.cpp
+++ b/mailnews/absync/src/nsAbSync.cpp
@@ -2816,15 +2816,20 @@ nsAbSync::GetTypeOfPhoneNumber(nsString tagName)
         continue;
       
       phoneType.Cut(0, loc+1);
-      if (!Compare(phoneType, NS_LITERAL_STRING(ABSYNC_HOME_PHONE_TYPE), nsCaseInsensitiveStringComparator()))
+      if (phoneType.Equals(NS_LITERAL_STRING(ABSYNC_HOME_PHONE_TYPE),
+                           nsCaseInsensitiveStringComparator()))
         return ABSYNC_HOME_PHONE_ID;
-      else if (!Compare(phoneType, NS_LITERAL_STRING(ABSYNC_WORK_PHONE_TYPE), nsCaseInsensitiveStringComparator()))
+      else if (phoneType.Equals(NS_LITERAL_STRING(ABSYNC_WORK_PHONE_TYPE),
+                                nsCaseInsensitiveStringComparator()))
         return ABSYNC_WORK_PHONE_ID;
-      else if (!Compare(phoneType, NS_LITERAL_STRING(ABSYNC_FAX_PHONE_TYPE), nsCaseInsensitiveStringComparator()))
+      else if (phoneType.Equals(NS_LITERAL_STRING(ABSYNC_FAX_PHONE_TYPE),
+                                nsCaseInsensitiveStringComparator()))
         return ABSYNC_FAX_PHONE_ID;
-      else if (!Compare(phoneType, NS_LITERAL_STRING(ABSYNC_PAGER_PHONE_TYPE), nsCaseInsensitiveStringComparator()))
+      else if (phoneType.Equals(NS_LITERAL_STRING(ABSYNC_PAGER_PHONE_TYPE),
+                                nsCaseInsensitiveStringComparator()))
         return ABSYNC_PAGER_PHONE_ID;
-      else if (!Compare(phoneType, NS_LITERAL_STRING(ABSYNC_CELL_PHONE_TYPE), nsCaseInsensitiveStringComparator()))
+      else if (phoneType.Equals(NS_LITERAL_STRING(ABSYNC_CELL_PHONE_TYPE),
+                                nsCaseInsensitiveStringComparator()))
         return ABSYNC_CELL_PHONE_ID;
     }
   }
@@ -2914,7 +2919,8 @@ nsAbSync::AddValueToNewCard(nsIAbCard *aCard, nsString *aTagName, nsString *aTag
     PR_FREEIF(tValue);
   }
 
-  if (!Compare(Substring(*aTagName, 0, 5), NS_LITERAL_STRING("phone"), nsCaseInsensitiveStringComparator()))
+  if (Substring(*aTagName, 0, 5).Equals(NS_LITERAL_STRING("phone"),
+                                        nsCaseInsensitiveStringComparator()))
   {
     nsString      tempVal;
     tempVal.Append(*aTagName +
diff --git a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp
index 6d8e721931b..750489fbc45 100644
--- a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp
+++ b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp
@@ -100,8 +100,8 @@ PRBool nsAbAutoCompleteSession::ItsADuplicate(PRUnichar* fullAddrStr, nsIAutoCom
                         rv = resultItem->GetValue(valueStr);
                         if (NS_SUCCEEDED(rv) && !valueStr.IsEmpty())
                         {
-                          if (Compare(nsDependentString(fullAddrStr), valueStr,
-                                      nsCaseInsensitiveStringComparator())==0)
+                          if (nsDependentString(fullAddrStr).Equals(valueStr,
+                                                                    nsCaseInsensitiveStringComparator()))
                             return PR_TRUE;
                         }
                     }
@@ -266,9 +266,9 @@ static PRBool CommonPrefix(const PRUnichar *aString, const PRUnichar *aSubstr, P
   if (!aSubstrLen || (nsCRT::strlen(aString) < NS_STATIC_CAST(PRUint32, aSubstrLen)))
     return PR_FALSE;
 
-  return (Compare(Substring(aString, aString+aSubstrLen),
-                  Substring(aSubstr, aSubstr+aSubstrLen),
-                  nsCaseInsensitiveStringComparator()) == 0);
+  return (Substring(aString,
+                    aString+aSubstrLen).Equals(Substring(aSubstr, aSubstr+aSubstrLen),
+                                               nsCaseInsensitiveStringComparator()));
 }
 
 
@@ -295,46 +295,48 @@ nsAbAutoCompleteSession::CheckEntry(nsAbAutoCompleteSearchString* searchStr,
     fullStringLen = searchStr->mFullStringLen;
   }
 
+  nsDependentString fullStringStr(fullString, fullStringLen);
+  
   // First check for a Nickname exact match
-  if (nickName && Compare(nsDependentString(fullString),
-                          nsDependentString(nickName),
-                          nsCaseInsensitiveStringComparator()) == 0)
+  if (nickName &&
+      fullStringStr.Equals(nsDependentString(nickName),
+                           nsCaseInsensitiveStringComparator()))
   {
     *matchType = NICKNAME_EXACT_MATCH;
     return PR_TRUE;
   }
 
   // Then check for a display Name exact match
-  if (displayName && Compare(nsDependentString(fullString),
-                             nsDependentString(displayName),
-                             nsCaseInsensitiveStringComparator()) == 0)
+  if (displayName &&
+      fullStringStr.Equals(nsDependentString(displayName),
+                           nsCaseInsensitiveStringComparator()))
   {
     *matchType = NAME_EXACT_MATCH;
     return PR_TRUE;
   }
 
   // Then check for a fisrt Name exact match
-  if (firstName && Compare(nsDependentString(fullString),
-                           nsDependentString(firstName),
-                           nsCaseInsensitiveStringComparator()) == 0)
+  if (firstName &&
+      fullStringStr.Equals(nsDependentString(firstName),
+                           nsCaseInsensitiveStringComparator()))
   {
     *matchType = NAME_EXACT_MATCH;
     return PR_TRUE;
   }
 
   // Then check for a last Name exact match
-  if (lastName && Compare(nsDependentString(fullString),
-                          nsDependentString(lastName),
-                          nsCaseInsensitiveStringComparator()) == 0)
+  if (lastName &&
+      fullStringStr.Equals(nsDependentString(lastName),
+                           nsCaseInsensitiveStringComparator()))
   {
     *matchType = NAME_EXACT_MATCH;
     return PR_TRUE;
   }
 
   // Then check for a Email exact match
-  if (emailAddress && Compare(nsDependentString(fullString),
-                              nsDependentString(emailAddress),
-                              nsCaseInsensitiveStringComparator()) == 0)
+  if (emailAddress &&
+      fullStringStr.Equals(nsDependentString(emailAddress),
+                           nsCaseInsensitiveStringComparator()))
   {
     *matchType = EMAIL_EXACT_MATCH;
     return PR_TRUE;
diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp
index 4766138c598..5186722d3c7 100644
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -1037,7 +1037,9 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa
                nsCOMPtrinboxFolder = do_QueryInterface(aSupport);
                nsXPIDLString folderName;
                inboxFolder->GetName(getter_Copies(folderName));
-               if (folderName && Compare(folderName, NS_LITERAL_STRING("INBOX"), nsCaseInsensitiveStringComparator()) ==0)
+               if (folderName &&
+                   folderName.Equals(NS_LITERAL_STRING("INBOX"),
+                                     nsCaseInsensitiveStringComparator()))
                {
                  rv1 = inboxFolder->Compact(urlListener, nsnull /* msgwindow */);
                  if (NS_SUCCEEDED(rv1))
diff --git a/mailnews/base/util/nsMsgFolder.cpp b/mailnews/base/util/nsMsgFolder.cpp
index cf8b7d43a73..f742d949d52 100644
--- a/mailnews/base/util/nsMsgFolder.cpp
+++ b/mailnews/base/util/nsMsgFolder.cpp
@@ -938,8 +938,9 @@ 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) && Compare(folderName, uniName,
-                                      nsCaseInsensitiveStringComparator()) == 0)
+			if (NS_SUCCEEDED(rv) &&
+          folderName.Equals(uniName,
+                            nsCaseInsensitiveStringComparator()))
 			{
 				*aChild = folder;
 				NS_ADDREF(*aChild);
diff --git a/mailnews/base/util/nsMsgI18N.cpp b/mailnews/base/util/nsMsgI18N.cpp
index 838e037a601..a7ebcc3d617 100644
--- a/mailnews/base/util/nsMsgI18N.cpp
+++ b/mailnews/base/util/nsMsgI18N.cpp
@@ -438,7 +438,8 @@ PRBool nsMsgI18Nmultibyte_charset(const char *charset)
     if (NS_SUCCEEDED(res)) {
       res = ccm2->GetCharsetData2(charsetAtom, NS_LITERAL_STRING(".isMultibyte").get(), &charsetData);
       if (NS_SUCCEEDED(res)) {
-        result = !Compare(charsetData, NS_LITERAL_STRING("true"), nsCaseInsensitiveStringComparator());
+        result = charsetData.Equals(NS_LITERAL_STRING("true"),
+                                    nsCaseInsensitiveStringComparator());
       }
     }
   }
diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp
index 8e557bc2bf4..dd1e11ab779 100644
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -2324,9 +2324,8 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
       {
         if (!fieldsFCC.IsEmpty())
         {
-          if (Compare(nsDependentString(fieldsFCC),
-                      NS_LITERAL_STRING("nocopy://"),
-                      nsCaseInsensitiveStringComparator()) == 0)
+          if (fieldsFCC.Equals(NS_LITERAL_STRING("nocopy://"),
+                               nsCaseInsensitiveStringComparator()))
           {
             compose->NotifyStateListeners(eComposeProcessDone, NS_OK);
             if (progress)
@@ -3801,7 +3800,8 @@ nsresult nsMsgCompose::TagConvertible(nsIDOMNode *node,  PRInt32 *_retval)
           if (NS_SUCCEEDED(pItem->GetNodeValue(typeValue)))
           {
             typeValue.StripChars("\"");
-            if (!Compare(typeValue, NS_LITERAL_STRING("cite"), nsCaseInsensitiveStringComparator()))
+            if (typeValue.Equals(NS_LITERAL_STRING("cite"),
+                                 nsCaseInsensitiveStringComparator()))
               *_retval = nsIMsgCompConvertible::Plain;
           }
         }
diff --git a/mailnews/compose/src/nsMsgSend.cpp b/mailnews/compose/src/nsMsgSend.cpp
index a9ff3948ac1..e79760a1f9e 100644
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1680,7 +1680,8 @@ nsMsgComposeAndSend::ProcessMultipartRelated(PRInt32 *aMailboxCount, PRInt32 *aN
       nsAutoString attributeValue;
       if (NS_SUCCEEDED(domElement->GetAttribute(NS_LITERAL_STRING("moz-do-not-send"), attributeValue)))
       {
-        if (!Compare(attributeValue, NS_LITERAL_STRING("true"), nsCaseInsensitiveStringComparator()))
+        if (attributeValue.Equals(NS_LITERAL_STRING("true"),
+                                  nsCaseInsensitiveStringComparator()))
           continue;
       }
     }
diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp
index 0562e3811b7..36d1661a5f3 100644
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -710,12 +710,12 @@ NS_IMETHODIMP nsImapMailFolder::CreateSubfolder(const PRUnichar* folderName, nsI
     nsresult rv = NS_ERROR_NULL_POINTER;
     if (!folderName) return rv;
 
-    if ( Compare(nsDependentString(folderName),NS_LITERAL_STRING("Trash"),nsCaseInsensitiveStringComparator()) == 0 )   // Trash , a special folder
+    if ( nsDependentString(folderName).Equals(NS_LITERAL_STRING("Trash"),nsCaseInsensitiveStringComparator()) )   // Trash , a special folder
     {
         AlertSpecialFolderExists(msgWindow);
         return NS_MSG_FOLDER_EXISTS;
     }
-    else if ( Compare(nsDependentString(folderName),NS_LITERAL_STRING("Inbox"),nsCaseInsensitiveStringComparator()) == 0 )  // Inbox, a special folder
+    else if ( nsDependentString(folderName).Equals(NS_LITERAL_STRING("Inbox"),nsCaseInsensitiveStringComparator()) )  // Inbox, a special folder
     {
         AlertSpecialFolderExists(msgWindow);
         return NS_MSG_FOLDER_EXISTS;
@@ -3923,9 +3923,8 @@ PRBool nsImapMailFolder::ShowDeletedMessages()
         {
           nsXPIDLString folderName;
           GetName(getter_Copies(folderName));
-          if (!Compare(Substring(folderName,0,convertedName.Length()),
-                       convertedName,
-                       nsCaseInsensitiveStringComparator()))
+          if (Substring(folderName,0,convertedName.Length()).Equals(convertedName,
+                                                                    nsCaseInsensitiveStringComparator()))
             showDeleted = PR_TRUE;
         }
       }
diff --git a/mailnews/import/eudora/src/nsEudoraCompose.cpp b/mailnews/import/eudora/src/nsEudoraCompose.cpp
index 85cdc2a9288..ea68be524be 100644
--- a/mailnews/import/eudora/src/nsEudoraCompose.cpp
+++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp
@@ -504,7 +504,7 @@ void nsEudoraCompose::ExtractType( nsString& str)
 	// valid multipart!
 	if (str.Length() > 10) {
 		str.Left( tStr, 10);
-		if (!Compare(tStr, NS_LITERAL_STRING("multipart/"), nsCaseInsensitiveStringComparator()))
+		if (tStr.Equals(NS_LITERAL_STRING("multipart/"), nsCaseInsensitiveStringComparator()))
 			str.Truncate();
 	}
 }
diff --git a/mailnews/import/eudora/src/nsEudoraMac.cpp b/mailnews/import/eudora/src/nsEudoraMac.cpp
index 8d2d7537586..940be7c2060 100644
--- a/mailnews/import/eudora/src/nsEudoraMac.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMac.cpp
@@ -1030,7 +1030,7 @@ PRBool nsEudoraMac::IsValidMailboxName( nsCString& fName)
 {
 	if (m_depth > 1)
 		return( PR_TRUE);
-	if (!Compare(fName, NS_LITERAL_CSTRING("Eudora Nicknames"), nsCaseInsensitiveCStringComparator()))
+	if (fName.Equals(NS_LITERAL_CSTRING("Eudora Nicknames"), nsCaseInsensitiveCStringComparator()))
 		return( PR_FALSE);
 	return( PR_TRUE);
 }
diff --git a/mailnews/import/eudora/src/nsEudoraWin32.cpp b/mailnews/import/eudora/src/nsEudoraWin32.cpp
index 8910eff507e..3784a61a386 100644
--- a/mailnews/import/eudora/src/nsEudoraWin32.cpp
+++ b/mailnews/import/eudora/src/nsEudoraWin32.cpp
@@ -694,7 +694,7 @@ void nsEudoraWin32::GetAccountName( const char *pSection, nsString& str)
 
 	nsCString	s(pSection);
 	
-	if (!Compare(s, NS_LITERAL_CSTRING("Settings"), nsCaseInsensitiveCStringComparator())) {
+	if (s.Equals(NS_LITERAL_CSTRING("Settings"), nsCaseInsensitiveCStringComparator())) {
 		str.Assign(NS_LITERAL_STRING("Eudora "));
 		str.AppendWithConversion( pSection);
 	}
@@ -703,7 +703,7 @@ void nsEudoraWin32::GetAccountName( const char *pSection, nsString& str)
 		str.AssignWithConversion(pSection);
 		if (s.Length() > 8) {
 			s.Left( tStr, 8); 
-			if (!Compare(tStr, NS_LITERAL_CSTRING("Persona-"), nsCaseInsensitiveCStringComparator())) {
+			if (tStr.Equals(NS_LITERAL_CSTRING("Persona-"), nsCaseInsensitiveCStringComparator())) {
 				s.Right( tStr, s.Length() - 8);
 				str.AssignWithConversion(tStr.get());
 			}
@@ -1378,9 +1378,8 @@ nsresult nsEudoraWin32::FoundAddressBook( nsIFileSpec *spec, const PRUnichar *pN
 		nsCRT::free( pLeaf);
 		nsString	tStr;
 		name.Right( tStr, 4);
-		if (! Compare(tStr,
-                      NS_LITERAL_STRING(".txt"),
-                      nsCaseInsensitiveStringComparator())) {
+		if (tStr.Equals(NS_LITERAL_STRING(".txt"),
+                        nsCaseInsensitiveStringComparator())) {
 			name.Left( tStr, name.Length() - 4);
 			name = tStr;
 		}
diff --git a/mailnews/import/oexpress/nsOEScanBoxes.cpp b/mailnews/import/oexpress/nsOEScanBoxes.cpp
index 88f178d0ed7..dc6006cec27 100644
--- a/mailnews/import/oexpress/nsOEScanBoxes.cpp
+++ b/mailnews/import/oexpress/nsOEScanBoxes.cpp
@@ -293,7 +293,7 @@ PRBool nsOEScanBoxes::FindMailBoxes( nsIFileSpec* descFile)
 		#endif
 		
 		pEntry->fileName.Right( ext, 4);
-		if (Compare(ext, mbxExt))
+		if (!ext.Equals(mbxExt))
 			pEntry->fileName.Append( ".mbx");		
 		
 		m_entryArray.AppendElement( pEntry);
diff --git a/mailnews/import/outlook/src/MapiApi.cpp b/mailnews/import/outlook/src/MapiApi.cpp
index 5e3deaeb84f..28e409b93d5 100644
--- a/mailnews/import/outlook/src/MapiApi.cpp
+++ b/mailnews/import/outlook/src/MapiApi.cpp
@@ -306,24 +306,25 @@ CGetStoreFoldersIter::CGetStoreFoldersIter( CMapiApi *pApi, CMapiFolderList& fol
 BOOL CGetStoreFoldersIter::ExcludeFolderClass( const PRUnichar *pName)
 {
 	BOOL bResult;
+    nsDependentString pNameStr(pName);
 	if (m_isMail) {
 		bResult = FALSE;
-        if (!Compare(nsDependentString(pName), NS_LITERAL_STRING("IPF.Appointment")))
+        if (pNameStr.Equals(NS_LITERAL_STRING("IPF.Appointment")))
 			bResult = TRUE;
-		else if (!Compare(nsDependentString(pName), NS_LITERAL_STRING("IPF.Contact")))
+		else if (pNameStr.Equals(NS_LITERAL_STRING("IPF.Contact")))
 			bResult = TRUE;
-		else if (!Compare(nsDependentString(pName), NS_LITERAL_STRING("IPF.Journal")))
+		else if (pNameStr.Equals(NS_LITERAL_STRING("IPF.Journal")))
 			bResult = TRUE;
-        else if (!Compare(nsDependentString(pName), NS_LITERAL_STRING("IPF.StickyNote")))
+        else if (pNameStr.Equals(NS_LITERAL_STRING("IPF.StickyNote")))
 			bResult = TRUE;
-		else if (!Compare(nsDependentString(pName), NS_LITERAL_STRING("IPF.Task")))
+		else if (pNameStr.Equals(NS_LITERAL_STRING("IPF.Task")))
 			bResult = TRUE;
 		// else if (!stricmp( pName, "IPF.Note"))
 		//	bResult = TRUE;
 	}
 	else {
 		bResult = TRUE;
-		if (!Compare( nsDependentString(pName), NS_LITERAL_STRING("IPF.Contact")))
+		if (pNameStr.Equals(NS_LITERAL_STRING("IPF.Contact")))
 			bResult = FALSE;
 	}
 
diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp
index c5a25783819..0062841a3b8 100644
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -801,8 +801,8 @@ nsMsgLocalMailFolder::CheckIfFolderExists(const PRUnichar *folderName, nsFileSpe
       PR_FREEIF(leaf);
 
       if (!leafName.IsEmpty() &&
-          Compare(nsDependentString(folderName), leafName,
-                  nsCaseInsensitiveStringComparator()) == 0)
+          leafName.Equals(nsDependentString(folderName), 
+                          nsCaseInsensitiveStringComparator()))
       {
            if (msgWindow)
               AlertFolderExists(msgWindow);
diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp
index 3ce71e8b808..9424a53485a 100644
--- a/modules/libjar/nsJAR.cpp
+++ b/modules/libjar/nsJAR.cpp
@@ -723,7 +723,8 @@ nsJAR::ParseOneFile(nsISignatureVerifier* verifier,
 
     //-- Lines to look for:
     // (1) Digest:
-    if (Compare(lineName, NS_LITERAL_CSTRING("SHA1-Digest"), nsCaseInsensitiveCStringComparator()) == 0) 
+    if (lineName.Equals(NS_LITERAL_CSTRING("SHA1-Digest"),
+                        nsCaseInsensitiveCStringComparator()))
     //-- This is a digest line, save the data in the appropriate place 
     {
       if(aFileType == JAR_MF)
@@ -739,7 +740,8 @@ nsJAR::ParseOneFile(nsISignatureVerifier* verifier,
     }
     
     // (2) Name: associates this manifest section with a file in the jar.
-    if (!foundName && Compare(lineName, NS_LITERAL_CSTRING("Name"), nsCaseInsensitiveCStringComparator()) == 0) 
+    if (!foundName && lineName.Equals(NS_LITERAL_CSTRING("Name"),
+                                      nsCaseInsensitiveCStringComparator())) 
     {
       curItemName = lineData;
       foundName = PR_TRUE;
@@ -749,9 +751,11 @@ nsJAR::ParseOneFile(nsISignatureVerifier* verifier,
     // (3) Magic: this may be an inline Javascript. 
     //     We can't do any other kind of magic.
     if ( aFileType == JAR_MF &&
-         Compare(lineName, NS_LITERAL_CSTRING("Magic"), nsCaseInsensitiveCStringComparator()) == 0) 
+         lineName.Equals(NS_LITERAL_CSTRING("Magic"),
+                         nsCaseInsensitiveCStringComparator()))
     {
-      if(Compare(lineData, NS_LITERAL_CSTRING("javascript"), nsCaseInsensitiveCStringComparator()) == 0)
+      if(lineData.Equals(NS_LITERAL_CSTRING("javascript"),
+                         nsCaseInsensitiveCStringComparator()))
         curItemMF->mType = JAR_EXTERNAL;
       else
         curItemMF->mType = JAR_INVALID;
diff --git a/netwerk/cache/src/nsCacheEntry.cpp b/netwerk/cache/src/nsCacheEntry.cpp
index 3131215e25c..c62a1907e07 100644
--- a/netwerk/cache/src/nsCacheEntry.cpp
+++ b/netwerk/cache/src/nsCacheEntry.cpp
@@ -591,7 +591,7 @@ nsCacheEntryHashTable::MatchEntry(PLDHashTable *       /* table */,
     NS_ASSERTION(key !=  nsnull, "### nsCacheEntryHashTable::MatchEntry : null key");
     nsCacheEntry *cacheEntry = ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry;
 
-    return Compare(*cacheEntry->mKey, *(nsCString *)key) == 0;
+    return cacheEntry->mKey->Equals(*(nsCString *)key);
 }
 
 
diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp
index 6effaa73c82..2813b875e7f 100644
--- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp
@@ -2132,7 +2132,7 @@ nsFtpState::SendFTPCommand(nsCString& command)
     
     // we don't want to log the password:
     nsCAutoString logcmd(command);
-    if (Compare(Substring(command, 0, 5), NS_LITERAL_CSTRING("PASS ")) == 0) 
+    if (Substring(command, 0, 5).Equals(NS_LITERAL_CSTRING("PASS "))) 
         logcmd = "PASS xxxxx";
     
     PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x)(dwait=%d) Writing \"%s\"\n", this, mWaitingForDConn, logcmd.get()));
diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
index dee8a652e5e..3f1f21384a6 100644
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -542,11 +542,10 @@ mozTXTToHTMLConv::ItMatchesDelimited(const PRUnichar * aInString,
           nsCRT::IsAsciiDigit(textAfterPos) ||
           textAfterPos == *rep
         ) ||
-        Compare(Substring(nsDependentString(aInString, aInLength),
-                          (before == LT_IGNORE ? 0 : 1),
-                          aRepLen),
-                nsDependentString(rep, aRepLen),
-                nsCaseInsensitiveStringComparator())
+        !Substring(nsDependentString(aInString, aInLength),
+                   (before == LT_IGNORE ? 0 : 1),
+                   aRepLen).Equals(nsDependentString(rep, aRepLen),
+                                   nsCaseInsensitiveStringComparator())
     )
     return PR_FALSE;
 
@@ -978,8 +977,9 @@ mozTXTToHTMLConv::CiteLevelTXT(const PRUnichar *line,
       const PRUnichar * indexString = &line[logLineStart];
            // here, |logLineStart < lineLength| is always true
       PRUint32 minlength = MinInt(6,nsCRT::strlen(indexString));
-      if (!Compare(Substring(indexString, indexString+minlength),
-                   Substring(NS_LITERAL_STRING(">From "), 0, minlength), nsCaseInsensitiveStringComparator()))
+      if (Substring(indexString,
+                    indexString+minlength).Equals(Substring(NS_LITERAL_STRING(">From "), 0, minlength),
+                                                  nsCaseInsensitiveStringComparator()))
         //XXX RFC2646
         moreCites = PR_FALSE;
       else
diff --git a/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/netwerk/streamconv/converters/nsUnknownDecoder.cpp
index 276196779c3..ce7778f147a 100644
--- a/netwerk/streamconv/converters/nsUnknownDecoder.cpp
+++ b/netwerk/streamconv/converters/nsUnknownDecoder.cpp
@@ -304,8 +304,10 @@ void nsUnknownDecoder::DetermineContentType(nsIRequest* request)
   //
   // If the buffer begins with a mailbox delimiter then it is not HTML
   //
-  else if (!Compare(Substring(str, 0, 5), NS_LITERAL_CSTRING("From "), nsCaseInsensitiveCStringComparator()) || 
-           !Compare(Substring(str, 0, 6), NS_LITERAL_CSTRING(">From "), nsCaseInsensitiveCStringComparator())) {
+  else if (Substring(str, 0, 5).Equals(NS_LITERAL_CSTRING("From "),
+                                       nsCaseInsensitiveCStringComparator()) ||
+           Substring(str, 0, 6).Equals(NS_LITERAL_CSTRING(">From "),
+                                       nsCaseInsensitiveCStringComparator())) {
     mContentType = TEXT_PLAIN;
   }
   //
diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp
index 3c5474218f0..e424a0e72bc 100644
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -1013,12 +1013,12 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
         if(theCount) {
           PRInt32 theIndex=0;
           for(theIndex=0;theIndex
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the NPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the NPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/**
- * MODULE NOTES:
- * 
- * This file declares the concrete HTMLContentSink class.
- * This class is used during the parsing process as the
- * primary interface between the parser and the content
- * model.
- */
-
-#include "nsHTMLContentSinkStream.h"
-#include "nsIParserNode.h"
-#include 
-#include "nsString.h"
-#include "nsReadableUtils.h"
-#include "nsIParser.h"
-#include "nsICharsetAlias.h"
-#include "nsIServiceManager.h"
-#include "nsIEntityConverter.h"
-#include "nsCRT.h"
-#include "nsIDocumentEncoder.h"   // for output flags
-#include "nsHTMLTokens.h"
-
-#include "nsIOutputStream.h"
-#include "nsFileStream.h"
-
-#include "nsNetUtil.h"           // for NS_MakeAbsoluteURI
-
-static NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
-static NS_DEFINE_CID(kEntityConverterCID, NS_ENTITYCONVERTER_CID);
-
-static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
-static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
-
-const  int            gTabSize=2;
-
-#define gMozDirty NS_LITERAL_STRING("_moz_dirty")
-
-/**
- *  This method gets called as part of our COM-like interfaces.
- *  Its purpose is to create an interface to parser object
- *  of some type.
- *  
- *  @update   gess 4/8/98
- *  @param    nsIID  id of object to discover
- *  @param    aInstancePtr ptr to newly discovered interface
- *  @return   NS_xxx result code
- */
-nsresult
-nsHTMLContentSinkStream::QueryInterface(const nsIID& aIID, void** aInstancePtr)
-{                                                                        
-  if (NULL == aInstancePtr) {                                            
-    return NS_ERROR_NULL_POINTER;                                        
-  }                                                                      
-  if (aIID.Equals(NS_GET_IID(nsISupports))) {
-    *aInstancePtr = (nsIContentSink*)(this);
-  }
-  else if (aIID.Equals(NS_GET_IID(nsIContentSink))) {
-    *aInstancePtr = (nsIContentSink*)(this);
-  }
-  else if (aIID.Equals(NS_GET_IID(nsIHTMLContentSink))) {
-    *aInstancePtr = (nsIHTMLContentSink*)(this);
-  }
-  else if (aIID.Equals(NS_GET_IID(nsIHTMLContentSinkStream))) {
-    *aInstancePtr = (nsIHTMLContentSinkStream*)(this);
-  }
-  else {
-    *aInstancePtr=0;
-    return NS_NOINTERFACE;
-  }
-  NS_ADDREF_THIS();
-  return NS_OK;                                                        
-}
-
-NS_IMPL_ADDREF(nsHTMLContentSinkStream)
-NS_IMPL_RELEASE(nsHTMLContentSinkStream)
-
-/**
- * Construct a content sink stream.
- * @update	gess7/7/98
- * @param 
- * @return
- */
-nsHTMLContentSinkStream::nsHTMLContentSinkStream()
-{
-  NS_INIT_REFCNT();
-  mLowerCaseTags = PR_TRUE;  
-  memset(mHTMLTagStack,0,sizeof(mHTMLTagStack));
-  memset(mDirtyStack,0,sizeof(mDirtyStack));
-  mDTD = 0;
-  mHTMLStackPos = 0;
-  mColPos = 0;
-  mIndent = 0;
-  mInBody = PR_FALSE;
-  mBuffer = nsnull;
-  mBufferSize = 0;
-  mBufferLength = 0;
-  mFlags = 0;
-  mHasOpenHtmlTag=PR_FALSE;
-}
-
-NS_IMETHODIMP
-nsHTMLContentSinkStream::Initialize(nsIOutputStream* aOutStream, 
-                                    nsAWritableString* aOutString,
-                                    const nsAReadableString* aCharsetOverride,
-                                    PRUint32 aFlags)
-{
-  mDoFormat = (aFlags & nsIDocumentEncoder::OutputFormatted) ? PR_TRUE
-                                                             : PR_FALSE;
-
-  mBodyOnly = (aFlags & nsIDocumentEncoder::OutputBodyOnly) ? PR_TRUE
-                                                            : PR_FALSE;
-  mMaxColumn = 72;
-  mFlags = aFlags;
-
-  // Set the line break character:
-  if ((mFlags & nsIDocumentEncoder::OutputCRLineBreak)
-      && (mFlags & nsIDocumentEncoder::OutputLFLineBreak)) // Windows/mail
-    mLineBreak.Assign(NS_LITERAL_STRING("\r\n"));
-  else if (mFlags & nsIDocumentEncoder::OutputCRLineBreak) // Mac
-    mLineBreak.Assign(NS_LITERAL_STRING("\r"));
-  else if (mFlags & nsIDocumentEncoder::OutputLFLineBreak) // Unix/DOM
-    mLineBreak.Assign(NS_LITERAL_STRING("\n"));
-  else
-    mLineBreak.AssignWithConversion(NS_LINEBREAK);         // Platform/default
-
-  mStream = aOutStream;
-  mString = aOutString;
-  if (aCharsetOverride != nsnull)
-    mCharsetOverride.Assign(*aCharsetOverride);
-
-  mPreLevel = 0;
-
-  return NS_OK;
-}
-
-nsHTMLContentSinkStream::~nsHTMLContentSinkStream()
-{
-  NS_IF_RELEASE(mDTD);
-
-  if (mBuffer)
-    delete [] mBuffer;
-}
-
-/**
- * This method tells the sink whether or not it is 
- * encoding an HTML fragment or the whole document.
- * By default, the entire document is encoded.
- *
- * @update 03/14/99 gpk
- * @param  aFlag set to true if only encoding a fragment
- */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::DoFragment(PRBool aFlag) 
-{
-  return NS_OK; 
-}
-
-/**
- * This gets called when handling illegal contents, especially
- * in dealing with tables. This method creates a new context.
- * 
- * @update 04/04/99 harishd
- * @param aPosition - The position from where the new context begins.
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::BeginContext(PRInt32 aPosition) 
-{
-  return NS_OK;
-}
-
-/**
- * This method terminates any new context that got created by
- * BeginContext and switches back to the main context.  
- *
- * @update 04/04/99 harishd
- * @param aPosition - Validates the end of a context.
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::EndContext(PRInt32 aPosition)
-{
-  return NS_OK;
-}
-
-/**
- * Initialize the Unicode encoder with our current mCharsetOverride.
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::InitEncoders()
-{
-  nsresult res;
-
-  // Initialize an entity encoder if we're using the string interface:
-  if (mString && (mFlags & nsIDocumentEncoder::OutputEncodeEntities))
-    res = nsComponentManager::CreateInstance(kEntityConverterCID, NULL, 
-                                             NS_GET_IID(nsIEntityConverter),
-                                             getter_AddRefs(mEntityConverter));
-
-  // Initialize a charset encoder if we're using the stream interface
-  if (mStream)
-  {
-    nsAutoString charsetName; charsetName.Assign(mCharsetOverride);
-    nsCOMPtr calias(do_GetService(kCharsetAliasCID, &res));
-    if (NS_SUCCEEDED(res) && calias) {
-      nsAutoString temp; temp.Assign(mCharsetOverride);
-      res = calias->GetPreferred(temp, charsetName);
-    }
-    if (NS_FAILED(res))
-    {
-      // failed - unknown alias , fallback to ISO-8859-1
-      charsetName.Assign(NS_LITERAL_STRING("ISO-8859-1"));
-    }
-
-    res = nsComponentManager::CreateInstance(kSaveAsCharsetCID, NULL, 
-                                             NS_GET_IID(nsISaveAsCharset),
-                                             getter_AddRefs(mCharsetEncoder));
-    if (NS_FAILED(res))
-      return res;
-    // SaveAsCharset requires a const char* in its first argument:
-    nsCAutoString charsetCString; charsetCString.AssignWithConversion(charsetName);
-    // For ISO-8859-1 only, convert to entity first (always generate entites like  ).
-    res = mCharsetEncoder->Init(charsetCString,
-                                charsetName.EqualsIgnoreCase("ISO-8859-1") ?
-                                nsISaveAsCharset::attr_htmlTextDefault :
-                                nsISaveAsCharset::attr_EntityAfterCharsetConv
-                                 + nsISaveAsCharset::attr_FallbackDecimalNCR,
-                                nsIEntityConverter::html32);
-  }
-
-  return res;
-}
-
-void nsHTMLContentSinkStream::EnsureBufferSize(PRInt32 aNewSize)
-{
-  if (mBufferSize < aNewSize) {
-    if(mBuffer) nsMemory::Free(mBuffer);
-
-    mBufferSize = 2*aNewSize+1; // make this twice as large
-    mBuffer = NS_STATIC_CAST(char *, nsMemory::Alloc(mBufferSize));
-    if(mBuffer){ 
-      mBuffer[0] = 0;
-    }
-  }
-}
-
-/**
- * Writes to the buffer/stream.
- * If we do both string and stream output, stream chars will override string.
- *
- * @param aString - the string to write.
- * @return The number of characters written.
- */
-PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString)
-{
-  if (mBodyOnly && !mInBody)
-    return 0;
-
-  int charsWritten = 0;
-
-  // For the string case, we don't want to do charset conversion,
-  // but we still want to encode entities.
-  if (mString)
-  {
-    if (!mEntityConverter && (mFlags & nsIDocumentEncoder::OutputEncodeEntities))
-      InitEncoders();
-    if (mEntityConverter && (mFlags & nsIDocumentEncoder::OutputEncodeEntities))
-    {
-      nsresult res;
-      PRUnichar *encodedBuffer = nsnull;
-      res = mEntityConverter->ConvertToEntities(PromiseFlatString(aString).get(),
-                                                nsIEntityConverter::html40Latin1,
-                                                &encodedBuffer);
-      if (NS_SUCCEEDED(res) && encodedBuffer)
-      {
-        PRInt32 len = nsCRT::strlen(encodedBuffer);
-        mString->Append(encodedBuffer, len);
-        nsCRT::free(encodedBuffer);
-        charsWritten = len;
-      }
-      else {
-        charsWritten = aString.Length();
-        mString->Append(aString);
-      }
-    }
-    else {
-      charsWritten = aString.Length();
-      mString->Append(aString);
-    }
-  }
-
-  if (!mStream)
-    return charsWritten;
-
-  // Now handle the stream case:
-  nsOutputStream out(mStream);
-
-  // If an encoder is being used then convert first convert the input string
-  char *encodedBuffer = nsnull;
-  nsresult res;
-
-  // Initialize the encoder if we haven't already
-  if (!mCharsetEncoder)
-    InitEncoders();
-
-  if (mCharsetEncoder)
-  {
-    // Call the converter to convert to the target charset.
-    // Convert() takes a char* output param even though it's writing unicode.
-    res = mCharsetEncoder->Convert(PromiseFlatString(aString).get(), &encodedBuffer);
-    if (NS_SUCCEEDED(res) && encodedBuffer)
-    {
-      charsWritten = nsCRT::strlen(encodedBuffer);
-      out.write(encodedBuffer, charsWritten);
-      nsCRT::free(encodedBuffer);
-    }
-
-    // If it didn't work, just write the unicode
-    else
-    {
-      charsWritten = aString.Length();
-      out.write(PromiseFlatString(aString).get(), charsWritten);
-    }
-  }
-
-  // If we couldn't get an encoder, just write the unicode
-  else
-  {
-    charsWritten = aString.Length();
-    out.write(PromiseFlatString(aString).get(), charsWritten);
-  }
-
-  return charsWritten;
-}
-
-void nsHTMLContentSinkStream::Write(const char* aData)
-{
-  if (mBodyOnly && !mInBody)
-    return;
-
-  if (mStream)
-  {
-    nsOutputStream out(mStream);
-    out << aData;
-  }
-  if (mString)
-  {
-    mString->Append(NS_ConvertASCIItoUCS2(aData));
-  }
-}
-
-void nsHTMLContentSinkStream::Write(char aData)
-{
-  if (mBodyOnly && !mInBody)
-    return;
-
-  if (mStream)
-  {
-    nsOutputStream out(mStream);
-    out << aData;
-  }
-  if (mString)
-  {
-    mString->Append(NS_ConvertASCIItoUCS2(aData));
-  }
-}
-
-/**
- * Write the attributes of the current tag.
- * 
- * @param aNode The parser node currently in play.
- */
-void nsHTMLContentSinkStream::WriteAttributes(const nsIParserNode& aNode)
-{
-  int theCount=aNode.GetAttributeCount();
-  if(theCount) {
-    int i=0;
-    for(i=0;i or 
, - // used by the editor. Bug 16988. Yuck. - // - if ((eHTMLTags)aNode.GetNodeType() == eHTMLTag_br - && (!Compare((key, NS_LITERAL_STRING("type"), nsCaseInsensitiveStringComparator()) - && value.Equals(NS_LITERAL_STRING("_moz"))))) - continue; - - if (mLowerCaseTags == PR_TRUE) - ToLowerCase(key); - else - ToUpperCase(key); - - EnsureBufferSize(key.Length() + 1); - key.ToCString(mBuffer,mBufferSize); - - // send to ouput " [KEY]=" - Write(' '); - Write(mBuffer); - mColPos += 1 + strlen(mBuffer) + 1; - - // Make all links absolute when converting only the selection: - if ((mFlags & nsIDocumentEncoder::OutputAbsoluteLinks) - && (!Compare(key, NS_LITERAL_STRING("href"), nsCaseInsensitiveStringComparator()) - || !Compare(key, NS_LITERAL_STRING("src"), nsCaseInsensitiveStringComparator()) - // Would be nice to handle OBJECT and APPLET tags, - // but that gets more complicated since we have to - // search the tag list for CODEBASE as well. - // For now, just leave them relative. - )) - { - if (mURI) - { - nsAutoString absURI; - if (NS_SUCCEEDED(NS_MakeAbsoluteURI(absURI, value, mURI)) - && !absURI.IsEmpty()) - value = absURI; - } - } - - if (value.Length() > 0) - { - Write(char(kEqual)); - mColPos += 1 + strlen(mBuffer) + 1; - - // send to ouput "\"[VALUE]\"" - Write('\"'); - Write(value); - Write('\"'); - } - - mColPos += 1 + strlen(mBuffer) + 1; - } - } -} - -/** - * This method gets called by the parser when it encounters - * a title tag and wants to set the document title in the sink. - * - * @update 04/30/99 gpk - * @param nsString reference to new title value - * @return PR_TRUE if successful. - */ -NS_IMETHODIMP -nsHTMLContentSinkStream::SetTitle(const nsString& aValue) -{ - const char* tagName = GetTagName(eHTMLTag_title); - Write(kLessThan); - Write(tagName); - Write(kGreaterThan); - - Write(aValue); - - Write(kLessThan); - Write(kForwardSlash); - Write(tagName); - Write(kGreaterThan); - - return NS_OK; -} - -/** - * This method is used to open the outer HTML container. - * - * XXX OpenHTML never gets called; AddStartTag gets called on - * XXX the html tag from OpenContainer, from nsXIFDTD::StartTopOfStack, - * XXX from nsXIFDTD::HandleStartToken. - * - * @param nsIParserNode reference to parser node interface - * @return PR_TRUE if successful. - */ -NS_IMETHODIMP -nsHTMLContentSinkStream::OpenHTML(const nsIParserNode& aNode) -{ - eHTMLTags tag = (eHTMLTags)aNode.GetNodeType(); - if (tag == eHTMLTag_html) - { - if(!mHasOpenHtmlTag) { - AddStartTag(aNode); - mHasOpenHtmlTag=PR_TRUE; - } - else { - PRInt32 ac=aNode.GetAttributeCount(); - if(ac>0) { - Write(kLessThan); - nsAutoString tagname; - tagname.AssignWithConversion(nsHTMLTags::GetStringValue(tag)); - Write(tagname); - WriteAttributes(aNode); - Write(kGreaterThan); - } - } - } - return NS_OK; -} - -/** - * All these HTML-specific methods may be called, or may not, - * depending on whether the parser is parsing XIF or HTML. - * So we can't depend on them; instead, we have Open/CloseContainer - * do all the specialized work, and the html-specific Open/Close - * methods must call the more general methods. - * - * Since there are so many of them, make macros: - */ - -#define USE_GENERAL_OPEN_METHOD(methodname, tagtype) \ -NS_IMETHODIMP nsHTMLContentSinkStream::methodname(const nsIParserNode& aNode) \ -{ \ - if ((eHTMLTags)aNode.GetNodeType() == tagtype) \ - AddStartTag(aNode); \ - return NS_OK; \ -} - -#define USE_GENERAL_CLOSE_METHOD(methodname, tagtype) \ -NS_IMETHODIMP nsHTMLContentSinkStream::methodname(const nsIParserNode& aNode) \ -{ \ - if ((eHTMLTags)aNode.GetNodeType() == tagtype) \ - AddEndTag(aNode); \ - return NS_OK; \ -} - -USE_GENERAL_CLOSE_METHOD(CloseHTML, eHTMLTag_html) -USE_GENERAL_OPEN_METHOD(OpenHead, eHTMLTag_head) -USE_GENERAL_CLOSE_METHOD(CloseHead, eHTMLTag_head) -USE_GENERAL_OPEN_METHOD(OpenBody, eHTMLTag_body) -USE_GENERAL_CLOSE_METHOD(CloseBody, eHTMLTag_body) -USE_GENERAL_OPEN_METHOD(OpenForm, eHTMLTag_form) -USE_GENERAL_CLOSE_METHOD(CloseForm, eHTMLTag_form) -USE_GENERAL_OPEN_METHOD(OpenMap, eHTMLTag_map) -USE_GENERAL_CLOSE_METHOD(CloseMap, eHTMLTag_map) -USE_GENERAL_OPEN_METHOD(OpenFrameset, eHTMLTag_frameset) -USE_GENERAL_CLOSE_METHOD(CloseFrameset, eHTMLTag_frameset) - -/** - * - * Check whether a node has the attribute _moz_dirty. - * If it does, we'll prettyprint it, otherwise we adhere to the - * surrounding text/whitespace/newline nodes provide formatting. - */ -PRBool nsHTMLContentSinkStream::IsDirty(const nsIParserNode& aNode) -{ - // Apparently there's no way to just ask for a particular attribute - // without looping over the list. - int theCount = aNode.GetAttributeCount(); - if (theCount) - { - for(int i=0; i < theCount; i++) - { - const nsAReadableString& key = (nsString&)aNode.GetKeyAt(i); - if (key == gMozDirty) - return PR_TRUE; - } - } - return PR_FALSE; -} - -void nsHTMLContentSinkStream::AddIndent() -{ - nsAutoString padding(NS_LITERAL_STRING(" ")); - for (PRInt32 i = mIndent; --i >= 0; ) - { - Write(padding); - mColPos += 2; - } -} - -void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode) -{ - eHTMLTags tag = (eHTMLTags)aNode.GetNodeType(); - PRBool isDirty = IsDirty(aNode); - - const nsAReadableString& name = aNode.GetText(); - nsAutoString tagName; - - if (tag == eHTMLTag_body) - mInBody = PR_TRUE; - - mHTMLTagStack[mHTMLStackPos] = tag; - mDirtyStack[mHTMLStackPos++] = isDirty; - tagName = name; - - if (tag == eHTMLTag_doctypeDecl || tag == eHTMLTag_markupDecl) - { - if (!(mFlags & nsIDocumentEncoder::OutputSelectionOnly)) - { - Write(" Markup Declaration Open. - } - return; - } - // Quoted plaintext mail/news lives in a pre tag. - // The editor has substituted
tags for all the newlines in the pre, - // in order to get clickable blank lines. - // We can't emit these
tags formatted, or we'll get - // double-spacing (one for the br, one for the line break); - // but we can't emit them unformatted, either, - // because then long quoted passages will make html source lines - // too long for news servers (and some mail servers) to handle. - // So we map all
tags inside
 to line breaks.
-  // If this turns out to be a problem, we could do this only if gMozDirty.
-  else if (tag == eHTMLTag_br && mPreLevel > 0)
-  {
-    Write(mLineBreak);
-    return;
-  }
-
-  if (mLowerCaseTags == PR_TRUE)
-    ToLowerCase(tagName);
-  else
-    ToUpperCase(tagName);
-
-#ifdef DEBUG_prettyprint
-  if (isDirty)
-    printf("AddStartTag(%s): BBO=%d, BAO=%d, BBC=%d, BAC=%d\n",
-           NS_LossyConvertUCS2toASCII(name).get(),
-           BreakBeforeOpen(tag),
-           BreakAfterOpen(tag),
-           BreakBeforeClose(tag),
-           BreakAfterClose(tag));
-#endif
-
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos != 0
-      && BreakBeforeOpen(tag))
-  {
-    Write(mLineBreak);
-    mColPos = 0;
-  }
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos == 0)
-    AddIndent();
-
-  EnsureBufferSize(tagName.Length() + 1);
-  tagName.ToCString(mBuffer,mBufferSize);
-
-  Write(kLessThan);
-  Write(mBuffer);
-
-  mColPos += 1 + tagName.Length();
-
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && tag == eHTMLTag_style)
-  {
-    Write(kGreaterThan);
-    Write(mLineBreak);
-    const   nsString& data = aNode.GetSkippedContent();
-    PRInt32 size = data.Length();
-    char*   buffer = new char[size+1];
-    if(buffer){
-      data.ToCString(buffer,size+1);
-      Write(buffer);
-      delete[] buffer;
-    }
-  }
-  else
-  {
-    WriteAttributes(aNode);
-    Write(kGreaterThan);
-    mColPos += 1;
-  }
-
-  if (tag == eHTMLTag_pre)
-    ++mPreLevel;
-
-  if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterOpen(tag)))
-  {
-    Write(mLineBreak);
-    mColPos = 0;
-  }
-
-  if (IndentChildren(tag))
-    mIndent++;
-}
-
-void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
-{
-  eHTMLTags         tag = (eHTMLTags)aNode.GetNodeType();
-  nsAutoString      tagName;
-  PRBool            isDirty = mDirtyStack[mHTMLStackPos-1];
-
-#ifdef DEBUG_prettyprint
-  if (isDirty)
-    printf("AddEndTag(%s): BBO=%d, BAO=%d, BBC=%d, BAC=%d\n",
-           (const char*)NS_ConvertUCS2toUTF8(aNode.GetText()),
-           BreakBeforeOpen(tag),
-           BreakAfterOpen(tag),
-           BreakBeforeClose(tag),
-           BreakAfterClose(tag));
-#endif
-
-  if (tag == eHTMLTag_unknown)
-  {
-    tagName.Assign(aNode.GetText());
-  }
-  else if (tag == eHTMLTag_pre)
-  {
-    --mPreLevel;
-    tagName.Assign(aNode.GetText());
-  }
-  else if (tag == eHTMLTag_comment)
-  {
-    tagName.Assign(NS_LITERAL_STRING("--"));
-  }
-  else if (tag == eHTMLTag_doctypeDecl || tag == eHTMLTag_markupDecl)
-  {
-    if (!(mFlags & nsIDocumentEncoder::OutputSelectionOnly))
-    {
-      Write(kGreaterThan);
-      Write(mLineBreak);
-    }
-    if ( mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_doctypeDecl || mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_markupDecl)
-    {
-      mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
-    }
-    return;
-  }
-  else if (tag == eHTMLTag_userdefined)
-  {
-    // nsHTMLTags::GetStringValue doesn't work for userdefined tags
-    tagName = aNode.GetText();
-  }
-  else
-  {
-    tagName.AssignWithConversion(nsHTMLTags::GetStringValue(tag));
-  }
-  if (mLowerCaseTags == PR_TRUE)
-    ToLowerCase(tagName);
-//  else
-//    ToUpperCase(tagName);
-
-  if (IndentChildren(tag))
-    mIndent--;
-
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && BreakBeforeClose(tag))
-  {
-    if (mColPos != 0)
-    {
-      Write(mLineBreak);
-      mColPos = 0;
-    }
-  }
-  if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos == 0)
-    AddIndent();
-
-  EnsureBufferSize(tagName.Length() + 1);
-  tagName.ToCString(mBuffer,mBufferSize);
-
-  if (tag != eHTMLTag_comment)
-  {
-    Write(kLessThan);
-    Write(kForwardSlash);
-    mColPos += 1 + 1;
-  }
-  
-  Write(mBuffer);
-  Write(kGreaterThan);
-
-  mColPos += strlen(mBuffer) + 1;
-
-  if (tag == eHTMLTag_body)
-    mInBody = PR_FALSE;
-
-  if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterClose(tag))
-      || tag == eHTMLTag_body || tag == eHTMLTag_html)
-  {
-    Write(mLineBreak);
-    mColPos = 0;
-  }
-  mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
-}
-
-/**
- *  This gets called by the parser when you want to add
- *  a leaf node to the current container in the content
- *  model.
- */
-nsresult
-nsHTMLContentSinkStream::AddLeaf(const nsIParserNode& aNode)
-{
-  eHTMLTags type = (eHTMLTags)aNode.GetNodeType();
-  eHTMLTags tag = eHTMLTag_unknown;
-  if (mHTMLStackPos > 0)
-    tag = mHTMLTagStack[mHTMLStackPos-1];
-  
-  if (type ==  eHTMLTag_area     ||
-      type ==  eHTMLTag_base     ||
-      type ==  eHTMLTag_basefont ||
-      type ==  eHTMLTag_br       ||
-      type ==  eHTMLTag_col      ||
-      type ==  eHTMLTag_frame    ||
-      type ==  eHTMLTag_hr       ||
-      type ==  eHTMLTag_img      ||
-      type ==  eHTMLTag_image    ||
-      type ==  eHTMLTag_input    ||
-      type ==  eHTMLTag_isindex  ||
-      type ==  eHTMLTag_link     ||
-      type ==  eHTMLTag_meta     ||
-      type ==  eHTMLTag_param    ||
-      type ==  eHTMLTag_sound)
-  {
-    AddStartTag(aNode);
-    mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
-  }
-  else if (type == eHTMLTag_entity)
-  {
-    Write('&');
-    const nsAReadableString& entity = aNode.GetText();
-    mColPos += Write(entity) + 1;
-    // Don't write the semicolon;
-    // rely on the DTD to include it if one is wanted.
-  }
-  else if (type == eHTMLTag_text)
-  {
-    if ((mHTMLStackPos > 0)
-        && (mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_doctypeDecl || mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_markupDecl)
-        && (mFlags & nsIDocumentEncoder::OutputSelectionOnly))
-      return NS_OK;
-
-    const nsAReadableString& text = aNode.GetText();
-    if (mPreLevel > 0)
-    {
-      Write(text);
-      mColPos += text.Length();
-    }
-    else if (!mDoFormat)
-    {
-      if (HasLongLines(text))
-      {
-        WriteWrapped(text);
-      }
-      else
-      {
-        Write(text);
-        mColPos += text.Length();
-      }
-    }
-    else
-    {
-      WriteWrapped(text);
-    }
-  }
-  else if (type == eHTMLTag_whitespace)
-  {
-    if (!mDoFormat || mPreLevel > 0)
-    {
-      const nsAReadableString& text = aNode.GetText();
-      Write(text);
-      mColPos += text.Length();
-    }
-  }
-  else if (type == eHTMLTag_newline)
-  {
-    if (!mDoFormat || mPreLevel > 0)
-    {
-      Write(mLineBreak);
-      mColPos = 0;
-    }
-  }
-
-  return NS_OK;
-}
-
-// See if the string has any lines longer than longLineLen:
-// if so, we presume formatting is wonky (e.g. the node has been edited)
-// and we'd better rewrap the whole text node.
-PRBool nsHTMLContentSinkStream::HasLongLines(const nsAReadableString& text)
-{
-  const PRUint32 longLineLen = 128;
-  PRUint32 start=0;
-  PRUint32 theLen=text.Length();
-  for (start = 0; start < theLen; )
-  {
-    PRInt32 eol = text.FindChar('\n', start);
-    if (eol < 0) eol = text.Length();
-    if ((PRUint32)(eol - start) > longLineLen)
-      return PR_TRUE;
-    start = eol+1;
-  }
-  return PR_FALSE;
-}
-
-void nsHTMLContentSinkStream::WriteWrapped(const nsAReadableString& text)
-{
-      // 1. Determine the length of the input string
-  PRInt32 length = text.Length();
-
-  // 2. If the offset plus the length of the text is smaller
-  // than the max then just add it 
-  if (mColPos + length < mMaxColumn)
-  {
-    Write(text);
-    mColPos += text.Length();
-  }
-  else
-  {
-    nsAutoString  str(text);
-    PRBool    done = PR_FALSE;
-    PRInt32   indx = 0;
-    PRInt32   offset = mColPos;
-
-    while (!done)
-    {        
-      // find the next break
-      PRInt32 start = mMaxColumn-offset;
-      if (start < 0)
-        start = 0;
-          
-      indx = str.FindChar(' ', PR_FALSE, start);
-
-      // if there is no break than just add it
-      if (indx == kNotFound)
-      {
-        Write(str);
-        mColPos += str.Length();
-        done = PR_TRUE;
-      }
-      else
-      {
-        // make first equal to the str from the 
-        // beginning to the index
-        nsString  first = str;
-
-        first.Truncate(indx);
-  
-        Write(first);
-        Write(mLineBreak);
-        mColPos = 0;
-  
-        // cut the string from the beginning to the index
-        str.Cut(0,indx);
-        offset = 0;
-      }
-    }
-  }
-}
-
-/**
- *  This gets called by the parser when you want to add
- *  a PI node to the current container in the content
- *  model.
- *  
- *  @updated gess 3/25/98
- *  @param   
- *  @return  
- */
-NS_IMETHODIMP
-nsHTMLContentSinkStream::AddProcessingInstruction(const nsIParserNode& aNode){
-
-#ifdef VERBOSE_DEBUG
-  DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
-#endif
-
-  return NS_OK;
-}
-
-/**
- *  This gets called by the parser when it encounters
- *  a DOCTYPE declaration in the HTML document.
- */
-
-NS_IMETHODIMP
-nsHTMLContentSinkStream::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
-{
-#ifdef VERBOSE_DEBUG
-  DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
-#endif
-   
- // Write(" parser( do_CreateInstance(kCParserCID, &rv) );
-    if (NS_FAILED(rv)) return rv;
-    if (!parser) return NS_ERROR_FAILURE;
-
-    nsAutoString htmlmime (NS_LITERAL_STRING("text/html"));
-    rv = parser->CreateCompatibleDTD(&mDTD, 0, eViewNormal,
-                                     &htmlmime, eDTDMode_transitional);
-  /* XXX Note: We output linebreaks for blocks.
-     I.e. we output linebreaks for "unknown" inline tags.
-     I just hunted such a bug for , same for ,  etc..
-     Better fallback to inline. /BenB */
-    if (NS_FAILED(rv) || !mDTD)
-      return PR_FALSE;
-  }
-
-  // Now we can get the inline status from the DTD:
-  return mDTD->IsBlockElement(aTag, eHTMLTag_unknown);
-}
-
-/**
-  * **** Pretty Printing Methods ******
-  *
-  */
-
-/**
-  * Desired line break state before the open tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakBeforeOpen(eHTMLTags aTag)
-{
- PRBool  result = PR_FALSE;
-  switch (aTag)
-  {
-    case  eHTMLTag_html:
-      result = PR_FALSE;
-      break;
-    case  eHTMLTag_title:
-      result = PR_TRUE;
-      break;
-    default:
-      result = IsBlockLevel(aTag);
-  }
-  return result;
-}
-
-/**
-  * Desired line break state after the open tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakAfterOpen(eHTMLTags aTag)
-{
-  PRBool  result = PR_FALSE;
-  switch (aTag)
-  {
-    case eHTMLTag_html:
-    case eHTMLTag_head:
-    case eHTMLTag_body:
-    case eHTMLTag_ul:
-    case eHTMLTag_ol:
-    case eHTMLTag_table:
-    case eHTMLTag_tbody:
-    case eHTMLTag_style:
-    case eHTMLTag_tr:
-    case eHTMLTag_br:
-      result = PR_TRUE;
-      break;
-
-    default:
-      break;
-  }
-  return result;
-}
-
-/**
-  * Desired line break state before the close tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakBeforeClose(eHTMLTags aTag)
-{
-  PRBool  result = PR_FALSE;
-
-  switch (aTag)
-  {
-    case eHTMLTag_html:
-    case eHTMLTag_head:
-    case eHTMLTag_body:
-    case eHTMLTag_ul:
-    case eHTMLTag_ol:
-    case eHTMLTag_table:
-    case eHTMLTag_tbody:
-    case eHTMLTag_style:
-      result = PR_TRUE;
-      break;
-
-    default:
-      break;
-  }
-  return result;
-}
-
-/**
-  * Desired line break state after the close tag.
-  */
-PRBool nsHTMLContentSinkStream::BreakAfterClose(eHTMLTags aTag)
-{
-  PRBool  result = PR_FALSE;
-
-  switch (aTag)
-  {
-    case eHTMLTag_html:
-    case eHTMLTag_head:
-    case eHTMLTag_body:
-    case eHTMLTag_tr:
-    case eHTMLTag_th:
-    case eHTMLTag_td:
-    case eHTMLTag_pre:
-    case eHTMLTag_title:
-    case eHTMLTag_meta:
-    case eHTMLTag_li:
-    case eHTMLTag_dt:
-    case eHTMLTag_dd:
-    case eHTMLTag_blockquote:
-    case eHTMLTag_p:
-    case eHTMLTag_div:
-      result = PR_TRUE;
-    break;
-
-    default:
-      result = IsBlockLevel(aTag);
-  }
-  return result;
-}
-
-/**
-  * Indent/outdent when the open/close tags are encountered.
-  * This implies that BreakAfterOpen() and BreakBeforeClose()
-  * are true no matter what those methods return.
-  */
-PRBool nsHTMLContentSinkStream::IndentChildren(eHTMLTags aTag)
-{
-  PRBool result = PR_FALSE;
-
-  switch (aTag)
-  {
-    case eHTMLTag_head:
-    case eHTMLTag_table:
-    case eHTMLTag_tr:
-    case eHTMLTag_ul:
-    case eHTMLTag_ol:
-    case eHTMLTag_tbody:
-    case eHTMLTag_form:
-    case eHTMLTag_frameset:
-    case eHTMLTag_li:
-    case eHTMLTag_dt:
-    case eHTMLTag_dd:
-    case eHTMLTag_blockquote:
-      result = PR_TRUE;      
-      break;
-
-    default:
-      result = PR_FALSE;
-      break;
-  }
-  return result;  
-}
-
-/**
-  * This method gets called when the parser begins the process
-  * of building the content model via the content sink.
-  *
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::WillBuildModel(void)
-{
-  mTabLevel=-1;
-
-  return NS_OK;
-}
-
-
-/**
-  * This method gets called when the parser concludes the process
-  * of building the content model via the content sink.
-  *
-  * @param  aQualityLevel describes how well formed the doc was.
-  *         0=GOOD; 1=FAIR; 2=POOR;
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::DidBuildModel(PRInt32 aQualityLevel) {
-  return NS_OK;
-}
-
-
-/**
-  * This method gets called when the parser gets i/o blocked,
-  * and wants to notify the sink that it may be a while before
-  * more data is available.
-  *
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::WillInterrupt(void) {
-  return NS_OK;
-}
-
-
-/**
-  * This method gets called when the parser i/o gets unblocked,
-  * and we're about to start dumping content again to the sink.
-  *
-  * @update 5/7/98 gess
-  */     
-NS_IMETHODIMP
-nsHTMLContentSinkStream::WillResume(void) {
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsHTMLContentSinkStream::SetParser(nsIParser* aParser) {
-  return NS_OK;
-}
-
-NS_IMETHODIMP 
-nsHTMLContentSinkStream::NotifyError(const nsParserError* aError)
-{
-  return NS_OK;
-}
-
diff --git a/parser/htmlparser/src/nsViewSourceHTML.cpp b/parser/htmlparser/src/nsViewSourceHTML.cpp
index a281af4f712..9e7baa2b6bf 100644
--- a/parser/htmlparser/src/nsViewSourceHTML.cpp
+++ b/parser/htmlparser/src/nsViewSourceHTML.cpp
@@ -1203,7 +1203,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
       {
         nsAutoString theStr;
         theStr.Assign(aToken->GetStringValue());
-        if(Compare(theStr, NS_LITERAL_STRING("XI"), nsCaseInsensitiveStringComparator()) != 0) {
+        if(!theStr.Equals(NS_LITERAL_STRING("XI"), nsCaseInsensitiveStringComparator())) {
           PRUnichar theChar=theStr.CharAt(0);
           if((nsCRT::IsAsciiDigit(theChar)) || ('X'==theChar) || ('x'==theChar)){
             theStr.Assign(NS_LITERAL_STRING("#") + theStr);
diff --git a/rdf/base/src/rdfutil.cpp b/rdf/base/src/rdfutil.cpp
index 3aa9b5d85aa..07183c75287 100644
--- a/rdf/base/src/rdfutil.cpp
+++ b/rdf/base/src/rdfutil.cpp
@@ -92,8 +92,8 @@ rdf_RequiresAbsoluteURI(const nsString& uri)
     // cheap shot at figuring out if this requires an absolute url translation
     if (Substring(uri, 0, 4).Equals(NS_LITERAL_STRING("urn:")) ||
         Substring(uri, 0, 9).Equals(NS_LITERAL_STRING("chrome:")) ||
-        !Compare(Substring(uri, 0, 3), NS_LITERAL_STRING("nc:"),
-                 nsCaseInsensitiveStringComparator())) {
+        Substring(uri, 0, 3).Equals(NS_LITERAL_STRING("nc:"),
+                                    nsCaseInsensitiveStringComparator())) {
         return PR_FALSE;
      }
      return PR_TRUE;
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index 28f2afd1203..a7160cc8884 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1744,9 +1744,8 @@ nsresult nsExternalHelperAppService::GetMIMEInfoForExtensionFromExtras(const cha
       while (start != end)
       {
           FindCharInReadable(',', iter, end);
-          if (Compare(Substring(start, iter),
-                      extension,
-                      nsCaseInsensitiveCStringComparator()) == 0)
+          if (Substring(start, iter).Equals(extension,
+                                            nsCaseInsensitiveCStringComparator()))
           {
               // This is the one.  Create MIMEInfo object and set
               // attributes appropriately.
diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
index 01ba227d643..7cf6f53a51f 100644
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
@@ -442,9 +442,8 @@ GetTypeAndDescriptionFromMimetypesFile(const nsAString& aFilename,
 
           while (start != end) {
             FindCharInReadable(',', iter, end);
-            if (Compare(Substring(start, iter),
-                        aFileExtension,
-                        nsCaseInsensitiveStringComparator()) == 0) {
+            if (Substring(start, iter).Equals(aFileExtension,
+                                              nsCaseInsensitiveStringComparator())) {
               // it's a match.  Assign the type and description and run
               aMajorType.Assign(Substring(majorTypeStart, majorTypeEnd));
               aMinorType.Assign(Substring(minorTypeStart, minorTypeEnd));
@@ -574,12 +573,12 @@ GetExtensionsAndDescriptionFromMimetypesFile(const nsAString& aFilename,
         }
 #endif
         if (NS_SUCCEEDED(rv) &&
-            Compare(Substring(majorTypeStart, majorTypeEnd),
-                    aMajorType,
-                    nsCaseInsensitiveStringComparator()) == 0 &&
-            Compare(Substring(minorTypeStart, minorTypeEnd),
-                    aMinorType,
-                    nsCaseInsensitiveStringComparator()) == 0) {
+            Substring(majorTypeStart,
+                      majorTypeEnd).Equals(aMajorType,
+                                           nsCaseInsensitiveStringComparator())&&
+            Substring(minorTypeStart,
+                      minorTypeEnd).Equals(aMinorType,
+                                           nsCaseInsensitiveStringComparator())) {
           // it's a match
           aFileExtensions.Assign(extensions);
           aDescription.Assign(Substring(descriptionStart, descriptionEnd));
@@ -948,13 +947,14 @@ GetHandlerAndDescriptionFromMailcapFile(const nsAString& aFilename,
           rv = ParseMIMEType(start_iter, majorTypeStart, majorTypeEnd,
                              minorTypeStart, minorTypeEnd, semicolon_iter);
           if (NS_SUCCEEDED(rv) &&
-              Compare(Substring(majorTypeStart, majorTypeEnd),
-                      aMajorType,
-                      nsCaseInsensitiveStringComparator()) == 0 &&
-              (Substring(minorTypeStart, minorTypeEnd).Equals(NS_LITERAL_STRING("*")) ||
-               Compare(Substring(minorTypeStart, minorTypeEnd),
-                       aMinorType,
-                       nsCaseInsensitiveStringComparator()) == 0)) { // we have a match
+              Substring(majorTypeStart,
+                        majorTypeEnd).Equals(aMajorType,
+                                             nsCaseInsensitiveStringComparator()) &&
+              (Substring(minorTypeStart,
+                         minorTypeEnd).Equals(NS_LITERAL_STRING("*")) ||
+               Substring(minorTypeStart,
+                         minorTypeEnd).Equals(aMinorType,
+                                              nsCaseInsensitiveStringComparator()))) { // we have a match
             PRBool match = PR_TRUE;
             ++semicolon_iter;             // point at the first char past the semicolon
             start_iter = semicolon_iter;  // handler string starts here
diff --git a/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/xpfe/components/bookmarks/src/nsBookmarksService.cpp
index 5799f6f5938..ce3c067a751 100644
--- a/xpfe/components/bookmarks/src/nsBookmarksService.cpp
+++ b/xpfe/components/bookmarks/src/nsBookmarksService.cpp
@@ -934,27 +934,22 @@ BookmarkParser::Unescape(nsString &text)
 
 	while((offset = text.FindChar((PRUnichar('&')), offset)) >= 0)
 	{
-		// XXX get max of 6 chars; change the value below if
-		// we ever start looking for longer HTML-escaped values
-		nsAutoString	temp;
-		text.Mid(temp, offset, 6);
-
-		if (Compare(Substring(temp, 0, 4), NS_LITERAL_STRING("<"), nsCaseInsensitiveStringComparator()) == 0)
+		if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING("<"), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 4);
 			text.Insert(PRUnichar('<'), offset);
 		}
-		if (Compare(Substring(temp, 0, 4), NS_LITERAL_STRING(">"), nsCaseInsensitiveStringComparator()) == 0)
+		else if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING(">"), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 4);
 			text.Insert(PRUnichar('>'), offset);
 		}
-		if (Compare(Substring(temp, 0, 5), NS_LITERAL_STRING("&"), nsCaseInsensitiveStringComparator()) == 0)
+		else if (Substring(text, offset, 5).Equals(NS_LITERAL_STRING("&"), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 5);
 			text.Insert(PRUnichar('&'), offset);
 		}
-		if (Compare(Substring(temp, 0, 6), NS_LITERAL_STRING("""), nsCaseInsensitiveStringComparator()) == 0)
+		else if (Substring(text, offset, 6).Equals(NS_LITERAL_STRING("""), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 6);
 			text.Insert(PRUnichar('\"'), offset);
diff --git a/xpfe/components/related/src/nsRelatedLinksHandler.cpp b/xpfe/components/related/src/nsRelatedLinksHandler.cpp
index 0dfcebb42e2..8ee62965506 100644
--- a/xpfe/components/related/src/nsRelatedLinksHandler.cpp
+++ b/xpfe/components/related/src/nsRelatedLinksHandler.cpp
@@ -556,27 +556,22 @@ RelatedLinksStreamListener::Unescape(nsString &text)
 
 	while((offset = text.FindChar((PRUnichar('&')), offset)) >= 0)
 	{
-		// XXX get max of 6 chars; change the value below if
-		// we ever start looking for longer HTML-escaped values
-		nsAutoString	temp;
-		text.Mid(temp, offset, 6);
-
-		if (Compare(Substring(temp, 0, 4), NS_LITERAL_STRING("<"), nsCaseInsensitiveStringComparator()) == 0)
+		if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING("<"), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 4);
 			text.Insert(PRUnichar('<'), offset);
 		}
-		if (Compare(Substring(temp, 0, 4), NS_LITERAL_STRING(">"), nsCaseInsensitiveStringComparator()) == 0)
+		else if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING(">"), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 4);
 			text.Insert(PRUnichar('>'), offset);
 		}
-		if (Compare(Substring(temp, 0, 5), NS_LITERAL_STRING("&"), nsCaseInsensitiveStringComparator()) == 0)
+		else if (Substring(text, offset, 5).Equals(NS_LITERAL_STRING("&"), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 5);
 			text.Insert(PRUnichar('&'), offset);
 		}
-		if (Compare(Substring(temp, 0, 6), NS_LITERAL_STRING("""), nsCaseInsensitiveStringComparator()) == 0)
+		else if (Substring(text, offset, 6).Equals(NS_LITERAL_STRING("""), nsCaseInsensitiveStringComparator()))
 		{
 			text.Cut(offset, 6);
 			text.Insert(PRUnichar('\"'), offset);
diff --git a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp
index 828061499e4..27241dd143b 100644
--- a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp
+++ b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp
@@ -337,9 +337,9 @@ nsUrlbarHistory::SearchPreviousResults(const PRUnichar *searchStr, nsIAutoComple
     // which doesn't make any sense (since the "!= 0" was inside the
     // parentheses)
     if (searchStrLen < prevSearchStrLen ||
-        Compare(Substring(searchStr, searchStr+prevSearchStrLen),
-                nsDependentString(prevSearchString, prevSearchStrLen),
-                nsCaseInsensitiveStringComparator())!= 0)
+        !Substring(searchStr,
+                   searchStr+prevSearchStrLen).Equals(nsDependentString(prevSearchString, prevSearchStrLen),
+                                                      nsCaseInsensitiveStringComparator()))
         return NS_ERROR_ABORT;
 
     nsCOMPtr array;
@@ -368,9 +368,9 @@ nsUrlbarHistory::SearchPreviousResults(const PRUnichar *searchStr, nsIAutoComple
 
 			if (itemValue.IsEmpty())
 				continue;
-            if (Compare(nsDependentString(searchStr, searchStrLen),
-                        Substring(itemValue, 0, searchStrLen),
-                        nsCaseInsensitiveStringComparator()) == 0)
+            if (nsDependentString(searchStr,
+                                  searchStrLen).Equals(Substring(itemValue, 0, searchStrLen),
+                                                       nsCaseInsensitiveStringComparator()))
                 continue;
 
 	    }
@@ -626,8 +626,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 (Compare(itemValue, nsDependentString(aItem),
-                        nsCaseInsensitiveStringComparator()) == 0)
+            if (itemValue.Equals(nsDependentString(aItem),
+                                 nsCaseInsensitiveStringComparator()))
             {
                 //printf("In CheckItemAvailability. Item already found\n");
                 *aResult = PR_TRUE;