Backout bug 492921 due to mochitest crashing.

This commit is contained in:
Ryan VanderMeulen 2012-02-29 20:29:49 -05:00
Родитель fab04db84d
Коммит 6adc508f04
18 изменённых файлов: 51 добавлений и 125 удалений

Просмотреть файл

@ -1598,43 +1598,7 @@ public:
* case for ASCII characters a-z. * case for ASCII characters a-z.
*/ */
static bool EqualsIgnoreASCIICase(const nsAString& aStr1, static bool EqualsIgnoreASCIICase(const nsAString& aStr1,
const nsAString& aStr2); const nsAString& aStr2);
/**
* Case insensitive comparison between a string and an ASCII literal.
* This must ONLY be applied to an actual literal string. Do not attempt
* to use it with a regular char* pointer, or with a char array variable.
* The template trick to acquire the array length at compile time without
* using a macro is due to Corey Kosak, which much thanks.
*/
static bool EqualsLiteralIgnoreASCIICase(const nsAString& aStr1,
const char* aStr2,
const PRUint32 len);
#ifdef NS_DISABLE_LITERAL_TEMPLATE
static inline bool
EqualsLiteralIgnoreASCIICase(const nsAString& aStr1,
const char* aStr2)
{
PRUint32 len = strlen(aStr2);
return EqualsLiteralIgnoreASCIICase(aStr1, aStr2, len);
}
#else
template<int N>
static inline bool
EqualsLiteralIgnoreASCIICase(const nsAString& aStr1,
const char (&aStr2)[N])
{
return EqualsLiteralIgnoreASCIICase(aStr1, aStr2, N-1);
}
template<int N>
static inline bool
EqualsLiteralIgnoreASCIICase(const nsAString& aStr1,
char (&aStr2)[N])
{
const char* s = aStr2;
return EqualsLiteralIgnoreASCIICase(aStr1, s, N-1);
}
#endif
/** /**
* Convert ASCII A-Z to a-z. * Convert ASCII A-Z to a-z.

Просмотреть файл

@ -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) {
nsContentUtils::ASCIIToUpper(aResult); ToUpperCase(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);
nsContentUtils::ASCIIToUpper(tag); ToUpperCase(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;
} }

Просмотреть файл

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

Просмотреть файл

@ -5322,7 +5322,6 @@ nsContentUtils::ASCIIToUpper(const nsAString& aSource, nsAString& aDest)
} }
} }
/* static */
bool bool
nsContentUtils::EqualsIgnoreASCIICase(const nsAString& aStr1, nsContentUtils::EqualsIgnoreASCIICase(const nsAString& aStr1,
const nsAString& aStr2) const nsAString& aStr2)
@ -5345,7 +5344,7 @@ nsContentUtils::EqualsIgnoreASCIICase(const nsAString& aStr1,
return false; return false;
} }
// We know they can only differ in the 0x0020 bit. // We know they only differ in the 0x0020 bit.
// Likely the two chars are the same, so check that first // Likely the two chars are the same, so check that first
if (c1 != c2) { if (c1 != c2) {
// They do differ, but since it's only in the 0x0020 bit, check if it's // They do differ, but since it's only in the 0x0020 bit, check if it's
@ -5360,44 +5359,6 @@ nsContentUtils::EqualsIgnoreASCIICase(const nsAString& aStr1,
return true; return true;
} }
/* static */
bool
nsContentUtils::EqualsLiteralIgnoreASCIICase(const nsAString& aStr1,
const char* aStr2,
const PRUint32 len)
{
if (aStr1.Length() != len) {
return false;
}
const PRUnichar* str1 = aStr1.BeginReading();
const char* str2 = str2;
const PRUnichar* end = str1 + len;
while (str1 < end) {
PRUnichar c1 = *str1++;
PRUnichar c2 = *str2++;
// First check if any bits other than the 0x0020 differs
if ((c1 ^ c2) & 0xffdf) {
return false;
}
// We know they can only differ in the 0x0020 bit.
// Likely the two chars are the same, so check that first
if (c1 != c2) {
// They do differ, but since it's only in the 0x0020 bit, check if it's
// the same ascii char, but just differing in case
PRUnichar c1Upper = c1 & 0xffdf;
if (!('A' <= c1Upper && c1Upper <= 'Z')) {
return false;
}
}
}
return true;
}
/* static */ /* static */
nsIInterfaceRequestor* nsIInterfaceRequestor*
nsContentUtils::GetSameOriginChecker() nsContentUtils::GetSameOriginChecker()

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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) {
nsContentUtils::ASCIIToLower(aTagName, lcTagName); ToLowerCase(aTagName, lcTagName);
} }
rv = CreateElem(needsLowercase ? lcTagName : aTagName, rv = CreateElem(needsLowercase ? lcTagName : aTagName,

Просмотреть файл

@ -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) {
nsContentUtils::ASCIIToLower(Substring(start, current), subString); ToLowerCase(Substring(start, current), subString);
linkMask |= ToLinkMask(subString); linkMask |= ToLinkMask(subString);
inString = false; inString = false;
} }
@ -199,8 +199,8 @@ PRUint32 nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
++current; ++current;
} }
if (inString) { if (inString) {
nsContentUtils::ASCIIToLower(Substring(start, current), subString); ToLowerCase(Substring(start, current), subString);
linkMask |= ToLinkMask(subString); linkMask |= ToLinkMask(subString);
} }
return linkMask; return linkMask;
} }

Просмотреть файл

@ -2488,25 +2488,24 @@ nsGenericHTMLElement::GetContentEditable(nsAString& aContentEditable)
nsresult nsresult
nsGenericHTMLElement::SetContentEditable(const nsAString& aContentEditable) nsGenericHTMLElement::SetContentEditable(const nsAString& aContentEditable)
{ {
if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "inherit")) { nsString contentEditable;
ToLowerCase(aContentEditable, contentEditable);
if (contentEditable.EqualsLiteral("inherit")) {
UnsetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, true); UnsetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, true);
return NS_OK; return NS_OK;
} }
if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "true")) { if (!contentEditable.EqualsLiteral("true") &&
SetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, NS_LITERAL_STRING("true"), true); !contentEditable.EqualsLiteral("false")) {
return NS_ERROR_DOM_SYNTAX_ERR;
return NS_OK;
}
if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "false")) {
SetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, NS_LITERAL_STRING("false"), true);
return NS_OK;
} }
return NS_ERROR_DOM_SYNTAX_ERR; SetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, contentEditable,
true);
return NS_OK;
} }
nsresult nsresult

Просмотреть файл

@ -433,9 +433,7 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
} }
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// The HTML5 spec is formulated in terms of the CSSOM spec, which specifies ToLowerCase(aMedia); // HTML4.0 spec is inconsistent, make it case INSENSITIVE
// that media queries should be ASCII lowercased during serialization.
nsContentUtils::ASCIIToLower(aMedia);
nsAutoString mimeType; nsAutoString mimeType;
nsAutoString notUsed; nsAutoString notUsed;

Просмотреть файл

@ -340,9 +340,7 @@ nsHTMLStyleElement::GetStyleSheetInfo(nsAString& aTitle,
aTitle.Assign(title); aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// The HTML5 spec is formulated in terms of the CSSOM spec, which specifies ToLowerCase(aMedia); // HTML4.0 spec is inconsistent, make it case INSENSITIVE
// that media queries should be ASCII lowercased during serialization.
nsContentUtils::ASCIIToLower(aMedia);
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);

Просмотреть файл

@ -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;
nsContentUtils::ASCIIToLower(aContentTypeOrUrl, type); ToLowerCase(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") &&

Просмотреть файл

@ -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);
// The SVG spec is formulated in terms of the CSS2 spec, // SVG spec refers to the HTML4.0 spec which is inconsistent, make it
// which specifies that media queries are case insensitive. // case INSENSITIVE
nsContentUtils::ASCIIToLower(aMedia); ToLowerCase(aMedia);
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
if (aType.IsEmpty()) { if (aType.IsEmpty()) {

Просмотреть файл

@ -932,18 +932,21 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement,
if (!key.IsEmpty()) { if (!key.IsEmpty()) {
if (mKeyMask == 0) if (mKeyMask == 0)
mKeyMask = cAllModifiers; mKeyMask = cAllModifiers;
nsContentUtils::ASCIIToLower(key); ToLowerCase(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(',') && mDetail == 'u') modifiers.First() != PRUnichar(',') &&
(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(',') && ('a' <= mDetail && mDetail <= 'z')) modifiers.First() != PRUnichar(',') &&
(('A' <= mDetail && mDetail <= 'Z') ||
('a' <= mDetail && mDetail <= 'z')))
ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict"); ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict");
} }
else { else {

Просмотреть файл

@ -44,6 +44,8 @@
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#define TX_ToLowerCase ToLowerCase
typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator; typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
/** /**
@ -60,7 +62,7 @@ TX_ToLowerCaseAtom(nsIAtom* aAtom)
{ {
nsAutoString str; nsAutoString str;
aAtom->ToString(str); aAtom->ToString(str);
nsContentUtils::ASCIIToLower(str); TX_ToLowerCase(str);
return do_GetAtom(str); return do_GetAtom(str);
} }

Просмотреть файл

@ -938,7 +938,7 @@ txExprParser::resolveQName(const nsAString& aQName,
*aPrefix = 0; *aPrefix = 0;
if (aIsNameTest && aContext->caseInsensitiveNameTests()) { if (aIsNameTest && aContext->caseInsensitiveNameTests()) {
nsAutoString lcname; nsAutoString lcname;
nsContentUtils::ASCIIToLower(aQName, lcname); TX_ToLowerCase(aQName, lcname);
*aLocalName = NS_NewAtom(lcname); *aLocalName = NS_NewAtom(lcname);
} }
else { else {

Просмотреть файл

@ -453,7 +453,7 @@ txXPathNodeUtils::getLocalName(const txXPathNode& aNode, nsAString& aLocalName)
// Check for html // Check for html
if (aNode.Content()->NodeInfo()->NamespaceEquals(kNameSpaceID_None) && if (aNode.Content()->NodeInfo()->NamespaceEquals(kNameSpaceID_None) &&
aNode.Content()->IsHTML()) { aNode.Content()->IsHTML()) {
nsContentUtils::ASCIIToUpper(aLocalName); ToUpperCase(aLocalName);
} }
} }

Просмотреть файл

@ -160,7 +160,7 @@ txMozillaXMLOutput::attribute(nsIAtom* aPrefix,
if (mOpenedElementIsHTML && aNsID == kNameSpaceID_None) { if (mOpenedElementIsHTML && aNsID == kNameSpaceID_None) {
nsAutoString lnameStr; nsAutoString lnameStr;
nsContentUtils::ASCIIToLower(aLocalName, lnameStr); 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;
nsContentUtils::ASCIIToLower(aLocalName, lnameStr); 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()) {
nsContentUtils::ASCIIToLower(httpEquiv); ToLowerCase(httpEquiv);
nsCOMPtr<nsIAtom> header = do_GetAtom(httpEquiv); nsCOMPtr<nsIAtom> header = do_GetAtom(httpEquiv);
processHTTPEquiv(header, value); processHTTPEquiv(header, value);
} }