mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
style: Don't reject negative values at parse time in media features
Clean-up some other test expectations while at it. Differential Revision: https://phabricator.services.mozilla.com/D170677
This commit is contained in:
parent
4ed0f518fb
commit
d68bd45cc3
3 changed files with 9 additions and 9 deletions
|
@ -126,18 +126,18 @@ fn eval_scan(_: &Context, _: Option<Scan>) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/mediaqueries-4/#color
|
/// https://drafts.csswg.org/mediaqueries-4/#color
|
||||||
fn eval_color(context: &Context) -> u32 {
|
fn eval_color(context: &Context) -> i32 {
|
||||||
unsafe { bindings::Gecko_MediaFeatures_GetColorDepth(context.device().document()) }
|
unsafe { bindings::Gecko_MediaFeatures_GetColorDepth(context.device().document()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/mediaqueries-4/#color-index
|
/// https://drafts.csswg.org/mediaqueries-4/#color-index
|
||||||
fn eval_color_index(_: &Context) -> u32 {
|
fn eval_color_index(_: &Context) -> i32 {
|
||||||
// We should return zero if the device does not use a color lookup table.
|
// We should return zero if the device does not use a color lookup table.
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/mediaqueries-4/#monochrome
|
/// https://drafts.csswg.org/mediaqueries-4/#monochrome
|
||||||
fn eval_monochrome(context: &Context) -> u32 {
|
fn eval_monochrome(context: &Context) -> i32 {
|
||||||
// For color devices we should return 0.
|
// For color devices we should return 0.
|
||||||
unsafe { bindings::Gecko_MediaFeatures_GetMonochromeBitsPerPixel(context.device().document()) }
|
unsafe { bindings::Gecko_MediaFeatures_GetMonochromeBitsPerPixel(context.device().document()) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub type KeywordParser = for<'a, 'i, 't> fn(
|
||||||
pub enum Evaluator {
|
pub enum Evaluator {
|
||||||
Length(QueryFeatureGetter<CSSPixelLength>),
|
Length(QueryFeatureGetter<CSSPixelLength>),
|
||||||
OptionalLength(QueryFeatureGetter<Option<CSSPixelLength>>),
|
OptionalLength(QueryFeatureGetter<Option<CSSPixelLength>>),
|
||||||
Integer(QueryFeatureGetter<u32>),
|
Integer(QueryFeatureGetter<i32>),
|
||||||
Float(QueryFeatureGetter<f32>),
|
Float(QueryFeatureGetter<f32>),
|
||||||
BoolInteger(QueryFeatureGetter<bool>),
|
BoolInteger(QueryFeatureGetter<bool>),
|
||||||
/// A non-negative number ratio, such as the one from device-pixel-ratio.
|
/// A non-negative number ratio, such as the one from device-pixel-ratio.
|
||||||
|
|
|
@ -663,8 +663,8 @@ impl QueryFeatureExpression {
|
||||||
pub enum QueryExpressionValue {
|
pub enum QueryExpressionValue {
|
||||||
/// A length.
|
/// A length.
|
||||||
Length(Length),
|
Length(Length),
|
||||||
/// A (non-negative) integer.
|
/// An integer.
|
||||||
Integer(u32),
|
Integer(i32),
|
||||||
/// A floating point value.
|
/// A floating point value.
|
||||||
Float(CSSFloat),
|
Float(CSSFloat),
|
||||||
/// A boolean value, specified as an integer (i.e., either 0 or 1).
|
/// A boolean value, specified as an integer (i.e., either 0 or 1).
|
||||||
|
@ -705,12 +705,12 @@ impl QueryExpressionValue {
|
||||||
) -> Result<QueryExpressionValue, ParseError<'i>> {
|
) -> Result<QueryExpressionValue, ParseError<'i>> {
|
||||||
Ok(match for_feature.evaluator {
|
Ok(match for_feature.evaluator {
|
||||||
Evaluator::OptionalLength(..) | Evaluator::Length(..) => {
|
Evaluator::OptionalLength(..) | Evaluator::Length(..) => {
|
||||||
let length = Length::parse_non_negative(context, input)?;
|
let length = Length::parse(context, input)?;
|
||||||
QueryExpressionValue::Length(length)
|
QueryExpressionValue::Length(length)
|
||||||
},
|
},
|
||||||
Evaluator::Integer(..) => {
|
Evaluator::Integer(..) => {
|
||||||
let integer = Integer::parse_non_negative(context, input)?;
|
let integer = Integer::parse(context, input)?;
|
||||||
QueryExpressionValue::Integer(integer.value() as u32)
|
QueryExpressionValue::Integer(integer.value())
|
||||||
},
|
},
|
||||||
Evaluator::BoolInteger(..) => {
|
Evaluator::BoolInteger(..) => {
|
||||||
let integer = Integer::parse_non_negative(context, input)?;
|
let integer = Integer::parse_non_negative(context, input)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue