Update to new parsing rules for grid media query per http://lists.w3.org/Archives/Public/www-style/2008Aug/0191.html . (Bug 453759) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2008-09-06 07:04:28 -07:00
Родитель 1ebad2d826
Коммит b4c73c1583
5 изменённых файлов: 18 добавлений и 5 удалений

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

@ -1671,8 +1671,14 @@ PRBool CSSParserImpl::ParseMediaQueryExpression(nsresult& aErrorCode, nsMediaQue
VARIANT_LENGTH, nsnull);
break;
case nsMediaFeature::eInteger:
case nsMediaFeature::eBoolInteger:
rv = ParsePositiveVariant(aErrorCode, expr->mValue,
VARIANT_INTEGER, nsnull);
// Enforce extra restrictions for eBoolInteger
if (rv &&
feature->mValueType == nsMediaFeature::eBoolInteger &&
expr->mValue.GetIntValue() > 1)
rv = PR_FALSE;
break;
case nsMediaFeature::eIntRatio:
{

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

@ -212,11 +212,18 @@ nsMediaExpression::Matches(nsPresContext *aPresContext,
}
break;
case nsMediaFeature::eInteger:
case nsMediaFeature::eBoolInteger:
{
NS_ASSERTION(actual.GetUnit() == eCSSUnit_Integer,
"bad actual value");
NS_ASSERTION(required.GetUnit() == eCSSUnit_Integer,
"bad required value");
NS_ASSERTION(mFeature->mValueType != nsMediaFeature::eBoolInteger ||
actual.GetIntValue() == 0 || actual.GetIntValue() == 1,
"bad actual bool integer value");
NS_ASSERTION(mFeature->mValueType != nsMediaFeature::eBoolInteger ||
required.GetIntValue() == 0 || required.GetIntValue() == 1,
"bad required bool integer value");
cmp = DoCompare(actual.GetIntValue(), required.GetIntValue());
}
break;
@ -392,6 +399,7 @@ nsMediaQuery::AppendToString(nsAString& aString) const
expr.mValue, aString);
break;
case nsMediaFeature::eInteger:
case nsMediaFeature::eBoolInteger:
NS_ASSERTION(expr.mValue.GetUnit() == eCSSUnit_Integer,
"bad unit");
// Use 'z-index' as a property that takes integer values

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

@ -336,7 +336,7 @@ nsMediaFeatures::features[] = {
{
&nsGkAtoms::grid,
nsMediaFeature::eMinMaxNotAllowed,
nsMediaFeature::eInteger,
nsMediaFeature::eBoolInteger,
nsnull,
GetGrid
},

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

@ -61,6 +61,7 @@ struct nsMediaFeature {
// was given (in addition to the types listed below).
eLength, // values are such that nsCSSValue::IsLengthUnit() is true
eInteger, // values are eCSSUnit_Integer
eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only)
eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer
eResolution, // values are in eCSSUnit_Inch (for dpi) or
// eCSSUnit_Centimeter (for dpcm)

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

@ -420,10 +420,8 @@ function run() {
expression_should_be_parseable("grid: 1");
expression_should_not_be_parseable("min-grid");
expression_should_not_be_parseable("max-grid: 1");
// FIXME: Mark these as todo since the spec isn't clear:
// http://lists.w3.org/Archives/Public/www-style/2008Jun/0214.html
todo_expression_should_not_be_parseable("grid: 2");
todo_expression_should_be_parseable("grid: -1");
expression_should_not_be_parseable("grid: 2");
expression_should_not_be_parseable("grid: -1");
// Assume we don't support grid devices
should_not_apply("(grid)");