Bug 1316549 Part 2 - Fix assertion failure: aRadiusY > 0 in FloatInfo::XInterceptAtY(). draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 14 Nov 2016 18:11:45 +0800
changeset 442777 0faf4bbbaf1040d971c3f514ae00ebbced93a0df
parent 442776 83328841615b02411bb996258b9bd04792a47e40
child 442778 8c7c0434e1c5f380154abdbf1f0b4b0455c32bcd
push id36803
push userbmo:tlin@mozilla.com
push dateWed, 23 Nov 2016 06:29:01 +0000
bugs1316549
milestone53.0a1
Bug 1316549 Part 2 - Fix assertion failure: aRadiusY > 0 in FloatInfo::XInterceptAtY(). We need to consider the case when only one of the four corner radius is specified. The two reftests are added to test 'border-top-right-radius' and 'border-bottom-right-radius', respectively. MozReview-Commit-ID: De2fXcb6ypP
layout/generic/nsFloatManager.cpp
layout/reftests/w3c-css/submitted/shapes1/reftest.list
layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-005-ref.html
layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-005.html
layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-006-ref.html
layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-006.html
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -709,24 +709,26 @@ nsFloatManager::FloatInfo::ComputeEllips
 
   NS_ASSERTION(aShapeBoxY <= aShapeBoxYMost, "Bad shape box coordinates!");
   NS_ASSERTION(aBandY <= aBandYMost, "Bad band coordinates!");
 
   nscoord xDiff = 0;
 
   // If the band intersects both the top and bottom corners, we don't need
   // to enter either branch because the correct xDiff is 0.
-  if (aBandYMost >= aShapeBoxY &&
+  if (aTopCornerRadiusY > 0 &&
+      aBandYMost >= aShapeBoxY &&
       aBandYMost <= aShapeBoxY + aTopCornerRadiusY) {
     // The band intersects only the top corner.
     nscoord y = aTopCornerRadiusY - (aBandYMost - aShapeBoxY);
     nscoord xIntercept =
       XInterceptAtY(y, aTopCornerRadiusX, aTopCornerRadiusY);
     xDiff = aTopCornerRadiusX - xIntercept;
-  } else if (aBandY >= aShapeBoxYMost - aBottomCornerRadiusY &&
+  } else if (aBottomCornerRadiusY > 0 &&
+             aBandY >= aShapeBoxYMost - aBottomCornerRadiusY &&
              aBandY <= aShapeBoxYMost) {
     // The band intersects only the bottom corner.
     nscoord y = aBottomCornerRadiusY - (aShapeBoxYMost - aBandY);
     nscoord xIntercept =
       XInterceptAtY(y, aBottomCornerRadiusX, aBottomCornerRadiusY);
     xDiff = aBottomCornerRadiusX - xIntercept;
   }
 
--- a/layout/reftests/w3c-css/submitted/shapes1/reftest.list
+++ b/layout/reftests/w3c-css/submitted/shapes1/reftest.list
@@ -10,16 +10,18 @@ default-preferences pref(layout.css.shap
 == shape-outside-content-box-001.html shape-outside-content-box-001-ref.html
 == shape-outside-content-box-002.html shape-outside-content-box-002-ref.html
 
 # <shape-box> with border-radius
 == shape-outside-margin-box-border-radius-001.html shape-outside-margin-box-border-radius-001-ref.html
 fails == shape-outside-margin-box-border-radius-002.html shape-outside-margin-box-border-radius-002-ref.html # Bug 1309830
 == shape-outside-margin-box-border-radius-003.html shape-outside-margin-box-border-radius-003-ref.html
 fails == shape-outside-margin-box-border-radius-004.html shape-outside-margin-box-border-radius-004-ref.html # Bug 1309830
+== shape-outside-margin-box-border-radius-005.html shape-outside-margin-box-border-radius-005-ref.html
+== shape-outside-margin-box-border-radius-006.html shape-outside-margin-box-border-radius-006-ref.html
 == shape-outside-border-box-border-radius-001.html shape-outside-border-box-border-radius-001-ref.html
 fails == shape-outside-border-box-border-radius-002.html shape-outside-border-box-border-radius-002-ref.html # Bug 1309830
 == shape-outside-border-box-border-radius-003.html shape-outside-border-box-border-radius-003-ref.html
 fails == shape-outside-border-box-border-radius-004.html shape-outside-border-box-border-radius-004-ref.html # Bug 1309830
 == shape-outside-padding-box-border-radius-001.html shape-outside-padding-box-border-radius-001-ref.html
 == shape-outside-padding-box-border-radius-002.html shape-outside-padding-box-border-radius-002-ref.html
 == shape-outside-content-box-border-radius-001.html shape-outside-content-box-border-radius-001-ref.html
 == shape-outside-content-box-border-radius-002.html shape-outside-content-box-border-radius-002-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-005-ref.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <meta charset="utf-8">
+  <title>CSS Shape Test: float left, margin-box, border-top-right-radius reference</title>
+  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="http://www.mozilla.org/">
+  <style>
+  .container {
+    position: absolute;
+    width: 200px;
+    line-height: 0;
+  }
+
+  .shape {
+    float: left;
+    /* Omit shape-outside: margin-box; */
+    border-top-right-radius: 50%;
+    box-sizing: content-box;
+    height: 20px;
+    width: 20px;
+    padding: 20px;
+    border: 20px solid lightgreen;
+    margin: 10px;
+    background-color: orange;
+  }
+
+  .box {
+    position: absolute;
+    width: 60px;
+    background-color: blue;
+  }
+  </style>
+
+  <body class="container">
+    <div class="shape"></div>
+    <div class="box" style="height: 12px; top: 0px; left: 96px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px; top: 12px; left: 108px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 36px; top: 24px; left: 120px;"></div>
+    <div class="box" style="height: 36px; top: 60px; left: 120px;"></div>
+    <div class="box" style="height: 12px; top: 96px; left: 120px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px; top: 108px; left: 120px;"></div> <!-- Box at corner -->
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-005.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <meta charset="utf-8">
+  <title>CSS Shape Test: float left, margin-box, border-top-right-radius</title>
+  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="http://www.mozilla.org/">
+  <link rel="help" href="https://drafts.csswg.org/css-shapes-1/#shapes-from-box-values">
+  <link rel="match" href="shape-outside-margin-box-border-radius-005-ref.html">
+  <meta name="flags" content="">
+  <meta name="assert" content="Test the boxes are wrapping around the left float shape defined by the margin-box and border-top-right-radius value.">
+  <style>
+  .container {
+    width: 200px;
+    line-height: 0;
+  }
+
+  .shape {
+    float: left;
+    shape-outside: margin-box;
+    border-top-right-radius: 50%;
+    box-sizing: content-box;
+    height: 20px;
+    width: 20px;
+    padding: 20px;
+    border: 20px solid lightgreen;
+    margin: 10px;
+    background-color: orange;
+  }
+
+  .box {
+    display: inline-block;
+    width: 60px;
+    background-color: blue;
+  }
+  </style>
+
+  <body class="container">
+    <div class="shape"></div>
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 36px;"></div>
+    <div class="box" style="height: 36px;"></div>
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-006-ref.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <meta charset="utf-8">
+  <title>CSS Shape Test: float left, margin-box, border-bottom-right-radius reference</title>
+  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="http://www.mozilla.org/">
+  <style>
+  .container {
+    position: absolute;
+    width: 200px;
+    line-height: 0;
+  }
+
+  .shape {
+    float: left;
+    /* Omit shape-outside: margin-box; */
+    border-bottom-right-radius: 50%;
+    box-sizing: content-box;
+    height: 20px;
+    width: 20px;
+    padding: 20px;
+    border: 20px solid lightgreen;
+    margin: 10px;
+    background-color: orange;
+  }
+
+  .box {
+    position: absolute;
+    width: 60px;
+    background-color: blue;
+  }
+  </style>
+
+  <body class="container">
+    <div class="shape"></div>
+    <div class="box" style="height: 12px; top: 0px; left: 120px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px; top: 12px; left: 120px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 36px; top: 24px; left: 120px;"></div>
+    <div class="box" style="height: 36px; top: 60px; left: 120px;"></div>
+    <div class="box" style="height: 12px; top: 96px; left: 108px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px; top: 108px; left: 96px;"></div> <!-- Box at corner -->
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/shapes1/shape-outside-margin-box-border-radius-006.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <meta charset="utf-8">
+  <title>CSS Shape Test: float left, margin-box, border-bottom-right-radius</title>
+  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="http://www.mozilla.org/">
+  <link rel="help" href="https://drafts.csswg.org/css-shapes-1/#shapes-from-box-values">
+  <link rel="match" href="shape-outside-margin-box-border-radius-006-ref.html">
+  <meta name="flags" content="">
+  <meta name="assert" content="Test the boxes are wrapping around the left float shape defined by the margin-box and border-bottom-right-radius value.">
+  <style>
+  .container {
+    width: 200px;
+    line-height: 0;
+  }
+
+  .shape {
+    float: left;
+    shape-outside: margin-box;
+    border-bottom-right-radius: 50%;
+    box-sizing: content-box;
+    height: 20px;
+    width: 20px;
+    padding: 20px;
+    border: 20px solid lightgreen;
+    margin: 10px;
+    background-color: orange;
+  }
+
+  .box {
+    display: inline-block;
+    width: 60px;
+    background-color: blue;
+  }
+  </style>
+
+  <body class="container">
+    <div class="shape"></div>
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 36px;"></div>
+    <div class="box" style="height: 36px;"></div>
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+    <div class="box" style="height: 12px;"></div> <!-- Box at corner -->
+  </body>
+</html>