Bug 1311270 - Part 7. Rename local variable in GetImageLayerClip and ComputeImageLayerPositioningArea. draft
authorcku <cku@mozilla.com>
Thu, 24 Nov 2016 17:23:01 +0800
changeset 453293 cad013dabea9af3f5636f894f867ff913d004cce
parent 453292 d9925011bd36dc82dccdb9ffb8fdcb7c085ccc33
child 453294 b1c1deb914ba23f74953670e8e79cc0d3ba635c4
push id39618
push userbmo:cku@mozilla.com
push dateFri, 23 Dec 2016 04:25:44 +0000
bugs1311270
milestone53.0a1
Bug 1311270 - Part 7. Rename local variable in GetImageLayerClip and ComputeImageLayerPositioningArea. GetImageLayerClip and ComputeImageLayerPositioningArea are used by both background and mask layer. Rename local variables to reveal this fact. MozReview-Commit-ID: FjScl95eWJg
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1939,30 +1939,30 @@ 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)
 {
-  StyleGeometryBox backgroundClip = ComputeBoxValue(aForFrame, aLayer.mClip);
-
-  if (IsSVGStyleGeometryBox(backgroundClip)) {
+  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, backgroundClip);
-
-    nsRect strokeBox = (backgroundClip == StyleGeometryBox::Stroke)
+      nsLayoutUtils::ComputeGeometryBox(aForFrame, layerClip);
+
+    nsRect strokeBox = (layerClip == StyleGeometryBox::Stroke)
       ? clipArea
       : nsLayoutUtils::ComputeGeometryBox(aForFrame, StyleGeometryBox::Stroke);
     nsRect clipAreaRelativeToStrokeBox = clipArea - strokeBox.TopLeft();
 
     // aBorderArea is the stroke-box area in a coordinate space defined by
     // the caller. This coordinate space can be svg user space of aForFrame,
     // the space of aForFrame's reference-frame, or anything else.
     //
@@ -1974,17 +1974,17 @@ nsCSSRendering::GetImageLayerClip(const 
       clipAreaRelativeToStrokeBox + aBorderArea.TopLeft();
 
     SetupDirtyRects(aClipState->mBGClipArea, aCallerDirtyRect,
                     aAppUnitsPerPixel, &aClipState->mDirtyRect,
                     &aClipState->mDirtyRectGfx);
     return;
   }
 
-  if (backgroundClip == StyleGeometryBox::NoClip) {
+  if (layerClip == StyleGeometryBox::NoClip) {
     aClipState->mBGClipArea = aCallerDirtyRect;
     aClipState->mHasAdditionalBGClipArea = false;
     aClipState->mCustomClip = false;
 
     SetupDirtyRects(aClipState->mBGClipArea, aCallerDirtyRect,
                     aAppUnitsPerPixel, &aClipState->mDirtyRect,
                     &aClipState->mDirtyRectGfx);
     return;
@@ -1999,21 +1999,21 @@ nsCSSRendering::GetImageLayerClip(const 
   nsRect clipBorderArea =
     ::BoxDecorationRectForBorder(aForFrame, aBorderArea, skipSides, &aBorder);
 
   bool haveRoundedCorners = GetRadii(aForFrame, aBorder, aBorderArea,
                                      clipBorderArea, aClipState->mRadii);
 
   bool isSolidBorder =
       aWillPaintBorder && IsOpaqueBorder(aBorder);
-  if (isSolidBorder && backgroundClip == StyleGeometryBox::Border) {
+  if (isSolidBorder && layerClip == 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
+    layerClip = haveRoundedCorners
                      ? StyleGeometryBox::MozAlmostPadding
                      : StyleGeometryBox::Padding;
   }
 
   aClipState->mBGClipArea = clipBorderArea;
   aClipState->mHasAdditionalBGClipArea = false;
   aClipState->mCustomClip = false;
 
@@ -2021,17 +2021,17 @@ nsCSSRendering::GetImageLayerClip(const 
       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'
     // like the content. (See below.)
     // Therefore, only 'content-box' makes a difference here.
-    if (backgroundClip == StyleGeometryBox::Content) {
+    if (layerClip == StyleGeometryBox::Content) {
       nsIScrollableFrame* scrollableFrame = do_QueryFrame(aForFrame);
       // Clip at a rectangle attached to the scrolled content.
       aClipState->mHasAdditionalBGClipArea = true;
       aClipState->mAdditionalBGClipArea = nsRect(
         aClipState->mBGClipArea.TopLeft()
           + scrollableFrame->GetScrolledFrame()->GetPosition()
           // For the dir=rtl case:
           + scrollableFrame->GetScrollRange().TopLeft(),
@@ -2041,32 +2041,32 @@ nsCSSRendering::GetImageLayerClip(const 
       // https://bugzilla.mozilla.org/show_bug.cgi?id=748518
       padding.bottom = 0;
       padding.ApplySkipSides(skipSides);
       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) {
+    layerClip = StyleGeometryBox::Padding;
+  }
+
+  if (layerClip != StyleGeometryBox::Border &&
+      layerClip != StyleGeometryBox::Text) {
     nsMargin border = aForFrame->GetUsedBorder();
-    if (backgroundClip == StyleGeometryBox::MozAlmostPadding) {
+    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 and border.
+      // {background|mask} 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);
       border.left = std::max(0, border.left - aAppUnitsPerPixel);
-    } else if (backgroundClip != StyleGeometryBox::Padding) {
-      NS_ASSERTION(backgroundClip == StyleGeometryBox::Content,
+    } else if (layerClip != StyleGeometryBox::Padding) {
+      NS_ASSERTION(layerClip == StyleGeometryBox::Content,
                    "unexpected background-clip");
       border += aForFrame->GetUsedPadding();
     }
     border.ApplySkipSides(skipSides);
     aClipState->mBGClipArea.Deflate(border);
 
     if (haveRoundedCorners) {
       nsIFrame::InsetBorderRadii(aClipState->mRadii, border);
@@ -3459,98 +3459,98 @@ nsCSSRendering::PaintBackgroundWithSC(co
 nsRect
 nsCSSRendering::ComputeImageLayerPositioningArea(nsPresContext* aPresContext,
                                                  nsIFrame* aForFrame,
                                                  const nsRect& aBorderArea,
                                                  const nsStyleImageLayers::Layer& aLayer,
                                                  nsIFrame** aAttachedToFrame,
                                                  bool* aOutIsTransformedFixed)
 {
-  // Compute background origin area relative to aBorderArea now as we may need
-  // it to compute the effective image size for a CSS gradient.
-  nsRect bgPositioningArea;
-
-  StyleGeometryBox backgroundOrigin =
+  // 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(backgroundOrigin)) {
+  if (IsSVGStyleGeometryBox(layerOrigin)) {
     MOZ_ASSERT(aForFrame->IsFrameOfType(nsIFrame::eSVG) &&
                (aForFrame->GetType() != nsGkAtoms::svgOuterSVGFrame));
     *aAttachedToFrame = aForFrame;
 
-    bgPositioningArea =
-      nsLayoutUtils::ComputeGeometryBox(aForFrame, backgroundOrigin);
+    positionArea =
+      nsLayoutUtils::ComputeGeometryBox(aForFrame, layerOrigin);
 
     nsPoint toStrokeBoxOffset = nsPoint(0, 0);
-    if (backgroundOrigin != StyleGeometryBox::Stroke) {
+    if (layerOrigin != StyleGeometryBox::Stroke) {
       nsRect strokeBox =
         nsLayoutUtils::ComputeGeometryBox(aForFrame,
                                           StyleGeometryBox::Stroke);
-      toStrokeBoxOffset = bgPositioningArea.TopLeft() - strokeBox.TopLeft();
+      toStrokeBoxOffset = positionArea.TopLeft() - strokeBox.TopLeft();
     }
 
     // For SVG frames, the return value is relative to the stroke box
-    return nsRect(toStrokeBoxOffset, bgPositioningArea.Size());
+    return nsRect(toStrokeBoxOffset, positionArea.Size());
   }
 
   MOZ_ASSERT(!aForFrame->IsFrameOfType(nsIFrame::eSVG) ||
              aForFrame->GetType() == nsGkAtoms::svgOuterSVGFrame);
 
   nsIAtom* frameType = aForFrame->GetType();
   nsIFrame* geometryFrame = aForFrame;
   if (MOZ_UNLIKELY(frameType == nsGkAtoms::scrollFrame &&
                    NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL == aLayer.mAttachment)) {
     nsIScrollableFrame* scrollableFrame = do_QueryFrame(aForFrame);
-    bgPositioningArea = nsRect(
+    positionArea = nsRect(
       scrollableFrame->GetScrolledFrame()->GetPosition()
         // For the dir=rtl case:
         + scrollableFrame->GetScrollRange().TopLeft(),
       scrollableFrame->GetScrolledRect().Size());
     // The ScrolledRect’s size does not include the borders or scrollbars,
     // reverse the handling of background-origin
     // compared to the common case below.
-    if (backgroundOrigin == StyleGeometryBox::Border) {
+    if (layerOrigin == StyleGeometryBox::Border) {
       nsMargin border = geometryFrame->GetUsedBorder();
       border.ApplySkipSides(geometryFrame->GetSkipSides());
-      bgPositioningArea.Inflate(border);
-      bgPositioningArea.Inflate(scrollableFrame->GetActualScrollbarSizes());
-    } else if (backgroundOrigin != StyleGeometryBox::Padding) {
+      positionArea.Inflate(border);
+      positionArea.Inflate(scrollableFrame->GetActualScrollbarSizes());
+    } else if (layerOrigin != StyleGeometryBox::Padding) {
       nsMargin padding = geometryFrame->GetUsedPadding();
       padding.ApplySkipSides(geometryFrame->GetSkipSides());
-      bgPositioningArea.Deflate(padding);
-      NS_ASSERTION(backgroundOrigin == StyleGeometryBox::Content,
+      positionArea.Deflate(padding);
+      NS_ASSERTION(layerOrigin == StyleGeometryBox::Content,
                    "unknown background-origin value");
     }
     *aAttachedToFrame = aForFrame;
-    return bgPositioningArea;
+    return positionArea;
   }
 
   if (MOZ_UNLIKELY(frameType == nsGkAtoms::canvasFrame)) {
     geometryFrame = aForFrame->PrincipalChildList().FirstChild();
     // geometryFrame might be null if this canvas is a page created
     // as an overflow container (e.g. the in-flow content has already
     // finished and this page only displays the continuations of
     // absolutely positioned content).
     if (geometryFrame) {
-      bgPositioningArea = geometryFrame->GetRect();
+      positionArea = geometryFrame->GetRect();
     }
   } else {
-    bgPositioningArea = nsRect(nsPoint(0,0), aBorderArea.Size());
-  }
-
-  // Background images are tiled over the 'background-clip' area
-  // but the origin of the tiling is based on the 'background-origin' area
-  if (backgroundOrigin != StyleGeometryBox::Border && geometryFrame) {
+    positionArea = nsRect(nsPoint(0,0), aBorderArea.Size());
+  }
+  // {background|mask} images are tiled over the '{background|mask}-clip' area
+  // but the origin of the tiling is based on the '{background|mask}-origin'
+  // area.
+  if (layerOrigin != StyleGeometryBox::Border && geometryFrame) {
     nsMargin border = geometryFrame->GetUsedBorder();
-    if (backgroundOrigin != StyleGeometryBox::Padding) {
+    if (layerOrigin != StyleGeometryBox::Padding) {
       border += geometryFrame->GetUsedPadding();
-      NS_ASSERTION(backgroundOrigin == StyleGeometryBox::Content,
+      NS_ASSERTION(layerOrigin == StyleGeometryBox::Content,
                    "unknown background-origin value");
     }
-    bgPositioningArea.Deflate(border);
+    positionArea.Deflate(border);
   }
 
   nsIFrame* attachedToFrame = aForFrame;
   if (NS_STYLE_IMAGELAYER_ATTACHMENT_FIXED == aLayer.mAttachment) {
     // If it's a fixed background attachment, then the image is placed
     // relative to the viewport, which is the area of the root frame
     // in a screen context or the page content frame in a print context.
     attachedToFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame();
@@ -3568,33 +3568,33 @@ nsCSSRendering::ComputeImageLayerPositio
     // If the background is affected by a transform, treat is as if it
     // wasn't fixed.
     if (nsLayoutUtils::IsTransformed(aForFrame, attachedToFrame)) {
       attachedToFrame = aForFrame;
       *aOutIsTransformedFixed = true;
     } else {
       // Set the background positioning area to the viewport's area
       // (relative to aForFrame)
-      bgPositioningArea =
+      positionArea =
         nsRect(-aForFrame->GetOffsetTo(attachedToFrame), attachedToFrame->GetSize());
 
       if (!pageContentFrame) {
         // Subtract the size of scrollbars.
         nsIScrollableFrame* scrollableFrame =
           aPresContext->PresShell()->GetRootScrollFrameAsScrollable();
         if (scrollableFrame) {
           nsMargin scrollbars = scrollableFrame->GetActualScrollbarSizes();
-          bgPositioningArea.Deflate(scrollbars);
+          positionArea.Deflate(scrollbars);
         }
       }
     }
   }
   *aAttachedToFrame = attachedToFrame;
 
-  return bgPositioningArea;
+  return positionArea;
 }
 
 // Implementation of the formula for computation of background-repeat round
 // See http://dev.w3.org/csswg/css3-background/#the-background-size
 // This function returns the adjusted size of the background image.
 static nscoord
 ComputeRoundedSize(nscoord aCurrentSize, nscoord aPositioningSize)
 {
@@ -3812,17 +3812,17 @@ nsCSSRendering::PrepareImageLayer(nsPres
   }
 
   // The frame to which the background is attached
   nsIFrame* attachedToFrame = aForFrame;
   // Is the background marked 'fixed', but affected by a transform?
   bool transformedFixed = false;
   // Compute background origin area relative to aBorderArea now as we may need
   // it to compute the effective image size for a CSS gradient.
-  nsRect bgPositioningArea =
+  nsRect positionArea =
     ComputeImageLayerPositioningArea(aPresContext, aForFrame, aBorderArea,
                                      aLayer, &attachedToFrame, &transformedFixed);
   if (aOutIsTransformedFixed) {
     *aOutIsTransformedFixed = transformedFixed;
   }
 
   // For background-attachment:fixed backgrounds, we'll limit the area
   // where the background can be drawn to the viewport.
@@ -3837,28 +3837,28 @@ nsCSSRendering::PrepareImageLayer(nsPres
     if (aFlags & nsCSSRendering::PAINTBG_TO_WINDOW) {
       // Clip background-attachment:fixed backgrounds to the viewport, if we're
       // painting to the screen and not transformed. This avoids triggering
       // tiling in common cases, without affecting output since drawing is
       // always clipped to the viewport when we draw to the screen. (But it's
       // not a pure optimization since it can affect the values of pixels at the
       // edge of the viewport --- whether they're sampled from a putative "next
       // tile" or not.)
-      bgClipRect.IntersectRect(bgClipRect, bgPositioningArea + aBorderArea.TopLeft());
+      bgClipRect.IntersectRect(bgClipRect, positionArea + aBorderArea.TopLeft());
     }
   }
 
   int repeatX = aLayer.mRepeat.mXRepeat;
   int repeatY = aLayer.mRepeat.mYRepeat;
 
   // Scale the image as specified for background-size and background-repeat.
   // Also as required for proper background positioning when background-position
   // is defined with percentages.
   CSSSizeOrRatio intrinsicSize = state.mImageRenderer.ComputeIntrinsicSize();
-  nsSize bgPositionSize = bgPositioningArea.Size();
+  nsSize bgPositionSize = positionArea.Size();
   nsSize imageSize = ComputeDrawnSizeForBackground(intrinsicSize,
                                                    bgPositionSize,
                                                    aLayer.mSize,
                                                    repeatX,
                                                    repeatY);
 
   if (imageSize.width <= 0 || imageSize.height <= 0)
     return state;
@@ -3893,18 +3893,18 @@ nsCSSRendering::PrepareImageLayer(nsPres
     if (isRepeat) {
       imageTopLeft.y = 0;
       state.mAnchor.y = 0;
     } else {
       repeatY = NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT;
     }
   }
 
-  imageTopLeft += bgPositioningArea.TopLeft();
-  state.mAnchor += bgPositioningArea.TopLeft();
+  imageTopLeft += positionArea.TopLeft();
+  state.mAnchor += positionArea.TopLeft();
   state.mDestArea = nsRect(imageTopLeft + aBorderArea.TopLeft(), imageSize);
   state.mFillArea = state.mDestArea;
 
   ExtendMode repeatMode = ExtendMode::CLAMP;
   if (repeatX == NS_STYLE_IMAGELAYER_REPEAT_REPEAT ||
       repeatX == NS_STYLE_IMAGELAYER_REPEAT_ROUND ||
       repeatX == NS_STYLE_IMAGELAYER_REPEAT_SPACE) {
     state.mFillArea.x = bgClipRect.x;