remove table background quirk use standards painting instead bug 237078 patch by [email protected] r=bernd sr=dbaron

crash prevention when colframes return bogus colindices bug 240854 r/sr=bzbarsky
This commit is contained in:
[email protected] committed 2004-04-18 18:17:00 +00:00
1 parent 5608945d45
commit 1499465b6c
12 files changed
+74 -236

No files matched your search

-4
View File
@@ -110,10 +110,6 @@ table {
font-variant: -moz-initial;
}
/* make sure backgrounds are inherited in tables -- see bug 4510*/
td, th, tr {
background: inherit;
}
/* Quirk: collapse top margin of BODY and TD and bottom margin of TD */
+2 -2
View File
@@ -1420,11 +1420,11 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
deflate.left = BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth);
}
}
rv = painter.QuirksPaintTable(this, deflate);
rv = painter.PaintTable(this, &deflate);
if (NS_FAILED(rv)) return rv;
}
else {
rv = painter.PaintTable(this);
rv = painter.PaintTable(this, nsnull);
if (NS_FAILED(rv)) return rv;
}
+9 -67
View File
@@ -44,9 +44,9 @@
#include "nsTablePainter.h"
#include "nsCSSRendering.h"
/* ~*~ Standards Mode Painting ~*~
/* ~*~ Table Background Painting ~*~
Background painting in Standards mode follows CSS2.1:17.5.1
Mozilla's Table Background painting follows CSS2.1:17.5.1
That section does not, however, describe the effect of
borders on background image positioning. What we do is:
@@ -95,12 +95,6 @@
flexibility in aligning /to/ those border widths.
*/
/* ~*~ Quirks Table Background Painting ~*~
Quirks inherits all backgrounds below the table level into the
cells; we don't paint intermediate backgrounds.
*/
/* ~*~ TableBackgroundPainter ~*~
@@ -360,62 +354,10 @@ TableBackgroundPainter::TranslateContext(nscoord aDX,
}
nsresult
TableBackgroundPainter::QuirksPaintTable(nsTableFrame* aTableFrame,
nsMargin& aDeflate)
TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame,
nsMargin* aDeflate)
{
NS_PRECONDITION(aTableFrame, "null table frame");
NS_PRECONDITION(eCompatibility_NavQuirks == mCompatMode,
"QuirksPaintTable called for non-Quirks");
nsVoidArray rowGroups;
PRUint32 numRowGroups;
aTableFrame->OrderRowGroups(rowGroups, numRowGroups);
if (numRowGroups < 1) { //degenerate case
PaintTableFrame(aTableFrame,nsnull, nsnull, &aDeflate);
/* No cells; nothing else to paint */
return NS_OK;
}
PaintTableFrame(aTableFrame,
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(0))),
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(numRowGroups - 1))),
&aDeflate);
if (mIsBorderCollapse) {
/* This is a simple pass, so we'll just keep with the table coord system. */
for (PRUint32 i = 0; i < numRowGroups; i++) {
nsTableRowGroupFrame* rg = aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(i)));
nsRect rgRect = rg->GetRect();
if (rgRect.Intersects(mDirtyRect) && !rg->HasView()) {
for (nsTableRowFrame* row = rg->GetFirstRow(); row; row = row->GetNextRow()) {
nsRect rowRect = row->GetRect();
rowRect.MoveBy(rgRect.x, rgRect.y);
if (mDirtyRect.YMost() > rowRect.y && //Intersect won't handle rowspans
!row->HasView()) {
for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) {
mCellRect = cell->GetRect();
mCellRect.MoveBy(rowRect.x, rowRect.y);
if (mCellRect.Intersects(mDirtyRect) && !cell->HasView()) {
nsresult rv = PaintCell(cell, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
}
}
}
}
}
}
return NS_OK;
}
nsresult
TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame)
{
NS_PRECONDITION(aTableFrame, "null table frame");
NS_PRECONDITION(eCompatibility_NavQuirks != mCompatMode,
"must call QuirksPaintTable in Quirks mode, not PaintTable");
nsVoidArray rowGroups;
PRUint32 numRowGroups;
@@ -430,7 +372,7 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame)
PaintTableFrame(aTableFrame,
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(0))),
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(numRowGroups - 1))),
nsnull);
aDeflate);
/*Set up column background/border data*/
if (mNumCols > 0) {
@@ -475,6 +417,9 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame)
col = NS_STATIC_CAST(nsTableColFrame*, col->GetNextSibling())) {
/*Create data struct for column*/
PRUint32 colIndex = col->GetColIndex();
NS_ASSERTION(colIndex < mNumCols, "prevent array boundary violation");
if (mNumCols <= colIndex)
break;
mCols[colIndex].mCol.SetFull(mPresContext, mRenderingContext, col);
//Bring column mRect into table's coord system
mCols[colIndex].mCol.mRect.MoveBy(cgData->mRect.x, cgData->mRect.y);
@@ -510,8 +455,6 @@ TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame,
PRBool aPassThrough)
{
NS_PRECONDITION(aFrame, "null frame");
NS_PRECONDITION(eCompatibility_NavQuirks != mCompatMode,
"must not call PaintRowGroup in Quirks mode");
nsTableRowFrame* firstRow = aFrame->GetFirstRow();
@@ -570,8 +513,7 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame,
PRBool aPassThrough)
{
NS_PRECONDITION(aFrame, "null frame");
NS_PRECONDITION(eCompatibility_NavQuirks != mCompatMode,
"must not call PaintRow in Quirks mode");
/* Load row data */
if (!aPassThrough) {
mRow.SetFull(mPresContext, mRenderingContext, aFrame);
+6 -19
View File
@@ -94,15 +94,13 @@ class TableBackgroundPainter
In border-collapse, the *table* paints the cells' borders,
so we need to make sure the backgrounds get painted first
(underneath) by doing a cell-background-only painting pass.
This happens in both Standards and Quirks mode PaintTable
calls.
The table must then do a no-cell-background pass that
continues as a normal background paint call in the cell
descendants.) This method doesn't handle views very well, but
then, nothing about BC table painting really does.
descendants.) This method doesn't handle views very well,
but then, nothing about BC table painting really does.
*/
/* ~*~ Using Standards Mode Painting ~*~
/* ~*~ Using nsTablePainter Background Painting ~*~
A call to PaintTable will normally paint all of the table's
elements (except the cells in non-BC). Elements with views
@@ -113,12 +111,13 @@ class TableBackgroundPainter
/** Paint background for the table frame and its children down through cells
* (Cells themselves will only be painted in border collapse)
* Standards mode only
* Table must do a flagged TABLE_BG_PAINT ::Paint call on its
* children afterwards
* @param aTableFrame - the table frame
* @param aDeflate - deflation needed to bring table's mRect
* to the outer grid lines in border-collapse
*/
nsresult PaintTable(nsTableFrame* aTableFrame);
nsresult PaintTable(nsTableFrame* aTableFrame, nsMargin* aDeflate);
/** Paint background for the row group and its children down through cells
* (Cells themselves will only be painted in border collapse)
@@ -140,18 +139,6 @@ class TableBackgroundPainter
nsresult PaintRow(nsTableRowFrame* aFrame)
{ return PaintRow(aFrame, PR_FALSE); }
/** Paint table's background, Quirks mode only
* Cell backgrounds will also be painted in border collapse:
* Table must do a flagged TABLE_BG_PAINT on its children
* afterwards.
* @param aTableFrame - the table frame
* @param aDeflate - deflation needed to bring table's mRect
* to the outer grid lines in border-collapse
*/
nsresult QuirksPaintTable(nsTableFrame* aTableFrame,
nsMargin& aDeflate);
private:
/** Paint table frame's background
+10 -13
View File
@@ -545,20 +545,17 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
//direct (not table-called) background paint
!(aFlags & (NS_PAINT_FLAG_TABLE_BG_PAINT | NS_PAINT_FLAG_TABLE_CELL_BG_PASS))) {
//Quirks inherits bg into cells & paints them there
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode()) {
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRow,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRow(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRow,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRow(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
PRUint8 overflow = GetStyleDisplay()->mOverflow;
+10 -13
View File
@@ -207,20 +207,17 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
//direct (not table-called) background paint
!(aFlags & (NS_PAINT_FLAG_TABLE_BG_PAINT | NS_PAINT_FLAG_TABLE_CELL_BG_PASS))) {
//Quirks inherits bg into cells & paints them there
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode()) {
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRowGroup,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRowGroup(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRowGroup,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRowGroup(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
PRUint8 overflow = GetStyleDisplay()->mOverflow;
-4
View File
@@ -110,10 +110,6 @@ table {
font-variant: -moz-initial;
}
/* make sure backgrounds are inherited in tables -- see bug 4510*/
td, th, tr {
background: inherit;
}
/* Quirk: collapse top margin of BODY and TD and bottom margin of TD */
+2 -2
View File
@@ -1420,11 +1420,11 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
deflate.left = BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth);
}
}
rv = painter.QuirksPaintTable(this, deflate);
rv = painter.PaintTable(this, &deflate);
if (NS_FAILED(rv)) return rv;
}
else {
rv = painter.PaintTable(this);
rv = painter.PaintTable(this, nsnull);
if (NS_FAILED(rv)) return rv;
}
+9 -67
View File
@@ -44,9 +44,9 @@
#include "nsTablePainter.h"
#include "nsCSSRendering.h"
/* ~*~ Standards Mode Painting ~*~
/* ~*~ Table Background Painting ~*~
Background painting in Standards mode follows CSS2.1:17.5.1
Mozilla's Table Background painting follows CSS2.1:17.5.1
That section does not, however, describe the effect of
borders on background image positioning. What we do is:
@@ -95,12 +95,6 @@
flexibility in aligning /to/ those border widths.
*/
/* ~*~ Quirks Table Background Painting ~*~
Quirks inherits all backgrounds below the table level into the
cells; we don't paint intermediate backgrounds.
*/
/* ~*~ TableBackgroundPainter ~*~
@@ -360,62 +354,10 @@ TableBackgroundPainter::TranslateContext(nscoord aDX,
}
nsresult
TableBackgroundPainter::QuirksPaintTable(nsTableFrame* aTableFrame,
nsMargin& aDeflate)
TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame,
nsMargin* aDeflate)
{
NS_PRECONDITION(aTableFrame, "null table frame");
NS_PRECONDITION(eCompatibility_NavQuirks == mCompatMode,
"QuirksPaintTable called for non-Quirks");
nsVoidArray rowGroups;
PRUint32 numRowGroups;
aTableFrame->OrderRowGroups(rowGroups, numRowGroups);
if (numRowGroups < 1) { //degenerate case
PaintTableFrame(aTableFrame,nsnull, nsnull, &aDeflate);
/* No cells; nothing else to paint */
return NS_OK;
}
PaintTableFrame(aTableFrame,
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(0))),
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(numRowGroups - 1))),
&aDeflate);
if (mIsBorderCollapse) {
/* This is a simple pass, so we'll just keep with the table coord system. */
for (PRUint32 i = 0; i < numRowGroups; i++) {
nsTableRowGroupFrame* rg = aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(i)));
nsRect rgRect = rg->GetRect();
if (rgRect.Intersects(mDirtyRect) && !rg->HasView()) {
for (nsTableRowFrame* row = rg->GetFirstRow(); row; row = row->GetNextRow()) {
nsRect rowRect = row->GetRect();
rowRect.MoveBy(rgRect.x, rgRect.y);
if (mDirtyRect.YMost() > rowRect.y && //Intersect won't handle rowspans
!row->HasView()) {
for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) {
mCellRect = cell->GetRect();
mCellRect.MoveBy(rowRect.x, rowRect.y);
if (mCellRect.Intersects(mDirtyRect) && !cell->HasView()) {
nsresult rv = PaintCell(cell, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
}
}
}
}
}
}
return NS_OK;
}
nsresult
TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame)
{
NS_PRECONDITION(aTableFrame, "null table frame");
NS_PRECONDITION(eCompatibility_NavQuirks != mCompatMode,
"must call QuirksPaintTable in Quirks mode, not PaintTable");
nsVoidArray rowGroups;
PRUint32 numRowGroups;
@@ -430,7 +372,7 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame)
PaintTableFrame(aTableFrame,
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(0))),
aTableFrame->GetRowGroupFrame(NS_STATIC_CAST(nsIFrame*, rowGroups.ElementAt(numRowGroups - 1))),
nsnull);
aDeflate);
/*Set up column background/border data*/
if (mNumCols > 0) {
@@ -475,6 +417,9 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame)
col = NS_STATIC_CAST(nsTableColFrame*, col->GetNextSibling())) {
/*Create data struct for column*/
PRUint32 colIndex = col->GetColIndex();
NS_ASSERTION(colIndex < mNumCols, "prevent array boundary violation");
if (mNumCols <= colIndex)
break;
mCols[colIndex].mCol.SetFull(mPresContext, mRenderingContext, col);
//Bring column mRect into table's coord system
mCols[colIndex].mCol.mRect.MoveBy(cgData->mRect.x, cgData->mRect.y);
@@ -510,8 +455,6 @@ TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame,
PRBool aPassThrough)
{
NS_PRECONDITION(aFrame, "null frame");
NS_PRECONDITION(eCompatibility_NavQuirks != mCompatMode,
"must not call PaintRowGroup in Quirks mode");
nsTableRowFrame* firstRow = aFrame->GetFirstRow();
@@ -570,8 +513,7 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame,
PRBool aPassThrough)
{
NS_PRECONDITION(aFrame, "null frame");
NS_PRECONDITION(eCompatibility_NavQuirks != mCompatMode,
"must not call PaintRow in Quirks mode");
/* Load row data */
if (!aPassThrough) {
mRow.SetFull(mPresContext, mRenderingContext, aFrame);
+6 -19
View File
@@ -94,15 +94,13 @@ class TableBackgroundPainter
In border-collapse, the *table* paints the cells' borders,
so we need to make sure the backgrounds get painted first
(underneath) by doing a cell-background-only painting pass.
This happens in both Standards and Quirks mode PaintTable
calls.
The table must then do a no-cell-background pass that
continues as a normal background paint call in the cell
descendants.) This method doesn't handle views very well, but
then, nothing about BC table painting really does.
descendants.) This method doesn't handle views very well,
but then, nothing about BC table painting really does.
*/
/* ~*~ Using Standards Mode Painting ~*~
/* ~*~ Using nsTablePainter Background Painting ~*~
A call to PaintTable will normally paint all of the table's
elements (except the cells in non-BC). Elements with views
@@ -113,12 +111,13 @@ class TableBackgroundPainter
/** Paint background for the table frame and its children down through cells
* (Cells themselves will only be painted in border collapse)
* Standards mode only
* Table must do a flagged TABLE_BG_PAINT ::Paint call on its
* children afterwards
* @param aTableFrame - the table frame
* @param aDeflate - deflation needed to bring table's mRect
* to the outer grid lines in border-collapse
*/
nsresult PaintTable(nsTableFrame* aTableFrame);
nsresult PaintTable(nsTableFrame* aTableFrame, nsMargin* aDeflate);
/** Paint background for the row group and its children down through cells
* (Cells themselves will only be painted in border collapse)
@@ -140,18 +139,6 @@ class TableBackgroundPainter
nsresult PaintRow(nsTableRowFrame* aFrame)
{ return PaintRow(aFrame, PR_FALSE); }
/** Paint table's background, Quirks mode only
* Cell backgrounds will also be painted in border collapse:
* Table must do a flagged TABLE_BG_PAINT on its children
* afterwards.
* @param aTableFrame - the table frame
* @param aDeflate - deflation needed to bring table's mRect
* to the outer grid lines in border-collapse
*/
nsresult QuirksPaintTable(nsTableFrame* aTableFrame,
nsMargin& aDeflate);
private:
/** Paint table frame's background
+10 -13
View File
@@ -545,20 +545,17 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
//direct (not table-called) background paint
!(aFlags & (NS_PAINT_FLAG_TABLE_BG_PAINT | NS_PAINT_FLAG_TABLE_CELL_BG_PASS))) {
//Quirks inherits bg into cells & paints them there
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode()) {
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRow,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRow(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRow,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRow(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
PRUint8 overflow = GetStyleDisplay()->mOverflow;
+10 -13
View File
@@ -207,20 +207,17 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
//direct (not table-called) background paint
!(aFlags & (NS_PAINT_FLAG_TABLE_BG_PAINT | NS_PAINT_FLAG_TABLE_CELL_BG_PASS))) {
//Quirks inherits bg into cells & paints them there
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode()) {
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
NS_ASSERTION(tableFrame, "null table frame");
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRowGroup,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRowGroup(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
TableBackgroundPainter painter(tableFrame,
TableBackgroundPainter::eOrigin_TableRowGroup,
aPresContext, aRenderingContext,
aDirtyRect);
nsresult rv = painter.PaintRowGroup(this);
if (NS_FAILED(rv)) return rv;
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
PRUint8 overflow = GetStyleDisplay()->mOverflow;