diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index a9da305f6a2..230a8839fed 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -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) } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 6d77e39770b..1b33db843e9 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -21375,11 +21375,11 @@ "support" ], "css/font_size.html": [ - "1647905b6a68c9bb577afcbcca203208de524a88", + "7c944acb4f7d909083888a355e6d664c23081b99", "reftest" ], "css/font_size_ref.html": [ - "b0b486eb2cbc8537edae3a7c76b08c8ecc9a0ef3", + "cc34cbb1aae8e0d3738476bb09264f0fade78ba6", "support" ], "css/font_style.html": [ diff --git a/tests/wpt/mozilla/tests/css/font_size.html b/tests/wpt/mozilla/tests/css/font_size.html index 921e2887d2b..4ffd55261f2 100644 --- a/tests/wpt/mozilla/tests/css/font_size.html +++ b/tests/wpt/mozilla/tests/css/font_size.html @@ -8,7 +8,7 @@

2em is 40px.

2rem is 14px.

200% is 40px. -

smaller is 17px. +

smaller is 16.66666…px.

larger is 24px.

xx-small is 9.6px.

x-small is 12px. diff --git a/tests/wpt/mozilla/tests/css/font_size_ref.html b/tests/wpt/mozilla/tests/css/font_size_ref.html index a046358a884..6bcf5433885 100644 --- a/tests/wpt/mozilla/tests/css/font_size_ref.html +++ b/tests/wpt/mozilla/tests/css/font_size_ref.html @@ -6,7 +6,7 @@

2em is 40px.

2rem is 14px.

200% is 40px. -

smaller is 17px. +

smaller is 16.66666…px.

larger is 24px.

xx-small is 9.6px.

x-small is 12px.