mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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
|
||||
fn eval_color(context: &Context) -> u32 {
|
||||
fn eval_color(context: &Context) -> i32 {
|
||||
unsafe { bindings::Gecko_MediaFeatures_GetColorDepth(context.device().document()) }
|
||||
}
|
||||
|
||||
/// 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.
|
||||
0
|
||||
}
|
||||
|
||||
/// 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.
|
||||
unsafe { bindings::Gecko_MediaFeatures_GetMonochromeBitsPerPixel(context.device().document()) }
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ pub type KeywordParser = for<'a, 'i, 't> fn(
|
|||
pub enum Evaluator {
|
||||
Length(QueryFeatureGetter<CSSPixelLength>),
|
||||
OptionalLength(QueryFeatureGetter<Option<CSSPixelLength>>),
|
||||
Integer(QueryFeatureGetter<u32>),
|
||||
Integer(QueryFeatureGetter<i32>),
|
||||
Float(QueryFeatureGetter<f32>),
|
||||
BoolInteger(QueryFeatureGetter<bool>),
|
||||
/// A non-negative number ratio, such as the one from device-pixel-ratio.
|
||||
|
|
|
@ -663,8 +663,8 @@ impl QueryFeatureExpression {
|
|||
pub enum QueryExpressionValue {
|
||||
/// A length.
|
||||
Length(Length),
|
||||
/// A (non-negative) integer.
|
||||
Integer(u32),
|
||||
/// An integer.
|
||||
Integer(i32),
|
||||
/// A floating point value.
|
||||
Float(CSSFloat),
|
||||
/// A boolean value, specified as an integer (i.e., either 0 or 1).
|
||||
|
@ -705,12 +705,12 @@ impl QueryExpressionValue {
|
|||
) -> Result<QueryExpressionValue, ParseError<'i>> {
|
||||
Ok(match for_feature.evaluator {
|
||||
Evaluator::OptionalLength(..) | Evaluator::Length(..) => {
|
||||
let length = Length::parse_non_negative(context, input)?;
|
||||
let length = Length::parse(context, input)?;
|
||||
QueryExpressionValue::Length(length)
|
||||
},
|
||||
Evaluator::Integer(..) => {
|
||||
let integer = Integer::parse_non_negative(context, input)?;
|
||||
QueryExpressionValue::Integer(integer.value() as u32)
|
||||
let integer = Integer::parse(context, input)?;
|
||||
QueryExpressionValue::Integer(integer.value())
|
||||
},
|
||||
Evaluator::BoolInteger(..) => {
|
||||
let integer = Integer::parse_non_negative(context, input)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue