Bug 1385140: Don't unconditionally generate Calc values when converting from Gecko. r?birtles draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 28 Jul 2017 14:06:37 +0200
changeset 617335 cc75d8d4134fa3f608e535502421ce0eda9f0178
parent 617165 df8afc5dbc7e62c9d36c32e00eda9b98f01309d9
child 639805 b19a21e760db2cc6748f8cffcd97713bbba817dc
push id71040
push userbmo:emilio+bugs@crisal.io
push dateFri, 28 Jul 2017 12:08:02 +0000
reviewersbirtles
bugs1385140
milestone56.0a1
Bug 1385140: Don't unconditionally generate Calc values when converting from Gecko. r?birtles Hopefully this one doesn't require much more explanation :) MozReview-Commit-ID: ERwq50WSvLV
servo/components/style/gecko/conversions.rs
servo/components/style/properties/gecko.mako.rs
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -97,16 +97,26 @@ impl From<nsStyleCoord_CalcValue> for Le
         match (other.mHasPercent, other.mLength) {
             (false, _) => LengthOrPercentage::Length(Au(other.mLength)),
             (true, 0) => LengthOrPercentage::Percentage(Percentage(other.mPercent)),
             _ => LengthOrPercentage::Calc(other.into()),
         }
     }
 }
 
+impl From<nsStyleCoord_CalcValue> for LengthOrPercentageOrAuto {
+    fn from(other: nsStyleCoord_CalcValue) -> LengthOrPercentageOrAuto {
+        match (other.mHasPercent, other.mLength) {
+            (false, _) => LengthOrPercentageOrAuto::Length(Au(other.mLength)),
+            (true, 0) => LengthOrPercentageOrAuto::Percentage(Percentage(other.mPercent)),
+            _ => LengthOrPercentageOrAuto::Calc(other.into()),
+        }
+    }
+}
+
 impl From<Angle> for CoordDataValue {
     fn from(reference: Angle) -> Self {
         match reference {
             Angle::Degree(val) => CoordDataValue::Degree(val),
             Angle::Gradian(val) => CoordDataValue::Grad(val),
             Angle::Radian(val) => CoordDataValue::Radian(val),
             Angle::Turn(val) => CoordDataValue::Turn(val),
         }
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -3429,17 +3429,17 @@ fn static_assert() {
         use values::computed::LengthOrPercentageOrAuto;
         use values::generics::background::BackgroundSize;
 
         fn to_servo(value: CalcValue, ty: u8) -> LengthOrPercentageOrAuto {
             if ty == DimensionType::eAuto as u8 {
                 LengthOrPercentageOrAuto::Auto
             } else {
                 debug_assert!(ty == DimensionType::eLengthPercentage as u8);
-                LengthOrPercentageOrAuto::Calc(value.into())
+                value.into()
             }
         }
 
         longhands::background_size::computed_value::T(
             self.gecko.${image_layers_field}.mLayers.iter().map(|ref layer| {
                 if DimensionType::eCover as u8 == layer.mSize.mWidthType {
                     debug_assert!(layer.mSize.mHeightType == DimensionType::eCover as u8);
                     return BackgroundSize::Cover