--- 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,
nsIFrame* const aFrame,
@@ -1949,30 +1950,33 @@ nsFloatManager::FloatInfo::FloatInfo(nsI
// margin box.
// https://drafts.csswg.org/css-shapes/#relation-to-box-model-and-float-behavior
return;
}
const StyleShapeSource& shapeOutside = mFrame->StyleDisplay()->mShapeOutside;
+ nscoord shapeMargin = (shapeOutside.GetType() == StyleShapeSourceType::None)
+ ? 0
+ : nsLayoutUtils::ResolveToLength<true>(
+ mFrame->StyleDisplay()->mShapeMargin,
+ LogicalSize(aWM, aContainerSize).ISize(aWM));
+
switch (shapeOutside.GetType()) {
case StyleShapeSourceType::None:
// No need to create shape info.
return;
case StyleShapeSourceType::URL:
MOZ_ASSERT_UNREACHABLE("shape-outside doesn't have URL source type!");
return;
case StyleShapeSourceType::Image: {
float shapeImageThreshold = mFrame->StyleDisplay()->mShapeImageThreshold;
- nscoord shapeMargin = nsLayoutUtils::ResolveToLength<true>(
- mFrame->StyleDisplay()->mShapeMargin,
- LogicalSize(aWM, aContainerSize).ISize(aWM));
mShapeInfo = ShapeInfo::CreateImageShape(shapeOutside.GetShapeImage(),
shapeImageThreshold,
shapeMargin,
mFrame,
aMarginRect,
aWM,
aContainerSize);
if (!mShapeInfo) {
@@ -1982,26 +1986,24 @@ nsFloatManager::FloatInfo::FloatInfo(nsI
break;
}
case StyleShapeSourceType::Box: {
// 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 = nsLayoutUtils::ResolveToLength<true>(
- mFrame->StyleDisplay()->mShapeMargin,
- LogicalSize(aWM, aContainerSize).ISize(aWM));
// Initialize <shape-box>'s reference rect.
LogicalRect shapeBoxRect =
ShapeInfo::ComputeShapeBoxRect(shapeOutside, mFrame, aMarginRect, aWM);
mShapeInfo = ShapeInfo::CreateBasicShape(basicShape, shapeMargin, mFrame,
shapeBoxRect, aWM,
aContainerSize);
break;
}
@@ -2145,30 +2147,39 @@ 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);
+ // Inflate logicalShapeBoxRect by aShapeMargin.
+ logicalShapeBoxRect.Inflate(aShapeMargin);
+
nscoord physicalRadii[8];
bool hasRadii = aFrame->GetShapeBoxBorderRadii(physicalRadii);
if (!hasRadii) {
return MakeUnique<RoundedBoxShapeInfo>(logicalShapeBoxRect,
UniquePtr<nscoord[]>());
}
+ // Add aShapeMargin to each of the radii.
+ for (nscoord& r : physicalRadii) {
+ r += aShapeMargin;
+ }
+
return MakeUnique<RoundedBoxShapeInfo>(logicalShapeBoxRect,
ConvertToFloatLogical(physicalRadii,
aWM));
}
/* static */ UniquePtr<nsFloatManager::ShapeInfo>
nsFloatManager::ShapeInfo::CreateBasicShape(
const UniquePtr<StyleBasicShape>& aBasicShape,