@@ -768,23 +768,31 @@ ${helpers.single_keyword_system("font-variant-caps",
768
768
} , 1. )
769
769
}
770
770
771
- /// If this value is specified as a ratio of the parent font (em units or percent)
772
- /// return the ratio
771
+ /// If this value is specified as a ratio of the parent font (em units
772
+ /// or percent) return the ratio
773
773
pub fn as_font_ratio( & self ) -> Option <f32 > {
774
- if let SpecifiedValue :: Length ( ref lop) = * self {
775
- if let LengthOrPercentage :: Percentage ( pc) = * lop {
776
- return Some ( pc. 0 )
777
- } else if let LengthOrPercentage :: Length ( ref nocalc) = * lop {
778
- if let NoCalcLength :: FontRelative ( FontRelativeLength :: Em ( em) ) = * nocalc {
779
- return Some ( em)
774
+ match * self {
775
+ SpecifiedValue :: Length ( ref lop) => {
776
+ match * lop {
777
+ LengthOrPercentage :: Percentage ( pc) => {
778
+ Some ( pc. 0 )
779
+ }
780
+ LengthOrPercentage :: Length ( ref nocalc) => {
781
+ match * nocalc {
782
+ NoCalcLength :: FontRelative ( FontRelativeLength :: Em ( em) ) => {
783
+ Some ( em)
784
+ }
785
+ _ => None ,
786
+ }
787
+ }
788
+ // FIXME(emilio): This looks super fishy!
789
+ LengthOrPercentage :: Calc ( ..) => None ,
780
790
}
781
791
}
782
- } else if let SpecifiedValue :: Larger = * self {
783
- return Some ( LARGER_FONT_SIZE_RATIO )
784
- } else if let SpecifiedValue :: Smaller = * self {
785
- return Some ( 1. / LARGER_FONT_SIZE_RATIO )
792
+ SpecifiedValue :: Larger => Some ( LARGER_FONT_SIZE_RATIO ) ,
793
+ SpecifiedValue :: Smaller => Some ( 1. / LARGER_FONT_SIZE_RATIO ) ,
794
+ _ => None ,
786
795
}
787
- None
788
796
}
789
797
790
798
/// Compute it against a given base font size
@@ -902,8 +910,7 @@ ${helpers.single_keyword_system("font-variant-caps",
902
910
specified_value: & SpecifiedValue ,
903
911
mut computed: Au ,
904
912
parent: & Font ) {
905
- if let SpecifiedValue :: Keyword ( kw, fraction)
906
- = * specified_value {
913
+ if let SpecifiedValue :: Keyword ( kw, fraction) = * specified_value {
907
914
context. mutate_style( ) . font_size_keyword = Some ( ( kw, fraction) ) ;
908
915
} else if let Some ( ratio) = specified_value. as_font_ratio( ) {
909
916
// In case a font-size-relative value was applied to a keyword
0 commit comments