Commit 85910977 authored by Ting-Yu Lin's avatar Ting-Yu Lin
Browse files

Bug 1326407 Part 7 - Rename BoxShapeInfo to RoundedBoxShapeInfo. r=dbaron

The radii has been cached in the BoxShapeInfo in the previous part. Hence
the rename.

This class will be used to implement inset() in the next part, so the rect
stored isn't necessarily the rect of the <shape-box>. It could be the inset
rectangle. Therefore I rename mShapeBoxRect to mRect to avoid any confusion.

MozReview-Commit-ID: J0hpQDsbMyN

--HG--
extra : rebase_source : 76cf50e1819a586199934c29f46d467a1b86a9ec
parent 784cc9ae
Loading
Loading
Loading
Loading
+18 −17
Original line number Diff line number Diff line
@@ -529,42 +529,42 @@ nsFloatManager::ClearContinues(StyleClear aBreakType) const
}

/////////////////////////////////////////////////////////////////////////////
// BoxShapeInfo
// RoundedBoxShapeInfo

nscoord
nsFloatManager::BoxShapeInfo::LineLeft(WritingMode aWM,
nsFloatManager::RoundedBoxShapeInfo::LineLeft(WritingMode aWM,
                                              const nscoord aBStart,
                                              const nscoord aBEnd) const
{
  if (!mRadii) {
    return mShapeBoxRect.x;
    return mRect.x;
  }

  nscoord lineLeftDiff =
    ComputeEllipseLineInterceptDiff(
      mShapeBoxRect.y, mShapeBoxRect.YMost(),
      mRect.y, mRect.YMost(),
      mRadii[eCornerTopLeftX], mRadii[eCornerTopLeftY],
      mRadii[eCornerBottomLeftX], mRadii[eCornerBottomLeftY],
      aBStart, aBEnd);
  return mShapeBoxRect.x + lineLeftDiff;
  return mRect.x + lineLeftDiff;
}

nscoord
nsFloatManager::BoxShapeInfo::LineRight(WritingMode aWM,
nsFloatManager::RoundedBoxShapeInfo::LineRight(WritingMode aWM,
                                               const nscoord aBStart,
                                               const nscoord aBEnd) const
{
  if (!mRadii) {
    return mShapeBoxRect.XMost();
    return mRect.XMost();
  }

  nscoord lineRightDiff =
    ComputeEllipseLineInterceptDiff(
      mShapeBoxRect.y, mShapeBoxRect.YMost(),
      mRect.y, mRect.YMost(),
      mRadii[eCornerTopRightX], mRadii[eCornerTopRightY],
      mRadii[eCornerBottomRightX], mRadii[eCornerBottomRightY],
      aBStart, aBEnd);
  return mShapeBoxRect.XMost() - lineRightDiff;
  return mRect.XMost() - lineRightDiff;
}

/////////////////////////////////////////////////////////////////////////////
@@ -806,12 +806,13 @@ nsFloatManager::ShapeInfo::CreateShapeBox(
  nscoord physicalRadii[8];
  bool hasRadii = aFrame->GetShapeBoxBorderRadii(physicalRadii);
  if (!hasRadii) {
    return MakeUnique<BoxShapeInfo>(logicalShapeBoxRect,
    return MakeUnique<RoundedBoxShapeInfo>(logicalShapeBoxRect,
                                           UniquePtr<nscoord[]>());
  }

  return MakeUnique<BoxShapeInfo>(logicalShapeBoxRect,
                                  ConvertToFloatLogical(physicalRadii, aWM));
  return MakeUnique<RoundedBoxShapeInfo>(logicalShapeBoxRect,
                                         ConvertToFloatLogical(physicalRadii,
                                                               aWM));
}

/* static */ UniquePtr<nsFloatManager::ShapeInfo>
+11 −12
Original line number Diff line number Diff line
@@ -421,12 +421,12 @@ private:
  };

  // Implements shape-outside: <shape-box>.
  class BoxShapeInfo final : public ShapeInfo
  class RoundedBoxShapeInfo final : public ShapeInfo
  {
  public:
    BoxShapeInfo(const nsRect& aShapeBoxRect,
    RoundedBoxShapeInfo(const nsRect& aRect,
                        mozilla::UniquePtr<nscoord[]> aRadii)
      : mShapeBoxRect(aShapeBoxRect)
      : mRect(aRect)
      , mRadii(Move(aRadii))
    {}

@@ -436,20 +436,19 @@ private:
    nscoord LineRight(mozilla::WritingMode aWM,
                      const nscoord aBStart,
                      const nscoord aBEnd) const override;
    nscoord BStart() const override { return mShapeBoxRect.y; }
    nscoord BEnd() const override { return mShapeBoxRect.YMost(); }
    bool IsEmpty() const override { return mShapeBoxRect.IsEmpty(); };
    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
    {
      mShapeBoxRect.MoveBy(aLineLeft, aBlockStart);
      mRect.MoveBy(aLineLeft, aBlockStart);
    }

  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 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.