Bug 1341149 - Implement ImageLayerClipState::ctor. r=mstange, a=lizzard
authorcku <cku@mozilla.com>
Fri, 24 Feb 2017 11:40:44 +0800
changeset 378909 3df2a420389bbeda6c16676068d1f452b2c6d340
parent 378908 abc24cf07fc9aaf416f5efabb808d60363120816
child 378910 7c6b8d7652544c7b306c25acebdc2a6fb32d0dd0
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, lizzard
bugs1341149
milestone53.0a2
Bug 1341149 - Implement ImageLayerClipState::ctor. r=mstange, a=lizzard MozReview-Commit-ID: 7MPrjtgz6c7
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1945,25 +1945,25 @@ ComputeBoxValue(nsIFrame* aForFrame, Sty
 
 /* static */ void
 nsCSSRendering::GetImageLayerClip(const nsStyleImageLayers::Layer& aLayer,
                                   nsIFrame* aForFrame, const nsStyleBorder& aBorder,
                                   const nsRect& aBorderArea, const nsRect& aCallerDirtyRect,
                                   bool aWillPaintBorder, nscoord aAppUnitsPerPixel,
                                   /* out */ ImageLayerClipState* aClipState)
 {
+  aClipState->mHasRoundedCorners = false;
+  aClipState->mHasAdditionalBGClipArea = false;
+  aClipState->mCustomClip = false;
+
   StyleGeometryBox layerClip = ComputeBoxValue(aForFrame, aLayer.mClip);
-
   if (IsSVGStyleGeometryBox(layerClip)) {
     MOZ_ASSERT(aForFrame->IsFrameOfType(nsIFrame::eSVG) &&
                (aForFrame->GetType() != nsGkAtoms::svgOuterSVGFrame));
 
-    aClipState->mHasAdditionalBGClipArea = false;
-    aClipState->mCustomClip = false;
-
     // The coordinate space of clipArea is svg user space.
     nsRect clipArea =
       nsLayoutUtils::ComputeGeometryBox(aForFrame, layerClip);
 
     nsRect strokeBox = (layerClip == StyleGeometryBox::Stroke)
       ? clipArea
       : nsLayoutUtils::ComputeGeometryBox(aForFrame, StyleGeometryBox::Stroke);
     nsRect clipAreaRelativeToStrokeBox = clipArea - strokeBox.TopLeft();
@@ -1982,18 +1982,16 @@ nsCSSRendering::GetImageLayerClip(const 
     SetupDirtyRects(aClipState->mBGClipArea, aCallerDirtyRect,
                     aAppUnitsPerPixel, &aClipState->mDirtyRect,
                     &aClipState->mDirtyRectGfx);
     return;
   }
 
   if (layerClip == StyleGeometryBox::NoClip) {
     aClipState->mBGClipArea = aCallerDirtyRect;
-    aClipState->mHasAdditionalBGClipArea = false;
-    aClipState->mCustomClip = false;
 
     SetupDirtyRects(aClipState->mBGClipArea, aCallerDirtyRect,
                     aAppUnitsPerPixel, &aClipState->mDirtyRect,
                     &aClipState->mDirtyRectGfx);
     return;
   }
 
   MOZ_ASSERT(!aForFrame->IsFrameOfType(nsIFrame::eSVG) ||
@@ -2015,18 +2013,16 @@ nsCSSRendering::GetImageLayerClip(const 
     // drawing area a bit to avoid seams between the border and
     // background.
     layerClip = haveRoundedCorners
                      ? StyleGeometryBox::MozAlmostPadding
                      : StyleGeometryBox::Padding;
   }
 
   aClipState->mBGClipArea = clipBorderArea;
-  aClipState->mHasAdditionalBGClipArea = false;
-  aClipState->mCustomClip = false;
 
   if (aForFrame->GetType() == nsGkAtoms::scrollFrame &&
       NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL == aLayer.mAttachment) {
     // As of this writing, this is still in discussion in the CSS Working Group
     // http://lists.w3.org/Archives/Public/www-style/2013Jul/0250.html
 
     // The rectangle for 'background-clip' scrolls with the content,
     // but the background is also clipped at a non-scrolling 'padding-box'
@@ -2086,18 +2082,16 @@ nsCSSRendering::GetImageLayerClip(const 
       nsIFrame::InsetBorderRadii(aClipState->mRadii, border);
     }
   }
 
   if (haveRoundedCorners) {
     auto d2a = aForFrame->PresContext()->AppUnitsPerDevPixel();
     nsCSSRendering::ComputePixelRadii(aClipState->mRadii, d2a, &aClipState->mClippedRadii);
     aClipState->mHasRoundedCorners = true;
-  } else {
-    aClipState->mHasRoundedCorners = false;
   }
 
 
   if (!haveRoundedCorners && aClipState->mHasAdditionalBGClipArea) {
     // Do the intersection here to account for the fast path(?) below.
     aClipState->mBGClipArea =
       aClipState->mBGClipArea.Intersect(aClipState->mAdditionalBGClipArea);
     aClipState->mHasAdditionalBGClipArea = false;
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -572,29 +572,37 @@ struct nsCSSRendering {
                     nsIFrame* aForFrame,
                     uint32_t aFlags,
                     const nsRect& aBorderArea,
                     const nsRect& aBGClipRect,
                     const nsStyleImageLayers::Layer& aLayer,
                     bool* aOutIsTransformedFixed = nullptr);
 
   struct ImageLayerClipState {
-    nsRect mBGClipArea;  // Affected by mClippedRadii
+    nsRect mBGClipArea;            // Affected by mClippedRadii
     nsRect mAdditionalBGClipArea;  // Not affected by mClippedRadii
     nsRect mDirtyRect;
     gfxRect mDirtyRectGfx;
 
     nscoord mRadii[8];
     RectCornerRadii mClippedRadii;
     bool mHasRoundedCorners;
     bool mHasAdditionalBGClipArea;
 
     // Whether we are being asked to draw with a caller provided background
     // clipping area. If this is true we also disable rounded corners.
     bool mCustomClip;
+
+    ImageLayerClipState()
+     : mHasRoundedCorners(false),
+       mHasAdditionalBGClipArea(false),
+       mCustomClip(false)
+    {
+      memset(mRadii, 0, sizeof(nscoord) * 8);
+    }
   };
 
   static void
   GetImageLayerClip(const nsStyleImageLayers::Layer& aLayer,
                     nsIFrame* aForFrame, const nsStyleBorder& aBorder,
                     const nsRect& aBorderArea, const nsRect& aCallerDirtyRect,
                     bool aWillPaintBorder, nscoord aAppUnitsPerPixel,
                     /* out */ ImageLayerClipState* aClipState);