This repository was archived by the owner on Jul 10, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ impl<'self> CompleteSelectResults {
34
34
let cb: n:: c:: ComputeFontSizeCb =
35
35
|parent : & Option < n:: h:: CssHint > , child : & n:: h:: CssHint | -> n:: h:: CssHint {
36
36
match * child {
37
+ // Handle relative units
37
38
CssHintLength ( n:: t:: CssUnitEm ( child_em) ) => {
38
39
match * parent {
39
40
Some ( CssHintLength ( parent_unit) ) => {
@@ -45,9 +46,24 @@ impl<'self> CompleteSelectResults {
45
46
new_value) ) ;
46
47
CssHintLength ( unit)
47
48
}
48
- _ => n:: h:: CssHintLength ( n:: t:: CssUnitEm ( child_em ) ) ,
49
+ _ => n:: h:: CssHintLength ( n:: t:: CssUnitPx ( float_to_css_fixed ( 16.0 ) ) ) ,
49
50
}
50
51
}
52
+ CssHintLength ( n:: t:: CssUnitPct ( child_pct) ) => {
53
+ match * parent {
54
+ Some ( CssHintLength ( parent_unit) ) => {
55
+ // CSS3 Values 5.1.1: Multiply parent unit by child unit.
56
+ let mut new_value =
57
+ n:: u:: css_fixed_to_float ( parent_unit. to_css_fixed ( ) ) ;
58
+ new_value *= n:: u:: css_fixed_to_float ( child_pct) / 100.0 ;
59
+ let unit = parent_unit. modify ( n:: u:: float_to_css_fixed (
60
+ new_value) ) ;
61
+ CssHintLength ( unit)
62
+ }
63
+ _ => n:: h:: CssHintLength ( n:: t:: CssUnitPx ( float_to_css_fixed ( 16.0 ) ) ) ,
64
+ }
65
+ }
66
+ // Pass through absolute units
51
67
CssHintLength ( unit) => CssHintLength ( unit) ,
52
68
_ => {
53
69
n:: h:: CssHintLength ( n:: t:: CssUnitPx ( float_to_css_fixed ( 16.0 ) ) )
You can’t perform that action at this time.
0 commit comments