mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
servo: Merge #17732 - style: Simplify font_size::SpecifiedValue::as_font_ratio (from emilio:font-size-as-ratio); r=nox
Source-Repo: https://github.com/servo/servo Source-Revision: bb0c05dd2b4b81dfe86931c5e2dadcb1af11992d --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : cb612b2ed443ef07d5db9a7a3370647976405ca2
This commit is contained in:
parent
5e8fe99296
commit
8535bd87be
@ -768,23 +768,31 @@ ${helpers.single_keyword_system("font-variant-caps",
|
||||
}, 1.)
|
||||
}
|
||||
|
||||
/// If this value is specified as a ratio of the parent font (em units or percent)
|
||||
/// return the ratio
|
||||
/// If this value is specified as a ratio of the parent font (em units
|
||||
/// or percent) return the ratio
|
||||
pub fn as_font_ratio(&self) -> Option<f32> {
|
||||
if let SpecifiedValue::Length(ref lop) = *self {
|
||||
if let LengthOrPercentage::Percentage(pc) = *lop {
|
||||
return Some(pc.0)
|
||||
} else if let LengthOrPercentage::Length(ref nocalc) = *lop {
|
||||
if let NoCalcLength::FontRelative(FontRelativeLength::Em(em)) = *nocalc {
|
||||
return Some(em)
|
||||
match *self {
|
||||
SpecifiedValue::Length(ref lop) => {
|
||||
match *lop {
|
||||
LengthOrPercentage::Percentage(pc) => {
|
||||
Some(pc.0)
|
||||
}
|
||||
LengthOrPercentage::Length(ref nocalc) => {
|
||||
match *nocalc {
|
||||
NoCalcLength::FontRelative(FontRelativeLength::Em(em)) => {
|
||||
Some(em)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
// FIXME(emilio): This looks super fishy!
|
||||
LengthOrPercentage::Calc(..) => None,
|
||||
}
|
||||
}
|
||||
} 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)
|
||||
SpecifiedValue::Larger => Some(LARGER_FONT_SIZE_RATIO),
|
||||
SpecifiedValue::Smaller => Some(1. / LARGER_FONT_SIZE_RATIO),
|
||||
_ => None,
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Compute it against a given base font size
|
||||
@ -902,8 +910,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
||||
specified_value: &SpecifiedValue,
|
||||
mut computed: Au,
|
||||
parent: &Font) {
|
||||
if let SpecifiedValue::Keyword(kw, fraction)
|
||||
= *specified_value {
|
||||
if let 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
|
||||
|
Loading…
Reference in New Issue
Block a user