diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml index 6005126fb27..27ad7bc80a1 100644 --- a/components/style/cbindgen.toml +++ b/components/style/cbindgen.toml @@ -50,6 +50,7 @@ include = [ "ComputedTimingFunction", "Display", "DisplayMode", + "ExtremumLength", "FillRule", "FontDisplay", "FontFaceSourceListComponent", diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs index 59ccd0afeca..8006d50925f 100644 --- a/components/style/gecko/values.rs +++ b/components/style/gecko/values.rs @@ -362,40 +362,13 @@ impl GeckoStyleCoordConvertible for Normal { impl GeckoStyleCoordConvertible for ExtremumLength { fn to_gecko_style_coord(&self, coord: &mut T) { - use crate::gecko_bindings::structs::{ - NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT, - }; - use crate::gecko_bindings::structs::{ - NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT, - }; - coord.set_value(CoordDataValue::Enumerated(match *self { - ExtremumLength::MozMaxContent => NS_STYLE_WIDTH_MAX_CONTENT, - ExtremumLength::MozMinContent => NS_STYLE_WIDTH_MIN_CONTENT, - ExtremumLength::MozFitContent => NS_STYLE_WIDTH_FIT_CONTENT, - ExtremumLength::MozAvailable => NS_STYLE_WIDTH_AVAILABLE, - })) + coord.set_value(CoordDataValue::Enumerated(*self as u32)); } fn from_gecko_style_coord(coord: &T) -> Option { - use crate::gecko_bindings::structs::{ - NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT, - }; - use crate::gecko_bindings::structs::{ - NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT, - }; + use num_traits::FromPrimitive; match coord.as_value() { - CoordDataValue::Enumerated(NS_STYLE_WIDTH_MAX_CONTENT) => { - Some(ExtremumLength::MozMaxContent) - }, - CoordDataValue::Enumerated(NS_STYLE_WIDTH_MIN_CONTENT) => { - Some(ExtremumLength::MozMinContent) - }, - CoordDataValue::Enumerated(NS_STYLE_WIDTH_FIT_CONTENT) => { - Some(ExtremumLength::MozFitContent) - }, - CoordDataValue::Enumerated(NS_STYLE_WIDTH_AVAILABLE) => { - Some(ExtremumLength::MozAvailable) - }, + CoordDataValue::Enumerated(v) => ExtremumLength::from_u32(v), _ => None, } } diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 96886e9096a..7592c3a2cae 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -975,6 +975,7 @@ pub type NonNegativeLengthOrPercentageOrNormal = Either