diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index e6f1c42e31a..0c71b82c841 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2022,10 +2022,8 @@ fn static_assert() { ${impl_simple_copy('font_weight', 'mFont.weight')} pub fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T { - debug_assert!(self.gecko.mFont.weight >= 100); - debug_assert!(self.gecko.mFont.weight <= 900); - debug_assert!(self.gecko.mFont.weight % 10 == 0); - unsafe { transmute(self.gecko.mFont.weight) } + debug_assert!(self.gecko.mFont.weight <= ::std::u16::MAX); + longhands::font_weight::computed_value::T(self.gecko.mFont.weight) } ${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")} diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 8942c73afb9..d424749abc0 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -457,6 +457,9 @@ ${helpers.single_keyword_system("font-variant-caps", pub mod computed_value { /// As of CSS Fonts Module Level 3, only the following values are /// valid: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 + /// + /// However, system fonts may provide other values. Pango + /// may provide 350, 380, and 1000 (on top of the existing values), for example. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, ToCss)] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub struct T(pub u16); @@ -483,8 +486,9 @@ ${helpers.single_keyword_system("font-variant-caps", /// Convert from an Gecko weight pub fn from_gecko_weight(weight: u16) -> Self { - Self::from_int(weight as i32) - .expect("from_gecko_weight: called with invalid weight") + // we allow a wider range of weights than is parseable + // because system fonts may provide custom values + T(weight) } /// Weither this weight is bold