Bug 1682607 - Normalize NaN in some other font-related lengths etc. r=jfkthame,layout-reviewers
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 10 Feb 2021 15:30:40 +0000
changeset 566829 aa1ad21ca19fc044a7d63f64dbd90417d1bf2aca
parent 566828 64e2b89ff57f583ad2e0902a4626770f512b5135
child 566830 a65883accdf6e90fae4fe5e85ab43e950e50f649
push id38191
push userbtara@mozilla.com
push dateThu, 11 Feb 2021 05:02:45 +0000
treeherdermozilla-central@5cbcb80f72bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame, layout-reviewers
bugs1682607
milestone87.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1682607 - Normalize NaN in some other font-related lengths etc. r=jfkthame,layout-reviewers Depends on D104563 Differential Revision: https://phabricator.services.mozilla.com/D104565
servo/components/style/values/specified/font.rs
servo/components/style/values/specified/length.rs
testing/web-platform/tests/css/css-fonts/infinite-size-crash.html
--- a/servo/components/style/values/specified/font.rs
+++ b/servo/components/style/values/specified/font.rs
@@ -920,17 +920,17 @@ impl FontSize {
             FontSize::Length(LengthPercentage::Length(NoCalcLength::Absolute(ref l))) => {
                 context.maybe_zoom_text(l.to_computed_value(context))
             },
             FontSize::Length(LengthPercentage::Length(ref l)) => l.to_computed_value(context),
             FontSize::Length(LengthPercentage::Percentage(pc)) => {
                 // If the parent font was keyword-derived, this is too.
                 // Tack the % onto the factor
                 info = compose_keyword(pc.0);
-                base_size.resolve(context) * pc.0
+                (base_size.resolve(context) * pc.0).normalized()
             },
             FontSize::Length(LengthPercentage::Calc(ref calc)) => {
                 let calc = calc.to_computed_value_zoomed(context, base_size);
                 calc.resolve(base_size.resolve(context))
             },
             FontSize::Keyword(i) => {
                 // As a specified keyword, this is keyword derived
                 info = i;
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -130,17 +130,17 @@ impl FontRelativeLength {
 
     /// Computes the font-relative length.
     pub fn to_computed_value(
         &self,
         context: &Context,
         base_size: FontBaseSize,
     ) -> computed::Length {
         let (reference_size, length) = self.reference_font_size_and_length(context, base_size);
-        reference_size * length
+        (reference_size * length).normalized()
     }
 
     /// Return reference font size.
     ///
     /// We use the base_size flag to pass a different size for computing
     /// font-size and unconstrained font-size.
     ///
     /// This returns a pair, the first one is the reference font size, and the
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-fonts/infinite-size-crash.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        CITE::first-letter {
+            font-size: 0%;
+            margin-inline-start: 2682182284.200815ch
+        }
+
+        * {
+            font-size: 4294967295% !important;
+        }
+    </style>
+</head>
+<del>
+    <button>
+        <cite></cite>
+    </button>
+</del>
+</html>