Backout changeset 89a9f4a88d5b (bug 676413) for causing content/html/content/test/test_bug664299.html failures.

This commit is contained in:
L. David Baron 2011-08-10 18:00:39 -07:00
Родитель 376285b3db
Коммит 50fab69e73
3 изменённых файлов: 26 добавлений и 46 удалений

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

@ -980,35 +980,28 @@ nsAttrValue::SetIntValueAndType(PRInt32 aValue, ValueType aType,
}
}
PRInt16
nsAttrValue::GetEnumTableIndex(const EnumTable* aTable)
PRBool
nsAttrValue::GetEnumTableIndex(const EnumTable* aTable, PRInt16& aResult)
{
PRInt16 index = sEnumTableArray->IndexOf(aTable);
if (index < 0) {
index = sEnumTableArray->Length();
NS_ASSERTION(index <= NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE,
"too many enum tables");
sEnumTableArray->AppendElement(aTable);
if (!sEnumTableArray->AppendElement(aTable)) {
return PR_FALSE;
}
}
return index;
}
aResult = index;
PRInt32
nsAttrValue::EnumTableEntryToValue(const EnumTable* aEnumTable,
const EnumTable* aTableEntry)
{
PRInt16 index = GetEnumTableIndex(aEnumTable);
PRInt32 value = (aTableEntry->value << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) +
index;
return value;
return PR_TRUE;
}
PRBool
nsAttrValue::ParseEnumValue(const nsAString& aValue,
const EnumTable* aTable,
PRBool aCaseSensitive,
const EnumTable* aDefaultValue)
PRBool aCaseSensitive)
{
ResetIfSet();
const EnumTable* tableEntry = aTable;
@ -1016,7 +1009,13 @@ nsAttrValue::ParseEnumValue(const nsAString& aValue,
while (tableEntry->tag) {
if (aCaseSensitive ? aValue.EqualsASCII(tableEntry->tag) :
aValue.LowerCaseEqualsASCII(tableEntry->tag)) {
PRInt32 value = EnumTableEntryToValue(aTable, tableEntry);
PRInt16 index;
if (!GetEnumTableIndex(aTable, index)) {
return PR_FALSE;
}
PRInt32 value = (tableEntry->value << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) +
index;
PRBool equals = aCaseSensitive || aValue.EqualsASCII(tableEntry->tag);
if (!equals) {
@ -1036,14 +1035,6 @@ nsAttrValue::ParseEnumValue(const nsAString& aValue,
tableEntry++;
}
if (aDefaultValue) {
NS_PRECONDITION(aTable <= aDefaultValue && aDefaultValue < tableEntry,
"aDefaultValue not inside aTable?");
SetIntValueAndType(EnumTableEntryToValue(aTable, aDefaultValue),
eEnum, &aValue);
return PR_TRUE;
}
return PR_FALSE;
}

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

@ -213,15 +213,11 @@ public:
* @param aValue the string to find the value for
* @param aTable the enumeration to map with
* @param aCaseSensitive specify if the parsing has to be case sensitive
* @param aDefaultValue if non-null, this function will always return true.
* Failure to parse aValue as one of the values in aTable will just
* cause aDefaultValue->value to be stored as the enumeration value.
* @return whether the enum value was found or not
*/
PRBool ParseEnumValue(const nsAString& aValue,
const EnumTable* aTable,
PRBool aCaseSensitive,
const EnumTable* aDefaultValue = nsnull);
PRBool aCaseSensitive);
/**
* Parse a string into an integer. Can optionally parse percent (n%).
@ -349,11 +345,13 @@ private:
/**
* Get the index of an EnumTable in the sEnumTableArray.
* If the EnumTable is not in the sEnumTableArray, it is added.
* If there is no more space in sEnumTableArray, it returns PR_FALSE.
*
* @param aTable the EnumTable to get the index of.
* @return the index of the EnumTable.
* @param aResult the index of the EnumTable.
* @return whether the index has been found or inserted.
*/
PRInt16 GetEnumTableIndex(const EnumTable* aTable);
PRBool GetEnumTableIndex(const EnumTable* aTable, PRInt16& aResult);
inline void SetPtrValueAndType(void* aValue, ValueBaseType aType);
void SetIntValueAndType(PRInt32 aValue, ValueType aType,
@ -377,10 +375,6 @@ private:
PRInt32* aErrorCode,
PRBool aCanBePercent = PR_FALSE,
PRBool* aIsPercent = nsnull) const;
// Given an enum table and a particular entry in that table, return
// the actual integer value we should store.
PRInt32 EnumTableEntryToValue(const EnumTable* aEnumTable,
const EnumTable* aTableEntry);
static nsTArray<const EnumTable*, nsTArrayDefaultAllocator>* sEnumTableArray;

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

@ -228,15 +228,15 @@ NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
NS_IMPL_INT_ATTR(nsHTMLImageElement, Vspace, vspace)
static const nsAttrValue::EnumTable kCrossOriginTable[] = {
// Order matters here; see ParseAttribute
{ "", nsImageLoadingContent::CORS_NONE },
{ "anonymous", nsImageLoadingContent::CORS_ANONYMOUS },
{ "use-credentials", nsImageLoadingContent::CORS_USE_CREDENTIALS },
{ 0 }
};
// Default crossOrigin mode is CORS_NONE.
static const nsAttrValue::EnumTable* kCrossOriginDefault = &kCrossOriginTable[0];
// crossorigin is not "limited to only known values" per spec, so it's
// just a string attr purposes of the DOM crossOrigin property.
NS_IMPL_STRING_ATTR(nsHTMLImageElement, CrossOrigin, crossorigin)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLImageElement, CrossOrigin, crossorigin, kCrossOriginDefault->tag)
NS_IMETHODIMP
nsHTMLImageElement::GetDraggable(PRBool* aDraggable)
@ -352,10 +352,7 @@ nsHTMLImageElement::ParseAttribute(PRInt32 aNamespaceID,
return ParseAlignValue(aValue, aResult);
}
if (aAttribute == nsGkAtoms::crossorigin) {
return aResult.ParseEnumValue(aValue, kCrossOriginTable, PR_FALSE,
// default value is anonymous if aValue is
// not a value we understand
&kCrossOriginTable[0]);
return aResult.ParseEnumValue(aValue, kCrossOriginTable, PR_FALSE);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
@ -659,9 +656,7 @@ nsHTMLImageElement::GetCORSMode()
nsImageLoadingContent::CORSMode ret = nsImageLoadingContent::CORS_NONE;
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::crossorigin);
if (value) {
NS_ASSERTION(value->Type() == nsAttrValue::eEnum,
"Why is this not an enum value?");
if (value && value->Type() == nsAttrValue::eEnum) {
ret = (nsImageLoadingContent::CORSMode) value->GetEnumValue();
}