mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Remove mozmm CSS unit.
Bug: 1416564 Reviewed-by: heycam MozReview-Commit-ID: AU4CUq09tw4
This commit is contained in:
parent
c261ff38c7
commit
eac0d104a3
5 changed files with 2 additions and 94 deletions
|
@ -77,8 +77,6 @@ pub struct CalcLengthOrPercentage {
|
|||
pub ch: Option<CSSFloat>,
|
||||
pub rem: Option<CSSFloat>,
|
||||
pub percentage: Option<computed::Percentage>,
|
||||
#[cfg(feature = "gecko")]
|
||||
pub mozmm: Option<CSSFloat>,
|
||||
}
|
||||
|
||||
impl ToCss for CalcLengthOrPercentage {
|
||||
|
@ -142,14 +140,7 @@ impl ToCss for CalcLengthOrPercentage {
|
|||
serialize!(ch);
|
||||
serialize_abs!(Cm);
|
||||
serialize!(em, ex);
|
||||
serialize_abs!(In);
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
serialize!(mozmm);
|
||||
}
|
||||
|
||||
serialize_abs!(Mm, Pc, Pt, Px, Q);
|
||||
serialize_abs!(In, Mm, Pc, Pt, Px, Q);
|
||||
serialize!(rem, vh, vmax, vmin, vw);
|
||||
|
||||
dest.write_str(")")
|
||||
|
@ -398,16 +389,6 @@ impl CalcNode {
|
|||
}
|
||||
}
|
||||
NoCalcLength::ServoCharacterWidth(..) => unreachable!(),
|
||||
#[cfg(feature = "gecko")]
|
||||
NoCalcLength::Physical(physical) => {
|
||||
use values::specified::length::PhysicalLength;
|
||||
|
||||
match physical {
|
||||
PhysicalLength::Mozmm(mozmm) => {
|
||||
ret.mozmm = Some(ret.mozmm.unwrap_or(0.) + mozmm * factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CalcNode::Sub(ref a, ref b) => {
|
||||
|
|
|
@ -359,60 +359,6 @@ impl Add<AbsoluteLength> for AbsoluteLength {
|
|||
}
|
||||
}
|
||||
|
||||
/// Represents a physical length based on DPI.
|
||||
///
|
||||
/// FIXME(emilio): Unship (https://bugzilla.mozilla.org/show_bug.cgi?id=1416564)
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToCss)]
|
||||
#[derive(MallocSizeOf)]
|
||||
pub enum PhysicalLength {
|
||||
/// A physical length in millimetres.
|
||||
#[css(dimension)]
|
||||
Mozmm(CSSFloat),
|
||||
}
|
||||
|
||||
impl PhysicalLength {
|
||||
/// Checks whether the length value is zero.
|
||||
pub fn is_zero(&self) -> bool {
|
||||
match *self {
|
||||
PhysicalLength::Mozmm(v) => v == 0.,
|
||||
}
|
||||
}
|
||||
|
||||
/// Computes the given character width.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn to_computed_value(&self, context: &Context) -> CSSPixelLength {
|
||||
use gecko_bindings::bindings;
|
||||
use std::f32;
|
||||
|
||||
// Same as Gecko
|
||||
const INCH_PER_MM: f32 = 1. / 25.4;
|
||||
|
||||
let au_per_physical_inch = unsafe {
|
||||
bindings::Gecko_GetAppUnitsPerPhysicalInch(context.device().pres_context()) as f32
|
||||
};
|
||||
|
||||
let px_per_physical_inch = au_per_physical_inch / AU_PER_PX;
|
||||
|
||||
let mm = match *self {
|
||||
PhysicalLength::Mozmm(v) => v,
|
||||
};
|
||||
|
||||
let pixel = mm * px_per_physical_inch * INCH_PER_MM;
|
||||
CSSPixelLength::new(pixel.min(f32::MAX).max(f32::MIN))
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<CSSFloat> for PhysicalLength {
|
||||
type Output = Self ;
|
||||
|
||||
#[inline]
|
||||
fn mul(self, scalar: CSSFloat) -> Self {
|
||||
match self {
|
||||
PhysicalLength::Mozmm(v) => PhysicalLength::Mozmm(v * scalar),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A `<length>` without taking `calc` expressions into account
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-values/#lengths>
|
||||
|
@ -439,10 +385,6 @@ pub enum NoCalcLength {
|
|||
/// `Stylist::synthesize_rules_for_legacy_attributes()`.
|
||||
#[css(function)]
|
||||
ServoCharacterWidth(CharacterWidth),
|
||||
|
||||
/// A physical length (mozmm) based on DPI
|
||||
#[cfg(feature = "gecko")]
|
||||
Physical(PhysicalLength),
|
||||
}
|
||||
|
||||
impl Mul<CSSFloat> for NoCalcLength {
|
||||
|
@ -455,8 +397,6 @@ impl Mul<CSSFloat> for NoCalcLength {
|
|||
NoCalcLength::FontRelative(v) => NoCalcLength::FontRelative(v * scalar),
|
||||
NoCalcLength::ViewportPercentage(v) => NoCalcLength::ViewportPercentage(v * scalar),
|
||||
NoCalcLength::ServoCharacterWidth(_) => panic!("Can't multiply ServoCharacterWidth!"),
|
||||
#[cfg(feature = "gecko")]
|
||||
NoCalcLength::Physical(v) => NoCalcLength::Physical(v * scalar),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -504,8 +444,6 @@ impl NoCalcLength {
|
|||
}
|
||||
Ok(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vmax(value)))
|
||||
},
|
||||
#[cfg(feature = "gecko")]
|
||||
"mozmm" => Ok(NoCalcLength::Physical(PhysicalLength::Mozmm(value))),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
|
@ -521,8 +459,6 @@ impl NoCalcLength {
|
|||
pub fn is_zero(&self) -> bool {
|
||||
match *self {
|
||||
NoCalcLength::Absolute(length) => length.is_zero(),
|
||||
#[cfg(feature = "gecko")]
|
||||
NoCalcLength::Physical(length) => length.is_zero(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue