Bug 1326406 Part 6 - Make CircleShapeInfo inherit from EllipseShapeInfo. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 23 Jan 2017 17:19:32 +0800
changeset 466057 6b6143aa3b716849a896367702ad01388f555bdb
parent 466056 3063178e7620c724e2d38d6141100162f291f416
child 543301 bb0d93a337a45c7c955dc872d728712994f068c6
push id42771
push userbmo:tlin@mozilla.com
push dateWed, 25 Jan 2017 05:31:10 +0000
bugs1326406
milestone54.0a1
Bug 1326406 Part 6 - Make CircleShapeInfo inherit from EllipseShapeInfo. MozReview-Commit-ID: H0UgT6P6c7K
layout/generic/nsFloatManager.cpp
layout/generic/nsFloatManager.h
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -624,45 +624,22 @@ nsFloatManager::CircleShapeInfo::CircleS
 {
   // Use physical coordinates to compute the center of the circle() since
   // the <position> keywords such as 'left', 'top', etc. are physical.
   // https://drafts.csswg.org/css-shapes-1/#funcdef-circle
   nsRect physicalShapeBoxRect =
     aShapeBoxRect.GetPhysicalRect(aWM, aContainerSize);
   nsPoint physicalCenter =
     ShapeUtils::ComputeCircleOrEllipseCenter(aBasicShape, physicalShapeBoxRect);
-  mRadius = ShapeUtils::ComputeCircleRadius(aBasicShape, physicalCenter,
-                                            physicalShapeBoxRect);
+  nscoord radius = ShapeUtils::ComputeCircleRadius(aBasicShape, physicalCenter,
+                                                   physicalShapeBoxRect);
+  mRadii = nsSize(radius, radius);
   mCenter = ConvertPhysicalToLogical(aWM, physicalCenter, aContainerSize);
 }
 
-nscoord
-nsFloatManager::CircleShapeInfo::LineLeft(WritingMode aWM,
-                                          const nscoord aBStart,
-                                          const nscoord aBEnd) const
-{
-  nscoord lineLeftDiff =
-    ComputeEllipseLineInterceptDiff(BStart(), BEnd(),
-                                    mRadius, mRadius, mRadius, mRadius,
-                                    aBStart, aBEnd);
-  return mCenter.x - mRadius + lineLeftDiff;
-}
-
-nscoord
-nsFloatManager::CircleShapeInfo::LineRight(WritingMode aWM,
-                                           const nscoord aBStart,
-                                           const nscoord aBEnd) const
-{
-  nscoord lineRightDiff =
-    ComputeEllipseLineInterceptDiff(BStart(), BEnd(),
-                                    mRadius, mRadius, mRadius, mRadius,
-                                    aBStart, aBEnd);
-  return mCenter.x + mRadius - lineRightDiff;
-}
-
 /////////////////////////////////////////////////////////////////////////////
 // EllipseShapeInfo
 
 nsFloatManager::EllipseShapeInfo::EllipseShapeInfo(
   StyleBasicShape* const aBasicShape,
   const LogicalRect& aShapeBoxRect,
   WritingMode aWM,
   const nsSize& aContainerSize)
--- a/layout/generic/nsFloatManager.h
+++ b/layout/generic/nsFloatManager.h
@@ -415,50 +415,18 @@ private:
     // This is the reference box of css shape-outside if specified, which
     // implements the <shape-box> value in the CSS Shapes Module Level 1.
     // The coordinate space is the same as FloatInfo::mRect.
     nsRect mShapeBoxRect;
     // The frame of the float.
     nsIFrame* const mFrame;
   };
 
-  // Implements shape-outside: circle().
-  class CircleShapeInfo final : public ShapeInfo
-  {
-  public:
-    CircleShapeInfo(mozilla::StyleBasicShape* const aBasicShape,
-                    const mozilla::LogicalRect& aShapeBoxRect,
-                    mozilla::WritingMode aWM,
-                    const nsSize& aContainerSize);
-
-    nscoord LineLeft(mozilla::WritingMode aWM,
-                     const nscoord aBStart,
-                     const nscoord aBEnd) const override;
-    nscoord LineRight(mozilla::WritingMode aWM,
-                      const nscoord aBStart,
-                      const nscoord aBEnd) const override;
-    nscoord BStart() const override { return mCenter.y - mRadius; }
-    nscoord BEnd() const override { return mCenter.y + mRadius; }
-    bool IsEmpty() const override { return mRadius == 0; };
-
-    void Translate(nscoord aLineLeft, nscoord aBlockStart) override
-    {
-      mCenter.MoveBy(aLineLeft, aBlockStart);
-    }
-
-  private:
-    // The position of the center of the circle. The coordinate space is the
-    // same as FloatInfo::mRect.
-    nsPoint mCenter;
-    // The radius of the circle in app units.
-    nscoord mRadius;
-  };
-
   // Implements shape-outside: ellipse().
-  class EllipseShapeInfo final : public ShapeInfo
+  class EllipseShapeInfo : public ShapeInfo
   {
   public:
     EllipseShapeInfo(mozilla::StyleBasicShape* const aBasicShape,
                      const mozilla::LogicalRect& aShapeBoxRect,
                      mozilla::WritingMode aWM,
                      const nsSize& aContainerSize);
 
     nscoord LineLeft(mozilla::WritingMode aWM,
@@ -471,25 +439,37 @@ private:
     nscoord BEnd() const override { return mCenter.y + mRadii.height; }
     bool IsEmpty() const override { return mRadii.IsEmpty(); };
 
     void Translate(nscoord aLineLeft, nscoord aBlockStart) override
     {
       mCenter.MoveBy(aLineLeft, aBlockStart);
     }
 
-  private:
+  protected:
+    EllipseShapeInfo() = default;
+
     // The position of the center of the ellipse. The coordinate space is the
     // same as FloatInfo::mRect.
     nsPoint mCenter;
     // The radii of the ellipse in app units. The width and height represent
     // the line-axis and block-axis radii of the ellipse.
     nsSize mRadii;
   };
 
+  // Implements shape-outside: circle().
+  class CircleShapeInfo final : public EllipseShapeInfo
+  {
+  public:
+    CircleShapeInfo(mozilla::StyleBasicShape* const aBasicShape,
+                    const mozilla::LogicalRect& aShapeBoxRect,
+                    mozilla::WritingMode aWM,
+                    const nsSize& aContainerSize);
+  };
+
   struct FloatInfo {
     nsIFrame *const mFrame;
     // The lowest block-ends of left/right floats up to and including
     // this one.
     nscoord mLeftBEnd, mRightBEnd;
 
     FloatInfo(nsIFrame* aFrame, nscoord aLineLeft, nscoord aBlockStart,
               const mozilla::LogicalRect& aMarginRect,