Skip to content

Commit

Permalink
Auto merge of #19217 - emilio:bye-mozmm, r=heycam
Browse files Browse the repository at this point in the history
style: Remove mozmm CSS unit.

Bug: 1416564
Reviewed-by: heycam
MozReview-Commit-ID: AU4CUq09tw4
  • Loading branch information
bors-servo committed Nov 14, 2017
2 parents 856dc3c + eac0d10 commit d287ec8
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 94 deletions.
3 changes: 0 additions & 3 deletions components/style/values/computed/length.rs
Expand Up @@ -36,9 +36,6 @@ impl ToComputedValue for specified::NoCalcLength {
length.to_computed_value(context.viewport_size_for_viewport_unit_resolution()),
specified::NoCalcLength::ServoCharacterWidth(length) =>
length.to_computed_value(context.style().get_font().clone_font_size().size()),
#[cfg(feature = "gecko")]
specified::NoCalcLength::Physical(length) =>
length.to_computed_value(context),
}
}

Expand Down
21 changes: 1 addition & 20 deletions components/style/values/specified/calc.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(")")
Expand Down Expand Up @@ -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) => {
Expand Down
64 changes: 0 additions & 64 deletions components/style/values/specified/length.rs
Expand Up @@ -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>
Expand All @@ -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 {
Expand All @@ -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),
}
}
}
Expand Down Expand Up @@ -504,8 +444,6 @@ impl NoCalcLength {
}
Ok(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vmax(value)))
},
#[cfg(feature = "gecko")]
"mozmm" => Ok(NoCalcLength::Physical(PhysicalLength::Mozmm(value))),
_ => Err(())
}
}
Expand All @@ -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
}
}
Expand Down
5 changes: 0 additions & 5 deletions components/style_derive/to_css.rs
Expand Up @@ -59,11 +59,6 @@ pub fn derive(input: DeriveInput) -> Tokens {
};

if variant_attrs.dimension {
// FIXME(emilio): Remove when bug 1416564 lands.
if identifier == "-mozmm" {
identifier = "mozmm".into();
}

expr = quote! {
#expr?;
::std::fmt::Write::write_str(dest, #identifier)
Expand Down
3 changes: 1 addition & 2 deletions ports/geckolib/glue.rs
Expand Up @@ -3163,7 +3163,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(
use style::properties::longhands::_moz_script_min_size::SpecifiedValue as MozScriptMinSize;
use style::properties::longhands::width::SpecifiedValue as Width;
use style::values::specified::MozLength;
use style::values::specified::length::{AbsoluteLength, FontRelativeLength, PhysicalLength};
use style::values::specified::length::{AbsoluteLength, FontRelativeLength};
use style::values::specified::length::{LengthOrPercentage, NoCalcLength};

let long = get_longhand_from_id!(property);
Expand All @@ -3174,7 +3174,6 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(
structs::nsCSSUnit::eCSSUnit_Inch => NoCalcLength::Absolute(AbsoluteLength::In(value)),
structs::nsCSSUnit::eCSSUnit_Centimeter => NoCalcLength::Absolute(AbsoluteLength::Cm(value)),
structs::nsCSSUnit::eCSSUnit_Millimeter => NoCalcLength::Absolute(AbsoluteLength::Mm(value)),
structs::nsCSSUnit::eCSSUnit_PhysicalMillimeter => NoCalcLength::Physical(PhysicalLength::Mozmm(value)),
structs::nsCSSUnit::eCSSUnit_Point => NoCalcLength::Absolute(AbsoluteLength::Pt(value)),
structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)),
structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)),
Expand Down

0 comments on commit d287ec8

Please sign in to comment.