diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 7774c599e93..2a27af6fddd 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -765,7 +765,7 @@ fn static_assert() { <%self:impl_trait style_struct_name="Font" - skip_longhands="font-family font-size font-weight" + skip_longhands="font-family font-size font-weight font-synthesis" skip_additionals="*"> pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) { @@ -828,6 +828,22 @@ fn static_assert() { // This is used for PartialEq, which we don't implement for gecko style structs. pub fn compute_font_hash(&mut self) {} + 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; + } + <% skip_box_longhands= """display overflow-y vertical-align diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 0733e83d82e..8f1dfecf33a 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -344,6 +344,69 @@ ${helpers.single_keyword("font-variant", } +<%helpers:longhand products="gecko" name="font-synthesis" animatable="False"> + use cssparser::ToCss; + use std::fmt; + use values::LocalToCss; + use values::computed::ComputedValueAsSpecified; + use values::NoViewportPercentage; + + impl ComputedValueAsSpecified for SpecifiedValue {} + impl NoViewportPercentage for SpecifiedValue {} + + pub mod computed_value { + pub use super::SpecifiedValue as T; + } + + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + pub struct SpecifiedValue { + pub weight: bool, + pub style: bool, + } + + impl ToCss for computed_value::T { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + if self.weight && self.style { + dest.write_str("weight style") + } else if self.style { + dest.write_str("style") + } else if self.weight { + dest.write_str("weight") + } else { + dest.write_str("none") + } + } + } + + #[inline] + pub fn get_initial_value() -> computed_value::T { + SpecifiedValue { weight: true, style: true } + } + + pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result { + let mut result = SpecifiedValue { weight: false, style: false }; + match_ignore_ascii_case! {try!(input.expect_ident()), + "none" => Ok(result), + "weight" => { + result.weight = true; + if input.try(|input| input.expect_ident_matching("style")).is_ok() { + result.style = true; + } + Ok(result) + }, + "style" => { + result.style = true; + if input.try(|input| input.expect_ident_matching("weight")).is_ok() { + result.weight = true; + } + Ok(result) + }, + _ => Err(()) + } + } + + // FIXME: This prop should be animatable ${helpers.single_keyword("font-stretch", "normal ultra-condensed extra-condensed condensed \