diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 5311f79f71f..f6f28924721 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1349,27 +1349,7 @@ fn static_assert() { } % endfor - pub fn set_grid_auto_flow(&mut self, v: longhands::grid_auto_flow::computed_value::T) { - use gecko_bindings::structs::NS_STYLE_GRID_AUTO_FLOW_ROW; - use gecko_bindings::structs::NS_STYLE_GRID_AUTO_FLOW_COLUMN; - use gecko_bindings::structs::NS_STYLE_GRID_AUTO_FLOW_DENSE; - use properties::longhands::grid_auto_flow::computed_value::AutoFlow::{Row, Column}; - - self.gecko.mGridAutoFlow = 0; - - let value = match v.autoflow { - Row => NS_STYLE_GRID_AUTO_FLOW_ROW, - Column => NS_STYLE_GRID_AUTO_FLOW_COLUMN, - }; - - self.gecko.mGridAutoFlow |= value as u8; - - if v.dense { - self.gecko.mGridAutoFlow |= NS_STYLE_GRID_AUTO_FLOW_DENSE as u8; - } - } - - ${impl_simple_copy('grid_auto_flow', 'mGridAutoFlow')} + ${impl_simple_type_with_conversion("grid_auto_flow")} pub fn set_grid_template_areas(&mut self, v: longhands::grid_template_areas::computed_value::T) { use gecko_bindings::bindings::Gecko_NewGridTemplateAreasValue; @@ -1791,21 +1771,7 @@ fn static_assert() { unsafe { transmute(self.gecko.mFont.weight) } } - pub fn set_font_synthesis(&mut self, v: longhands::font_synthesis::computed_value::T) { - use gecko_bindings::structs::{NS_FONT_SYNTHESIS_WEIGHT, NS_FONT_SYNTHESIS_STYLE}; - - self.gecko.mFont.synthesis = 0; - if v.weight { - self.gecko.mFont.synthesis |= NS_FONT_SYNTHESIS_WEIGHT as u8; - } - if v.style { - self.gecko.mFont.synthesis |= NS_FONT_SYNTHESIS_STYLE as u8; - } - } - - pub fn copy_font_synthesis_from(&mut self, other: &Self) { - self.gecko.mFont.synthesis = other.gecko.mFont.synthesis; - } + ${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")} pub fn set_font_size_adjust(&mut self, v: longhands::font_size_adjust::computed_value::T) { use properties::longhands::font_size_adjust::computed_value::T; @@ -3703,25 +3669,7 @@ fn static_assert() { } } - pub fn set_text_emphasis_position(&mut self, v: longhands::text_emphasis_position::computed_value::T) { - use properties::longhands::text_emphasis_position::*; - - let mut result = match v.0 { - HorizontalWritingModeValue::Over => structs::NS_STYLE_TEXT_EMPHASIS_POSITION_OVER as u8, - HorizontalWritingModeValue::Under => structs::NS_STYLE_TEXT_EMPHASIS_POSITION_UNDER as u8, - }; - match v.1 { - VerticalWritingModeValue::Right => { - result |= structs::NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT as u8; - } - VerticalWritingModeValue::Left => { - result |= structs::NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT as u8; - } - } - self.gecko.mTextEmphasisPosition = result; - } - - <%call expr="impl_simple_copy('text_emphasis_position', 'mTextEmphasisPosition')"> + ${impl_simple_type_with_conversion("text_emphasis_position")} pub fn set_text_emphasis_style(&mut self, v: longhands::text_emphasis_style::computed_value::T) { use properties::longhands::text_emphasis_style::computed_value::T; diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 3ba7576fe37..cf2d9b8d7ec 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -1161,7 +1161,7 @@ ${helpers.single_keyword_system("font-variant-caps", } -<%helpers:longhand products="gecko" name="font-synthesis" animation_value_type="none" +<%helpers:longhand products="gecko" name="font-synthesis" animation_value_type="discrete" spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis"> use std::fmt; use style_traits::ToCss; @@ -1221,6 +1221,34 @@ ${helpers.single_keyword_system("font-variant-caps", _ => Err(()) } } + + #[cfg(feature = "gecko")] + impl From for SpecifiedValue { + fn from(bits: u8) -> SpecifiedValue { + use gecko_bindings::structs; + + SpecifiedValue { + weight: bits & structs::NS_FONT_SYNTHESIS_WEIGHT as u8 != 0, + style: bits & structs::NS_FONT_SYNTHESIS_STYLE as u8 != 0 + } + } + } + + #[cfg(feature = "gecko")] + impl From for u8 { + fn from(v: SpecifiedValue) -> u8 { + use gecko_bindings::structs; + + let mut bits: u8 = 0; + if v.weight { + bits |= structs::NS_FONT_SYNTHESIS_WEIGHT as u8; + } + if v.style { + bits |= structs::NS_FONT_SYNTHESIS_STYLE as u8; + } + bits + } + } ${helpers.single_keyword_system("font-stretch", diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index f78059017b5..8a4aea6a2b0 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -624,7 +624,7 @@ ${helpers.predefined_type("word-spacing", } -<%helpers:longhand name="text-emphasis-position" animation_value_type="none" products="gecko" +<%helpers:longhand name="text-emphasis-position" animation_value_type="discrete" products="gecko" spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-position"> use values::computed::ComputedValueAsSpecified; use style_traits::ToCss; @@ -682,6 +682,32 @@ ${helpers.predefined_type("word-spacing", SpecifiedValue(horiz, vert) } } + + impl From for SpecifiedValue { + fn from(bits: u8) -> SpecifiedValue { + SpecifiedValue::from_gecko_keyword(bits as u32) + } + } + + impl From for u8 { + fn from(v: SpecifiedValue) -> u8 { + use gecko_bindings::structs; + + let mut result = match v.0 { + HorizontalWritingModeValue::Over => structs::NS_STYLE_TEXT_EMPHASIS_POSITION_OVER, + HorizontalWritingModeValue::Under => structs::NS_STYLE_TEXT_EMPHASIS_POSITION_UNDER, + }; + match v.1 { + VerticalWritingModeValue::Right => { + result |= structs::NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT; + } + VerticalWritingModeValue::Left => { + result |= structs::NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT; + } + }; + result as u8 + } + } % endif diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index ac220446e64..46cc63143f0 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -292,7 +292,7 @@ ${helpers.predefined_type("object-position", <%helpers:longhand name="grid-auto-flow" spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-flow" products="gecko" - animation_value_type="none"> + animation_value_type="discrete"> use std::fmt; use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; @@ -372,6 +372,43 @@ ${helpers.predefined_type("object-position", Err(()) } } + + #[cfg(feature = "gecko")] + impl From for SpecifiedValue { + fn from(bits: u8) -> SpecifiedValue { + use gecko_bindings::structs; + use self::computed_value::AutoFlow; + + SpecifiedValue { + autoflow: + if bits & structs::NS_STYLE_GRID_AUTO_FLOW_ROW as u8 != 0 { + AutoFlow::Row + } else { + AutoFlow::Column + }, + dense: + bits & structs::NS_STYLE_GRID_AUTO_FLOW_DENSE as u8 != 0, + } + } + } + + #[cfg(feature = "gecko")] + impl From for u8 { + fn from(v: SpecifiedValue) -> u8 { + use gecko_bindings::structs; + use self::computed_value::AutoFlow; + + let mut result: u8 = match v.autoflow { + AutoFlow::Row => structs::NS_STYLE_GRID_AUTO_FLOW_ROW as u8, + AutoFlow::Column => structs::NS_STYLE_GRID_AUTO_FLOW_COLUMN as u8, + }; + + if v.dense { + result |= structs::NS_STYLE_GRID_AUTO_FLOW_DENSE as u8; + } + result + } + } <%helpers:longhand name="grid-template-areas"