Bug 492931 - Part 1a: Change to ASCII case conversion in content/ where appropriate. r=sicking

This commit is contained in:
Emanuel Hoogeveen 2012-02-29 19:31:45 -05:00
parent 106ac5e0c1
commit 36698a56aa
13 changed files with 32 additions and 33 deletions

View File

@ -714,7 +714,7 @@ nsAttrValue::GetEnumString(nsAString& aResult, bool aRealTag) const
if (table->value == val) { if (table->value == val) {
aResult.AssignASCII(table->tag); aResult.AssignASCII(table->tag);
if (!aRealTag && allEnumBits & NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER) { if (!aRealTag && allEnumBits & NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER) {
ToUpperCase(aResult); nsContentUtils::ASCIIToUpper(aResult);
} }
return; return;
} }
@ -1316,7 +1316,7 @@ nsAttrValue::ParseEnumValue(const nsAString& aValue,
if (!equals) { if (!equals) {
nsAutoString tag; nsAutoString tag;
tag.AssignASCII(tableEntry->tag); tag.AssignASCII(tableEntry->tag);
ToUpperCase(tag); nsContentUtils::ASCIIToUpper(tag);
if ((equals = tag.Equals(aValue))) { if ((equals = tag.Equals(aValue))) {
value |= NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER; value |= NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER;
} }

View File

@ -617,8 +617,9 @@ nsContentSink::ProcessLinkHeader(nsIContent* aElement,
if (media.IsEmpty()) { if (media.IsEmpty()) {
media = value; media = value;
// HTML4.0 spec is inconsistent, make it case INSENSITIVE // The HTML5 spec is formulated in terms of the CSS3 spec,
ToLowerCase(media); // which specifies that media queries are case insensitive.
nsContentUtils::ASCIIToLower(media);
} }
} else if (attr.LowerCaseEqualsLiteral("anchor")) { } else if (attr.LowerCaseEqualsLiteral("anchor")) {
if (anchor.IsEmpty()) { if (anchor.IsEmpty()) {
@ -757,7 +758,7 @@ nsContentSink::ProcessMETATag(nsIContent* aContent)
nsAutoString result; nsAutoString result;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, result); aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, result);
if (!result.IsEmpty()) { if (!result.IsEmpty()) {
ToLowerCase(header); nsContentUtils::ASCIIToLower(header);
nsCOMPtr<nsIAtom> fieldAtom(do_GetAtom(header)); nsCOMPtr<nsIAtom> fieldAtom(do_GetAtom(header));
rv = ProcessHeaderData(fieldAtom, result, aContent); rv = ProcessHeaderData(fieldAtom, result, aContent);
} }
@ -769,7 +770,7 @@ nsContentSink::ProcessMETATag(nsIContent* aContent)
nsAutoString result; nsAutoString result;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, result); aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, result);
if (!result.IsEmpty()) { if (!result.IsEmpty()) {
ToLowerCase(result); nsContentUtils::ASCIIToLower(result);
mDocument->SetHeaderData(nsGkAtoms::handheldFriendly, result); mDocument->SetHeaderData(nsGkAtoms::handheldFriendly, result);
} }
} }

View File

@ -211,10 +211,9 @@ nsDOMAttribute::GetNameAtom(nsIContent* aContent)
aContent->IsInHTMLDocument() && aContent->IsInHTMLDocument() &&
aContent->IsHTML()) { aContent->IsHTML()) {
nsAutoString name; nsAutoString name;
mNodeInfo->NameAtom()->ToString(name); mNodeInfo->GetName(name);
nsAutoString lower; nsContentUtils::ASCIIToLower(name);
ToLowerCase(name, lower); nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(name);
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(lower);
nameAtom.swap(result); nameAtom.swap(result);
} else { } else {
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom(); nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();

View File

@ -335,9 +335,7 @@ nsDOMAttributeMap::SetNamedItemInternal(nsIDOMNode *aNode,
else { else {
if (mContent->IsInHTMLDocument() && if (mContent->IsInHTMLDocument() &&
mContent->IsHTML()) { mContent->IsHTML()) {
nsAutoString lower; nsContentUtils::ASCIIToLower(name);
ToLowerCase(name, lower);
name = lower;
} }
rv = mContent->NodeInfo()->NodeInfoManager()-> rv = mContent->NodeInfo()->NodeInfoManager()->

View File

@ -4423,7 +4423,7 @@ nsDocument::CreateElement(const nsAString& aTagName,
bool needsLowercase = IsHTML() && !IsLowercaseASCII(aTagName); bool needsLowercase = IsHTML() && !IsLowercaseASCII(aTagName);
nsAutoString lcTagName; nsAutoString lcTagName;
if (needsLowercase) { if (needsLowercase) {
ToLowerCase(aTagName, lcTagName); nsContentUtils::ASCIIToLower(aTagName, lcTagName);
} }
rv = CreateElem(needsLowercase ? lcTagName : aTagName, rv = CreateElem(needsLowercase ? lcTagName : aTagName,

View File

@ -185,7 +185,7 @@ PRUint32 nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
while (current != done) { while (current != done) {
if (nsContentUtils::IsHTMLWhitespace(*current)) { if (nsContentUtils::IsHTMLWhitespace(*current)) {
if (inString) { if (inString) {
ToLowerCase(Substring(start, current), subString); nsContentUtils::ASCIIToLower(Substring(start, current), subString);
linkMask |= ToLinkMask(subString); linkMask |= ToLinkMask(subString);
inString = false; inString = false;
} }
@ -199,7 +199,7 @@ PRUint32 nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
++current; ++current;
} }
if (inString) { if (inString) {
ToLowerCase(Substring(start, current), subString); nsContentUtils::ASCIIToLower(Substring(start, current), subString);
linkMask |= ToLinkMask(subString); linkMask |= ToLinkMask(subString);
} }
return linkMask; return linkMask;

View File

@ -2489,7 +2489,7 @@ nsresult
nsGenericHTMLElement::SetContentEditable(const nsAString& aContentEditable) nsGenericHTMLElement::SetContentEditable(const nsAString& aContentEditable)
{ {
nsString contentEditable; nsString contentEditable;
ToLowerCase(aContentEditable, contentEditable); nsContentUtils::ASCIIToLower(aContentEditable, contentEditable);
if (contentEditable.EqualsLiteral("inherit")) { if (contentEditable.EqualsLiteral("inherit")) {
UnsetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, true); UnsetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, true);

View File

@ -433,7 +433,9 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
} }
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); 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 mimeType;
nsAutoString notUsed; nsAutoString notUsed;

View File

@ -340,7 +340,9 @@ nsHTMLStyleElement::GetStyleSheetInfo(nsAString& aTitle,
aTitle.Assign(title); aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); 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); GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);

View File

@ -1361,7 +1361,7 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl,
contentType.AssignLiteral("text/html"); contentType.AssignLiteral("text/html");
if (aOptionalArgCount > 0) { if (aOptionalArgCount > 0) {
nsAutoString type; nsAutoString type;
ToLowerCase(aContentTypeOrUrl, type); nsContentUtils::ASCIIToLower(aContentTypeOrUrl, type);
nsCAutoString actualType, dummy; nsCAutoString actualType, dummy;
NS_ParseContentType(NS_ConvertUTF16toUTF8(type), actualType, dummy); NS_ParseContentType(NS_ConvertUTF16toUTF8(type), actualType, dummy);
if (!actualType.EqualsLiteral("text/html") && if (!actualType.EqualsLiteral("text/html") &&

View File

@ -337,9 +337,9 @@ nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
aTitle.Assign(title); aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// SVG spec refers to the HTML4.0 spec which is inconsistent, make it // The SVG spec is formulated in terms of the CSS2 spec,
// case INSENSITIVE // which specifies that media queries are case insensitive.
ToLowerCase(aMedia); nsContentUtils::ASCIIToLower(aMedia);
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
if (aType.IsEmpty()) { if (aType.IsEmpty()) {

View File

@ -932,21 +932,18 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement,
if (!key.IsEmpty()) { if (!key.IsEmpty()) {
if (mKeyMask == 0) if (mKeyMask == 0)
mKeyMask = cAllModifiers; mKeyMask = cAllModifiers;
ToLowerCase(key); nsContentUtils::ASCIIToLower(key);
// We have a charcode. // We have a charcode.
mMisc = 1; mMisc = 1;
mDetail = key[0]; mDetail = key[0];
const PRUint8 GTK2Modifiers = cShift | cControl | cShiftMask | cControlMask; const PRUint8 GTK2Modifiers = cShift | cControl | cShiftMask | cControlMask;
if ((mKeyMask & GTK2Modifiers) == GTK2Modifiers && if ((mKeyMask & GTK2Modifiers) == GTK2Modifiers &&
modifiers.First() != PRUnichar(',') && modifiers.First() != PRUnichar(',') && mDetail == 'u')
(mDetail == 'u' || mDetail == 'U'))
ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "GTK2Conflict"); ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "GTK2Conflict");
const PRUint8 WinModifiers = cControl | cAlt | cControlMask | cAltMask; const PRUint8 WinModifiers = cControl | cAlt | cControlMask | cAltMask;
if ((mKeyMask & WinModifiers) == WinModifiers && if ((mKeyMask & WinModifiers) == WinModifiers &&
modifiers.First() != PRUnichar(',') && modifiers.First() != PRUnichar(',') && ('a' <= mDetail && mDetail <= 'z'))
(('A' <= mDetail && mDetail <= 'Z') ||
('a' <= mDetail && mDetail <= 'z')))
ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict"); ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict");
} }
else { else {

View File

@ -160,7 +160,7 @@ txMozillaXMLOutput::attribute(nsIAtom* aPrefix,
if (mOpenedElementIsHTML && aNsID == kNameSpaceID_None) { if (mOpenedElementIsHTML && aNsID == kNameSpaceID_None) {
nsAutoString lnameStr; nsAutoString lnameStr;
ToLowerCase(aLocalName, lnameStr); TX_ToLowerCase(aLocalName, lnameStr);
lname = do_GetAtom(lnameStr); lname = do_GetAtom(lnameStr);
} }
else { else {
@ -499,7 +499,7 @@ txMozillaXMLOutput::startElement(nsIAtom* aPrefix,
nsId = kNameSpaceID_XHTML; nsId = kNameSpaceID_XHTML;
nsAutoString lnameStr; nsAutoString lnameStr;
ToLowerCase(aLocalName, lnameStr); TX_ToLowerCase(aLocalName, lnameStr);
lname = do_GetAtom(lnameStr); lname = do_GetAtom(lnameStr);
} }
else { else {
@ -802,7 +802,7 @@ txMozillaXMLOutput::endHTMLElement(nsIContent* aElement)
nsAutoString value; nsAutoString value;
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::content, value); aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::content, value);
if (!value.IsEmpty()) { if (!value.IsEmpty()) {
ToLowerCase(httpEquiv); nsContentUtils::ASCIIToLower(httpEquiv);
nsCOMPtr<nsIAtom> header = do_GetAtom(httpEquiv); nsCOMPtr<nsIAtom> header = do_GetAtom(httpEquiv);
processHTTPEquiv(header, value); processHTTPEquiv(header, value);
} }