style: Let aspect-ratio (css-sizing-4) support 'auto | <ratio>'.

In order to test its parsing and serialization, we expose it but protect
it behind a pref.

Besides, I would like to drop layout.css.aspect-ratio-number.enabled in
the next patch because the spec has been updated. It seems we don't have
to keep this pref and we should always use Number.

Differential Revision: https://phabricator.services.mozilla.com/D74955
This commit is contained in:
Boris Chiou 2020-05-21 06:45:10 +00:00 committed by Emilio Cobos Álvarez
parent bd23e05c47
commit fc9321bb23
8 changed files with 185 additions and 18 deletions

View file

@ -21,7 +21,7 @@ use crate::media_queries::Device;
use crate::properties;
use crate::properties::{ComputedValues, LonghandId, StyleBuilder};
use crate::rule_cache::RuleCacheConditions;
use crate::{ArcSlice, Atom};
use crate::{ArcSlice, Atom, One};
use euclid::default::Size2D;
use servo_arc::Arc;
use std::cell::RefCell;
@ -68,6 +68,7 @@ pub use self::list::Quotes;
pub use self::motion::{OffsetPath, OffsetRotate};
pub use self::outline::OutlineStyle;
pub use self::percentage::{NonNegativePercentage, Percentage};
pub use self::position::AspectRatio;
pub use self::position::{GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto, ZIndex};
pub use self::rect::NonNegativeLengthOrNumberRect;
pub use self::resolution::Resolution;
@ -600,6 +601,18 @@ impl From<NonNegativeNumber> for CSSFloat {
}
}
impl One for NonNegativeNumber {
#[inline]
fn one() -> Self {
NonNegative(1.0)
}
#[inline]
fn is_one(&self) -> bool {
self.0 == 1.0
}
}
/// A wrapper of Number, but the value between 0 and 1
pub type ZeroToOneNumber = ZeroToOne<CSSFloat>;