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
--- 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