diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 59523c5a2a0..f83a536166e 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -173,6 +173,7 @@ ${helpers.single_keyword("font-variant", "normal small-caps")} pub mod computed_value { use std::fmt; #[derive(PartialEq, Eq, Copy, Clone, Hash, Deserialize, Serialize, HeapSizeOf, Debug)] + #[repr(u16)] pub enum T { % for weight in range(100, 901, 100): Weight${weight} = ${weight}, diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 47d4b5c7d72..ff7ddd9a40c 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -424,7 +424,7 @@ fn static_assert() { } -<%self:impl_trait style_struct_name="Font" skip_longhands="font-size" skip_additionals="*"> +<%self:impl_trait style_struct_name="Font" skip_longhands="font-size font-weight" skip_additionals="*"> // FIXME(bholley): Gecko has two different sizes, one of which (mSize) is the // actual computed size, and the other of which (mFont.size) is the 'display @@ -441,6 +441,18 @@ fn static_assert() { Au(self.gecko.mSize) } + fn set_font_weight(&mut self, v: longhands::font_weight::computed_value::T) { + self.gecko.mFont.weight = v as u16; + } + <%call expr="impl_simple_copy('font_weight', 'mFont.weight')"> + + 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) } + } + // This is used for PartialEq, which we don't implement for gecko style structs. fn compute_font_hash(&mut self) {}