Bug 1326406 Part 6 - Make CircleShapeInfo inherit from EllipseShapeInfo. r=dbaron

MozReview-Commit-ID: H0UgT6P6c7K

--HG--
extra : rebase_source : c78b150708644baf09dcd182659eeeb108f6f7da
This commit is contained in:
Ting-Yu Lin 2017-01-23 17:19:32 +08:00
Родитель 0807932a97
Коммит 587b378e1d
2 изменённых файлов: 17 добавлений и 60 удалений

Просмотреть файл

@ -629,35 +629,12 @@ nsFloatManager::CircleShapeInfo::CircleShapeInfo(
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

Просмотреть файл

@ -420,40 +420,8 @@ private:
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,
@ -476,7 +444,9 @@ private:
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;
@ -485,6 +455,16 @@ private:
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