Bug 1311270 - Part 8. Add assertion for margin-box. draft
authorcku <cku@mozilla.com>
Wed, 30 Nov 2016 15:51:05 +0800
changeset 445797 1ff830c10f2469db3d11c405a664021c7d89b312
parent 445796 4b448f086ad0825e46bb4be82aecfbe889d00466
child 445798 49f1c89959c6f43cda9fa7cc017b61ddee0329e9
push id37609
push userbmo:cku@mozilla.com
push dateWed, 30 Nov 2016 08:03:11 +0000
bugs1311270
milestone53.0a1
Bug 1311270 - Part 8. Add assertion for margin-box. MozReview-Commit-ID: FEkEf3ps83k
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -2048,16 +2048,24 @@ 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.
     layerClip = StyleGeometryBox::Padding;
   }
 
+  // See the comment of StyleGeometryBox::Margin.
+  // Hitting this assertion means we turn on margin-box suppprting for
+  // positioned mask from CSS parser and style system. In this case, you
+  // should *inflate* mBGClipArea by the margin returning from
+  // aForFrame->GetUsedMargin in the code chunk bellow.
+  MOZ_ASSERT(layerClip != StyleGeometryBox::Margin,
+             "StyleGeometryBox::Margin rendering is not supported yet.\n");
+
   if (layerClip != StyleGeometryBox::Border &&
       layerClip != StyleGeometryBox::Text) {
     nsMargin border = aForFrame->GetUsedBorder();
     if (layerClip == StyleGeometryBox::MozAlmostPadding) {
       // Reduce |border| by 1px (device pixels) on all sides, if
       // possible, so that we don't get antialiasing seams between the
       // {background|mask} and border.
       border.top = std::max(0, border.top - aAppUnitsPerPixel);
@@ -3463,16 +3471,21 @@ nsCSSRendering::PaintBackgroundWithSC(co
 nsRect
 nsCSSRendering::ComputeImageLayerPositioningArea(nsPresContext* aPresContext,
                                                  nsIFrame* aForFrame,
                                                  const nsRect& aBorderArea,
                                                  const nsStyleImageLayers::Layer& aLayer,
                                                  nsIFrame** aAttachedToFrame,
                                                  bool* aOutIsTransformedFixed)
 {
+  // StyleGeometryBox::Margin is absolutely not a valid property value for
+  // {mask|backgroun}-origin.
+  MOZ_ASSERT(aLayer.mOrigin != StyleGeometryBox::Margin,
+             "StyleGeometryBox::Margin is not valid value for {mask|bg}-origin.\n");
+
   // Compute {background|mask} origin area relative to aBorderArea now as we
   // may need  it to compute the effective image size for a CSS gradient.
   nsRect positionArea;
 
   StyleGeometryBox layerOrigin =
     ComputeBoxValue(aForFrame, aLayer.mOrigin);
 
   if (IsSVGStyleGeometryBox(layerOrigin)) {