Bug 1397439 - stylo: Use saturating subtraction for script level; r?emilio draft
authorManish Goregaokar <manishearth@gmail.com>
Wed, 06 Sep 2017 14:49:09 -0700
changeset 660324 fc72174d6bcc6abee0e4f69f8bb7a381384469c2
parent 660316 b4677739a11d65da60eb6ae412d78cdb1e7115f5
child 730215 c8dd2a39503f32f6e850a6c11778a5fa9ca81186
push id78379
push userbmo:manishearth@gmail.com
push dateWed, 06 Sep 2017 21:55:33 +0000
reviewersemilio
bugs1397439
milestone57.0a1
Bug 1397439 - stylo: Use saturating subtraction for script level; r?emilio MozReview-Commit-ID: 3OBc1f4k9Ru
layout/style/crashtests/1397439-1.html
layout/style/crashtests/crashtests.list
servo/components/style/properties/gecko.mako.rs
new file mode 100644
--- /dev/null
+++ b/layout/style/crashtests/1397439-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<math>
+<mstyle scriptlevel=101>
+<mstyle scriptlevel=-204>
+</math>
+
--- a/layout/style/crashtests/crashtests.list
+++ b/layout/style/crashtests/crashtests.list
@@ -208,8 +208,9 @@ 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
+load 1397439-1.html
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -2355,17 +2355,17 @@ fn static_assert() {
     /// unconstrained size are set to the explicit value. However, if the font
     /// size is manually set to an em or percent unit, the unconstrained size
     /// will be set to the value of that unit computed against the parent
     /// unconstrained size, whereas the font size will be set computing against
     /// the parent font size.
     pub fn calculate_script_level_size(&self, parent: &Self, device: &Device) -> (Au, Au) {
         use std::cmp;
 
-        let delta = self.gecko.mScriptLevel - parent.gecko.mScriptLevel;
+        let delta = self.gecko.mScriptLevel.saturating_sub(parent.gecko.mScriptLevel);
 
         let parent_size = Au(parent.gecko.mSize);
         let parent_unconstrained_size = Au(parent.gecko.mScriptUnconstrainedSize);
 
         if delta == 0 {
             return (parent_size, parent_unconstrained_size)
         }