Backing out bug 421069 (which I landed earlier today for roc) because it caused bug 424016.
authordbaron@dbaron.org
Wed, 19 Mar 2008 22:58:00 -0700
changeset 13365 899c36aa508cb380bb878a240cfbd548c582d69b
parent 13364 f31e4968efb1217b096325108d1a27f6163466f8
child 13366 074ebfba009c6fc45103074534181e4742a12d23
push idunknown
push userunknown
push dateunknown
bugs421069, 424016
milestone1.9b5pre
Backing out bug 421069 (which I landed earlier today for roc) because it caused bug 424016.
layout/tables/nsTableFrame.cpp
layout/tables/nsTablePainter.cpp
layout/tables/nsTablePainter.h
layout/tables/nsTableRowFrame.cpp
layout/tables/nsTableRowGroupFrame.cpp
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -1391,20 +1391,22 @@ nsTableFrame::BuildDisplayList(nsDisplay
 // XXX We don't put the borders and backgrounds in tree order like we should.
 // That requires some major surgery which we aren't going to do right now.
 void
 nsTableFrame::PaintTableBorderBackground(nsIRenderingContext& aRenderingContext,
                                          const nsRect& aDirtyRect,
                                          nsPoint aPt)
 {
   nsPresContext* presContext = PresContext();
+  nsRect dirtyRect = aDirtyRect - aPt;
+  nsIRenderingContext::AutoPushTranslation
+    translate(&aRenderingContext, aPt.x, aPt.y);
 
   TableBackgroundPainter painter(this, TableBackgroundPainter::eOrigin_Table,
-                                 presContext, aRenderingContext,
-                                 aDirtyRect, aPt);
+                                 presContext, aRenderingContext, dirtyRect);
   nsresult rv;
   
   if (eCompatibility_NavQuirks == presContext->CompatibilityMode()) {
     nsMargin deflate(0,0,0,0);
     if (IsBorderCollapse()) {
       PRInt32 p2t = nsPresContext::AppUnitsPerCSSPixel();
       BCPropertyData* propData =
         (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)this,
@@ -1422,28 +1424,25 @@ nsTableFrame::PaintTableBorderBackground
   }
   else {
     rv = painter.PaintTable(this, nsnull);
     if (NS_FAILED(rv)) return;
   }
 
   if (GetStyleVisibility()->IsVisible()) {
     const nsStyleBorder* border = GetStyleBorder();
+    nsRect  rect(0, 0, mRect.width, mRect.height);
     if (!IsBorderCollapse()) {
       PRIntn skipSides = GetSkipSides();
-      nsRect rect(aPt, mRect.Size());
       nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
-                                  aDirtyRect, rect, *border, mStyleContext,
+                                  dirtyRect, rect, *border, mStyleContext,
                                   skipSides);
     }
     else {
-      // XXX we should probably get rid of this translation at some stage
-      // But that would mean modifying PaintBCBorders, ugh
-      nsIRenderingContext::AutoPushTranslation translate(&aRenderingContext, aPt.x, aPt.y);
-      PaintBCBorders(aRenderingContext, aDirtyRect - aPt);
+      PaintBCBorders(aRenderingContext, dirtyRect);
     }
   }
 }
 
 //null range means the whole thing
 NS_IMETHODIMP
 nsTableFrame::SetSelected(nsPresContext* aPresContext,
                           nsIDOMRange *aRange,
--- a/layout/tables/nsTablePainter.cpp
+++ b/layout/tables/nsTablePainter.cpp
@@ -218,21 +218,19 @@ TableBackgroundPainter::TableBackgroundD
   mBorder = mSynthBorder;
   return NS_OK;
 }
 
 TableBackgroundPainter::TableBackgroundPainter(nsTableFrame*        aTableFrame,
                                                Origin               aOrigin,
                                                nsPresContext*       aPresContext,
                                                nsIRenderingContext& aRenderingContext,
-                                               const nsRect&        aDirtyRect,
-                                               const nsPoint&       aRenderPt)
+                                               const nsRect&        aDirtyRect)
   : mPresContext(aPresContext),
     mRenderingContext(aRenderingContext),
-    mRenderPt(aRenderPt),
     mDirtyRect(aDirtyRect),
     mOrigin(aOrigin),
     mCols(nsnull),
     mZeroBorder(aPresContext)
 {
   MOZ_COUNT_CTOR(TableBackgroundPainter);
 
   NS_FOR_CSS_SIDES(side) {
@@ -312,30 +310,31 @@ TableBackgroundPainter::PaintTableFrame(
         tableData.Destroy(mPresContext);
         return rv;
       }
     }
   }
   if (tableData.IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                           tableData.mFrame, mDirtyRect,
-                                          tableData.mRect + mRenderPt,
+                                          tableData.mRect,
                                           *tableData.mBackground,
                                           *tableData.mBorder,
                                           mZeroPadding, PR_TRUE);
   }
   tableData.Destroy(mPresContext);
   return NS_OK;
 }
 
 void
 TableBackgroundPainter::TranslateContext(nscoord aDX,
                                          nscoord aDY)
 {
-  mRenderPt += nsPoint(aDX, aDY);
+  mRenderingContext.Translate(aDX, aDY);
+  mDirtyRect.MoveBy(-aDX, -aDY);
   if (mCols) {
     TableBackgroundData* lastColGroup = nsnull;
     for (PRUint32 i = 0; i < mNumCols; i++) {
       mCols[i].mCol.mRect.MoveBy(-aDX, -aDY);
       if (lastColGroup != mCols[i].mColGroup) {
         NS_ASSERTION(mCols[i].mColGroup, "colgroup data should not be null - bug 237421");
         // we need to wallpaper a over zero pointer deref, bug 237421 will have the real fix
         if (!mCols[i].mColGroup)
@@ -437,17 +436,17 @@ TableBackgroundPainter::PaintTable(nsTab
   }
 
   for (PRUint32 i = 0; i < rowGroups.Length(); i++) {
     nsTableRowGroupFrame* rg = rowGroups[i];
     mRowGroup.SetFrame(rg);
     // Need to compute the right rect via GetOffsetTo, since the row
     // group may not be a child of the table.
     mRowGroup.mRect.MoveTo(rg->GetOffsetTo(aTableFrame));
-    if (mRowGroup.mRect.Intersects(mDirtyRect - mRenderPt)) {
+    if (mRowGroup.mRect.Intersects(mDirtyRect)) {
       nsresult rv = PaintRowGroup(rg, rg->IsPseudoStackingContextFromStyle());
       if (NS_FAILED(rv)) return rv;
     }
   }
   return NS_OK;
 }
 
 nsresult
@@ -491,20 +490,19 @@ TableBackgroundPainter::PaintRowGroup(ns
 
   /* Find the right row to start with */
   nscoord ignored; // We don't care about overflow above, since what we really
                    // care about are backgrounds and overflow above doesn't
                    // correspond to backgrounds, since cells can't span up from
                    // their originating row.  We do care about overflow below,
                    // however, since that can be due to rowspans.
 
-  // Note that mDirtyRect  - mRenderPt is guaranteed to be in the row
-  // group's coordinate system here, so passing its .y to
-  // GetFirstRowContaining is ok.
-  nsIFrame* cursor = aFrame->GetFirstRowContaining(mDirtyRect.y - mRenderPt.y, &ignored);
+  // Note that mDirtyRect is guaranteed to be in the row group's coordinate
+  // system here, so passing its .y to GetFirstRowContaining is ok.
+  nsIFrame* cursor = aFrame->GetFirstRowContaining(mDirtyRect.y, &ignored);
 
   // Sadly, it seems like there may be non-row frames in there... or something?
   // There are certainly null-checks in GetFirstRow() and GetNextRow().  :(
   while (cursor && cursor->GetType() != nsGkAtoms::tableRowFrame) {
     cursor = cursor->GetNextSibling();
   }
 
   // It's OK if cursor is null here.
@@ -515,17 +513,17 @@ TableBackgroundPainter::PaintRowGroup(ns
     // list for the rowgroup, so not having a cursor means that there's some
     // good reason we don't have a cursor and we shouldn't create one here.
     row = firstRow;
   }
   
   /* Finally paint */
   for (; row; row = row->GetNextRow()) {
     mRow.SetFrame(row);
-    if (mDirtyRect.YMost() - mRenderPt.y < mRow.mRect.y) { // Intersect wouldn't handle
+    if (mDirtyRect.YMost() < mRow.mRect.y) { // Intersect wouldn't handle
                                              // rowspans.
 
       // All done; cells originating in later rows can't intersect mDirtyRect.
       break;
     }
     
     nsresult rv = PaintRow(row, aPassThrough || row->IsPseudoStackingContextFromStyle());
     if (NS_FAILED(rv)) return rv;
@@ -582,17 +580,17 @@ TableBackgroundPainter::PaintRow(nsTable
     mRow.mRect.MoveTo(0, 0);
   }
   //else: Use row group's coord system -> no translation necessary
 
   for (nsTableCellFrame* cell = aFrame->GetFirstCell(); cell; cell = cell->GetNextCell()) {
     mCellRect = cell->GetRect();
     //Translate to use the same coord system as mRow.
     mCellRect.MoveBy(mRow.mRect.x, mRow.mRect.y);
-    if (mCellRect.Intersects(mDirtyRect - mRenderPt)) {
+    if (mCellRect.Intersects(mDirtyRect)) {
       nsresult rv = PaintCell(cell, aPassThrough || cell->IsPseudoStackingContextFromStyle());
       if (NS_FAILED(rv)) return rv;
     }
   }
 
   /* Unload row data */
   mRow.Clear();
   return NS_OK;
@@ -614,50 +612,47 @@ TableBackgroundPainter::PaintCell(nsTabl
 
   PRInt32 colIndex;
   aCell->GetColIndex(colIndex);
 
   //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->mRect,
                                           *mCols[colIndex].mColGroup->mBackground,
                                           *mCols[colIndex].mColGroup->mBorder,
                                           mZeroPadding, 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.mRect,
                                           *mCols[colIndex].mCol.mBackground,
                                           *mCols[colIndex].mCol.mBorder,
                                           mZeroPadding, PR_TRUE, &mCellRect);
   }
 
   //Paint row group background
   if (mRowGroup.IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
-                                          mRowGroup.mFrame, mDirtyRect,
-                                          mRowGroup.mRect + mRenderPt,
+                                          mRowGroup.mFrame, mDirtyRect, mRowGroup.mRect,
                                           *mRowGroup.mBackground, *mRowGroup.mBorder,
                                           mZeroPadding, PR_TRUE, &mCellRect);
   }
 
   //Paint row background
   if (mRow.IsVisible()) {
     nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
-                                          mRow.mFrame, mDirtyRect,
-                                          mRow.mRect + mRenderPt,
+                                          mRow.mFrame, mDirtyRect, mRow.mRect,
                                           *mRow.mBackground, *mRow.mBorder,
                                           mZeroPadding, PR_TRUE, &mCellRect);
   }
 
   //Paint cell background in border-collapse unless we're just passing
   if (mIsBorderCollapse && !aPassSelf) {
-    aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
-            mRenderPt + mCellRect.TopLeft());
+    aCell->PaintCellBackground(mRenderingContext, mDirtyRect, mCellRect.TopLeft());
   }
 
   return NS_OK;
 }
--- a/layout/tables/nsTablePainter.h
+++ b/layout/tables/nsTablePainter.h
@@ -63,27 +63,23 @@ class TableBackgroundPainter
 
     enum Origin { eOrigin_Table, eOrigin_TableRowGroup, eOrigin_TableRow };
 
     /** Public constructor
       * @param aTableFrame       - the table's table frame
       * @param aOrigin           - what type of table frame is creating this instance
       * @param aPresContext      - the presentation context
       * @param aRenderingContext - the rendering context
-      * @param aDirtyRect        - the area that needs to be painted,
-      * relative to aRenderingContext
-      * @param aPt               - offset of the table frame relative to
-      * aRenderingContext
+      * @param aDirtyRect        - the area that needs to be painted
       */
     TableBackgroundPainter(nsTableFrame*        aTableFrame,
                            Origin               aOrigin,
                            nsPresContext*       aPresContext,
                            nsIRenderingContext& aRenderingContext,
-                           const nsRect&        aDirtyRect,
-                           const nsPoint&       aPt);
+                           const nsRect&        aDirtyRect);
 
     /** Destructor */
     ~TableBackgroundPainter();
 
     /* ~*~ The Border Collapse Painting Issue ~*~
 
        In border-collapse, the *table* paints the cells' borders,
        so we need to make sure the backgrounds get painted first
@@ -222,17 +218,16 @@ class TableBackgroundPainter
       TableBackgroundData* mColGroup; //link to col's parent colgroup's data (owned by painter)
       ColData() {
         mColGroup = nsnull;
       }
     };
 
     nsPresContext*      mPresContext;
     nsIRenderingContext& mRenderingContext;
-    nsPoint              mRenderPt;
     nsRect               mDirtyRect;
 #ifdef DEBUG
     nsCompatibility      mCompatMode;
 #endif
     PRBool               mIsBorderCollapse;
     Origin               mOrigin; //user's table frame type
 
     ColData*             mCols;  //array of columns' ColData
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -569,20 +569,21 @@ public:
 };
 
 void
 nsDisplayTableRowBackground::Paint(nsDisplayListBuilder* aBuilder,
     nsIRenderingContext* aCtx, const nsRect& aDirtyRect) {
   nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(mFrame);
 
   nsPoint pt = aBuilder->ToReferenceFrame(mFrame);
+  nsIRenderingContext::AutoPushTranslation translate(aCtx, pt.x, pt.y);
   TableBackgroundPainter painter(tableFrame,
                                  TableBackgroundPainter::eOrigin_TableRow,
                                  mFrame->PresContext(), *aCtx,
-                                 aDirtyRect, pt);
+                                 aDirtyRect - pt);
   painter.PaintRow(static_cast<nsTableRowFrame*>(mFrame));
 }
 
 NS_IMETHODIMP
 nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                   const nsRect&           aDirtyRect,
                                   const nsDisplayListSet& aLists)
 {
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -188,20 +188,21 @@ nsTableRowGroupFrame::InitRepeatedFrame(
 }
 
 static void
 PaintRowGroupBackground(nsIFrame* aFrame, nsIRenderingContext* aCtx,
                         const nsRect& aDirtyRect, nsPoint aPt)
 {
   nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(aFrame);
 
+  nsIRenderingContext::AutoPushTranslation translate(aCtx, aPt.x, aPt.y);
   TableBackgroundPainter painter(tableFrame,
                                  TableBackgroundPainter::eOrigin_TableRowGroup,
                                  aFrame->PresContext(), *aCtx,
-                                 aDirtyRect, aPt);
+                                 aDirtyRect - aPt);
   painter.PaintRowGroup(static_cast<nsTableRowGroupFrame*>(aFrame));
 }
 
 // Handle the child-traversal part of DisplayGenericTablePart
 static nsresult
 DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
             const nsRect& aDirtyRect, const nsDisplayListSet& aLists)
 {