Bug 1531025 part 2: Skip an unnecessary border-radius calculation if the radii are 0 (to avoid division by 0). r=boris
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 04 Mar 2019 19:24:01 +0000
changeset 520172 bfb349870bbfec611db4ca53391bdf61df15992b
parent 520171 818af1db79a228cc7709fd82eabe417e521259d1
child 520173 341088b5783b543852906cc7c7b87e0a78b64732
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1531025
milestone67.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 1531025 part 2: Skip an unnecessary border-radius calculation if the radii are 0 (to avoid division by 0). r=boris This patch avoids a potential division by 0 (one that's unlikely to be triggered by real content), for correctness and robustness. This patch isn't really changing the logic, because the newly-guarded code is already guarded by a "length < sum" check, and "length" is expected to be nonnegative [1], which means "sum" would already have been nonzero in cases where the existing strict less-than comparison returned true. [1] One special case where we can have negative `length` values here: if this is an outline with an `outline-offset` that is sufficiently negative to entirely cancel out the outlined element's border-box size, then that can produce a negative `length` (i.e. the outline box will have a negative size, conceptually). In that scenario, we were previously dividing by 0 here and working with bogus huge/infinite negative values as a result, but we should not do that. Depends on D21578 Differential Revision: https://phabricator.services.mozilla.com/D21579
layout/generic/nsFrame.cpp
testing/web-platform/meta/css/css-ui/outline-013.html.ini
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1710,21 +1710,20 @@ bool nsIFrame::ComputeBorderRadii(const 
   NS_FOR_CSS_SIDES(side) {
     uint32_t hc1 = SideToHalfCorner(side, false, true);
     uint32_t hc2 = SideToHalfCorner(side, true, true);
     nscoord length =
         SideIsVertical(side) ? aBorderArea.height : aBorderArea.width;
     nscoord sum = aRadii[hc1] + aRadii[hc2];
     if (sum) {
       haveRadius = true;
-    }
-
-    // avoid floating point division in the normal case
-    if (length < sum) {
-      ratio = std::min(ratio, double(length) / sum);
+      // avoid floating point division in the normal case
+      if (length < sum) {
+        ratio = std::min(ratio, double(length) / sum);
+      }
     }
   }
   if (ratio < 1.0) {
     NS_FOR_CSS_HALF_CORNERS(corner) { aRadii[corner] *= ratio; }
   }
 
   return haveRadius;
 }
--- a/testing/web-platform/meta/css/css-ui/outline-013.html.ini
+++ b/testing/web-platform/meta/css/css-ui/outline-013.html.ini
@@ -1,3 +1,2 @@
 [outline-013.html]
-  expected:
-    if webrender: FAIL
+  expected: FAIL