stylo: Cascade relative font-sizes applied to keyword sizes

This commit is contained in:
Manish Goregaokar 2017-04-12 14:23:33 +08:00 committed by Manish Goregaokar
parent 3c5a21ebf3
commit 8b9163900d
4 changed files with 68 additions and 19 deletions

View file

@ -267,8 +267,21 @@
DeclaredValue::Value(ref specified_value) => {
let computed = specified_value.to_computed_value(context);
% if property.ident == "font_size":
if let longhands::font_size::SpecifiedValue::Keyword(kw) = **specified_value {
context.mutate_style().font_size_keyword = Some(kw);
if let longhands::font_size::SpecifiedValue::Keyword(kw, fraction)
= **specified_value {
context.mutate_style().font_size_keyword = Some((kw, fraction));
} else if let Some(ratio) = specified_value.as_font_ratio() {
// In case a font-size-relative value was applied to a keyword
// value, we must preserve this fact in case the generic font family
// changes. relative values (em and %) applied to keywords must be
// recomputed from the base size for the keyword and the relative size.
//
// See bug 1355707
if let Some((kw, fraction)) = context.inherited_style().font_size_keyword {
context.mutate_style().font_size_keyword = Some((kw, fraction * ratio));
} else {
context.mutate_style().font_size_keyword = None;
}
} else {
context.mutate_style().font_size_keyword = None;
}
@ -294,7 +307,7 @@
.to_computed_value(context);
context.mutate_style().mutate_${data.current_style_struct.name_lower}()
.set_font_size(computed);
context.mutate_style().font_size_keyword = Some(Default::default());
context.mutate_style().font_size_keyword = Some((Default::default(), 1.));
% else:
// We assume that it's faster to use copy_*_from rather than
// set_*(get_initial_value());