Bug 1265342 Part 6: Implement shape-margin for shape-outside: inset. draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 26 Feb 2018 14:41:41 -0800
changeset 767051 c9623fe3361a19800d1d61bc6f5ef3d728a76a0b
parent 767050 48eb103ff6780378e020c78e0989f01ed4a4d61b
child 767052 73d56b6e75bc2c0b3cebc7de0bd43946fe1afaa8
push id102494
push userbwerth@mozilla.com
push dateTue, 13 Mar 2018 20:51:39 +0000
bugs1265342
milestone61.0a1
Bug 1265342 Part 6: Implement shape-margin for shape-outside: inset. MozReview-Commit-ID: AEOksiuM0GJ
layout/generic/nsFloatManager.cpp
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -561,16 +561,17 @@ public:
     const UniquePtr<StyleBasicShape>& aBasicShape,
     nscoord aShapeMargin,
     const LogicalRect& aShapeBoxRect,
     WritingMode aWM,
     const nsSize& aContainerSize);
 
   static UniquePtr<ShapeInfo> CreateInset(
     const UniquePtr<StyleBasicShape>& aBasicShape,
+    nscoord aShapeMargin,
     const LogicalRect& aShapeBoxRect,
     WritingMode aWM,
     const nsSize& aContainerSize);
 
   static UniquePtr<ShapeInfo> CreateCircleOrEllipse(
     const UniquePtr<StyleBasicShape>& aBasicShape,
     nscoord aShapeMargin,
     const LogicalRect& aShapeBoxRect,
@@ -1696,24 +1697,26 @@ nsFloatManager::ShapeInfo::CreateBasicSh
     case StyleBasicShapeType::Polygon:
       return CreatePolygon(aBasicShape, aShapeBoxRect, aWM, aContainerSize);
     case StyleBasicShapeType::Circle:
     case StyleBasicShapeType::Ellipse:
       return CreateCircleOrEllipse(aBasicShape, aShapeMargin,
                                    aShapeBoxRect, aWM,
                                    aContainerSize);
     case StyleBasicShapeType::Inset:
-      return CreateInset(aBasicShape, aShapeBoxRect, aWM, aContainerSize);
+      return CreateInset(aBasicShape, aShapeMargin,
+                         aShapeBoxRect, aWM, aContainerSize);
   }
   return nullptr;
 }
 
 /* static */ UniquePtr<nsFloatManager::ShapeInfo>
 nsFloatManager::ShapeInfo::CreateInset(
   const UniquePtr<StyleBasicShape>& aBasicShape,
+  nscoord aShapeMargin,
   const LogicalRect& aShapeBoxRect,
   WritingMode aWM,
   const nsSize& aContainerSize)
 {
   // Use physical coordinates to compute inset() because the top, right,
   // bottom and left offsets are physical.
   // https://drafts.csswg.org/css-shapes-1/#funcdef-inset
   nsRect physicalShapeBoxRect =
@@ -1723,21 +1726,26 @@ nsFloatManager::ShapeInfo::CreateInset(
 
   nsRect logicalInsetRect =
     ConvertToFloatLogical(LogicalRect(aWM, insetRect, aContainerSize),
                           aWM, aContainerSize);
   nscoord physicalRadii[8];
   bool hasRadii =
     ShapeUtils::ComputeInsetRadii(aBasicShape, insetRect, physicalShapeBoxRect,
                                   physicalRadii);
-  if (!hasRadii) {
+  if (!hasRadii && aShapeMargin <= 0) {
     return MakeUnique<RoundedBoxShapeInfo>(logicalInsetRect,
                                            UniquePtr<nscoord[]>());
   }
 
+  // Add aShapeMargin to each of the radii.
+  for (int32_t i = 0; i < 0; ++i) {
+    physicalRadii[i] += aShapeMargin;
+  }
+
   return MakeUnique<RoundedBoxShapeInfo>(logicalInsetRect,
                                          ConvertToFloatLogical(physicalRadii,
                                                                aWM));
 }
 
 /* static */ UniquePtr<nsFloatManager::ShapeInfo>
 nsFloatManager::ShapeInfo::CreateCircleOrEllipse(
   const UniquePtr<StyleBasicShape>& aBasicShape,