From a59e8cb2be035b0645998c49b22770bfffedf5da Mon Sep 17 00:00:00 2001 From: Emanuel Hoogeveen Date: Wed, 29 Feb 2012 19:31:45 -0500 Subject: [PATCH] Bug 492931 - Part 1a: Change to ASCII case conversion in content/ where appropriate. r=sicking --- content/base/src/nsAttrValue.cpp | 4 ++-- content/base/src/nsContentSink.cpp | 9 +++++---- content/base/src/nsDOMAttribute.cpp | 7 +++---- content/base/src/nsDOMAttributeMap.cpp | 4 +--- content/base/src/nsDocument.cpp | 2 +- content/base/src/nsStyleLinkElement.cpp | 6 +++--- content/html/content/src/nsGenericHTMLElement.cpp | 2 +- content/html/content/src/nsHTMLLinkElement.cpp | 4 +++- content/html/content/src/nsHTMLStyleElement.cpp | 4 +++- content/html/document/src/nsHTMLDocument.cpp | 2 +- content/svg/content/src/nsSVGStyleElement.cpp | 6 +++--- content/xbl/src/nsXBLPrototypeHandler.cpp | 9 +++------ content/xslt/src/xslt/txMozillaXMLOutput.cpp | 6 +++--- 13 files changed, 32 insertions(+), 33 deletions(-) diff --git a/content/base/src/nsAttrValue.cpp b/content/base/src/nsAttrValue.cpp index dd9b995358f..c372a1bfd4a 100644 --- a/content/base/src/nsAttrValue.cpp +++ b/content/base/src/nsAttrValue.cpp @@ -714,7 +714,7 @@ nsAttrValue::GetEnumString(nsAString& aResult, bool aRealTag) const if (table->value == val) { aResult.AssignASCII(table->tag); if (!aRealTag && allEnumBits & NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER) { - ToUpperCase(aResult); + nsContentUtils::ASCIIToUpper(aResult); } return; } @@ -1316,7 +1316,7 @@ nsAttrValue::ParseEnumValue(const nsAString& aValue, if (!equals) { nsAutoString tag; tag.AssignASCII(tableEntry->tag); - ToUpperCase(tag); + nsContentUtils::ASCIIToUpper(tag); if ((equals = tag.Equals(aValue))) { value |= NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER; } diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 601e7829c0c..768acbce10f 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -617,8 +617,9 @@ nsContentSink::ProcessLinkHeader(nsIContent* aElement, if (media.IsEmpty()) { media = value; - // HTML4.0 spec is inconsistent, make it case INSENSITIVE - ToLowerCase(media); + // The HTML5 spec is formulated in terms of the CSS3 spec, + // which specifies that media queries are case insensitive. + nsContentUtils::ASCIIToLower(media); } } else if (attr.LowerCaseEqualsLiteral("anchor")) { if (anchor.IsEmpty()) { @@ -757,7 +758,7 @@ nsContentSink::ProcessMETATag(nsIContent* aContent) nsAutoString result; aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, result); if (!result.IsEmpty()) { - ToLowerCase(header); + nsContentUtils::ASCIIToLower(header); nsCOMPtr fieldAtom(do_GetAtom(header)); rv = ProcessHeaderData(fieldAtom, result, aContent); } @@ -769,7 +770,7 @@ nsContentSink::ProcessMETATag(nsIContent* aContent) nsAutoString result; aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, result); if (!result.IsEmpty()) { - ToLowerCase(result); + nsContentUtils::ASCIIToLower(result); mDocument->SetHeaderData(nsGkAtoms::handheldFriendly, result); } } diff --git a/content/base/src/nsDOMAttribute.cpp b/content/base/src/nsDOMAttribute.cpp index 77795865214..6e8f52fe641 100644 --- a/content/base/src/nsDOMAttribute.cpp +++ b/content/base/src/nsDOMAttribute.cpp @@ -211,10 +211,9 @@ nsDOMAttribute::GetNameAtom(nsIContent* aContent) aContent->IsInHTMLDocument() && aContent->IsHTML()) { nsAutoString name; - mNodeInfo->NameAtom()->ToString(name); - nsAutoString lower; - ToLowerCase(name, lower); - nsCOMPtr nameAtom = do_GetAtom(lower); + mNodeInfo->GetName(name); + nsContentUtils::ASCIIToLower(name); + nsCOMPtr nameAtom = do_GetAtom(name); nameAtom.swap(result); } else { nsCOMPtr nameAtom = mNodeInfo->NameAtom(); diff --git a/content/base/src/nsDOMAttributeMap.cpp b/content/base/src/nsDOMAttributeMap.cpp index 6a6d442d643..f0617a0e5fa 100644 --- a/content/base/src/nsDOMAttributeMap.cpp +++ b/content/base/src/nsDOMAttributeMap.cpp @@ -335,9 +335,7 @@ nsDOMAttributeMap::SetNamedItemInternal(nsIDOMNode *aNode, else { if (mContent->IsInHTMLDocument() && mContent->IsHTML()) { - nsAutoString lower; - ToLowerCase(name, lower); - name = lower; + nsContentUtils::ASCIIToLower(name); } rv = mContent->NodeInfo()->NodeInfoManager()-> diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 4837d14f621..b429d2f450a 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -4423,7 +4423,7 @@ nsDocument::CreateElement(const nsAString& aTagName, bool needsLowercase = IsHTML() && !IsLowercaseASCII(aTagName); nsAutoString lcTagName; if (needsLowercase) { - ToLowerCase(aTagName, lcTagName); + nsContentUtils::ASCIIToLower(aTagName, lcTagName); } rv = CreateElem(needsLowercase ? lcTagName : aTagName, diff --git a/content/base/src/nsStyleLinkElement.cpp b/content/base/src/nsStyleLinkElement.cpp index 9cb62d9cfd4..36e923811ba 100644 --- a/content/base/src/nsStyleLinkElement.cpp +++ b/content/base/src/nsStyleLinkElement.cpp @@ -185,7 +185,7 @@ PRUint32 nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes) while (current != done) { if (nsContentUtils::IsHTMLWhitespace(*current)) { if (inString) { - ToLowerCase(Substring(start, current), subString); + nsContentUtils::ASCIIToLower(Substring(start, current), subString); linkMask |= ToLinkMask(subString); inString = false; } @@ -199,8 +199,8 @@ PRUint32 nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes) ++current; } if (inString) { - ToLowerCase(Substring(start, current), subString); - linkMask |= ToLinkMask(subString); + nsContentUtils::ASCIIToLower(Substring(start, current), subString); + linkMask |= ToLinkMask(subString); } return linkMask; } diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 6fc86ebd7b7..0ef219ce376 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -2489,7 +2489,7 @@ nsresult nsGenericHTMLElement::SetContentEditable(const nsAString& aContentEditable) { nsString contentEditable; - ToLowerCase(aContentEditable, contentEditable); + nsContentUtils::ASCIIToLower(aContentEditable, contentEditable); if (contentEditable.EqualsLiteral("inherit")) { UnsetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, true); diff --git a/content/html/content/src/nsHTMLLinkElement.cpp b/content/html/content/src/nsHTMLLinkElement.cpp index 478f2cb840c..18ce3485e81 100644 --- a/content/html/content/src/nsHTMLLinkElement.cpp +++ b/content/html/content/src/nsHTMLLinkElement.cpp @@ -433,7 +433,9 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle, } GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - ToLowerCase(aMedia); // HTML4.0 spec is inconsistent, make it case INSENSITIVE + // The HTML5 spec is formulated in terms of the CSSOM spec, which specifies + // that media queries should be ASCII lowercased during serialization. + nsContentUtils::ASCIIToLower(aMedia); nsAutoString mimeType; nsAutoString notUsed; diff --git a/content/html/content/src/nsHTMLStyleElement.cpp b/content/html/content/src/nsHTMLStyleElement.cpp index 935af2a8e60..8d87a269e56 100644 --- a/content/html/content/src/nsHTMLStyleElement.cpp +++ b/content/html/content/src/nsHTMLStyleElement.cpp @@ -340,7 +340,9 @@ nsHTMLStyleElement::GetStyleSheetInfo(nsAString& aTitle, aTitle.Assign(title); GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - ToLowerCase(aMedia); // HTML4.0 spec is inconsistent, make it case INSENSITIVE + // The HTML5 spec is formulated in terms of the CSSOM spec, which specifies + // that media queries should be ASCII lowercased during serialization. + nsContentUtils::ASCIIToLower(aMedia); GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index baf1d436ac9..42879425af3 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -1361,7 +1361,7 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl, contentType.AssignLiteral("text/html"); if (aOptionalArgCount > 0) { nsAutoString type; - ToLowerCase(aContentTypeOrUrl, type); + nsContentUtils::ASCIIToLower(aContentTypeOrUrl, type); nsCAutoString actualType, dummy; NS_ParseContentType(NS_ConvertUTF16toUTF8(type), actualType, dummy); if (!actualType.EqualsLiteral("text/html") && diff --git a/content/svg/content/src/nsSVGStyleElement.cpp b/content/svg/content/src/nsSVGStyleElement.cpp index 181ef23b450..14204e643cc 100644 --- a/content/svg/content/src/nsSVGStyleElement.cpp +++ b/content/svg/content/src/nsSVGStyleElement.cpp @@ -337,9 +337,9 @@ nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle, aTitle.Assign(title); GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - // SVG spec refers to the HTML4.0 spec which is inconsistent, make it - // case INSENSITIVE - ToLowerCase(aMedia); + // The SVG spec is formulated in terms of the CSS2 spec, + // which specifies that media queries are case insensitive. + nsContentUtils::ASCIIToLower(aMedia); GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); if (aType.IsEmpty()) { diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp index 017e762d020..0b2a36ad9f2 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -932,21 +932,18 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement, if (!key.IsEmpty()) { if (mKeyMask == 0) mKeyMask = cAllModifiers; - ToLowerCase(key); + nsContentUtils::ASCIIToLower(key); // We have a charcode. mMisc = 1; mDetail = key[0]; const PRUint8 GTK2Modifiers = cShift | cControl | cShiftMask | cControlMask; if ((mKeyMask & GTK2Modifiers) == GTK2Modifiers && - modifiers.First() != PRUnichar(',') && - (mDetail == 'u' || mDetail == 'U')) + modifiers.First() != PRUnichar(',') && mDetail == 'u') ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "GTK2Conflict"); const PRUint8 WinModifiers = cControl | cAlt | cControlMask | cAltMask; if ((mKeyMask & WinModifiers) == WinModifiers && - modifiers.First() != PRUnichar(',') && - (('A' <= mDetail && mDetail <= 'Z') || - ('a' <= mDetail && mDetail <= 'z'))) + modifiers.First() != PRUnichar(',') && ('a' <= mDetail && mDetail <= 'z')) ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict"); } else { diff --git a/content/xslt/src/xslt/txMozillaXMLOutput.cpp b/content/xslt/src/xslt/txMozillaXMLOutput.cpp index 172750139c6..000bd3494ba 100644 --- a/content/xslt/src/xslt/txMozillaXMLOutput.cpp +++ b/content/xslt/src/xslt/txMozillaXMLOutput.cpp @@ -160,7 +160,7 @@ txMozillaXMLOutput::attribute(nsIAtom* aPrefix, if (mOpenedElementIsHTML && aNsID == kNameSpaceID_None) { nsAutoString lnameStr; - ToLowerCase(aLocalName, lnameStr); + TX_ToLowerCase(aLocalName, lnameStr); lname = do_GetAtom(lnameStr); } else { @@ -499,7 +499,7 @@ txMozillaXMLOutput::startElement(nsIAtom* aPrefix, nsId = kNameSpaceID_XHTML; nsAutoString lnameStr; - ToLowerCase(aLocalName, lnameStr); + TX_ToLowerCase(aLocalName, lnameStr); lname = do_GetAtom(lnameStr); } else { @@ -802,7 +802,7 @@ txMozillaXMLOutput::endHTMLElement(nsIContent* aElement) nsAutoString value; aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::content, value); if (!value.IsEmpty()) { - ToLowerCase(httpEquiv); + nsContentUtils::ASCIIToLower(httpEquiv); nsCOMPtr header = do_GetAtom(httpEquiv); processHTTPEquiv(header, value); }