зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1326406
Part 3 - Add ShapeInfo::Translate() for moving the origin of ShapeInfo. r=dbaron
Instead of manually adding (aLineLeft, aBlockStart) when creating a shape, add Translate() to let the shapes implement their only way to move their origin. FloatInfo could then move the shapes after they're created. MozReview-Commit-ID: ApZBHnkng74 --HG-- extra : rebase_source : 10da425372e4e26b0da506059befc99e1c47a39d
This commit is contained in:
Родитель
287eecf10f
Коммит
3cda6f7ed5
|
@ -618,8 +618,6 @@ nsFloatManager::BoxShapeInfo::LineRight(WritingMode aWM,
|
|||
|
||||
nsFloatManager::CircleShapeInfo::CircleShapeInfo(
|
||||
StyleBasicShape* const aBasicShape,
|
||||
nscoord aLineLeft,
|
||||
nscoord aBlockStart,
|
||||
const LogicalRect& aShapeBoxRect,
|
||||
WritingMode aWM,
|
||||
const nsSize& aContainerSize)
|
||||
|
@ -639,8 +637,8 @@ nsFloatManager::CircleShapeInfo::CircleShapeInfo(
|
|||
// mCenter.x is in the line-axis of the frame manager and mCenter.y are in
|
||||
// the frame manager's real block-axis.
|
||||
LogicalPoint logicalCenter(aWM, physicalCenter, aContainerSize);
|
||||
mCenter = nsPoint(logicalCenter.LineRelative(aWM, aContainerSize) + aLineLeft,
|
||||
logicalCenter.B(aWM) + aBlockStart);
|
||||
mCenter = nsPoint(logicalCenter.LineRelative(aWM, aContainerSize),
|
||||
logicalCenter.B(aWM));
|
||||
}
|
||||
|
||||
nscoord
|
||||
|
@ -719,20 +717,22 @@ nsFloatManager::FloatInfo::FloatInfo(nsIFrame* aFrame,
|
|||
}
|
||||
|
||||
if (shapeOutside.GetType() == StyleShapeSourceType::Box) {
|
||||
nsRect shapeBoxRect(rect.LineLeft(aWM, aContainerSize) + aLineLeft,
|
||||
rect.BStart(aWM) + aBlockStart,
|
||||
nsRect shapeBoxRect(rect.LineLeft(aWM, aContainerSize), rect.BStart(aWM),
|
||||
rect.ISize(aWM), rect.BSize(aWM));
|
||||
mShapeInfo = MakeUnique<BoxShapeInfo>(shapeBoxRect, mFrame);
|
||||
} else if (shapeOutside.GetType() == StyleShapeSourceType::Shape) {
|
||||
StyleBasicShape* const basicShape = shapeOutside.GetBasicShape();
|
||||
|
||||
if (basicShape->GetShapeType() == StyleBasicShapeType::Circle) {
|
||||
mShapeInfo = MakeUnique<CircleShapeInfo>(basicShape, aLineLeft, aBlockStart,
|
||||
rect, aWM, aContainerSize);
|
||||
mShapeInfo =
|
||||
MakeUnique<CircleShapeInfo>(basicShape, rect, aWM, aContainerSize);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown StyleShapeSourceType!");
|
||||
}
|
||||
|
||||
// Translate the shape to the same origin as nsFloatManager.
|
||||
mShapeInfo->Translate(aLineLeft, aBlockStart);
|
||||
}
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
|
|
|
@ -352,6 +352,9 @@ private:
|
|||
virtual nscoord BEnd() const = 0;
|
||||
virtual bool IsEmpty() const = 0;
|
||||
|
||||
// Translate the current origin by the specified offsets.
|
||||
virtual void Translate(nscoord aLineLeft, nscoord aBlockStart) = 0;
|
||||
|
||||
protected:
|
||||
// Compute the minimum line-axis difference between the bounding shape
|
||||
// box and its rounded corner within the given band (block-axis region).
|
||||
|
@ -391,11 +394,16 @@ private:
|
|||
nscoord BEnd() const override { return mShapeBoxRect.YMost(); }
|
||||
bool IsEmpty() const override { return mShapeBoxRect.IsEmpty(); };
|
||||
|
||||
void Translate(nscoord aLineLeft, nscoord aBlockStart) override
|
||||
{
|
||||
mShapeBoxRect.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.
|
||||
const nsRect mShapeBoxRect;
|
||||
nsRect mShapeBoxRect;
|
||||
// The frame of the float.
|
||||
nsIFrame* const mFrame;
|
||||
};
|
||||
|
@ -405,8 +413,6 @@ private:
|
|||
{
|
||||
public:
|
||||
CircleShapeInfo(mozilla::StyleBasicShape* const aBasicShape,
|
||||
nscoord aLineLeft,
|
||||
nscoord aBlockStart,
|
||||
const mozilla::LogicalRect& aShapeBoxRect,
|
||||
mozilla::WritingMode aWM,
|
||||
const nsSize& aContainerSize);
|
||||
|
@ -421,6 +427,11 @@ private:
|
|||
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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче