Make font-size: larger/smaller work with the base size stuff

This commit is contained in:
Manish Goregaokar 2017-04-26 11:45:10 -07:00 committed by Manish Goregaokar
parent e23c8f1f3c
commit e4d39b5476
4 changed files with 14 additions and 6 deletions

View file

@ -741,6 +741,10 @@ ${helpers.single_keyword_system("font-variant-caps",
}
% endif
/// This is the ratio applied for font-size: larger
/// and smaller by both Firefox and Chrome
const LARGER_FONT_SIZE_RATIO: f32 = 1.2;
impl SpecifiedValue {
/// https://html.spec.whatwg.org/multipage/#rules-for-parsing-a-legacy-font-size
pub fn from_html_size(size: u8) -> Self {
@ -768,6 +772,10 @@ ${helpers.single_keyword_system("font-variant-caps",
return Some(em)
}
}
} else if let SpecifiedValue::Larger = *self {
return Some(LARGER_FONT_SIZE_RATIO)
} else if let SpecifiedValue::Smaller = *self {
return Some(1. / LARGER_FONT_SIZE_RATIO)
}
None
}
@ -799,11 +807,11 @@ ${helpers.single_keyword_system("font-variant-caps",
key.to_computed_value(context).scale_by(fraction)
}
SpecifiedValue::Smaller => {
FontRelativeLength::Em(0.85)
FontRelativeLength::Em(1. / LARGER_FONT_SIZE_RATIO)
.to_computed_value(context, base_size)
}
SpecifiedValue::Larger => {
FontRelativeLength::Em(1.2)
FontRelativeLength::Em(LARGER_FONT_SIZE_RATIO)
.to_computed_value(context, base_size)
}