servo: Merge #17906 - style: Don't unconditionally generate Calc values when converting background-size from Gecko (from emilio:calc-bgsize); r=hiro,birtles
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 29 Jul 2017 06:41:27 -0500
changeset 420525 d24b801a5c8e504cf1bd7df6dd8879d5a0bec919
parent 420524 564a2867f073ba9e592f28330830daf91bf5e1ae
child 420526 01b9da502326dd85afeeeca5780c319460184c00
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro, birtles
bugs17906, 1385140
milestone56.0a1
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
servo: Merge #17906 - style: Don't unconditionally generate Calc values when converting background-size from Gecko (from emilio:calc-bgsize); r=hiro,birtles Bug: 1385140 MozReview-Commit-ID: ERwq50WSvLV Source-Repo: https://github.com/servo/servo Source-Revision: 6b320eaad3b0bc5e5efe432f504714156d325c4d
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
@@ -3441,17 +3441,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