diff --git a/servo/components/style/properties/longhand/font.mako.rs b/servo/components/style/properties/longhand/font.mako.rs index 723d657abe29..11e4aeb1ef0c 100644 --- a/servo/components/style/properties/longhand/font.mako.rs +++ b/servo/components/style/properties/longhand/font.mako.rs @@ -891,9 +891,10 @@ ${helpers.single_keyword_system("font-variant-caps", } } + #[allow(unused_mut)] pub fn cascade_specified_font_size(context: &mut Context, specified_value: &SpecifiedValue, - computed: Au, + mut computed: Au, parent: &Font) { if let SpecifiedValue::Keyword(kw, fraction) = *specified_value { @@ -914,6 +915,22 @@ ${helpers.single_keyword_system("font-variant-caps", context.mutate_style().font_size_keyword = None; } + // we could use clone_language and clone_font_family() here but that's + // expensive. Do it only in gecko mode for now. + % if product == "gecko": + use gecko_bindings::structs::nsIAtom; + // if the language or generic changed, we need to recalculate + // the font size from the stored font-size origin information. + if context.style().get_font().gecko().mLanguage.raw::() != + context.inherited_style().get_font().gecko().mLanguage.raw::() || + context.style().get_font().gecko().mGenericID != + context.inherited_style().get_font().gecko().mGenericID { + if let Some((kw, ratio)) = context.style().font_size_keyword { + computed = kw.to_computed_value(context).scale_by(ratio); + } + } + % endif + let parent_unconstrained = context.mutate_style() .mutate_font() .apply_font_size(computed,