Unify positive-nonzero value restriction (used for integers) with one-or-larger value restriction (used for floats) as a single one-or-larger value restriction. (Bug 653842, patch 2) r=bzbarsky

This commit is contained in:
L. David Baron 2011-05-09 15:02:35 -04:00
Родитель 0c2f648f67
Коммит 6bc0543ecc
3 изменённых файлов: 20 добавлений и 26 удалений

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

@ -579,9 +579,9 @@ protected:
PRBool ParseNonNegativeVariant(nsCSSValue& aValue,
PRInt32 aVariantMask,
const PRInt32 aKeywordTable[]);
PRBool ParsePositiveNonZeroVariant(nsCSSValue& aValue,
PRInt32 aVariantMask,
const PRInt32 aKeywordTable[]);
PRBool ParseOneOrLargerVariant(nsCSSValue& aValue,
PRInt32 aVariantMask,
const PRInt32 aKeywordTable[]);
PRBool ParseCounter(nsCSSValue& aValue);
PRBool ParseAttr(nsCSSValue& aValue);
PRBool SetValueToURL(nsCSSValue& aValue, const nsString& aURL);
@ -4470,19 +4470,25 @@ CSSParserImpl::ParseNonNegativeVariant(nsCSSValue& aValue,
// computes the calc will be required to clamp the resulting value to an
// appropriate range.
PRBool
CSSParserImpl::ParsePositiveNonZeroVariant(nsCSSValue& aValue,
PRInt32 aVariantMask,
const PRInt32 aKeywordTable[])
CSSParserImpl::ParseOneOrLargerVariant(nsCSSValue& aValue,
PRInt32 aVariantMask,
const PRInt32 aKeywordTable[])
{
// The variant mask must only contain non-numeric variants or the ones
// that we specifically handle.
NS_ABORT_IF_FALSE((aVariantMask & ~(VARIANT_ALL_NONNUMERIC |
VARIANT_NUMBER |
VARIANT_INTEGER)) == 0,
"need to update code below to handle additional variants");
if (ParseVariant(aValue, aVariantMask, aKeywordTable)) {
if (aValue.GetUnit() == eCSSUnit_Integer) {
if (aValue.GetIntValue() <= 0) {
if (aValue.GetIntValue() < 1) {
UngetToken();
return PR_FALSE;
}
} else if (eCSSUnit_Number == aValue.GetUnit()) {
if (aValue.GetFloatValue() < 1.0f) {
UngetToken();
return PR_FALSE;
}
@ -5675,17 +5681,8 @@ CSSParserImpl::ParseSingleValueProperty(nsCSSValue& aValue,
return ParseVariant(aValue, variant, kwtable);
case CSS_PROPERTY_VALUE_NONNEGATIVE:
return ParseNonNegativeVariant(aValue, variant, kwtable);
case CSS_PROPERTY_VALUE_POSITIVE_NONZERO:
return ParsePositiveNonZeroVariant(aValue, variant, kwtable);
case CSS_PROPERTY_VALUE_AT_LEAST_ONE:
NS_ABORT_IF_FALSE((variant &
~(VARIANT_ALL_NONNUMERIC | VARIANT_NUMBER)) == 0,
"need to update code to handle additional variants");
if (!ParseVariant(aValue, variant, kwtable))
return PR_FALSE;
// Enforce the restriction that the value is greater than 1.
return aValue.GetUnit() != eCSSUnit_Number ||
aValue.GetFloatValue() >= 1.0f;
return ParseOneOrLargerVariant(aValue, variant, kwtable);
}
}
@ -8198,7 +8195,7 @@ CSSParserImpl::ParseTransitionStepTimingFunctionValues(nsCSSValue& aValue)
nsRefPtr<nsCSSValue::Array> val = nsCSSValue::Array::Create(2);
if (!ParsePositiveNonZeroVariant(val->Item(0), VARIANT_INTEGER, nsnull)) {
if (!ParseOneOrLargerVariant(val->Item(0), VARIANT_INTEGER, nsnull)) {
return PR_FALSE;
}

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

@ -1248,7 +1248,7 @@ CSS_PROP_COLUMN(
CSS_PROPERTY_PARSE_VALUE |
// Need to reject 0 in addition to negatives. If we accept 0, we
// need to change NS_STYLE_COLUMN_COUNT_AUTO to something else.
CSS_PROPERTY_VALUE_POSITIVE_NONZERO,
CSS_PROPERTY_VALUE_AT_LEAST_ONE,
VARIANT_AHI,
nsnull,
offsetof(nsStyleColumn, mColumnCount),
@ -1818,7 +1818,7 @@ CSS_PROP_BACKENDONLY(
orphans,
Orphans,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_POSITIVE_NONZERO,
CSS_PROPERTY_VALUE_AT_LEAST_ONE,
VARIANT_HI,
nsnull)
CSS_PROP_SHORTHAND(
@ -2379,7 +2379,7 @@ CSS_PROP_BACKENDONLY(
widows,
Widows,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_POSITIVE_NONZERO,
CSS_PROPERTY_VALUE_AT_LEAST_ONE,
VARIANT_HI,
nsnull)
CSS_PROP_POSITION(
@ -2490,7 +2490,7 @@ CSS_PROP_XUL(
box_ordinal_group,
CSS_PROP_DOMPROP_PREFIXED(BoxOrdinalGroup),
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_POSITIVE_NONZERO,
CSS_PROPERTY_VALUE_AT_LEAST_ONE,
VARIANT_HI,
nsnull,
CSS_PROP_NO_OFFSET,

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

@ -113,11 +113,8 @@ PR_STATIC_ASSERT((CSS_PROPERTY_PARSE_PROPERTY_MASK &
// should enforce that the value of this property must be 0 or larger.
#define CSS_PROPERTY_VALUE_NONNEGATIVE (1<<13)
// The parser (in particular, CSSParserImpl::ParseSingleValueProperty)
// should enforce that the value of this property must be greater than 0.
#define CSS_PROPERTY_VALUE_POSITIVE_NONZERO (2<<13)
// The parser (in particular, CSSParserImpl::ParseSingleValueProperty)
// should enforce that the value of this property must be 1 or larger.
#define CSS_PROPERTY_VALUE_AT_LEAST_ONE (3<<13)
#define CSS_PROPERTY_VALUE_AT_LEAST_ONE (2<<13)
// NOTE: next free bit is (1<<15)