Bug 1265342 Part 5d: Move EllipseShapeInfo class definition ahead of RoundedBoxShapeInfo so it can be referenced by rounded boxes. draft
authorBrad Werth <bwerth@mozilla.com>
Tue, 17 Apr 2018 11:59:11 -0700
changeset 787953 c898ec3dddef1c061a7b5f79714f085f10726e06
parent 787952 1bae7f3258cfcaa20ad46f814117be746eb22316
child 787954 70a84de16cc8a89ffa4256dc6485d24df3f28afe
push id107854
push userbwerth@mozilla.com
push dateWed, 25 Apr 2018 18:14:35 +0000
bugs1265342
milestone61.0a1
Bug 1265342 Part 5d: Move EllipseShapeInfo class definition ahead of RoundedBoxShapeInfo so it can be referenced by rounded boxes. MozReview-Commit-ID: G8qdPlnh8kY
layout/generic/nsFloatManager.cpp
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -631,87 +631,16 @@ protected:
   // on increasing y values. This function uses a binary search to find the
   // first interval that contains aTargetY. If no such interval exists, this
   // function returns aIntervals.Length().
   static size_t MinIntervalIndexContainingY(const nsTArray<nsRect>& aIntervals,
                                             const nscoord aTargetY);
 };
 
 /////////////////////////////////////////////////////////////////////////////
-// RoundedBoxShapeInfo
-//
-// Implements shape-outside: <shape-box> and shape-outside: inset().
-//
-class nsFloatManager::RoundedBoxShapeInfo final : public nsFloatManager::ShapeInfo
-{
-public:
-  RoundedBoxShapeInfo(const nsRect& aRect,
-                      UniquePtr<nscoord[]> aRadii)
-    : mRect(aRect)
-    , mRadii(Move(aRadii))
-  {}
-
-  nscoord LineLeft(const nscoord aBStart,
-                   const nscoord aBEnd) const override;
-  nscoord LineRight(const nscoord aBStart,
-                    const nscoord aBEnd) const override;
-  nscoord BStart() const override { return mRect.y; }
-  nscoord BEnd() const override { return mRect.YMost(); }
-  bool IsEmpty() const override { return mRect.IsEmpty(); };
-
-  void Translate(nscoord aLineLeft, nscoord aBlockStart) override
-  {
-    mRect.MoveBy(aLineLeft, aBlockStart);
-  }
-
-private:
-  // The rect of the rounded box shape in the float manager's coordinate
-  // space.
-  nsRect mRect;
-  // The half corner radii of the reference box. It's an nscoord[8] array
-  // in the float manager's coordinate space. If there are no radii, it's
-  // nullptr.
-  UniquePtr<nscoord[]> mRadii;
-};
-
-nscoord
-nsFloatManager::RoundedBoxShapeInfo::LineLeft(const nscoord aBStart,
-                                              const nscoord aBEnd) const
-{
-  if (!mRadii) {
-    return mRect.x;
-  }
-
-  nscoord lineLeftDiff =
-    ComputeEllipseLineInterceptDiff(
-      mRect.y, mRect.YMost(),
-      mRadii[eCornerTopLeftX], mRadii[eCornerTopLeftY],
-      mRadii[eCornerBottomLeftX], mRadii[eCornerBottomLeftY],
-      aBStart, aBEnd);
-  return mRect.x + lineLeftDiff;
-}
-
-nscoord
-nsFloatManager::RoundedBoxShapeInfo::LineRight(const nscoord aBStart,
-                                               const nscoord aBEnd) const
-{
-  if (!mRadii) {
-    return mRect.XMost();
-  }
-
-  nscoord lineRightDiff =
-    ComputeEllipseLineInterceptDiff(
-      mRect.y, mRect.YMost(),
-      mRadii[eCornerTopRightX], mRadii[eCornerTopRightY],
-      mRadii[eCornerBottomRightX], mRadii[eCornerBottomRightY],
-      aBStart, aBEnd);
-  return mRect.XMost() - lineRightDiff;
-}
-
-/////////////////////////////////////////////////////////////////////////////
 // EllipseShapeInfo
 //
 // Implements shape-outside: circle() and shape-outside: ellipse().
 //
 class nsFloatManager::EllipseShapeInfo final : public nsFloatManager::ShapeInfo
 {
 public:
   // Construct the float area using math to calculate the shape boundary.
@@ -1069,16 +998,87 @@ nsFloatManager::EllipseShapeInfo::LineLe
 nscoord
 nsFloatManager::EllipseShapeInfo::LineRight(const nscoord aBStart,
                                             const nscoord aBEnd) const
 {
   return LineEdge(aBStart, aBEnd, false);
 }
 
 /////////////////////////////////////////////////////////////////////////////
+// RoundedBoxShapeInfo
+//
+// Implements shape-outside: <shape-box> and shape-outside: inset().
+//
+class nsFloatManager::RoundedBoxShapeInfo final : public nsFloatManager::ShapeInfo
+{
+public:
+  RoundedBoxShapeInfo(const nsRect& aRect,
+                      UniquePtr<nscoord[]> aRadii)
+    : mRect(aRect)
+    , mRadii(Move(aRadii))
+  {}
+
+  nscoord LineLeft(const nscoord aBStart,
+                   const nscoord aBEnd) const override;
+  nscoord LineRight(const nscoord aBStart,
+                    const nscoord aBEnd) const override;
+  nscoord BStart() const override { return mRect.y; }
+  nscoord BEnd() const override { return mRect.YMost(); }
+  bool IsEmpty() const override { return mRect.IsEmpty(); };
+
+  void Translate(nscoord aLineLeft, nscoord aBlockStart) override
+  {
+    mRect.MoveBy(aLineLeft, aBlockStart);
+  }
+
+private:
+  // The rect of the rounded box shape in the float manager's coordinate
+  // space.
+  nsRect mRect;
+  // The half corner radii of the reference box. It's an nscoord[8] array
+  // in the float manager's coordinate space. If there are no radii, it's
+  // nullptr.
+  UniquePtr<nscoord[]> mRadii;
+};
+
+nscoord
+nsFloatManager::RoundedBoxShapeInfo::LineLeft(const nscoord aBStart,
+                                              const nscoord aBEnd) const
+{
+  if (!mRadii) {
+    return mRect.x;
+  }
+
+  nscoord lineLeftDiff =
+    ComputeEllipseLineInterceptDiff(
+      mRect.y, mRect.YMost(),
+      mRadii[eCornerTopLeftX], mRadii[eCornerTopLeftY],
+      mRadii[eCornerBottomLeftX], mRadii[eCornerBottomLeftY],
+      aBStart, aBEnd);
+  return mRect.x + lineLeftDiff;
+}
+
+nscoord
+nsFloatManager::RoundedBoxShapeInfo::LineRight(const nscoord aBStart,
+                                               const nscoord aBEnd) const
+{
+  if (!mRadii) {
+    return mRect.XMost();
+  }
+
+  nscoord lineRightDiff =
+    ComputeEllipseLineInterceptDiff(
+      mRect.y, mRect.YMost(),
+      mRadii[eCornerTopRightX], mRadii[eCornerTopRightY],
+      mRadii[eCornerBottomRightX], mRadii[eCornerBottomRightY],
+      aBStart, aBEnd);
+  return mRect.XMost() - lineRightDiff;
+}
+
+/////////////////////////////////////////////////////////////////////////////
 // PolygonShapeInfo
 //
 // Implements shape-outside: polygon().
 //
 class nsFloatManager::PolygonShapeInfo final : public nsFloatManager::ShapeInfo
 {
 public:
   explicit PolygonShapeInfo(nsTArray<nsPoint>&& aVertices);