Bug 1265342 Part 7: Implement shape-margin for shape-outside: shape-box.
MozReview-Commit-ID: 67vq9Gcr8qJ
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -548,16 +548,17 @@ public:
const nsSize& aContainerSize)
{
return nsRect(aRect.LineLeft(aWM, aContainerSize), aRect.BStart(aWM),
aRect.ISize(aWM), aRect.BSize(aWM));
}
static UniquePtr<ShapeInfo> CreateShapeBox(
nsIFrame* const aFrame,
+ nscoord aShapeMargin,
const LogicalRect& aShapeBoxRect,
WritingMode aWM,
const nsSize& aContainerSize);
static UniquePtr<ShapeInfo> CreateBasicShape(
const UniquePtr<StyleBasicShape>& aBasicShape,
nscoord aShapeMargin,
const LogicalRect& aShapeBoxRect,
@@ -1495,20 +1496,24 @@ nsFloatManager::FloatInfo::FloatInfo(nsI
// Image is not ready, or fails to load, etc.
return;
}
break;
}
case StyleShapeSourceType::Box: {
+ nscoord shapeMargin =
+ ::ResolveToDefiniteSize(mFrame->StyleDisplay()->mShapeMargin,
+ aContainerSize.width);
// Initialize <shape-box>'s reference rect.
LogicalRect shapeBoxRect =
ShapeInfo::ComputeShapeBoxRect(shapeOutside, mFrame, aMarginRect, aWM);
- mShapeInfo = ShapeInfo::CreateShapeBox(mFrame, shapeBoxRect, aWM,
+ mShapeInfo = ShapeInfo::CreateShapeBox(mFrame, shapeMargin,
+ shapeBoxRect, aWM,
aContainerSize);
break;
}
case StyleShapeSourceType::Shape: {
const UniquePtr<StyleBasicShape>& basicShape = shapeOutside.GetBasicShape();
nscoord shapeMargin =
::ResolveToDefiniteSize(mFrame->StyleDisplay()->mShapeMargin,
@@ -1661,30 +1666,36 @@ nsFloatManager::ShapeInfo::ComputeShapeB
}
return rect;
}
/* static */ UniquePtr<nsFloatManager::ShapeInfo>
nsFloatManager::ShapeInfo::CreateShapeBox(
nsIFrame* const aFrame,
+ nscoord aShapeMargin,
const LogicalRect& aShapeBoxRect,
WritingMode aWM,
const nsSize& aContainerSize)
{
nsRect logicalShapeBoxRect
= ConvertToFloatLogical(aShapeBoxRect, aWM, aContainerSize);
nscoord physicalRadii[8];
bool hasRadii = aFrame->GetShapeBoxBorderRadii(physicalRadii);
- if (!hasRadii) {
+ if (!hasRadii && aShapeMargin <= 0) {
return MakeUnique<RoundedBoxShapeInfo>(logicalShapeBoxRect,
UniquePtr<nscoord[]>());
}
+ // Add aShapeMargin to each of the radii.
+ for (int32_t i = 0; i < 8; ++i) {
+ physicalRadii[i] += aShapeMargin;
+ }
+
return MakeUnique<RoundedBoxShapeInfo>(logicalShapeBoxRect,
ConvertToFloatLogical(physicalRadii,
aWM));
}
/* static */ UniquePtr<nsFloatManager::ShapeInfo>
nsFloatManager::ShapeInfo::CreateBasicShape(
const UniquePtr<StyleBasicShape>& aBasicShape,