Bug 1265342 Part 5d: Move EllipseShapeInfo class definition ahead of RoundedBoxShapeInfo so it can be referenced by rounded boxes. r=dholbert

MozReview-Commit-ID: G8qdPlnh8kY

--HG--
extra : rebase_source : 2917054937f488c601394f1d244151c9c3df7596
This commit is contained in:
Brad Werth 2018-04-17 11:59:11 -07:00
Родитель eb8a0661ae
Коммит b935ad1265
1 изменённых файлов: 71 добавлений и 71 удалений

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

@ -635,77 +635,6 @@ protected:
const nscoord aTargetY); 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 // EllipseShapeInfo
// //
@ -1073,6 +1002,77 @@ nsFloatManager::EllipseShapeInfo::LineRight(const nscoord aBStart,
return LineEdge(aBStart, aBEnd, false); 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 // PolygonShapeInfo
// //