Bug 1311270 - Part 8. Handle rendering of mask-clip:margin-box. draft
authorcku <cku@mozilla.com>
Wed, 23 Nov 2016 18:58:26 +0800
changeset 443046 df93dbc729621180ab1ed1038f5f4122d686919f
parent 443045 cdae017d023cd319915af9894e832822524b0923
child 443047 fdba8a95cf53c02e912269e614195c6feee7b433
push id36890
push userbmo:cku@mozilla.com
push dateWed, 23 Nov 2016 19:16:58 +0000
bugs1311270
milestone53.0a1
Bug 1311270 - Part 8. Handle rendering of mask-clip:margin-box. MozReview-Commit-ID: AhinMykxOKH
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1871,23 +1871,16 @@ nsCSSRendering::GetImageLayerClip(const 
   // Same coordinate space as aBorderArea.
   Sides skipSides = aForFrame->GetSkipSides();
   nsRect clipBorderArea =
     ::BoxDecorationRectForBorder(aForFrame, aBorderArea, skipSides, &aBorder);
 
   bool haveRoundedCorners = GetRadii(aForFrame, aBorder, aBorderArea,
                                      clipBorderArea, aClipState->mRadii);
 
-  // XXX TODO: bug 1303623 only implements the parser of fill-box|stroke-box|view-box|no-clip.
-  // So we need to fallback to default value when rendering. We should remove this
-  // in bug 1311270.
-  if (backgroundClip == StyleGeometryBox::Margin) {
-    backgroundClip = StyleGeometryBox::Border;
-  }
-
   bool isSolidBorder =
       aWillPaintBorder && IsOpaqueBorder(aBorder);
   if (isSolidBorder && backgroundClip == StyleGeometryBox::Border) {
     // If we have rounded corners, we need to inflate the background
     // drawing area a bit to avoid seams between the border and
     // background.
     backgroundClip = haveRoundedCorners
                      ? StyleGeometryBox::MozAlmostPadding
@@ -1925,18 +1918,26 @@ nsCSSRendering::GetImageLayerClip(const 
       aClipState->mAdditionalBGClipArea.Deflate(padding);
     }
 
     // Also clip at a non-scrolling, rounded-corner 'padding-box',
     // same as the scrolled content because of the 'overflow' property.
     backgroundClip = StyleGeometryBox::Padding;
   }
 
-  if (backgroundClip != StyleGeometryBox::Border &&
-      backgroundClip != StyleGeometryBox::Text) {
+  if (backgroundClip == StyleGeometryBox::Margin) {
+    nsMargin border = aForFrame->GetUsedMargin();
+    border.ApplySkipSides(skipSides);
+    aClipState->mBGClipArea.Inflate(border);
+
+    if (haveRoundedCorners) {
+      nsIFrame::InsetBorderRadii(aClipState->mRadii, border);
+    }
+  } else if (backgroundClip != StyleGeometryBox::Border &&
+             backgroundClip != StyleGeometryBox::Text) {
     nsMargin border = aForFrame->GetUsedBorder();
     if (backgroundClip == StyleGeometryBox::MozAlmostPadding) {
       // Reduce |border| by 1px (device pixels) on all sides, if
       // possible, so that we don't get antialiasing seams between the
       // background and border.
       border.top = std::max(0, border.top - aAppUnitsPerPixel);
       border.right = std::max(0, border.right - aAppUnitsPerPixel);
       border.bottom = std::max(0, border.bottom - aAppUnitsPerPixel);