Backed out changeset 76a4f60761f9 for breaking Mochitests on multiple platforms on layout/style/test/test_transitions_per_property.html.
authorDorel Luca <dluca@mozilla.com>
Mon, 21 May 2018 02:48:20 +0300
changeset 419119 26800d5aaf70be800a1a14c858e09ea54b21edeb
parent 419118 ad12df88c16e7e65c7f44a1fbe1f1ee6cb17c0a6
child 419120 40f686deb993defb39e4b9c4e72d79368514d84d
push id34026
push userapavel@mozilla.com
push dateMon, 21 May 2018 09:47:33 +0000
treeherdermozilla-central@dc1868d255be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone62.0a1
backs out76a4f60761f972e768327e3d65bafa2fe0c8b1cb
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 76a4f60761f9 for breaking Mochitests on multiple platforms on layout/style/test/test_transitions_per_property.html.
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhand/font.mako.rs
servo/components/style/properties/properties.mako.rs
servo/components/style/values/computed/font.rs
servo/components/style/values/generics/font.rs
servo/components/style/values/generics/mod.rs
servo/components/style/values/specified/font.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -2602,34 +2602,28 @@ fn static_assert() {
     pub fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T {
         let weight: f32 = unsafe {
             bindings::Gecko_FontWeight_ToFloat(self.gecko.mFont.weight)
         };
         longhands::font_weight::computed_value::T(weight)
     }
 
     pub fn set_font_stretch(&mut self, v: longhands::font_stretch::computed_value::T) {
-        unsafe {
-            bindings::Gecko_FontStretch_SetFloat(
-                &mut self.gecko.mFont.stretch,
-                v.value(),
-            )
-        };
+        unsafe { bindings::Gecko_FontStretch_SetFloat(&mut self.gecko.mFont.stretch, (v.0).0) };
     }
     ${impl_simple_copy('font_stretch', 'mFont.stretch')}
     pub fn clone_font_stretch(&self) -> longhands::font_stretch::computed_value::T {
-        use values::computed::font::FontStretch;
         use values::computed::Percentage;
         use values::generics::NonNegative;
 
         let stretch =
             unsafe { bindings::Gecko_FontStretch_ToFloat(self.gecko.mFont.stretch) };
         debug_assert!(stretch >= 0.);
 
-        FontStretch(NonNegative(Percentage(stretch)))
+        NonNegative(Percentage(stretch))
     }
 
     pub fn set_font_style(&mut self, v: longhands::font_style::computed_value::T) {
         use values::generics::font::FontStyle;
         let s = &mut self.gecko.mFont.style;
         unsafe {
             match v {
                 FontStyle::Normal => bindings::Gecko_FontSlantStyle_SetNormal(s),
--- a/servo/components/style/properties/longhand/font.mako.rs
+++ b/servo/components/style/properties/longhand/font.mako.rs
@@ -79,17 +79,17 @@
                           initial_value="specified::FontSynthesis::get_initial_value()",
                           animation_value_type="discrete",
                           flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
                           spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis")}
 
 ${helpers.predefined_type(
     "font-stretch",
     "FontStretch",
-    initial_value="computed::FontStretch::hundred()",
+    initial_value="computed::NonNegativePercentage::hundred()",
     initial_specified_value="specified::FontStretch::normal()",
     animation_value_type="Percentage",
     flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
     spec="https://drafts.csswg.org/css-fonts/#propdef-font-stretch",
     servo_restyle_damage="rebuild_and_reflow",
 )}
 
 ${helpers.single_keyword_system("font-kerning",
@@ -330,17 +330,17 @@ https://drafts.csswg.org/css-fonts-4/#lo
         impl ToComputedValue for SystemFont {
             type ComputedValue = ComputedSystemFont;
 
             fn to_computed_value(&self, cx: &Context) -> Self::ComputedValue {
                 use gecko_bindings::bindings;
                 use gecko_bindings::structs::{LookAndFeel_FontID, nsFont};
                 use std::mem;
                 use values::computed::Percentage;
-                use values::computed::font::{FontSize, FontStretch, FontStyle, FontFamilyList};
+                use values::computed::font::{FontSize, FontStyle, FontFamilyList};
                 use values::generics::NonNegative;
 
                 let id = match *self {
                     % for font in system_fonts:
                         SystemFont::${to_camel_case(font)} => {
                             LookAndFeel_FontID::eFont_${to_camel_case(font.replace("-moz-", ""))}
                         }
                     % endfor
@@ -351,19 +351,19 @@ https://drafts.csswg.org/css-fonts-4/#lo
                     bindings::Gecko_nsFont_InitSystem(
                         &mut system,
                         id as i32,
                         cx.style().get_font().gecko(),
                         cx.device().pres_context()
                     )
                 }
                 let font_weight = longhands::font_weight::computed_value::T::from_gecko_weight(system.weight);
-                let font_stretch = FontStretch(NonNegative(Percentage(unsafe {
+                let font_stretch = NonNegative(Percentage(unsafe {
                     bindings::Gecko_FontStretch_ToFloat(system.stretch)
-                })));
+                }));
                 let font_style = FontStyle::from_gecko(system.style);
                 let ret = ComputedSystemFont {
                     font_family: longhands::font_family::computed_value::T(
                         FontFamilyList(
                             unsafe { system.fontlist.mFontlist.mBasePtr.to_safe() }
                         )
                     ),
                     font_size: FontSize {
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -2300,20 +2300,23 @@ pub mod style_structs {
                     }
                 % endfor
             % elif style_struct.name == "Font":
                 /// Computes a font hash in order to be able to cache fonts
                 /// effectively in GFX and layout.
                 pub fn compute_font_hash(&mut self) {
                     // Corresponds to the fields in
                     // `gfx::font_template::FontTemplateDescriptor`.
+                    //
+                    // FIXME(emilio): Where's font-style?
                     let mut hasher: FnvHasher = Default::default();
-                    self.font_weight.hash(&mut hasher);
-                    self.font_stretch.hash(&mut hasher);
-                    self.font_style.hash(&mut hasher);
+                    // We hash the floating point number with four decimal
+                    // places.
+                    hasher.write_u64((self.font_weight.0 * 10000.).trunc() as u64);
+                    hasher.write_u64(((self.font_stretch.0).0 * 10000.).trunc() as u64);
                     self.font_family.hash(&mut hasher);
                     self.hash = hasher.finish()
                 }
 
                 /// (Servo does not handle MathML, so this just calls copy_font_size_from)
                 pub fn inherit_font_size_from(&mut self, parent: &Self,
                                               _: Option<NonNegativeLength>,
                                               _: &Device) {
--- a/servo/components/style/values/computed/font.rs
+++ b/servo/components/style/values/computed/font.rs
@@ -10,47 +10,42 @@ use byteorder::{BigEndian, ByteOrder};
 use cssparser::{serialize_identifier, CssStringWriter, Parser};
 #[cfg(feature = "gecko")]
 use gecko_bindings::{bindings, structs};
 #[cfg(feature = "gecko")]
 use gecko_bindings::sugar::refptr::RefPtr;
 #[cfg(feature = "gecko")]
 use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
 use std::fmt::{self, Write};
+#[cfg(feature = "gecko")]
 use std::hash::{Hash, Hasher};
 #[cfg(feature = "servo")]
 use std::slice;
 use style_traits::{CssWriter, ParseError, ToCss};
 use values::CSSFloat;
 use values::animated::{ToAnimatedValue, ToAnimatedZero};
-use values::computed::{Angle, Context, Integer, NonNegative, NonNegativeLength, NonNegativePercentage};
-use values::computed::{Number, Percentage, ToComputedValue};
+use values::computed::{Angle, Context, Integer, NonNegativeLength, Number, ToComputedValue};
 use values::generics::font::{self as generics, FeatureTagValue, FontSettings, VariationValue};
 use values::specified::font::{self as specified, MIN_FONT_WEIGHT, MAX_FONT_WEIGHT};
 use values::specified::length::{FontBaseSize, NoCalcLength};
 
 pub use values::computed::Length as MozScriptMinSize;
 pub use values::specified::font::{FontSynthesis, MozScriptSizeMultiplier, XLang, XTextZoom};
+pub use values::computed::NonNegativePercentage as FontStretch;
 
 /// A value for the font-weight property per:
 ///
 /// https://drafts.csswg.org/css-fonts-4/#propdef-font-weight
 ///
 /// This is effectively just a `Number`.
 #[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
          ToCss)]
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
 pub struct FontWeight(pub Number);
 
-impl Hash for FontWeight {
-    fn hash<H: Hasher>(&self, hasher: &mut H) {
-        hasher.write_u64((self.0 * 10000.).trunc() as u64);
-    }
-}
-
 impl ToAnimatedValue for FontWeight {
     type AnimatedValue = Number;
 
     #[inline]
     fn to_animated_value(self) -> Self::AnimatedValue {
         self.0
     }
 
@@ -853,22 +848,16 @@ impl ToAnimatedValue for FontStyleAngle 
         FontStyleAngle(Angle::Deg(
             animated.degrees()
                 .min(specified::FONT_STYLE_OBLIQUE_MAX_ANGLE_DEGREES)
                 .max(specified::FONT_STYLE_OBLIQUE_MIN_ANGLE_DEGREES)
         ))
     }
 }
 
-impl Hash for FontStyleAngle {
-    fn hash<H: Hasher>(&self, hasher: &mut H) {
-        hasher.write_u64((self.0.degrees() * 10000.).trunc() as u64);
-    }
-}
-
 /// The computed value of `font-style`.
 ///
 /// FIXME(emilio): Angle should be a custom type to handle clamping during
 /// animation.
 pub type FontStyle = generics::FontStyle<FontStyleAngle>;
 
 impl FontStyle {
     /// The `normal` value.
@@ -922,48 +911,8 @@ impl ToCss for FontStyle {
                     dest.write_char(' ')?;
                     angle.to_css(dest)?;
                 }
                 Ok(())
             }
         }
     }
 }
-
-/// A value for the font-stretch property per:
-///
-/// https://drafts.csswg.org/css-fonts-4/#propdef-font-stretch
-#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss)]
-#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-pub struct FontStretch(pub NonNegativePercentage);
-
-impl FontStretch {
-    /// 100%
-    pub fn hundred() -> Self {
-        FontStretch(NonNegativePercentage::hundred())
-    }
-
-    /// The float value of the percentage
-    #[inline]
-    pub fn value(&self) -> CSSFloat {
-        ((self.0).0).0
-    }
-}
-
-impl ToAnimatedValue for FontStretch {
-    type AnimatedValue = Percentage;
-
-    #[inline]
-    fn to_animated_value(self) -> Self::AnimatedValue {
-        (self.0).0
-    }
-
-    #[inline]
-    fn from_animated_value(animated: Self::AnimatedValue) -> Self {
-        FontStretch(NonNegative(animated))
-    }
-}
-
-impl Hash for FontStretch {
-    fn hash<H: Hasher>(&self, hasher: &mut H) {
-        hasher.write_u64((self.value() * 10000.).trunc() as u64);
-    }
-}
--- a/servo/components/style/values/generics/font.rs
+++ b/servo/components/style/values/generics/font.rs
@@ -223,17 +223,17 @@ impl Default for KeywordSize {
     }
 }
 
 /// A generic value for the `font-style` property.
 ///
 /// https://drafts.csswg.org/css-fonts-4/#font-style-prop
 #[allow(missing_docs)]
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Hash, MallocSizeOf,
+#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf,
          PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero)]
 pub enum FontStyle<Angle> {
     #[animation(error)]
     Normal,
     #[animation(error)]
     Italic,
     #[value_info(starts_with_keyword)]
     Oblique(Angle),
--- a/servo/components/style/values/generics/mod.rs
+++ b/servo/components/style/values/generics/mod.rs
@@ -151,17 +151,17 @@ impl SpecifiedValueInfo for CounterStyle
             }
         }
         include!("../../counter_style/predefined.rs");
     }
 }
 
 /// A wrapper of Non-negative values.
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Hash, MallocSizeOf,
+#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf,
          PartialEq, PartialOrd, SpecifiedValueInfo, ToAnimatedZero,
          ToComputedValue, ToCss)]
 pub struct NonNegative<T>(pub T);
 
 /// A wrapper of greater-than-or-equal-to-one values.
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
 #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf,
          PartialEq, PartialOrd, SpecifiedValueInfo, ToAnimatedZero,
--- a/servo/components/style/values/specified/font.rs
+++ b/servo/components/style/values/specified/font.rs
@@ -485,32 +485,32 @@ impl Parse for FontStretch {
             return Ok(FontStretch::Stretch(percentage));
         }
 
         Ok(FontStretch::Keyword(FontStretchKeyword::parse(input)?))
     }
 }
 
 impl ToComputedValue for FontStretch {
-    type ComputedValue = computed::FontStretch;
+    type ComputedValue = NonNegative<ComputedPercentage>;
 
     fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
         match *self {
             FontStretch::Stretch(ref percentage) => {
-                computed::FontStretch(NonNegative(percentage.to_computed_value(context)))
+                NonNegative(percentage.to_computed_value(context))
             },
             FontStretch::Keyword(ref kw) => {
-                computed::FontStretch(NonNegative(kw.compute()))
+                NonNegative(kw.compute())
             },
             FontStretch::System(_) => self.compute_system(context),
         }
     }
 
     fn from_computed_value(computed: &Self::ComputedValue) -> Self {
-        FontStretch::Stretch(Percentage::from_computed_value(&(computed.0).0))
+        FontStretch::Stretch(Percentage::from_computed_value(&computed.0))
     }
 }
 
 #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
 /// A specified font-size value
 pub enum FontSize {
     /// A length; e.g. 10px.
     Length(LengthOrPercentage),