diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 3fd058879776..0600c8192f95 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -1113,7 +1113,7 @@ nsHTMLDocument::GetImageMap(const nsString& aMapName, nsCOMPtr map; mImageMaps->QueryElementAt(i, NS_GET_IID(nsIDOMHTMLMapElement), getter_AddRefs(map)); if (map && NS_SUCCEEDED(map->GetName(name))) { - if (name.EqualsIgnoreCase(aMapName)) { + if (name.Equals(aMapName, nsCaseInsensitiveStringComparator())) { *aResult = map; NS_ADDREF(*aResult); return NS_OK; @@ -1894,7 +1894,7 @@ nsHTMLDocument::SetDomain(const nsAReadableString& aDomain) nsAutoString suffix; current.Right(suffix, aDomain.Length()); PRUnichar c = current.CharAt(current.Length() - aDomain.Length() - 1); - if (suffix.EqualsIgnoreCase(nsString(aDomain)) && + if (suffix.Equals(aDomain, nsCaseInsensitiveStringComparator()) && (c == '.' || c == '/')) ok = PR_TRUE; } @@ -2017,9 +2017,7 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody) return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } - nsAutoString bodyStr; - bodyStr.Assign(NS_LITERAL_STRING("BODY")); - + NS_NAMED_LITERAL_STRING(bodyStr, "BODY"); nsCOMPtr child; root->GetFirstChild(getter_AddRefs(child)); @@ -2031,7 +2029,8 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody) domElement->GetTagName(tagName); - if (bodyStr.EqualsIgnoreCase(tagName)) { + ToUpperCase(tagName); + if (bodyStr.Equals(tagName)) { nsCOMPtr ret; nsresult rv = root->ReplaceChild(aBody, child, getter_AddRefs(ret)); @@ -3757,7 +3756,7 @@ nsHTMLDocument::GetBodyContent() return PR_FALSE; } - nsAutoString bodyStr(NS_LITERAL_STRING("BODY")); + NS_NAMED_LITERAL_STRING(bodyStr, "BODY"); nsCOMPtr child; root->GetFirstChild(getter_AddRefs(child)); @@ -3768,7 +3767,8 @@ nsHTMLDocument::GetBodyContent() nsAutoString tagName; domElement->GetTagName(tagName); - if (bodyStr.EqualsIgnoreCase(tagName)) { + ToUpperCase(tagName); + if (bodyStr.Equals(tagName)) { mBodyContent = child; return PR_TRUE; diff --git a/content/html/style/src/nsCSSLoader.cpp b/content/html/style/src/nsCSSLoader.cpp index d3d482f1aca2..4d8a656e5caa 100644 --- a/content/html/style/src/nsCSSLoader.cpp +++ b/content/html/style/src/nsCSSLoader.cpp @@ -42,6 +42,7 @@ #include "nsICharsetConverterManager.h" #include "nsIUnicodeDecoder.h" #include "nsICharsetAlias.h" +#include "nsUnicharUtils.h" #include "nsHashtable.h" #include "nsIURL.h" #include "nsIURL.h" @@ -1137,7 +1138,7 @@ PRBool CSSLoaderImpl::IsAlternate(const nsString& aTitle) { if (!aTitle.IsEmpty()) { - return PRBool(! aTitle.EqualsIgnoreCase(mPreferredSheet)); + return PRBool(! aTitle.Equals(mPreferredSheet, nsCaseInsensitiveStringComparator())); } return PR_FALSE; } diff --git a/content/xml/content/src/nsXMLElement.cpp b/content/xml/content/src/nsXMLElement.cpp index 6a2db9119e9a..caaab6946c79 100644 --- a/content/xml/content/src/nsXMLElement.cpp +++ b/content/xml/content/src/nsXMLElement.cpp @@ -378,7 +378,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell) kActuateAtom, value); if (rv == NS_CONTENT_ATTR_HAS_VALUE && - value.EqualsAtom(kOnLoadAtom,PR_FALSE)) { + value.EqualsAtom(kOnLoadAtom, PR_FALSE)) { // show= ? nsLinkVerb verb = eLinkVerb_Undefined; diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index c000ec662f87..1941effe0363 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -2272,7 +2272,6 @@ nsXULDocument::SelectAll() nsIContent * end = nsnull; nsIContent * body = nsnull; - nsAutoString bodyStr; bodyStr.Assign(NS_LITERAL_STRING("BODY")); PRInt32 i, n; mRootContent->ChildCount(n); for (i=0;iChildAt(i, child); nsCOMPtr atom; child->GetTag(*getter_AddRefs(atom)); - if (bodyStr.EqualsIgnoreCase(atom)) { + + nsAutoString atomValue; + atom->ToString(atomValue); + + ToUpperCase(atomValue); + if (NS_LITERAL_STRING("BODY").Equals(atomValue)) { body = child; break; } diff --git a/content/xul/templates/src/nsXULSortService.cpp b/content/xul/templates/src/nsXULSortService.cpp index 65406912dc73..a22226e38845 100644 --- a/content/xul/templates/src/nsXULSortService.cpp +++ b/content/xul/templates/src/nsXULSortService.cpp @@ -539,7 +539,7 @@ XULSortServiceImpl::GetSortColumnIndex(nsIContent *tree, const nsString &sortRes } } if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None, kSortSeparatorsAtom, value)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (value.EqualsIgnoreCase(*trueStr))) + && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (value.EqualsIgnoreCase("true"))) { inbetweenSeparatorSort = PR_TRUE; } @@ -614,7 +614,7 @@ XULSortServiceImpl::NodeHasSortInfo(nsIContent *child, nsString &sortResource, n if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, value)) && (rv == NS_CONTENT_ATTR_HAS_VALUE)) { - if (value.EqualsIgnoreCase(*trueStr)) + if (value.EqualsIgnoreCase("true")) { if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None, kResourceAtom, sortResource)) && (rv == NS_CONTENT_ATTR_HAS_VALUE)) @@ -628,7 +628,7 @@ XULSortServiceImpl::NodeHasSortInfo(nsIContent *child, nsString &sortResource, n if (NS_SUCCEEDED(rv = child->GetAttr(kNameSpaceID_None, kSortSeparatorsAtom, value)) && (rv == NS_CONTENT_ATTR_HAS_VALUE)) { - if (value.EqualsIgnoreCase(*trueStr)) + if (value.EqualsIgnoreCase("true")) { inbetweenSeparatorSort = PR_TRUE; } @@ -1694,7 +1694,7 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo, PR // if its a container, find its treechildren node, and sort those if (NS_FAILED(rv = parentNode->GetAttr(kNameSpaceID_None, nsXULAtoms::container, value)) || - (rv != NS_CONTENT_ATTR_HAS_VALUE) || (!value.EqualsIgnoreCase(*trueStr))) + (rv != NS_CONTENT_ATTR_HAS_VALUE) || (!value.EqualsIgnoreCase("true"))) continue; if (NS_FAILED(rv = parentNode->ChildCount(numChildren))) continue; @@ -1981,7 +1981,7 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort } } if (NS_SUCCEEDED(rv = root->GetAttr(kNameSpaceID_None, kStaticsSortLastHintAtom, valueStr)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (valueStr.EqualsIgnoreCase(*trueStr))) + && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (valueStr.EqualsIgnoreCase("true"))) { // indicate that static XUL comes after RDF-generated content by making negative staticCount = -staticCount; @@ -2132,10 +2132,10 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, PRBool invertTreeFlag = PR_FALSE; nsAutoString value; if (NS_SUCCEEDED(rv = treeNode->GetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, value)) - && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (value.EqualsIgnoreCase(*trueStr))) + && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (value.EqualsIgnoreCase("true"))) { if (NS_SUCCEEDED(rv = treeNode->GetAttr(kNameSpaceID_None, kResourceAtom, - value)) && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (value.EqualsIgnoreCase(sortResource))) + value)) && (rv == NS_CONTENT_ATTR_HAS_VALUE) && (value.Equals(sortResource, nsCaseInsensitiveStringComparator()))) { if (NS_SUCCEEDED(rv = treeNode->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, value)) && (rv == NS_CONTENT_ATTR_HAS_VALUE)) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 2d40af869509..28f3577819b1 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -109,7 +109,7 @@ #include "prlog.h" // this is going away - see -// http://bugzilla.mozilla.org/show_bug.cgi?id=71482 +// #include "nsIBrowserHistory.h" #ifdef DEBUG_DOCSHELL_FOCUS @@ -1362,10 +1362,10 @@ nsDocShell::GetDocShellEnumerator(PRInt32 aItemType, PRInt32 aDirection, nsISimp rv = docShellEnum->First(); if (NS_FAILED(rv)) return rv; - - docShellEnum->AddRef(); // ensure we don't lose the last ref inside the QueryInterface + + NS_ADDREF(docShellEnum); // ensure we don't lose the last ref inside the QueryInterface rv = docShellEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)outEnum); - docShellEnum->Release(); + NS_RELEASE(docShellEnum); return rv; } @@ -1633,7 +1633,7 @@ nsDocShell::FindItemWithName(const PRUnichar * aName, reqAsTreeItem(do_QueryInterface(aRequestor)); // First we check our name. - if (mName.EqualsWithConversion(aName)) { + if (mName.Equals(aName)) { *_retval = NS_STATIC_CAST(nsIDocShellTreeItem *, this); NS_ADDREF(*_retval); return NS_OK; @@ -2271,7 +2271,8 @@ nsDocShell::LoadURI(const PRUnichar * aURI, nsresult rv = CreateFixupURI(aURI, getter_AddRefs(uri)); - if (NS_ERROR_UNKNOWN_PROTOCOL == rv) { + if (NS_ERROR_UNKNOWN_PROTOCOL == rv || + NS_ERROR_MALFORMED_URI == rv) { // we weren't able to find a protocol handler nsCOMPtr prompter; nsCOMPtr stringBundle; @@ -2281,44 +2282,34 @@ nsDocShell::LoadURI(const PRUnichar * aURI, NS_ENSURE_TRUE(stringBundle, NS_ERROR_FAILURE); nsXPIDLString messageStr; - NS_ENSURE_SUCCESS(stringBundle-> - GetStringFromName( - NS_LITERAL_STRING("protocolNotFound").get(), - getter_Copies(messageStr)), - NS_ERROR_FAILURE); + nsresult strerror; + + if (NS_ERROR_UNKNOWN_PROTOCOL == rv) { + const nsAutoString uriString(aURI); + PRInt32 colon = uriString.FindChar(':'); + // extract the scheme + nsAutoString scheme; + uriString.Left(scheme, colon); + + const PRUnichar* formatStrs[] = { scheme.get() }; + + strerror = + stringBundle->FormatStringFromName(NS_LITERAL_STRING("protocolNotFound").get(), + formatStrs, + 1, + getter_Copies(messageStr)); + } + else { + // NS_ERROR_MALFORMED_URI + strerror = + stringBundle->GetStringFromName(NS_LITERAL_STRING("malformedURI").get(), + getter_Copies(messageStr)); + } - nsAutoString uriString(aURI); - PRInt32 colon = uriString.FindChar(':'); - // extract the scheme - nsAutoString scheme; - uriString.Left(scheme, colon); - nsCAutoString cScheme; - cScheme.AssignWithConversion(scheme); - - PRUnichar *msg = nsTextFormatter::smprintf(messageStr, cScheme.get()); - if (!msg) - return NS_ERROR_OUT_OF_MEMORY; - - prompter->Alert(nsnull, msg); - nsTextFormatter::smprintf_free(msg); + // now we have the string + NS_ENSURE_SUCCESS(strerror, NS_ERROR_FAILURE); + prompter->Alert(nsnull, messageStr); } // end unknown protocol - else if (NS_ERROR_MALFORMED_URI == rv) { - // malformed URI - nsCOMPtr prompter; - nsCOMPtr stringBundle; - GetPromptAndStringBundle(getter_AddRefs(prompter), - getter_AddRefs(stringBundle)); - - NS_ENSURE_TRUE(stringBundle, NS_ERROR_FAILURE); - - nsXPIDLString messageStr; - NS_ENSURE_SUCCESS(stringBundle-> - GetStringFromName( - NS_LITERAL_STRING("malformedURI").get(), - getter_Copies(messageStr)), - NS_ERROR_FAILURE); - prompter->Alert(nsnull, messageStr.get()); - } if (NS_FAILED(rv) || !uri) return NS_ERROR_FAILURE; @@ -3673,7 +3664,6 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest, AddToGlobalHistory(uri); // this is a redirect, so hide the page from // being enumerated in history - // this is temporary until bug 71482 is fixed if (mGlobalHistory) { nsCOMPtr browserHistory = do_QueryInterface(mGlobalHistory); @@ -3930,18 +3920,18 @@ nsDocShell::NewContentViewerObj(const char *aContentType, nsIContentViewer ** aViewer) { //XXX This should probably be some category thing.... - char id[256]; - PR_snprintf(id, sizeof(id), - NS_DOCUMENT_LOADER_FACTORY_CONTRACTID_PREFIX "%s;1?type=%s", - (const char *) "view", aContentType); + nsCAutoString contractId(NS_DOCUMENT_LOADER_FACTORY_CONTRACTID_PREFIX + "view" + ";1?type="); + contractId += aContentType; - // Note that we're always passing in "view" for the component id above + // Note that we're always passing in "view" for the contractid above // and to the docLoaderFactory->CreateInstance() at the end of this method. // nsLayoutDLF makes the determination if it should be a "view-source" // Create an instance of the document-loader-factory nsCOMPtr - docLoaderFactory(do_CreateInstance(id)); + docLoaderFactory(do_CreateInstance(contractId.get())); if (!docLoaderFactory) { // try again after loading plugins nsresult err; @@ -3953,7 +3943,7 @@ nsDocShell::NewContentViewerObj(const char *aContentType, pluginHost->LoadPlugins(); - docLoaderFactory = do_CreateInstance(id); + docLoaderFactory = do_CreateInstance(contractId.get()); if (!docLoaderFactory) return NS_ERROR_FAILURE; @@ -4101,6 +4091,9 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) isSubWindow = PR_TRUE; break; } + + // don't use nsCOMPtr here to avoid extra addref + // when assigning to curwin nsIDOMWindow* temp; curwin->GetParent(&temp); if (curwin == temp) { @@ -4728,7 +4721,7 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData, nsresult rv = NS_ERROR_FAILURE; PRUint32 available = 0; PRUint32 bytesRead; - char *headersBuf = nsnull; + nsXPIDLCString headersBuf; // used during the manipulation of the String from the InputStream nsCAutoString headersString; @@ -4743,23 +4736,25 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData, // rv = aHeadersData->Available(&available); - if (NS_FAILED(rv) || available < 1) { - goto AHTC_CLEANUP; - } + if (NS_FAILED(rv) || available < 1) + return rv; do { - aHeadersData->ReadSegments(AHTC_WriteFunc, &headersBuf, available, + aHeadersData->ReadSegments(AHTC_WriteFunc, + getter_Copies(headersBuf), + available, &bytesRead); rv = aHeadersData->Available(&available); - if (NS_FAILED(rv)) { - goto AHTC_CLEANUP; - } + if (NS_FAILED(rv)) + return rv; + } while (0 < available); // - // Turn the char * buffer into an nsString. + // Turn nsXPIDLCString into an nsString. + // (need to find the new string APIs so we don't do this // - headersString = (const char *) headersBuf; + headersString = headersBuf.get(); // // Iterate over the nsString: for each "\r\n" delimeted chunk, @@ -4769,16 +4764,14 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData, while (PR_TRUE) { crlf = headersString.Find("\r\n", PR_TRUE); if (-1 == crlf) { - rv = NS_OK; - goto AHTC_CLEANUP; + return NS_OK; } headersString.Mid(oneHeader, 0, crlf); headersString.Cut(0, crlf + 2); oneHeader.StripWhitespace(); colon = oneHeader.Find(":"); if (-1 == colon) { - rv = NS_ERROR_NULL_POINTER; - goto AHTC_CLEANUP; + return NS_ERROR_NULL_POINTER; } oneHeader.Left(headerName, colon); colon++; @@ -4790,15 +4783,10 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData, rv = aChannel->SetRequestHeader(headerName.get(), headerValue.get()); if (NS_FAILED(rv)) { - rv = NS_ERROR_NULL_POINTER; - goto AHTC_CLEANUP; + return NS_ERROR_NULL_POINTER; } } - - AHTC_CLEANUP: - nsMemory::Free((void *) headersBuf); - headersBuf = nsnull; - return rv; + return NS_ERROR_FAILURE; } nsresult nsDocShell::DoChannelLoad(nsIChannel * aChannel, @@ -4922,35 +4910,45 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor) const char kHash = '#'; // Split the new URI into a left and right part - nsAutoString sNew; - sNew.AssignWithConversion(newSpec); - nsAutoString sNewLeft; - nsAutoString sNewRef; - PRInt32 hashNew = sNew.FindChar(kHash); + // (assume we're parsing it out right + nsACString::const_iterator urlStart, urlEnd, refStart, refEnd; + newSpec.BeginReading(urlStart); + newSpec.EndReading(refEnd); + + PRInt32 hashNew = newSpec.FindChar(kHash); if (hashNew == 0) { - return NS_OK; // Strange URI + return NS_OK; // Strange URI } else if (hashNew > 0) { - sNew.Left(sNewLeft, hashNew); - sNew.Right(sNewRef, sNew.Length() - hashNew - 1); + // found it + urlEnd = urlStart; + urlEnd.advance(hashNew); + + refStart = urlEnd; + ++refStart; // advanced past '#' + } else { - sNewLeft = sNew; + // no hash at all + urlEnd = refStart = refEnd; } - + const nsACString& sNewLeft = Substring(urlStart, urlEnd); + const nsACString& sNewRef = Substring(refStart, refEnd); + // Split the current URI in a left and right part - nsAutoString sCurrent; - sCurrent.AssignWithConversion(currentSpec); - nsAutoString sCurrentLeft; - PRInt32 hashCurrent = sCurrent.FindChar(kHash); + nsACString::const_iterator currentLeftStart, currentLeftEnd; + currentSpec.BeginReading(currentLeftStart); + + PRInt32 hashCurrent = currentSpec.FindChar(kHash); if (hashCurrent == 0) { return NS_OK; // Strange URI } else if (hashCurrent > 0) { - sCurrent.Left(sCurrentLeft, hashCurrent); + currentLeftEnd = currentLeftStart; + currentLeftEnd.advance(hashCurrent); } else { - sCurrentLeft = sCurrent; + currentSpec.EndReading(currentLeftEnd); } // Exit when there are no anchors @@ -4967,7 +4965,7 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor) // This means that comparing "http://www.ABC.com/" to "http://www.abc.com/" // will fail this test. - if (sCurrentLeft.CompareWithConversion(sNewLeft, PR_FALSE, -1) != 0) { + if (Substring(currentLeftStart, currentLeftEnd).Equals(sNewLeft)) { return NS_OK; // URIs not the same } @@ -4987,17 +4985,16 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor) // We assume that the bytes are in UTF-8, as it says in the spec: // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1 - nsAutoString savedNewRef(sNewRef); - sNewRef = NS_ConvertUTF8toUCS2(str); + // We try the UTF-8 string first, and then try the + // document's charset (see below). + rv = shell->GoToAnchor(NS_ConvertUTF8toUCS2(str)); nsMemory::Free(str); - // We try the UTF-8 string first, and then try the document's charset (see below). - rv = shell->GoToAnchor(sNewRef); - // Above will fail if the anchor name is not UTF-8. // Need to convert from document charset to unicode. if (NS_FAILED(rv)) { + // Get a document charset NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE); nsCOMPtr @@ -5009,36 +5006,22 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor) nsAutoString aCharset; rv = doc->GetDocumentCharacterSet(aCharset); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - char *charsetStr = ToNewCString(aCharset); - NS_ENSURE_TRUE(charsetStr, NS_ERROR_OUT_OF_MEMORY); - - // Use the saved string - char *uriStr = ToNewCString(savedNewRef); - if (!uriStr) { - nsMemory::Free(charsetStr); - return NS_ERROR_OUT_OF_MEMORY; - } nsCOMPtr textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); - if (NS_FAILED(rv)) { - nsMemory::Free(uriStr); - nsMemory::Free(charsetStr); + if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - } // Unescape and convert to unicode - PRUnichar *uStr; - rv = textToSubURI->UnEscapeAndConvert(charsetStr, uriStr, - &uStr); - nsMemory::Free(uriStr); - nsMemory::Free(charsetStr); + nsXPIDLString uStr; + NS_LossyConvertUCS2toASCII charset(aCharset); + + rv = textToSubURI->UnEscapeAndConvert(charset.get(), + PromiseFlatCString(sNewRef).get(), + getter_Copies(uStr)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - sNewRef.Assign(uStr); - nsMemory::Free(uStr); - - rv = shell->GoToAnchor(sNewRef); + rv = shell->GoToAnchor(uStr); } } } diff --git a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp index e58c5b0a1a66..1d87ccc6adb2 100644 --- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp +++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp @@ -225,7 +225,7 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::DoTransaction(void) // do nothing. nsAutoString itemPropertyNameString; cssDecl->Item(0, itemPropertyNameString); - PRBool thisOne = propertyNameString.EqualsIgnoreCase(itemPropertyNameString); + PRBool thisOne = propertyNameString.Equals(itemPropertyNameString, nsCaseInsensitiveStringComparator()); if (thisOne) { mPropertyWasSet = PR_TRUE; if (multiple) { @@ -252,7 +252,7 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::DoTransaction(void) nsAutoString itemPropertyNameString; for (index = 0 ; index < length; index++) { cssDecl->Item(index, itemPropertyNameString); - PRBool thisOne = propertyNameString.EqualsIgnoreCase(itemPropertyNameString); + PRBool thisOne = propertyNameString.Equals(itemPropertyNameString, nsCaseInsensitiveStringComparator()); if (thisOne) { // we have found the property we are looking for... // if we have to remove it, do nothing or remove only the corresponding value diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 4dff0eb66c39..7f802b21d98d 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -3457,7 +3457,7 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTagStr) { nsAutoString tag, tagStr(aTagStr); element->GetTagName(tag); - if (tag.EqualsIgnoreCase(tagStr)) + if (tag.Equals(tagStr, nsCaseInsensitiveStringComparator())) return PR_TRUE; } return PR_FALSE; diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 5c28bf4d5bf4..bbec04cf1437 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -2767,7 +2767,7 @@ nsHTMLEditor::GetElementOrParentByTagName(const nsAReadableString& aTagName, nsI } else { currentNode->GetNodeName(currentTagName); - if (currentTagName.EqualsIgnoreCase(TagName)) + if (currentTagName.Equals(TagName, nsCaseInsensitiveStringComparator())) { NODE_FOUND: bNodeFound = PR_TRUE; @@ -3991,7 +3991,7 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode, { nsAutoString tag, value; element->GetTagName(tag); - if (propName.EqualsIgnoreCase(tag)) + if (propName.Equals(tag, nsCaseInsensitiveStringComparator())) { PRBool found = PR_FALSE; if (aAttribute && 0!=aAttribute->Length()) @@ -4006,7 +4006,7 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode, else { nsString tString(*aValue); - if (tString.EqualsIgnoreCase(value)) { + if (tString.Equals(value, nsCaseInsensitiveStringComparator())) { found = PR_TRUE; } else { // we found the prop with the attribute, but the value doesn't match diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 991a6d0acb92..902b598ce795 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -219,7 +219,7 @@ NS_IMETHODIMP nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName, if (domWindow) { nsAutoString ourName; domWindow->GetName(ourName); - if (name.EqualsIgnoreCase(ourName)) { + if (name.Equals(ourName, nsCaseInsensitiveStringComparator())) { *aFoundItem = mWebBrowser->mDocShellAsItem; NS_IF_ADDREF(*aFoundItem); return NS_OK; diff --git a/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp b/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp index 3a4885f57136..f7296fbbf4e3 100644 --- a/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp +++ b/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp @@ -141,8 +141,7 @@ void txMozillaXMLOutput::endElement(const String& aName, const PRInt32 aNsID) #ifdef DEBUG nsAutoString nodeName; mCurrentNode->GetNodeName(nodeName); - if (!nodeName.EqualsIgnoreCase(aName.getConstNSString())) - NS_ASSERTION(nodeName.EqualsIgnoreCase(aName.getConstNSString()), + NS_ASSERTION(nodeName.Equals(aName.getConstNSString(), nsCaseInsensitiveStringComparator()), "Unbalanced startElement and endElement calls!"); #endif @@ -198,7 +197,11 @@ void txMozillaXMLOutput::endElement(const String& aName, const PRInt32 aNsID) // Add this script element to the array of loading script elements. nsCOMPtr scriptElement = do_QueryInterface(mCurrentNode, &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "Need script element"); - mScriptElements.AppendElement(scriptElement); + if (!mScriptElements) + rv = NS_NewISupportsArray(getter_AddRefs(mScriptElements)); + NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create array"); + if (NS_SUCCEEDED(rv)) + mScriptElements->AppendElement(scriptElement); // Add the script element to the tree. nsCOMPtr document = do_QueryInterface(mScriptParent); @@ -239,8 +242,9 @@ nsresult txMozillaXMLOutput::getRootContent(nsIContent** aReturn) PRBool txMozillaXMLOutput::isDone() { - PRUint32 scriptCount; - mScriptElements.Count(&scriptCount); + PRUint32 scriptCount = 0; + if (mScriptElements) + mScriptElements->Count(&scriptCount); return (scriptCount == 0); } @@ -267,9 +271,11 @@ void txMozillaXMLOutput::processingInstruction(const String& aTarget, const Stri void txMozillaXMLOutput::removeScriptElement(nsIDOMHTMLScriptElement *aElement) { - PRInt32 index = mScriptElements.IndexOf(aElement); - if (index > -1) - mScriptElements.RemoveElementAt(index); + if (mScriptElements) { + PRInt32 index = mScriptElements->IndexOf(aElement); + if (index > -1) + mScriptElements->RemoveElementAt(index); + } } void txMozillaXMLOutput::setOutputDocument(nsIDOMDocument* aDocument) diff --git a/extensions/transformiix/source/xslt/txMozillaXMLOutput.h b/extensions/transformiix/source/xslt/txMozillaXMLOutput.h index 353a599dbf0c..2719c4e3cd51 100644 --- a/extensions/transformiix/source/xslt/txMozillaXMLOutput.h +++ b/extensions/transformiix/source/xslt/txMozillaXMLOutput.h @@ -174,7 +174,7 @@ private: nsCOMPtr mNameSpaceManager; - nsSupportsArray mScriptElements; + nsCOMPtr mScriptElements; nsAutoString mText; diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index 1b96c90a9723..4681b309f476 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -465,7 +465,7 @@ PRUint32 FontAliasKey::HashCode(void) const PRBool FontAliasKey::Equals(const nsHashKey *aKey) const { - return mString.EqualsIgnoreCase(((FontAliasKey*)aKey)->mString); + return mString.Equals(((FontAliasKey*)aKey)->mString, nsCaseInsensitiveStringComparator()); } nsHashKey* FontAliasKey::Clone(void) const diff --git a/gfx/src/nsFont.cpp b/gfx/src/nsFont.cpp index 2d0ddfa825b3..3f35eeb2a6c0 100644 --- a/gfx/src/nsFont.cpp +++ b/gfx/src/nsFont.cpp @@ -38,6 +38,7 @@ #include "nsFont.h" #include "nsString.h" +#include "nsUnicharUtils.h" nsFont::nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant, PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize, @@ -92,7 +93,7 @@ PRBool nsFont::Equals(const nsFont& aOther) const (decorations == aOther.decorations) && (size == aOther.size) && (sizeAdjust == aOther.sizeAdjust) && - name.EqualsIgnoreCase(aOther.name)) { + name.Equals(aOther.name, nsCaseInsensitiveStringComparator())) { return PR_TRUE; } return PR_FALSE; diff --git a/gfx/src/windows/nsDeviceContextSpecWin.cpp b/gfx/src/windows/nsDeviceContextSpecWin.cpp index 07393bebd3fd..78e38122b191 100644 --- a/gfx/src/windows/nsDeviceContextSpecWin.cpp +++ b/gfx/src/windows/nsDeviceContextSpecWin.cpp @@ -1062,7 +1062,7 @@ nsDeviceContextSpecWin::ShowNativePrintDialog(nsIWidget *aWidget, PRBool aQuiet) if (NS_SUCCEEDED(GetLocalizedBundle(PRINTDLG_PROPERTIES, getter_AddRefs(strBundle)))) { nsAutoString doExtendStr; if (NS_SUCCEEDED(GetLocalizedString(strBundle, "extend", doExtendStr))) { - doExtend = doExtendStr.EqualsIgnoreCase("true"); + doExtend = doExtendStr.Equals(NS_LITERAL_STRING("true")); } } diff --git a/gfx/src/windows/nsFontMetricsWin.cpp b/gfx/src/windows/nsFontMetricsWin.cpp index 9bc98e9ad74c..380b12b87b09 100644 --- a/gfx/src/windows/nsFontMetricsWin.cpp +++ b/gfx/src/windows/nsFontMetricsWin.cpp @@ -2913,9 +2913,13 @@ nsFontWin* nsFontMetricsWin::LoadGenericFont(HDC aDC, PRUint32 aChar, nsString* aName) { for (int i = mLoadedFonts.Count()-1; i >= 0; --i) { - if (aName->EqualsIgnoreCase(((nsFontWin*)mLoadedFonts[i])->mName)) { + // woah, this seems bad + const nsACString& fontName = + nsDependentCString(((nsFontWin*)mLoadedFonts[i])->mName); + if (aName->Equals(NS_ConvertASCIItoUCS2(((nsFontWin*)mLoadedFonts[i])->mName), + nsCaseInsensitiveStringComparator())) return nsnull; - } + } nsFontWin* font = LoadFont(aDC, aName); if (font && font->HasGlyph(aChar)) { @@ -4664,9 +4668,11 @@ nsFontWin* nsFontMetricsWinA::LoadGenericFont(HDC aDC, PRUnichar aChar, nsString* aName) { for (int i = mLoadedFonts.Count()-1; i >= 0; --i) { - if (aName->EqualsIgnoreCase(((nsFontWinA*)mLoadedFonts[i])->mName)) { + + if (aName->Equals(NS_ConvertASCIItoUCS2(((nsFontWin*)mLoadedFonts[i])->mName), + nsCaseInsensitiveStringComparator())) return nsnull; - } + } nsFontWinA* font = (nsFontWinA*)LoadFont(aDC, aName); if (font && font->HasGlyph(aChar)) { diff --git a/gfx/src/windows/nsNativeThemeWin.cpp b/gfx/src/windows/nsNativeThemeWin.cpp index 879c3d47649c..0a73eba8890a 100644 --- a/gfx/src/windows/nsNativeThemeWin.cpp +++ b/gfx/src/windows/nsNativeThemeWin.cpp @@ -55,6 +55,7 @@ #include "nsIPresContext.h" #include "nsILookAndFeel.h" #include "nsIMenuFrame.h" +#include "nsUnicharUtils.h" #include #define THEME_COLOR 204 @@ -315,13 +316,6 @@ static PRInt32 GetContentState(nsIFrame* aFrame) return flags; } -static PRBool HasAttrValue(nsIContent* aContent, nsIAtom* aAtom, const char* aStr) -{ - nsAutoString attr; - aContent->GetAttr(kNameSpaceID_None, aAtom, attr); - return attr.EqualsIgnoreCase(aStr); -} - static PRBool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom) { if (!aFrame) @@ -333,7 +327,8 @@ static PRBool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom) if (res == NS_CONTENT_ATTR_NO_VALUE || (res != NS_CONTENT_ATTR_NOT_THERE && attr.IsEmpty())) return PR_TRUE; // This handles the HTML case (an attr with no value is like a true val) - return attr.EqualsIgnoreCase("true"); // This handles the XUL case. + return attr.Equals(NS_LITERAL_STRING("true"), // This handles the XUL case. + nsCaseInsensitiveStringComparator()); } PRBool nsNativeThemeWin::IsDisabled(nsIFrame* aFrame) @@ -358,7 +353,8 @@ PRBool nsNativeThemeWin::IsChecked(nsIFrame* aFrame) return PR_TRUE; // XXXdwh Can the HTML form control's checked property differ // from the checked attribute? If so, will need an IsContentofType // HTML followed by a QI to nsIDOMHTMLInputElement to grab the prop. - return checked.EqualsIgnoreCase("true"); // This handles the XUL case. + return checked.Equals(NS_LITERAL_STRING("true"), // This handles the XUL case + nsCaseInsensitiveStringComparator()); } PRBool nsNativeThemeWin::IsSelected(nsIFrame* aFrame) diff --git a/intl/chardet/src/nsMetaCharsetObserver.cpp b/intl/chardet/src/nsMetaCharsetObserver.cpp index ba6c697cc143..5e517a06562d 100644 --- a/intl/chardet/src/nsMetaCharsetObserver.cpp +++ b/intl/chardet/src/nsMetaCharsetObserver.cpp @@ -284,11 +284,11 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify( newCharset = charsetValue; } - + nsDependentString charsetString(charset); + if (!newCharset.IsEmpty()) { - nsAutoString charsetString(charset); - if(! newCharset.EqualsIgnoreCase(charsetString)) + if(! newCharset.Equals(charsetString, nsCaseInsensitiveStringComparator())) { PRBool same = PR_FALSE; nsresult res2 = mAlias->Equals( newCharset, charsetString , &same); diff --git a/intl/locale/src/nsLanguageAtomService.cpp b/intl/locale/src/nsLanguageAtomService.cpp index 936e6c4ae91e..ed7bfd550144 100644 --- a/intl/locale/src/nsLanguageAtomService.cpp +++ b/intl/locale/src/nsLanguageAtomService.cpp @@ -107,7 +107,7 @@ nsLanguageAtom::LanguageIs(const PRUnichar* aLanguage, PRBool* aResult) NS_ENSURE_ARG_POINTER(aLanguage); NS_ENSURE_ARG_POINTER(aResult); - *aResult = mLang.EqualsWithConversion(aLanguage); + *aResult = mLang.Equals(nsDependentString(aLanguage)); return NS_OK; } diff --git a/intl/locale/src/windows/nsDateTimeFormatWin.cpp b/intl/locale/src/windows/nsDateTimeFormatWin.cpp index 2c47e5d35a60..9b5caa8d6e0f 100644 --- a/intl/locale/src/windows/nsDateTimeFormatWin.cpp +++ b/intl/locale/src/windows/nsDateTimeFormatWin.cpp @@ -43,6 +43,7 @@ #include "nsLocaleCID.h" #include "nsILocaleService.h" #include "nsIWin32Locale.h" +#include "nsUnicharUtils.h" #include "nsCRT.h" #include "nsCOMPtr.h" #include "prmem.h" @@ -62,14 +63,14 @@ nsresult nsDateTimeFormatWin::Initialize(nsILocale* locale) // use cached info if match with stored locale if (NULL == locale) { - if (mLocale.Length() && mLocale.EqualsIgnoreCase(mAppLocale)) { + if (mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) { return NS_OK; } } else { res = locale->GetCategory(aCategory.get(), &aLocaleUnichar); if (NS_SUCCEEDED(res) && NULL != aLocaleUnichar) { - if (mLocale.Length() && mLocale.EqualsIgnoreCase(nsString(aLocaleUnichar))) { + if (mLocale.Equals(nsDependentString(aLocaleUnichar), nsCaseInsensitiveStringComparator())) { nsMemory::Free(aLocaleUnichar); return NS_OK; } diff --git a/intl/uconv/src/nsCharsetAliasImp.cpp b/intl/uconv/src/nsCharsetAliasImp.cpp index 4b5cc3c0dcdc..f5c22c080da3 100644 --- a/intl/uconv/src/nsCharsetAliasImp.cpp +++ b/intl/uconv/src/nsCharsetAliasImp.cpp @@ -141,7 +141,7 @@ NS_IMETHODIMP nsCharsetAlias2::Equals(const nsAReadableString& aCharset1, const if(NS_SUCCEEDED(res)) { res = this->GetPreferred(aCharset2, name2); if(NS_SUCCEEDED(res)) { - *oResult = (name1.EqualsIgnoreCase(name2)) ? PR_TRUE : PR_FALSE; + *oResult = name1.Equals(name2, nsCaseInsensitiveStringComparator()); } } diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 36ad8d1301b7..e018c206ce5a 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -55,6 +55,7 @@ class nsIDeviceContext; class nsIRenderingContext; class nsIPageSequenceFrame; class nsString; +class nsAString; class nsStringArray; class nsICaret; class nsIStyleContext; @@ -363,7 +364,7 @@ public: * Scrolls the view of the document so that the anchor with the specified * name is displayed at the top of the window */ - NS_IMETHOD GoToAnchor(const nsString& aAnchorName) = 0; + NS_IMETHOD GoToAnchor(const nsAString& aAnchorName) = 0; /** * Scrolls the view of the document so that the frame is displayed at the diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index cc8bf850fa1a..0f6c346436b1 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -931,7 +931,7 @@ public: nsIRenderingContext** aContext); NS_IMETHOD CantRenderReplacedElement(nsIPresContext* aPresContext, nsIFrame* aFrame); - NS_IMETHOD GoToAnchor(const nsString& aAnchorName); + NS_IMETHOD GoToAnchor(const nsAString& aAnchorName); NS_IMETHOD ScrollFrameIntoView(nsIFrame *aFrame, PRIntn aVPercent, @@ -3828,7 +3828,7 @@ PresShell::CantRenderReplacedElement(nsIPresContext* aPresContext, } NS_IMETHODIMP -PresShell::GoToAnchor(const nsString& aAnchorName) +PresShell::GoToAnchor(const nsAString& aAnchorName) { nsCOMPtr doc = do_QueryInterface(mDocument); nsCOMPtr htmlDoc = do_QueryInterface(mDocument); @@ -3898,7 +3898,7 @@ PresShell::GoToAnchor(const nsString& aAnchorName) nsCOMPtr element = do_QueryInterface(node); nsAutoString value; if (element && NS_SUCCEEDED(element->GetAttribute(NS_LITERAL_STRING("name"), value))) { - if (value.EqualsWithConversion(aAnchorName)) { + if (value.Equals(aAnchorName)) { content = do_QueryInterface(element); break; } @@ -3961,7 +3961,7 @@ PresShell::GoToAnchor(const nsString& aAnchorName) nsCompatibility compatMode; mPresContext->GetCompatibilityMode(&compatMode); - if ((aAnchorName.EqualsIgnoreCase("top")) && + if ((NS_LossyConvertUCS2toASCII(aAnchorName).EqualsIgnoreCase("top")) && (compatMode == eCompatibility_NavQuirks) && (mViewManager)) { // Get the viewport scroller diff --git a/layout/base/public/nsIPresShell.h b/layout/base/public/nsIPresShell.h index 36ad8d1301b7..e018c206ce5a 100644 --- a/layout/base/public/nsIPresShell.h +++ b/layout/base/public/nsIPresShell.h @@ -55,6 +55,7 @@ class nsIDeviceContext; class nsIRenderingContext; class nsIPageSequenceFrame; class nsString; +class nsAString; class nsStringArray; class nsICaret; class nsIStyleContext; @@ -363,7 +364,7 @@ public: * Scrolls the view of the document so that the anchor with the specified * name is displayed at the top of the window */ - NS_IMETHOD GoToAnchor(const nsString& aAnchorName) = 0; + NS_IMETHOD GoToAnchor(const nsAString& aAnchorName) = 0; /** * Scrolls the view of the document so that the frame is displayed at the diff --git a/layout/forms/nsFormControlHelper.cpp b/layout/forms/nsFormControlHelper.cpp index 5875715e957c..bf76f40ec56c 100644 --- a/layout/forms/nsFormControlHelper.cpp +++ b/layout/forms/nsFormControlHelper.cpp @@ -219,18 +219,14 @@ nsFormControlHelper::GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& if (NS_CONTENT_ATTR_NOT_THERE != result) { - nsAutoString wrapHard; wrapHard.AssignWithConversion(kTextControl_Wrap_Hard); - nsAutoString wrapPhysical; wrapPhysical.AssignWithConversion(kTextControl_Wrap_Physical); - if (wrap.EqualsIgnoreCase(wrapHard)) { + if (wrap.EqualsIgnoreCase(kTextControl_Wrap_Hard)) { aWrapProp = eHTMLTextWrap_Hard; return result; } - nsAutoString wrapSoft; wrapSoft.AssignWithConversion(kTextControl_Wrap_Soft); - nsAutoString wrapVirtual; wrapVirtual.AssignWithConversion(kTextControl_Wrap_Virtual); - if (wrap.EqualsIgnoreCase(wrapSoft) || - wrap.EqualsIgnoreCase(wrapVirtual) || - wrap.EqualsIgnoreCase(wrapPhysical)) { + if (wrap.EqualsIgnoreCase(kTextControl_Wrap_Soft) || + wrap.EqualsIgnoreCase(kTextControl_Wrap_Virtual) || + wrap.EqualsIgnoreCase(kTextControl_Wrap_Physical)) { aWrapProp = eHTMLTextWrap_Soft; return result; } diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index cc8bf850fa1a..0f6c346436b1 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -931,7 +931,7 @@ public: nsIRenderingContext** aContext); NS_IMETHOD CantRenderReplacedElement(nsIPresContext* aPresContext, nsIFrame* aFrame); - NS_IMETHOD GoToAnchor(const nsString& aAnchorName); + NS_IMETHOD GoToAnchor(const nsAString& aAnchorName); NS_IMETHOD ScrollFrameIntoView(nsIFrame *aFrame, PRIntn aVPercent, @@ -3828,7 +3828,7 @@ PresShell::CantRenderReplacedElement(nsIPresContext* aPresContext, } NS_IMETHODIMP -PresShell::GoToAnchor(const nsString& aAnchorName) +PresShell::GoToAnchor(const nsAString& aAnchorName) { nsCOMPtr doc = do_QueryInterface(mDocument); nsCOMPtr htmlDoc = do_QueryInterface(mDocument); @@ -3898,7 +3898,7 @@ PresShell::GoToAnchor(const nsString& aAnchorName) nsCOMPtr element = do_QueryInterface(node); nsAutoString value; if (element && NS_SUCCEEDED(element->GetAttribute(NS_LITERAL_STRING("name"), value))) { - if (value.EqualsWithConversion(aAnchorName)) { + if (value.Equals(aAnchorName)) { content = do_QueryInterface(element); break; } @@ -3961,7 +3961,7 @@ PresShell::GoToAnchor(const nsString& aAnchorName) nsCompatibility compatMode; mPresContext->GetCompatibilityMode(&compatMode); - if ((aAnchorName.EqualsIgnoreCase("top")) && + if ((NS_LossyConvertUCS2toASCII(aAnchorName).EqualsIgnoreCase("top")) && (compatMode == eCompatibility_NavQuirks) && (mViewManager)) { // Get the viewport scroller diff --git a/layout/html/forms/src/nsFormControlHelper.cpp b/layout/html/forms/src/nsFormControlHelper.cpp index 5875715e957c..bf76f40ec56c 100644 --- a/layout/html/forms/src/nsFormControlHelper.cpp +++ b/layout/html/forms/src/nsFormControlHelper.cpp @@ -219,18 +219,14 @@ nsFormControlHelper::GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& if (NS_CONTENT_ATTR_NOT_THERE != result) { - nsAutoString wrapHard; wrapHard.AssignWithConversion(kTextControl_Wrap_Hard); - nsAutoString wrapPhysical; wrapPhysical.AssignWithConversion(kTextControl_Wrap_Physical); - if (wrap.EqualsIgnoreCase(wrapHard)) { + if (wrap.EqualsIgnoreCase(kTextControl_Wrap_Hard)) { aWrapProp = eHTMLTextWrap_Hard; return result; } - nsAutoString wrapSoft; wrapSoft.AssignWithConversion(kTextControl_Wrap_Soft); - nsAutoString wrapVirtual; wrapVirtual.AssignWithConversion(kTextControl_Wrap_Virtual); - if (wrap.EqualsIgnoreCase(wrapSoft) || - wrap.EqualsIgnoreCase(wrapVirtual) || - wrap.EqualsIgnoreCase(wrapPhysical)) { + if (wrap.EqualsIgnoreCase(kTextControl_Wrap_Soft) || + wrap.EqualsIgnoreCase(kTextControl_Wrap_Virtual) || + wrap.EqualsIgnoreCase(kTextControl_Wrap_Physical)) { aWrapProp = eHTMLTextWrap_Soft; return result; } diff --git a/layout/mathml/base/src/Makefile.in b/layout/mathml/base/src/Makefile.in index cde271c7a7af..79f964bf31bf 100644 --- a/layout/mathml/base/src/Makefile.in +++ b/layout/mathml/base/src/Makefile.in @@ -37,6 +37,7 @@ REQUIRES = xpcom \ widget \ webshell \ locale \ + unicharutil \ view \ necko \ docshell \ diff --git a/layout/mathml/base/src/makefile.win b/layout/mathml/base/src/makefile.win index eb196c92a293..901518caaa3e 100644 --- a/layout/mathml/base/src/makefile.win +++ b/layout/mathml/base/src/makefile.win @@ -30,6 +30,7 @@ REQUIRES = xpcom \ string \ gfx \ locale \ + unicharutil \ webshell \ necko \ dom \ diff --git a/layout/mathml/base/src/nsMathMLChar.cpp b/layout/mathml/base/src/nsMathMLChar.cpp index 96702829411b..ccf21d27a7c2 100644 --- a/layout/mathml/base/src/nsMathMLChar.cpp +++ b/layout/mathml/base/src/nsMathMLChar.cpp @@ -33,6 +33,7 @@ #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsString.h" +#include "nsUnicharUtils.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" #include "nsStyleUtil.h" @@ -849,7 +850,7 @@ StretchyFontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData) nsGlyphTable* glyphTable = gGlyphTableList->TableAt(i); nsAutoString fontName; glyphTable->GetPrimaryFontName(fontName); - if (fontName.EqualsIgnoreCase(aFamily) && + if (fontName.Equals(aFamily, nsCaseInsensitiveStringComparator()) && glyphTable->Has(currPresContext, currChar)) { currList->AppendElement(glyphTable); // the table is retained return PR_TRUE; // don't stop @@ -947,7 +948,7 @@ PreferredFontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData) for (i = 0; i < count; i++) { glyphTable = gGlyphTableList->TableAt(i); glyphTable->GetPrimaryFontName(fontName); - if (fontName.EqualsIgnoreCase(aFamily)) { + if (fontName.Equals(aFamily, nsCaseInsensitiveStringComparator())) { found = PR_TRUE; break; } @@ -959,7 +960,7 @@ PreferredFontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData) for (i = 0; i < count; i++) { glyphTable = gGlyphTableList->AdditionalTableAt(i); glyphTable->GetPrimaryFontName(fontName); - if (fontName.EqualsIgnoreCase(aFamily)) { + if (fontName.Equals(aFamily, nsCaseInsensitiveStringComparator())) { found = PR_TRUE; break; } diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp index d3d482f1aca2..4d8a656e5caa 100644 --- a/layout/style/nsCSSLoader.cpp +++ b/layout/style/nsCSSLoader.cpp @@ -42,6 +42,7 @@ #include "nsICharsetConverterManager.h" #include "nsIUnicodeDecoder.h" #include "nsICharsetAlias.h" +#include "nsUnicharUtils.h" #include "nsHashtable.h" #include "nsIURL.h" #include "nsIURL.h" @@ -1137,7 +1138,7 @@ PRBool CSSLoaderImpl::IsAlternate(const nsString& aTitle) { if (!aTitle.IsEmpty()) { - return PRBool(! aTitle.EqualsIgnoreCase(mPreferredSheet)); + return PRBool(! aTitle.Equals(mPreferredSheet, nsCaseInsensitiveStringComparator())); } return PR_FALSE; } diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 57060ee7fdcf..e19ffdf04723 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -1490,9 +1490,8 @@ nsMenuPopupFrame::FindMenuWithShortcut(PRUint32 aLetter) char tempChar[2]; tempChar[0] = aLetter; tempChar[1] = 0; - nsAutoString tempChar2; tempChar2.AssignWithConversion(tempChar); - if (shortcutKey.EqualsIgnoreCase(tempChar2)) { + if (shortcutKey.EqualsIgnoreCase(tempChar)) { // We match! nsCOMPtr menuFrame = do_QueryInterface(currFrame); if (menuFrame) diff --git a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp index 2899b438e870..3f7bcf691b4f 100644 --- a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp +++ b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp @@ -1117,8 +1117,8 @@ nsOutlinerBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, nsCOMPtr cellContext; GetPseudoStyleContext(nsXULAtoms::mozoutlinercell, getter_AddRefs(cellContext)); - nsAutoString cell(NS_LITERAL_STRING("cell")); - if (currCol->IsCycler() || cell.EqualsWithConversion(aCellItem)) { + NS_NAMED_LITERAL_STRING(cell, "cell"); + if (currCol->IsCycler() || cell.Equals(aCellItem)) { // If the current Column is a Cycler, then the Rect is just the cell - the margins. // Similarly, if we're just being asked for the cell rect, provide it. diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 2899b438e870..3f7bcf691b4f 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -1117,8 +1117,8 @@ nsOutlinerBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, nsCOMPtr cellContext; GetPseudoStyleContext(nsXULAtoms::mozoutlinercell, getter_AddRefs(cellContext)); - nsAutoString cell(NS_LITERAL_STRING("cell")); - if (currCol->IsCycler() || cell.EqualsWithConversion(aCellItem)) { + NS_NAMED_LITERAL_STRING(cell, "cell"); + if (currCol->IsCycler() || cell.Equals(aCellItem)) { // If the current Column is a Cycler, then the Rect is just the cell - the margins. // Similarly, if we're just being asked for the cell rect, provide it. diff --git a/mailnews/absync/src/nsAbSync.cpp b/mailnews/absync/src/nsAbSync.cpp index 404081904c56..1fd81a1e5f28 100644 --- a/mailnews/absync/src/nsAbSync.cpp +++ b/mailnews/absync/src/nsAbSync.cpp @@ -2795,10 +2795,10 @@ EarlyExit: } PRInt32 -nsAbSync::GetTypeOfPhoneNumber(nsString tagName) -{ - nsString compValue = tagName; - compValue.Append(NS_LITERAL_STRING("_type")); +nsAbSync::GetTypeOfPhoneNumber(const nsAString& tagName) +{ + NS_NAMED_LITERAL_STRING(typePostfix, "_type"); + const nsAString& compValue = tagName + typePostfix; for (PRInt32 i=0; iCount(); i++) { @@ -2806,7 +2806,8 @@ nsAbSync::GetTypeOfPhoneNumber(nsString tagName) if ( (!val) || val->IsEmpty() ) continue; - if (!compValue.CompareWithConversion(*val, PR_TRUE, compValue.Length())) + const nsAString& valPrefix = Substring(*val, 0, compValue.Length()); + if (compValue.Equals(valPrefix, nsCaseInsensitiveStringComparator())) { nsString phoneType; diff --git a/mailnews/absync/src/nsAbSync.h b/mailnews/absync/src/nsAbSync.h index 95b653447311..9ea449747469 100644 --- a/mailnews/absync/src/nsAbSync.h +++ b/mailnews/absync/src/nsAbSync.h @@ -248,7 +248,7 @@ private: nsresult ProcessDeletedRecords(); nsresult ProcessLastChange(); nsresult ProcessPhoneNumbersTheyAreSpecial(nsIAbCard *aCard); - PRInt32 GetTypeOfPhoneNumber(nsString tagName); + PRInt32 GetTypeOfPhoneNumber(const nsAString& tagName); // For updating... PRInt32 HuntForExistingABEntryInServerRecord(PRInt32 aPersonIndex, diff --git a/mailnews/base/util/nsMsgFolder.cpp b/mailnews/base/util/nsMsgFolder.cpp index 318c093c1458..e2b4c670c5bb 100644 --- a/mailnews/base/util/nsMsgFolder.cpp +++ b/mailnews/base/util/nsMsgFolder.cpp @@ -903,7 +903,7 @@ NS_IMETHODIMP nsMsgFolder::GetName(PRUnichar **name) NS_IMETHODIMP nsMsgFolder::SetName(const PRUnichar * name) { // override the URI-generated name - if (!mName.EqualsWithConversion(name)) + if (!mName.Equals(name)) { mName = name; @@ -2285,7 +2285,7 @@ NS_IMETHODIMP nsMsgFolder::MatchName(nsString *name, PRBool *matches) { if (!matches) return NS_ERROR_NULL_POINTER; - *matches = mName.EqualsIgnoreCase(*name); + *matches = mName.Equals(*name, nsCaseInsensitiveStringComparator()); return NS_OK; } diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 1be8748b4c5b..b10292b7ee6b 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -6307,7 +6307,11 @@ NS_IMETHODIMP nsImapMailFolder::MatchName(nsString *name, PRBool *matches) if (!matches) return NS_ERROR_NULL_POINTER; PRBool isInbox = mName.EqualsIgnoreCase("inbox"); - *matches = mName.EqualsWithConversion(*name, isInbox); + if (isInbox) + *matches = mName.Equals(*name, nsCaseInsensitiveStringComparator()); + else + *matches = mName.Equals(*name); + return NS_OK; } diff --git a/mailnews/import/outlook/src/MapiApi.cpp b/mailnews/import/outlook/src/MapiApi.cpp index a7337cdea518..10c4189e6d18 100644 --- a/mailnews/import/outlook/src/MapiApi.cpp +++ b/mailnews/import/outlook/src/MapiApi.cpp @@ -41,6 +41,7 @@ #include "nsCRT.h" #include "prprf.h" #include "nsReadableUtils.h" +#include "nsUnicharUtils.h" int CMapiApi::m_clients = 0; @@ -1530,11 +1531,11 @@ void CMapiFolderList::EnsureUniqueName( CMapiFolder *pFolder) done = TRUE; i = m_array.Count() - 1; while (i >= 0) { - pCurrent = (CMapiFolder *)GetAt( i); + pCurrent = (CMapiFolder *)GetAt(i); if (pCurrent->GetDepth() == pFolder->GetDepth()) { - pCurrent->GetDisplayName( cName); - if (!cName.CompareWithConversion( name, PR_TRUE)) { - ChangeName( name); + pCurrent->GetDisplayName(cName); + if (cName.Equals(name, nsCaseInsensitiveStringComparator())) { + ChangeName(name); pFolder->SetDisplayName(name.get()); done = FALSE; break; diff --git a/mailnews/import/src/Makefile.in b/mailnews/import/src/Makefile.in index ceb3a181f348..eae749937062 100644 --- a/mailnews/import/src/Makefile.in +++ b/mailnews/import/src/Makefile.in @@ -44,6 +44,7 @@ REQUIRES = xpcom \ necko \ rdf \ msgdb \ + unicharutil \ $(NULL) ifeq ($(USE_SHORT_LIBNAME),1) @@ -77,6 +78,7 @@ EXTRA_DSO_LDOPTS += \ $(LIBS_DIR) \ $(EXTRA_DSO_LIBS) \ $(MOZ_COMPONENT_LIBS) \ + $(MOZ_UNICHARUTIL_LIBS) \ $(NULL) diff --git a/mailnews/import/src/makefile.win b/mailnews/import/src/makefile.win index e1bda0659fd1..362850568d06 100644 --- a/mailnews/import/src/makefile.win +++ b/mailnews/import/src/makefile.win @@ -36,6 +36,7 @@ REQUIRES = xpcom \ necko \ rdf \ msgdb \ + unicharutil \ $(NULL) CPP_OBJS=\ @@ -58,6 +59,7 @@ CPP_OBJS=\ LLIBS=\ $(DIST)\lib\xpcom.lib \ + $(DIST)\lib\unicharutil_s.lib \ $(LIBNSPR) \ $(NULL) diff --git a/mailnews/import/src/nsImportMail.cpp b/mailnews/import/src/nsImportMail.cpp index 2ff768839277..2e2ccbcd69cc 100644 --- a/mailnews/import/src/nsImportMail.cpp +++ b/mailnews/import/src/nsImportMail.cpp @@ -51,6 +51,7 @@ #include "nsIImportMailboxDescriptor.h" #include "nsCRT.h" #include "nsString.h" +#include "nsUnicharUtils.h" #include "nsIProxyObjectManager.h" #include "nsXPIDLString.h" @@ -1148,7 +1149,7 @@ void nsImportGenericMail::GetUniquePrettyName( nsIMsgAccountManager *pMgr, nsStr nsXPIDLString prettyName; rv = server->GetPrettyName( getter_Copies( prettyName)); if (NS_SUCCEEDED( rv)) { - if (!newName.CompareWithConversion( nsAutoString(prettyName), PR_TRUE)) + if (newName.Equals( prettyName, nsCaseInsensitiveStringComparator())) found = PR_TRUE; } } diff --git a/modules/plugin/base/src/Makefile.in b/modules/plugin/base/src/Makefile.in index d215c2f1a7fd..53fcc8e83098 100644 --- a/modules/plugin/base/src/Makefile.in +++ b/modules/plugin/base/src/Makefile.in @@ -43,6 +43,7 @@ REQUIRES = xpcom \ caps \ intl \ uconv \ + unicharutil \ dom \ gfx \ layout \ @@ -98,6 +99,7 @@ EXTRA_DSO_LDOPTS = \ $(EXTRA_DSO_LIBS) \ $(MOZ_NECKO_UTIL_LIBS) \ $(MOZ_COMPONENT_LIBS) \ + $(MOZ_UNICHARUTIL_LIBS) \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/modules/plugin/base/src/makefile.win b/modules/plugin/base/src/makefile.win index 4046749cbed2..c37454de3532 100644 --- a/modules/plugin/base/src/makefile.win +++ b/modules/plugin/base/src/makefile.win @@ -39,6 +39,7 @@ REQUIRES = xpcom \ caps \ intl \ uconv \ + unicharutil \ dom \ content \ layout \ @@ -82,6 +83,7 @@ CACHELIBNAME=netcache.lib LLIBS = \ $(DIST)\lib\gkgfx.lib \ $(DIST)\lib\xpcom.lib \ + $(DIST)\lib\unicharutil_s.lib \ $(LIBNSPR) WIN_LIBS = \ diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 011632afe0e2..1337a319ff70 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -147,6 +147,8 @@ #include "nsInt64.h" #include "nsPluginError.h" +#include "nsUnicharUtils.h" + #ifdef XP_UNIX #if defined(MOZ_WIDGET_GTK) #include // for GDK_DISPLAY() @@ -4583,7 +4585,7 @@ static int PR_CALLBACK ComparePluginFileInDirectory (const void *v1, const void PRInt32 result = 0; if (LL_EQ(pfd1->mModTime, pfd2->mModTime)) - result = pfd1->mFilename.CompareWithConversion(pfd2->mFilename.get(), PR_TRUE); + result = Compare(pfd1->mFilename, pfd2->mFilename, nsCaseInsensitiveStringComparator()); else if (LL_CMP(pfd1->mModTime, >, pfd2->mModTime)) result = -1; else diff --git a/webshell/tests/viewer/Makefile.in b/webshell/tests/viewer/Makefile.in index c9b4405bb84f..e383e50ee079 100644 --- a/webshell/tests/viewer/Makefile.in +++ b/webshell/tests/viewer/Makefile.in @@ -48,6 +48,7 @@ REQUIRES = xpcom \ view \ pref \ intl \ + unicharutil \ editor \ cookie \ windowwatcher \ @@ -126,6 +127,7 @@ XP_DIST_LIBS += \ $(EXTRA_DSO_LIBS) \ $(XPCOM_LIBS) \ $(MOZ_JS_LIBS) \ + $(MOZ_UNICHARUTIL_LIBS) \ $(NULL) XP_LIBS = \ diff --git a/webshell/tests/viewer/makefile.win b/webshell/tests/viewer/makefile.win index 25a2e1c011a7..540647035237 100644 --- a/webshell/tests/viewer/makefile.win +++ b/webshell/tests/viewer/makefile.win @@ -39,7 +39,6 @@ REQUIRES = xpcom \ pref \ intl \ editor \ - cookie \ xpconnect \ gfx \ content \ diff --git a/webshell/tests/viewer/nsBrowserWindow.cpp b/webshell/tests/viewer/nsBrowserWindow.cpp index 1115c56f5a2e..f2280fd18298 100644 --- a/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/webshell/tests/viewer/nsBrowserWindow.cpp @@ -78,6 +78,7 @@ #include "nsIWebBrowserSetup.h" #include "nsCWebBrowser.h" +#include "nsUnicharUtils.h" #include "nsIParser.h" #include "nsEditorMode.h" @@ -3310,8 +3311,8 @@ nsBrowserWindow::DispatchStyleMenu(PRInt32 aID) titles.StringAt(index, title); fputs(NS_LossyConvertUCS2toASCII(title).get(), stdout); fprintf(stdout, "\" %s%s\n", - ((title.EqualsIgnoreCase(current)) ? "<< current " : ""), - ((title.EqualsIgnoreCase(defaultStyle)) ? "** default" : "")); + ((title.Equals(current, nsCaseInsensitiveStringComparator())) ? "<< current " : ""), + ((title.Equals(defaultStyle, nsCaseInsensitiveStringComparator())) ? "** default" : "")); } NS_RELEASE(shell); } diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp index 7bd40a72c408..94820e9e4451 100644 --- a/widget/src/windows/nsFilePicker.cpp +++ b/widget/src/windows/nsFilePicker.cpp @@ -33,7 +33,6 @@ #include "nsIPlatformCharset.h" #include "nsFilePicker.h" #include "nsILocalFile.h" -#include "nsIFileChannel.h" #include "nsIURL.h" #include "nsIStringBundle.h" #include @@ -178,9 +177,11 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) if ( extIndex >= 0) { nsAutoString ext; mDefault.Right(ext, mDefault.Length() - extIndex); - // Should we test for ".cgi", ".asp", ".jsp" and other "generated" html pages? - if ( ext.EqualsIgnoreCase(".htm") || - ext.EqualsIgnoreCase(".html") || + // Should we test for ".cgi", ".asp", ".jsp" and other + // "generated" html pages? + + if ( ext.EqualsIgnoreCase(".htm") || + ext.EqualsIgnoreCase(".html") || ext.EqualsIgnoreCase(".shtml") ) { // This is supposed to append ".htm" if user doesn't supply an extension //XXX Actually, behavior is sort of weird: diff --git a/xpfe/browser/src/Makefile.in b/xpfe/browser/src/Makefile.in index 836eade0c8b7..8a44fb51f4d5 100644 --- a/xpfe/browser/src/Makefile.in +++ b/xpfe/browser/src/Makefile.in @@ -38,17 +38,14 @@ REQUIRES = xpcom \ shistory \ widget \ gfx \ - layout \ content \ docshell \ appshell \ dom \ uriloader \ pref \ - editor \ appcomps \ webbrwsr \ - uconv \ chardet \ windowwatcher \ $(NULL) @@ -58,7 +55,7 @@ CPPSRCS = nsBrowserInstance.cpp EXTRA_DSO_LDOPTS = \ $(LIBS_DIR) \ $(MOZ_COMPONENT_LIBS) \ - $(MOZ_JS_LIBS) \ + $(MOZ_UNICHARUTIL_LIBS) \ $(NULL) include $(topsrcdir)/config/rules.mk