bug 127040 - paint backgrounds in correct order when there are collapsed borders. sr=kin, r=dbaron, a=shaver

This commit is contained in:
karnaze%netscape.com 2002-02-26 00:27:42 +00:00
Родитель e7305de97e
Коммит 2017816095
13 изменённых файлов: 254 добавлений и 158 удалений

Просмотреть файл

@ -400,6 +400,9 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
return NS_OK;
}
nsTableFrame* tableFrame = nsnull;
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(rv);
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
const nsStyleVisibility* vis =
@ -407,7 +410,6 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
if (vis->IsVisibleOrCollapsed()) {
const nsStyleBackground* myColor = (const nsStyleBackground*)mStyleContext->GetStyleData(eStyleStruct_Background);
#ifdef OLD_TABLE_SELECTION
myColor = GetColorStyleFromSelection(myColor);
@ -423,27 +425,24 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)cellTableStyle));
nsRect rect(0, 0, mRect.width, mRect.height);
// draw the background except when the cell is empty and 'empty-cells: hide' is set
if (!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND == cellTableStyle->mEmptyCells) {
// Draw the background for collapsed borders only during pass1. Draw the backgrounds
// when the cell is not empty or when showing empty cells or backgrounds
if ((!tableFrame->IsBorderCollapse() ||
!(aFlags & BORDER_COLLAPSE_BACKGROUNDS)) && // unset bit indicates pass1
(!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND == cellTableStyle->mEmptyCells)) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, 0, 0, PR_TRUE);
}
// draw the border except when the cell is empty and 'empty-cells: hide || -moz-show-background' is set
if (!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells) {
// draw the border only for separate borders and only when there is content or showing empty cells
if (!tableFrame->IsBorderCollapse() &&
(!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells)) {
PRIntn skipSides = GetSkipSides();
nsTableFrame* tableFrame = nsnull; // I should be checking my own style context, but border-collapse isn't inheriting correctly
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
if ((NS_SUCCEEDED(rv)) && tableFrame) {
const nsStyleTableBorder* tableStyle;
tableFrame->GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)tableStyle));
if (!tableFrame->IsBorderCollapse()) {
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mStyleContext, skipSides);
}
}
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mStyleContext, skipSides);
}
#ifndef OLD_TABLE_SELECTION
DecorateForSelection(aPresContext, aRenderingContext,myColor); //ignore return value
@ -459,31 +458,38 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
}
#endif
// if the cell originates in a row and/or col that is collapsed, the
// bottom and/or right portion of the cell is painted by translating
// the rendering context.
PRBool clipState;
nsPoint offset;
GetCollapseOffset(aPresContext, offset);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PushState();
aRenderingContext.Translate(offset.x, offset.y);
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
nsClipCombine_kIntersect, clipState);
}
else{
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
// paint the children unless its the background layer, there are collapsed border, and it's pass1
if ( !((NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
tableFrame->IsBorderCollapse() &&
!(aFlags & BORDER_COLLAPSE_BACKGROUNDS)) ) {
// if the cell originates in a row and/or col that is collapsed, the
// bottom and/or right portion of the cell is painted by translating
// the rendering context.
PRBool clipState;
nsPoint offset;
GetCollapseOffset(aPresContext, offset);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PopState(clipState);
}
else {
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
aRenderingContext.PopState(clipState);
aRenderingContext.Translate(offset.x, offset.y);
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
nsClipCombine_kIntersect, clipState);
}
else {
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PopState(clipState);
}
else {
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
aRenderingContext.PopState(clipState);
}
}
}

Просмотреть файл

@ -1437,7 +1437,34 @@ nsTableFrame::GetAdditionalChildListName(PRInt32 aIndex,
return NS_OK;
}
/* SEC: TODO: adjust the rect for captions */
void
nsTableFrame::PaintChildren(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// If overflow is hidden then set the clip rect so that children don't
// leak out of us. Note that because overflow'-clip' only applies to
// the content area we do this after painting the border and background
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
nsHTMLContainerFrame::PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
// table paint code is concerned primarily with borders and bg color
// SEC: TODO: adjust the rect for captions
NS_METHOD
nsTableFrame::Paint(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -1445,37 +1472,41 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
// table paint code is concerned primarily with borders and bg color
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
const nsStyleVisibility* vis =
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
if (vis->IsVisibleOrCollapsed()) {
if (vis && vis->IsVisibleOrCollapsed()) {
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
// paint the column groups and columns
nsIFrame* colGroupFrame = mColGroups.FirstChild();
while (nsnull != colGroupFrame) {
PaintChild(aPresContext, aRenderingContext, aDirtyRect, colGroupFrame, aWhichLayer);
colGroupFrame->GetNextSibling(&colGroupFrame);
}
PRIntn skipSides = GetSkipSides();
if (IsBorderCollapse()) {
PaintBCBorders(aPresContext, aRenderingContext, aDirtyRect);
}
else {
// paint the border here only for separate borders
if (!IsBorderCollapse()) {
PRIntn skipSides = GetSkipSides();
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, mStyleContext, skipSides);
}
}
}
// for collapsed borders paint the backgrounds of cells, but not their contents (that happens below)
PRUint32 flags = aFlags;
if ((NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && IsBorderCollapse()) {
flags &= ~BORDER_COLLAPSE_BACKGROUNDS; // set bit to 0
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, flags);
if ((NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && IsBorderCollapse()) {
// for collapsed borders, paint the borders and then the backgrounds of cell
// contents but not the backgrounds of the cells
PaintBCBorders(aPresContext, aRenderingContext, aDirtyRect);
flags |= BORDER_COLLAPSE_BACKGROUNDS; // set bit to 1
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, flags);
}
#ifdef DEBUG
// for debug...
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
@ -1483,22 +1514,7 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
}
#endif
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// If overflow is hidden then set the clip rect so that children don't
// leak out of us. Note that because overflow'-clip' only applies to
// the content area we do this after painting the border and background
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PopState(clipState);
}
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableFrame", &aRenderingContext, NS_RGB(255,128,255));
return NS_OK;
/*nsFrame::Paint(aPresContext,

Просмотреть файл

@ -61,6 +61,10 @@ struct nsStylePosition;
enum nsPixelRound {eAlwaysRoundUp=0, eAlwaysRoundDown, eRoundUpIfHalfOrMore};
// flags for Paint, PaintChild, PaintChildren are currently only used by tables.
// use low order bit of flags to distinguish between pass1(0) and pass2(1) border collapse backgrounds
#define BORDER_COLLAPSE_BACKGROUNDS 0x00000001
#ifdef DEBUG_TABLE_REFLOW_TIMING
#ifdef WIN32
#include <windows.h>
@ -304,6 +308,12 @@ public:
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0);
virtual void PaintChildren(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0);
nsMargin* GetBCBorder(nsIPresContext& aPresContext,
PRBool aInnerBorderOnly,
nsMargin& aBorder) const;

Просмотреть файл

@ -600,7 +600,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if (disp && (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow)) {
PRBool clipState;
aRenderingContext.PopState(clipState);
@ -650,7 +650,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.Translate(kidRect.x, kidRect.y);
kid->Paint(aPresContext, aRenderingContext, kidDamageArea,
aWhichLayer);
aWhichLayer, aFlags);
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
GetShowFrameBorders()) {

Просмотреть файл

@ -51,8 +51,6 @@ class nsReflowTimer;
#define NS_ROW_NEED_SPECIAL_REFLOW 0x20000000
#define NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT 0x40000000
#define NS_ROW_FRAME_PAINT_SKIP_ROW 0x00000001
#define NS_ROW_FRAME_PAINT_SKIP_CELLS 0x00000002
/**
* nsTableRowFrame is the frame that maps table rows
* (HTML tag TR). This class cannot be reused

Просмотреть файл

@ -235,7 +235,7 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if (disp && (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow)) {
PRBool clipState;
aRenderingContext.PopState(clipState);
@ -284,7 +284,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
damageArea.width, damageArea.height);
aRenderingContext.PushState();
aRenderingContext.Translate(kidRect.x, kidRect.y);
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer);
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer, aFlags);
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
GetShowFrameBorders()) {

Просмотреть файл

@ -0,0 +1,36 @@
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>testcase for bug 127040</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<TABLE style="background-color: green; border-collapse: collapse; border-color:
blue; border-style: solid; border-width: 2px; ">
<TR>
<TD style="background-color: red; border-color: blue; border-width: 2px;
border-style: solid; ">asdf</TD>
<TD style="border-color: blue; border-width: 2px; border-style: solid; ">qwer</TD>
</TR>
<TR>
<TD style="background-color: red; border-color: blue; border-width: 2px;
border-style: solid; ">fdsa</TD>
<TD style="background-color: red; border-color: blue; border-width: 2px;
border-style: solid; ">rewq</TD>
</TR>
<TR>
<TD style="border-color: blue; border-width: 2px; border-style: solid; ">zxcv</TD>
<TD style="border-color: blue; border-width: 2px; border-style: solid; ">uiop</TD>
</TR>
</TABLE>
</body>
</html>

Просмотреть файл

@ -400,6 +400,9 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
return NS_OK;
}
nsTableFrame* tableFrame = nsnull;
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(rv);
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
const nsStyleVisibility* vis =
@ -407,7 +410,6 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
if (vis->IsVisibleOrCollapsed()) {
const nsStyleBackground* myColor = (const nsStyleBackground*)mStyleContext->GetStyleData(eStyleStruct_Background);
#ifdef OLD_TABLE_SELECTION
myColor = GetColorStyleFromSelection(myColor);
@ -423,27 +425,24 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)cellTableStyle));
nsRect rect(0, 0, mRect.width, mRect.height);
// draw the background except when the cell is empty and 'empty-cells: hide' is set
if (!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND == cellTableStyle->mEmptyCells) {
// Draw the background for collapsed borders only during pass1. Draw the backgrounds
// when the cell is not empty or when showing empty cells or backgrounds
if ((!tableFrame->IsBorderCollapse() ||
!(aFlags & BORDER_COLLAPSE_BACKGROUNDS)) && // unset bit indicates pass1
(!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND == cellTableStyle->mEmptyCells)) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, 0, 0, PR_TRUE);
}
// draw the border except when the cell is empty and 'empty-cells: hide || -moz-show-background' is set
if (!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells) {
// draw the border only for separate borders and only when there is content or showing empty cells
if (!tableFrame->IsBorderCollapse() &&
(!GetContentEmpty() ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells)) {
PRIntn skipSides = GetSkipSides();
nsTableFrame* tableFrame = nsnull; // I should be checking my own style context, but border-collapse isn't inheriting correctly
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
if ((NS_SUCCEEDED(rv)) && tableFrame) {
const nsStyleTableBorder* tableStyle;
tableFrame->GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)tableStyle));
if (!tableFrame->IsBorderCollapse()) {
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mStyleContext, skipSides);
}
}
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mStyleContext, skipSides);
}
#ifndef OLD_TABLE_SELECTION
DecorateForSelection(aPresContext, aRenderingContext,myColor); //ignore return value
@ -459,31 +458,38 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
}
#endif
// if the cell originates in a row and/or col that is collapsed, the
// bottom and/or right portion of the cell is painted by translating
// the rendering context.
PRBool clipState;
nsPoint offset;
GetCollapseOffset(aPresContext, offset);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PushState();
aRenderingContext.Translate(offset.x, offset.y);
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
nsClipCombine_kIntersect, clipState);
}
else{
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
// paint the children unless its the background layer, there are collapsed border, and it's pass1
if ( !((NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
tableFrame->IsBorderCollapse() &&
!(aFlags & BORDER_COLLAPSE_BACKGROUNDS)) ) {
// if the cell originates in a row and/or col that is collapsed, the
// bottom and/or right portion of the cell is painted by translating
// the rendering context.
PRBool clipState;
nsPoint offset;
GetCollapseOffset(aPresContext, offset);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PopState(clipState);
}
else {
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
aRenderingContext.PopState(clipState);
aRenderingContext.Translate(offset.x, offset.y);
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
nsClipCombine_kIntersect, clipState);
}
else {
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.PopState(clipState);
}
else {
if ((NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) || HasPctOverHeight()) {
aRenderingContext.PopState(clipState);
}
}
}

Просмотреть файл

@ -1437,7 +1437,34 @@ nsTableFrame::GetAdditionalChildListName(PRInt32 aIndex,
return NS_OK;
}
/* SEC: TODO: adjust the rect for captions */
void
nsTableFrame::PaintChildren(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// If overflow is hidden then set the clip rect so that children don't
// leak out of us. Note that because overflow'-clip' only applies to
// the content area we do this after painting the border and background
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
nsHTMLContainerFrame::PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
// table paint code is concerned primarily with borders and bg color
// SEC: TODO: adjust the rect for captions
NS_METHOD
nsTableFrame::Paint(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -1445,37 +1472,41 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
// table paint code is concerned primarily with borders and bg color
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
const nsStyleVisibility* vis =
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
if (vis->IsVisibleOrCollapsed()) {
if (vis && vis->IsVisibleOrCollapsed()) {
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
// paint the column groups and columns
nsIFrame* colGroupFrame = mColGroups.FirstChild();
while (nsnull != colGroupFrame) {
PaintChild(aPresContext, aRenderingContext, aDirtyRect, colGroupFrame, aWhichLayer);
colGroupFrame->GetNextSibling(&colGroupFrame);
}
PRIntn skipSides = GetSkipSides();
if (IsBorderCollapse()) {
PaintBCBorders(aPresContext, aRenderingContext, aDirtyRect);
}
else {
// paint the border here only for separate borders
if (!IsBorderCollapse()) {
PRIntn skipSides = GetSkipSides();
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, mStyleContext, skipSides);
}
}
}
// for collapsed borders paint the backgrounds of cells, but not their contents (that happens below)
PRUint32 flags = aFlags;
if ((NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && IsBorderCollapse()) {
flags &= ~BORDER_COLLAPSE_BACKGROUNDS; // set bit to 0
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, flags);
if ((NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && IsBorderCollapse()) {
// for collapsed borders, paint the borders and then the backgrounds of cell
// contents but not the backgrounds of the cells
PaintBCBorders(aPresContext, aRenderingContext, aDirtyRect);
flags |= BORDER_COLLAPSE_BACKGROUNDS; // set bit to 1
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, flags);
}
#ifdef DEBUG
// for debug...
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
@ -1483,22 +1514,7 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
}
#endif
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// If overflow is hidden then set the clip rect so that children don't
// leak out of us. Note that because overflow'-clip' only applies to
// the content area we do this after painting the border and background
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PopState(clipState);
}
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableFrame", &aRenderingContext, NS_RGB(255,128,255));
return NS_OK;
/*nsFrame::Paint(aPresContext,

Просмотреть файл

@ -61,6 +61,10 @@ struct nsStylePosition;
enum nsPixelRound {eAlwaysRoundUp=0, eAlwaysRoundDown, eRoundUpIfHalfOrMore};
// flags for Paint, PaintChild, PaintChildren are currently only used by tables.
// use low order bit of flags to distinguish between pass1(0) and pass2(1) border collapse backgrounds
#define BORDER_COLLAPSE_BACKGROUNDS 0x00000001
#ifdef DEBUG_TABLE_REFLOW_TIMING
#ifdef WIN32
#include <windows.h>
@ -304,6 +308,12 @@ public:
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0);
virtual void PaintChildren(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0);
nsMargin* GetBCBorder(nsIPresContext& aPresContext,
PRBool aInnerBorderOnly,
nsMargin& aBorder) const;

Просмотреть файл

@ -600,7 +600,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if (disp && (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow)) {
PRBool clipState;
aRenderingContext.PopState(clipState);
@ -650,7 +650,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.Translate(kidRect.x, kidRect.y);
kid->Paint(aPresContext, aRenderingContext, kidDamageArea,
aWhichLayer);
aWhichLayer, aFlags);
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
GetShowFrameBorders()) {

Просмотреть файл

@ -51,8 +51,6 @@ class nsReflowTimer;
#define NS_ROW_NEED_SPECIAL_REFLOW 0x20000000
#define NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT 0x40000000
#define NS_ROW_FRAME_PAINT_SKIP_ROW 0x00000001
#define NS_ROW_FRAME_PAINT_SKIP_CELLS 0x00000002
/**
* nsTableRowFrame is the frame that maps table rows
* (HTML tag TR). This class cannot be reused

Просмотреть файл

@ -235,7 +235,7 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
if (disp && (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow)) {
PRBool clipState;
aRenderingContext.PopState(clipState);
@ -284,7 +284,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
damageArea.width, damageArea.height);
aRenderingContext.PushState();
aRenderingContext.Translate(kidRect.x, kidRect.y);
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer);
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer, aFlags);
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
GetShowFrameBorders()) {