Bug 456792 - Two more API cleanups for nsCSSRendering; patch 1; r+sr=roc
authorZack Weinberg <zweinberg@mozilla.com>
Thu, 25 Sep 2008 17:53:27 +0200
changeset 19705 182489ec31e875310ca18df5d0a7f74fcd988ffd
parent 19704 f8c3ffbe3ba5eb2eb859edcad7c52dae40110d47
child 19706 d01bc28978cdc198c17beb65b278d2a4feae72eb
push id2372
push usersgautherie.bz@free.fr
push dateThu, 25 Sep 2008 15:53:59 +0000
treeherdermozilla-central@182489ec31e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs456792
milestone1.9.1b1pre
Bug 456792 - Two more API cleanups for nsCSSRendering; patch 1; r+sr=roc
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRendering.h
layout/forms/nsGfxCheckboxControlFrame.cpp
layout/forms/nsGfxRadioControlFrame.cpp
layout/mathml/base/src/nsMathMLChar.cpp
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTablePainter.cpp
layout/tables/nsTablePainter.h
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -1261,17 +1261,16 @@ nsCSSRendering::PaintBackground(nsPresCo
                                 PRBool aUsePrintSettings,
                                 nsRect* aBGClipRect)
 {
   NS_PRECONDITION(aForFrame,
                   "Frame is expected to be provided to PaintBackground");
 
   PRBool isCanvas;
   const nsStyleBackground *color;
-  const nsStylePadding* padding = aForFrame->GetStylePadding();
   const nsStyleBorder* border = aForFrame->GetStyleBorder();
 
   if (!FindBackground(aPresContext, aForFrame, &color, &isCanvas)) {
     // we don't want to bail out of moz-appearance is set on a root
     // node. If it has a parent content node, bail because it's not
     // a root, other wise keep going in order to let the theme stuff
     // draw the background. The canvas really should be drawing the
     // bg, but there's no way to hook that up via css.
@@ -1284,17 +1283,17 @@ nsCSSRendering::PaintBackground(nsPresCo
       return;
     }
         
     color = aForFrame->GetStyleBackground();
   }
   if (!isCanvas) {
     PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
                           aDirtyRect, aBorderArea, *color, *border,
-                          *padding, aUsePrintSettings, aBGClipRect);
+                          aUsePrintSettings, aBGClipRect);
     return;
   }
 
   nsStyleBackground canvasColor(*color);
 
   nsIViewManager* vm = aPresContext->GetViewManager();
 
   if (NS_GET_A(canvasColor.mBackgroundColor) < 255) {
@@ -1314,17 +1313,17 @@ nsCSSRendering::PaintBackground(nsPresCo
         NS_ComposeColors(backColor, canvasColor.mBackgroundColor);
     }
   }
 
   vm->SetDefaultBackgroundColor(canvasColor.mBackgroundColor);
 
   PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
                         aDirtyRect, aBorderArea, canvasColor,
-                        *border, *padding, aUsePrintSettings, aBGClipRect);
+                        *border, aUsePrintSettings, aBGClipRect);
 }
 
 inline nscoord IntDivFloor(nscoord aDividend, nscoord aDivisor)
 {
   NS_PRECONDITION(aDivisor > 0,
                   "this function only works for positive divisors");
   // ANSI C, ISO 9899:1999 section 6.5.5 defines integer division as
   // truncation of the result towards zero.  Earlier C standards, as
@@ -1432,17 +1431,16 @@ IsSolidBorder(const nsStyleBorder& aBord
 void
 nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
                                       nsIRenderingContext& aRenderingContext,
                                       nsIFrame* aForFrame,
                                       const nsRect& aDirtyRect,
                                       const nsRect& aBorderArea,
                                       const nsStyleBackground& aColor,
                                       const nsStyleBorder& aBorder,
-                                      const nsStylePadding& aPadding,
                                       PRBool aUsePrintSettings,
                                       nsRect* aBGClipRect)
 {
   NS_PRECONDITION(aForFrame,
                   "Frame is expected to be provided to PaintBackground");
 
   PRBool canDrawBackgroundImage = PR_TRUE;
   PRBool canDrawBackgroundColor = PR_TRUE;
@@ -1497,33 +1495,33 @@ nsCSSRendering::PaintBackgroundWithSC(ns
   if (!dirtyRect.IntersectRect(bgClipArea, aDirtyRect)) {
     // Nothing to paint
     return;
   }
 
   // if there is no background image or background images are turned off, try a color.
   if (!aColor.mBackgroundImage || !canDrawBackgroundImage) {
     PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
-                         aColor, aBorder, aPadding, canDrawBackgroundColor);
+                         aColor, aBorder, canDrawBackgroundColor);
     return;
   }
 
   // We have a background image
 
   // Lookup the image
   imgIRequest *req = aPresContext->LoadImage(aColor.mBackgroundImage,
                                              aForFrame);
 
   PRUint32 status = imgIRequest::STATUS_ERROR;
   if (req)
     req->GetImageStatus(&status);
 
   if (!req || !(status & imgIRequest::STATUS_FRAME_COMPLETE) || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
     PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
-                         aColor, aBorder, aPadding, canDrawBackgroundColor);
+                         aColor, aBorder, canDrawBackgroundColor);
     return;
   }
 
   nsCOMPtr<imgIContainer> image;
   req->GetImage(getter_AddRefs(image));
 
   nsSize imageSize;
   image->GetWidth(&imageSize.width);
@@ -1618,17 +1616,17 @@ nsCSSRendering::PaintBackgroundWithSC(ns
     default:
       NS_ASSERTION(repeat == NS_STYLE_BG_REPEAT_OFF, "unknown background-repeat value");
       break;
   }
 
   // The background color is rendered over the 'background-clip' area
   if (needBackgroundColor) {
     PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
-                         aColor, aBorder, aPadding, canDrawBackgroundColor);
+                         aColor, aBorder, canDrawBackgroundColor);
   }
 
   if ((tileWidth == 0) || (tileHeight == 0) || dirtyRect.IsEmpty()) {
     // Nothing left to paint
     return;
   }
 
   nsPoint borderAreaOriginSnapped = aBorderArea.TopLeft();
@@ -2312,17 +2310,16 @@ nsCSSRendering::DrawBorderImageSide(gfxC
 
 void
 nsCSSRendering::PaintBackgroundColor(nsPresContext* aPresContext,
                                      nsIRenderingContext& aRenderingContext,
                                      nsIFrame* aForFrame,
                                      const nsRect& aBgClipArea,
                                      const nsStyleBackground& aColor,
                                      const nsStyleBorder& aBorder,
-                                     const nsStylePadding& aPadding,
                                      PRBool aCanPaintNonWhite)
 {
   // If we're only allowed to paint white, then don't bail out on transparent
   // color if we're not completely transparent.  See the corresponding check
   // for whether we're allowed to paint background images in
   // PaintBackgroundWithSC before the first call to PaintBackgroundColor.
   if (NS_GET_A(aColor.mBackgroundColor) == 0 &&
       (aCanPaintNonWhite || aColor.IsTransparent())) {
--- a/layout/base/nsCSSRendering.h
+++ b/layout/base/nsCSSRendering.h
@@ -154,17 +154,16 @@ public:
    */
   static void PaintBackgroundWithSC(nsPresContext* aPresContext,
                                     nsIRenderingContext& aRenderingContext,
                                     nsIFrame* aForFrame,
                                     const nsRect& aDirtyRect,
                                     const nsRect& aBorderArea,
                                     const nsStyleBackground& aColor,
                                     const nsStyleBorder& aBorder,
-                                    const nsStylePadding& aPadding,
                                     PRBool aUsePrintSettings = PR_FALSE,
                                     nsRect* aBGClipRect = nsnull);
 
   /**
    * Called by the presShell when painting is finished, so we can clear our
    * inline background data cache.
    */
   static void DidPaint();
@@ -271,17 +270,16 @@ protected:
                                   PRUint8 aVFillType);
 
   static void PaintBackgroundColor(nsPresContext* aPresContext,
                                    nsIRenderingContext& aRenderingContext,
                                    nsIFrame* aForFrame,
                                    const nsRect& aBgClipArea,
                                    const nsStyleBackground& aColor,
                                    const nsStyleBorder& aBorder,
-                                   const nsStylePadding& aPadding,
                                    PRBool aCanPaintNonWhite);
 
   static void PaintRoundedBackground(nsPresContext* aPresContext,
                                      nsIRenderingContext& aRenderingContext,
                                      nsIFrame* aForFrame,
                                      const nsRect& aBorderArea,
                                      const nsStyleBackground& aColor,
                                      const nsStyleBorder& aBorder,
--- a/layout/forms/nsGfxCheckboxControlFrame.cpp
+++ b/layout/forms/nsGfxCheckboxControlFrame.cpp
@@ -245,34 +245,33 @@ nsGfxCheckboxControlFrame::BuildDisplayL
   }
 
   return aLists.Content()->AppendNewToTop(new (aBuilder) nsDisplayCheckMark(this));
 }
 
 void
 nsGfxCheckboxControlFrame::PaintCheckBoxFromStyle(
     nsIRenderingContext& aRenderingContext, nsPoint aPt, const nsRect& aDirtyRect) {
-  const nsStylePadding* myPadding = mCheckButtonFaceStyle->GetStylePadding();
   const nsStylePosition* myPosition = mCheckButtonFaceStyle->GetStylePosition();
   const nsStyleBorder* myBorder = mCheckButtonFaceStyle->GetStyleBorder();
   const nsStyleBackground* myBackground = mCheckButtonFaceStyle->GetStyleBackground();
 
   NS_ASSERTION(myPosition->mWidth.GetUnit() == eStyleUnit_Coord &&
                myPosition->mHeight.GetUnit() == eStyleUnit_Coord,
                "styles for :-moz-checkbox are incorrect or author-accessible");
   nscoord width = myPosition->mWidth.GetCoordValue();
   nscoord height = myPosition->mHeight.GetCoordValue();
   // Position the button centered within the control's rectangle.
   nscoord x = (mRect.width - width) / 2;
   nscoord y = (mRect.height - height) / 2;
   nsRect rect(aPt.x + x, aPt.y + y, width, height);
 
   nsCSSRendering::PaintBackgroundWithSC(PresContext(), aRenderingContext,
                                         this, aDirtyRect, rect, *myBackground,
-                                        *myBorder, *myPadding, PR_FALSE);
+                                        *myBorder, PR_FALSE);
   nsCSSRendering::PaintBorder(PresContext(), aRenderingContext, this,
                               aDirtyRect, rect, *myBorder,
                               mCheckButtonFaceStyle);
 }
 
 //------------------------------------------------------------
 PRBool
 nsGfxCheckboxControlFrame::GetCheckboxState ( )
--- a/layout/forms/nsGfxRadioControlFrame.cpp
+++ b/layout/forms/nsGfxRadioControlFrame.cpp
@@ -125,17 +125,16 @@ nsGfxRadioControlFrame::SetRadioButtonFa
 void
 nsGfxRadioControlFrame::PaintRadioButtonFromStyle(
     nsIRenderingContext& aRenderingContext, nsPoint aPt, const nsRect& aDirtyRect)
 {
   const nsStyleBorder* myBorder = mRadioButtonFaceStyle->GetStyleBorder();
   // Paint the button for the radio button using CSS background rendering code
   const nsStyleBackground* myColor = mRadioButtonFaceStyle->GetStyleBackground();
   const nsStyleColor* color = mRadioButtonFaceStyle->GetStyleColor();
-  const nsStylePadding* myPadding = mRadioButtonFaceStyle->GetStylePadding();
   const nsStylePosition* myPosition = mRadioButtonFaceStyle->GetStylePosition();
 
   NS_ASSERTION(myPosition->mWidth.GetUnit() == eStyleUnit_Coord &&
                myPosition->mHeight.GetUnit() == eStyleUnit_Coord,
                "styles for :-moz-radio are incorrect or author-accessible");
   nscoord width = myPosition->mWidth.GetCoordValue();
   nscoord height = myPosition->mHeight.GetCoordValue();
   // Position the button centered within the radio control's rectangle.
@@ -149,17 +148,17 @@ nsGfxRadioControlFrame::PaintRadioButton
   // XXXldb It would make more sense to use
   // |aRenderingContext.FillEllipse| here, but on at least GTK that
   // doesn't draw a round enough circle.
   nsStyleBackground tmpColor     = *myColor;
   tmpColor.mBackgroundColor = color->mColor;
   nsPresContext* pc = PresContext();
   nsCSSRendering::PaintBackgroundWithSC(pc, aRenderingContext,
                                         this, aDirtyRect, rect,
-                                        tmpColor, *myBorder, *myPadding, PR_FALSE);
+                                        tmpColor, *myBorder, PR_FALSE);
   nsCSSRendering::PaintBorder(pc, aRenderingContext, this,
                               aDirtyRect, rect, *myBorder, mRadioButtonFaceStyle, 0);
 }
 
 class nsDisplayRadioButtonFromStyle : public nsDisplayItem {
 public:
   nsDisplayRadioButtonFromStyle(nsGfxRadioControlFrame* aFrame)
     : nsDisplayItem(aFrame) {
--- a/layout/mathml/base/src/nsMathMLChar.cpp
+++ b/layout/mathml/base/src/nsMathMLChar.cpp
@@ -1925,22 +1925,20 @@ private:
   nsStyleContext* mStyleContext;
   nsRect          mRect;
 };
 
 void nsDisplayMathMLCharBackground::Paint(nsDisplayListBuilder* aBuilder,
      nsIRenderingContext* aCtx, const nsRect& aDirtyRect)
 {
   const nsStyleBorder* border = mStyleContext->GetStyleBorder();
-  const nsStylePadding* padding = mStyleContext->GetStylePadding();
   const nsStyleBackground* backg = mStyleContext->GetStyleBackground();
+  nsRect rect(mRect + aBuilder->ToReferenceFrame(mFrame));
   nsCSSRendering::PaintBackgroundWithSC(mFrame->PresContext(), *aCtx, mFrame,
-                                        aDirtyRect,
-                                        mRect + aBuilder->ToReferenceFrame(mFrame),
-                                        *backg, *border, *padding,
+                                        aDirtyRect, rect, *backg, *border,
                                         PR_TRUE);
 }
 
 class nsDisplayMathMLCharForeground : public nsDisplayItem {
 public:
   nsDisplayMathMLCharForeground(nsIFrame* aFrame, nsMathMLChar* aChar,
 				PRBool aIsSelected)
     : nsDisplayItem(aFrame), mChar(aChar), mIsSelected(aIsSelected) {
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -1201,10 +1201,10 @@ nsBCTableCellFrame::PaintBackground(nsIR
   }
 
   nsRect rect(aPt, GetSize());
   // bypassing nsCSSRendering::PaintBackground is safe because this kind
   // of frame cannot be used for the root element
   nsCSSRendering::PaintBackgroundWithSC(PresContext(), aRenderingContext, this,
                                         aDirtyRect, rect,
                                         *GetStyleBackground(), myBorder,
-                                        *GetStylePadding(), PR_TRUE, nsnull);
+                                        PR_TRUE, nsnull);
 }
--- a/layout/tables/nsTablePainter.cpp
+++ b/layout/tables/nsTablePainter.cpp
@@ -235,18 +235,16 @@ TableBackgroundPainter::TableBackgroundP
 {
   MOZ_COUNT_CTOR(TableBackgroundPainter);
 
   NS_FOR_CSS_SIDES(side) {
     mZeroBorder.SetBorderStyle(side, NS_STYLE_BORDER_STYLE_SOLID);
     mZeroBorder.SetBorderWidth(side, 0);
   }
 
-  mZeroPadding.RecalcData();
-
   mIsBorderCollapse = aTableFrame->IsBorderCollapse();
 #ifdef DEBUG
   mCompatMode = mPresContext->CompatibilityMode();
 #endif
   mNumCols = aTableFrame->GetColCount();
 }
 
 TableBackgroundPainter::~TableBackgroundPainter()
@@ -315,17 +313,17 @@ TableBackgroundPainter::PaintTableFrame(
     }
   }
   if (tableData.IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                           tableData.mFrame, mDirtyRect,
                                           tableData.mRect + mRenderPt,
                                           *tableData.mBackground,
                                           *tableData.mBorder,
-                                          mZeroPadding, PR_TRUE);
+                                          PR_TRUE);
   }
   tableData.Destroy(mPresContext);
   return NS_OK;
 }
 
 void
 TableBackgroundPainter::TranslateContext(nscoord aDX,
                                          nscoord aDY)
@@ -620,45 +618,45 @@ TableBackgroundPainter::PaintCell(nsTabl
 
   //Paint column group background
   if (mCols && mCols[colIndex].mColGroup && mCols[colIndex].mColGroup->IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                           mCols[colIndex].mColGroup->mFrame, mDirtyRect,
                                           mCols[colIndex].mColGroup->mRect + mRenderPt,
                                           *mCols[colIndex].mColGroup->mBackground,
                                           *mCols[colIndex].mColGroup->mBorder,
-                                          mZeroPadding, PR_TRUE, &mCellRect);
+                                          PR_TRUE, &mCellRect);
   }
 
   //Paint column background
   if (mCols && mCols[colIndex].mCol.IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                           mCols[colIndex].mCol.mFrame, mDirtyRect,
                                           mCols[colIndex].mCol.mRect + mRenderPt,
                                           *mCols[colIndex].mCol.mBackground,
                                           *mCols[colIndex].mCol.mBorder,
-                                          mZeroPadding, PR_TRUE, &mCellRect);
+                                          PR_TRUE, &mCellRect);
   }
 
   //Paint row group background
   if (mRowGroup.IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                           mRowGroup.mFrame, mDirtyRect,
                                           mRowGroup.mRect + mRenderPt,
                                           *mRowGroup.mBackground, *mRowGroup.mBorder,
-                                          mZeroPadding, PR_TRUE, &mCellRect);
+                                          PR_TRUE, &mCellRect);
   }
 
   //Paint row background
   if (mRow.IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                           mRow.mFrame, mDirtyRect,
                                           mRow.mRect + mRenderPt,
                                           *mRow.mBackground, *mRow.mBorder,
-                                          mZeroPadding, PR_TRUE, &mCellRect);
+                                          PR_TRUE, &mCellRect);
   }
 
   //Paint cell background in border-collapse unless we're just passing
   if (mIsBorderCollapse && !aPassSelf) {
     aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
                                mCellRect.TopLeft());
   }
 
--- a/layout/tables/nsTablePainter.h
+++ b/layout/tables/nsTablePainter.h
@@ -236,15 +236,12 @@ class TableBackgroundPainter
     Origin               mOrigin; //user's table frame type
 
     ColData*             mCols;  //array of columns' ColData
     PRUint32             mNumCols;
     TableBackgroundData  mRowGroup; //current row group
     TableBackgroundData  mRow;      //current row
     nsRect               mCellRect; //current cell's rect
 
-
     nsStyleBorder        mZeroBorder;  //cached zero-width border
-    nsStylePadding       mZeroPadding; //cached zero-width padding
-
 };
 
 #endif
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -3837,23 +3837,21 @@ void
 nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext*      aStyleContext,
                                       nsPresContext*      aPresContext,
                                       nsIRenderingContext& aRenderingContext,
                                       const nsRect&        aRect,
                                       const nsRect&        aDirtyRect)
 {
   const nsStyleBackground* myColor = aStyleContext->GetStyleBackground();
   const nsStyleBorder* myBorder = aStyleContext->GetStyleBorder();
-  const nsStylePadding* myPadding = aStyleContext->GetStylePadding();
   const nsStyleOutline* myOutline = aStyleContext->GetStyleOutline();
   
   nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext,
                                         this, aDirtyRect, aRect,
-                                        *myColor, *myBorder, *myPadding,
-                                        PR_TRUE);
+                                        *myColor, *myBorder, PR_TRUE);
 
   nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
                               aDirtyRect, aRect, *myBorder, mStyleContext);
 
   nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
                                aDirtyRect, aRect, *myBorder, *myOutline,
                                aStyleContext);
 }