Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit d720a46

Browse files
committed
Backout changeset 89a9f4a88d5b (bug 676413) for causing content/html/content/test/test_bug664299.html failures.
1 parent ea53247 commit d720a46

File tree

3 files changed

+26
-46
lines changed

3 files changed

+26
-46
lines changed

content/base/src/nsAttrValue.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -980,43 +980,42 @@ nsAttrValue::SetIntValueAndType(PRInt32 aValue, ValueType aType,
980980
}
981981
}
982982

983-
PRInt16
984-
nsAttrValue::GetEnumTableIndex(const EnumTable* aTable)
983+
PRBool
984+
nsAttrValue::GetEnumTableIndex(const EnumTable* aTable, PRInt16& aResult)
985985
{
986986
PRInt16 index = sEnumTableArray->IndexOf(aTable);
987987
if (index < 0) {
988988
index = sEnumTableArray->Length();
989989
NS_ASSERTION(index <= NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE,
990990
"too many enum tables");
991-
sEnumTableArray->AppendElement(aTable);
991+
if (!sEnumTableArray->AppendElement(aTable)) {
992+
return PR_FALSE;
993+
}
992994
}
993995

994-
return index;
995-
}
996+
aResult = index;
996997

997-
PRInt32
998-
nsAttrValue::EnumTableEntryToValue(const EnumTable* aEnumTable,
999-
const EnumTable* aTableEntry)
1000-
{
1001-
PRInt16 index = GetEnumTableIndex(aEnumTable);
1002-
PRInt32 value = (aTableEntry->value << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) +
1003-
index;
1004-
return value;
998+
return PR_TRUE;
1005999
}
10061000

10071001
PRBool
10081002
nsAttrValue::ParseEnumValue(const nsAString& aValue,
10091003
const EnumTable* aTable,
1010-
PRBool aCaseSensitive,
1011-
const EnumTable* aDefaultValue)
1004+
PRBool aCaseSensitive)
10121005
{
10131006
ResetIfSet();
10141007
const EnumTable* tableEntry = aTable;
10151008

10161009
while (tableEntry->tag) {
10171010
if (aCaseSensitive ? aValue.EqualsASCII(tableEntry->tag) :
10181011
aValue.LowerCaseEqualsASCII(tableEntry->tag)) {
1019-
PRInt32 value = EnumTableEntryToValue(aTable, tableEntry);
1012+
PRInt16 index;
1013+
if (!GetEnumTableIndex(aTable, index)) {
1014+
return PR_FALSE;
1015+
}
1016+
1017+
PRInt32 value = (tableEntry->value << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) +
1018+
index;
10201019

10211020
PRBool equals = aCaseSensitive || aValue.EqualsASCII(tableEntry->tag);
10221021
if (!equals) {
@@ -1036,14 +1035,6 @@ nsAttrValue::ParseEnumValue(const nsAString& aValue,
10361035
tableEntry++;
10371036
}
10381037

1039-
if (aDefaultValue) {
1040-
NS_PRECONDITION(aTable <= aDefaultValue && aDefaultValue < tableEntry,
1041-
"aDefaultValue not inside aTable?");
1042-
SetIntValueAndType(EnumTableEntryToValue(aTable, aDefaultValue),
1043-
eEnum, &aValue);
1044-
return PR_TRUE;
1045-
}
1046-
10471038
return PR_FALSE;
10481039
}
10491040

content/base/src/nsAttrValue.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,11 @@ class nsAttrValue {
213213
* @param aValue the string to find the value for
214214
* @param aTable the enumeration to map with
215215
* @param aCaseSensitive specify if the parsing has to be case sensitive
216-
* @param aDefaultValue if non-null, this function will always return true.
217-
* Failure to parse aValue as one of the values in aTable will just
218-
* cause aDefaultValue->value to be stored as the enumeration value.
219216
* @return whether the enum value was found or not
220217
*/
221218
PRBool ParseEnumValue(const nsAString& aValue,
222219
const EnumTable* aTable,
223-
PRBool aCaseSensitive,
224-
const EnumTable* aDefaultValue = nsnull);
220+
PRBool aCaseSensitive);
225221

226222
/**
227223
* Parse a string into an integer. Can optionally parse percent (n%).
@@ -349,11 +345,13 @@ class nsAttrValue {
349345
/**
350346
* Get the index of an EnumTable in the sEnumTableArray.
351347
* If the EnumTable is not in the sEnumTableArray, it is added.
348+
* If there is no more space in sEnumTableArray, it returns PR_FALSE.
352349
*
353350
* @param aTable the EnumTable to get the index of.
354-
* @return the index of the EnumTable.
351+
* @param aResult the index of the EnumTable.
352+
* @return whether the index has been found or inserted.
355353
*/
356-
PRInt16 GetEnumTableIndex(const EnumTable* aTable);
354+
PRBool GetEnumTableIndex(const EnumTable* aTable, PRInt16& aResult);
357355

358356
inline void SetPtrValueAndType(void* aValue, ValueBaseType aType);
359357
void SetIntValueAndType(PRInt32 aValue, ValueType aType,
@@ -377,10 +375,6 @@ class nsAttrValue {
377375
PRInt32* aErrorCode,
378376
PRBool aCanBePercent = PR_FALSE,
379377
PRBool* aIsPercent = nsnull) const;
380-
// Given an enum table and a particular entry in that table, return
381-
// the actual integer value we should store.
382-
PRInt32 EnumTableEntryToValue(const EnumTable* aEnumTable,
383-
const EnumTable* aTableEntry);
384378

385379
static nsTArray<const EnumTable*, nsTArrayDefaultAllocator>* sEnumTableArray;
386380

content/html/content/src/nsHTMLImageElement.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
228228
NS_IMPL_INT_ATTR(nsHTMLImageElement, Vspace, vspace)
229229

230230
static const nsAttrValue::EnumTable kCrossOriginTable[] = {
231-
// Order matters here; see ParseAttribute
231+
{ "", nsImageLoadingContent::CORS_NONE },
232232
{ "anonymous", nsImageLoadingContent::CORS_ANONYMOUS },
233233
{ "use-credentials", nsImageLoadingContent::CORS_USE_CREDENTIALS },
234234
{ 0 }
235235
};
236+
// Default crossOrigin mode is CORS_NONE.
237+
static const nsAttrValue::EnumTable* kCrossOriginDefault = &kCrossOriginTable[0];
236238

237-
// crossorigin is not "limited to only known values" per spec, so it's
238-
// just a string attr purposes of the DOM crossOrigin property.
239-
NS_IMPL_STRING_ATTR(nsHTMLImageElement, CrossOrigin, crossorigin)
239+
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLImageElement, CrossOrigin, crossorigin, kCrossOriginDefault->tag)
240240

241241
NS_IMETHODIMP
242242
nsHTMLImageElement::GetDraggable(PRBool* aDraggable)
@@ -352,10 +352,7 @@ nsHTMLImageElement::ParseAttribute(PRInt32 aNamespaceID,
352352
return ParseAlignValue(aValue, aResult);
353353
}
354354
if (aAttribute == nsGkAtoms::crossorigin) {
355-
return aResult.ParseEnumValue(aValue, kCrossOriginTable, PR_FALSE,
356-
// default value is anonymous if aValue is
357-
// not a value we understand
358-
&kCrossOriginTable[0]);
355+
return aResult.ParseEnumValue(aValue, kCrossOriginTable, PR_FALSE);
359356
}
360357
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
361358
return PR_TRUE;
@@ -659,9 +656,7 @@ nsHTMLImageElement::GetCORSMode()
659656
nsImageLoadingContent::CORSMode ret = nsImageLoadingContent::CORS_NONE;
660657

661658
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::crossorigin);
662-
if (value) {
663-
NS_ASSERTION(value->Type() == nsAttrValue::eEnum,
664-
"Why is this not an enum value?");
659+
if (value && value->Type() == nsAttrValue::eEnum) {
665660
ret = (nsImageLoadingContent::CORSMode) value->GetEnumValue();
666661
}
667662

0 commit comments

Comments
 (0)