Bug 1397363 - stylo: Use Au's arithmetic operations for accumulation ; r?emilio draft
authorManish Goregaokar <manishearth@gmail.com>
Wed, 06 Sep 2017 14:19:10 -0700
changeset 660330 7b627e3218ccba58e62d0ec94b2f33a8ff763c38
parent 659233 973e8b890a62aee4b3170558ac3b608928162ef6
child 730220 3d720e5fdbb9e4b55e56c671e3136812be4ce448
push id78385
push userbmo:manishearth@gmail.com
push dateWed, 06 Sep 2017 22:40:59 +0000
reviewersemilio
bugs1397363
milestone57.0a1
Bug 1397363 - stylo: Use Au's arithmetic operations for accumulation ; r?emilio MozReview-Commit-ID: 9FFRE3tUHYk
layout/style/crashtests/1397363-1.html
layout/style/crashtests/crashtests.list
servo/components/style/values/animated/mod.rs
servo/components/style/values/specified/length.rs
new file mode 100644
--- /dev/null
+++ b/layout/style/crashtests/1397363-1.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<script>
+a = document.documentElement.animate([{ "clip": "rect(632vw,0,103.9vmax,5ex)" }],
+                                     { duration:96.2272536276,
+                                       iterations:Number.POSITIVE_INFINITY,
+                                       iterationComposite:"accumulate" });
+a.playbackRate = 3000;
+</script>
+</head>
+</html>
--- a/layout/style/crashtests/crashtests.list
+++ b/layout/style/crashtests/crashtests.list
@@ -207,8 +207,9 @@ load 1391577.html
 load 1393189.html
 load 1393580.html
 load 1389645.html
 load 1390726.html
 load 1393791.html
 load 1384232.html
 load 1395725.html
 load 1396041.html
+load 1397363-1.html
--- a/servo/components/style/values/animated/mod.rs
+++ b/servo/components/style/values/animated/mod.rs
@@ -157,17 +157,17 @@ where
             _ => Err(()),
         }
     }
 }
 
 impl Animate for Au {
     #[inline]
     fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
-        Ok(Au(self.0.animate(&other.0, procedure)?))
+        Ok(Au::new(self.0.animate(&other.0, procedure)?))
     }
 }
 
 impl<T> Animate for Size2D<T>
 where
     T: Animate + Copy,
 {
     #[inline]
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //! [Length values][length].
 //!
 //! [length]: https://drafts.csswg.org/css-values/#lengths
 
-use app_units::Au;
+use app_units::{Au, MAX_AU, MIN_AU};
 use cssparser::{Parser, Token, BasicParseError};
 use euclid::Size2D;
 use font_metrics::FontMetricsQueryResult;
 use parser::{Parse, ParserContext};
 use std::{cmp, fmt, mem};
 use std::ascii::AsciiExt;
 use std::ops::Mul;
 use style_traits::{ToCss, ParseError, StyleParseError};
@@ -231,26 +231,22 @@ impl CharacterWidth {
         //
         // TODO(pcwalton): Find these from the font.
         let average_advance = reference_font_size.scale_by(0.5);
         let max_advance = reference_font_size;
         average_advance.scale_by(self.0 as CSSFloat - 1.0) + max_advance
     }
 }
 
-/// Same as Gecko
-const ABSOLUTE_LENGTH_MAX: i32 = (1 << 30);
-const ABSOLUTE_LENGTH_MIN: i32 = - (1 << 30);
-
 /// Helper to convert a floating point length to application units
 fn to_au_round(length: CSSFloat, au_per_unit: CSSFloat) -> Au {
     Au(
-        (length * au_per_unit)
-        .min(ABSOLUTE_LENGTH_MAX as f32)
-        .max(ABSOLUTE_LENGTH_MIN as f32)
+        ((length * au_per_unit) as f64)
+        .min(MAX_AU.0 as f64)
+        .max(MIN_AU.0 as f64)
         .round() as i32
     )
 }
 
 /// Represents an absolute length with its unit
 #[derive(Clone, Copy, Debug, PartialEq)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub enum AbsoluteLength {