servo: Merge #19217 - style: Remove mozmm CSS unit (from emilio:bye-mozmm); r=heycam

Bug: 1416564
Reviewed-by: heycam
MozReview-Commit-ID: AU4CUq09tw4
Source-Repo: https://github.com/servo/servo
Source-Revision: d287ec8d3ee5af9e64979ec77894f218cae1b46d

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 13b3c872225a62eee9dd271925a9a61aa909c594
This commit is contained in:
Emilio Cobos Álvarez 2017-11-14 07:27:28 -06:00
Родитель 87eb11a314
Коммит 2bf6571d80
5 изменённых файлов: 2 добавлений и 94 удалений

Просмотреть файл

@ -36,9 +36,6 @@ impl ToComputedValue for specified::NoCalcLength {
length.to_computed_value(context.viewport_size_for_viewport_unit_resolution()), length.to_computed_value(context.viewport_size_for_viewport_unit_resolution()),
specified::NoCalcLength::ServoCharacterWidth(length) => specified::NoCalcLength::ServoCharacterWidth(length) =>
length.to_computed_value(context.style().get_font().clone_font_size().size()), length.to_computed_value(context.style().get_font().clone_font_size().size()),
#[cfg(feature = "gecko")]
specified::NoCalcLength::Physical(length) =>
length.to_computed_value(context),
} }
} }

Просмотреть файл

@ -77,8 +77,6 @@ pub struct CalcLengthOrPercentage {
pub ch: Option<CSSFloat>, pub ch: Option<CSSFloat>,
pub rem: Option<CSSFloat>, pub rem: Option<CSSFloat>,
pub percentage: Option<computed::Percentage>, pub percentage: Option<computed::Percentage>,
#[cfg(feature = "gecko")]
pub mozmm: Option<CSSFloat>,
} }
impl ToCss for CalcLengthOrPercentage { impl ToCss for CalcLengthOrPercentage {
@ -142,14 +140,7 @@ impl ToCss for CalcLengthOrPercentage {
serialize!(ch); serialize!(ch);
serialize_abs!(Cm); serialize_abs!(Cm);
serialize!(em, ex); serialize!(em, ex);
serialize_abs!(In); serialize_abs!(In, Mm, Pc, Pt, Px, Q);
#[cfg(feature = "gecko")]
{
serialize!(mozmm);
}
serialize_abs!(Mm, Pc, Pt, Px, Q);
serialize!(rem, vh, vmax, vmin, vw); serialize!(rem, vh, vmax, vmin, vw);
dest.write_str(")") dest.write_str(")")
@ -398,16 +389,6 @@ impl CalcNode {
} }
} }
NoCalcLength::ServoCharacterWidth(..) => unreachable!(), 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) => { 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 /// A `<length>` without taking `calc` expressions into account
/// ///
/// <https://drafts.csswg.org/css-values/#lengths> /// <https://drafts.csswg.org/css-values/#lengths>
@ -439,10 +385,6 @@ pub enum NoCalcLength {
/// `Stylist::synthesize_rules_for_legacy_attributes()`. /// `Stylist::synthesize_rules_for_legacy_attributes()`.
#[css(function)] #[css(function)]
ServoCharacterWidth(CharacterWidth), ServoCharacterWidth(CharacterWidth),
/// A physical length (mozmm) based on DPI
#[cfg(feature = "gecko")]
Physical(PhysicalLength),
} }
impl Mul<CSSFloat> for NoCalcLength { impl Mul<CSSFloat> for NoCalcLength {
@ -455,8 +397,6 @@ impl Mul<CSSFloat> for NoCalcLength {
NoCalcLength::FontRelative(v) => NoCalcLength::FontRelative(v * scalar), NoCalcLength::FontRelative(v) => NoCalcLength::FontRelative(v * scalar),
NoCalcLength::ViewportPercentage(v) => NoCalcLength::ViewportPercentage(v * scalar), NoCalcLength::ViewportPercentage(v) => NoCalcLength::ViewportPercentage(v * scalar),
NoCalcLength::ServoCharacterWidth(_) => panic!("Can't multiply ServoCharacterWidth!"), 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))) Ok(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vmax(value)))
}, },
#[cfg(feature = "gecko")]
"mozmm" => Ok(NoCalcLength::Physical(PhysicalLength::Mozmm(value))),
_ => Err(()) _ => Err(())
} }
} }
@ -521,8 +459,6 @@ impl NoCalcLength {
pub fn is_zero(&self) -> bool { pub fn is_zero(&self) -> bool {
match *self { match *self {
NoCalcLength::Absolute(length) => length.is_zero(), NoCalcLength::Absolute(length) => length.is_zero(),
#[cfg(feature = "gecko")]
NoCalcLength::Physical(length) => length.is_zero(),
_ => false _ => false
} }
} }

Просмотреть файл

@ -59,11 +59,6 @@ pub fn derive(input: DeriveInput) -> Tokens {
}; };
if variant_attrs.dimension { if variant_attrs.dimension {
// FIXME(emilio): Remove when bug 1416564 lands.
if identifier == "-mozmm" {
identifier = "mozmm".into();
}
expr = quote! { expr = quote! {
#expr?; #expr?;
::std::fmt::Write::write_str(dest, #identifier) ::std::fmt::Write::write_str(dest, #identifier)

Просмотреть файл

@ -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::_moz_script_min_size::SpecifiedValue as MozScriptMinSize;
use style::properties::longhands::width::SpecifiedValue as Width; use style::properties::longhands::width::SpecifiedValue as Width;
use style::values::specified::MozLength; 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}; use style::values::specified::length::{LengthOrPercentage, NoCalcLength};
let long = get_longhand_from_id!(property); let long = get_longhand_from_id!(property);
@ -3174,7 +3174,6 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(
structs::nsCSSUnit::eCSSUnit_Inch => NoCalcLength::Absolute(AbsoluteLength::In(value)), structs::nsCSSUnit::eCSSUnit_Inch => NoCalcLength::Absolute(AbsoluteLength::In(value)),
structs::nsCSSUnit::eCSSUnit_Centimeter => NoCalcLength::Absolute(AbsoluteLength::Cm(value)), structs::nsCSSUnit::eCSSUnit_Centimeter => NoCalcLength::Absolute(AbsoluteLength::Cm(value)),
structs::nsCSSUnit::eCSSUnit_Millimeter => NoCalcLength::Absolute(AbsoluteLength::Mm(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_Point => NoCalcLength::Absolute(AbsoluteLength::Pt(value)),
structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)), structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)),
structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)), structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)),