diff --git a/components/style/properties/shorthands/font.mako.rs b/components/style/properties/shorthands/font.mako.rs index 91b2d239a27..45c2c59e234 100644 --- a/components/style/properties/shorthands/font.mako.rs +++ b/components/style/properties/shorthands/font.mako.rs @@ -31,6 +31,7 @@ derive_value_info="False" spec="https://drafts.csswg.org/css-fonts-3/#propdef-font" > + use crate::computed_values::font_variant_caps::T::SmallCaps; use crate::parser::Parse; use crate::properties::longhands::{font_family, font_style, font_weight, font_stretch}; use crate::properties::longhands::font_variant_caps; @@ -100,8 +101,11 @@ } } if variant_caps.is_none() { - if let Ok(value) = input.try_parse(|input| font_variant_caps::parse(context, input)) { - variant_caps = Some(value); + // The only variant-caps value allowed is small-caps (from CSS2); the added values + // defined by CSS Fonts 3 and later are not accepted. + // https://www.w3.org/TR/css-fonts-4/#font-prop + if input.try_parse(|input| input.expect_ident_matching("small-caps")).is_ok() { + variant_caps = Some(font_variant_caps::SpecifiedValue::Keyword(SmallCaps)); continue } } @@ -205,6 +209,14 @@ FontStretch::System(..) => return Ok(()), }; + // The only variant-caps value allowed in the shorthand is small-caps (from CSS2); + // the added values defined by CSS Fonts 3 and later are not supported. + // https://www.w3.org/TR/css-fonts-4/#font-prop + if self.font_variant_caps != &font_variant_caps::get_initial_specified_value() && + *self.font_variant_caps != font_variant_caps::SpecifiedValue::Keyword(SmallCaps) { + return Ok(()); + } + % for name in "style variant_caps weight".split(): if self.font_${name} != &font_${name}::get_initial_specified_value() { self.font_${name}.to_css(dest)?;