mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Replace AspectRatio with computed::position::Ratio in media-queries.
Also, we drop the pref, layout.css.aspect-ratio-number.enabled, becacuse the spec of css-sizing-4 uses Number now. Differential Revision: https://phabricator.services.mozilla.com/D75233
This commit is contained in:
parent
fc9321bb23
commit
7022f451e1
7 changed files with 50 additions and 54 deletions
|
@ -12,9 +12,11 @@ use crate::values::generics::position::AspectRatio as GenericAspectRatio;
|
|||
use crate::values::generics::position::Position as GenericPosition;
|
||||
use crate::values::generics::position::PositionComponent as GenericPositionComponent;
|
||||
use crate::values::generics::position::PositionOrAuto as GenericPositionOrAuto;
|
||||
use crate::values::generics::position::Ratio as GenericRatio;
|
||||
use crate::values::generics::position::ZIndex as GenericZIndex;
|
||||
pub use crate::values::specified::position::{GridAutoFlow, GridTemplateAreas, MasonryAutoFlow};
|
||||
use crate::Zero;
|
||||
use std::cmp::{Ordering, PartialOrd};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
|
||||
|
@ -70,5 +72,24 @@ impl GenericPositionComponent for LengthPercentage {
|
|||
/// A computed value for the `z-index` property.
|
||||
pub type ZIndex = GenericZIndex<Integer>;
|
||||
|
||||
/// A computed <ratio> value.
|
||||
pub type Ratio = GenericRatio<NonNegativeNumber>;
|
||||
|
||||
impl PartialOrd for Ratio {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
f64::partial_cmp(
|
||||
&((self.0).0 as f64 * (other.1).0 as f64),
|
||||
&((self.1).0 as f64 * (other.0).0 as f64),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Ratio {
|
||||
/// Returns a new Ratio.
|
||||
pub fn new(a: f32, b: f32) -> Self {
|
||||
GenericRatio(a.into(), b.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// A computed value for the `aspect-ratio` property.
|
||||
pub type AspectRatio = GenericAspectRatio<NonNegativeNumber>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue