Bug 1323912 - Part 1. Rename PaintBackground to PaintStyleImageLayer. draft
authorcku <cku@mozilla.com>
Tue, 03 Jan 2017 11:57:13 +0800
changeset 456116 e3c4952525af9138c020b21f0ea59e6d07db1683
parent 455971 a2741dd43eeae54f4dd7423bd832a761481c56ce
child 456117 47b07f413fde4c3ba38f8dab6aa29e5aed6fbdd8
push id40410
push userbmo:cku@mozilla.com
push dateThu, 05 Jan 2017 02:50:43 +0000
bugs1323912
milestone53.0a1
Bug 1323912 - Part 1. Rename PaintBackground to PaintStyleImageLayer. MozReview-Commit-ID: GWuII34t0j7
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
layout/painting/nsDisplayList.cpp
layout/svg/nsSVGIntegrationUtils.cpp
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTablePainter.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1803,17 +1803,17 @@ nsCSSRendering::PaintBGParams::ForSingle
 
   PaintBGParams result(aPresCtx, aRenderingCtx, aDirtyRect, aBorderArea, aFrame,
     aPaintFlags, aLayer, aCompositionOp);
 
   return result;
 }
 
 DrawResult
-nsCSSRendering::PaintBackground(const PaintBGParams& aParams)
+nsCSSRendering::PaintStyleImageLayer(const PaintBGParams& aParams)
 {
   PROFILER_LABEL("nsCSSRendering", "PaintBackground",
     js::ProfileEntry::Category::GRAPHICS);
 
   NS_PRECONDITION(aParams.frame,
                   "Frame is expected to be provided to PaintBackground");
 
   nsStyleContext *sc;
@@ -1830,17 +1830,17 @@ nsCSSRendering::PaintBackground(const Pa
     nsIContent* content = aParams.frame->GetContent();
     if (!content || content->GetParent()) {
       return DrawResult::SUCCESS;
     }
 
     sc = aParams.frame->StyleContext();
   }
 
-  return PaintBackgroundWithSC(aParams, sc, *aParams.frame->StyleBorder());
+  return PaintStyleImageLayerWithSC(aParams, sc, *aParams.frame->StyleBorder());
 }
 
 static bool
 IsOpaqueBorderEdge(const nsStyleBorder& aBorder, mozilla::Side aSide)
 {
   if (aBorder.GetComputedBorder().Side(aSide) == 0)
     return true;
   switch (aBorder.GetBorderStyle(aSide)) {
@@ -3238,19 +3238,19 @@ DetermineCompositionOp(const nsCSSRender
 
     return nsCSSRendering::GetGFXCompositeMode(layer.mComposite);
   }
 
   return nsCSSRendering::GetGFXBlendMode(layer.mBlendMode);
 }
 
 DrawResult
-nsCSSRendering::PaintBackgroundWithSC(const PaintBGParams& aParams,
-                                      nsStyleContext *aBackgroundSC,
-                                      const nsStyleBorder& aBorder)
+nsCSSRendering::PaintStyleImageLayerWithSC(const PaintBGParams& aParams,
+                                           nsStyleContext *aBackgroundSC,
+                                           const nsStyleBorder& aBorder)
 {
   NS_PRECONDITION(aParams.frame,
                   "Frame is expected to be provided to PaintBackground");
 
   // If we're drawing all layers, aCompositonOp is ignored, so make sure that
   // it was left at its default value.
   MOZ_ASSERT_IF(aParams.layer == -1,
                 aParams.compositionOp == CompositionOp::OP_OVER);
@@ -3443,22 +3443,22 @@ nsCSSRendering::PaintBackgroundWithSC(co
           if (co != CompositionOp::OP_OVER) {
             NS_ASSERTION(ctx->CurrentOp() == CompositionOp::OP_OVER,
                          "It is assumed the initial op is OP_OVER, when it is "
                          "restored later");
             ctx->SetOp(co);
           }
 
           result &=
-            state.mImageRenderer.DrawBackground(&aParams.presCtx,
-                                                aParams.renderingCtx,
-                                                state.mDestArea, state.mFillArea,
-                                                state.mAnchor + paintBorderArea.TopLeft(),
-                                                clipState.mDirtyRect,
-                                                state.mRepeatSize);
+            state.mImageRenderer.DrawLayer(&aParams.presCtx,
+                                           aParams.renderingCtx,
+                                           state.mDestArea, state.mFillArea,
+                                           state.mAnchor + paintBorderArea.TopLeft(),
+                                           clipState.mDirtyRect,
+                                           state.mRepeatSize);
 
           if (co != CompositionOp::OP_OVER) {
             ctx->SetOp(CompositionOp::OP_OVER);
           }
         }
       }
     }
   }
@@ -5781,23 +5781,23 @@ nsImageRenderer::DrawableForElement(cons
   NS_ASSERTION(mImageElementSurface.GetSourceSurface(), "Surface should be ready.");
   RefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(
                                 mImageElementSurface.GetSourceSurface().get(),
                                 mImageElementSurface.mSize);
   return drawable.forget();
 }
 
 DrawResult
-nsImageRenderer::DrawBackground(nsPresContext*       aPresContext,
-                                nsRenderingContext&  aRenderingContext,
-                                const nsRect&        aDest,
-                                const nsRect&        aFill,
-                                const nsPoint&       aAnchor,
-                                const nsRect&        aDirty,
-                                const nsSize&        aRepeatSize)
+nsImageRenderer::DrawLayer(nsPresContext*       aPresContext,
+                           nsRenderingContext&  aRenderingContext,
+                           const nsRect&        aDest,
+                           const nsRect&        aFill,
+                           const nsPoint&       aAnchor,
+                           const nsRect&        aDirty,
+                           const nsSize&        aRepeatSize)
 {
   if (!IsReady()) {
     NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me");
     return DrawResult::TEMPORARY_ERROR;
   }
   if (aDest.IsEmpty() || aFill.IsEmpty() ||
       mSize.width <= 0 || mSize.height <= 0) {
     return DrawResult::SUCCESS;
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -142,17 +142,17 @@ public:
    */
   bool PrepareImage();
 
   /**
    * The three Compute*Size functions correspond to the sizing algorthms and
    * definitions from the CSS Image Values and Replaced Content spec. See
    * http://dev.w3.org/csswg/css-images-3/#sizing .
    */
-   
+
   /**
    * Compute the intrinsic size of the image as defined in the CSS Image Values
    * spec. The intrinsic size is the unscaled size which the image would ideally
    * like to be in app units.
    */
   mozilla::CSSSizeOrRatio ComputeIntrinsicSize();
 
   /**
@@ -204,27 +204,27 @@ public:
    * Set this image's preferred size. This will be its intrinsic size where
    * specified and the default size where it is not. Used as the unscaled size
    * when rendering the image.
    */
   void SetPreferredSize(const mozilla::CSSSizeOrRatio& aIntrinsicSize,
                         const nsSize& aDefaultSize);
 
   /**
-   * Draws the image to the target rendering context using background-specific
-   * arguments.
+   * Draws the image to the target rendering context using
+   * {background|mask}-specific arguments.
    * @see nsLayoutUtils::DrawImage() for parameters.
    */
-  DrawResult DrawBackground(nsPresContext*       aPresContext,
-                            nsRenderingContext&  aRenderingContext,
-                            const nsRect&        aDest,
-                            const nsRect&        aFill,
-                            const nsPoint&       aAnchor,
-                            const nsRect&        aDirty,
-                            const nsSize&        aRepeatSize);
+  DrawResult DrawLayer(nsPresContext*       aPresContext,
+                       nsRenderingContext&  aRenderingContext,
+                       const nsRect&        aDest,
+                       const nsRect&        aFill,
+                       const nsPoint&       aAnchor,
+                       const nsRect&        aDirty,
+                       const nsSize&        aRepeatSize);
 
   /**
    * Draw the image to a single component of a border-image style rendering.
    * aFill The destination rect to be drawn into
    * aSrc is the part of the image to be rendered into a tile (aUnitSize in
    * aFill), if aSrc and the dest tile are different sizes, the image will be
    * scaled to map aSrc onto the dest tile.
    * aHFill and aVFill are the repeat patterns for the component -
@@ -664,34 +664,35 @@ struct nsCSSRendering {
        dirtyRect(aDirtyRect),
        borderArea(aBorderArea),
        frame(aFrame),
        paintFlags(aPaintFlags),
        layer(aLayer),
        compositionOp(aCompositionOp) {}
   };
 
-  static DrawResult PaintBackground(const PaintBGParams& aParams);
+  static DrawResult PaintStyleImageLayer(const PaintBGParams& aParams);
 
 
   /**
-   * Same as |PaintBackground|, except using the provided style structs.
+   * Same as |PaintStyleImageLayer|, except using the provided style structs.
    * This short-circuits the code that ensures that the root element's
-   * background is drawn on the canvas.
-   * The aLayer parameter allows you to paint a single layer of the background.
+   * {background|mask} is drawn on the canvas.
+   * The aLayer parameter allows you to paint a single layer of the
+   * {background|mask}.
    * The default value for aLayer, -1, means that all layers will be painted.
    * The background color will only be painted if the back-most layer is also
-   * being painted.
+   * being painted and (aParams.paintFlags & PAINTBG_MASK_IMAGE) is false.
    * aCompositionOp is only respected if a single layer is specified (aLayer != -1).
    * If all layers are painted, the image layer's blend mode (or the mask
    * layer's composition mode) will be used.
    */
-  static DrawResult PaintBackgroundWithSC(const PaintBGParams& aParams,
-                                          nsStyleContext *mBackgroundSC,
-                                          const nsStyleBorder& aBorder);
+  static DrawResult PaintStyleImageLayerWithSC(const PaintBGParams& aParams,
+                                               nsStyleContext *mBackgroundSC,
+                                               const nsStyleBorder& aBorder);
 
   /**
    * Returns the rectangle covered by the given background layer image, taking
    * into account background positioning, sizing, and repetition, but not
    * clipping.
    */
   static nsRect GetBackgroundLayerRect(nsPresContext* aPresContext,
                                        nsIFrame* aForFrame,
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3244,17 +3244,17 @@ nsDisplayBackgroundImage::PaintInternal(
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForSingleLayer(*mFrame->PresContext(),
                                                   *aCtx,
                                                   aBounds, mBackgroundRect,
                                                   mFrame, flags, mLayer,
                                                   CompositionOp::OP_OVER);
   params.bgClipRect = aClipRect;
   image::DrawResult result =
-    nsCSSRendering::PaintBackground(params);
+    nsCSSRendering::PaintStyleImageLayer(params);
 
   if (clip == StyleGeometryBox::Text) {
     ctx->PopGroupAndBlend();
   }
 
   nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
 }
 
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -507,17 +507,17 @@ PaintMaskSurface(const PaintFramesParams
                                                       rc, aParams.dirtyRect,
                                                       aParams.borderArea,
                                                       aParams.frame,
                                                       aParams.builder->GetBackgroundPaintFlags() |
                                                       nsCSSRendering::PAINTBG_MASK_IMAGE,
                                                       i, compositionOp);
 
       result =
-        nsCSSRendering::PaintBackgroundWithSC(params, aSC,
+        nsCSSRendering::PaintStyleImageLayerWithSC(params, aSC,
                                               *aParams.frame->StyleBorder());
       if (result != DrawResult::SUCCESS) {
         return result;
       }
     }
   }
 
   return DrawResult::SUCCESS;
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -371,17 +371,17 @@ nsTableCellFrame::PaintBackground(nsRend
                                   uint32_t             aFlags)
 {
   nsRect rect(aPt, GetSize());
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForAllLayers(*PresContext(),
                                                 aRenderingContext,
                                                 aDirtyRect, rect,
                                                 this, aFlags);
-  return nsCSSRendering::PaintBackground(params);
+  return nsCSSRendering::PaintStyleImageLayer(params);
 }
 
 // Called by nsTablePainter
 DrawResult
 nsTableCellFrame::PaintCellBackground(nsRenderingContext& aRenderingContext,
                                       const nsRect& aDirtyRect, nsPoint aPt,
                                       uint32_t aFlags)
 {
@@ -1199,17 +1199,16 @@ nsBCTableCellFrame::GetBorderOverflow()
   LogicalMargin halfBorder(wm,
                            BC_BORDER_START_HALF_COORD(p2t, mBStartBorder),
                            BC_BORDER_END_HALF_COORD(p2t, mIEndBorder),
                            BC_BORDER_END_HALF_COORD(p2t, mBEndBorder),
                            BC_BORDER_START_HALF_COORD(p2t, mIStartBorder));
   return halfBorder.GetPhysicalMargin(wm);
 }
 
-
 DrawResult
 nsBCTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
                                     const nsRect&        aDirtyRect,
                                     nsPoint              aPt,
                                     uint32_t             aFlags)
 {
   // make border-width reflect the half of the border-collapse
   // assigned border that's inside the cell
@@ -1225,10 +1224,11 @@ nsBCTableCellFrame::PaintBackground(nsRe
   // bypassing nsCSSRendering::PaintBackground is safe because this kind
   // of frame cannot be used for the root element
   nsRect rect(aPt, GetSize());
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForAllLayers(*PresContext(),
                                                 aRenderingContext, aDirtyRect,
                                                 rect, this,
                                                 aFlags);
-  return nsCSSRendering::PaintBackgroundWithSC(params, StyleContext(), myBorder);
+  return nsCSSRendering::PaintStyleImageLayerWithSC(params, StyleContext(),
+                                                    myBorder);
 }
--- a/layout/tables/nsTablePainter.cpp
+++ b/layout/tables/nsTablePainter.cpp
@@ -234,17 +234,17 @@ TableBackgroundPainter::PaintTableFrame(
       nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext,
                                                   mRenderingContext,
                                                   mDirtyRect,
                                                   tableData.mRect + mRenderPt,
                                                   tableData.mFrame,
                                                   mBGPaintFlags);
 
     result &=
-      nsCSSRendering::PaintBackgroundWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params,
                                             tableData.mFrame->StyleContext(),
                                             tableData.StyleBorder(mZeroBorder));
   }
 
   return result;
 }
 
 void
@@ -575,60 +575,60 @@ TableBackgroundPainter::PaintCell(nsTabl
     nsCSSRendering::PaintBGParams params =
       nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
                                                  mDirtyRect,
                                                  mCols[colIndex].mColGroup.mRect + mRenderPt,
                                                  mCols[colIndex].mColGroup.mFrame,
                                                  mBGPaintFlags);
     params.bgClipRect = &aColBGRect;
     result &=
-      nsCSSRendering::PaintBackgroundWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params,
                                             mCols[colIndex].mColGroup.mFrame->StyleContext(),
                                             mCols[colIndex].mColGroup.StyleBorder(mZeroBorder));
   }
 
   //Paint column background
   if (haveColumns && mCols[colIndex].mCol.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
       nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
                                                   mDirtyRect,
                                                   mCols[colIndex].mCol.mRect + mRenderPt,
                                                   mCols[colIndex].mCol.mFrame,
                                                   mBGPaintFlags);
     params.bgClipRect = &aColBGRect;
     result &=
-      nsCSSRendering::PaintBackgroundWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params,
                                             mCols[colIndex].mCol.mFrame->StyleContext(),
                                             mCols[colIndex].mCol.StyleBorder(mZeroBorder));
   }
 
   //Paint row group background
   if (aRowGroupBGData.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
       nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
                                                   mDirtyRect,
                                                   aRowGroupBGData.mRect + mRenderPt,
                                                   aRowGroupBGData.mFrame, mBGPaintFlags);
     params.bgClipRect = &aRowGroupBGRect;
     result &=
-      nsCSSRendering::PaintBackgroundWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params,
                                             aRowGroupBGData.mFrame->StyleContext(),
                                             aRowGroupBGData.StyleBorder(mZeroBorder));
   }
 
   //Paint row background
   if (aRowBGData.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
       nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
                                                   mDirtyRect,
                                                   aRowBGData.mRect + mRenderPt,
                                                   aRowBGData.mFrame, mBGPaintFlags);
     params.bgClipRect = &aRowBGRect;
     result &=
-      nsCSSRendering::PaintBackgroundWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params,
                                             aRowBGData.mFrame->StyleContext(),
                                             aRowBGData.StyleBorder(mZeroBorder));
   }
 
   //Paint cell background in border-collapse unless we're just passing
   if (mIsBorderCollapse && !aPassSelf) {
     result &=
       aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -4144,17 +4144,18 @@ nsTreeBodyFrame::PaintBackgroundLayer(ns
                                       const nsRect&        aDirtyRect)
 {
   const nsStyleBorder* myBorder = aStyleContext->StyleBorder();
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForAllLayers(*aPresContext, aRenderingContext,
                                                 aDirtyRect, aRect, this,
                                                 nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES);
   DrawResult result =
-    nsCSSRendering::PaintBackgroundWithSC(params, aStyleContext, *myBorder);
+    nsCSSRendering::PaintStyleImageLayerWithSC(params, aStyleContext,
+                                               *myBorder);
 
   result &=
     nsCSSRendering::PaintBorderWithStyleBorder(aPresContext, aRenderingContext,
                                                this, aDirtyRect, aRect,
                                                *myBorder, mStyleContext,
                                                PaintBorderFlags::SYNC_DECODE_IMAGES);
 
   nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,